Linux Watchdog driver development
 help / color / mirror / Atom feed
* [PATCH 0/2] Add big endian support
@ 2014-03-25  9:35 Xiubo Li
  2014-03-25  9:35 ` [PATCH 1/2] watchdog: imx2_wdt: Sort the header files alphabetically Xiubo Li
  2014-03-25  9:35 ` [PATCH 2/2] watchdog: imx2_wdt: Add big-endian support Xiubo Li
  0 siblings, 2 replies; 5+ messages in thread
From: Xiubo Li @ 2014-03-25  9:35 UTC (permalink / raw)
  To: wim, w.sang, linux-watchdog; +Cc: linux-kernel, Xiubo Li

This patches are preparing for Vybird, LS1 and LS2. And on LS1 the IP will
in BE mode.

And this has been test on Vybird.


Xiubo Li (2):
  watchdog: imx2_wdt: Sort the header files alphabetically
  watchdog: imx2_wdt: Add big-endian support

 drivers/watchdog/imx2_wdt.c | 52 ++++++++++++++++++++++++++++++++-------------
 1 file changed, 37 insertions(+), 15 deletions(-)

-- 
1.8.4



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] watchdog: imx2_wdt: Sort the header files alphabetically
  2014-03-25  9:35 [PATCH 0/2] Add big endian support Xiubo Li
@ 2014-03-25  9:35 ` Xiubo Li
  2014-03-25  9:35 ` [PATCH 2/2] watchdog: imx2_wdt: Add big-endian support Xiubo Li
  1 sibling, 0 replies; 5+ messages in thread
From: Xiubo Li @ 2014-03-25  9:35 UTC (permalink / raw)
  To: wim, w.sang, linux-watchdog; +Cc: linux-kernel, Xiubo Li

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
---
 drivers/watchdog/imx2_wdt.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
index dd51d95..1795922 100644
--- a/drivers/watchdog/imx2_wdt.c
+++ b/drivers/watchdog/imx2_wdt.c
@@ -21,19 +21,19 @@
  * Halt on suspend:	Manual		Can be automatic
  */
 
+#include <linux/clk.h>
+#include <linux/fs.h>
 #include <linux/init.h>
+#include <linux/io.h>
+#include <linux/jiffies.h>
 #include <linux/kernel.h>
 #include <linux/miscdevice.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/platform_device.h>
-#include <linux/watchdog.h>
-#include <linux/clk.h>
-#include <linux/fs.h>
-#include <linux/io.h>
-#include <linux/uaccess.h>
 #include <linux/timer.h>
-#include <linux/jiffies.h>
+#include <linux/uaccess.h>
+#include <linux/watchdog.h>
 
 #define DRIVER_NAME "imx2-wdt"
 
-- 
1.8.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] watchdog: imx2_wdt: Add big-endian support
  2014-03-25  9:35 [PATCH 0/2] Add big endian support Xiubo Li
  2014-03-25  9:35 ` [PATCH 1/2] watchdog: imx2_wdt: Sort the header files alphabetically Xiubo Li
@ 2014-03-25  9:35 ` Xiubo Li
  2014-03-26  2:00   ` Guenter Roeck
  1 sibling, 1 reply; 5+ messages in thread
From: Xiubo Li @ 2014-03-25  9:35 UTC (permalink / raw)
  To: wim, w.sang, linux-watchdog; +Cc: linux-kernel, Xiubo Li

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
---
 drivers/watchdog/imx2_wdt.c | 40 +++++++++++++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 9 deletions(-)

diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
index 1795922..c410981 100644
--- a/drivers/watchdog/imx2_wdt.c
+++ b/drivers/watchdog/imx2_wdt.c
@@ -30,6 +30,7 @@
 #include <linux/miscdevice.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/timer.h>
 #include <linux/uaccess.h>
@@ -64,9 +65,26 @@ static struct {
 	void __iomem *base;
 	unsigned timeout;
 	unsigned long status;
+	bool big_endian;
 	struct timer_list timer;	/* Pings the watchdog when closed */
 } imx2_wdt;
 
+static inline u16 imx2_wdt_readw(void __iomem *addr)
+{
+	if (imx2_wdt.big_endian)
+		return ioread16be(addr);
+	else
+		return ioread16(addr);
+}
+
+static inline void imx2_wdt_writew(u16 val, void __iomem *addr)
+{
+	if (imx2_wdt.big_endian)
+		iowrite16be(val, addr);
+	else
+		iowrite16(val, addr);
+}
+
 static struct miscdevice imx2_wdt_miscdev;
 
 static bool nowayout = WATCHDOG_NOWAYOUT;
@@ -87,7 +105,7 @@ static const struct watchdog_info imx2_wdt_info = {
 
 static inline void imx2_wdt_setup(void)
 {
-	u16 val = __raw_readw(imx2_wdt.base + IMX2_WDT_WCR);
+	u16 val = imx2_wdt_readw(imx2_wdt.base + IMX2_WDT_WCR);
 
 	/* Suspend timer in low power mode, write once-only */
 	val |= IMX2_WDT_WCR_WDZST;
@@ -100,17 +118,17 @@ static inline void imx2_wdt_setup(void)
 	/* Set the watchdog's Time-Out value */
 	val |= WDOG_SEC_TO_COUNT(imx2_wdt.timeout);
 
-	__raw_writew(val, imx2_wdt.base + IMX2_WDT_WCR);
+	imx2_wdt_writew(val, imx2_wdt.base + IMX2_WDT_WCR);
 
 	/* enable the watchdog */
 	val |= IMX2_WDT_WCR_WDE;
-	__raw_writew(val, imx2_wdt.base + IMX2_WDT_WCR);
+	imx2_wdt_writew(val, imx2_wdt.base + IMX2_WDT_WCR);
 }
 
 static inline void imx2_wdt_ping(void)
 {
-	__raw_writew(IMX2_WDT_SEQ1, imx2_wdt.base + IMX2_WDT_WSR);
-	__raw_writew(IMX2_WDT_SEQ2, imx2_wdt.base + IMX2_WDT_WSR);
+	imx2_wdt_writew(IMX2_WDT_SEQ1, imx2_wdt.base + IMX2_WDT_WSR);
+	imx2_wdt_writew(IMX2_WDT_SEQ2, imx2_wdt.base + IMX2_WDT_WSR);
 }
 
 static void imx2_wdt_timer_ping(unsigned long arg)
@@ -143,12 +161,12 @@ static void imx2_wdt_stop(void)
 
 static void imx2_wdt_set_timeout(int new_timeout)
 {
-	u16 val = __raw_readw(imx2_wdt.base + IMX2_WDT_WCR);
+	u16 val = imx2_wdt_readw(imx2_wdt.base + IMX2_WDT_WCR);
 
 	/* set the new timeout value in the WSR */
 	val &= ~IMX2_WDT_WCR_WT;
 	val |= WDOG_SEC_TO_COUNT(new_timeout);
-	__raw_writew(val, imx2_wdt.base + IMX2_WDT_WCR);
+	imx2_wdt_writew(val, imx2_wdt.base + IMX2_WDT_WCR);
 }
 
 static int imx2_wdt_open(struct inode *inode, struct file *file)
@@ -192,7 +210,7 @@ static long imx2_wdt_ioctl(struct file *file, unsigned int cmd,
 		return put_user(0, p);
 
 	case WDIOC_GETBOOTSTATUS:
-		val = __raw_readw(imx2_wdt.base + IMX2_WDT_WRSR);
+		val = imx2_wdt_readw(imx2_wdt.base + IMX2_WDT_WRSR);
 		new_value = val & IMX2_WDT_WRSR_TOUT ? WDIOF_CARDRESET : 0;
 		return put_user(new_value, p);
 
@@ -257,8 +275,12 @@ static struct miscdevice imx2_wdt_miscdev = {
 
 static int __init imx2_wdt_probe(struct platform_device *pdev)
 {
-	int ret;
+	struct device_node *np = pdev->dev.of_node;
 	struct resource *res;
+	int ret;
+
+	if (np)
+		imx2_wdt.big_endian = of_property_read_bool(np, "big-endians");
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	imx2_wdt.base = devm_ioremap_resource(&pdev->dev, res);
-- 
1.8.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] watchdog: imx2_wdt: Add big-endian support
  2014-03-25  9:35 ` [PATCH 2/2] watchdog: imx2_wdt: Add big-endian support Xiubo Li
@ 2014-03-26  2:00   ` Guenter Roeck
  2014-03-26  2:23     ` Li.Xiubo
  0 siblings, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2014-03-26  2:00 UTC (permalink / raw)
  To: Xiubo Li, wim, w.sang, linux-watchdog; +Cc: linux-kernel

On 03/25/2014 02:35 AM, Xiubo Li wrote:
> Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
> ---

There is no explanation for this patch in the headline.

Ultimately there are four cases
	CPU	HW
	little	little
	little	big
	big	little
	big	big
Current code handles big/big as well as little/little, and you are adding
little/big to the list of supported combinations. Questions are
1) which combinations are possible ?
2) is big/little a combination which needs to be handled as well ?
	
The "big-endians" property is new and will have to be approved by the
DT maintainers. If in fact needed, I would suggest to use "big-endian"
as this seems to be more common.

Guenter


>   drivers/watchdog/imx2_wdt.c | 40 +++++++++++++++++++++++++++++++---------
>   1 file changed, 31 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
> index 1795922..c410981 100644
> --- a/drivers/watchdog/imx2_wdt.c
> +++ b/drivers/watchdog/imx2_wdt.c
> @@ -30,6 +30,7 @@
>   #include <linux/miscdevice.h>
>   #include <linux/module.h>
>   #include <linux/moduleparam.h>
> +#include <linux/of.h>
>   #include <linux/platform_device.h>
>   #include <linux/timer.h>
>   #include <linux/uaccess.h>
> @@ -64,9 +65,26 @@ static struct {
>   	void __iomem *base;
>   	unsigned timeout;
>   	unsigned long status;
> +	bool big_endian;
>   	struct timer_list timer;	/* Pings the watchdog when closed */
>   } imx2_wdt;
>
> +static inline u16 imx2_wdt_readw(void __iomem *addr)
> +{
> +	if (imx2_wdt.big_endian)
> +		return ioread16be(addr);
> +	else
> +		return ioread16(addr);
> +}
> +
> +static inline void imx2_wdt_writew(u16 val, void __iomem *addr)
> +{
> +	if (imx2_wdt.big_endian)
> +		iowrite16be(val, addr);
> +	else
> +		iowrite16(val, addr);
> +}
> +
>   static struct miscdevice imx2_wdt_miscdev;
>
>   static bool nowayout = WATCHDOG_NOWAYOUT;
> @@ -87,7 +105,7 @@ static const struct watchdog_info imx2_wdt_info = {
>
>   static inline void imx2_wdt_setup(void)
>   {
> -	u16 val = __raw_readw(imx2_wdt.base + IMX2_WDT_WCR);
> +	u16 val = imx2_wdt_readw(imx2_wdt.base + IMX2_WDT_WCR);
>
>   	/* Suspend timer in low power mode, write once-only */
>   	val |= IMX2_WDT_WCR_WDZST;
> @@ -100,17 +118,17 @@ static inline void imx2_wdt_setup(void)
>   	/* Set the watchdog's Time-Out value */
>   	val |= WDOG_SEC_TO_COUNT(imx2_wdt.timeout);
>
> -	__raw_writew(val, imx2_wdt.base + IMX2_WDT_WCR);
> +	imx2_wdt_writew(val, imx2_wdt.base + IMX2_WDT_WCR);
>
>   	/* enable the watchdog */
>   	val |= IMX2_WDT_WCR_WDE;
> -	__raw_writew(val, imx2_wdt.base + IMX2_WDT_WCR);
> +	imx2_wdt_writew(val, imx2_wdt.base + IMX2_WDT_WCR);
>   }
>
>   static inline void imx2_wdt_ping(void)
>   {
> -	__raw_writew(IMX2_WDT_SEQ1, imx2_wdt.base + IMX2_WDT_WSR);
> -	__raw_writew(IMX2_WDT_SEQ2, imx2_wdt.base + IMX2_WDT_WSR);
> +	imx2_wdt_writew(IMX2_WDT_SEQ1, imx2_wdt.base + IMX2_WDT_WSR);
> +	imx2_wdt_writew(IMX2_WDT_SEQ2, imx2_wdt.base + IMX2_WDT_WSR);
>   }
>
>   static void imx2_wdt_timer_ping(unsigned long arg)
> @@ -143,12 +161,12 @@ static void imx2_wdt_stop(void)
>
>   static void imx2_wdt_set_timeout(int new_timeout)
>   {
> -	u16 val = __raw_readw(imx2_wdt.base + IMX2_WDT_WCR);
> +	u16 val = imx2_wdt_readw(imx2_wdt.base + IMX2_WDT_WCR);
>
>   	/* set the new timeout value in the WSR */
>   	val &= ~IMX2_WDT_WCR_WT;
>   	val |= WDOG_SEC_TO_COUNT(new_timeout);
> -	__raw_writew(val, imx2_wdt.base + IMX2_WDT_WCR);
> +	imx2_wdt_writew(val, imx2_wdt.base + IMX2_WDT_WCR);
>   }
>
>   static int imx2_wdt_open(struct inode *inode, struct file *file)
> @@ -192,7 +210,7 @@ static long imx2_wdt_ioctl(struct file *file, unsigned int cmd,
>   		return put_user(0, p);
>
>   	case WDIOC_GETBOOTSTATUS:
> -		val = __raw_readw(imx2_wdt.base + IMX2_WDT_WRSR);
> +		val = imx2_wdt_readw(imx2_wdt.base + IMX2_WDT_WRSR);
>   		new_value = val & IMX2_WDT_WRSR_TOUT ? WDIOF_CARDRESET : 0;
>   		return put_user(new_value, p);
>
> @@ -257,8 +275,12 @@ static struct miscdevice imx2_wdt_miscdev = {
>
>   static int __init imx2_wdt_probe(struct platform_device *pdev)
>   {
> -	int ret;
> +	struct device_node *np = pdev->dev.of_node;
>   	struct resource *res;
> +	int ret;
> +
> +	if (np)
> +		imx2_wdt.big_endian = of_property_read_bool(np, "big-endians");
>
>   	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>   	imx2_wdt.base = devm_ioremap_resource(&pdev->dev, res);
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH 2/2] watchdog: imx2_wdt: Add big-endian support
  2014-03-26  2:00   ` Guenter Roeck
@ 2014-03-26  2:23     ` Li.Xiubo
  0 siblings, 0 replies; 5+ messages in thread
From: Li.Xiubo @ 2014-03-26  2:23 UTC (permalink / raw)
  To: Guenter Roeck, wim@iguana.be, w.sang@pengutronix.de,
	linux-watchdog@vger.kernel.org
  Cc: linux-kernel@vger.kernel.org


> Subject: Re: [PATCH 2/2] watchdog: imx2_wdt: Add big-endian support
> 
> On 03/25/2014 02:35 AM, Xiubo Li wrote:
> > Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
> > ---
> 
> There is no explanation for this patch in the headline.
> 
> Ultimately there are four cases
> 	CPU	HW
> 	little	little
This case for most IMX* and Vybird and the LS2 SoCs.



> 	little	 big
This case for LS1 SoC.



> 	big	little
Actually, this case hasn't ever occurs for this IP, but maybe in the
Feature, not now.



> 	big	big
This case maybe for the PowrPC SoCs.



> Current code handles big/big as well as little/little, and you are adding
> little/big to the list of supported combinations. Questions are
> 1) which combinations are possible ?
> 2) is big/little a combination which needs to be handled as well ?
> 

Yes, I originally intended to use the Regmap APIs, but it couldn't support
The 16bit registers accessing now, and also won't support the [bit  little]
case too.

So now this driver will only support the following three cases:
CPU        IP
Little     little
Little     big
Big        big

If there hasn't any other problems, I will resend this patches adding this
Information.



> The "big-endians" property is new and will have to be approved by the
> DT maintainers. If in fact needed, I would suggest to use "big-endian"
> as this seems to be more common.
>

Yes, There has other IP driver has been accepted by DT maintainers. So
After this I will send the DT patches to them.

 
Thanks very much,

Best Regards,
Xiubo



> Guenter
> 
> 
> >   drivers/watchdog/imx2_wdt.c | 40 +++++++++++++++++++++++++++++++---------
> >   1 file changed, 31 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
> > index 1795922..c410981 100644
> > --- a/drivers/watchdog/imx2_wdt.c
> > +++ b/drivers/watchdog/imx2_wdt.c
> > @@ -30,6 +30,7 @@
> >   #include <linux/miscdevice.h>
> >   #include <linux/module.h>
> >   #include <linux/moduleparam.h>
> > +#include <linux/of.h>
> >   #include <linux/platform_device.h>
> >   #include <linux/timer.h>
> >   #include <linux/uaccess.h>
> > @@ -64,9 +65,26 @@ static struct {
> >   	void __iomem *base;
> >   	unsigned timeout;
> >   	unsigned long status;
> > +	bool big_endian;
> >   	struct timer_list timer;	/* Pings the watchdog when closed */
> >   } imx2_wdt;
> >
> > +static inline u16 imx2_wdt_readw(void __iomem *addr)
> > +{
> > +	if (imx2_wdt.big_endian)
> > +		return ioread16be(addr);
> > +	else
> > +		return ioread16(addr);
> > +}
> > +
> > +static inline void imx2_wdt_writew(u16 val, void __iomem *addr)
> > +{
> > +	if (imx2_wdt.big_endian)
> > +		iowrite16be(val, addr);
> > +	else
> > +		iowrite16(val, addr);
> > +}
> > +
> >   static struct miscdevice imx2_wdt_miscdev;
> >
> >   static bool nowayout = WATCHDOG_NOWAYOUT;
> > @@ -87,7 +105,7 @@ static const struct watchdog_info imx2_wdt_info = {
> >
> >   static inline void imx2_wdt_setup(void)
> >   {
> > -	u16 val = __raw_readw(imx2_wdt.base + IMX2_WDT_WCR);
> > +	u16 val = imx2_wdt_readw(imx2_wdt.base + IMX2_WDT_WCR);
> >
> >   	/* Suspend timer in low power mode, write once-only */
> >   	val |= IMX2_WDT_WCR_WDZST;
> > @@ -100,17 +118,17 @@ static inline void imx2_wdt_setup(void)
> >   	/* Set the watchdog's Time-Out value */
> >   	val |= WDOG_SEC_TO_COUNT(imx2_wdt.timeout);
> >
> > -	__raw_writew(val, imx2_wdt.base + IMX2_WDT_WCR);
> > +	imx2_wdt_writew(val, imx2_wdt.base + IMX2_WDT_WCR);
> >
> >   	/* enable the watchdog */
> >   	val |= IMX2_WDT_WCR_WDE;
> > -	__raw_writew(val, imx2_wdt.base + IMX2_WDT_WCR);
> > +	imx2_wdt_writew(val, imx2_wdt.base + IMX2_WDT_WCR);
> >   }
> >
> >   static inline void imx2_wdt_ping(void)
> >   {
> > -	__raw_writew(IMX2_WDT_SEQ1, imx2_wdt.base + IMX2_WDT_WSR);
> > -	__raw_writew(IMX2_WDT_SEQ2, imx2_wdt.base + IMX2_WDT_WSR);
> > +	imx2_wdt_writew(IMX2_WDT_SEQ1, imx2_wdt.base + IMX2_WDT_WSR);
> > +	imx2_wdt_writew(IMX2_WDT_SEQ2, imx2_wdt.base + IMX2_WDT_WSR);
> >   }
> >
> >   static void imx2_wdt_timer_ping(unsigned long arg)
> > @@ -143,12 +161,12 @@ static void imx2_wdt_stop(void)
> >
> >   static void imx2_wdt_set_timeout(int new_timeout)
> >   {
> > -	u16 val = __raw_readw(imx2_wdt.base + IMX2_WDT_WCR);
> > +	u16 val = imx2_wdt_readw(imx2_wdt.base + IMX2_WDT_WCR);
> >
> >   	/* set the new timeout value in the WSR */
> >   	val &= ~IMX2_WDT_WCR_WT;
> >   	val |= WDOG_SEC_TO_COUNT(new_timeout);
> > -	__raw_writew(val, imx2_wdt.base + IMX2_WDT_WCR);
> > +	imx2_wdt_writew(val, imx2_wdt.base + IMX2_WDT_WCR);
> >   }
> >
> >   static int imx2_wdt_open(struct inode *inode, struct file *file)
> > @@ -192,7 +210,7 @@ static long imx2_wdt_ioctl(struct file *file, unsigned
> int cmd,
> >   		return put_user(0, p);
> >
> >   	case WDIOC_GETBOOTSTATUS:
> > -		val = __raw_readw(imx2_wdt.base + IMX2_WDT_WRSR);
> > +		val = imx2_wdt_readw(imx2_wdt.base + IMX2_WDT_WRSR);
> >   		new_value = val & IMX2_WDT_WRSR_TOUT ? WDIOF_CARDRESET : 0;
> >   		return put_user(new_value, p);
> >
> > @@ -257,8 +275,12 @@ static struct miscdevice imx2_wdt_miscdev = {
> >
> >   static int __init imx2_wdt_probe(struct platform_device *pdev)
> >   {
> > -	int ret;
> > +	struct device_node *np = pdev->dev.of_node;
> >   	struct resource *res;
> > +	int ret;
> > +
> > +	if (np)
> > +		imx2_wdt.big_endian = of_property_read_bool(np, "big-endians");
> >
> >   	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >   	imx2_wdt.base = devm_ioremap_resource(&pdev->dev, res);
> >
> 
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-03-26  2:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-25  9:35 [PATCH 0/2] Add big endian support Xiubo Li
2014-03-25  9:35 ` [PATCH 1/2] watchdog: imx2_wdt: Sort the header files alphabetically Xiubo Li
2014-03-25  9:35 ` [PATCH 2/2] watchdog: imx2_wdt: Add big-endian support Xiubo Li
2014-03-26  2:00   ` Guenter Roeck
2014-03-26  2:23     ` Li.Xiubo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox