mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [RFC] usb: ehci: use linux-way ehci_readl and ehci_writel
@ 2014-07-17 11:54 Antony Pavlov
  2014-07-23  7:14 ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Antony Pavlov @ 2014-07-17 11:54 UTC (permalink / raw)
  To: barebox

Also drop nowhere defined CONFIG_EHCI_DESC_BIG_ENDIAN.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 drivers/usb/host/ehci.h | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 5d899cc..2ec69f6 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -18,6 +18,8 @@
 #ifndef USB_EHCI_H
 #define USB_EHCI_H
 
+#include <io.h>
+
 #if !defined(CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS)
 #define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS	16
 #endif
@@ -109,14 +111,15 @@ struct usb_linux_config_descriptor {
 	unsigned char	MaxPower;
 } __attribute__ ((packed));
 
-#if defined CONFIG_EHCI_DESC_BIG_ENDIAN
-#define	ehci_readl(x)		(*((volatile u32 *)(x)))
-#define ehci_writel(a, b)	(*((volatile u32 *)(a)) = ((volatile u32)b))
-#else
-#define ehci_readl(x)		cpu_to_le32((*((volatile u32 *)(x))))
-#define ehci_writel(a, b)	(*((volatile u32 *)(a)) = \
-					cpu_to_le32(((volatile u32)b)))
-#endif
+static inline void ehci_writel(const unsigned int val, __u32 __iomem *regs)
+{
+	writel(val, regs);
+}
+
+static inline unsigned int ehci_readl(__u32 __iomem *regs)
+{
+	return readl(regs);
+}
 
 #if defined CONFIG_EHCI_MMIO_BIG_ENDIAN
 #define hc32_to_cpu(x)		be32_to_cpu((x))
-- 
2.0.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [RFC] usb: ehci: use linux-way ehci_readl and ehci_writel
  2014-07-17 11:54 [RFC] usb: ehci: use linux-way ehci_readl and ehci_writel Antony Pavlov
@ 2014-07-23  7:14 ` Sascha Hauer
  2014-07-24  7:03   ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2014-07-23  7:14 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

On Thu, Jul 17, 2014 at 03:54:07PM +0400, Antony Pavlov wrote:
> Also drop nowhere defined CONFIG_EHCI_DESC_BIG_ENDIAN.
> 
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>

Applied, thanks

Sascha

> ---
>  drivers/usb/host/ehci.h | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
> index 5d899cc..2ec69f6 100644
> --- a/drivers/usb/host/ehci.h
> +++ b/drivers/usb/host/ehci.h
> @@ -18,6 +18,8 @@
>  #ifndef USB_EHCI_H
>  #define USB_EHCI_H
>  
> +#include <io.h>
> +
>  #if !defined(CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS)
>  #define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS	16
>  #endif
> @@ -109,14 +111,15 @@ struct usb_linux_config_descriptor {
>  	unsigned char	MaxPower;
>  } __attribute__ ((packed));
>  
> -#if defined CONFIG_EHCI_DESC_BIG_ENDIAN
> -#define	ehci_readl(x)		(*((volatile u32 *)(x)))
> -#define ehci_writel(a, b)	(*((volatile u32 *)(a)) = ((volatile u32)b))
> -#else
> -#define ehci_readl(x)		cpu_to_le32((*((volatile u32 *)(x))))
> -#define ehci_writel(a, b)	(*((volatile u32 *)(a)) = \
> -					cpu_to_le32(((volatile u32)b)))
> -#endif
> +static inline void ehci_writel(const unsigned int val, __u32 __iomem *regs)
> +{
> +	writel(val, regs);
> +}
> +
> +static inline unsigned int ehci_readl(__u32 __iomem *regs)
> +{
> +	return readl(regs);
> +}
>  
>  #if defined CONFIG_EHCI_MMIO_BIG_ENDIAN
>  #define hc32_to_cpu(x)		be32_to_cpu((x))
> -- 
> 2.0.1
> 
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [RFC] usb: ehci: use linux-way ehci_readl and ehci_writel
  2014-07-23  7:14 ` Sascha Hauer
@ 2014-07-24  7:03   ` Sascha Hauer
  2014-07-24  7:43     ` Antony Pavlov
  0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2014-07-24  7:03 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

On Wed, Jul 23, 2014 at 09:14:08AM +0200, Sascha Hauer wrote:
> On Thu, Jul 17, 2014 at 03:54:07PM +0400, Antony Pavlov wrote:
> > Also drop nowhere defined CONFIG_EHCI_DESC_BIG_ENDIAN.
> > 
> > Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> 
> Applied, thanks

And reverted it.

> > -#if defined CONFIG_EHCI_DESC_BIG_ENDIAN
> > -#define	ehci_readl(x)		(*((volatile u32 *)(x)))
> > -#define ehci_writel(a, b)	(*((volatile u32 *)(a)) = ((volatile u32)b))
> > -#else
> > -#define ehci_readl(x)		cpu_to_le32((*((volatile u32 *)(x))))
> > -#define ehci_writel(a, b)	(*((volatile u32 *)(a)) = \
> > -					cpu_to_le32(((volatile u32)b)))
> > -#endif
> > +static inline void ehci_writel(const unsigned int val, __u32 __iomem *regs)
> > +{
> > +	writel(val, regs);
> > +}

ehci_writel has the argument order (reg, val), not (val, reg)

Putting a 'writel' in a function name with this argument order wasn't
the best idea...

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [RFC] usb: ehci: use linux-way ehci_readl and ehci_writel
  2014-07-24  7:03   ` Sascha Hauer
@ 2014-07-24  7:43     ` Antony Pavlov
  0 siblings, 0 replies; 4+ messages in thread
From: Antony Pavlov @ 2014-07-24  7:43 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On Thu, 24 Jul 2014 09:03:47 +0200
Sascha Hauer <s.hauer@pengutronix.de> wrote:

> On Wed, Jul 23, 2014 at 09:14:08AM +0200, Sascha Hauer wrote:
> > On Thu, Jul 17, 2014 at 03:54:07PM +0400, Antony Pavlov wrote:
> > > Also drop nowhere defined CONFIG_EHCI_DESC_BIG_ENDIAN.
> > > 
> > > Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> > 
> > Applied, thanks
> 
> And reverted it.
> 
> > > -#if defined CONFIG_EHCI_DESC_BIG_ENDIAN
> > > -#define	ehci_readl(x)		(*((volatile u32 *)(x)))
> > > -#define ehci_writel(a, b)	(*((volatile u32 *)(a)) = ((volatile u32)b))
> > > -#else
> > > -#define ehci_readl(x)		cpu_to_le32((*((volatile u32 *)(x))))
> > > -#define ehci_writel(a, b)	(*((volatile u32 *)(a)) = \
> > > -					cpu_to_le32(((volatile u32)b)))
> > > -#endif
> > > +static inline void ehci_writel(const unsigned int val, __u32 __iomem *regs)
> > > +{
> > > +	writel(val, regs);
> > > +}
> 
> ehci_writel has the argument order (reg, val), not (val, reg)
> 
> Putting a 'writel' in a function name with this argument order wasn't
> the best idea...

Sorry!

I have made this patch while I was working on AR933x USB support (big-endian EHCI).
I suppose this patch was initial buggy version and I have forgot to ammend fixup.

-- 
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2014-07-24  7:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-17 11:54 [RFC] usb: ehci: use linux-way ehci_readl and ehci_writel Antony Pavlov
2014-07-23  7:14 ` Sascha Hauer
2014-07-24  7:03   ` Sascha Hauer
2014-07-24  7:43     ` Antony Pavlov

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