Lines Matching +full:uv +full:- +full:shutdown

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * wm831x-core.c -- Device access for Wolfson WM831x PMICs
28 /* Current settings - values are 2*2^(reg_val/4) microamps. These are
93 if (!wm831x->locked) in wm831x_reg_locked()
125 dev_vdbg(wm831x->dev, "Registers locked\n"); in wm831x_reg_lock()
127 mutex_lock(&wm831x->io_lock); in wm831x_reg_lock()
128 WARN_ON(wm831x->locked); in wm831x_reg_lock()
129 wm831x->locked = 1; in wm831x_reg_lock()
130 mutex_unlock(&wm831x->io_lock); in wm831x_reg_lock()
132 dev_err(wm831x->dev, "Failed to lock registers: %d\n", ret); in wm831x_reg_lock()
154 dev_vdbg(wm831x->dev, "Registers unlocked\n"); in wm831x_reg_unlock()
156 mutex_lock(&wm831x->io_lock); in wm831x_reg_unlock()
157 WARN_ON(!wm831x->locked); in wm831x_reg_unlock()
158 wm831x->locked = 0; in wm831x_reg_unlock()
159 mutex_unlock(&wm831x->io_lock); in wm831x_reg_unlock()
523 ret = regmap_read(wm831x->regmap, reg, &val); in wm831x_reg_read()
543 return regmap_bulk_read(wm831x->regmap, reg, buf, count); in wm831x_bulk_read()
558 return -EPERM; in wm831x_write()
560 dev_vdbg(wm831x->dev, "Write %04x to R%d(0x%x)\n", in wm831x_write()
562 ret = regmap_write(wm831x->regmap, reg + i, buf[i]); in wm831x_write()
582 mutex_lock(&wm831x->io_lock); in wm831x_reg_write()
586 mutex_unlock(&wm831x->io_lock); in wm831x_reg_write()
605 mutex_lock(&wm831x->io_lock); in wm831x_set_bits()
608 ret = regmap_update_bits(wm831x->regmap, reg, mask, val); in wm831x_set_bits()
610 ret = -EPERM; in wm831x_set_bits()
612 mutex_unlock(&wm831x->io_lock); in wm831x_set_bits()
624 DEFINE_RES_IRQ_NAMED(WM831X_IRQ_UV_DC1, "UV"),
635 DEFINE_RES_IRQ_NAMED(WM831X_IRQ_UV_DC2, "UV"),
645 DEFINE_RES_IRQ_NAMED(WM831X_IRQ_UV_DC3, "UV"),
654 DEFINE_RES_IRQ_NAMED(WM831X_IRQ_UV_DC4, "UV"),
663 DEFINE_RES_IRQ_NAMED(WM831X_IRQ_UV_DC4, "UV"),
698 DEFINE_RES_IRQ_NAMED(WM831X_IRQ_UV_LDO1, "UV"),
707 DEFINE_RES_IRQ_NAMED(WM831X_IRQ_UV_LDO2, "UV"),
716 DEFINE_RES_IRQ_NAMED(WM831X_IRQ_UV_LDO3, "UV"),
725 DEFINE_RES_IRQ_NAMED(WM831X_IRQ_UV_LDO4, "UV"),
734 DEFINE_RES_IRQ_NAMED(WM831X_IRQ_UV_LDO5, "UV"),
743 DEFINE_RES_IRQ_NAMED(WM831X_IRQ_UV_LDO6, "UV"),
752 DEFINE_RES_IRQ_NAMED(WM831X_IRQ_UV_LDO7, "UV"),
761 DEFINE_RES_IRQ_NAMED(WM831X_IRQ_UV_LDO8, "UV"),
770 DEFINE_RES_IRQ_NAMED(WM831X_IRQ_UV_LDO9, "UV"),
779 DEFINE_RES_IRQ_NAMED(WM831X_IRQ_UV_LDO10, "UV"),
841 .name = "wm831x-backup",
844 .name = "wm831x-buckv",
850 .name = "wm831x-buckv",
856 .name = "wm831x-buckp",
862 .name = "wm831x-boostp",
868 .name = "wm831x-clk",
871 .name = "wm831x-epe",
875 .name = "wm831x-epe",
879 .name = "wm831x-gpio",
884 .name = "wm831x-hwmon",
887 .name = "wm831x-isink",
893 .name = "wm831x-isink",
899 .name = "wm831x-ldo",
905 .name = "wm831x-ldo",
911 .name = "wm831x-ldo",
917 .name = "wm831x-ldo",
923 .name = "wm831x-ldo",
929 .name = "wm831x-ldo",
935 .name = "wm831x-aldo",
941 .name = "wm831x-aldo",
947 .name = "wm831x-aldo",
953 .name = "wm831x-aldo",
959 .name = "wm831x-alive-ldo",
965 .name = "wm831x-on",
970 .name = "wm831x-power",
975 .name = "wm831x-status",
981 .name = "wm831x-status",
987 .name = "wm831x-watchdog",
995 .name = "wm831x-backup",
998 .name = "wm831x-buckv",
1004 .name = "wm831x-buckv",
1010 .name = "wm831x-buckp",
1016 .name = "wm831x-boostp",
1022 .name = "wm831x-clk",
1025 .name = "wm831x-epe",
1029 .name = "wm831x-epe",
1033 .name = "wm831x-gpio",
1038 .name = "wm831x-hwmon",
1041 .name = "wm831x-isink",
1047 .name = "wm831x-isink",
1053 .name = "wm831x-ldo",
1059 .name = "wm831x-ldo",
1065 .name = "wm831x-ldo",
1071 .name = "wm831x-ldo",
1077 .name = "wm831x-ldo",
1083 .name = "wm831x-aldo",
1089 .name = "wm831x-alive-ldo",
1095 .name = "wm831x-on",
1100 .name = "wm831x-power",
1105 .name = "wm831x-status",
1111 .name = "wm831x-status",
1117 .name = "wm831x-watchdog",
1125 .name = "wm831x-backup",
1128 .name = "wm831x-buckv",
1134 .name = "wm831x-buckv",
1140 .name = "wm831x-buckp",
1146 .name = "wm831x-boostp",
1152 .name = "wm831x-clk",
1155 .name = "wm831x-epe",
1159 .name = "wm831x-epe",
1163 .name = "wm831x-gpio",
1168 .name = "wm831x-hwmon",
1171 .name = "wm831x-isink",
1177 .name = "wm831x-isink",
1183 .name = "wm831x-ldo",
1189 .name = "wm831x-ldo",
1195 .name = "wm831x-ldo",
1201 .name = "wm831x-ldo",
1207 .name = "wm831x-ldo",
1213 .name = "wm831x-ldo",
1219 .name = "wm831x-aldo",
1225 .name = "wm831x-aldo",
1231 .name = "wm831x-aldo",
1237 .name = "wm831x-aldo",
1243 .name = "wm831x-alive-ldo",
1249 .name = "wm831x-on",
1254 .name = "wm831x-power",
1259 .name = "wm831x-status",
1265 .name = "wm831x-status",
1271 .name = "wm831x-watchdog",
1279 .name = "wm831x-backup",
1282 .name = "wm831x-buckv",
1288 .name = "wm831x-buckv",
1294 .name = "wm831x-buckp",
1300 .name = "wm831x-buckp",
1306 .name = "wm831x-clk",
1309 .name = "wm831x-gpio",
1314 .name = "wm831x-hwmon",
1317 .name = "wm831x-ldo",
1323 .name = "wm831x-ldo",
1329 .name = "wm831x-ldo",
1335 .name = "wm831x-ldo",
1341 .name = "wm831x-ldo",
1347 .name = "wm831x-ldo",
1353 .name = "wm831x-aldo",
1359 .name = "wm831x-aldo",
1365 .name = "wm831x-aldo",
1371 .name = "wm831x-aldo",
1377 .name = "wm831x-alive-ldo",
1383 .name = "wm831x-on",
1388 .name = "wm831x-status",
1394 .name = "wm831x-status",
1400 .name = "wm831x-watchdog",
1408 .name = "wm831x-touch",
1416 .name = "wm831x-rtc",
1424 .name = "wm831x-backlight",
1454 * Instantiate the generic non-control parts of the device.
1458 struct wm831x_pdata *pdata = &wm831x->pdata; in wm831x_device_init()
1463 mutex_init(&wm831x->io_lock); in wm831x_device_init()
1464 mutex_init(&wm831x->key_lock); in wm831x_device_init()
1465 dev_set_drvdata(wm831x->dev, wm831x); in wm831x_device_init()
1467 wm831x->soft_shutdown = pdata->soft_shutdown; in wm831x_device_init()
1471 dev_err(wm831x->dev, "Failed to read parent ID: %d\n", ret); in wm831x_device_init()
1479 dev_err(wm831x->dev, "Device is not a WM831x: ID %x\n", ret); in wm831x_device_init()
1480 ret = -EINVAL; in wm831x_device_init()
1486 dev_err(wm831x->dev, "Failed to read revision: %d\n", ret); in wm831x_device_init()
1493 dev_err(wm831x->dev, "Failed to read device ID: %d\n", ret); in wm831x_device_init()
1501 dev_info(wm831x->dev, "Device is an engineering sample\n"); in wm831x_device_init()
1502 ret = wm831x->type; in wm831x_device_init()
1508 wm831x->num_gpio = 16; in wm831x_device_init()
1509 wm831x->charger_irq_wake = 1; in wm831x_device_init()
1511 wm831x->has_gpio_ena = 1; in wm831x_device_init()
1512 wm831x->has_cs_sts = 1; in wm831x_device_init()
1515 dev_info(wm831x->dev, "WM8310 revision %c\n", 'A' + rev); in wm831x_device_init()
1520 wm831x->num_gpio = 16; in wm831x_device_init()
1521 wm831x->charger_irq_wake = 1; in wm831x_device_init()
1523 wm831x->has_gpio_ena = 1; in wm831x_device_init()
1524 wm831x->has_cs_sts = 1; in wm831x_device_init()
1527 dev_info(wm831x->dev, "WM8311 revision %c\n", 'A' + rev); in wm831x_device_init()
1532 wm831x->num_gpio = 16; in wm831x_device_init()
1533 wm831x->charger_irq_wake = 1; in wm831x_device_init()
1535 wm831x->has_gpio_ena = 1; in wm831x_device_init()
1536 wm831x->has_cs_sts = 1; in wm831x_device_init()
1539 dev_info(wm831x->dev, "WM8312 revision %c\n", 'A' + rev); in wm831x_device_init()
1544 wm831x->num_gpio = 12; in wm831x_device_init()
1545 dev_info(wm831x->dev, "WM8320 revision %c\n", 'A' + rev); in wm831x_device_init()
1550 wm831x->num_gpio = 12; in wm831x_device_init()
1551 dev_info(wm831x->dev, "WM8321 revision %c\n", 'A' + rev); in wm831x_device_init()
1556 wm831x->num_gpio = 12; in wm831x_device_init()
1557 dev_info(wm831x->dev, "WM8325 revision %c\n", 'A' + rev); in wm831x_device_init()
1562 wm831x->num_gpio = 12; in wm831x_device_init()
1563 dev_info(wm831x->dev, "WM8326 revision %c\n", 'A' + rev); in wm831x_device_init()
1567 dev_err(wm831x->dev, "Unknown WM831x device %04x\n", ret); in wm831x_device_init()
1568 ret = -EINVAL; in wm831x_device_init()
1575 if (parent != wm831x->type) in wm831x_device_init()
1576 dev_warn(wm831x->dev, "Device was registered as a WM%x\n", in wm831x_device_init()
1577 wm831x->type); in wm831x_device_init()
1582 dev_err(wm831x->dev, "Failed to read security key: %d\n", ret); in wm831x_device_init()
1586 dev_warn(wm831x->dev, "Security key had non-zero value %x\n", in wm831x_device_init()
1590 wm831x->locked = 1; in wm831x_device_init()
1592 if (pdata->pre_init) { in wm831x_device_init()
1593 ret = pdata->pre_init(wm831x); in wm831x_device_init()
1595 dev_err(wm831x->dev, "pre_init() failed: %d\n", ret); in wm831x_device_init()
1600 for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) { in wm831x_device_init()
1601 if (!pdata->gpio_defaults[i]) in wm831x_device_init()
1606 pdata->gpio_defaults[i] & 0xffff); in wm831x_device_init()
1610 if (pdata->wm831x_num) in wm831x_device_init()
1611 wm831x_num = pdata->wm831x_num * 10; in wm831x_device_init()
1613 wm831x_num = -1; in wm831x_device_init()
1624 ret = mfd_add_devices(wm831x->dev, wm831x_num, in wm831x_device_init()
1630 ret = mfd_add_devices(wm831x->dev, wm831x_num, in wm831x_device_init()
1633 if (!pdata->disable_touch) in wm831x_device_init()
1634 mfd_add_devices(wm831x->dev, wm831x_num, in wm831x_device_init()
1640 ret = mfd_add_devices(wm831x->dev, wm831x_num, in wm831x_device_init()
1643 if (!pdata->disable_touch) in wm831x_device_init()
1644 mfd_add_devices(wm831x->dev, wm831x_num, in wm831x_device_init()
1653 ret = mfd_add_devices(wm831x->dev, wm831x_num, in wm831x_device_init()
1664 dev_err(wm831x->dev, "Failed to add children\n"); in wm831x_device_init()
1673 dev_err(wm831x->dev, "Failed to read clock status: %d\n", ret); in wm831x_device_init()
1678 ret = mfd_add_devices(wm831x->dev, wm831x_num, in wm831x_device_init()
1682 dev_err(wm831x->dev, "Failed to add RTC: %d\n", ret); in wm831x_device_init()
1686 dev_info(wm831x->dev, "32.768kHz clock disabled, no RTC\n"); in wm831x_device_init()
1689 if (pdata->backlight) { in wm831x_device_init()
1690 /* Treat errors as non-critical */ in wm831x_device_init()
1691 ret = mfd_add_devices(wm831x->dev, wm831x_num, backlight_devs, in wm831x_device_init()
1695 dev_err(wm831x->dev, "Failed to add backlight: %d\n", in wm831x_device_init()
1701 if (pdata->post_init) { in wm831x_device_init()
1702 ret = pdata->post_init(wm831x); in wm831x_device_init()
1704 dev_err(wm831x->dev, "post_init() failed: %d\n", ret); in wm831x_device_init()
1714 mfd_remove_devices(wm831x->dev); in wm831x_device_init()
1727 if (wm831x->charger_irq_wake) { in wm831x_device_suspend()
1743 dev_info(wm831x->dev, in wm831x_device_suspend()
1756 if (wm831x->soft_shutdown) { in wm831x_device_shutdown()
1757 dev_info(wm831x->dev, "Initiating shutdown...\n"); in wm831x_device_shutdown()