Lines Matching +full:have +full:- +full:pmic
1 // SPDX-License-Identifier: GPL-2.0+
3 // wm8350.c -- Voltage and current regulation for the Wolfson WM8350 PMIC
17 #include <linux/mfd/wm8350/pmic.h>
101 switch (wm8350->pmic.isink_A_dcdc) { in wm8350_isink_enable()
109 1 << (wm8350->pmic.isink_A_dcdc - in wm8350_isink_enable()
113 return -EINVAL; in wm8350_isink_enable()
117 switch (wm8350->pmic.isink_B_dcdc) { in wm8350_isink_enable()
125 1 << (wm8350->pmic.isink_B_dcdc - in wm8350_isink_enable()
129 return -EINVAL; in wm8350_isink_enable()
133 return -EINVAL; in wm8350_isink_enable()
145 switch (wm8350->pmic.isink_A_dcdc) { in wm8350_isink_disable()
149 1 << (wm8350->pmic.isink_A_dcdc - in wm8350_isink_disable()
155 return -EINVAL; in wm8350_isink_disable()
159 switch (wm8350->pmic.isink_B_dcdc) { in wm8350_isink_disable()
163 1 << (wm8350->pmic.isink_B_dcdc - in wm8350_isink_disable()
169 return -EINVAL; in wm8350_isink_disable()
173 return -EINVAL; in wm8350_isink_disable()
191 return -EINVAL; in wm8350_isink_is_enabled()
208 return -EINVAL; in wm8350_isink_enable_time()
235 return -EINVAL; in wm8350_isink_enable_time()
257 return -EINVAL; in wm8350_isink_set_flash()
269 dev_dbg(wm8350->dev, "%s %d mV %d\n", __func__, dcdc, uV / 1000); in wm8350_dcdc_set_suspend_voltage()
287 return -EINVAL; in wm8350_dcdc_set_suspend_voltage()
294 /* all DCDCs have same mV bits */ in wm8350_dcdc_set_suspend_voltage()
311 val | wm8350->pmic.dcdc1_hib_mode); in wm8350_dcdc_set_suspend_enable()
317 val | wm8350->pmic.dcdc3_hib_mode); in wm8350_dcdc_set_suspend_enable()
323 val | wm8350->pmic.dcdc4_hib_mode); in wm8350_dcdc_set_suspend_enable()
329 val | wm8350->pmic.dcdc6_hib_mode); in wm8350_dcdc_set_suspend_enable()
334 return -EINVAL; in wm8350_dcdc_set_suspend_enable()
349 wm8350->pmic.dcdc1_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK; in wm8350_dcdc_set_suspend_disable()
355 wm8350->pmic.dcdc3_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK; in wm8350_dcdc_set_suspend_disable()
361 wm8350->pmic.dcdc4_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK; in wm8350_dcdc_set_suspend_disable()
367 wm8350->pmic.dcdc6_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK; in wm8350_dcdc_set_suspend_disable()
374 return -EINVAL; in wm8350_dcdc_set_suspend_disable()
400 return -EINVAL; in wm8350_dcdc25_set_suspend_enable()
425 return -EINVAL; in wm8350_dcdc25_set_suspend_disable()
439 hib_mode = &wm8350->pmic.dcdc1_hib_mode; in wm8350_dcdc_set_suspend_mode()
442 hib_mode = &wm8350->pmic.dcdc3_hib_mode; in wm8350_dcdc_set_suspend_mode()
445 hib_mode = &wm8350->pmic.dcdc4_hib_mode; in wm8350_dcdc_set_suspend_mode()
448 hib_mode = &wm8350->pmic.dcdc6_hib_mode; in wm8350_dcdc_set_suspend_mode()
453 return -EINVAL; in wm8350_dcdc_set_suspend_mode()
467 return -EINVAL; in wm8350_dcdc_set_suspend_mode()
484 dev_dbg(wm8350->dev, "%s %d mV %d\n", __func__, ldo, uV / 1000); in wm8350_ldo_set_suspend_voltage()
500 return -EINVAL; in wm8350_ldo_set_suspend_voltage()
507 /* all LDOs have same mV bits */ in wm8350_ldo_set_suspend_voltage()
533 return -EINVAL; in wm8350_ldo_set_suspend_enable()
536 /* all LDOs have same mV bits */ in wm8350_ldo_set_suspend_enable()
562 return -EINVAL; in wm8350_ldo_set_suspend_disable()
565 /* all LDOs have same mV bits */ in wm8350_ldo_set_suspend_disable()
577 dev_dbg(wm8350->dev, "%s %d start %d stop %d\n", in wm8350_dcdc_set_slot()
582 return -EINVAL; in wm8350_dcdc_set_slot()
604 return -EINVAL; in wm8350_dcdc_set_slot()
624 dev_dbg(wm8350->dev, "%s %d start %d stop %d\n", in wm8350_ldo_set_slot()
629 return -EINVAL; in wm8350_ldo_set_slot()
645 return -EINVAL; in wm8350_ldo_set_slot()
659 dev_dbg(wm8350->dev, "%s %d mode: %s %s\n", __func__, dcdc, in wm8350_dcdc25_set_mode()
684 return -EINVAL; in wm8350_dcdc25_set_mode()
709 return -EINVAL; in force_continuous_enable()
728 return -EINVAL; in wm8350_dcdc_set_mode()
731 return -EINVAL; in wm8350_dcdc_set_mode()
733 val = 1 << (dcdc - WM8350_DCDC_1); in wm8350_dcdc_set_mode()
786 return -EINVAL; in wm8350_dcdc_get_mode()
789 mask = 1 << (dcdc - WM8350_DCDC_1); in wm8350_dcdc_get_mode()
794 dev_dbg(wm8350->dev, "mask %x active %x sleep %x force %x", in wm8350_dcdc_get_mode()
822 {0, 10000, REGULATOR_MODE_STANDBY}, /* 0 - 10mA - LDO */
823 {10000, 100000, REGULATOR_MODE_IDLE}, /* 10mA - 100mA - Standby */
824 {100000, 1000000, REGULATOR_MODE_NORMAL}, /* > 100mA - Active */
825 {-1, -1, REGULATOR_MODE_NORMAL},
829 {0, 10000, REGULATOR_MODE_STANDBY}, /* 0 - 10mA - LDO */
830 {10000, 100000, REGULATOR_MODE_IDLE}, /* 10mA - 100mA - Standby */
831 {100000, 800000, REGULATOR_MODE_NORMAL}, /* > 100mA - Active */
832 {-1, -1, REGULATOR_MODE_NORMAL},
839 while (eff[i].uA_load_min != -1) { in get_mode()
1106 struct wm8350 *wm8350 = dev_get_drvdata(&pdev->dev); in wm8350_regulator_probe()
1112 if (pdev->id < WM8350_DCDC_1 || pdev->id > WM8350_ISINK_B) in wm8350_regulator_probe()
1113 return -ENODEV; in wm8350_regulator_probe()
1116 switch (pdev->id) { in wm8350_regulator_probe()
1119 wm8350->pmic.dcdc1_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK; in wm8350_regulator_probe()
1123 wm8350->pmic.dcdc3_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK; in wm8350_regulator_probe()
1127 wm8350->pmic.dcdc4_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK; in wm8350_regulator_probe()
1131 wm8350->pmic.dcdc6_hib_mode = val & WM8350_DCDC_HIB_MODE_MASK; in wm8350_regulator_probe()
1135 config.dev = &pdev->dev; in wm8350_regulator_probe()
1136 config.init_data = dev_get_platdata(&pdev->dev); in wm8350_regulator_probe()
1137 config.driver_data = dev_get_drvdata(&pdev->dev); in wm8350_regulator_probe()
1138 config.regmap = wm8350->regmap; in wm8350_regulator_probe()
1141 rdev = devm_regulator_register(&pdev->dev, &wm8350_reg[pdev->id], in wm8350_regulator_probe()
1144 dev_err(&pdev->dev, "failed to register %s\n", in wm8350_regulator_probe()
1145 wm8350_reg[pdev->id].name); in wm8350_regulator_probe()
1150 ret = wm8350_register_irq(wm8350, wm8350_reg[pdev->id].irq, in wm8350_regulator_probe()
1153 dev_err(&pdev->dev, "failed to register regulator %s IRQ\n", in wm8350_regulator_probe()
1154 wm8350_reg[pdev->id].name); in wm8350_regulator_probe()
1166 wm8350_free_irq(wm8350, wm8350_reg[pdev->id].irq, rdev); in wm8350_regulator_remove()
1175 return -EINVAL; in wm8350_register_regulator()
1177 if (wm8350->pmic.pdev[reg]) in wm8350_register_regulator()
1178 return -EBUSY; in wm8350_register_regulator()
1181 reg > wm8350->pmic.max_dcdc) in wm8350_register_regulator()
1182 return -ENODEV; in wm8350_register_regulator()
1184 reg > wm8350->pmic.max_isink) in wm8350_register_regulator()
1185 return -ENODEV; in wm8350_register_regulator()
1187 pdev = platform_device_alloc("wm8350-regulator", reg); in wm8350_register_regulator()
1189 return -ENOMEM; in wm8350_register_regulator()
1191 wm8350->pmic.pdev[reg] = pdev; in wm8350_register_regulator()
1193 initdata->driver_data = wm8350; in wm8350_register_regulator()
1195 pdev->dev.platform_data = initdata; in wm8350_register_regulator()
1196 pdev->dev.parent = wm8350->dev; in wm8350_register_regulator()
1202 dev_err(wm8350->dev, "Failed to register regulator %d: %d\n", in wm8350_register_regulator()
1205 wm8350->pmic.pdev[reg] = NULL; in wm8350_register_regulator()
1213 * wm8350_register_led - Register a WM8350 LED output
1222 * provide a power-efficient LED driver. This function registers the
1235 if (lednum >= ARRAY_SIZE(wm8350->pmic.led) || lednum < 0) { in wm8350_register_led()
1236 dev_err(wm8350->dev, "Invalid LED index %d\n", lednum); in wm8350_register_led()
1237 return -ENODEV; in wm8350_register_led()
1240 led = &wm8350->pmic.led[lednum]; in wm8350_register_led()
1242 if (led->pdev) { in wm8350_register_led()
1243 dev_err(wm8350->dev, "LED %d already allocated\n", lednum); in wm8350_register_led()
1244 return -EINVAL; in wm8350_register_led()
1247 pdev = platform_device_alloc("wm8350-led", lednum); in wm8350_register_led()
1249 dev_err(wm8350->dev, "Failed to allocate LED %d\n", lednum); in wm8350_register_led()
1250 return -ENOMEM; in wm8350_register_led()
1253 led->isink_consumer.dev_name = dev_name(&pdev->dev); in wm8350_register_led()
1254 led->isink_consumer.supply = "led_isink"; in wm8350_register_led()
1255 led->isink_init.num_consumer_supplies = 1; in wm8350_register_led()
1256 led->isink_init.consumer_supplies = &led->isink_consumer; in wm8350_register_led()
1257 led->isink_init.constraints.min_uA = 0; in wm8350_register_led()
1258 led->isink_init.constraints.max_uA = pdata->max_uA; in wm8350_register_led()
1259 led->isink_init.constraints.valid_ops_mask in wm8350_register_led()
1261 led->isink_init.constraints.valid_modes_mask = REGULATOR_MODE_NORMAL; in wm8350_register_led()
1262 ret = wm8350_register_regulator(wm8350, isink, &led->isink_init); in wm8350_register_led()
1268 led->dcdc_consumer.dev_name = dev_name(&pdev->dev); in wm8350_register_led()
1269 led->dcdc_consumer.supply = "led_vcc"; in wm8350_register_led()
1270 led->dcdc_init.num_consumer_supplies = 1; in wm8350_register_led()
1271 led->dcdc_init.consumer_supplies = &led->dcdc_consumer; in wm8350_register_led()
1272 led->dcdc_init.constraints.valid_modes_mask = REGULATOR_MODE_NORMAL; in wm8350_register_led()
1273 led->dcdc_init.constraints.valid_ops_mask = REGULATOR_CHANGE_STATUS; in wm8350_register_led()
1274 ret = wm8350_register_regulator(wm8350, dcdc, &led->dcdc_init); in wm8350_register_led()
1282 wm8350->pmic.isink_A_dcdc = dcdc; in wm8350_register_led()
1285 wm8350->pmic.isink_B_dcdc = dcdc; in wm8350_register_led()
1289 pdev->dev.platform_data = pdata; in wm8350_register_led()
1290 pdev->dev.parent = wm8350->dev; in wm8350_register_led()
1293 dev_err(wm8350->dev, "Failed to register LED %d: %d\n", in wm8350_register_led()
1299 led->pdev = pdev; in wm8350_register_led()
1309 .name = "wm8350-regulator",
1330 MODULE_ALIAS("platform:wm8350-regulator");