Lines Matching +full:resource +full:- +full:id

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()
618 static const struct resource wm831x_dcdc1_resources[] = {
629 static const struct resource wm831x_dcdc2_resources[] = {
639 static const struct resource wm831x_dcdc3_resources[] = {
648 static const struct resource wm831x_dcdc4_resources[] = {
657 static const struct resource wm8320_dcdc4_buck_resources[] = {
666 static const struct resource wm831x_gpio_resources[] = {
674 static const struct resource wm831x_isink1_resources[] = {
683 static const struct resource wm831x_isink2_resources[] = {
692 static const struct resource wm831x_ldo1_resources[] = {
701 static const struct resource wm831x_ldo2_resources[] = {
710 static const struct resource wm831x_ldo3_resources[] = {
719 static const struct resource wm831x_ldo4_resources[] = {
728 static const struct resource wm831x_ldo5_resources[] = {
737 static const struct resource wm831x_ldo6_resources[] = {
746 static const struct resource wm831x_ldo7_resources[] = {
755 static const struct resource wm831x_ldo8_resources[] = {
764 static const struct resource wm831x_ldo9_resources[] = {
773 static const struct resource wm831x_ldo10_resources[] = {
782 static const struct resource wm831x_ldo11_resources[] = {
790 static const struct resource wm831x_on_resources[] = {
795 static const struct resource wm831x_power_resources[] = {
809 static const struct resource wm831x_rtc_resources[] = {
814 static const struct resource wm831x_status1_resources[] = {
822 static const struct resource wm831x_status2_resources[] = {
830 static const struct resource wm831x_touch_resources[] = {
835 static const struct resource wm831x_wdt_resources[] = {
841 .name = "wm831x-backup",
844 .name = "wm831x-buckv",
845 .id = 1,
850 .name = "wm831x-buckv",
851 .id = 2,
856 .name = "wm831x-buckp",
857 .id = 3,
862 .name = "wm831x-boostp",
863 .id = 4,
868 .name = "wm831x-clk",
871 .name = "wm831x-epe",
872 .id = 1,
875 .name = "wm831x-epe",
876 .id = 2,
879 .name = "wm831x-gpio",
884 .name = "wm831x-hwmon",
887 .name = "wm831x-isink",
888 .id = 1,
893 .name = "wm831x-isink",
894 .id = 2,
899 .name = "wm831x-ldo",
900 .id = 1,
905 .name = "wm831x-ldo",
906 .id = 2,
911 .name = "wm831x-ldo",
912 .id = 3,
917 .name = "wm831x-ldo",
918 .id = 4,
923 .name = "wm831x-ldo",
924 .id = 5,
929 .name = "wm831x-ldo",
930 .id = 6,
935 .name = "wm831x-aldo",
936 .id = 7,
941 .name = "wm831x-aldo",
942 .id = 8,
947 .name = "wm831x-aldo",
948 .id = 9,
953 .name = "wm831x-aldo",
954 .id = 10,
959 .name = "wm831x-alive-ldo",
960 .id = 11,
965 .name = "wm831x-on",
970 .name = "wm831x-power",
975 .name = "wm831x-status",
976 .id = 1,
981 .name = "wm831x-status",
982 .id = 2,
987 .name = "wm831x-watchdog",
995 .name = "wm831x-backup",
998 .name = "wm831x-buckv",
999 .id = 1,
1004 .name = "wm831x-buckv",
1005 .id = 2,
1010 .name = "wm831x-buckp",
1011 .id = 3,
1016 .name = "wm831x-boostp",
1017 .id = 4,
1022 .name = "wm831x-clk",
1025 .name = "wm831x-epe",
1026 .id = 1,
1029 .name = "wm831x-epe",
1030 .id = 2,
1033 .name = "wm831x-gpio",
1038 .name = "wm831x-hwmon",
1041 .name = "wm831x-isink",
1042 .id = 1,
1047 .name = "wm831x-isink",
1048 .id = 2,
1053 .name = "wm831x-ldo",
1054 .id = 1,
1059 .name = "wm831x-ldo",
1060 .id = 2,
1065 .name = "wm831x-ldo",
1066 .id = 3,
1071 .name = "wm831x-ldo",
1072 .id = 4,
1077 .name = "wm831x-ldo",
1078 .id = 5,
1083 .name = "wm831x-aldo",
1084 .id = 7,
1089 .name = "wm831x-alive-ldo",
1090 .id = 11,
1095 .name = "wm831x-on",
1100 .name = "wm831x-power",
1105 .name = "wm831x-status",
1106 .id = 1,
1111 .name = "wm831x-status",
1112 .id = 2,
1117 .name = "wm831x-watchdog",
1125 .name = "wm831x-backup",
1128 .name = "wm831x-buckv",
1129 .id = 1,
1134 .name = "wm831x-buckv",
1135 .id = 2,
1140 .name = "wm831x-buckp",
1141 .id = 3,
1146 .name = "wm831x-boostp",
1147 .id = 4,
1152 .name = "wm831x-clk",
1155 .name = "wm831x-epe",
1156 .id = 1,
1159 .name = "wm831x-epe",
1160 .id = 2,
1163 .name = "wm831x-gpio",
1168 .name = "wm831x-hwmon",
1171 .name = "wm831x-isink",
1172 .id = 1,
1177 .name = "wm831x-isink",
1178 .id = 2,
1183 .name = "wm831x-ldo",
1184 .id = 1,
1189 .name = "wm831x-ldo",
1190 .id = 2,
1195 .name = "wm831x-ldo",
1196 .id = 3,
1201 .name = "wm831x-ldo",
1202 .id = 4,
1207 .name = "wm831x-ldo",
1208 .id = 5,
1213 .name = "wm831x-ldo",
1214 .id = 6,
1219 .name = "wm831x-aldo",
1220 .id = 7,
1225 .name = "wm831x-aldo",
1226 .id = 8,
1231 .name = "wm831x-aldo",
1232 .id = 9,
1237 .name = "wm831x-aldo",
1238 .id = 10,
1243 .name = "wm831x-alive-ldo",
1244 .id = 11,
1249 .name = "wm831x-on",
1254 .name = "wm831x-power",
1259 .name = "wm831x-status",
1260 .id = 1,
1265 .name = "wm831x-status",
1266 .id = 2,
1271 .name = "wm831x-watchdog",
1279 .name = "wm831x-backup",
1282 .name = "wm831x-buckv",
1283 .id = 1,
1288 .name = "wm831x-buckv",
1289 .id = 2,
1294 .name = "wm831x-buckp",
1295 .id = 3,
1300 .name = "wm831x-buckp",
1301 .id = 4,
1306 .name = "wm831x-clk",
1309 .name = "wm831x-gpio",
1314 .name = "wm831x-hwmon",
1317 .name = "wm831x-ldo",
1318 .id = 1,
1323 .name = "wm831x-ldo",
1324 .id = 2,
1329 .name = "wm831x-ldo",
1330 .id = 3,
1335 .name = "wm831x-ldo",
1336 .id = 4,
1341 .name = "wm831x-ldo",
1342 .id = 5,
1347 .name = "wm831x-ldo",
1348 .id = 6,
1353 .name = "wm831x-aldo",
1354 .id = 7,
1359 .name = "wm831x-aldo",
1360 .id = 8,
1365 .name = "wm831x-aldo",
1366 .id = 9,
1371 .name = "wm831x-aldo",
1372 .id = 10,
1377 .name = "wm831x-alive-ldo",
1378 .id = 11,
1383 .name = "wm831x-on",
1388 .name = "wm831x-status",
1389 .id = 1,
1394 .name = "wm831x-status",
1395 .id = 2,
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()
1497 /* Some engineering samples do not have the ID set, rely on 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()