[U-Boot] [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.
Signed-off-by: Marek Vasut marex@denx.de Cc: Chin Liang See clsee@altera.com Cc: Dinh Nguyen dinguyen@altera.com Cc: Albert Aribaud albert.u.boot@aribaud.net Cc: Pavel Machek pavel@denx.de Cc: Jagannadha Sutradharudu Teki jagannadh.teki@gmail.com --- drivers/spi/altera_spi.c | 49 ++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-)
diff --git a/drivers/spi/altera_spi.c b/drivers/spi/altera_spi.c index 5accbb5..13191f3 100644 --- a/drivers/spi/altera_spi.c +++ b/drivers/spi/altera_spi.c @@ -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);

Clean up the definitions of bits in the Altera SPI driver, there is no need to put braces around numbers afterall. No functional change.
Signed-off-by: Marek Vasut marex@denx.de Cc: Chin Liang See clsee@altera.com Cc: Dinh Nguyen dinguyen@altera.com Cc: Albert Aribaud albert.u.boot@aribaud.net Cc: Pavel Machek pavel@denx.de Cc: Jagannadha Sutradharudu Teki jagannadh.teki@gmail.com --- drivers/spi/altera_spi.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/spi/altera_spi.c b/drivers/spi/altera_spi.c index 13191f3..21f90fc 100644 --- a/drivers/spi/altera_spi.c +++ b/drivers/spi/altera_spi.c @@ -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 }

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.
Signed-off-by: Marek Vasut marex@denx.de Cc: Chin Liang See clsee@altera.com Cc: Dinh Nguyen dinguyen@altera.com Cc: Albert Aribaud albert.u.boot@aribaud.net Cc: Pavel Machek pavel@denx.de Cc: Jagannadha Sutradharudu Teki jagannadh.teki@gmail.com --- drivers/spi/altera_spi.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/drivers/spi/altera_spi.c b/drivers/spi/altera_spi.c index 21f90fc..373ce30 100644 --- a/drivers/spi/altera_spi.c +++ b/drivers/spi/altera_spi.c @@ -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);

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.
Signed-off-by: Marek Vasut marex@denx.de Cc: Chin Liang See clsee@altera.com Cc: Dinh Nguyen dinguyen@altera.com Cc: Albert Aribaud albert.u.boot@aribaud.net Cc: Pavel Machek pavel@denx.de Cc: Jagannadha Sutradharudu Teki jagannadh.teki@gmail.com --- 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.
diff --git a/drivers/spi/altera_spi.c b/drivers/spi/altera_spi.c index 373ce30..8e898b9 100644 --- a/drivers/spi/altera_spi.c +++ b/drivers/spi/altera_spi.c @@ -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)

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.
Signed-off-by: Marek Vasut marex@denx.de Cc: Chin Liang See clsee@altera.com Cc: Dinh Nguyen dinguyen@altera.com Cc: Albert Aribaud albert.u.boot@aribaud.net Cc: Pavel Machek pavel@denx.de Cc: Jagannadha Sutradharudu Teki jagannadh.teki@gmail.com --- drivers/spi/altera_spi.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
V2: Just update the code due to changes in previous patch
diff --git a/drivers/spi/altera_spi.c b/drivers/spi/altera_spi.c index 8e898b9..c08969d 100644 --- a/drivers/spi/altera_spi.c +++ b/drivers/spi/altera_spi.c @@ -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:

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
Signed-off-by: Marek Vasut marex@denx.de Cc: Chin Liang See clsee@altera.com Cc: Dinh Nguyen dinguyen@altera.com Cc: Albert Aribaud albert.u.boot@aribaud.net Cc: Pavel Machek pavel@denx.de Cc: Jagannadha Sutradharudu Teki jagannadh.teki@gmail.com --- 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
diff --git a/doc/SPI/README.altera_spi b/doc/SPI/README.altera_spi new file mode 100644 index 0000000..b07449f --- /dev/null +++ b/doc/SPI/README.altera_spi @@ -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

Just move the configuration options scattered all over the driver to the top of the source file. No functional change.
Signed-off-by: Marek Vasut marex@denx.de Cc: Chin Liang See clsee@altera.com Cc: Dinh Nguyen dinguyen@altera.com Cc: Albert Aribaud albert.u.boot@aribaud.net Cc: Pavel Machek pavel@denx.de Cc: Jagannadha Sutradharudu Teki jagannadh.teki@gmail.com --- drivers/spi/altera_spi.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/spi/altera_spi.c b/drivers/spi/altera_spi.c index 93365c2..8f31507 100644 --- a/drivers/spi/altera_spi.c +++ b/drivers/spi/altera_spi.c @@ -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) {

On 23 October 2014 01:26, Marek Vasut marex@denx.de wrote:
Just move the configuration options scattered all over the driver to the top of the source file. No functional change.
Signed-off-by: Marek Vasut marex@denx.de Cc: Chin Liang See clsee@altera.com Cc: Dinh Nguyen dinguyen@altera.com Cc: Albert Aribaud albert.u.boot@aribaud.net Cc: Pavel Machek pavel@denx.de Cc: Jagannadha Sutradharudu Teki jagannadh.teki@gmail.com
drivers/spi/altera_spi.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/spi/altera_spi.c b/drivers/spi/altera_spi.c index 93365c2..8f31507 100644 --- a/drivers/spi/altera_spi.c +++ b/drivers/spi/altera_spi.c @@ -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) { -- 2.0.0
Series missing's - cover letter and v2 change log.
Applied to u-boot-spi/master
thanks!

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

Hi Dinh,
On Thu, 6 Nov 2014 17:03:48 -0600 Dinh Nguyen dinguyen@opensource.altera.com wrote:
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?
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

On 11/06/2014 05:40 PM, Anatolij Gustschin wrote:
Hi Dinh,
On Thu, 6 Nov 2014 17:03:48 -0600 Dinh Nguyen dinguyen@opensource.altera.com wrote:
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?
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.
Yep, that was it! Thanks alot for seeing that.
Dinh

On Friday, November 07, 2014 at 12:54:14 AM, Dinh Nguyen wrote:
On 11/06/2014 05:40 PM, Anatolij Gustschin wrote:
Hi Dinh,
On Thu, 6 Nov 2014 17:03:48 -0600
Dinh Nguyen dinguyen@opensource.altera.com wrote:
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?
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.
Yep, that was it! Thanks alot for seeing that.
Thanks for spotting this, I'll pick the patch for Anatolij.
Best regards, Marek Vasut

On Wed 2014-10-22 21:55:58, Marek Vasut wrote:
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:
Acked-by: Pavel Machek pavel@denx.de
Pavel
participants (5)
-
Anatolij Gustschin
-
Dinh Nguyen
-
Jagan Teki
-
Marek Vasut
-
Pavel Machek