From: Jon Hunter <jon-hunter@ti.com>
To: Tony Lindgren <tony@atomide.com>
Cc: linux-omap@vger.kernel.org, "Cousson, Benoit" <b-cousson@ti.com>
Subject: Re: 4430sdp nfsroot broken with ff5c9059
Date: Tue, 16 Apr 2013 12:14:52 -0500 [thread overview]
Message-ID: <516D870C.2030108@ti.com> (raw)
In-Reply-To: <20130415212756.GQ10155@atomide.com>
On 04/15/2013 04:27 PM, Tony Lindgren wrote:
> * Jon Hunter <jon-hunter@ti.com> [130415 11:15]:
...
>> From 56598ba51a75481b050433bb38b7ae31a5ed4ae8 Mon Sep 17 00:00:00 2001
>> From: Jon Hunter <jon-hunter@ti.com>
>> Date: Mon, 15 Apr 2013 13:06:54 -0500
>> Subject: [PATCH] gpio/omap: ensure gpio context is initialised
>
> Seems to work thanks:
>
> Tested-by: Tony Lindgren <tony@atomide.com>
Thanks. I have been cleaning this up and updating a little. Care to
re-test this version? If it is good I will send it out.
By the way, I realise I need to add a similar fix for dmtimer :-p
Cheers
Jon
>From 3980952af35054e50d743691fc3e0867de5b0f4d Mon Sep 17 00:00:00 2001
From: Jon Hunter <jon-hunter@ti.com>
Date: Mon, 15 Apr 2013 13:06:54 -0500
Subject: [PATCH] gpio/omap: ensure gpio context is initialised
Commit a2797be (gpio/omap: force restore if context loss is not
detectable) broke gpio support for OMAP when booting with device-tree
because a restore of the gpio context being performed without ever
initialising the gpio context. In other words, the context restored was
bad.
This problem could also occur in the non device-tree case, however, it
is much less likely because when booting without device-tree we can
detect context loss via a platform specific API and so context restore
is performed less often.
Nevertheless we should ensure that the gpio context is initialised
during the probe for gpio banks that could lose their state regardless
of whether we are booting with device-tree or not.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
---
drivers/gpio/gpio-omap.c | 53 +++++++++++++++++++++++++++++++++++++---------
1 file changed, 43 insertions(+), 10 deletions(-)
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 0557529..444451b 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -70,6 +70,7 @@ struct gpio_bank {
bool is_mpuio;
bool dbck_flag;
bool loses_context;
+ bool context_valid;
int stride;
u32 width;
int context_loss_count;
@@ -1085,6 +1086,7 @@ static void omap_gpio_chip_init(struct gpio_bank *bank)
}
static const struct of_device_id omap_gpio_match[];
+static void omap_gpio_init_context(struct gpio_bank *p);
static int omap_gpio_probe(struct platform_device *pdev)
{
@@ -1179,8 +1181,10 @@ static int omap_gpio_probe(struct platform_device *pdev)
omap_gpio_chip_init(bank);
omap_gpio_show_rev(bank);
- if (bank->loses_context)
+ if (bank->loses_context) {
bank->get_context_loss_count = pdata->get_context_loss_count;
+ omap_gpio_init_context(bank);
+ }
pm_runtime_put(bank->dev);
@@ -1269,6 +1273,14 @@ static int omap_gpio_runtime_resume(struct device *dev)
int c;
spin_lock_irqsave(&bank->lock, flags);
+
+ /*
+ * On the first resume during the probe, the context has not
+ * been initialised and so if the context is not valid return.
+ */
+ if (!bank->context_valid)
+ goto done;
+
_gpio_dbck_enable(bank);
/*
@@ -1287,19 +1299,15 @@ static int omap_gpio_runtime_resume(struct device *dev)
omap_gpio_restore_context(bank);
} else {
c = bank->get_context_loss_count(bank->dev);
- if (c != bank->context_loss_count) {
+ if (c != bank->context_loss_count)
omap_gpio_restore_context(bank);
- } else {
- spin_unlock_irqrestore(&bank->lock, flags);
- return 0;
- }
+ else
+ goto done;
}
}
- if (!bank->workaround_enabled) {
- spin_unlock_irqrestore(&bank->lock, flags);
- return 0;
- }
+ if (!bank->workaround_enabled)
+ goto done;
l = __raw_readl(bank->base + bank->regs->datain);
@@ -1352,6 +1360,7 @@ static int omap_gpio_runtime_resume(struct device *dev)
}
bank->workaround_enabled = false;
+done:
spin_unlock_irqrestore(&bank->lock, flags);
return 0;
@@ -1385,6 +1394,29 @@ void omap2_gpio_resume_after_idle(void)
}
#if defined(CONFIG_PM_RUNTIME)
+static void omap_gpio_init_context(struct gpio_bank *p)
+{
+ struct omap_gpio_reg_offs *regs = p->regs;
+ void __iomem *base = p->base;
+
+ p->context.ctrl = __raw_readl(base + regs->ctrl);
+ p->context.oe = __raw_readl(base + regs->direction);
+ p->context.wake_en = __raw_readl(base + regs->wkup_en);
+ p->context.leveldetect0 = __raw_readl(base + regs->leveldetect0);
+ p->context.leveldetect1 = __raw_readl(base + regs->leveldetect1);
+ p->context.risingdetect = __raw_readl(base + regs->risingdetect);
+ p->context.fallingdetect = __raw_readl(base + regs->fallingdetect);
+ p->context.irqenable1 = __raw_readl(base + regs->irqenable);
+ p->context.irqenable2 = __raw_readl(base + regs->irqenable2);
+
+ if (regs->set_dataout && p->regs->clr_dataout)
+ p->context.dataout = __raw_readl(base + regs->set_dataout);
+ else
+ p->context.dataout = __raw_readl(base + regs->dataout);
+
+ p->context_valid = true;
+}
+
static void omap_gpio_restore_context(struct gpio_bank *bank)
{
__raw_writel(bank->context.wake_en,
@@ -1422,6 +1454,7 @@ static void omap_gpio_restore_context(struct gpio_bank *bank)
#else
#define omap_gpio_runtime_suspend NULL
#define omap_gpio_runtime_resume NULL
+#define omap_gpio_init_context NULL
#endif
static const struct dev_pm_ops gpio_pm_ops = {
--
1.7.10.4
next prev parent reply other threads:[~2013-04-16 17:14 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-09 21:23 4430sdp nfsroot broken with ff5c9059 Tony Lindgren
2013-04-10 17:31 ` Jon Hunter
2013-04-10 18:20 ` Tony Lindgren
2013-04-10 20:43 ` Jon Hunter
2013-04-10 20:54 ` Tony Lindgren
2013-04-10 22:25 ` Jon Hunter
2013-04-10 22:27 ` Tony Lindgren
2013-04-13 0:06 ` Tony Lindgren
2013-04-13 2:17 ` Jon Hunter
2013-04-13 16:50 ` Tony Lindgren
2013-04-15 16:57 ` Jon Hunter
2013-04-15 18:10 ` Jon Hunter
2013-04-15 21:27 ` Tony Lindgren
2013-04-16 17:14 ` Jon Hunter [this message]
2013-04-16 18:06 ` Tony Lindgren
2013-04-16 18:40 ` Jon Hunter
2013-04-17 0:56 ` Tony Lindgren
2013-04-10 23:58 ` Javier Martinez Canillas
2013-04-11 0:28 ` Jon Hunter
2013-04-11 0:50 ` Javier Martinez Canillas
2013-04-11 9:22 ` Benoit Cousson
2013-04-11 9:58 ` Javier Martinez Canillas
2013-05-08 22:05 ` Tony Lindgren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=516D870C.2030108@ti.com \
--to=jon-hunter@ti.com \
--cc=b-cousson@ti.com \
--cc=linux-omap@vger.kernel.org \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.