Skip to contentSkip to conversation

xilinx_spi: Splitted into generic, of and platform driver, added support for DS570

PATCH In review Richard Röjfors 6 participants 10 messages Sep 28, 2009 – Nov 11, 2009 4 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 xilinx_spi: Splitted into generic, of and platform driver, added support for DS570

This patch splits xilinx_spi into three parts, an OF and a platform driver and generic part.

The generic part now also works on X86, it supports accessing the IP booth big and little endian. There is also support for 16 and 32 bit SPI for the Xilinx SPI IP DS570

---

drivers/spi/Kconfig +17 -2
index 2c733c2..ecabc12 100644
@@ -218,8 +218,8 @@ config SPI_TXX9
 	  SPI driver for Toshiba TXx9 MIPS SoCs
 
 config SPI_XILINX
-	tristate "Xilinx SPI controller"
-	depends on (XILINX_VIRTEX || MICROBLAZE) && EXPERIMENTAL
+	tristate "Xilinx SPI controller common module"
+	depends on HAS_IOMEM && EXPERIMENTAL
 	select SPI_BITBANG
 	help
 	  This exposes the SPI controller IP from the Xilinx EDK.
@@ -227,6 +227,21 @@ config SPI_XILINX
 	  See the "OPB Serial Peripheral Interface (SPI) (v1.00e)"
 	  Product Specification document (DS464) for hardware details.
 
+	  Or for the DS570, see "XPS Serial Peripheral Interface (SPI) (v2.00b)"
+
+config SPI_XILINX_OF
+	tristate "Xilinx SPI controller OF device"
+	depends on SPI_XILINX && XILINX_VIRTEX
+	help
+	  This is the OF driver for the SPI controller IP from the Xilinx EDK.
+
+config SPI_XILINX_PLTFM
+	tristate "Xilinx SPI controller platform device"
+	depends on SPI_XILINX
+	help
+	  This is the platform driver for the SPI controller IP
+	  from the Xilinx EDK.
+
 #
 # Add new SPI master controllers in alphabetical order above this line
 #
drivers/spi/Makefile +2 -0
index 3de408d..5a91cf5 100644
@@ -30,6 +30,8 @@ obj-$(CONFIG_SPI_S3C24XX_GPIO)		+= spi_s3c24xx_gpio.o
 obj-$(CONFIG_SPI_S3C24XX)		+= spi_s3c24xx.o
 obj-$(CONFIG_SPI_TXX9)			+= spi_txx9.o
 obj-$(CONFIG_SPI_XILINX)		+= xilinx_spi.o
+obj-$(CONFIG_SPI_XILINX_OF)		+= xilinx_spi_of.o
+obj-$(CONFIG_SPI_XILINX_PLTFM)		+= xilinx_spi_pltfm.o
 obj-$(CONFIG_SPI_SH_SCI)		+= spi_sh_sci.o
 # 	... add above this line ...
 
drivers/spi/xilinx_spi.c +193 -192

582 lines not on this page · raw message

drivers/spi/xilinx_spi.h new file +33 -0
new file mode 100644
index 0000000..e0ad67e
@@ -0,0 +1,33 @@
+/*
+ * xilinx_spi.h
+ * Copyright (c) 2009 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _XILINX_SPI_H_
+#define _XILINX_SPI_H_ 1
+
+#include <linux/spi/spi.h>
+#include <linux/spi/spi_bitbang.h>
+#include <linux/spi/xilinx_spi.h>
+
+#define XILINX_SPI_NAME "xilinx_spi"
+
+struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
+	u32 irq, s16 bus_num, u16 num_chipselect, u8 bits_per_word,
+	bool big_endian);
+
+void xilinx_spi_deinit(struct spi_master *master);
+#endif
drivers/spi/xilinx_spi_of.c new file +120 -0

120 lines not on this page · raw message

drivers/spi/xilinx_spi_pltfm.c new file +104 -0

104 lines not on this page · raw message

include/linux/spi/xilinx_spi.h new file +19 -0
new file mode 100644
index 0000000..03e1301
@@ -0,0 +1,19 @@
+#ifndef __LINUX_SPI_XILINX_SPI_H
+#define __LINUX_SPI_XILINX_SPI_H
+
+/**
+ * struct xspi_platform_data - Platform data of the Xilinx SPI driver
+ * @num_chipselect:	Number of chip select by the IP
+ * @bits_per_word:	Number of bits per word. 8/16/32, Note that the DS464
+ *			only support 8bit SPI.
+ * @devices:		Devices to add when the driver is probed.
+ * @num_devices:	Number of devices in the devices array.
+ */
+struct xspi_platform_data {
+	u16 num_chipselect;
+	u8 bits_per_word;
+	struct spi_board_info *devices;
+	u8 num_devices;
+};
+
+#endif /* __LINUX_SPI_XILINX_SPI_H */
#1 lore raw
Quoted 24 lines

-----Original Message-----
From: Richard Röjfors [mailto:[email protected]]
Sent: Monday, September 28, 2009 8:22 AM
To: [email protected]
Cc: [email protected]; [email protected]; Andrew Morton; John Linn
Subject: [PATCH v4] xilinx_spi: Splitted into generic, of and platform driver, added support for DS570

This patch splits xilinx_spi into three parts, an OF and a platform driver and generic part.

The generic part now also works on X86, it supports accessing the IP booth big and little endian. There is also support for 16 and 32 bit SPI for the Xilinx SPI IP DS570

---

drivers/spi/Kconfig +0 -0
index 2c733c2..ecabc12 100644
@@ -218,8 +218,8 @@ config SPI_TXX9
 	  SPI driver for Toshiba TXx9 MIPS SoCs
 

<snip>

Quoted 11 lines
drivers/spi/Kconfig +6 -4
-struct xilinx_spi {
-	/* bitbang has to be first */
-	struct spi_bitbang bitbang;
-	struct completion done;
+/* to follow are some functions that does little of big endian read and
+ * write depending on the config of the device.
+ */
+static inline void xspi_write8(struct xilinx_spi *xspi, u32 offs, u8 val)
+{
+	iowrite8(val, xspi->regs + offs + ((xspi->big_endian) ? 3 : 0));

drivers/spi/Kconfig

Quoted 10 lines
drivers/spi/Kconfig +8 -1
+}
 
-	void __iomem	*regs;	/* virt. address of the control registers */
+static inline void xspi_write16(struct xilinx_spi *xspi, u32 offs, u16 val)
+{
+	if (xspi->big_endian)
+		iowrite16be(val, xspi->regs + offs + 2);
+	else
+		iowrite16(val, xspi->regs + offs);
+}

Hi Richard,

If you're worried about efficiency (the reason for 16 and 32 bit xfers), why wouldn't you do the big-endian vs little endian I/O decision at compile time rather than run time?

The big_endian variable is not a constant boolean, I don't know if that could help so that the compiler optimizes this check away? Or maybe it is already and I'm just missing that?

Quoted 20 lines
drivers/spi/Kconfig +11 -6
-	u32		irq;
+static inline void xspi_write32(struct xilinx_spi *xspi, u32 offs, u32 val)
+{
+	if (xspi->big_endian)
+		iowrite32be(val, xspi->regs + offs);
+	else
+		iowrite32(val, xspi->regs + offs);
+}
 
-	u32		speed_hz; /* SCK has a fixed frequency of speed_hz Hz */
+static inline u8 xspi_read8(struct xilinx_spi *xspi, u32 offs)
+{
+	return ioread8(xspi->regs + offs + ((xspi->big_endian) ? 3 : 0));
+}
 
-	u8 *rx_ptr;		/* pointer in the Tx buffer */
-	const u8 *tx_ptr;	/* pointer in the Rx buffer */
-	int remaining_bytes;	/* the number of bytes left to transfer */
-};

<snip>

Quoted 48 lines
drivers/spi/Kconfig +19 -8
-
 /* This driver supports single master mode only. Hence Tx FIFO Empty
  * is the only interrupt we care about.
  * Receive FIFO Overrun, Transmit FIFO Underrun, Mode Fault, and Slave Mode
@@ -237,32 +298,50 @@ static irqreturn_t xilinx_spi_irq(int irq, void *dev_id)
 	u32 ipif_isr;
 
 	/* Get the IPIF interrupts, and clear them immediately */
-	ipif_isr = in_be32(xspi->regs + XIPIF_V123B_IISR_OFFSET);
-	out_be32(xspi->regs + XIPIF_V123B_IISR_OFFSET, ipif_isr);
+	ipif_isr = xspi_read32(xspi, XIPIF_V123B_IISR_OFFSET);
+	xspi_write32(xspi, XIPIF_V123B_IISR_OFFSET, ipif_isr);
 
 	if (ipif_isr & XSPI_INTR_TX_EMPTY) {	/* Transmission completed */
 		u16 cr;
 		u8 sr;
+		u8 rsize;
+		if (xspi->bits_per_word == 8)
+			rsize = 1;
+		else if (xspi->bits_per_word == 16)
+			rsize = 2;
+		else
+			rsize = 4;
 
 		/* A transmit has just completed. Process received data and
 		 * check for more data to transmit. Always inhibit the
 		 * transmitter while the Isr refills the transmit register/FIFO,
 		 * or make sure it is stopped if we're done.
 		 */
-		cr = in_be16(xspi->regs + XSPI_CR_OFFSET);
-		out_be16(xspi->regs + XSPI_CR_OFFSET,
-			 cr | XSPI_CR_TRANS_INHIBIT);
+		cr = xspi_read16(xspi, XSPI_CR_OFFSET);
+		xspi_write16(xspi, XSPI_CR_OFFSET, cr | XSPI_CR_TRANS_INHIBIT);
 
 		/* Read out all the data from the Rx FIFO */
-		sr = in_8(xspi->regs + XSPI_SR_OFFSET);
+		sr = xspi_read8(xspi, XSPI_SR_OFFSET);
 		while ((sr & XSPI_SR_RX_EMPTY_MASK) == 0) {
-			u8 data;
+			u32 data;
+			if (rsize == 1)
+				data = xspi_read8(xspi, XSPI_RXD_OFFSET);
+			else if (rsize == 2)
+				data = xspi_read16(xspi, XSPI_RXD_OFFSET);
+			else
+				data = xspi_read32(xspi, XSPI_RXD_OFFSET);
 

drivers/spi/Kconfig static irqreturn_t xilinx_spi_irq(int irq, void *dev_id) · line 341

Quoted 10 lines
drivers/spi/Kconfig +7 -2
-			data = in_8(xspi->regs + XSPI_RXD_OFFSET);
 			if (xspi->rx_ptr) {
-				*xspi->rx_ptr++ = data;
+				if (rsize == 1)
+					*xspi->rx_ptr = data & 0xff;
+				else if (rsize == 2)
+					*(u16 *)(xspi->rx_ptr) = data & 0xffff;
+				else
+					*((u32 *)(xspi->rx_ptr)) = data;
+				xspi->rx_ptr += rsize;

Maybe I'm out of line here...

I'm wondering if this is going to be any more efficient that just using 8 bit accesses as it seems like the amount of run-time decisions being made is quite a few. I guess it depends on how many bytes are being transferred as with big transfers maybe it will pay off.

In my opinion, which isn't worth much many times :), sometimes the flexibility with soft logic, like this is a pain for testability and increases complexity. If there's reasonable performance gains then maybe it's a good tradeoff.

Do you know how much performance gain there is or is expected as maybe you've seen the pay off already?

Thanks,
John

Quoted 17 lines
drivers/spi/Kconfig +3 -2
 			}
-			sr = in_8(xspi->regs + XSPI_SR_OFFSET);
+
+			sr = xspi_read8(xspi, XSPI_SR_OFFSET);
 		}
 
 		/* See if there is more data to send */
@@ -271,7 +350,7 @@ static irqreturn_t xilinx_spi_irq(int irq, void *dev_id)
 			/* Start the transfer by not inhibiting the
 			 * transmitter any longer
 			 */
-			out_be16(xspi->regs + XSPI_CR_OFFSET, cr);
+			xspi_write16(xspi, XSPI_CR_OFFSET, cr);
 		} else {
 			/* No more data to send.
 			 * Indicate the transfer is completed.

drivers/spi/Kconfig static irqreturn_t xilinx_spi_irq(int irq, void *dev_id) · line 363

Quoted 7 lines
drivers/spi/Kconfig +0 -1
@@ -279,44 +358,21 @@ static irqreturn_t xilinx_spi_irq(int irq, void *dev_id)
 			complete(&xspi->done);
 		}
 	}
-
 	return IRQ_HANDLED;
 }
 

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

#2 lore raw
Quoted 40 lines · John Linn
Quoted 24 lines

-----Original Message-----
From: Richard Röjfors [mailto:[email protected]]
Sent: Monday, September 28, 2009 8:22 AM
To: [email protected]
Cc: [email protected]; [email protected]; Andrew Morton; John Linn
Subject: [PATCH v4] xilinx_spi: Splitted into generic, of and platform driver, added support for DS570

This patch splits xilinx_spi into three parts, an OF and a platform driver and generic part.

The generic part now also works on X86, it supports accessing the IP booth big and little endian. There is also support for 16 and 32 bit SPI for the Xilinx SPI IP DS570

---

drivers/spi/Kconfig +0 -0
index 2c733c2..ecabc12 100644
@@ -218,8 +218,8 @@ config SPI_TXX9
 	  SPI driver for Toshiba TXx9 MIPS SoCs
 

<snip>

Quoted 13 lines
drivers/spi/Kconfig +7 -4
-struct xilinx_spi {
-	/* bitbang has to be first */
-	struct spi_bitbang bitbang;
-	struct completion done;
+/* to follow are some functions that does little of big endian read and
+ * write depending on the config of the device.
+ */
+static inline void xspi_write8(struct xilinx_spi *xspi, u32 offs, u8 val)
+{
+	iowrite8(val, xspi->regs + offs + ((xspi->big_endian) ? 3 : 0));
+}
Quoted 11 lines

drivers/spi/Kconfig

Quoted 8 lines
drivers/spi/Kconfig +7 -1
-	void __iomem	*regs;	/* virt. address of the control registers */
+static inline void xspi_write16(struct xilinx_spi *xspi, u32 offs, u16 val)
+{
+	if (xspi->big_endian)
+		iowrite16be(val, xspi->regs + offs + 2);
+	else
+		iowrite16(val, xspi->regs + offs);
+}

Hi Richard,

Hi John,

Thanks for the quick feedback.

Quoted 1 line

If you're worried about efficiency (the reason for 16 and 32 bit xfers), why wouldn't you do the big-endian vs little endian I/O decision at compile time rather than run time?

I'm afraid we can't do it compile time, if we want to be flexible. As example;
The IP is big endian, in our case the PCI interface flips the byte order. But the PCI interface might be setup differently ->would be accessed big endian even on a little endian machine.

We could use callbacks set up during probe, instead of having the if-sentence. But I don't think the callback solution could be slower (if talking performance), since the compiler can't inline them, the current functions could be inlined if the compiler feels like it.

Quoted 86 lines

The big_endian variable is not a constant boolean, I don't know if that could help so that the compiler optimizes this check away? Or maybe it is already and I'm just missing that?

Quoted 20 lines
drivers/spi/Kconfig +11 -6
-	u32		irq;
+static inline void xspi_write32(struct xilinx_spi *xspi, u32 offs, u32 val)
+{
+	if (xspi->big_endian)
+		iowrite32be(val, xspi->regs + offs);
+	else
+		iowrite32(val, xspi->regs + offs);
+}
 
-	u32		speed_hz; /* SCK has a fixed frequency of speed_hz Hz */
+static inline u8 xspi_read8(struct xilinx_spi *xspi, u32 offs)
+{
+	return ioread8(xspi->regs + offs + ((xspi->big_endian) ? 3 : 0));
+}
 
-	u8 *rx_ptr;		/* pointer in the Tx buffer */
-	const u8 *tx_ptr;	/* pointer in the Rx buffer */
-	int remaining_bytes;	/* the number of bytes left to transfer */
-};

<snip>

Quoted 48 lines
drivers/spi/Kconfig +19 -8
-
 /* This driver supports single master mode only. Hence Tx FIFO Empty
  * is the only interrupt we care about.
  * Receive FIFO Overrun, Transmit FIFO Underrun, Mode Fault, and Slave Mode
@@ -237,32 +298,50 @@ static irqreturn_t xilinx_spi_irq(int irq, void *dev_id)
 	u32 ipif_isr;
 
 	/* Get the IPIF interrupts, and clear them immediately */
-	ipif_isr = in_be32(xspi->regs + XIPIF_V123B_IISR_OFFSET);
-	out_be32(xspi->regs + XIPIF_V123B_IISR_OFFSET, ipif_isr);
+	ipif_isr = xspi_read32(xspi, XIPIF_V123B_IISR_OFFSET);
+	xspi_write32(xspi, XIPIF_V123B_IISR_OFFSET, ipif_isr);
 
 	if (ipif_isr & XSPI_INTR_TX_EMPTY) {	/* Transmission completed */
 		u16 cr;
 		u8 sr;
+		u8 rsize;
+		if (xspi->bits_per_word == 8)
+			rsize = 1;
+		else if (xspi->bits_per_word == 16)
+			rsize = 2;
+		else
+			rsize = 4;
 
 		/* A transmit has just completed. Process received data and
 		 * check for more data to transmit. Always inhibit the
 		 * transmitter while the Isr refills the transmit register/FIFO,
 		 * or make sure it is stopped if we're done.
 		 */
-		cr = in_be16(xspi->regs + XSPI_CR_OFFSET);
-		out_be16(xspi->regs + XSPI_CR_OFFSET,
-			 cr | XSPI_CR_TRANS_INHIBIT);
+		cr = xspi_read16(xspi, XSPI_CR_OFFSET);
+		xspi_write16(xspi, XSPI_CR_OFFSET, cr | XSPI_CR_TRANS_INHIBIT);
 
 		/* Read out all the data from the Rx FIFO */
-		sr = in_8(xspi->regs + XSPI_SR_OFFSET);
+		sr = xspi_read8(xspi, XSPI_SR_OFFSET);
 		while ((sr & XSPI_SR_RX_EMPTY_MASK) == 0) {
-			u8 data;
+			u32 data;
+			if (rsize == 1)
+				data = xspi_read8(xspi, XSPI_RXD_OFFSET);
+			else if (rsize == 2)
+				data = xspi_read16(xspi, XSPI_RXD_OFFSET);
+			else
+				data = xspi_read32(xspi, XSPI_RXD_OFFSET);
 

drivers/spi/Kconfig static irqreturn_t xilinx_spi_irq(int irq, void *dev_id) · line 341

Quoted 10 lines
drivers/spi/Kconfig +7 -2
-			data = in_8(xspi->regs + XSPI_RXD_OFFSET);
 			if (xspi->rx_ptr) {
-				*xspi->rx_ptr++ = data;
+				if (rsize == 1)
+					*xspi->rx_ptr = data & 0xff;
+				else if (rsize == 2)
+					*(u16 *)(xspi->rx_ptr) = data & 0xffff;
+				else
+					*((u32 *)(xspi->rx_ptr)) = data;
+				xspi->rx_ptr += rsize;

Maybe I'm out of line here...

Quoted 1 line

I'm wondering if this is going to be any more efficient that just using 8 bit accesses

We can not do 8 bit accesses if the IP is set up to do 16/32bit SPI, then the TX/RX registers are as wide as the bit setup.

We could do 32 bit reads from the registers, then we waste some cycles on the PLB bus, but have slightly simpler code.

Quoted 5 lines

as it seems like the amount of run-time decisions being made is quite a few. I guess it depends on how many bytes are being transferred as with big transfers maybe it will pay off.

In my opinion, which isn't worth much many times :), sometimes the flexibility with soft logic, like this is a pain for testability and increases complexity. If there's reasonable performance gains then maybe it's a good tradeoff.

Do you know how much performance gain there is or is expected as maybe you've seen the pay off already?

I haven't done any measurements, and we are basically only controlling GPIO so performance is not an issue for us. I just didn't want do make it slower. I think you have more experience here. Do you think it's better to just do 32bit reads to make the code simple? If so I will update the code.

Thanks
--Richard

#3 lore raw
Quoted 62 lines

-----Original Message-----
From: Richard Röjfors [mailto:[email protected]]
Sent: Tuesday, September 29, 2009 12:35 AM
To: John Linn
Cc: [email protected]; [email protected]; [email protected]; Andrew Morton
Subject: Re: [PATCH v4] xilinx_spi: Splitted into generic, of and platform driver, added support for DS570

Quoted 40 lines · John Linn
Quoted 24 lines

-----Original Message-----
From: Richard Röjfors [mailto:[email protected]]
Sent: Monday, September 28, 2009 8:22 AM
To: [email protected]
Cc: [email protected]; [email protected]; Andrew Morton; John Linn
Subject: [PATCH v4] xilinx_spi: Splitted into generic, of and platform driver, added support for DS570

This patch splits xilinx_spi into three parts, an OF and a platform driver and generic part.

The generic part now also works on X86, it supports accessing the IP booth big and little endian. There is also support for 16 and 32 bit SPI for the Xilinx SPI IP DS570

---

drivers/spi/Kconfig +0 -0
index 2c733c2..ecabc12 100644
@@ -218,8 +218,8 @@ config SPI_TXX9
 	  SPI driver for Toshiba TXx9 MIPS SoCs
 

<snip>

Quoted 13 lines
drivers/spi/Kconfig +7 -4
-struct xilinx_spi {
-	/* bitbang has to be first */
-	struct spi_bitbang bitbang;
-	struct completion done;
+/* to follow are some functions that does little of big endian read and
+ * write depending on the config of the device.
+ */
+static inline void xspi_write8(struct xilinx_spi *xspi, u32 offs, u8 val)
+{
+	iowrite8(val, xspi->regs + offs + ((xspi->big_endian) ? 3 : 0));
+}
Quoted 11 lines

drivers/spi/Kconfig

Quoted 8 lines
drivers/spi/Kconfig +7 -1
-	void __iomem	*regs;	/* virt. address of the control registers */
+static inline void xspi_write16(struct xilinx_spi *xspi, u32 offs, u16 val)
+{
+	if (xspi->big_endian)
+		iowrite16be(val, xspi->regs + offs + 2);
+	else
+		iowrite16(val, xspi->regs + offs);
+}

Hi Richard,

Quoted 3 lines

Hi John,

Thanks for the quick feedback.

No problem. I thought at 1st that the point of the new code was performance, but it sounds like you're trying to make sure the driver will work with a system that can be built in many different permutations.

Quoted 10 lines
Quoted 2 lines

If you're worried about efficiency (the reason for 16 and 32 bit xfers), why wouldn't you do the

big-endian vs little endian I/O decision at compile time rather than run time?

I'm afraid we can't do it compile time, if we want to be flexible. As example;
The IP is big endian, in our case the PCI interface flips the byte order. But the PCI interface might be setup differently ->would be accessed big endian even on a little endian machine.

Ok I see the flexibility requirements.

Quoted 93 lines

We could use callbacks set up during probe, instead of having the if-sentence. But I don't think the callback solution could be slower (if talking performance), since the compiler can't inline them, the current functions could be inlined if the compiler feels like it.

Quoted 1 line

The big_endian variable is not a constant boolean, I don't know if that could help so that the

compiler optimizes this check away? Or maybe it is already and I'm just missing that?

Quoted 85 lines
Quoted 21 lines
drivers/spi/Kconfig +11 -6
-	u32		irq;
+static inline void xspi_write32(struct xilinx_spi *xspi, u32 offs, u32 val)
+{
+	if (xspi->big_endian)
+		iowrite32be(val, xspi->regs + offs);
+	else
+		iowrite32(val, xspi->regs + offs);
+}
 
-	u32		speed_hz; /* SCK has a fixed frequency of speed_hz Hz */
+static inline u8 xspi_read8(struct xilinx_spi *xspi, u32 offs)
+{
+	return ioread8(xspi->regs + offs + ((xspi->big_endian) ? 3 : 0));
+}
 
-	u8 *rx_ptr;		/* pointer in the Tx buffer */
-	const u8 *tx_ptr;	/* pointer in the Rx buffer */
-	int remaining_bytes;	/* the number of bytes left to transfer */
-};

<snip>

Quoted 48 lines
drivers/spi/Kconfig +19 -8
-
 /* This driver supports single master mode only. Hence Tx FIFO Empty
  * is the only interrupt we care about.
  * Receive FIFO Overrun, Transmit FIFO Underrun, Mode Fault, and Slave Mode
@@ -237,32 +298,50 @@ static irqreturn_t xilinx_spi_irq(int irq, void *dev_id)
 	u32 ipif_isr;
 
 	/* Get the IPIF interrupts, and clear them immediately */
-	ipif_isr = in_be32(xspi->regs + XIPIF_V123B_IISR_OFFSET);
-	out_be32(xspi->regs + XIPIF_V123B_IISR_OFFSET, ipif_isr);
+	ipif_isr = xspi_read32(xspi, XIPIF_V123B_IISR_OFFSET);
+	xspi_write32(xspi, XIPIF_V123B_IISR_OFFSET, ipif_isr);
 
 	if (ipif_isr & XSPI_INTR_TX_EMPTY) {	/* Transmission completed */
 		u16 cr;
 		u8 sr;
+		u8 rsize;
+		if (xspi->bits_per_word == 8)
+			rsize = 1;
+		else if (xspi->bits_per_word == 16)
+			rsize = 2;
+		else
+			rsize = 4;
 
 		/* A transmit has just completed. Process received data and
 		 * check for more data to transmit. Always inhibit the
 		 * transmitter while the Isr refills the transmit register/FIFO,
 		 * or make sure it is stopped if we're done.
 		 */
-		cr = in_be16(xspi->regs + XSPI_CR_OFFSET);
-		out_be16(xspi->regs + XSPI_CR_OFFSET,
-			 cr | XSPI_CR_TRANS_INHIBIT);
+		cr = xspi_read16(xspi, XSPI_CR_OFFSET);
+		xspi_write16(xspi, XSPI_CR_OFFSET, cr | XSPI_CR_TRANS_INHIBIT);
 
 		/* Read out all the data from the Rx FIFO */
-		sr = in_8(xspi->regs + XSPI_SR_OFFSET);
+		sr = xspi_read8(xspi, XSPI_SR_OFFSET);
 		while ((sr & XSPI_SR_RX_EMPTY_MASK) == 0) {
-			u8 data;
+			u32 data;
+			if (rsize == 1)
+				data = xspi_read8(xspi, XSPI_RXD_OFFSET);
+			else if (rsize == 2)
+				data = xspi_read16(xspi, XSPI_RXD_OFFSET);
+			else
+				data = xspi_read32(xspi, XSPI_RXD_OFFSET);
 

drivers/spi/Kconfig static irqreturn_t xilinx_spi_irq(int irq, void *dev_id) · line 341

Quoted 10 lines
drivers/spi/Kconfig +7 -2
-			data = in_8(xspi->regs + XSPI_RXD_OFFSET);
 			if (xspi->rx_ptr) {
-				*xspi->rx_ptr++ = data;
+				if (rsize == 1)
+					*xspi->rx_ptr = data & 0xff;
+				else if (rsize == 2)
+					*(u16 *)(xspi->rx_ptr) = data & 0xffff;
+				else
+					*((u32 *)(xspi->rx_ptr)) = data;
+				xspi->rx_ptr += rsize;

Maybe I'm out of line here...

Quoted 7 lines
Quoted 1 line

I'm wondering if this is going to be any more efficient that just using 8 bit accesses

We can not do 8 bit accesses if the IP is set up to do 16/32bit SPI, then the TX/RX registers are as wide as the bit setup.

We could do 32 bit reads from the registers, then we waste some cycles on the PLB bus, but have slightly simpler code.

Looking at the IP spec, it looks like 32 bit operations to registers should work and that sounds like the right direction to go (32 bit only).

Doing 32 bit operations on the PLB, rather than 8 bit operations, won't waste any cycles on the bus as you're on the bus either way so it can't be used by any other device, it's just how many byte lanes are being used on the bus.

Quoted 8 lines
Quoted 2 lines

as it seems like the amount of run-time decisions being made is quite a few. I guess it depends on

how many bytes are being transferred as with big transfers maybe it will pay off.

Quoted 2 lines

In my opinion, which isn't worth much many times :), sometimes the flexibility with soft logic,

like this is a pain for testability and increases complexity. If there's reasonable performance gains then maybe it's a good tradeoff.

Quoted 1 line
Quoted 8 lines
Quoted 1 line

Do you know how much performance gain there is or is expected as maybe you've seen the pay off

already?

I haven't done any measurements, and we are basically only controlling GPIO so performance is not an issue for us. I just didn't want do make it slower. I think you have more experience here. Do you think it's better to just do 32bit reads to make the code simple? If so I will update the code.

Yes, 32 ops.

If you get a new driver that's ready, I can hopefully find some time to test it in our automated test with the SPI EEPROM.

Quoted 3 lines

Thanks
--Richard

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

#5 lore raw
In reply to a message not in the archive

Oops, I replied to the original version, but missed the subsequent versions. Looks like some of my comments still apply though. Overall, the patch changes too many things all at once. You should look at splitting it up. At the very least the io accessor changes should be done in a separate patch.

Quoted 9 lines · Richard Röjfors
(quoted diff) +0 -0
@@ -227,6 +227,21 @@ config SPI_XILINX

         See the "OPB Serial Peripheral Interface (SPI) (v1.00e)" Product Specification document (DS464) for hardware details.

+         Or for the DS570, see "XPS Serial Peripheral Interface (SPI) (v2.00b)"

drivers/spi/Kconfig +4 -0
+
+config SPI_XILINX_OF
+       tristate "Xilinx SPI controller OF device"
+       depends on SPI_XILINX && XILINX_VIRTEX

drivers/spi/Kconfig config SPI_XILINX · line 244

Quoted 10 lines
drivers/spi/Kconfig +10 -0
+       help
+         This is the OF driver for the SPI controller IP from the Xilinx EDK.
+
+config SPI_XILINX_PLTFM
+       tristate "Xilinx SPI controller platform device"
+       depends on SPI_XILINX
+       help
+         This is the platform driver for the SPI controller IP
+         from the Xilinx EDK.
+

Personally, I don't think it is necessary to present these options to the user. I think they can be auto-selected depending on CONFIG_OF and CONFIG_PLATFORM.

Quoted 7 lines
drivers/spi/xilinx_spi.c +7 -0
+struct xilinx_spi {
+       /* bitbang has to be first */
+       struct spi_bitbang bitbang;
+       struct completion done;
+       struct resource mem; /* phys mem */
+       void __iomem    *regs;  /* virt. address of the control registers */
+       u32 irq;

drivers/spi/xilinx_spi.c line 40

Quoted 10 lines
drivers/spi/xilinx_spi.c +10 -0
+       u8 *rx_ptr;             /* pointer in the Tx buffer */
+       const u8 *tx_ptr;       /* pointer in the Rx buffer */
+       int remaining_bytes;    /* the number of bytes left to transfer */
+       /* offset to the XSPI regs, these might vary... */
+       u8 bits_per_word;
+       bool big_endian;        /* The device could be accessed big or little
+                                * endian
+                                */
+};
+

Why is the definition of xilinx_spi moved?

Quoted 84 lines

 /* Register definitions as per "OPB Serial Peripheral Interface (SPI) (v1.00e)
 * Product Specification", DS464
 */

drivers/spi/xilinx_spi.c +1 -1
-#define XSPI_CR_OFFSET         0x62    /* 16-bit Control Register */
+#define XSPI_CR_OFFSET         0x60    /* Control Register */

 #define XSPI_CR_ENABLE         0x02
 #define XSPI_CR_MASTER_MODE    0x04

drivers/spi/xilinx_spi.c +35 -14
@@ -40,8 +53,9 @@
  #define XSPI_CR_RXFIFO_RESET   0x40
  #define XSPI_CR_MANUAL_SSELECT 0x80
  #define XSPI_CR_TRANS_INHIBIT  0x100
+#define XSPI_CR_LSB_FIRST      0x200
 
-#define XSPI_SR_OFFSET         0x67    /* 8-bit Status Register */
+#define XSPI_SR_OFFSET         0x64    /* Status Register */
 
  #define XSPI_SR_RX_EMPTY_MASK  0x01    /* Receive FIFO is empty */
  #define XSPI_SR_RX_FULL_MASK   0x02    /* Receive FIFO is full */
@@ -49,8 +63,8 @@
  #define XSPI_SR_TX_FULL_MASK   0x08    /* Transmit FIFO is full */
  #define XSPI_SR_MODE_FAULT_MASK        0x10    /* Mode fault error */
 
-#define XSPI_TXD_OFFSET                0x6b    /* 8-bit Data Transmit Register */
-#define XSPI_RXD_OFFSET                0x6f    /* 8-bit Data Receive Register */
+#define XSPI_TXD_OFFSET                0x68    /* Data Transmit Register */
+#define XSPI_RXD_OFFSET                0x6C    /* Data Receive Register */
 
  #define XSPI_SSR_OFFSET                0x70    /* 32-bit Slave Select Register */
 
@@ -70,43 +84,72 @@
  #define XSPI_INTR_TX_UNDERRUN          0x08    /* TxFIFO was underrun */
  #define XSPI_INTR_RX_FULL              0x10    /* RxFIFO is full */
  #define XSPI_INTR_RX_OVERRUN           0x20    /* RxFIFO was overrun */
+#define XSPI_INTR_TX_HALF_EMPTY                0x40    /* TxFIFO is half empty */
 
  #define XIPIF_V123B_RESETR_OFFSET      0x40    /* IPIF reset register */
  #define XIPIF_V123B_RESET_MASK         0x0a    /* the value to write */
 
-struct xilinx_spi {
-       /* bitbang has to be first */
-       struct spi_bitbang bitbang;
-       struct completion done;
+/* to follow are some functions that does little of big endian read and
+ * write depending on the config of the device.
+ */
+static inline void xspi_write8(struct xilinx_spi *xspi, u32 offs, u8 val)
+{
+       iowrite8(val, xspi->regs + offs + ((xspi->big_endian) ? 3 : 0));
+}
 
-       void __iomem    *regs;  /* virt. address of the control registers */
+static inline void xspi_write16(struct xilinx_spi *xspi, u32 offs, u16 val)
+{
+       if (xspi->big_endian)
+               iowrite16be(val, xspi->regs + offs + 2);
+       else
+               iowrite16(val, xspi->regs + offs);
+}
 
-       u32             irq;
+static inline void xspi_write32(struct xilinx_spi *xspi, u32 offs, u32 val)
+{
+       if (xspi->big_endian)
+               iowrite32be(val, xspi->regs + offs);
+       else
+               iowrite32(val, xspi->regs + offs);
+}
 
-       u32             speed_hz; /* SCK has a fixed frequency of speed_hz Hz */
+static inline u8 xspi_read8(struct xilinx_spi *xspi, u32 offs)
+{
+       return ioread8(xspi->regs + offs + ((xspi->big_endian) ? 3 : 0));
+}
 
-       u8 *rx_ptr;             /* pointer in the Tx buffer */
-       const u8 *tx_ptr;       /* pointer in the Rx buffer */
-       int remaining_bytes;    /* the number of bytes left to transfer */
-};
+static inline u16 xspi_read16(struct xilinx_spi *xspi, u32 offs)
+{
+       if (xspi->big_endian)
+               return ioread16be(xspi->regs + offs + 2);
+       else

drivers/spi/xilinx_spi.c line 135

Quoted 10 lines
drivers/spi/xilinx_spi.c +10 -0
+               return ioread16(xspi->regs + offs);
+}
+
+static inline u32 xspi_read32(struct xilinx_spi *xspi, u32 offs)
+{
+       if (xspi->big_endian)
+               return ioread32be(xspi->regs + offs);
+       else
+               return ioread32(xspi->regs + offs);
+}

Ah, you changed these to functions instead of macros. I like. However, as you suggested elsewhere in this thread, you could change these to callbacks and then eliminate the if/else statements. I think that is the approach you should use. I don't think you need to worry about it being slower. Any extra cycles for jumping to a callback will be far dwarfed by the number of cycles it takes to complete an SPI transfer.

g.

Signature · 8 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
#6 lore raw
Quoted 35 lines

-----Original Message-----
From: [email protected] [mailto:linuxppc-dev- [email protected]] On Behalf Of Grant Likely
Sent: Monday, November 09, 2009 1:22 PM
To: Richard Röjfors
Cc: [email protected]; Andrew Morton; [email protected]; John Linn; [email protected]
Subject: Re: [spi-devel-general] [PATCH v4] xilinx_spi: Splitted into generic, of and platform driver, added support for DS570

Oops, I replied to the original version, but missed the subsequent versions. Looks like some of my comments still apply though. Overall, the patch changes too many things all at once. You should look at splitting it up. At the very least the io accessor changes should be done in a separate patch.

Quoted 15 lines · Richard Röjfors
(quoted diff) +0 -0
@@ -227,6 +227,21 @@ config SPI_XILINX

         See the "OPB Serial Peripheral Interface (SPI) (v1.00e)" Product Specification document (DS464) for hardware details.

+         Or for the DS570, see "XPS Serial Peripheral Interface (SPI) (v2.00b)"

drivers/spi/Kconfig +10 -0
+
+config SPI_XILINX_OF
+       tristate "Xilinx SPI controller OF device"
+       depends on SPI_XILINX && XILINX_VIRTEX
+       help
+         This is the OF driver for the SPI controller IP from the Xilinx EDK.
+
+config SPI_XILINX_PLTFM
+       tristate "Xilinx SPI controller platform device"
+       depends on SPI_XILINX
Quoted 8 lines
Quoted 4 lines

+       help
+         This is the platform driver for the SPI controller IP
+         from the Xilinx EDK.
+

Personally, I don't think it is necessary to present these options to the user. I think they can be auto-selected depending on CONFIG_OF and CONFIG_PLATFORM.

And in any event, OF should work for MICROBLAZE, too...

Steve

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

#8 lore raw
In reply to a message not in the archive
Quoted 23 lines · Grant Likely

Oops, I replied to the original version, but missed the subsequent versions. Looks like some of my comments still apply though. Overall, the patch changes too many things all at once. You should look at splitting it up. At the very least the io accessor changes should be done in a separate patch.

Quoted 15 lines · Richard Röjfors
drivers/spi/Kconfig +11 -0
@@ -227,6 +227,21 @@ config SPI_XILINX
         See the "OPB Serial Peripheral Interface (SPI) (v1.00e)"
         Product Specification document (DS464) for hardware details.
 
+         Or for the DS570, see "XPS Serial Peripheral Interface (SPI) (v2.00b)"
+
+config SPI_XILINX_OF
+       tristate "Xilinx SPI controller OF device"
+       depends on SPI_XILINX && XILINX_VIRTEX
+       help
+         This is the OF driver for the SPI controller IP from the Xilinx EDK.
+
+config SPI_XILINX_PLTFM
+       tristate "Xilinx SPI controller platform device"
+       depends on SPI_XILINX
Quoted 8 lines

drivers/spi/Kconfig config SPI_XILINX · line 244

Quoted 4 lines
drivers/spi/Kconfig +4 -0
+       help
+         This is the platform driver for the SPI controller IP
+         from the Xilinx EDK.
+

Personally, I don't think it is necessary to present these options to the user. I think they can be auto-selected depending on CONFIG_OF and CONFIG_PLATFORM.

Sure that can be changed, I prefer to to that in an incremental patch after this one.

Quoted 12 lines
Quoted 12 lines
drivers/spi/xilinx_spi.c +11 -0
+struct xilinx_spi {
+       /* bitbang has to be first */
+       struct spi_bitbang bitbang;
+       struct completion done;
+       struct resource mem; /* phys mem */
+       void __iomem    *regs;  /* virt. address of the control registers */
+       u32 irq;
+       u8 *rx_ptr;             /* pointer in the Tx buffer */
+       const u8 *tx_ptr;       /* pointer in the Rx buffer */
+       int remaining_bytes;    /* the number of bytes left to transfer */
+       /* offset to the XSPI regs, these might vary... */
Quoted 8 lines

drivers/spi/xilinx_spi.c line 40

Quoted 6 lines
drivers/spi/xilinx_spi.c +6 -0
+       u8 bits_per_word;
+       bool big_endian;        /* The device could be accessed big or little
+                                * endian
+                                */
+};
+

Why is the definition of xilinx_spi moved?

I liked the idea of heaving the struct defined in the top of the file.

Quoted 95 lines
Quoted 84 lines

/* Register definitions as per "OPB Serial Peripheral Interface (SPI) (v1.00e)
* Product Specification", DS464
*/

drivers/spi/xilinx_spi.c +36 -15
-#define XSPI_CR_OFFSET         0x62    /* 16-bit Control Register */
+#define XSPI_CR_OFFSET         0x60    /* Control Register */
 
 #define XSPI_CR_ENABLE         0x02
 #define XSPI_CR_MASTER_MODE    0x04
@@ -40,8 +53,9 @@
 #define XSPI_CR_RXFIFO_RESET   0x40
 #define XSPI_CR_MANUAL_SSELECT 0x80
 #define XSPI_CR_TRANS_INHIBIT  0x100
+#define XSPI_CR_LSB_FIRST      0x200
 
-#define XSPI_SR_OFFSET         0x67    /* 8-bit Status Register */
+#define XSPI_SR_OFFSET         0x64    /* Status Register */
 
 #define XSPI_SR_RX_EMPTY_MASK  0x01    /* Receive FIFO is empty */
 #define XSPI_SR_RX_FULL_MASK   0x02    /* Receive FIFO is full */
@@ -49,8 +63,8 @@
 #define XSPI_SR_TX_FULL_MASK   0x08    /* Transmit FIFO is full */
 #define XSPI_SR_MODE_FAULT_MASK        0x10    /* Mode fault error */
 
-#define XSPI_TXD_OFFSET                0x6b    /* 8-bit Data Transmit Register */
-#define XSPI_RXD_OFFSET                0x6f    /* 8-bit Data Receive Register */
+#define XSPI_TXD_OFFSET                0x68    /* Data Transmit Register */
+#define XSPI_RXD_OFFSET                0x6C    /* Data Receive Register */
 
 #define XSPI_SSR_OFFSET                0x70    /* 32-bit Slave Select Register */
 
@@ -70,43 +84,72 @@
 #define XSPI_INTR_TX_UNDERRUN          0x08    /* TxFIFO was underrun */
 #define XSPI_INTR_RX_FULL              0x10    /* RxFIFO is full */
 #define XSPI_INTR_RX_OVERRUN           0x20    /* RxFIFO was overrun */
+#define XSPI_INTR_TX_HALF_EMPTY                0x40    /* TxFIFO is half empty */
 
 #define XIPIF_V123B_RESETR_OFFSET      0x40    /* IPIF reset register */
 #define XIPIF_V123B_RESET_MASK         0x0a    /* the value to write */
 
-struct xilinx_spi {
-       /* bitbang has to be first */
-       struct spi_bitbang bitbang;
-       struct completion done;
+/* to follow are some functions that does little of big endian read and
+ * write depending on the config of the device.
+ */
+static inline void xspi_write8(struct xilinx_spi *xspi, u32 offs, u8 val)
+{
+       iowrite8(val, xspi->regs + offs + ((xspi->big_endian) ? 3 : 0));
+}
 
-       void __iomem    *regs;  /* virt. address of the control registers */
+static inline void xspi_write16(struct xilinx_spi *xspi, u32 offs, u16 val)
+{
+       if (xspi->big_endian)
+               iowrite16be(val, xspi->regs + offs + 2);
+       else
+               iowrite16(val, xspi->regs + offs);
+}
 
-       u32             irq;
+static inline void xspi_write32(struct xilinx_spi *xspi, u32 offs, u32 val)
+{
+       if (xspi->big_endian)
+               iowrite32be(val, xspi->regs + offs);
+       else
+               iowrite32(val, xspi->regs + offs);
+}
 
-       u32             speed_hz; /* SCK has a fixed frequency of speed_hz Hz */
+static inline u8 xspi_read8(struct xilinx_spi *xspi, u32 offs)
+{
+       return ioread8(xspi->regs + offs + ((xspi->big_endian) ? 3 : 0));
+}
 
-       u8 *rx_ptr;             /* pointer in the Tx buffer */
-       const u8 *tx_ptr;       /* pointer in the Rx buffer */
-       int remaining_bytes;    /* the number of bytes left to transfer */
-};
+static inline u16 xspi_read16(struct xilinx_spi *xspi, u32 offs)
+{
+       if (xspi->big_endian)
+               return ioread16be(xspi->regs + offs + 2);
+       else

drivers/spi/xilinx_spi.c line 135

Quoted 10 lines
drivers/spi/xilinx_spi.c +10 -0
+               return ioread16(xspi->regs + offs);
+}
+
+static inline u32 xspi_read32(struct xilinx_spi *xspi, u32 offs)
+{
+       if (xspi->big_endian)
+               return ioread32be(xspi->regs + offs);
+       else
+               return ioread32(xspi->regs + offs);
+}
Quoted 7 lines

Ah, you changed these to functions instead of macros. I like. However, as you suggested elsewhere in this thread, you could change these to callbacks and then eliminate the if/else statements. I think that is the approach you should use. I don't think you need to worry about it being slower. Any extra cycles for jumping to a callback will be far dwarfed by the number of cycles it takes to complete an SPI transfer.

Sure that can be updated. I prefer to do that in an incremental patch, would be great to get this big one merged first.

--Richard

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july

#10 lore raw
In reply to a message not in the archive
Quoted 6 lines · Richard Röjfors
Quoted 5 lines · Grant Likely

Oops, I replied to the original version, but missed the subsequent versions.  Looks like some of my comments still apply though. Overall, the patch changes too many things all at once.  You should look at splitting it up.  At the very least the io accessor changes should be done in a separate patch.

Hi Richard. Please do another spin of this patch. I don't have any particular problem with the changes, but it needs to be in a more granular form so I can review it properly.

Quoted 20 lines
Quoted 11 lines
Quoted 11 lines

+struct xilinx_spi {
+       /* bitbang has to be first */
+       struct spi_bitbang bitbang;
+       struct completion done;
+       struct resource mem; /* phys mem */
+       void __iomem    *regs;  /* virt. address of the control registers */
+       u32 irq;
+       u8 *rx_ptr;             /* pointer in the Tx buffer */
+       const u8 *tx_ptr;       /* pointer in the Rx buffer */
+       int remaining_bytes;    /* the number of bytes left to transfer */
+       /* offset to the XSPI regs, these might vary... */

Quoted 8 lines

Review

Quoted 6 lines

+       u8 bits_per_word;
+       bool big_endian;        /* The device could be accessed big or little
+                                * endian
+                                */

(quoted diff) +2 -0
+};
+

Why is the definition of xilinx_spi moved?

Quoted 1 line

I liked the idea of heaving the struct defined in the top of the file.

... which is completely unrelated to the patch purpose, and is not mentioned in the patch header. If you really want to move it then put it in a completely separate patch and describe the change properly. As it is right now it is just noise that makes the stated purpose of the patch hard to review.

Quoted 10 lines
Quoted 7 lines

Ah, you changed these to functions instead of macros.  I like. However, as you suggested elsewhere in this thread, you could change these to callbacks and then eliminate the if/else statements.  I think that is the approach you should use.  I don't think you need to worry about it being slower.  Any extra cycles for jumping to a callback will be far dwarfed by the number of cycles it takes to complete an SPI transfer.

Sure that can be updated. I prefer to do that in an incremental patch, would be great to get this big one merged first.

As already commented on, this patch is too big and does too many unrelated things. Please split into discrete changes so it can be reviewed properly.

Thanks,
g.

Signature · 8 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
#12 lore raw
In reply to a message not in the archive
Quoted 18 lines

-----Original Message-----
From: glikely-s3s/[email protected] [mailto:glikely-s3s/[email protected]] On Behalf Of Grant Likely
Sent: Tuesday, November 10, 2009 9:45 AM
To: Richard Röjfors
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org; [email protected]; Andrew Morton; [email protected]; John Linn
Subject: Re: [spi-devel-general] [PATCH v4] xilinx_spi: Splitted into generic, of and platform
driver, added support for DS570

Quoted 6 lines · Richard Röjfors
Quoted 5 lines · Grant Likely

Oops, I replied to the original version, but missed the subsequent versions.  Looks like some of my comments still apply though. Overall, the patch changes too many things all at once.  You should look at splitting it up.  At the very least the io accessor changes should be done in a separate patch.

Quoted 3 lines

Hi Richard. Please do another spin of this patch. I don't have any particular problem with the changes, but it needs to be in a more granular form so I can review it properly.

I agree.

We have a functioning driver such that I need to make sure it doesn't regress. More granular changes will also allow us to better isolate any problems if they occur.

Thanks,
John

Quoted 44 lines
Quoted 21 lines
Quoted 12 lines
Quoted 12 lines

+struct xilinx_spi {
+       /* bitbang has to be first */
+       struct spi_bitbang bitbang;
+       struct completion done;
+       struct resource mem; /* phys mem */
+       void __iomem    *regs;  /* virt. address of the control registers */
+       u32 irq;
+       u8 *rx_ptr;             /* pointer in the Tx buffer */
+       const u8 *tx_ptr;       /* pointer in the Rx buffer */
+       int remaining_bytes;    /* the number of bytes left to transfer */
+       /* offset to the XSPI regs, these might vary... */

Quoted 8 lines

Review

Quoted 6 lines

+       u8 bits_per_word;
+       bool big_endian;        /* The device could be accessed big or little
+                                * endian
+                                */

(quoted diff) +2 -0
+};
+

Why is the definition of xilinx_spi moved?

Quoted 1 line

I liked the idea of heaving the struct defined in the top of the file.

... which is completely unrelated to the patch purpose, and is not mentioned in the patch header. If you really want to move it then put it in a completely separate patch and describe the change properly. As it is right now it is just noise that makes the stated purpose of the patch hard to review.

Quoted 10 lines
Quoted 7 lines

Ah, you changed these to functions instead of macros.  I like. However, as you suggested elsewhere in this thread, you could change these to callbacks and then eliminate the if/else statements.  I think that is the approach you should use.  I don't think you need to worry about it being slower.  Any extra cycles for jumping to a callback will be far dwarfed by the number of cycles it takes to complete an SPI transfer.

Sure that can be updated. I prefer to do that in an incremental patch, would be great to get this big one merged first.

As already commented on, this patch is too big and does too many unrelated things. Please split into discrete changes so it can be reviewed properly.

Quoted 6 lines

Thanks,
g.

--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july

#13 lore raw
In reply to Grant Likely
Quoted 4 lines · Grant Likely

Hi Richard. Please do another spin of this patch. I don't have any particular problem with the changes, but it needs to be in a more granular form so I can review it properly.

I will post an update today.

In the future, if you are "quasi responsible for everything Xilinx", please reply earlier to patches on drivers for your IP:s.

--Richard