Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regulator: da9062: refactor buck modes into header

This patch refactors buck modes into a header file so that device trees
can make use of these mode constants.

The new header filename uses da9063 because DA9063 was the earlier chip
and its driver code will want updating at some point in a similar manner.

Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
Link: https://lore.kernel.org/r/1573652416-9848-2-git-send-email-chf.fritz@googlemail.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Christoph Fritz and committed by
Mark Brown
7d34aec5 9ebde17c

+26 -18
+10 -18
drivers/regulator/da9062-regulator.c
··· 16 16 #include <linux/regulator/of_regulator.h> 17 17 #include <linux/mfd/da9062/core.h> 18 18 #include <linux/mfd/da9062/registers.h> 19 + #include <dt-bindings/regulator/dlg,da9063-regulator.h> 19 20 20 21 /* Regulator IDs */ 21 22 enum { ··· 76 75 struct da9062_regulator regulator[0]; 77 76 }; 78 77 79 - /* BUCK modes */ 80 - enum { 81 - BUCK_MODE_MANUAL, /* 0 */ 82 - BUCK_MODE_SLEEP, /* 1 */ 83 - BUCK_MODE_SYNC, /* 2 */ 84 - BUCK_MODE_AUTO /* 3 */ 85 - }; 86 - 87 78 /* Regulator operations */ 88 79 89 80 /* Current limits array (in uA) ··· 105 112 106 113 switch (mode) { 107 114 case REGULATOR_MODE_FAST: 108 - val = BUCK_MODE_SYNC; 115 + val = DA9063_BUCK_MODE_SYNC; 109 116 break; 110 117 case REGULATOR_MODE_NORMAL: 111 - val = BUCK_MODE_AUTO; 118 + val = DA9063_BUCK_MODE_AUTO; 112 119 break; 113 120 case REGULATOR_MODE_STANDBY: 114 - val = BUCK_MODE_SLEEP; 121 + val = DA9063_BUCK_MODE_SLEEP; 115 122 break; 116 123 default: 117 124 return -EINVAL; ··· 138 145 139 146 switch (val) { 140 147 default: 141 - case BUCK_MODE_MANUAL: 142 148 /* Sleep flag bit decides the mode */ 143 149 break; 144 - case BUCK_MODE_SLEEP: 150 + case DA9063_BUCK_MODE_SLEEP: 145 151 return REGULATOR_MODE_STANDBY; 146 - case BUCK_MODE_SYNC: 152 + case DA9063_BUCK_MODE_SYNC: 147 153 return REGULATOR_MODE_FAST; 148 - case BUCK_MODE_AUTO: 154 + case DA9063_BUCK_MODE_AUTO: 149 155 return REGULATOR_MODE_NORMAL; 150 156 } 151 157 ··· 271 279 272 280 switch (mode) { 273 281 case REGULATOR_MODE_FAST: 274 - val = BUCK_MODE_SYNC; 282 + val = DA9063_BUCK_MODE_SYNC; 275 283 break; 276 284 case REGULATOR_MODE_NORMAL: 277 - val = BUCK_MODE_AUTO; 285 + val = DA9063_BUCK_MODE_AUTO; 278 286 break; 279 287 case REGULATOR_MODE_STANDBY: 280 - val = BUCK_MODE_SLEEP; 288 + val = DA9063_BUCK_MODE_SLEEP; 281 289 break; 282 290 default: 283 291 return -EINVAL;
+16
include/dt-bindings/regulator/dlg,da9063-regulator.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + 3 + #ifndef _DT_BINDINGS_REGULATOR_DLG_DA9063_H 4 + #define _DT_BINDINGS_REGULATOR_DLG_DA9063_H 5 + 6 + /* 7 + * These buck mode constants may be used to specify values in device tree 8 + * properties (e.g. regulator-initial-mode). 9 + * A description of the following modes is in the manufacturers datasheet. 10 + */ 11 + 12 + #define DA9063_BUCK_MODE_SLEEP 1 13 + #define DA9063_BUCK_MODE_SYNC 2 14 + #define DA9063_BUCK_MODE_AUTO 3 15 + 16 + #endif