Message ID | 335243c9467c0127206234819a94c9f72358fdf2.1314704558.git.pratyush.anand@st.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
* Pratyush Anand | 2011-08-30 17:28:01 [+0530]: >diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h >index 815efa2..32282b4 100644 >--- a/arch/arm/include/asm/io.h >+++ b/arch/arm/include/asm/io.h >@@ -297,6 +297,14 @@ extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size); > extern int devmem_is_allowed(unsigned long pfn); > #endif > >+/* Big Endian */ >+#define out_be32(a, v) writel(__cpu_to_be32(v), a) >+#define in_be32(a) __be32_to_cpu(readl(a)) >+ >+/* Little endian */ >+#define out_le32(a, v) writel(__cpu_to_le32(v), a) >+#define in_le32(a) __le32_to_cpu(readl(a)) In LE-mode __le32_to_cpu() is NOP and you get a LE value. In BE-mode readl() will swap a and le32_to_cpu will swap a again. So you get a BE value. Is this what you want? >+ Please split this patch out and get it accepterd by ARM community. USB people won't merge this. Sebastian
On Wed, Aug 31, 2011 at 1:05 PM, Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote: > * Pratyush Anand | 2011-08-30 17:28:01 [+0530]: > >>diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h >>index 815efa2..32282b4 100644 >>--- a/arch/arm/include/asm/io.h >>+++ b/arch/arm/include/asm/io.h >>@@ -297,6 +297,14 @@ extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size); >> extern int devmem_is_allowed(unsigned long pfn); >> #endif >> >>+/* Big Endian */ >>+#define out_be32(a, v) writel(__cpu_to_be32(v), a) >>+#define in_be32(a) __be32_to_cpu(readl(a)) >>+ >>+/* Little endian */ >>+#define out_le32(a, v) writel(__cpu_to_le32(v), a) >>+#define in_le32(a) __le32_to_cpu(readl(a)) > > In LE-mode __le32_to_cpu() is NOP and you get a LE value. > In BE-mode readl() will swap a and le32_to_cpu will swap a again. So you > get a BE value. Is this what you want? > There can be some peripheral like dwc-otg, whose registers will be either in LE or in BE depending on the RTL configuration selected by a implementor. Software always expects a LE value when it will call "in_" and will provide a LE value when "out_". It expects beacuse , it wants to do same bit wise operation for both configurations. >>+ > > Please split this patch out and get it accepterd by ARM community. USB > people won't merge this. > Ok, will send it to ARM mailing list. Regards Pratyush > Sebastian > -- > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >
On Tue, 2011-08-30 at 17:28 +0530, Pratyush Anand wrote: > There are some peripheral(e.g dwc otg) whose registers can be configured to > work in either little or big endian mode. Therefor macros like out_be32, > in_be32, out_le32 and in_le32 have been added to support such peripherals. Yuck. Don't copy those ppc specific historical accessors :-) Doesn't arm have writel_be ? If not , define those, it's a bit more common, or better, switch to the newer iomap variants which should be provided in both endianness. Cheers, Ben. > Signed-off-by: Pratyush Anand <pratyush.anand@st.com> > --- > arch/arm/include/asm/io.h | 8 ++++++++ > 1 files changed, 8 insertions(+), 0 deletions(-) > > diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h > index 815efa2..32282b4 100644 > --- a/arch/arm/include/asm/io.h > +++ b/arch/arm/include/asm/io.h > @@ -297,6 +297,14 @@ extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size); > extern int devmem_is_allowed(unsigned long pfn); > #endif > > +/* Big Endian */ > +#define out_be32(a, v) writel(__cpu_to_be32(v), a) > +#define in_be32(a) __be32_to_cpu(readl(a)) > + > +/* Little endian */ > +#define out_le32(a, v) writel(__cpu_to_le32(v), a) > +#define in_le32(a) __le32_to_cpu(readl(a)) > + > /* > * Convert a physical pointer to a virtual kernel pointer for /dev/mem > * access
> There can be some peripheral like dwc-otg, whose registers will be > either in LE or in BE > depending on the RTL configuration selected by a implementor. > Software always expects a LE value when it will call "in_" and will > provide a LE value when "out_". > It expects beacuse , it wants to do same bit wise operation for both > configurations. Then these are the wrong accessors. Cheers, Ben. > > > >>+ > > > > Please split this patch out and get it accepterd by ARM community. USB > > people won't merge this. > > > > Ok, will send it to ARM mailing list. > > Regards > Pratyush > > > Sebastian > > -- > > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > > the body of a message to majordomo@vger.kernel.org > > More majordomo info at http://vger.kernel.org/majordomo-info.html > > > _______________________________________________ > Linuxppc-dev mailing list > Linuxppc-dev@lists.ozlabs.org > https://lists.ozlabs.org/listinfo/linuxppc-dev
* Benjamin Herrenschmidt | 2011-09-02 21:01:43 [+1000]: >or better, switch to the newer iomap variants which should be >provided in both endianness. I know some ppc-mmu provide the capability to perform the endian swap during page access. I wasn't aware that there is a kernel wide interface for this. What do you do on architectures which don't provide this? >Cheers, >Ben. Sebastian
On Mon, 2011-09-05 at 16:28 +0200, Sebastian Andrzej Siewior wrote: > * Benjamin Herrenschmidt | 2011-09-02 21:01:43 [+1000]: > > >or better, switch to the newer iomap variants which should be > >provided in both endianness. > > I know some ppc-mmu provide the capability to perform the endian swap > during page access. I wasn't aware that there is a kernel wide interface > for this. What do you do on architectures which don't provide this? Oh we don't provide a kernel interface for it, well not "officially", that's not what I meant by using iomap. You -can- use the platform specific _PAGE_ENDIAN to ioremap_flags() but that's very platform specific and it's up to you to know you're doing it on a CPU that supports it :-) Cheers, Ben.
diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h index 815efa2..32282b4 100644 --- a/arch/arm/include/asm/io.h +++ b/arch/arm/include/asm/io.h @@ -297,6 +297,14 @@ extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size); extern int devmem_is_allowed(unsigned long pfn); #endif +/* Big Endian */ +#define out_be32(a, v) writel(__cpu_to_be32(v), a) +#define in_be32(a) __be32_to_cpu(readl(a)) + +/* Little endian */ +#define out_le32(a, v) writel(__cpu_to_le32(v), a) +#define in_le32(a) __le32_to_cpu(readl(a)) + /* * Convert a physical pointer to a virtual kernel pointer for /dev/mem * access
There are some peripheral(e.g dwc otg) whose registers can be configured to work in either little or big endian mode. Therefor macros like out_be32, in_be32, out_le32 and in_le32 have been added to support such peripherals. Signed-off-by: Pratyush Anand <pratyush.anand@st.com> --- arch/arm/include/asm/io.h | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)