summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAlejandro Gonzalez <alex.gonzalez@digi.com>2010-06-23 14:13:29 +0200
committerAlejandro Gonzalez <alex.gonzalez@digi.com>2010-06-23 14:31:10 +0200
commita7ffa03d4fd492441def38a3c770615b342c7e6a (patch)
tree583ab7e1873a34a2b2a18b6680a24e1f269a4b5f /drivers
parent436bc07e9deda38533233e1b1d822f0b360d1f60 (diff)
ccwmx51: Do not unconditionally set the PMIC as a suspend wake up source
This behaviour was causing that even when the user has not explicitely set a wakeup source the system was suspending without a way to awake. With this change the RTC wake up source is set up when its suspend method is called, making it possible to check for enabled wake up sources on the platform suspend enter. Signed-off-by: Alejandro Gonzalez <alex.gonzalez@digi.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mxc/pmic/core/pmic_core_i2c.c16
-rw-r--r--drivers/mxc/pmic/core/pmic_core_spi.c18
-rw-r--r--drivers/rtc/rtc-mc13892.c11
3 files changed, 36 insertions, 9 deletions
diff --git a/drivers/mxc/pmic/core/pmic_core_i2c.c b/drivers/mxc/pmic/core/pmic_core_i2c.c
index d2f982efb2a1..12f394d69088 100644
--- a/drivers/mxc/pmic/core/pmic_core_i2c.c
+++ b/drivers/mxc/pmic/core/pmic_core_i2c.c
@@ -71,6 +71,13 @@ static struct platform_device power_ldm = {
.name = "pmic_power",
.id = 1,
};
+
+static struct resource pmic_rtc_resources[] = {
+ {
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
static struct platform_device rtc_ldm = {
.name = "pmic_rtc",
.id = 1,
@@ -92,13 +99,17 @@ static struct platform_device bleds_ldm = {
.id = 'b',
};
-static void pmic_pdev_register(struct device *dev)
+static void pmic_pdev_register(struct i2c_client *client)
{
+ struct device *dev = client->dev;
+
platform_device_register(&adc_ldm);
if (!cpu_is_mx53())
platform_device_register(&battery_ldm);
+ rtc_ldm.resource->start = client->irq;
+ rtc_ldm.resource->end = client->irq;
platform_device_register(&rtc_ldm);
platform_device_register(&power_ldm);
platform_device_register(&light_ldm);
@@ -270,7 +281,6 @@ static int __devinit pmic_probe(struct i2c_client *client,
dev_err(&client->dev, "request irq %d error!\n", pmic_irq);
return ret;
}
- enable_irq_wake(pmic_irq);
if (plat_data && plat_data->init) {
ret = plat_data->init(mc13892);
@@ -282,7 +292,7 @@ static int __devinit pmic_probe(struct i2c_client *client,
if (ret)
dev_err(&client->dev, "create device file failed!\n");
- pmic_pdev_register(&client->dev);
+ pmic_pdev_register(&client);
dev_info(&client->dev, "Loaded\n");
diff --git a/drivers/mxc/pmic/core/pmic_core_spi.c b/drivers/mxc/pmic/core/pmic_core_spi.c
index 300ae9aafdaa..b685b5f51261 100644
--- a/drivers/mxc/pmic/core/pmic_core_spi.c
+++ b/drivers/mxc/pmic/core/pmic_core_spi.c
@@ -41,7 +41,7 @@
/*
* Static functions
*/
-static void pmic_pdev_register(void);
+static void pmic_pdev_register(struct spi_device *spi);
static void pmic_pdev_unregister(void);
/*
@@ -59,9 +59,17 @@ static struct platform_device power_ldm = {
.name = "pmic_power",
.id = 1,
};
+static struct resource pmic_rtc_resources[] = {
+ {
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
static struct platform_device rtc_ldm = {
.name = "pmic_rtc",
.id = 1,
+ .num_resources = ARRAY_SIZE(pmic_rtc_resources),
+ .resource = pmic_rtc_resources,
};
static struct platform_device light_ldm = {
.name = "pmic_light",
@@ -93,10 +101,12 @@ extern pmic_version_t mxc_pmic_version;
* This function registers platform device structures for
* PMIC client drivers.
*/
-static void pmic_pdev_register(void)
+static void pmic_pdev_register(struct spi_device *spi)
{
platform_device_register(&adc_ldm);
platform_device_register(&battery_ldm);
+ rtc_ldm.resource->start = spi->irq;
+ rtc_ldm.resource->end = spi->irq;
platform_device_register(&rtc_ldm);
platform_device_register(&power_ldm);
platform_device_register(&light_ldm);
@@ -210,8 +220,6 @@ static int __devinit pmic_probe(struct spi_device *spi)
return ret;
}
- enable_irq_wake(spi->irq);
-
if (plat_data && plat_data->init) {
ret = plat_data->init(spi_get_drvdata(spi));
if (ret != 0) {
@@ -223,7 +231,7 @@ static int __devinit pmic_probe(struct spi_device *spi)
power_ldm.dev.platform_data = spi->dev.platform_data;
- pmic_pdev_register();
+ pmic_pdev_register(spi);
printk(KERN_INFO "Device %s probed\n", dev_name(&spi->dev));
diff --git a/drivers/rtc/rtc-mc13892.c b/drivers/rtc/rtc-mc13892.c
index e579c1853a26..3b7e3af4e54c 100644
--- a/drivers/rtc/rtc-mc13892.c
+++ b/drivers/rtc/rtc-mc13892.c
@@ -207,7 +207,8 @@ static int mxc_rtc_probe(struct platform_device *pdev)
pdata->event.param = pdata;
CHECK_ERROR(pmic_event_subscribe(EVENT_TODAI, pdata->event));
- device_init_wakeup(&pdev->dev, 1);
+ device_init_wakeup(&pdev->dev, 0);
+ device_set_wakeup_capable(&pdev->dev, 1);
pdata->rtc = rtc_device_register(pdev->name, &pdev->dev,
&mxc_rtc_ops, THIS_MODULE);
@@ -229,12 +230,20 @@ static int __exit mxc_rtc_remove(struct platform_device *pdev)
return 0;
}
+static int mxc_rtc_suspend(struct platform_device *pdev, pm_message_t state)
+{
+ if (device_may_wakeup(&pdev->dev))
+ enable_irq_wake(platform_get_irq(pdev, 0));
+ return 0;
+}
+
static struct platform_driver mxc_rtc_driver = {
.driver = {
.name = "pmic_rtc",
},
.probe = mxc_rtc_probe,
.remove = __exit_p(mxc_rtc_remove),
+ .suspend = mxc_rtc_suspend,
};
static int __init mxc_rtc_init(void)