Skip to contentSkip to conversation

add avr32/at91 on-chip iO accessors

RFC In review Ben Dooks 7 participants 25 messages Mar 26, 2015 – Apr 28, 2015

Subsystems (11)
lore
Share & tools
lore

Ben Dooks

author
#0 lore raw

As discussed from Ben Hutchings' suggestion on the original series, avoid open coding the AVR32/AT91 IO accessors.

author
#1 lore raw

RFC 1/6 atmel: add atmel_io.h

The AVR32 and ARM (AT91) architectures share a number of drivers which need to access the on chip peripherals. The current drivers work with the default endian configuration, however it is possilbe to run some of the ATMEL ARM architectures in big endian mode.

If we change the drivers from __raw to _relaxed IO accesors then the ARM side works but the AVR32 will not. The _relaxed assume the bus is little endian and the __raw are native. The AVR32 is native big endian so these are not the right functions.

To sort this out, and avoid a number of drivers having #ifdef for the AVR32 case we add <linux/atmel_io.h> to provide some AT91/AVR32 independant IO accessor functions.

--
CC: Haavard Skinnemoen <[email protected]>
CC: Hans-Christian Egtvedt <[email protected]>
CC: Andrew Victor <[email protected]>
CC: Nicolas Ferre <[email protected]>
CC: linux-arm-kernel at lists.infradead.org

---
 include/linux/atmel_io.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 include/linux/atmel_io.h
include/linux/atmel_io.h new file +25 -0
new file mode 100644
index 0000000..1234e88
@@ -0,0 +1,25 @@
+/* Atmel AT91/AVR32 independant IO
+ *
+ * Copyright 2015 Codethink Ltd.
+ * Ben Dooks <[email protected]>
+ *
+ * Provide architecture indendant, endian-safe IO accessor functions
+ */
+
+#ifdef CONFIG_AVR32
+/* For AVR32 the readl and writel relaxed will do an extra byte reverse
+ * as the peripherals are already in the same endian-ness as the CPU and
+ * readl/writel assume little endian where the CPU is big endian
+ */
+#define atmel_oc_readl	__raw_readl
+#define atmel_oc_writel	__raw_writel
+
+#define atmel_oc_readw	__raw_readw
+#define atmel_oc_writew	__raw_writew
+#else
+#define atmel_oc_readl	readl_relaxed
+#define atmel_oc_writel	writel_relaxed
+
+#define atmel_oc_readw	readw_relaxed
+#define atmel_oc_writew	writew_relaxed
+#endif
Signature · 1 line
2.1.4
#2 lore raw

RFC 1/6 atmel: add atmel_io.h

Quoted 10 lines · Ben Dooks

The AVR32 and ARM (AT91) architectures share a number of drivers which need to access the on chip peripherals. The current drivers work with the default endian configuration, however it is possilbe to run some of the ATMEL ARM architectures in big endian mode.

If we change the drivers from __raw to _relaxed IO accesors then the ARM side works but the AVR32 will not. The _relaxed assume the bus is little endian and the __raw are native. The AVR32 is native big endian so these are not the right functions.

Quoted 5 lines

To sort this out, and avoid a number of drivers having #ifdef for the AVR32 case we add <linux/atmel_io.h> to provide some AT91/AVR32 independant IO accessor functions.

Quoted 42 lines

--
CC: Haavard Skinnemoen <[email protected]>
CC: Hans-Christian Egtvedt <[email protected]>
CC: Andrew Victor <[email protected]>
CC: Nicolas Ferre <[email protected]>
CC: linux-arm-kernel at lists.infradead.org

---
 include/linux/atmel_io.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 include/linux/atmel_io.h
include/linux/atmel_io.h new file +25 -0
new file mode 100644
index 0000000..1234e88
@@ -0,0 +1,25 @@
+/* Atmel AT91/AVR32 independant IO
+ *
+ * Copyright 2015 Codethink Ltd.
+ * Ben Dooks <[email protected]>
+ *
+ * Provide architecture indendant, endian-safe IO accessor functions
+ */
+
+#ifdef CONFIG_AVR32
+/* For AVR32 the readl and writel relaxed will do an extra byte reverse
+ * as the peripherals are already in the same endian-ness as the CPU and
+ * readl/writel assume little endian where the CPU is big endian
+ */
+#define atmel_oc_readl	__raw_readl
+#define atmel_oc_writel	__raw_writel
+
+#define atmel_oc_readw	__raw_readw
+#define atmel_oc_writew	__raw_writew
+#else
+#define atmel_oc_readl	readl_relaxed
+#define atmel_oc_writel	writel_relaxed
+
+#define atmel_oc_readw	readw_relaxed
+#define atmel_oc_writew	writew_relaxed
+#endif
Signature · 2 lines
mvh
Hans-Christian Egtvedt
#3 lore raw

RFC 1/6 atmel: add atmel_io.h

Hi,

Quoted 11 lines · Hans-Christian Egtvedt
Quoted 10 lines · Ben Dooks

The AVR32 and ARM (AT91) architectures share a number of drivers which need to access the on chip peripherals. The current drivers work with the default endian configuration, however it is possilbe to run some of the ATMEL ARM architectures in big endian mode.

If we change the drivers from __raw to _relaxed IO accesors then the ARM side works but the AVR32 will not. The _relaxed assume the bus is little endian and the __raw are native. The AVR32 is native big endian so these are not the right functions.

Quoted 8 lines
Quoted 5 lines

To sort this out, and avoid a number of drivers having #ifdef for the AVR32 case we add <linux/atmel_io.h> to provide some AT91/AVR32 independant IO accessor functions.

Is there any reason why read/write[bwl]_relaxed can't be made to do big endian accesses on avr32?

Signature · 3 lines
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#4 lore raw

RFC 1/6 atmel: add atmel_io.h

Quoted 18 lines · Alexandre Belloni

Hi,

Quoted 15 lines · Hans-Christian Egtvedt
Quoted 14 lines · Ben Dooks

The AVR32 and ARM (AT91) architectures share a number of drivers which need to access the on chip peripherals. The current drivers work with the default endian configuration, however it is possilbe to run some of the ATMEL ARM architectures in big endian mode.

If we change the drivers from __raw to _relaxed IO accesors then the ARM side works but the AVR32 will not. The _relaxed assume the bus is little endian and the __raw are native. The AVR32 is native big endian so these are not the right functions.

To sort this out, and avoid a number of drivers having #ifdef for the AVR32 case we add <linux/atmel_io.h> to provide some AT91/AVR32 independant IO accessor functions.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Is there any reason why read/write[bwl]_relaxed can't be made to do big endian accesses on avr32?

read/write[bwl]* are defined to be little endian accessors - they have their roots in PCI.

Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
author
#5 lore raw

RFC 2/6 tty: serial: atmel: use atmel_io.h to provide on-chip IO

In reply to Ben Dooks

Use <linux/atmel_io.h> to provide IO accessors which work on both AVR32 and ARM for on-chip peripherals.

--
CC: Nicolas Ferre <[email protected]>
CC: Greg Kroah-Hartman <[email protected]>
CC: Jiri Slaby <[email protected]>
CC: linux-serial at vger.kernel.org
CC: Linux ARM Kernel <[email protected]>

---
 drivers/tty/serial/atmel_serial.c | 63 +++++++++++++++++----------------------
 1 file changed, 28 insertions(+), 35 deletions(-)
drivers/tty/serial/atmel_serial.c +28 -35
index 40ef95f..eed0700 100644
@@ -38,6 +38,7 @@
 #include <linux/of_gpio.h>
 #include <linux/dma-mapping.h>
 #include <linux/dmaengine.h>
+#include <linux/atmel_io.h>
 #include <linux/atmel_pdc.h>
 #include <linux/atmel_serial.h>
 #include <linux/uaccess.h>
@@ -88,44 +89,36 @@ static void atmel_stop_rx(struct uart_port *port);
 
 #define ATMEL_ISR_PASS_LIMIT	256
 
-#ifdef CONFIG_AVR32
-#define __atserial_writel	__raw_writel
-#define __atserial_readl	__raw_readl
-#else
-#define __atserial_writel	writel_relaxed
-#define __atserial_readl	readl_relaxed
-#endif
-
 /* UART registers. CR is write-only, hence no GET macro */
-#define UART_PUT_CR(port,v)	__atserial_writel(v, (port)->membase + ATMEL_US_CR)
-#define UART_GET_MR(port)	__atserial_readl((port)->membase + ATMEL_US_MR)
-#define UART_PUT_MR(port,v)	__atserial_writel(v, (port)->membase + ATMEL_US_MR)
-#define UART_PUT_IER(port,v)	__atserial_writel(v, (port)->membase + ATMEL_US_IER)
-#define UART_PUT_IDR(port,v)	__atserial_writel(v, (port)->membase + ATMEL_US_IDR)
-#define UART_GET_IMR(port)	__atserial_readl((port)->membase + ATMEL_US_IMR)
-#define UART_GET_CSR(port)	__atserial_readl((port)->membase + ATMEL_US_CSR)
-#define UART_GET_CHAR(port)	__atserial_readl((port)->membase + ATMEL_US_RHR)
-#define UART_PUT_CHAR(port,v)	__atserial_writel(v, (port)->membase + ATMEL_US_THR)
-#define UART_GET_BRGR(port)	__atserial_readl((port)->membase + ATMEL_US_BRGR)
-#define UART_PUT_BRGR(port,v)	__atserial_writel(v, (port)->membase + ATMEL_US_BRGR)
-#define UART_PUT_RTOR(port,v)	__atserial_writel(v, (port)->membase + ATMEL_US_RTOR)
-#define UART_PUT_TTGR(port, v)	__atserial_writel(v, (port)->membase + ATMEL_US_TTGR)
-#define UART_GET_IP_NAME(port)	__atserial_readl((port)->membase + ATMEL_US_NAME)
-#define UART_GET_IP_VERSION(port) __atserial_readl((port)->membase + ATMEL_US_VERSION)
+#define UART_PUT_CR(port,v)	atmel_oc_writel(v, (port)->membase + ATMEL_US_CR)
+#define UART_GET_MR(port)	atmel_oc_readl((port)->membase + ATMEL_US_MR)
+#define UART_PUT_MR(port,v)	atmel_oc_writel(v, (port)->membase + ATMEL_US_MR)
+#define UART_PUT_IER(port,v)	atmel_oc_writel(v, (port)->membase + ATMEL_US_IER)
+#define UART_PUT_IDR(port,v)	atmel_oc_writel(v, (port)->membase + ATMEL_US_IDR)
+#define UART_GET_IMR(port)	atmel_oc_readl((port)->membase + ATMEL_US_IMR)
+#define UART_GET_CSR(port)	atmel_oc_readl((port)->membase + ATMEL_US_CSR)
+#define UART_GET_CHAR(port)	atmel_oc_readl((port)->membase + ATMEL_US_RHR)
+#define UART_PUT_CHAR(port,v)	atmel_oc_writel(v, (port)->membase + ATMEL_US_THR)
+#define UART_GET_BRGR(port)	atmel_oc_readl((port)->membase + ATMEL_US_BRGR)
+#define UART_PUT_BRGR(port,v)	atmel_oc_writel(v, (port)->membase + ATMEL_US_BRGR)
+#define UART_PUT_RTOR(port,v)	atmel_oc_writel(v, (port)->membase + ATMEL_US_RTOR)
+#define UART_PUT_TTGR(port, v)	atmel_oc_writel(v, (port)->membase + ATMEL_US_TTGR)
+#define UART_GET_IP_NAME(port)	atmel_oc_readl((port)->membase + ATMEL_US_NAME)
+#define UART_GET_IP_VERSION(port) atmel_oc_readl((port)->membase + ATMEL_US_VERSION)
 
  /* PDC registers */
-#define UART_PUT_PTCR(port,v)	__atserial_writel(v, (port)->membase + ATMEL_PDC_PTCR)
-#define UART_GET_PTSR(port)	__atserial_readl((port)->membase + ATMEL_PDC_PTSR)
-
-#define UART_PUT_RPR(port,v)	__atserial_writel(v, (port)->membase + ATMEL_PDC_RPR)
-#define UART_GET_RPR(port)	__atserial_readl((port)->membase + ATMEL_PDC_RPR)
-#define UART_PUT_RCR(port,v)	__atserial_writel(v, (port)->membase + ATMEL_PDC_RCR)
-#define UART_PUT_RNPR(port,v)	__atserial_writel(v, (port)->membase + ATMEL_PDC_RNPR)
-#define UART_PUT_RNCR(port,v)	__atserial_writel(v, (port)->membase + ATMEL_PDC_RNCR)
-
-#define UART_PUT_TPR(port,v)	__atserial_writel(v, (port)->membase + ATMEL_PDC_TPR)
-#define UART_PUT_TCR(port,v)	__atserial_writel(v, (port)->membase + ATMEL_PDC_TCR)
-#define UART_GET_TCR(port)	__atserial_readl((port)->membase + ATMEL_PDC_TCR)
+#define UART_PUT_PTCR(port,v)	atmel_oc_writel(v, (port)->membase + ATMEL_PDC_PTCR)
+#define UART_GET_PTSR(port)	atmel_oc_readl((port)->membase + ATMEL_PDC_PTSR)
+
+#define UART_PUT_RPR(port,v)	atmel_oc_writel(v, (port)->membase + ATMEL_PDC_RPR)
+#define UART_GET_RPR(port)	atmel_oc_readl((port)->membase + ATMEL_PDC_RPR)
+#define UART_PUT_RCR(port,v)	atmel_oc_writel(v, (port)->membase + ATMEL_PDC_RCR)
+#define UART_PUT_RNPR(port,v)	atmel_oc_writel(v, (port)->membase + ATMEL_PDC_RNPR)
+#define UART_PUT_RNCR(port,v)	atmel_oc_writel(v, (port)->membase + ATMEL_PDC_RNCR)
+
+#define UART_PUT_TPR(port,v)	atmel_oc_writel(v, (port)->membase + ATMEL_PDC_TPR)
+#define UART_PUT_TCR(port,v)	atmel_oc_writel(v, (port)->membase + ATMEL_PDC_TCR)
+#define UART_GET_TCR(port)	atmel_oc_readl((port)->membase + ATMEL_PDC_TCR)
 
 struct atmel_dma_buffer {
 	unsigned char	*buf;
Signature · 1 line
2.1.4
author
#6 lore raw

RFC 3/6 clocksource: tcb_clksrc: use atmel_io.h to provide on-chip IO

In reply to Ben Dooks

Use <linux/atmel_io.h> to provide IO accessors which work on both AVR32 and ARM for on-chip peripherals.

--
CC: Daniel Lezcano <[email protected]>
CC: Thomas Gleixner <[email protected]>
CC: Linux Kernel <[email protected]>
CC: Linux ARM Kernel <[email protected]>
CC: Andrew Victor <[email protected]>
CC: Nicolas Ferre <[email protected]>
CC: Jean-Christophe Plagniol-Villard <[email protected]>

---
 drivers/clocksource/tcb_clksrc.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/clocksource/tcb_clksrc.c +3 -7
index 0f819dd3..b25416d 100644
@@ -9,6 +9,7 @@
 #include <linux/ioport.h>
 #include <linux/io.h>
 #include <linux/platform_device.h>
+#include <linux/atmel_io.h>
 #include <linux/atmel_tc.h>
 
 
@@ -41,13 +42,8 @@
 
 static void __iomem *tcaddr;
 
-#ifdef CONFIG_AVR32
-#define tcb_readl	__raw_readl
-#define tcb_writel	__raw_writel
-#else
-#define tcb_readl	readl_relaxed
-#define tcb_writel	writel_relaxed
-#endif
+#define tcb_readl	atmel_oc_readl
+#define tcb_writel	atmel_oc_writel
 
 static cycle_t tc_get_cycles(struct clocksource *cs)
 {
Signature · 1 line
2.1.4
Acked-by on v1 3/6
#7 lore raw

Re: [RFC 3/6] clocksource: tcb_clksrc: use atmel_io.h to provide on-chip IO

Quoted 4 lines · Ben Dooks

Use <linux/atmel_io.h> to provide IO accessors which work on both AVR32 and ARM for on-chip peripherals.

Quoted 27 lines

--
CC: Daniel Lezcano <[email protected]>
CC: Thomas Gleixner <[email protected]>
CC: Linux Kernel <[email protected]>
CC: Linux ARM Kernel <[email protected]>
CC: Andrew Victor <[email protected]>
CC: Nicolas Ferre <[email protected]>
CC: Jean-Christophe Plagniol-Villard <[email protected]>

---
 drivers/clocksource/tcb_clksrc.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/clocksource/tcb_clksrc.c +1 -0
index 0f819dd3..b25416d 100644
@@ -9,6 +9,7 @@
 #include <linux/ioport.h>
 #include <linux/io.h>
 #include <linux/platform_device.h>
+#include <linux/atmel_io.h>
 #include <linux/atmel_tc.h>
 
 
@@ -41,13 +42,8 @@
 
 static void __iomem *tcaddr;

drivers/clocksource/tcb_clksrc.c line 46

Quoted 10 lines
drivers/clocksource/tcb_clksrc.c +2 -7
 
-#ifdef CONFIG_AVR32
-#define tcb_readl	__raw_readl
-#define tcb_writel	__raw_writel
-#else
-#define tcb_readl	readl_relaxed
-#define tcb_writel	writel_relaxed
-#endif
+#define tcb_readl	atmel_oc_readl
+#define tcb_writel	atmel_oc_writel

A note here is that we could replace these defines completely, and use the atmel_oc_{read,write}{l,w} directly in the driver. That would be a nice follow-up to this patch, first replace the defines to use the common accessor, then replace the defines all together.

<snipp>

Signature · 2 lines
mvh
Hans-Christian Egtvedt
author
#8 lore raw

RFC 4/6 spi: atmel: use atmel_io.h to provide on-chip IO

In reply to Ben Dooks

Use <linux/atmel_io.h> to provide IO accessors which work on both AVR32 and ARM for on-chip peripherals.

--
CC: Nicolas Ferre <[email protected]> (supporter:ATMEL SPI DRIVER)
CC: Mark Brown <[email protected]> (maintainer:SPI SUBSYSTEM)
CC: linux-spi at vger.kernel.org (open list:SPI SUBSYSTEM)
CC: linux-arm-kernel at lists.infradead.org

---
 drivers/spi/spi-atmel.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/spi/spi-atmel.c +4 -9
index a2f40b1..f10cc75 100644
@@ -25,6 +25,7 @@
 
 #include <linux/io.h>
 #include <linux/gpio.h>
+#include <linux/atmel_io.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/pm_runtime.h>
 
@@ -180,17 +181,11 @@
 	  | SPI_BF(name, value))
 
 /* Register access macros */
-#ifdef CONFIG_AVR32
 #define spi_readl(port, reg) \
-	__raw_readl((port)->regs + SPI_##reg)
+	atmel_oc_readl((port)->regs + SPI_##reg)
 #define spi_writel(port, reg, value) \
-	__raw_writel((value), (port)->regs + SPI_##reg)
-#else
-#define spi_readl(port, reg) \
-	readl_relaxed((port)->regs + SPI_##reg)
-#define spi_writel(port, reg, value) \
-	writel_relaxed((value), (port)->regs + SPI_##reg)
-#endif
+	atmel_oc_writel((value), (port)->regs + SPI_##reg)
+
 /* use PIO for small transfers, avoiding DMA setup/teardown overhead and
  * cache operations; better heuristics consider wordsize and bitrate.
  */
Signature · 1 line
2.1.4
#9 lore raw

RFC 4/6 spi: atmel: use atmel_io.h to provide on-chip IO

Quoted 4 lines · Ben Dooks

Use <linux/atmel_io.h> to provide IO accessors which work on both AVR32 and ARM for on-chip peripherals.

Quoted 8 lines

--
CC: Nicolas Ferre <[email protected]> (supporter:ATMEL SPI DRIVER)
CC: Mark Brown <[email protected]> (maintainer:SPI SUBSYSTEM)
CC: linux-spi at vger.kernel.org (open list:SPI SUBSYSTEM)
CC: linux-arm-kernel at lists.infradead.org

---
 drivers/spi/spi-atmel.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

<snipp diff>

Signature · 1 line
BR, HcE
maintainer
#10 lore raw

RFC 4/6 spi: atmel: use atmel_io.h to provide on-chip IO

In reply to Ben Dooks
Quoted 2 lines · Ben Dooks

Use <linux/atmel_io.h> to provide IO accessors which work on both AVR32 and ARM for on-chip peripherals.

To repeat the feedback on your previous big endian fix: I've not been
CCed on the cover letter or any of the other patches so can someone tell
me if there are any dependencies or anything?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150326/fd3c92b5/attachment-0001.sig>

#11 lore raw

RFC 4/6 spi: atmel: use atmel_io.h to provide on-chip IO

Le 26/03/2015 16:38, Mark Brown a ?crit :

Quoted 7 lines · Ben Dooks
Quoted 2 lines

Use <linux/atmel_io.h> to provide IO accessors which work on both AVR32 and ARM for on-chip peripherals.

To repeat the feedback on your previous big endian fix: I've not been CCed on the cover letter or any of the other patches so can someone tell me if there are any dependencies or anything?

Yes, there is dependency on a common header file. So I think we should keep the series grouped or plan a migration path.

Bye,

Signature · 1 line
Nicolas Ferre
maintainer
#12 lore raw

RFC 4/6 spi: atmel: use atmel_io.h to provide on-chip IO

Quoted 8 lines · Nicolas Ferre

Le 26/03/2015 16:38, Mark Brown a ?crit :

Quoted 3 lines

To repeat the feedback on your previous big endian fix: I've not been CCed on the cover letter or any of the other patches so can someone tell me if there are any dependencies or anything?

Yes, there is dependency on a common header file. So I think we should keep the series grouped or plan a migration path.

OK, thanks for letting me know - Ben, if you're working on this stuff
*please* bear dependency issues like this in mind.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150326/44f78a79/attachment.sig>

maintainer
#13 lore raw

RFC 4/6 spi: atmel: use atmel_io.h to provide on-chip IO

In reply to Ben Dooks
Quoted 2 lines · Ben Dooks

Use <linux/atmel_io.h> to provide IO accessors which work on both AVR32 and ARM for on-chip peripherals.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150326/e6aaa420/attachment.sig>

author
#14 lore raw

RFC 5/6 usb: gadget: atmel_usba: use atmel_io.h to provide on-chip IO

In reply to Ben Dooks

Use <linux/atmel_io.h> to provide IO accessors which work on both AVR32 and ARM for on-chip peripherals.

--
CC: Nicolas Ferre <[email protected]>
CC: Felipe Balbi <[email protected]>
CC: Greg Kroah-Hartman <[email protected]>
CC: linux-usb at vger.kernel.org

---
 drivers/usb/gadget/udc/atmel_usba_udc.c |  1 +
 drivers/usb/gadget/udc/atmel_usba_udc.h | 12 +++---------
 2 files changed, 4 insertions(+), 9 deletions(-)
drivers/usb/gadget/udc/atmel_usba_udc.c +1 -0
index be2f503..6735585 100644
@@ -13,6 +13,7 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/atmel_io.h>
 #include <linux/slab.h>
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
drivers/usb/gadget/udc/atmel_usba_udc.h +3 -9
index 92bd486..3d40aa3 100644
@@ -191,15 +191,9 @@
 	 | USBA_BF(name, value))
 
 /* Register access macros */
-#ifdef CONFIG_AVR32
-#define usba_io_readl	__raw_readl
-#define usba_io_writel	__raw_writel
-#define usba_io_writew	__raw_writew
-#else
-#define usba_io_readl	readl_relaxed
-#define usba_io_writel	writel_relaxed
-#define usba_io_writew	writew_relaxed
-#endif
+#define usba_io_readl	atmel_oc_readl
+#define usba_io_writel	atmel_oc_writel
+#define usba_io_writew	atmel_oc_writew
 
 #define usba_readl(udc, reg)					\
 	usba_io_readl((udc)->regs + USBA_##reg)
Signature · 1 line
2.1.4
#15 lore raw

RFC 5/6 usb: gadget: atmel_usba: use atmel_io.h to provide on-chip IO

Quoted 4 lines · Ben Dooks

Use <linux/atmel_io.h> to provide IO accessors which work on both AVR32 and ARM for on-chip peripherals.

Quoted 32 lines

--
CC: Nicolas Ferre <[email protected]>
CC: Felipe Balbi <[email protected]>
CC: Greg Kroah-Hartman <[email protected]>
CC: linux-usb at vger.kernel.org

---
 drivers/usb/gadget/udc/atmel_usba_udc.c |  1 +
 drivers/usb/gadget/udc/atmel_usba_udc.h | 12 +++---------
 2 files changed, 4 insertions(+), 9 deletions(-)
drivers/usb/gadget/udc/atmel_usba_udc.c +1 -0
index be2f503..6735585 100644
@@ -13,6 +13,7 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/atmel_io.h>
 #include <linux/slab.h>
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
drivers/usb/gadget/udc/atmel_usba_udc.h +0 -2
index 92bd486..3d40aa3 100644
@@ -191,15 +191,9 @@
 	 | USBA_BF(name, value))
 
 /* Register access macros */
-#ifdef CONFIG_AVR32
-#define usba_io_readl	__raw_readl

drivers/usb/gadget/udc/atmel_usba_udc.h line 196

Quoted 10 lines
drivers/usb/gadget/udc/atmel_usba_udc.h +3 -7
-#define usba_io_writel	__raw_writel
-#define usba_io_writew	__raw_writew
-#else
-#define usba_io_readl	readl_relaxed
-#define usba_io_writel	writel_relaxed
-#define usba_io_writew	writew_relaxed
-#endif
+#define usba_io_readl	atmel_oc_readl
+#define usba_io_writel	atmel_oc_writel
+#define usba_io_writew	atmel_oc_writew

Same comment as earlier patch, it would be nice to remove the define usba_io_{read,write}{l,w} defines in a follow-up patch.

<snipp diff>

Signature · 2 lines
mvh
Hans-Christian Egtvedt
#16 lore raw

RFC 5/6 usb: gadget: atmel_usba: use atmel_io.h to provide on-chip IO

Quoted 37 lines · Hans-Christian Egtvedt
Quoted 4 lines · Ben Dooks

Use <linux/atmel_io.h> to provide IO accessors which work on both AVR32 and ARM for on-chip peripherals.

Quoted 29 lines

--
CC: Nicolas Ferre <[email protected]>
CC: Felipe Balbi <[email protected]>
CC: Greg Kroah-Hartman <[email protected]>
CC: linux-usb at vger.kernel.org

---
 drivers/usb/gadget/udc/atmel_usba_udc.c |  1 +
 drivers/usb/gadget/udc/atmel_usba_udc.h | 12 +++---------
 2 files changed, 4 insertions(+), 9 deletions(-)
drivers/usb/gadget/udc/atmel_usba_udc.c +1 -0
index be2f503..6735585 100644
@@ -13,6 +13,7 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/atmel_io.h>
 #include <linux/slab.h>
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
drivers/usb/gadget/udc/atmel_usba_udc.h +0 -0
index 92bd486..3d40aa3 100644
@@ -191,15 +191,9 @@
 	 | USBA_BF(name, value))
 
Quoted 16 lines

drivers/usb/gadget/udc/atmel_usba_udc.h line 196

Quoted 13 lines
drivers/usb/gadget/udc/atmel_usba_udc.h +3 -9
 /* Register access macros */
-#ifdef CONFIG_AVR32
-#define usba_io_readl	__raw_readl
-#define usba_io_writel	__raw_writel
-#define usba_io_writew	__raw_writew
-#else
-#define usba_io_readl	readl_relaxed
-#define usba_io_writel	writel_relaxed
-#define usba_io_writew	writew_relaxed
-#endif
+#define usba_io_readl	atmel_oc_readl
+#define usba_io_writel	atmel_oc_writel
+#define usba_io_writew	atmel_oc_writew

Same comment as earlier patch, it would be nice to remove the define usba_io_{read,write}{l,w} defines in a follow-up patch.

I'm fine with this too. Is this targetted at v4.2 ?

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150427/3e26756e/attachment.sig>
author
#17 lore raw

RFC 5/6 usb: gadget: atmel_usba: use atmel_io.h to provide on-chip IO

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Quoted 12 lines
Quoted 11 lines
Quoted 8 lines

/* Register access macros */ -#ifdef CONFIG_AVR32 -#define
usba_io_readl __raw_readl -#define usba_io_writel __raw_writel
-#define usba_io_writew __raw_writew -#else -#define
usba_io_readl readl_relaxed -#define usba_io_writel
writel_relaxed -#define usba_io_writew writew_relaxed -#endif
+#define usba_io_readl atmel_oc_readl +#define usba_io_writel
atmel_oc_writel +#define usba_io_writew atmel_oc_writew

Same comment as earlier patch, it would be nice to remove the define usba_io_{read,write}{l,w} defines in a follow-up patch.

Quoted 1 line

I'm fine with this too. Is this targetted at v4.2 ?

Yes, although we may move it to the soc specific include directories to avoid adding more to linux/

I will be sorting this out next week.

- --
Ben Dooks http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJVP6neAAoJEMuhVOkVU3uz6tQH/jmZ0MszsoDjiKWdTnG+etoy WUhAEdnmaqPEfJSaBy2OPCcmj9T1O07wg1L/2rHQHBrVuR9bW0gWY/TyJQahnn3A YG81fgfIvOTAwmxIkaF10mG1/haG1LgPQ4P6j7AaKz09Zowath0rsga17AhYuUyh bps4Go7yHF/OpjuwB9VxSttMAbVAIHqXbuc5kufN89JAxDT6x5tV/BrqkqEoHpSV kW7VvGb/V4Aeax1h9klfdUEBlL2czkVuYYtTnicc9lFN3T9+6XJ+SNwKLtSklEr3 SLM78DoIQQoKYWCf8vsg0FR0E9LeR1ytgZXPfOpdAoId+iZt39tBk9bMi/XOiBo= =ceej
-----END PGP SIGNATURE-----

#18 lore raw

RFC 5/6 usb: gadget: atmel_usba: use atmel_io.h to provide on-chip IO

Le 28/04/2015 17:40, Ben Dooks a ?crit :

Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 9 lines

/* Register access macros */ -#ifdef CONFIG_AVR32 -#define
usba_io_readl __raw_readl -#define usba_io_writel __raw_writel
-#define usba_io_writew __raw_writew -#else -#define
usba_io_readl readl_relaxed -#define usba_io_writel
writel_relaxed -#define usba_io_writew writew_relaxed -#endif
+#define usba_io_readl atmel_oc_readl +#define usba_io_writel
atmel_oc_writel +#define usba_io_writew atmel_oc_writew

Same comment as earlier patch, it would be nice to remove the define usba_io_{read,write}{l,w} defines in a follow-up patch.

Quoted 4 lines
Quoted 1 line

I'm fine with this too. Is this targetted at v4.2 ?

Yes, although we may move it to the soc specific include directories to avoid adding more to linux/

BTW, Ben, what _oc_ stands for in the new macro name?

Bye,

Signature · 1 line
Nicolas Ferre
#19 lore raw

RFC 5/6 usb: gadget: atmel_usba: use atmel_io.h to provide on-chip IO

In reply to Ben Dooks

Hi,

Quoted 11 lines · Ben Dooks
Quoted 11 lines
Quoted 10 lines
Quoted 7 lines

/* Register access macros */ -#ifdef CONFIG_AVR32 -#define
usba_io_readl __raw_readl -#define usba_io_writel __raw_writel
-#define usba_io_writew __raw_writew -#else -#define
usba_io_readl readl_relaxed -#define usba_io_writel
writel_relaxed -#define usba_io_writew writew_relaxed -#endif
+#define usba_io_readl atmel_oc_readl +#define usba_io_writel
atmel_oc_writel +#define usba_io_writew atmel_oc_writew

Same comment as earlier patch, it would be nice to remove the define usba_io_{read,write}{l,w} defines in a follow-up patch.

Quoted 6 lines
Quoted 1 line

I'm fine with this too. Is this targetted at v4.2 ?

Yes, although we may move it to the soc specific include directories to avoid adding more to linux/

I will be sorting this out next week.

I would rather not see drivers including anything from asm or mach-* (unless strictly necessary), otherwise it's a pain to build-test anything

cheers

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150428/736c6cb1/attachment-0001.sig>
author
#20 lore raw

RFC 5/6 usb: gadget: atmel_usba: use atmel_io.h to provide on-chip IO

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Quoted 18 lines · Felipe Balbi

Hi,

Quoted 15 lines · Ben Dooks
Quoted 14 lines
Quoted 4 lines
Quoted 4 lines

/* Register access macros */ -#ifdef CONFIG_AVR32 -#define
usba_io_readl __raw_readl -#define usba_io_writel
__raw_writel -#define usba_io_writew __raw_writew -#else
-#define usba_io_readl readl_relaxed -#define

Quoted 8 lines
Quoted 4 lines

usba_io_writel writel_relaxed -#define usba_io_writew writew_relaxed -#endif +#define usba_io_readl atmel_oc_readl +#define usba_io_writel atmel_oc_writel
+#define usba_io_writew atmel_oc_writew

Same comment as earlier patch, it would be nice to remove the define usba_io_{read,write}{l,w} defines in a follow-up patch.

I'm fine with this too. Is this targetted at v4.2 ?

Quoted 8 lines
Quoted 4 lines

Yes, although we may move it to the soc specific include directories to avoid adding more to linux/

I will be sorting this out next week.

I would rather not see drivers including anything from asm or mach-* (unless strictly necessary), otherwise it's a pain to build-test anything

Thanks. I think the soc/ include is available for all. I will check this tomorrow.

- --
Ben Dooks http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJVP7aBAAoJEMuhVOkVU3uzId4H/3ZsZ4Vogng63I04OpLtt5Qs VopvttCvaLczye/wOWQKptXJuKIBmrs66BcV4ZsVi1SZjfbju9X1blzc0+6fxU9X xE2rw3kDPZmtKm6v1GCRrE/uzhKeKgAnfp7Yf7pkdn98Lx2D9gy/s7GRN6Bkql28 pz/QIqr/H6Hp2frbubakKx/F7SFV88ZUNZXLkw8+vkn7gKGRX7ODcPFldjbjooIa zyDdrZWiqhTHdWzQ813vNgKJfP1GiYNZuht+EhAh0ngLy0YnqnSXF0eZiOy/uF0Z cCMlXZo1Q/2LkqVKEgywJDxGhCruT3RpPDWLk6eA9trlHF62j3WSn65nDxKtBwA= =cqtq
-----END PGP SIGNATURE-----

#21 lore raw

RFC 5/6 usb: gadget: atmel_usba: use atmel_io.h to provide on-chip IO

Quoted 27 lines · Ben Dooks

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Quoted 23 lines · Felipe Balbi

Hi,

Quoted 19 lines · Ben Dooks
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines

/* Register access macros */ -#ifdef CONFIG_AVR32 -#define
usba_io_readl __raw_readl -#define usba_io_writel
__raw_writel -#define usba_io_writew __raw_writew -#else
-#define usba_io_readl readl_relaxed -#define

Quoted 8 lines
Quoted 4 lines

usba_io_writel writel_relaxed -#define usba_io_writew writew_relaxed -#endif +#define usba_io_readl atmel_oc_readl +#define usba_io_writel atmel_oc_writel
+#define usba_io_writew atmel_oc_writew

Same comment as earlier patch, it would be nice to remove the define usba_io_{read,write}{l,w} defines in a follow-up patch.

Quoted 1 line

I'm fine with this too. Is this targetted at v4.2 ?

Yes, although we may move it to the soc specific include directories to avoid adding more to linux/

I will be sorting this out next week.

Quoted 7 lines
Quoted 3 lines

I would rather not see drivers including anything from asm or mach-* (unless strictly necessary), otherwise it's a pain to build-test anything

Thanks. I think the soc/ include is available for all. I will check this tomorrow.

if that's the case, no issues from my side :-)

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150428/27cfa000/attachment.sig>
author
#22 lore raw

RFC 6/6 mmc: atmel-mci: use atmel_io.h to provide on-chip IO

In reply to Ben Dooks

Use <linux/atmel_io.h> to provide IO accessors which work on both AVR32 and ARM for on-chip peripherals.

--
CC: Ludovic Desroches <[email protected]>
CC: Chris Ball <[email protected]>
CC: Ulf Hansson <[email protected]>
CC: linux-mmc at vger.kernel.org

---
 drivers/mmc/host/atmel-mci-regs.h | 11 ++---------
 drivers/mmc/host/atmel-mci.c      |  1 +
 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/mmc/host/atmel-mci-regs.h +2 -9
index 711bb53..2293f2c 100644
@@ -135,17 +135,10 @@
 #define ATMCI_REGS_SIZE		0x100
 
 /* Register access macros */
-#ifdef CONFIG_AVR32
 #define atmci_readl(port,reg)			\
-	__raw_readl((port)->regs + reg)
+	atmel_oc_readl((port)->regs + reg)
 #define atmci_writel(port,reg,value)			\
-	__raw_writel((value), (port)->regs + reg)
-#else
-#define atmci_readl(port,reg)			\
-	readl_relaxed((port)->regs + reg)
-#define atmci_writel(port,reg,value)			\
-	writel_relaxed((value), (port)->regs + reg)
-#endif
+	atmel_oc_writel((value), (port)->regs + reg)
 
 /* On AVR chips the Peripheral DMA Controller is not connected to MCI. */
 #ifdef CONFIG_AVR32
drivers/mmc/host/atmel-mci.c +1 -0
index 03d7c75..49de0d7 100644
@@ -37,6 +37,7 @@
 
 #include <linux/atmel-mci.h>
 #include <linux/atmel_pdc.h>
+#include <linux/atmel_io.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
 #include <linux/pinctrl/consumer.h>
Signature · 1 line
2.1.4
#23 lore raw

RFC 6/6 mmc: atmel-mci: use atmel_io.h to provide on-chip IO

Quoted 25 lines · Ben Dooks

Use <linux/atmel_io.h> to provide IO accessors which work on both AVR32 and ARM for on-chip peripherals.

--
CC: Ludovic Desroches <[email protected]>
CC: Chris Ball <[email protected]>
CC: Ulf Hansson <[email protected]>
CC: linux-mmc at vger.kernel.org

---
 drivers/mmc/host/atmel-mci-regs.h | 11 ++---------
 drivers/mmc/host/atmel-mci.c      |  1 +
 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/mmc/host/atmel-mci-regs.h +0 -2
index 711bb53..2293f2c 100644
@@ -135,17 +135,10 @@
 #define ATMCI_REGS_SIZE		0x100
 
 /* Register access macros */
-#ifdef CONFIG_AVR32
 #define atmci_readl(port,reg)			\
-	__raw_readl((port)->regs + reg)

drivers/mmc/host/atmel-mci-regs.h line 141

Quoted 10 lines
drivers/mmc/host/atmel-mci-regs.h +2 -7
+	atmel_oc_readl((port)->regs + reg)
 #define atmci_writel(port,reg,value)			\
-	__raw_writel((value), (port)->regs + reg)
-#else
-#define atmci_readl(port,reg)			\
-	readl_relaxed((port)->regs + reg)
-#define atmci_writel(port,reg,value)			\
-	writel_relaxed((value), (port)->regs + reg)
-#endif
+	atmel_oc_writel((value), (port)->regs + reg)

Defines are utilized in the header file, but ...

drivers/mmc/host/atmel-mci.c line 40

Quoted 12 lines
drivers/mmc/host/atmel-mci-regs.h +0 -0
 /* On AVR chips the Peripheral DMA Controller is not connected to MCI. */
 #ifdef CONFIG_AVR32
drivers/mmc/host/atmel-mci.c +1 -0
index 03d7c75..49de0d7 100644
@@ -37,6 +37,7 @@
 
 #include <linux/atmel-mci.h>
 #include <linux/atmel_pdc.h>
+#include <linux/atmel_io.h>

... you include the required header file in the source file instead.

Also, a follow-up patch could remove the atmci_{read,write}{l,w} defines completely.

Quoted 3 lines
drivers/mmc/host/atmel-mci.c +0 -0
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
 #include <linux/pinctrl/consumer.h>
Signature · 2 lines
mvh
Hans-Christian Egtvedt
author
#24 lore raw
In reply to Ben Dooks
Quoted 2 lines · Ben Dooks

As discussed from Ben Hutchings' suggestion on the original series, avoid open coding the AVR32/AT91 IO accessors.

I think the only thing to discuss is whether to use linux/atmel_io.h or maybe put it under include/soc/atmel ?

Signature · 2 lines
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius