From: grant.likely@secretlab.ca (Grant Likely)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/4] ARM: kirkwood: convert orion-wdt to fdt.
Date: Fri, 02 Mar 2012 01:22:40 -0600 [thread overview]
Message-ID: <20120302072240.C16033E2D8D@localhost> (raw)
In-Reply-To: <2f29e88b98b2bcff0c241996e6d7216a60995d2d.1330625878.git.jason@lakedaemon.net>
On Thu, 1 Mar 2012 18:20:55 +0000, Jason Cooper <jason@lakedaemon.net> wrote:
> Converted register address to a variable so that it could be set from
> fdt. Also, pull clock frequency from fdt and clean up failure logic a
> bit.
>
> Same as rtc-mv, this device is used in all kirkwood boards. So, it is
> placed in kirkwood.dtsi.
>
> Signed-off-by: Jason Cooper <jason@lakedaemon.net>
> ---
> arch/arm/boot/dts/kirkwood.dtsi | 6 +++++
> arch/arm/mach-kirkwood/board-dt.c | 1 -
> arch/arm/mach-kirkwood/common.c | 2 +-
> arch/arm/mach-kirkwood/common.h | 1 -
> drivers/watchdog/orion_wdt.c | 44 ++++++++++++++++++++++++++----------
> 5 files changed, 39 insertions(+), 15 deletions(-)
>
> diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi
> index 5fb185c..bf28424 100644
> --- a/arch/arm/boot/dts/kirkwood.dtsi
> +++ b/arch/arm/boot/dts/kirkwood.dtsi
> @@ -8,5 +8,11 @@
> reg = <0xf1010300 0x1f>;
> interrupts = <53>;
> };
> +
> + wdt at fed20300 {
> + compatible = "marvell,orion-wdt";
> + reg = <0xfed20300 0x28>;
> + clock-frequency = <200000000>;
> + };
> };
>
> diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c
> index 6fc41ae..7ef5fb7 100644
> --- a/arch/arm/mach-kirkwood/board-dt.c
> +++ b/arch/arm/mach-kirkwood/board-dt.c
> @@ -135,7 +135,6 @@ static void __init kirkwood_dt_init(void)
> #endif
>
> /* internal devices that every board has */
> - kirkwood_wdt_init();
> kirkwood_xor0_init();
> kirkwood_xor1_init();
> kirkwood_crypto_init();
> diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
> index 0c0375f..35dc40b 100644
> --- a/arch/arm/mach-kirkwood/common.c
> +++ b/arch/arm/mach-kirkwood/common.c
> @@ -303,7 +303,7 @@ void __init kirkwood_xor1_init(void)
> /*****************************************************************************
> * Watchdog
> ****************************************************************************/
> -void __init kirkwood_wdt_init(void)
> +static void __init kirkwood_wdt_init(void)
> {
> orion_wdt_init(kirkwood_tclk);
> }
> diff --git a/arch/arm/mach-kirkwood/common.h b/arch/arm/mach-kirkwood/common.h
> index ca08826..ac4b2fb 100644
> --- a/arch/arm/mach-kirkwood/common.h
> +++ b/arch/arm/mach-kirkwood/common.h
> @@ -53,7 +53,6 @@ void kirkwood_restart(char, const char *);
>
> char *kirkwood_id(void);
> void kirkwood_l2_init(void);
> -void kirkwood_wdt_init(void);
Similar comment here; patch undoes changes made in patch 2.
> void kirkwood_xor0_init(void);
> void kirkwood_xor1_init(void);
> void kirkwood_crypto_init(void);
> diff --git a/drivers/watchdog/orion_wdt.c b/drivers/watchdog/orion_wdt.c
> index 4ad78f8..4be76ca 100644
> --- a/drivers/watchdog/orion_wdt.c
> +++ b/drivers/watchdog/orion_wdt.c
> @@ -17,6 +17,7 @@
> #include <linux/fs.h>
> #include <linux/miscdevice.h>
> #include <linux/platform_device.h>
> +#include <linux/of.h>
> #include <linux/watchdog.h>
> #include <linux/init.h>
> #include <linux/uaccess.h>
> @@ -28,9 +29,9 @@
> /*
> * Watchdog timer block registers.
> */
> -#define TIMER_CTRL (TIMER_VIRT_BASE + 0x0000)
> +#define TIMER_CTRL 0x0000
> #define WDT_EN 0x0010
> -#define WDT_VAL (TIMER_VIRT_BASE + 0x0024)
> +#define WDT_VAL 0x0024
>
> #define WDT_MAX_CYCLE_COUNT 0xffffffff
> #define WDT_IN_USE 0
> @@ -40,6 +41,7 @@ static int nowayout = WATCHDOG_NOWAYOUT;
> static int heartbeat = -1; /* module parameter (seconds) */
> static unsigned int wdt_max_duration; /* (seconds) */
> static unsigned int wdt_tclk;
> +static unsigned int wdt_reg;
> static unsigned long wdt_status;
> static DEFINE_SPINLOCK(wdt_lock);
>
> @@ -48,7 +50,7 @@ static void orion_wdt_ping(void)
> spin_lock(&wdt_lock);
>
> /* Reload watchdog duration */
> - writel(wdt_tclk * heartbeat, WDT_VAL);
> + writel(wdt_tclk * heartbeat, wdt_reg + WDT_VAL);
>
> spin_unlock(&wdt_lock);
> }
> @@ -60,7 +62,7 @@ static void orion_wdt_enable(void)
> spin_lock(&wdt_lock);
>
> /* Set watchdog duration */
> - writel(wdt_tclk * heartbeat, WDT_VAL);
> + writel(wdt_tclk * heartbeat, wdt_reg + WDT_VAL);
>
> /* Clear watchdog timer interrupt */
> reg = readl(BRIDGE_CAUSE);
> @@ -68,9 +70,9 @@ static void orion_wdt_enable(void)
> writel(reg, BRIDGE_CAUSE);
>
> /* Enable watchdog timer */
> - reg = readl(TIMER_CTRL);
> + reg = readl(wdt_reg + TIMER_CTRL);
> reg |= WDT_EN;
> - writel(reg, TIMER_CTRL);
> + writel(reg, wdt_reg + TIMER_CTRL);
>
> /* Enable reset on watchdog */
> reg = readl(RSTOUTn_MASK);
> @@ -92,9 +94,9 @@ static void orion_wdt_disable(void)
> writel(reg, RSTOUTn_MASK);
>
> /* Disable watchdog timer */
> - reg = readl(TIMER_CTRL);
> + reg = readl(wdt_reg + TIMER_CTRL);
> reg &= ~WDT_EN;
> - writel(reg, TIMER_CTRL);
> + writel(reg, wdt_reg + TIMER_CTRL);
>
> spin_unlock(&wdt_lock);
> }
> @@ -102,7 +104,7 @@ static void orion_wdt_disable(void)
> static int orion_wdt_get_timeleft(int *time_left)
> {
> spin_lock(&wdt_lock);
> - *time_left = readl(WDT_VAL) / wdt_tclk;
> + *time_left = readl(wdt_reg + WDT_VAL) / wdt_tclk;
> spin_unlock(&wdt_lock);
> return 0;
> }
> @@ -236,15 +238,23 @@ static struct miscdevice orion_wdt_miscdev = {
> static int __devinit orion_wdt_probe(struct platform_device *pdev)
> {
> struct orion_wdt_platform_data *pdata = pdev->dev.platform_data;
> + struct device_node *np = pdev->dev.of_node;
> int ret;
>
> - if (pdata) {
> + if (pdata)
> wdt_tclk = pdata->tclk;
> - } else {
> - printk(KERN_ERR "Orion Watchdog misses platform data\n");
> +
> + of_property_read_u32(np, "clock-frequency", &wdt_tclk);
> +
> + if (!wdt_tclk) {
> + printk(KERN_ERR "Orion Watchdog can't get clock freq\n");
> return -ENODEV;
> }
>
> + wdt_reg = TIMER_VIRT_BASE;
> +
> + of_property_read_u32(np, "reg", &wdt_reg);
> +
Never decode 'reg' directly. Always use platform_get_resource() for
platform devices. That works for DT and non-DT users.
> if (orion_wdt_miscdev.parent)
> return -EBUSY;
> orion_wdt_miscdev.parent = &pdev->dev;
> @@ -284,6 +294,15 @@ static void orion_wdt_shutdown(struct platform_device *pdev)
> orion_wdt_disable();
> }
>
> +#ifdef CONFIG_OF
> +static struct of_device_id orion_wdt_of_match_table[] = {
> + { .compatible = "marvell,orion-wdt", },
> + {},
> +};
> +#else
> +#define orion_wdt_of_match_table NULL
> +#endif
> +
> static struct platform_driver orion_wdt_driver = {
> .probe = orion_wdt_probe,
> .remove = __devexit_p(orion_wdt_remove),
> @@ -291,6 +310,7 @@ static struct platform_driver orion_wdt_driver = {
> .driver = {
> .owner = THIS_MODULE,
> .name = "orion_wdt",
> + .of_match_table = orion_wdt_of_match_table,
of_match_ptr()
> },
> };
>
> --
> 1.7.3.4
>
--
email sent from notmuch.vim plugin
next prev parent reply other threads:[~2012-03-02 7:22 UTC|newest]
Thread overview: 136+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-01 18:20 [PATCH 0/4] ARM: kirkwood: fdt: convert kirkwood init funcs to fdt Jason Cooper
2012-03-01 18:20 ` [PATCH 1/4] ARM: kirkwood: move var setting to correct location Jason Cooper
2012-03-01 18:20 ` [PATCH 2/4] ARM: kirkwood: fdt: absorb kirkwood_init() Jason Cooper
2012-03-02 7:09 ` Grant Likely
2012-03-01 18:20 ` [PATCH 3/4] ARM: kirkwood: convert rtc-mv to fdt Jason Cooper
2012-03-01 19:35 ` Arnd Bergmann
2012-03-01 21:26 ` Jason
2012-03-02 7:19 ` Grant Likely
2012-03-02 9:48 ` Arnd Bergmann
2012-03-02 16:27 ` Jason
2012-03-04 14:59 ` Michael Walle
2012-03-04 16:48 ` Arnd Bergmann
2012-03-04 22:27 ` Jason
2012-03-04 23:22 ` Michael Walle
2012-03-01 18:20 ` [PATCH 4/4] ARM: kirkwood: convert orion-wdt " Jason Cooper
2012-03-01 19:48 ` Arnd Bergmann
2012-03-02 7:22 ` Grant Likely [this message]
2012-03-02 9:15 ` Simon Guinot
2012-03-02 14:15 ` Jason
2012-03-02 14:56 ` Arnd Bergmann
2012-03-02 15:36 ` Jason
2012-03-02 16:48 ` Arnd Bergmann
2012-03-02 17:02 ` Jason
2012-03-02 22:36 ` Andrew Lunn
2012-03-03 22:54 ` Jason
2012-03-01 19:50 ` [PATCH 0/4] ARM: kirkwood: fdt: convert kirkwood init funcs " Arnd Bergmann
2012-03-01 20:01 ` Jason
2012-03-01 20:28 ` Arnd Bergmann
2012-03-01 21:23 ` Jason
2012-03-01 22:14 ` Arnd Bergmann
2012-03-02 16:31 ` Jason
2012-03-02 16:58 ` Arnd Bergmann
2012-03-02 17:04 ` Jason
2012-03-02 17:50 ` [PATCH 0/5 v2] " Jason Cooper
2012-03-02 17:50 ` [PATCH 1/5 v2] ARM: kirkwood: covert orion-spi " Jason Cooper
2012-03-04 18:12 ` Michael Walle
2012-03-04 20:29 ` Arnd Bergmann
2012-03-02 17:50 ` [PATCH 2/5] ARM: kirkwood: move var setting to correct location Jason Cooper
2012-03-02 17:50 ` [PATCH 3/5 v2] ARM: kirkwood: fdt: absorb kirkwood_init() Jason Cooper
2012-03-02 17:50 ` [PATCH 4/5 v2] ARM: kirkwood: convert rtc-mv to fdt Jason Cooper
2012-03-04 15:12 ` Michael Walle
2012-03-04 16:50 ` Arnd Bergmann
2012-03-05 0:17 ` Jason
2012-03-02 17:50 ` [PATCH 5/5 v2] ARM: kirkwood: convert orion-wdt " Jason Cooper
2012-03-02 18:32 ` Arnd Bergmann
2012-03-02 19:57 ` Jason
2012-03-02 20:02 ` Arnd Bergmann
[not found] ` <20120302200034.GQ11986@titan.lakedaemon.net>
2012-03-02 20:35 ` [PULL REQUEST v2] ARM: kirkwood: fdt: convert kirkwood init funcs " Arnd Bergmann
2012-03-02 21:18 ` Arnd Bergmann
2012-03-05 18:49 ` Nicolas Pitre
2012-03-05 19:15 ` Jason
2012-03-05 20:16 ` Arnd Bergmann
2012-03-05 20:29 ` Jason
2012-03-05 20:43 ` Nicolas Pitre
2012-03-05 21:17 ` Jason
2012-03-05 21:27 ` Nicolas Pitre
2012-03-06 14:29 ` Jason
2012-03-03 10:08 ` [PATCH 5/5 v2] ARM: kirkwood: convert orion-wdt " Russell King - ARM Linux
2012-03-03 23:05 ` Jason
2012-03-02 17:52 ` [PULL REQUEST] ARM: kirkwood: fdt: convert kirkwood init funcs " Jason
2012-03-02 17:56 ` Jason
2012-03-07 3:44 ` [PATCH 0/14 v3] ARM: kirkwood: fdt: convert kirkwood " Jason Cooper
2012-03-07 3:44 ` [PATCH 01/14] ARM: orion: spi: remove enable_clock_fix which is not used Jason Cooper
2012-03-09 4:33 ` Grant Likely
2012-03-07 3:44 ` [PATCH 02/14] ARM: Kirkwood: Remove tclk from kirkwood_asoc_platform_data Jason Cooper
2012-03-07 3:44 ` [PATCH 03/14] ARM: kirkwood: add dreamplug (fdt) support Jason Cooper
2012-03-07 3:44 ` [PATCH 04/14] ARM: kirkwood: fdt: absorb kirkwood_init() Jason Cooper
2012-03-07 3:44 ` [PATCH 05/14] ARM: kirkwood: add interrupt controller to devicetree Jason Cooper
2012-03-07 3:44 ` [PATCH 06/14] ARM: kirkwood: convert uart0 " Jason Cooper
2012-03-07 18:31 ` Arnd Bergmann
2012-03-07 18:37 ` Jason
2012-03-07 19:27 ` Jason
2012-03-07 20:05 ` Andrew Lunn
2012-03-07 20:55 ` Jason
2012-03-07 21:13 ` Arnd Bergmann
2012-03-07 21:29 ` Jason
2012-03-08 16:25 ` Jason
2012-03-08 17:01 ` Arnd Bergmann
2012-03-08 17:41 ` Arnd Bergmann
2012-03-08 19:27 ` Thomas Gleixner
2012-03-08 19:47 ` Jason
2012-03-08 21:32 ` Grant Likely
2012-03-08 21:50 ` Jason
2012-03-08 22:22 ` Rob Herring
2012-03-08 21:27 ` Grant Likely
2012-03-08 23:14 ` Arnd Bergmann
2012-03-07 21:47 ` Michael Walle
2012-03-08 21:31 ` Grant Likely
2012-03-08 21:55 ` Jason
2012-03-07 3:44 ` [PATCH 07/14] ARM: kirkwood: rtc-mv devicetree bindings Jason Cooper
2012-03-07 3:44 ` [PATCH 08/14] ARM: kirkwood: use devicetree for rtc-mv Jason Cooper
2012-03-07 18:32 ` Arnd Bergmann
2012-03-07 3:44 ` [PATCH 09/14] ARM: kirkwood: mv_cesa devicetree bindings Jason Cooper
2012-03-07 3:44 ` [PATCH 10/14] ARM: kirkwood: mv_cesa devicetree support Jason Cooper
2012-03-07 3:44 ` [PATCH 11/14] ARM: kirkwood: ehci-orion: add device tree binding Jason Cooper
2012-03-07 3:44 ` [PATCH 12/14] ARM: kirkwood: use devicetree for orion-ehci Jason Cooper
2012-03-07 3:44 ` [PATCH 13/14] ARM: kirkwood: sata_mv: add device tree binding Jason Cooper
2012-03-07 3:44 ` [PATCH 14/14] ARM: kirkwood: use devicetree to init sata_mv Jason Cooper
2012-03-07 18:40 ` Arnd Bergmann
2012-03-07 18:52 ` Jason
2012-03-07 19:00 ` Arnd Bergmann
2012-03-13 1:57 ` [PATCH 0/7 v4] ARM: kirkwood: fdt: convert kirkwood to fdt Jason Cooper
2012-03-13 1:57 ` [PATCH 1/7] ARM: orion: spi: remove enable_clock_fix which is not used Jason Cooper
2012-03-13 1:57 ` [PATCH 2/7] ARM: Kirkwood: Remove tclk from kirkwood_asoc_platform_data Jason Cooper
2012-03-13 1:57 ` [PATCH 3/7 v2] ARM: orion: wdt: use resource vice direct access Jason Cooper
2012-03-13 9:54 ` Arnd Bergmann
2012-03-13 1:57 ` [PATCH 4/7 v4] ARM: kirkwood: add dreamplug (fdt) support Jason Cooper
2012-03-13 10:10 ` Arnd Bergmann
2012-03-13 13:12 ` Jason Cooper
2012-04-05 22:07 ` Ian Campbell
2012-04-05 22:41 ` Jason Cooper
2012-04-06 8:52 ` Ian Campbell
[not found] ` <384286E8-E5C8-4069-9702-8A24C70D799C@gmail.com>
2012-04-16 13:27 ` dreamplug kernel and uboot code and apparent dreamplug board design change Jason Cooper
2012-03-13 1:57 ` [PATCH 5/7 v2] ARM: kirkwood: convert uart0 to devicetree Jason Cooper
2012-03-13 13:18 ` Jason Cooper
2012-03-13 1:57 ` [PATCH 6/7] ARM: kirkwood: rtc-mv devicetree bindings Jason Cooper
2012-03-13 9:57 ` Arnd Bergmann
2012-03-13 10:03 ` Uwe Kleine-König
2012-03-13 1:57 ` [PATCH 7/7] ARM: kirkwood: use devicetree for rtc-mv Jason Cooper
2012-03-13 9:58 ` Arnd Bergmann
2012-03-13 13:22 ` Jason Cooper
2012-03-13 13:44 ` Arnd Bergmann
2012-03-16 4:21 ` [PATCH 0/9 v5] ARM: kirkwood: fdt: convert kirkwood to fdt Jason Cooper
2012-03-16 4:21 ` [PATCH 1/9] ARM: orion: spi: remove enable_clock_fix which is not used Jason Cooper
2012-03-16 4:21 ` [PATCH 2/9] ARM: Kirkwood: Remove tclk from kirkwood_asoc_platform_data Jason Cooper
2012-03-16 4:21 ` [PATCH 3/9 v3] ARM: orion: wdt: use resource vice direct access Jason Cooper
2012-03-16 4:21 ` [PATCH 4/9] ARM: kirkwood: fdt: use mrvl ticker symbol Jason Cooper
2012-03-16 4:21 ` [PATCH 5/9] ARM: kirkwood: fdt: absorb kirkwood_init() Jason Cooper
2012-03-16 4:21 ` [PATCH 6/9 v2] ARM: kirkwood: fdt: facilitate new boards during fdt migration Jason Cooper
2012-03-16 4:21 ` [PATCH 7/9] ARM: kirkwood: fdt: define uart[01] as disabled, enable uart0 Jason Cooper
2012-03-16 4:21 ` [PATCH 8/9 v2] ARM: kirkwood: rtc-mv devicetree bindings Jason Cooper
2012-03-16 4:21 ` [PATCH 9/9] ARM: kirkwood: use devicetree for rtc-mv Jason Cooper
2012-03-16 20:18 ` [PATCH 0/9 v5] ARM: kirkwood: fdt: convert kirkwood to fdt Arnd Bergmann
2012-03-16 20:28 ` Jason Cooper
2012-03-16 20:41 ` Arnd Bergmann
2012-03-16 21:02 ` Jason Cooper
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=20120302072240.C16033E2D8D@localhost \
--to=grant.likely@secretlab.ca \
--cc=linux-arm-kernel@lists.infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).