diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-06-02 14:18:50 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-07-31 17:28:19 -0400 |
commit | b9d03d999b46f0897492f3aac3e794312e5282db (patch) | |
tree | 8907facb28142cfed290221af4d46973c8ea68b1 /drivers/mfd | |
parent | 266a5e02fe2690637b2318c9fc5c3513937128f4 (diff) |
mfd: Only register wm831x RTC device if the 32.768kHz crystal is enabled
The RTC uses the 32.768kHz crystal so if it's not enabled (and it can only
be enabled via OTP or InstantConfig, not runtime software) the RTC can't
function.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd')
-rw-r--r-- | drivers/mfd/wm831x-core.c | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/drivers/mfd/wm831x-core.c b/drivers/mfd/wm831x-core.c index ff57a1674758..58f033b57efe 100644 --- a/drivers/mfd/wm831x-core.c +++ b/drivers/mfd/wm831x-core.c | |||
@@ -976,11 +976,6 @@ static struct mfd_cell wm8310_devs[] = { | |||
976 | .resources = wm831x_power_resources, | 976 | .resources = wm831x_power_resources, |
977 | }, | 977 | }, |
978 | { | 978 | { |
979 | .name = "wm831x-rtc", | ||
980 | .num_resources = ARRAY_SIZE(wm831x_rtc_resources), | ||
981 | .resources = wm831x_rtc_resources, | ||
982 | }, | ||
983 | { | ||
984 | .name = "wm831x-status", | 979 | .name = "wm831x-status", |
985 | .id = 1, | 980 | .id = 1, |
986 | .num_resources = ARRAY_SIZE(wm831x_status1_resources), | 981 | .num_resources = ARRAY_SIZE(wm831x_status1_resources), |
@@ -1108,11 +1103,6 @@ static struct mfd_cell wm8311_devs[] = { | |||
1108 | .resources = wm831x_power_resources, | 1103 | .resources = wm831x_power_resources, |
1109 | }, | 1104 | }, |
1110 | { | 1105 | { |
1111 | .name = "wm831x-rtc", | ||
1112 | .num_resources = ARRAY_SIZE(wm831x_rtc_resources), | ||
1113 | .resources = wm831x_rtc_resources, | ||
1114 | }, | ||
1115 | { | ||
1116 | .name = "wm831x-status", | 1106 | .name = "wm831x-status", |
1117 | .id = 1, | 1107 | .id = 1, |
1118 | .num_resources = ARRAY_SIZE(wm831x_status1_resources), | 1108 | .num_resources = ARRAY_SIZE(wm831x_status1_resources), |
@@ -1264,11 +1254,6 @@ static struct mfd_cell wm8312_devs[] = { | |||
1264 | .resources = wm831x_power_resources, | 1254 | .resources = wm831x_power_resources, |
1265 | }, | 1255 | }, |
1266 | { | 1256 | { |
1267 | .name = "wm831x-rtc", | ||
1268 | .num_resources = ARRAY_SIZE(wm831x_rtc_resources), | ||
1269 | .resources = wm831x_rtc_resources, | ||
1270 | }, | ||
1271 | { | ||
1272 | .name = "wm831x-status", | 1257 | .name = "wm831x-status", |
1273 | .id = 1, | 1258 | .id = 1, |
1274 | .num_resources = ARRAY_SIZE(wm831x_status1_resources), | 1259 | .num_resources = ARRAY_SIZE(wm831x_status1_resources), |
@@ -1395,11 +1380,6 @@ static struct mfd_cell wm8320_devs[] = { | |||
1395 | .resources = wm831x_on_resources, | 1380 | .resources = wm831x_on_resources, |
1396 | }, | 1381 | }, |
1397 | { | 1382 | { |
1398 | .name = "wm831x-rtc", | ||
1399 | .num_resources = ARRAY_SIZE(wm831x_rtc_resources), | ||
1400 | .resources = wm831x_rtc_resources, | ||
1401 | }, | ||
1402 | { | ||
1403 | .name = "wm831x-status", | 1383 | .name = "wm831x-status", |
1404 | .id = 1, | 1384 | .id = 1, |
1405 | .num_resources = ARRAY_SIZE(wm831x_status1_resources), | 1385 | .num_resources = ARRAY_SIZE(wm831x_status1_resources), |
@@ -1426,6 +1406,13 @@ static struct mfd_cell touch_devs[] = { | |||
1426 | }, | 1406 | }, |
1427 | }; | 1407 | }; |
1428 | 1408 | ||
1409 | static struct mfd_cell rtc_devs[] = { | ||
1410 | { | ||
1411 | .name = "wm831x-rtc", | ||
1412 | .num_resources = ARRAY_SIZE(wm831x_rtc_resources), | ||
1413 | .resources = wm831x_rtc_resources, | ||
1414 | }, | ||
1415 | }; | ||
1429 | 1416 | ||
1430 | static struct mfd_cell backlight_devs[] = { | 1417 | static struct mfd_cell backlight_devs[] = { |
1431 | { | 1418 | { |
@@ -1658,6 +1645,27 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq) | |||
1658 | goto err_irq; | 1645 | goto err_irq; |
1659 | } | 1646 | } |
1660 | 1647 | ||
1648 | /* The RTC can only be used if the 32.768kHz crystal is | ||
1649 | * enabled; this can't be controlled by software at runtime. | ||
1650 | */ | ||
1651 | ret = wm831x_reg_read(wm831x, WM831X_CLOCK_CONTROL_2); | ||
1652 | if (ret < 0) { | ||
1653 | dev_err(wm831x->dev, "Failed to read clock status: %d\n", ret); | ||
1654 | goto err_irq; | ||
1655 | } | ||
1656 | |||
1657 | if (ret & WM831X_XTAL_ENA) { | ||
1658 | ret = mfd_add_devices(wm831x->dev, wm831x_num, | ||
1659 | rtc_devs, ARRAY_SIZE(rtc_devs), | ||
1660 | NULL, wm831x->irq_base); | ||
1661 | if (ret != 0) { | ||
1662 | dev_err(wm831x->dev, "Failed to add RTC: %d\n", ret); | ||
1663 | goto err_irq; | ||
1664 | } | ||
1665 | } else { | ||
1666 | dev_info(wm831x->dev, "32.768kHz clock disabled, no RTC\n"); | ||
1667 | } | ||
1668 | |||
1661 | if (pdata && pdata->backlight) { | 1669 | if (pdata && pdata->backlight) { |
1662 | /* Treat errors as non-critical */ | 1670 | /* Treat errors as non-critical */ |
1663 | ret = mfd_add_devices(wm831x->dev, wm831x_num, backlight_devs, | 1671 | ret = mfd_add_devices(wm831x->dev, wm831x_num, backlight_devs, |