* [PATCH 08/23] mfd/db8500-prcmu: add watchdog accessor functions
@ 2011-08-12 8:28 Linus Walleij
2011-10-03 15:53 ` Samuel Ortiz
0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2011-08-12 8:28 UTC (permalink / raw)
To: Samuel Ortiz, linux-kernel; +Cc: Lee Jones, Jonas Aberg, Linus Walleij
From: Jonas Aberg <jonas.aberg@stericsson.com>
This implements the watchdog accessor functions for the DB8500
PRCMU, making it possible to implement the watchdog driver.
Signed-off-by: Jonas Aberg <jonas.aberg@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/mfd/db8500-prcmu.c | 72 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 72 insertions(+), 0 deletions(-)
diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c
index 28a6090..95498f8 100644
--- a/drivers/mfd/db8500-prcmu.c
+++ b/drivers/mfd/db8500-prcmu.c
@@ -1543,6 +1543,78 @@ int prcmu_stop_temp_sense(void)
return config_hot_period(0xFFFF);
}
+static int prcmu_a9wdog(u8 cmd, u8 d0, u8 d1, u8 d2, u8 d3)
+{
+
+ mutex_lock(&mb4_transfer.lock);
+
+ while (readl(PRCM_MBOX_CPU_VAL) & MBOX_BIT(4))
+ cpu_relax();
+
+ writeb(d0, (tcdm_base + PRCM_REQ_MB4_A9WDOG_0));
+ writeb(d1, (tcdm_base + PRCM_REQ_MB4_A9WDOG_1));
+ writeb(d2, (tcdm_base + PRCM_REQ_MB4_A9WDOG_2));
+ writeb(d3, (tcdm_base + PRCM_REQ_MB4_A9WDOG_3));
+
+ writeb(cmd, (tcdm_base + PRCM_MBOX_HEADER_REQ_MB4));
+
+ writel(MBOX_BIT(4), PRCM_MBOX_CPU_SET);
+ wait_for_completion(&mb4_transfer.work);
+
+ mutex_unlock(&mb4_transfer.lock);
+
+ return 0;
+
+}
+
+int prcmu_config_a9wdog(u8 num, bool sleep_auto_off)
+{
+ BUG_ON(num == 0 || num > 0xf);
+ return prcmu_a9wdog(MB4H_A9WDOG_CONF, num, 0, 0,
+ sleep_auto_off ? A9WDOG_AUTO_OFF_EN :
+ A9WDOG_AUTO_OFF_DIS);
+}
+
+int prcmu_enable_a9wdog(u8 id)
+{
+ return prcmu_a9wdog(MB4H_A9WDOG_EN, id, 0, 0, 0);
+}
+
+int prcmu_disable_a9wdog(u8 id)
+{
+ return prcmu_a9wdog(MB4H_A9WDOG_DIS, id, 0, 0, 0);
+}
+
+int prcmu_kick_a9wdog(u8 id)
+{
+ return prcmu_a9wdog(MB4H_A9WDOG_KICK, id, 0, 0, 0);
+}
+
+/*
+ * timeout is 28 bit, in ms.
+ */
+#define MAX_WATCHDOG_TIMEOUT 131000
+int prcmu_load_a9wdog(u8 id, u32 timeout)
+{
+ if (timeout > MAX_WATCHDOG_TIMEOUT)
+ /*
+ * Due to calculation bug in prcmu fw, timeouts
+ * can't be bigger than 131 seconds.
+ */
+ return -EINVAL;
+
+ return prcmu_a9wdog(MB4H_A9WDOG_LOAD,
+ (id & A9WDOG_ID_MASK) |
+ /*
+ * Put the lowest 28 bits of timeout at
+ * offset 4. Four first bits are used for id.
+ */
+ (u8)((timeout << 4) & 0xf0),
+ (u8)((timeout >> 4) & 0xff),
+ (u8)((timeout >> 12) & 0xff),
+ (u8)((timeout >> 20) & 0xff));
+}
+
/**
* prcmu_set_clock_divider() - Configure the clock divider.
* @clock: The clock for which the request is made.
--
1.7.3.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 08/23] mfd/db8500-prcmu: add watchdog accessor functions
2011-08-12 8:28 [PATCH 08/23] mfd/db8500-prcmu: add watchdog accessor functions Linus Walleij
@ 2011-10-03 15:53 ` Samuel Ortiz
2011-10-05 14:17 ` Linus Walleij
0 siblings, 1 reply; 3+ messages in thread
From: Samuel Ortiz @ 2011-10-03 15:53 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-kernel, Lee Jones, Jonas Aberg, Linus Walleij
Hi Linus,
On Fri, Aug 12, 2011 at 10:28:33AM +0200, Linus Walleij wrote:
> +int prcmu_config_a9wdog(u8 num, bool sleep_auto_off)
> +{
> + BUG_ON(num == 0 || num > 0xf);
> + return prcmu_a9wdog(MB4H_A9WDOG_CONF, num, 0, 0,
> + sleep_auto_off ? A9WDOG_AUTO_OFF_EN :
> + A9WDOG_AUTO_OFF_DIS);
> +}
> +
> +int prcmu_enable_a9wdog(u8 id)
> +{
> + return prcmu_a9wdog(MB4H_A9WDOG_EN, id, 0, 0, 0);
> +}
> +
> +int prcmu_disable_a9wdog(u8 id)
> +{
> + return prcmu_a9wdog(MB4H_A9WDOG_DIS, id, 0, 0, 0);
> +}
> +
> +int prcmu_kick_a9wdog(u8 id)
> +{
> + return prcmu_a9wdog(MB4H_A9WDOG_KICK, id, 0, 0, 0);
> +}
So I suppose you will eventually export those symbols ?
Cheers,
Samuel.
--
Intel Open Source Technology Centre
http://oss.intel.com/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 08/23] mfd/db8500-prcmu: add watchdog accessor functions
2011-10-03 15:53 ` Samuel Ortiz
@ 2011-10-05 14:17 ` Linus Walleij
0 siblings, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2011-10-05 14:17 UTC (permalink / raw)
To: Samuel Ortiz; +Cc: Linus Walleij, linux-kernel, Lee Jones, Jonas Aberg
On Mon, Oct 3, 2011 at 5:53 PM, Samuel Ortiz <sameo@linux.intel.com> wrote:
>> +int prcmu_kick_a9wdog(u8 id)
>> +{
>> + return prcmu_a9wdog(MB4H_A9WDOG_KICK, id, 0, 0, 0);
>> +}
>
> So I suppose you will eventually export those symbols ?
Not really, both this driver and the watchdog driver are of the
"always-compile-in" (bool) type, you really don't want to load the
watchdog as a module, because then the watchdog cannot safeguard
the module loading process to that point :-P
So we just call these from compile-in code.
I actually have Jonas' watchdog driver ready as well if you want
me to submit it on top of this patch set so you get the whole
picture.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-10-05 14:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-12 8:28 [PATCH 08/23] mfd/db8500-prcmu: add watchdog accessor functions Linus Walleij
2011-10-03 15:53 ` Samuel Ortiz
2011-10-05 14:17 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®