15 #include <linux/kernel.h>
16 #include <linux/module.h>
20 #include <linux/slab.h>
133 dev_err(wm831x->
dev,
"Failed to lock registers: %d\n", ret);
165 static bool wm831x_reg_readable(
struct device *
dev,
unsigned int reg)
344 static bool wm831x_reg_writeable(
struct device *dev,
unsigned int reg)
348 if (wm831x_reg_locked(wm831x, reg))
481 static bool wm831x_reg_volatile(
struct device *dev,
unsigned int reg)
546 static int wm831x_write(
struct wm831x *wm831x,
unsigned short reg,
555 for (i = 0; i < bytes / 2; i++) {
556 if (wm831x_reg_locked(wm831x, reg))
560 buf[i], reg + i, reg + i);
583 ret = wm831x_write(wm831x, reg, 2, &val);
600 unsigned short mask,
unsigned short val)
606 if (!wm831x_reg_locked(wm831x, reg))
617 static struct resource wm831x_dcdc1_resources[] = {
638 static struct resource wm831x_dcdc2_resources[] = {
658 static struct resource wm831x_dcdc3_resources[] = {
672 static struct resource wm831x_dcdc4_resources[] = {
686 static struct resource wm8320_dcdc4_buck_resources[] = {
700 static struct resource wm831x_gpio_resources[] = {
708 static struct resource wm831x_isink1_resources[] = {
721 static struct resource wm831x_isink2_resources[] = {
734 static struct resource wm831x_ldo1_resources[] = {
748 static struct resource wm831x_ldo2_resources[] = {
762 static struct resource wm831x_ldo3_resources[] = {
776 static struct resource wm831x_ldo4_resources[] = {
790 static struct resource wm831x_ldo5_resources[] = {
804 static struct resource wm831x_ldo6_resources[] = {
818 static struct resource wm831x_ldo7_resources[] = {
832 static struct resource wm831x_ldo8_resources[] = {
846 static struct resource wm831x_ldo9_resources[] = {
860 static struct resource wm831x_ldo10_resources[] = {
874 static struct resource wm831x_ldo11_resources[] = {
882 static struct resource wm831x_on_resources[] = {
891 static struct resource wm831x_power_resources[] = {
960 static struct resource wm831x_rtc_resources[] = {
975 static struct resource wm831x_status1_resources[] = {
983 static struct resource wm831x_status2_resources[] = {
991 static struct resource wm831x_touch_resources[] = {
1006 static struct resource wm831x_wdt_resources[] = {
1014 static struct mfd_cell wm8310_devs[] = {
1016 .name =
"wm831x-backup",
1019 .name =
"wm831x-buckv",
1021 .num_resources =
ARRAY_SIZE(wm831x_dcdc1_resources),
1022 .resources = wm831x_dcdc1_resources,
1025 .
name =
"wm831x-buckv",
1027 .num_resources =
ARRAY_SIZE(wm831x_dcdc2_resources),
1028 .resources = wm831x_dcdc2_resources,
1031 .
name =
"wm831x-buckp",
1033 .num_resources =
ARRAY_SIZE(wm831x_dcdc3_resources),
1034 .resources = wm831x_dcdc3_resources,
1037 .
name =
"wm831x-boostp",
1039 .num_resources =
ARRAY_SIZE(wm831x_dcdc4_resources),
1040 .resources = wm831x_dcdc4_resources,
1043 .
name =
"wm831x-clk",
1046 .name =
"wm831x-epe",
1050 .name =
"wm831x-epe",
1054 .name =
"wm831x-gpio",
1055 .num_resources =
ARRAY_SIZE(wm831x_gpio_resources),
1056 .resources = wm831x_gpio_resources,
1059 .
name =
"wm831x-hwmon",
1062 .name =
"wm831x-isink",
1064 .num_resources =
ARRAY_SIZE(wm831x_isink1_resources),
1065 .resources = wm831x_isink1_resources,
1068 .
name =
"wm831x-isink",
1070 .num_resources =
ARRAY_SIZE(wm831x_isink2_resources),
1071 .resources = wm831x_isink2_resources,
1074 .
name =
"wm831x-ldo",
1076 .num_resources =
ARRAY_SIZE(wm831x_ldo1_resources),
1077 .resources = wm831x_ldo1_resources,
1080 .
name =
"wm831x-ldo",
1082 .num_resources =
ARRAY_SIZE(wm831x_ldo2_resources),
1083 .resources = wm831x_ldo2_resources,
1086 .
name =
"wm831x-ldo",
1088 .num_resources =
ARRAY_SIZE(wm831x_ldo3_resources),
1089 .resources = wm831x_ldo3_resources,
1092 .
name =
"wm831x-ldo",
1094 .num_resources =
ARRAY_SIZE(wm831x_ldo4_resources),
1095 .resources = wm831x_ldo4_resources,
1098 .
name =
"wm831x-ldo",
1100 .num_resources =
ARRAY_SIZE(wm831x_ldo5_resources),
1101 .resources = wm831x_ldo5_resources,
1104 .
name =
"wm831x-ldo",
1106 .num_resources =
ARRAY_SIZE(wm831x_ldo6_resources),
1107 .resources = wm831x_ldo6_resources,
1110 .
name =
"wm831x-aldo",
1112 .num_resources =
ARRAY_SIZE(wm831x_ldo7_resources),
1113 .resources = wm831x_ldo7_resources,
1116 .
name =
"wm831x-aldo",
1118 .num_resources =
ARRAY_SIZE(wm831x_ldo8_resources),
1119 .resources = wm831x_ldo8_resources,
1122 .
name =
"wm831x-aldo",
1124 .num_resources =
ARRAY_SIZE(wm831x_ldo9_resources),
1125 .resources = wm831x_ldo9_resources,
1128 .
name =
"wm831x-aldo",
1130 .num_resources =
ARRAY_SIZE(wm831x_ldo10_resources),
1131 .resources = wm831x_ldo10_resources,
1134 .
name =
"wm831x-alive-ldo",
1136 .num_resources =
ARRAY_SIZE(wm831x_ldo11_resources),
1137 .resources = wm831x_ldo11_resources,
1140 .
name =
"wm831x-on",
1141 .num_resources =
ARRAY_SIZE(wm831x_on_resources),
1142 .resources = wm831x_on_resources,
1145 .
name =
"wm831x-power",
1146 .num_resources =
ARRAY_SIZE(wm831x_power_resources),
1147 .resources = wm831x_power_resources,
1150 .
name =
"wm831x-status",
1152 .num_resources =
ARRAY_SIZE(wm831x_status1_resources),
1153 .resources = wm831x_status1_resources,
1156 .
name =
"wm831x-status",
1158 .num_resources =
ARRAY_SIZE(wm831x_status2_resources),
1159 .resources = wm831x_status2_resources,
1162 .
name =
"wm831x-watchdog",
1163 .num_resources =
ARRAY_SIZE(wm831x_wdt_resources),
1164 .resources = wm831x_wdt_resources,
1168 static struct mfd_cell wm8311_devs[] = {
1170 .name =
"wm831x-backup",
1173 .name =
"wm831x-buckv",
1175 .num_resources =
ARRAY_SIZE(wm831x_dcdc1_resources),
1176 .resources = wm831x_dcdc1_resources,
1179 .
name =
"wm831x-buckv",
1181 .num_resources =
ARRAY_SIZE(wm831x_dcdc2_resources),
1182 .resources = wm831x_dcdc2_resources,
1185 .
name =
"wm831x-buckp",
1187 .num_resources =
ARRAY_SIZE(wm831x_dcdc3_resources),
1188 .resources = wm831x_dcdc3_resources,
1191 .
name =
"wm831x-boostp",
1193 .num_resources =
ARRAY_SIZE(wm831x_dcdc4_resources),
1194 .resources = wm831x_dcdc4_resources,
1197 .
name =
"wm831x-clk",
1200 .name =
"wm831x-epe",
1204 .name =
"wm831x-epe",
1208 .name =
"wm831x-gpio",
1209 .num_resources =
ARRAY_SIZE(wm831x_gpio_resources),
1210 .resources = wm831x_gpio_resources,
1213 .
name =
"wm831x-hwmon",
1216 .name =
"wm831x-isink",
1218 .num_resources =
ARRAY_SIZE(wm831x_isink1_resources),
1219 .resources = wm831x_isink1_resources,
1222 .
name =
"wm831x-isink",
1224 .num_resources =
ARRAY_SIZE(wm831x_isink2_resources),
1225 .resources = wm831x_isink2_resources,
1228 .
name =
"wm831x-ldo",
1230 .num_resources =
ARRAY_SIZE(wm831x_ldo1_resources),
1231 .resources = wm831x_ldo1_resources,
1234 .
name =
"wm831x-ldo",
1236 .num_resources =
ARRAY_SIZE(wm831x_ldo2_resources),
1237 .resources = wm831x_ldo2_resources,
1240 .
name =
"wm831x-ldo",
1242 .num_resources =
ARRAY_SIZE(wm831x_ldo3_resources),
1243 .resources = wm831x_ldo3_resources,
1246 .
name =
"wm831x-ldo",
1248 .num_resources =
ARRAY_SIZE(wm831x_ldo4_resources),
1249 .resources = wm831x_ldo4_resources,
1252 .
name =
"wm831x-ldo",
1254 .num_resources =
ARRAY_SIZE(wm831x_ldo5_resources),
1255 .resources = wm831x_ldo5_resources,
1258 .
name =
"wm831x-aldo",
1260 .num_resources =
ARRAY_SIZE(wm831x_ldo7_resources),
1261 .resources = wm831x_ldo7_resources,
1264 .
name =
"wm831x-alive-ldo",
1266 .num_resources =
ARRAY_SIZE(wm831x_ldo11_resources),
1267 .resources = wm831x_ldo11_resources,
1270 .
name =
"wm831x-on",
1271 .num_resources =
ARRAY_SIZE(wm831x_on_resources),
1272 .resources = wm831x_on_resources,
1275 .
name =
"wm831x-power",
1276 .num_resources =
ARRAY_SIZE(wm831x_power_resources),
1277 .resources = wm831x_power_resources,
1280 .
name =
"wm831x-status",
1282 .num_resources =
ARRAY_SIZE(wm831x_status1_resources),
1283 .resources = wm831x_status1_resources,
1286 .
name =
"wm831x-status",
1288 .num_resources =
ARRAY_SIZE(wm831x_status2_resources),
1289 .resources = wm831x_status2_resources,
1292 .
name =
"wm831x-watchdog",
1293 .num_resources =
ARRAY_SIZE(wm831x_wdt_resources),
1294 .resources = wm831x_wdt_resources,
1298 static struct mfd_cell wm8312_devs[] = {
1300 .name =
"wm831x-backup",
1303 .name =
"wm831x-buckv",
1305 .num_resources =
ARRAY_SIZE(wm831x_dcdc1_resources),
1306 .resources = wm831x_dcdc1_resources,
1309 .
name =
"wm831x-buckv",
1311 .num_resources =
ARRAY_SIZE(wm831x_dcdc2_resources),
1312 .resources = wm831x_dcdc2_resources,
1315 .
name =
"wm831x-buckp",
1317 .num_resources =
ARRAY_SIZE(wm831x_dcdc3_resources),
1318 .resources = wm831x_dcdc3_resources,
1321 .
name =
"wm831x-boostp",
1323 .num_resources =
ARRAY_SIZE(wm831x_dcdc4_resources),
1324 .resources = wm831x_dcdc4_resources,
1327 .
name =
"wm831x-clk",
1330 .name =
"wm831x-epe",
1334 .name =
"wm831x-epe",
1338 .name =
"wm831x-gpio",
1339 .num_resources =
ARRAY_SIZE(wm831x_gpio_resources),
1340 .resources = wm831x_gpio_resources,
1343 .
name =
"wm831x-hwmon",
1346 .name =
"wm831x-isink",
1348 .num_resources =
ARRAY_SIZE(wm831x_isink1_resources),
1349 .resources = wm831x_isink1_resources,
1352 .
name =
"wm831x-isink",
1354 .num_resources =
ARRAY_SIZE(wm831x_isink2_resources),
1355 .resources = wm831x_isink2_resources,
1358 .
name =
"wm831x-ldo",
1360 .num_resources =
ARRAY_SIZE(wm831x_ldo1_resources),
1361 .resources = wm831x_ldo1_resources,
1364 .
name =
"wm831x-ldo",
1366 .num_resources =
ARRAY_SIZE(wm831x_ldo2_resources),
1367 .resources = wm831x_ldo2_resources,
1370 .
name =
"wm831x-ldo",
1372 .num_resources =
ARRAY_SIZE(wm831x_ldo3_resources),
1373 .resources = wm831x_ldo3_resources,
1376 .
name =
"wm831x-ldo",
1378 .num_resources =
ARRAY_SIZE(wm831x_ldo4_resources),
1379 .resources = wm831x_ldo4_resources,
1382 .
name =
"wm831x-ldo",
1384 .num_resources =
ARRAY_SIZE(wm831x_ldo5_resources),
1385 .resources = wm831x_ldo5_resources,
1388 .
name =
"wm831x-ldo",
1390 .num_resources =
ARRAY_SIZE(wm831x_ldo6_resources),
1391 .resources = wm831x_ldo6_resources,
1394 .
name =
"wm831x-aldo",
1396 .num_resources =
ARRAY_SIZE(wm831x_ldo7_resources),
1397 .resources = wm831x_ldo7_resources,
1400 .
name =
"wm831x-aldo",
1402 .num_resources =
ARRAY_SIZE(wm831x_ldo8_resources),
1403 .resources = wm831x_ldo8_resources,
1406 .
name =
"wm831x-aldo",
1408 .num_resources =
ARRAY_SIZE(wm831x_ldo9_resources),
1409 .resources = wm831x_ldo9_resources,
1412 .
name =
"wm831x-aldo",
1414 .num_resources =
ARRAY_SIZE(wm831x_ldo10_resources),
1415 .resources = wm831x_ldo10_resources,
1418 .
name =
"wm831x-alive-ldo",
1420 .num_resources =
ARRAY_SIZE(wm831x_ldo11_resources),
1421 .resources = wm831x_ldo11_resources,
1424 .
name =
"wm831x-on",
1425 .num_resources =
ARRAY_SIZE(wm831x_on_resources),
1426 .resources = wm831x_on_resources,
1429 .
name =
"wm831x-power",
1430 .num_resources =
ARRAY_SIZE(wm831x_power_resources),
1431 .resources = wm831x_power_resources,
1434 .
name =
"wm831x-status",
1436 .num_resources =
ARRAY_SIZE(wm831x_status1_resources),
1437 .resources = wm831x_status1_resources,
1440 .
name =
"wm831x-status",
1442 .num_resources =
ARRAY_SIZE(wm831x_status2_resources),
1443 .resources = wm831x_status2_resources,
1446 .
name =
"wm831x-watchdog",
1447 .num_resources =
ARRAY_SIZE(wm831x_wdt_resources),
1448 .resources = wm831x_wdt_resources,
1452 static struct mfd_cell wm8320_devs[] = {
1454 .name =
"wm831x-backup",
1457 .name =
"wm831x-buckv",
1459 .num_resources =
ARRAY_SIZE(wm831x_dcdc1_resources),
1460 .resources = wm831x_dcdc1_resources,
1463 .
name =
"wm831x-buckv",
1465 .num_resources =
ARRAY_SIZE(wm831x_dcdc2_resources),
1466 .resources = wm831x_dcdc2_resources,
1469 .
name =
"wm831x-buckp",
1471 .num_resources =
ARRAY_SIZE(wm831x_dcdc3_resources),
1472 .resources = wm831x_dcdc3_resources,
1475 .
name =
"wm831x-buckp",
1477 .num_resources =
ARRAY_SIZE(wm8320_dcdc4_buck_resources),
1478 .resources = wm8320_dcdc4_buck_resources,
1481 .
name =
"wm831x-clk",
1484 .name =
"wm831x-gpio",
1485 .num_resources =
ARRAY_SIZE(wm831x_gpio_resources),
1486 .resources = wm831x_gpio_resources,
1489 .
name =
"wm831x-hwmon",
1492 .name =
"wm831x-ldo",
1494 .num_resources =
ARRAY_SIZE(wm831x_ldo1_resources),
1495 .resources = wm831x_ldo1_resources,
1498 .
name =
"wm831x-ldo",
1500 .num_resources =
ARRAY_SIZE(wm831x_ldo2_resources),
1501 .resources = wm831x_ldo2_resources,
1504 .
name =
"wm831x-ldo",
1506 .num_resources =
ARRAY_SIZE(wm831x_ldo3_resources),
1507 .resources = wm831x_ldo3_resources,
1510 .
name =
"wm831x-ldo",
1512 .num_resources =
ARRAY_SIZE(wm831x_ldo4_resources),
1513 .resources = wm831x_ldo4_resources,
1516 .
name =
"wm831x-ldo",
1518 .num_resources =
ARRAY_SIZE(wm831x_ldo5_resources),
1519 .resources = wm831x_ldo5_resources,
1522 .
name =
"wm831x-ldo",
1524 .num_resources =
ARRAY_SIZE(wm831x_ldo6_resources),
1525 .resources = wm831x_ldo6_resources,
1528 .
name =
"wm831x-aldo",
1530 .num_resources =
ARRAY_SIZE(wm831x_ldo7_resources),
1531 .resources = wm831x_ldo7_resources,
1534 .
name =
"wm831x-aldo",
1536 .num_resources =
ARRAY_SIZE(wm831x_ldo8_resources),
1537 .resources = wm831x_ldo8_resources,
1540 .
name =
"wm831x-aldo",
1542 .num_resources =
ARRAY_SIZE(wm831x_ldo9_resources),
1543 .resources = wm831x_ldo9_resources,
1546 .
name =
"wm831x-aldo",
1548 .num_resources =
ARRAY_SIZE(wm831x_ldo10_resources),
1549 .resources = wm831x_ldo10_resources,
1552 .
name =
"wm831x-alive-ldo",
1554 .num_resources =
ARRAY_SIZE(wm831x_ldo11_resources),
1555 .resources = wm831x_ldo11_resources,
1558 .
name =
"wm831x-on",
1559 .num_resources =
ARRAY_SIZE(wm831x_on_resources),
1560 .resources = wm831x_on_resources,
1563 .
name =
"wm831x-status",
1565 .num_resources =
ARRAY_SIZE(wm831x_status1_resources),
1566 .resources = wm831x_status1_resources,
1569 .
name =
"wm831x-status",
1571 .num_resources =
ARRAY_SIZE(wm831x_status2_resources),
1572 .resources = wm831x_status2_resources,
1575 .
name =
"wm831x-watchdog",
1576 .num_resources =
ARRAY_SIZE(wm831x_wdt_resources),
1577 .resources = wm831x_wdt_resources,
1581 static struct mfd_cell touch_devs[] = {
1583 .name =
"wm831x-touch",
1584 .num_resources =
ARRAY_SIZE(wm831x_touch_resources),
1585 .resources = wm831x_touch_resources,
1589 static struct mfd_cell rtc_devs[] = {
1591 .name =
"wm831x-rtc",
1592 .num_resources =
ARRAY_SIZE(wm831x_rtc_resources),
1593 .resources = wm831x_rtc_resources,
1597 static struct mfd_cell backlight_devs[] = {
1599 .name =
"wm831x-backlight",
1610 .readable_reg = wm831x_reg_readable,
1611 .writeable_reg = wm831x_reg_writeable,
1612 .volatile_reg = wm831x_reg_volatile,
1633 dev_err(wm831x->
dev,
"Failed to read parent ID: %d\n", ret);
1641 dev_err(wm831x->
dev,
"Device is not a WM831x: ID %x\n", ret);
1648 dev_err(wm831x->
dev,
"Failed to read revision: %d\n", ret);
1655 dev_err(wm831x->
dev,
"Failed to read device ID: %d\n", ret);
1663 dev_info(wm831x->
dev,
"Device is an engineering sample\n");
1677 dev_info(wm831x->
dev,
"WM8310 revision %c\n",
'A' + rev);
1689 dev_info(wm831x->
dev,
"WM8311 revision %c\n",
'A' + rev);
1701 dev_info(wm831x->
dev,
"WM8312 revision %c\n",
'A' + rev);
1707 dev_info(wm831x->
dev,
"WM8320 revision %c\n",
'A' + rev);
1713 dev_info(wm831x->
dev,
"WM8321 revision %c\n",
'A' + rev);
1719 dev_info(wm831x->
dev,
"WM8325 revision %c\n",
'A' + rev);
1725 dev_info(wm831x->
dev,
"WM8326 revision %c\n",
'A' + rev);
1729 dev_err(wm831x->
dev,
"Unknown WM831x device %04x\n", ret);
1738 dev_warn(wm831x->
dev,
"Device was registered as a WM%lx\n",
1744 dev_err(wm831x->
dev,
"Failed to read security key: %d\n", ret);
1748 dev_warn(wm831x->
dev,
"Security key had non-zero value %x\n",
1757 dev_err(wm831x->
dev,
"pre_init() failed: %d\n", ret);
1828 dev_err(wm831x->
dev,
"Failed to add children\n");
1837 dev_err(wm831x->
dev,
"Failed to read clock status: %d\n", ret);
1846 dev_err(wm831x->
dev,
"Failed to add RTC: %d\n", ret);
1850 dev_info(wm831x->
dev,
"32.768kHz clock disabled, no RTC\n");
1859 dev_err(wm831x->
dev,
"Failed to add backlight: %d\n",
1868 dev_err(wm831x->
dev,
"post_init() failed: %d\n", ret);
1916 "Acknowledging masked charger IRQs: %x\n",
1929 dev_info(wm831x->
dev,
"Initiating shutdown...\n");