Skip to contentSkip to conversation

spi: altera: Use struct-based register access

PATCH In review Marek Vasut 5 participants 13 messages Oct 22, 2014 – Nov 7, 2014 SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/7 spi: altera: Use struct-based register access

Zap the offset-based register access and use the struct-based one as this is the preferred method.

No functional change, but there are some line-over-80 problems in the driver, which will be addressed later.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Jagannadha Sutradharudu Teki <[email protected]>
---
 drivers/spi/altera_spi.c | 49 ++++++++++++++++++++++++------------------------
 1 file changed, 25 insertions(+), 24 deletions(-)
drivers/spi/altera_spi.c +25 -24
index 5accbb5..13191f3 100644
@@ -12,11 +12,14 @@
 #include <malloc.h>
 #include <spi.h>
 
-#define ALTERA_SPI_RXDATA	0
-#define ALTERA_SPI_TXDATA	4
-#define ALTERA_SPI_STATUS	8
-#define ALTERA_SPI_CONTROL	12
-#define ALTERA_SPI_SLAVE_SEL	20
+struct altera_spi_regs {
+	u32	rxdata;
+	u32	txdata;
+	u32	status;
+	u32	control;
+	u32	_reserved;
+	u32	slave_sel;
+};
 
 #define ALTERA_SPI_STATUS_ROE_MSK	(0x8)
 #define ALTERA_SPI_STATUS_TOE_MSK	(0x10)
@@ -39,8 +42,8 @@
 static ulong altera_spi_base_list[] = CONFIG_SYS_ALTERA_SPI_LIST;
 
 struct altera_spi_slave {
-	struct spi_slave slave;
-	ulong base;
+	struct spi_slave	slave;
+	struct altera_spi_regs	*regs;
 };
 #define to_altera_spi_slave(s) container_of(s, struct altera_spi_slave, slave)
 
@@ -54,16 +57,16 @@ __attribute__((weak))
 void spi_cs_activate(struct spi_slave *slave)
 {
 	struct altera_spi_slave *altspi = to_altera_spi_slave(slave);
-	writel(1 << slave->cs, altspi->base + ALTERA_SPI_SLAVE_SEL);
-	writel(ALTERA_SPI_CONTROL_SSO_MSK, altspi->base + ALTERA_SPI_CONTROL);
+	writel(1 << slave->cs, &altspi->regs->slave_sel);
+	writel(ALTERA_SPI_CONTROL_SSO_MSK, &altspi->regs->control);
 }
 
 __attribute__((weak))
 void spi_cs_deactivate(struct spi_slave *slave)
 {
 	struct altera_spi_slave *altspi = to_altera_spi_slave(slave);
-	writel(0, altspi->base + ALTERA_SPI_CONTROL);
-	writel(0, altspi->base + ALTERA_SPI_SLAVE_SEL);
+	writel(0, &altspi->regs->control);
+	writel(0, &altspi->regs->slave_sel);
 }
 
 void spi_init(void)
@@ -87,9 +90,9 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 	if (!altspi)
 		return NULL;
 
-	altspi->base = altera_spi_base_list[bus];
-	debug("%s: bus:%i cs:%i base:%lx\n", __func__,
-		bus, cs, altspi->base);
+	altspi->regs = (struct altera_spi_regs *)altera_spi_base_list[bus];
+	debug("%s: bus:%i cs:%i base:%p\n", __func__,
+		bus, cs, altspi->regs);
 
 	return &altspi->slave;
 }
@@ -105,8 +108,8 @@ int spi_claim_bus(struct spi_slave *slave)
 	struct altera_spi_slave *altspi = to_altera_spi_slave(slave);
 
 	debug("%s: bus:%i cs:%i\n", __func__, slave->bus, slave->cs);
-	writel(0, altspi->base + ALTERA_SPI_CONTROL);
-	writel(0, altspi->base + ALTERA_SPI_SLAVE_SEL);
+	writel(0, &altspi->regs->control);
+	writel(0, &altspi->regs->slave_sel);
 	return 0;
 }
 
@@ -115,7 +118,7 @@ void spi_release_bus(struct spi_slave *slave)
 	struct altera_spi_slave *altspi = to_altera_spi_slave(slave);
 
 	debug("%s: bus:%i cs:%i\n", __func__, slave->bus, slave->cs);
-	writel(0, altspi->base + ALTERA_SPI_SLAVE_SEL);
+	writel(0, &altspi->regs->slave_sel);
 }
 
 #ifndef CONFIG_ALTERA_SPI_IDLE_VAL
@@ -142,20 +145,18 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
 	}
 
 	/* empty read buffer */
-	if (readl(altspi->base + ALTERA_SPI_STATUS) &
-	    ALTERA_SPI_STATUS_RRDY_MSK)
-		readl(altspi->base + ALTERA_SPI_RXDATA);
+	if (readl(&altspi->regs->status) & ALTERA_SPI_STATUS_RRDY_MSK)
+		readl(&altspi->regs->rxdata);
 	if (flags & SPI_XFER_BEGIN)
 		spi_cs_activate(slave);
 
 	while (bytes--) {
 		uchar d = txp ? *txp++ : CONFIG_ALTERA_SPI_IDLE_VAL;
 		debug("%s: tx:%x ", __func__, d);
-		writel(d, altspi->base + ALTERA_SPI_TXDATA);
-		while (!(readl(altspi->base + ALTERA_SPI_STATUS) &
-			 ALTERA_SPI_STATUS_RRDY_MSK))
+		writel(d, &altspi->regs->txdata);
+		while (!(readl(&altspi->regs->status) & ALTERA_SPI_STATUS_RRDY_MSK))
 			;
-		d = readl(altspi->base + ALTERA_SPI_RXDATA);
+		d = readl(&altspi->regs->rxdata);
 		if (rxp)
 			*rxp++ = d;
 		debug("rx:%x\n", d);
Signature · 1 line
2.0.0
#1 lore raw

PATCH 2/7 spi: altera: Clean up bit definitions

Clean up the definitions of bits in the Altera SPI driver, there is no need to put braces around numbers afterall. No functional change.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Jagannadha Sutradharudu Teki <[email protected]>
---
 drivers/spi/altera_spi.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/spi/altera_spi.c +13 -13
index 13191f3..21f90fc 100644
@@ -21,19 +21,19 @@ struct altera_spi_regs {
 	u32	slave_sel;
 };
 
-#define ALTERA_SPI_STATUS_ROE_MSK	(0x8)
-#define ALTERA_SPI_STATUS_TOE_MSK	(0x10)
-#define ALTERA_SPI_STATUS_TMT_MSK	(0x20)
-#define ALTERA_SPI_STATUS_TRDY_MSK	(0x40)
-#define ALTERA_SPI_STATUS_RRDY_MSK	(0x80)
-#define ALTERA_SPI_STATUS_E_MSK	(0x100)
-
-#define ALTERA_SPI_CONTROL_IROE_MSK	(0x8)
-#define ALTERA_SPI_CONTROL_ITOE_MSK	(0x10)
-#define ALTERA_SPI_CONTROL_ITRDY_MSK	(0x40)
-#define ALTERA_SPI_CONTROL_IRRDY_MSK	(0x80)
-#define ALTERA_SPI_CONTROL_IE_MSK	(0x100)
-#define ALTERA_SPI_CONTROL_SSO_MSK	(0x400)
+#define ALTERA_SPI_STATUS_ROE_MSK	(1 << 3)
+#define ALTERA_SPI_STATUS_TOE_MSK	(1 << 4)
+#define ALTERA_SPI_STATUS_TMT_MSK	(1 << 5)
+#define ALTERA_SPI_STATUS_TRDY_MSK	(1 << 6)
+#define ALTERA_SPI_STATUS_RRDY_MSK	(1 << 7)
+#define ALTERA_SPI_STATUS_E_MSK		(1 << 8)
+
+#define ALTERA_SPI_CONTROL_IROE_MSK	(1 << 3)
+#define ALTERA_SPI_CONTROL_ITOE_MSK	(1 << 4)
+#define ALTERA_SPI_CONTROL_ITRDY_MSK	(1 << 6)
+#define ALTERA_SPI_CONTROL_IRRDY_MSK	(1 << 7)
+#define ALTERA_SPI_CONTROL_IE_MSK	(1 << 8)
+#define ALTERA_SPI_CONTROL_SSO_MSK	(1 << 10)
 
 #ifndef CONFIG_SYS_ALTERA_SPI_LIST
 #define CONFIG_SYS_ALTERA_SPI_LIST { CONFIG_SYS_SPI_BASE }
Signature · 1 line
2.0.0
#2 lore raw

PATCH 3/7 spi: altera: Clean up most checkpatch issues

In reply to Marek Vasut

This patch just zaps most of the checkpatch cries present in the driver. There is one more left, which will be addressed separately. There is no functional change.

This patch also adds a bunch of newlines all around the place, this is to make the code much more readable.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Jagannadha Sutradharudu Teki <[email protected]>
---
 drivers/spi/altera_spi.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/spi/altera_spi.c +13 -10
index 21f90fc..373ce30 100644
@@ -47,22 +47,19 @@ struct altera_spi_slave {
 };
 #define to_altera_spi_slave(s) container_of(s, struct altera_spi_slave, slave)
 
-__attribute__((weak))
-int spi_cs_is_valid(unsigned int bus, unsigned int cs)
+__weak int spi_cs_is_valid(unsigned int bus, unsigned int cs)
 {
 	return bus < ARRAY_SIZE(altera_spi_base_list) && cs < 32;
 }
 
-__attribute__((weak))
-void spi_cs_activate(struct spi_slave *slave)
+__weak void spi_cs_activate(struct spi_slave *slave)
 {
 	struct altera_spi_slave *altspi = to_altera_spi_slave(slave);
 	writel(1 << slave->cs, &altspi->regs->slave_sel);
 	writel(ALTERA_SPI_CONTROL_SSO_MSK, &altspi->regs->control);
 }
 
-__attribute__((weak))
-void spi_cs_deactivate(struct spi_slave *slave)
+__weak void spi_cs_deactivate(struct spi_slave *slave)
 {
 	struct altera_spi_slave *altspi = to_altera_spi_slave(slave);
 	writel(0, &altspi->regs->control);
@@ -91,8 +88,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 		return NULL;
 
 	altspi->regs = (struct altera_spi_regs *)altera_spi_base_list[bus];
-	debug("%s: bus:%i cs:%i base:%p\n", __func__,
-		bus, cs, altspi->regs);
+	debug("%s: bus:%i cs:%i base:%p\n", __func__, bus, cs, altspi->regs);
 
 	return &altspi->slave;
 }
@@ -135,7 +131,8 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
 	uchar *rxp = din;
 
 	debug("%s: bus:%i cs:%i bitlen:%i bytes:%i flags:%lx\n", __func__,
-		slave->bus, slave->cs, bitlen, bytes, flags);
+	      slave->bus, slave->cs, bitlen, bytes, flags);
+
 	if (bitlen == 0)
 		goto done;
 
@@ -147,21 +144,27 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
 	/* empty read buffer */
 	if (readl(&altspi->regs->status) & ALTERA_SPI_STATUS_RRDY_MSK)
 		readl(&altspi->regs->rxdata);
+
 	if (flags & SPI_XFER_BEGIN)
 		spi_cs_activate(slave);
 
 	while (bytes--) {
 		uchar d = txp ? *txp++ : CONFIG_ALTERA_SPI_IDLE_VAL;
+
 		debug("%s: tx:%x ", __func__, d);
 		writel(d, &altspi->regs->txdata);
+
 		while (!(readl(&altspi->regs->status) & ALTERA_SPI_STATUS_RRDY_MSK))
 			;
+
 		d = readl(&altspi->regs->rxdata);
 		if (rxp)
 			*rxp++ = d;
+
 		debug("rx:%x\n", d);
 	}
- done:
+
+done:
 	if (flags & SPI_XFER_END)
 		spi_cs_deactivate(slave);
 
Signature · 1 line
2.0.0
#3 lore raw

PATCH v2 4/7 spi: altera: Zap endless loop

In reply to Marek Vasut

The driver contained an endless loop when waiting for TX completion, this is a bad idea since if the hardware fails, the loop might spin forever. Add timeout and handle it.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Jagannadha Sutradharudu Teki <[email protected]>
---
 drivers/spi/altera_spi.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

V2: Use get_timer() in the look timing
Zap the ad-hoc timeout variable.

drivers/spi/altera_spi.c +11 -2
index 373ce30..8e898b9 100644
@@ -129,6 +129,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
 	uint bytes = bitlen / 8;
 	const uchar *txp = dout;
 	uchar *rxp = din;
+	uint32_t reg, start;
 
 	debug("%s: bus:%i cs:%i bitlen:%i bytes:%i flags:%lx\n", __func__,
 	      slave->bus, slave->cs, bitlen, bytes, flags);
@@ -154,8 +155,16 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
 		debug("%s: tx:%x ", __func__, d);
 		writel(d, &altspi->regs->txdata);
 
-		while (!(readl(&altspi->regs->status) & ALTERA_SPI_STATUS_RRDY_MSK))
-			;
+		start = get_timer(0);
+		while (1) {
+			reg = readl(&altspi->regs->status);
+			if (reg & ALTERA_SPI_STATUS_RRDY_MSK)
+				break;
+			if (get_timer(start) > (CONFIG_SYS_HZ / 1000)) {
+				printf("%s: Transmission timed out!\n", __func__);
+				goto done;
+			}
+		}
 
 		d = readl(&altspi->regs->rxdata);
 		if (rxp)
Signature · 1 line
2.0.0
#4 lore raw

PATCH v2 5/7 spi: altera: Clean up the use of variable d

In reply to Marek Vasut

The variable d is used in rather questionable way. Rework the code a bit so it's clearer what it does. Also, rename the variable from d to data to make it's name less mysterious. Finally, change it's data type to uint32_t , since it's accessed as a 32bit number.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Jagannadha Sutradharudu Teki <[email protected]>
---
 drivers/spi/altera_spi.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

V2: Just update the code due to changes in previous patch

drivers/spi/altera_spi.c +13 -10
index 8e898b9..c08969d 100644
@@ -126,10 +126,10 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
 {
 	struct altera_spi_slave *altspi = to_altera_spi_slave(slave);
 	/* assume spi core configured to do 8 bit transfers */
-	uint bytes = bitlen / 8;
-	const uchar *txp = dout;
-	uchar *rxp = din;
-	uint32_t reg, start;
+	unsigned int bytes = bitlen / 8;
+	const unsigned char *txp = dout;
+	unsigned char *rxp = din;
+	uint32_t reg, data, start;
 
 	debug("%s: bus:%i cs:%i bitlen:%i bytes:%i flags:%lx\n", __func__,
 	      slave->bus, slave->cs, bitlen, bytes, flags);
@@ -150,10 +150,13 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
 		spi_cs_activate(slave);
 
 	while (bytes--) {
-		uchar d = txp ? *txp++ : CONFIG_ALTERA_SPI_IDLE_VAL;
+		if (txp)
+			data = *txp++;
+		else
+			data = CONFIG_ALTERA_SPI_IDLE_VAL;
 
-		debug("%s: tx:%x ", __func__, d);
-		writel(d, &altspi->regs->txdata);
+		debug("%s: tx:%x ", __func__, data);
+		writel(data, &altspi->regs->txdata);
 
 		start = get_timer(0);
 		while (1) {
@@ -166,11 +169,11 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
 			}
 		}
 
-		d = readl(&altspi->regs->rxdata);
+		data = readl(&altspi->regs->rxdata);
 		if (rxp)
-			*rxp++ = d;
+			*rxp++ = data & 0xff;
 
-		debug("rx:%x\n", d);
+		debug("rx:%x\n", data);
 	}
 
 done:
Signature · 1 line
2.0.0
#5 lore raw

PATCH v2 6/7 spi: altera: Add short note about EPCS/EPCQx1

In reply to Marek Vasut

Add short documentation-alike note on how to use the Altera SPI driver with the EPCS/EPCQx1 FPGA IP block on SoCFPGA Cyclone V into doc/SPI/README.altera_spi

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Jagannadha Sutradharudu Teki <[email protected]>
---
 doc/SPI/README.altera_spi | 6 ++++++
 1 files changed, 6 insertions(+)
 create mode 100644 doc/SPI/README.altera_spi

V2: Move the documentation into doc/SPI/README.altera_spi

doc/SPI/README.altera_spi new file +6 -0
new file mode 100644
index 0000000..b07449f
@@ -0,0 +1,6 @@
+SoCFPGA EPCS/EPCQx1 mini howto:
+- Instantiate EPCS/EPCQx1 Serial flash controller in QSys and rebuild
+- The controller base address is the "Base" in QSys + 0x400
+- Set MSEL[4:0]=10010 (AS Standard)
+- Load the bitstream into FPGA, enable bridges
+- Only then will the driver work
Signature · 1 line
2.0.0
#6 lore raw

PATCH 7/7 spi: altera: Move the config options to the top

In reply to Marek Vasut

Just move the configuration options scattered all over the driver to the top of the source file. No functional change.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Jagannadha Sutradharudu Teki <[email protected]>
---
 drivers/spi/altera_spi.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/spi/altera_spi.c +8 -8
index 93365c2..8f31507 100644
@@ -13,6 +13,14 @@
 #include <malloc.h>
 #include <spi.h>
 
+#ifndef CONFIG_ALTERA_SPI_IDLE_VAL
+#define CONFIG_ALTERA_SPI_IDLE_VAL 0xff
+#endif
+
+#ifndef CONFIG_SYS_ALTERA_SPI_LIST
+#define CONFIG_SYS_ALTERA_SPI_LIST { CONFIG_SYS_SPI_BASE }
+#endif
+
 struct altera_spi_regs {
 	u32	rxdata;
 	u32	txdata;
@@ -36,10 +44,6 @@ struct altera_spi_regs {
 #define ALTERA_SPI_CONTROL_IE_MSK	(1 << 8)
 #define ALTERA_SPI_CONTROL_SSO_MSK	(1 << 10)
 
-#ifndef CONFIG_SYS_ALTERA_SPI_LIST
-#define CONFIG_SYS_ALTERA_SPI_LIST { CONFIG_SYS_SPI_BASE }
-#endif
-
 static ulong altera_spi_base_list[] = CONFIG_SYS_ALTERA_SPI_LIST;
 
 struct altera_spi_slave {
@@ -118,10 +122,6 @@ void spi_release_bus(struct spi_slave *slave)
 	writel(0, &altspi->regs->slave_sel);
 }
 
-#ifndef CONFIG_ALTERA_SPI_IDLE_VAL
-# define CONFIG_ALTERA_SPI_IDLE_VAL 0xff
-#endif
-
 int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
 	     void *din, unsigned long flags)
 {
Signature · 1 line
2.0.0
#7 lore raw

PATCH 7/7 spi: altera: Move the config options to the top

Quoted 55 lines · Marek Vasut

Just move the configuration options scattered all over the driver to the top of the source file. No functional change.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Albert Aribaud <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Jagannadha Sutradharudu Teki <[email protected]>
---
 drivers/spi/altera_spi.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/spi/altera_spi.c +8 -9
index 93365c2..8f31507 100644
@@ -13,6 +13,14 @@
 #include <malloc.h>
 #include <spi.h>
 
+#ifndef CONFIG_ALTERA_SPI_IDLE_VAL
+#define CONFIG_ALTERA_SPI_IDLE_VAL 0xff
+#endif
+
+#ifndef CONFIG_SYS_ALTERA_SPI_LIST
+#define CONFIG_SYS_ALTERA_SPI_LIST { CONFIG_SYS_SPI_BASE }
+#endif
+
 struct altera_spi_regs {
        u32     rxdata;
        u32     txdata;
@@ -36,10 +44,6 @@ struct altera_spi_regs {
 #define ALTERA_SPI_CONTROL_IE_MSK      (1 << 8)
 #define ALTERA_SPI_CONTROL_SSO_MSK     (1 << 10)
 
-#ifndef CONFIG_SYS_ALTERA_SPI_LIST
-#define CONFIG_SYS_ALTERA_SPI_LIST { CONFIG_SYS_SPI_BASE }
-#endif
-
 static ulong altera_spi_base_list[] = CONFIG_SYS_ALTERA_SPI_LIST;
 
 struct altera_spi_slave {
@@ -118,10 +122,6 @@ void spi_release_bus(struct spi_slave *slave)
        writel(0, &altspi->regs->slave_sel);
 }
 
-#ifndef CONFIG_ALTERA_SPI_IDLE_VAL
-# define CONFIG_ALTERA_SPI_IDLE_VAL 0xff
-#endif
-
 int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
             void *din, unsigned long flags)
 {
--
Quoted 2 lines

2.0.0

Series missing's - cover letter and v2 change log.

Applied to u-boot-spi/master

thanks!

Signature · 1 line
Jagan.
#8 lore raw

[U-Boot] socfpga: mainline cannot boot linux

In reply to Marek Vasut

Hi Marek,

Have you been able to successfully boot Linux using the mainline uboot? I cannot seem to be able to boot linux on the C5 SocDK.

It starts to boot linux, but then reboots after a bit back into u-boot. So I commented out #define CONFIG_HW_WATCHDOG in include/configs/socfpga_cyclone5.h. That helped so that I can look that __log_buf.
I was able to trace it down that it was not able to get a tty console, because serial8250_console_setup() is failing at:

if (!port->iobase && !port->membase)

For reasons I haven't figured out yet, both port->iobase and port->membase are NULL.

So no debug console, but Linux is able to boot all the way to the point of tyring to mount a FS.

Perhaps some kind of memory setup issue? I've seen a thread where Chin-Liang was able to boot, but I don't know if he did any other tricks.

Just wondering if I'm missing a patch or something?

Thanks,
Dinh

#9 lore raw

[U-Boot] socfpga: mainline cannot boot linux

Hi Dinh,

Quoted 17 lines · On Thu, 6 Nov 2014 17:03:48 -0600 Dinh Nguyen <[email protected]>…

Hi Marek,

Have you been able to successfully boot Linux using the mainline uboot? I cannot seem to be able to boot linux on the C5 SocDK.

It starts to boot linux, but then reboots after a bit back into u-boot. So I commented out #define CONFIG_HW_WATCHDOG in include/configs/socfpga_cyclone5.h. That helped so that I can look that __log_buf.
I was able to trace it down that it was not able to get a tty console, because serial8250_console_setup() is failing at:

if (!port->iobase && !port->membase)

For reasons I haven't figured out yet, both port->iobase and port->membase are NULL.

Quoted 7 lines

So no debug console, but Linux is able to boot all the way to the point of tyring to mount a FS.

Perhaps some kind of memory setup issue? I've seen a thread where Chin-Liang was able to boot, but I don't know if he did any other tricks.

Just wondering if I'm missing a patch or something?

the issue could be the wrong console= argument on the kernel command line. In the current socfpga_config5.h I see

  #define CONFIG_BOOTARGS         "console=ttyS0" __stringify(CONFIG_BAUDRATE)

A comma is missing after "console=ttyS0"

It should be

  #define CONFIG_BOOTARGS         "console=ttyS0," __stringify(CONFIG_BAUDRATE)

Could you please test it? Thanks.

Best regards,

Anatolij

#10 lore raw

[U-Boot] socfpga: mainline cannot boot linux

Quoted 35 lines · Anatolij Gustschin

Hi Dinh,

Quoted 17 lines · On Thu, 6 Nov 2014 17:03:48 -0600 Dinh Nguyen <[email protected]>…

Hi Marek,

Have you been able to successfully boot Linux using the mainline uboot? I cannot seem to be able to boot linux on the C5 SocDK.

It starts to boot linux, but then reboots after a bit back into u-boot. So I commented out #define CONFIG_HW_WATCHDOG in include/configs/socfpga_cyclone5.h. That helped so that I can look that __log_buf.
I was able to trace it down that it was not able to get a tty console, because serial8250_console_setup() is failing at:

if (!port->iobase && !port->membase)

For reasons I haven't figured out yet, both port->iobase and port->membase are NULL.

Quoted 7 lines

So no debug console, but Linux is able to boot all the way to the point of tyring to mount a FS.

Perhaps some kind of memory setup issue? I've seen a thread where Chin-Liang was able to boot, but I don't know if he did any other tricks.

Just wondering if I'm missing a patch or something?

the issue could be the wrong console= argument on the kernel command line. In the current socfpga_config5.h I see

  #define CONFIG_BOOTARGS         "console=ttyS0" __stringify(CONFIG_BAUDRATE)
Quoted 7 lines

A comma is missing after "console=ttyS0"

It should be

  #define CONFIG_BOOTARGS         "console=ttyS0," __stringify(CONFIG_BAUDRATE)

Could you please test it? Thanks.

Yep, that was it! Thanks alot for seeing that.

Dinh

#11 lore raw

[U-Boot] socfpga: mainline cannot boot linux

Quoted 40 lines · Dinh Nguyen
Quoted 39 lines · Anatolij Gustschin

Hi Dinh,

On Thu, 6 Nov 2014 17:03:48 -0600

Quoted 17 lines · Dinh Nguyen

Hi Marek,

Have you been able to successfully boot Linux using the mainline uboot? I cannot seem to be able to boot linux on the C5 SocDK.

It starts to boot linux, but then reboots after a bit back into u-boot. So I commented out #define CONFIG_HW_WATCHDOG in include/configs/socfpga_cyclone5.h. That helped so that I can look that __log_buf.
I was able to trace it down that it was not able to get a tty console, because serial8250_console_setup() is failing at:

if (!port->iobase && !port->membase)

For reasons I haven't figured out yet, both port->iobase and port->membase are NULL.

Quoted 8 lines

So no debug console, but Linux is able to boot all the way to the point of tyring to mount a FS.

Perhaps some kind of memory setup issue? I've seen a thread where Chin-Liang was able to boot, but I don't know if he did any other tricks.

Just wondering if I'm missing a patch or something?

the issue could be the wrong console= argument on the kernel command line. In the current socfpga_config5.h I see

  #define CONFIG_BOOTARGS         "console=ttyS0"
  __stringify(CONFIG_BAUDRATE)

A comma is missing after "console=ttyS0"

Quoted 8 lines
Quoted 6 lines

It should be

  #define CONFIG_BOOTARGS         "console=ttyS0,"
  __stringify(CONFIG_BAUDRATE)

Could you please test it? Thanks.

Yep, that was it! Thanks alot for seeing that.

Thanks for spotting this, I'll pick the patch for Anatolij.

Best regards,
Marek Vasut

#12 lore raw

PATCH 1/7 spi: altera: Use struct-based register access

In reply to Marek Vasut
Quoted 5 lines · Marek Vasut

Zap the offset-based register access and use the struct-based one as this is the preferred method.

No functional change, but there are some line-over-80 problems in the driver, which will be addressed later.

For 1-7:

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html