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

Merge remote-tracking branch 'regulator/topic/wm8994' into v3.9-rc8

+42 -19
+42 -19
drivers/regulator/wm8994-regulator.c
··· 18 18 #include <linux/err.h> 19 19 #include <linux/platform_device.h> 20 20 #include <linux/regulator/driver.h> 21 + #include <linux/regulator/machine.h> 21 22 #include <linux/gpio.h> 22 23 #include <linux/slab.h> 23 24 ··· 29 28 struct wm8994_ldo { 30 29 struct regulator_dev *regulator; 31 30 struct wm8994 *wm8994; 31 + struct regulator_consumer_supply supply; 32 + struct regulator_init_data init_data; 32 33 }; 33 34 34 35 #define WM8994_LDO1_MAX_SELECTOR 0x7 ··· 102 99 }, 103 100 }; 104 101 102 + static const struct regulator_consumer_supply wm8994_ldo_consumer[] = { 103 + { .supply = "AVDD1" }, 104 + { .supply = "DCVDD" }, 105 + }; 106 + 107 + static const struct regulator_init_data wm8994_ldo_default[] = { 108 + { 109 + .constraints = { 110 + .valid_ops_mask = REGULATOR_CHANGE_STATUS, 111 + }, 112 + .num_consumer_supplies = 1, 113 + }, 114 + { 115 + .constraints = { 116 + .valid_ops_mask = REGULATOR_CHANGE_STATUS, 117 + }, 118 + .num_consumer_supplies = 1, 119 + }, 120 + }; 121 + 105 122 static int wm8994_ldo_probe(struct platform_device *pdev) 106 123 { 107 124 struct wm8994 *wm8994 = dev_get_drvdata(pdev->dev.parent); ··· 140 117 } 141 118 142 119 ldo->wm8994 = wm8994; 120 + ldo->supply = wm8994_ldo_consumer[id]; 121 + ldo->supply.dev_name = dev_name(wm8994->dev); 143 122 144 123 config.dev = wm8994->dev; 145 124 config.driver_data = ldo; 146 125 config.regmap = wm8994->regmap; 147 - if (pdata) { 148 - config.init_data = pdata->ldo[id].init_data; 126 + config.init_data = &ldo->init_data; 127 + if (pdata) 149 128 config.ena_gpio = pdata->ldo[id].enable; 129 + else if (wm8994->dev->of_node) 130 + config.ena_gpio = wm8994->pdata.ldo[id].enable; 131 + 132 + /* Use default constraints if none set up */ 133 + if (!pdata || !pdata->ldo[id].init_data || wm8994->dev->of_node) { 134 + dev_dbg(wm8994->dev, "Using default init data, supply %s %s\n", 135 + ldo->supply.dev_name, ldo->supply.supply); 136 + 137 + ldo->init_data = wm8994_ldo_default[id]; 138 + ldo->init_data.consumer_supplies = &ldo->supply; 139 + if (!config.ena_gpio) 140 + ldo->init_data.constraints.valid_ops_mask = 0; 141 + } else { 142 + ldo->init_data = *pdata->ldo[id].init_data; 150 143 } 151 144 152 145 ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &config); ··· 201 162 }, 202 163 }; 203 164 204 - static int __init wm8994_ldo_init(void) 205 - { 206 - int ret; 207 - 208 - ret = platform_driver_register(&wm8994_ldo_driver); 209 - if (ret != 0) 210 - pr_err("Failed to register Wm8994 GP LDO driver: %d\n", ret); 211 - 212 - return ret; 213 - } 214 - subsys_initcall(wm8994_ldo_init); 215 - 216 - static void __exit wm8994_ldo_exit(void) 217 - { 218 - platform_driver_unregister(&wm8994_ldo_driver); 219 - } 220 - module_exit(wm8994_ldo_exit); 165 + module_platform_driver(wm8994_ldo_driver); 221 166 222 167 /* Module information */ 223 168 MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");