Skip to contentSkip to conversation

spi: kirkwood_spi: implement mvebu_spi_set_mode()

PATCH Superseded Chris Packham 3 participants 8 messages Oct 14, 2016 – Oct 27, 2016

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

PATCH 1/1 spi: kirkwood_spi: implement mvebu_spi_set_mode()

Set the appropriate bits in the interface config register based on the SPI_ mode flags.

---

 arch/arm/include/asm/arch-mvebu/spi.h |  4 ++++
 drivers/spi/kirkwood_spi.c            | 13 +++++++++++++
 2 files changed, 17 insertions(+)
arch/arm/include/asm/arch-mvebu/spi.h +4 -0
index 78869a253d1f..3545aed17347 100644
@@ -52,6 +52,10 @@ struct kwspi_registers {
 #define KWSPI_ADRLEN_3BYTE	(2 << 8)
 #define KWSPI_ADRLEN_4BYTE	(3 << 8)
 #define KWSPI_ADRLEN_MASK	(3 << 8)
+#define KWSPI_CPOL		(1 << 11)
+#define KWSPI_CPHA		(1 << 12)
+#define KWSPI_TXLSBF		(1 << 13)
+#define KWSPI_RXLSBF		(1 << 14)
 
 #define KWSPI_IRQUNMASK		1 /* unmask SPI interrupt */
 #define KWSPI_IRQMASK		0 /* mask SPI interrupt */
drivers/spi/kirkwood_spi.c +13 -0
index 6851ba942f51..69a0be9ea5b2 100644
@@ -271,6 +271,19 @@ static int mvebu_spi_set_speed(struct udevice *bus, uint hz)
 
 static int mvebu_spi_set_mode(struct udevice *bus, uint mode)
 {
+	struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
+	struct kwspi_registers *reg = plat->spireg;
+	u32 data = readl(&reg->cfg);
+
+	if (mode & SPI_CPHA)
+		data |= KWSPI_CPHA;
+	if (mode & SPI_CPOL)
+		data |= KWSPI_CPOL;
+	if (mode & SPI_LSB_FIRST)
+		data |= (KWSPI_RXLSBF | KWSPI_TXLSBF);
+
+	writel(data, &reg->cfg);
+
 	return 0;
 }
 
Signature · 1 line
2.10.0.479.g7c56b16
#2 lore raw

PATCH 1/1 spi: kirkwood_spi: implement mvebu_spi_set_mode()

In reply to Chris Packham
Quoted 30 lines · Chris Packham

Set the appropriate bits in the interface config register based on the SPI_ mode flags.

---

 arch/arm/include/asm/arch-mvebu/spi.h |  4 ++++
 drivers/spi/kirkwood_spi.c            | 13 +++++++++++++
 2 files changed, 17 insertions(+)
arch/arm/include/asm/arch-mvebu/spi.h +4 -0
index 78869a253d1f..3545aed17347 100644
@@ -52,6 +52,10 @@ struct kwspi_registers {
 #define KWSPI_ADRLEN_3BYTE     (2 << 8)
 #define KWSPI_ADRLEN_4BYTE     (3 << 8)
 #define KWSPI_ADRLEN_MASK      (3 << 8)
+#define KWSPI_CPOL             (1 << 11)
+#define KWSPI_CPHA             (1 << 12)
+#define KWSPI_TXLSBF           (1 << 13)
+#define KWSPI_RXLSBF           (1 << 14)
 
 #define KWSPI_IRQUNMASK                1 /* unmask SPI interrupt */
 #define KWSPI_IRQMASK          0 /* mask SPI interrupt */
drivers/spi/kirkwood_spi.c +0 -0
index 6851ba942f51..69a0be9ea5b2 100644

drivers/spi/kirkwood_spi.c static int mvebu_spi_set_speed(struct udevice *bus, uint hz) · line 276

Quoted 6 lines
drivers/spi/kirkwood_spi.c +3 -0
@@ -271,6 +271,19 @@ static int mvebu_spi_set_speed(struct udevice *bus, uint hz)
 
 static int mvebu_spi_set_mode(struct udevice *bus, uint mode)
 {
+       struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
+       struct kwspi_registers *reg = plat->spireg;
+       u32 data = readl(&reg->cfg);

Better to clear the bits(mask) on data before updating,

thanks!

Signature · 4 lines
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.
#3 lore raw

PATCH v2 1/1 spi: kirkwood_spi: implement mvebu_spi_set_mode()

Set the appropriate bits in the interface config register based on the SPI_ mode flags.

---

Changes in v2:
- Clear bits before updating

 arch/arm/include/asm/arch-mvebu/spi.h |  4 ++++
 drivers/spi/kirkwood_spi.c            | 15 +++++++++++++++
 2 files changed, 19 insertions(+)
arch/arm/include/asm/arch-mvebu/spi.h +4 -0
index 78869a253d1f..3545aed17347 100644
@@ -52,6 +52,10 @@ struct kwspi_registers {
 #define KWSPI_ADRLEN_3BYTE	(2 << 8)
 #define KWSPI_ADRLEN_4BYTE	(3 << 8)
 #define KWSPI_ADRLEN_MASK	(3 << 8)
+#define KWSPI_CPOL		(1 << 11)
+#define KWSPI_CPHA		(1 << 12)
+#define KWSPI_TXLSBF		(1 << 13)
+#define KWSPI_RXLSBF		(1 << 14)
 
 #define KWSPI_IRQUNMASK		1 /* unmask SPI interrupt */
 #define KWSPI_IRQMASK		0 /* mask SPI interrupt */
drivers/spi/kirkwood_spi.c +15 -0
index 6851ba942f51..791f3e8099c8 100644
@@ -271,6 +271,21 @@ static int mvebu_spi_set_speed(struct udevice *bus, uint hz)
 
 static int mvebu_spi_set_mode(struct udevice *bus, uint mode)
 {
+	struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
+	struct kwspi_registers *reg = plat->spireg;
+	u32 data = readl(&reg->cfg);
+
+	data &= ~(KWSPI_CPHA | KWSPI_CPOL | KWSPI_RXLSBF | KWSPI_TXLSBF);
+
+	if (mode & SPI_CPHA)
+		data |= KWSPI_CPHA;
+	if (mode & SPI_CPOL)
+		data |= KWSPI_CPOL;
+	if (mode & SPI_LSB_FIRST)
+		data |= (KWSPI_RXLSBF | KWSPI_TXLSBF);
+
+	writel(data, &reg->cfg);
+
 	return 0;
 }
 
Signature · 1 line
2.10.1
Applied
#4 lore raw

PATCH v2 1/1 spi: kirkwood_spi: implement mvebu_spi_set_mode()

Quoted 4 lines · Chris Packham

Set the appropriate bits in the interface config register based on the SPI_ mode flags.

Missed updating Stefan Reviewed-by tag? please check for next time.

Quoted 4 lines

---

Changes in v2:
- Clear bits before updating

Applied, thanks!

Signature · 4 lines
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.
#5 lore raw

PATCH v2 1/1 spi: kirkwood_spi: implement mvebu_spi_set_mode()

Quoted 2 lines · Jagan Teki

On Thu, Oct 27, 2016 at 1:46 PM, Chris Packham <[email protected]>

Quoted 6 lines · wrote:
Quoted 4 lines

Set the appropriate bits in the interface config register based on the SPI_ mode flags.

Missed updating Stefan Reviewed-by tag? please check for next time.

That was semi-intentional. I thought v2 was different enough that I didn't want to assume Stefan's review would carry through.

Quoted 13 lines
Quoted 5 lines

---

Changes in v2:
- Clear bits before updating

Applied, thanks!

--
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.

#6 lore raw

PATCH v2 1/1 spi: kirkwood_spi: implement mvebu_spi_set_mode()

Quoted 8 lines · Chris Packham
Quoted 2 lines · On 27/10/2016 10:41 PM, "Jagan Teki" <[email protected]…

On Thu, Oct 27, 2016 at 1:46 PM, Chris Packham

Quoted 3 lines · <judge.packham at gmail.com <mailto:[email protected]>> wrote:
Quoted 3 lines

Set the appropriate bits in the interface config register based on the SPI_ mode flags.

Quoted 7 lines
Quoted 1 line
Quoted 1 line

<mailto:[email protected]>>

Quoted 2 lines

Missed updating Stefan Reviewed-by tag? please check for next time.

That was semi-intentional. I thought v2 was different enough that I didn't want to assume Stefan's review would carry through.

Fair enough. I've overlooked the clearing of the bits spotted by Jagan. Please add my Reviewed-by now as well.

Thanks,
Stefan

#7 lore raw

PATCH v2 1/1 spi: kirkwood_spi: implement mvebu_spi_set_mode()

Quoted 21 lines · Stefan Roese
Quoted 20 lines · Chris Packham
Quoted 3 lines · On 27/10/2016 10:41 PM, "Jagan Teki" <[email protected]…

On Thu, Oct 27, 2016 at 1:46 PM, Chris Packham

Quoted 5 lines · <judge.packham at gmail.com <mailto:[email protected]>> wrote:
Quoted 5 lines

Set the appropriate bits in the interface config register based on the SPI_ mode flags.

<mailto:[email protected]>>

Quoted 3 lines

Missed updating Stefan Reviewed-by tag? please check for next time.

Quoted 6 lines
Quoted 2 lines

That was semi-intentional. I thought v2 was different enough that I didn't want to assume Stefan's review would carry through.

Fair enough. I've overlooked the clearing of the bits spotted by Jagan. Please add my Reviewed-by now as well.

Yeah, added and applied!

Signature · 4 lines
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.