Commit b9d03d99 authored by Mark Brown's avatar Mark Brown Committed by Samuel Ortiz

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: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 266a5e02
...@@ -975,11 +975,6 @@ static struct mfd_cell wm8310_devs[] = { ...@@ -975,11 +975,6 @@ static struct mfd_cell wm8310_devs[] = {
.num_resources = ARRAY_SIZE(wm831x_power_resources), .num_resources = ARRAY_SIZE(wm831x_power_resources),
.resources = wm831x_power_resources, .resources = wm831x_power_resources,
}, },
{
.name = "wm831x-rtc",
.num_resources = ARRAY_SIZE(wm831x_rtc_resources),
.resources = wm831x_rtc_resources,
},
{ {
.name = "wm831x-status", .name = "wm831x-status",
.id = 1, .id = 1,
...@@ -1107,11 +1102,6 @@ static struct mfd_cell wm8311_devs[] = { ...@@ -1107,11 +1102,6 @@ static struct mfd_cell wm8311_devs[] = {
.num_resources = ARRAY_SIZE(wm831x_power_resources), .num_resources = ARRAY_SIZE(wm831x_power_resources),
.resources = wm831x_power_resources, .resources = wm831x_power_resources,
}, },
{
.name = "wm831x-rtc",
.num_resources = ARRAY_SIZE(wm831x_rtc_resources),
.resources = wm831x_rtc_resources,
},
{ {
.name = "wm831x-status", .name = "wm831x-status",
.id = 1, .id = 1,
...@@ -1263,11 +1253,6 @@ static struct mfd_cell wm8312_devs[] = { ...@@ -1263,11 +1253,6 @@ static struct mfd_cell wm8312_devs[] = {
.num_resources = ARRAY_SIZE(wm831x_power_resources), .num_resources = ARRAY_SIZE(wm831x_power_resources),
.resources = wm831x_power_resources, .resources = wm831x_power_resources,
}, },
{
.name = "wm831x-rtc",
.num_resources = ARRAY_SIZE(wm831x_rtc_resources),
.resources = wm831x_rtc_resources,
},
{ {
.name = "wm831x-status", .name = "wm831x-status",
.id = 1, .id = 1,
...@@ -1394,11 +1379,6 @@ static struct mfd_cell wm8320_devs[] = { ...@@ -1394,11 +1379,6 @@ static struct mfd_cell wm8320_devs[] = {
.num_resources = ARRAY_SIZE(wm831x_on_resources), .num_resources = ARRAY_SIZE(wm831x_on_resources),
.resources = wm831x_on_resources, .resources = wm831x_on_resources,
}, },
{
.name = "wm831x-rtc",
.num_resources = ARRAY_SIZE(wm831x_rtc_resources),
.resources = wm831x_rtc_resources,
},
{ {
.name = "wm831x-status", .name = "wm831x-status",
.id = 1, .id = 1,
...@@ -1426,6 +1406,13 @@ static struct mfd_cell touch_devs[] = { ...@@ -1426,6 +1406,13 @@ static struct mfd_cell touch_devs[] = {
}, },
}; };
static struct mfd_cell rtc_devs[] = {
{
.name = "wm831x-rtc",
.num_resources = ARRAY_SIZE(wm831x_rtc_resources),
.resources = wm831x_rtc_resources,
},
};
static struct mfd_cell backlight_devs[] = { static struct mfd_cell backlight_devs[] = {
{ {
...@@ -1658,6 +1645,27 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq) ...@@ -1658,6 +1645,27 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
goto err_irq; goto err_irq;
} }
/* The RTC can only be used if the 32.768kHz crystal is
* enabled; this can't be controlled by software at runtime.
*/
ret = wm831x_reg_read(wm831x, WM831X_CLOCK_CONTROL_2);
if (ret < 0) {
dev_err(wm831x->dev, "Failed to read clock status: %d\n", ret);
goto err_irq;
}
if (ret & WM831X_XTAL_ENA) {
ret = mfd_add_devices(wm831x->dev, wm831x_num,
rtc_devs, ARRAY_SIZE(rtc_devs),
NULL, wm831x->irq_base);
if (ret != 0) {
dev_err(wm831x->dev, "Failed to add RTC: %d\n", ret);
goto err_irq;
}
} else {
dev_info(wm831x->dev, "32.768kHz clock disabled, no RTC\n");
}
if (pdata && pdata->backlight) { if (pdata && pdata->backlight) {
/* Treat errors as non-critical */ /* Treat errors as non-critical */
ret = mfd_add_devices(wm831x->dev, wm831x_num, backlight_devs, ret = mfd_add_devices(wm831x->dev, wm831x_num, backlight_devs,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment