All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3 0/4] uboot sata support for sunxi platform
@ 2014-03-07  1:19 Ian Campbell
  2014-03-07  1:20 ` [U-Boot] [PATCH v3 1/4] ahci-plat: Provide a weak scsi_init hook Ian Campbell
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: Ian Campbell @ 2014-03-07  1:19 UTC (permalink / raw)
  To: u-boot

This is the third version of my series to add support for AHCI to the
sunxi platform. This uses the existing ahci platform support already
present in u-boot. Most of the sunxi specific code comes from the Linux
platform patches.

Since last time I've cut out all the unused register #defines and made
the Calxeda midway platform use the scsi_init hook (new patch).

I've tested this only on cubietruck, but it is enabled for Olinino
Micro, cubieboard and cubieboard2 based on inspection of the Linux DTS
files. I have also now tested on Calxeda midway.

Once again as requested I am also cross posting to the main uboot
mailing list since the first two patches are generic and don't rely on
sunxi stuff and so could go into mainline now.

Ian.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v3 1/4] ahci-plat: Provide a weak scsi_init hook
  2014-03-07  1:19 [U-Boot] [PATCH v3 0/4] uboot sata support for sunxi platform Ian Campbell
@ 2014-03-07  1:20 ` Ian Campbell
  2014-03-10 21:27   ` [U-Boot] [U-Boot, v3, " Tom Rini
  2014-03-07  1:20 ` [U-Boot] [PATCH v3 2/4] highbank: use " Ian Campbell
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 18+ messages in thread
From: Ian Campbell @ 2014-03-07  1:20 UTC (permalink / raw)
  To: u-boot

This allow the platform to register the platform ahci device.

Signed-off-by: Ian Campbell <ijc@hellion.org.uk>
---
In theory this could perhaps be used by highbank. I have access to a
Midway system (close enough for testing purposes, I think) but since
Calxeda has folded I'm not sure it is worth it, and I am not entirely
keen on reflashing firmware on the system I have access too (no safety
net)...
---
 arch/arm/lib/board.c | 6 ++++++
 drivers/block/ahci.c | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 34f50b0..fe381a3 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -33,6 +33,7 @@
 #include <nand.h>
 #include <onenand_uboot.h>
 #include <mmc.h>
+#include <scsi.h>
 #include <libfdt.h>
 #include <fdtdec.h>
 #include <post.h>
@@ -593,6 +594,11 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	mmc_initialize(gd->bd);
 #endif
 
+#ifdef CONFIG_CMD_SCSI
+	puts("SCSI:  ");
+	scsi_init();
+#endif
+
 #ifdef CONFIG_HAS_DATAFLASH
 	AT91F_DataflashInit();
 	dataflash_print_info();
diff --git a/drivers/block/ahci.c b/drivers/block/ahci.c
index 0daad36..d5370fa 100644
--- a/drivers/block/ahci.c
+++ b/drivers/block/ahci.c
@@ -924,6 +924,11 @@ int ahci_init(u32 base)
 err_out:
 	return rc;
 }
+
+void __weak scsi_init(void)
+{
+}
+
 #endif
 
 /*
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v3 2/4] highbank: use scsi_init hook
  2014-03-07  1:19 [U-Boot] [PATCH v3 0/4] uboot sata support for sunxi platform Ian Campbell
  2014-03-07  1:20 ` [U-Boot] [PATCH v3 1/4] ahci-plat: Provide a weak scsi_init hook Ian Campbell
@ 2014-03-07  1:20 ` Ian Campbell
  2014-03-07  2:43   ` Rob Herring
  2014-03-10 21:28   ` [U-Boot] [U-Boot,v3,2/4] " Tom Rini
  2014-03-07  1:20 ` [U-Boot] [PATCH v3 3/4] ahci: wait longer for link Ian Campbell
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 18+ messages in thread
From: Ian Campbell @ 2014-03-07  1:20 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Ian Campbell <ijc@hellion.org.uk>
---
 board/highbank/highbank.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/board/highbank/highbank.c b/board/highbank/highbank.c
index 4b272c7..d42447d 100644
--- a/board/highbank/highbank.c
+++ b/board/highbank/highbank.c
@@ -51,17 +51,23 @@ int board_eth_init(bd_t *bis)
 	return rc;
 }
 
-#ifdef CONFIG_MISC_INIT_R
-int misc_init_r(void)
+#ifdef CONFIG_SCSI_AHCI_PLAT
+void scsi_init(void)
 {
-	char envbuffer[16];
-	u32 boot_choice;
 	u32 reg = readl(HB_SREG_A9_PWRDOM_STAT);
 
 	if (reg & PWRDOM_STAT_SATA) {
 		ahci_init(HB_AHCI_BASE);
 		scsi_scan(1);
 	}
+}
+#endif
+
+#ifdef CONFIG_MISC_INIT_R
+int misc_init_r(void)
+{
+	char envbuffer[16];
+	u32 boot_choice;
 
 	boot_choice = readl(HB_SREG_A9_BOOT_SRC_STAT) & 0xff;
 	sprintf(envbuffer, "bootcmd%d", boot_choice);
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v3 3/4] ahci: wait longer for link.
  2014-03-07  1:19 [U-Boot] [PATCH v3 0/4] uboot sata support for sunxi platform Ian Campbell
  2014-03-07  1:20 ` [U-Boot] [PATCH v3 1/4] ahci-plat: Provide a weak scsi_init hook Ian Campbell
  2014-03-07  1:20 ` [U-Boot] [PATCH v3 2/4] highbank: use " Ian Campbell
@ 2014-03-07  1:20 ` Ian Campbell
  2014-03-10 21:28   ` [U-Boot] [U-Boot,v3,3/4] " Tom Rini
  2014-03-07  1:20 ` [U-Boot] [PATCH v3 4/4] ahci: provide sunxi SATA driver using AHCI platform framework Ian Campbell
  2014-03-07  1:24 ` [U-Boot] [linux-sunxi] [PATCH v3 0/4] uboot sata support for sunxi platform Ian Campbell
  4 siblings, 1 reply; 18+ messages in thread
From: Ian Campbell @ 2014-03-07  1:20 UTC (permalink / raw)
  To: u-boot

I have observed timeouts on a cubietruck.

The increase to 40ms is completely arbitrary and Works For Me(tm). I
couldn't find a good reference for how long you are supposed to wait,
although googling around it seems like tens of ms rather than single
digits is more common. I don't think there is any harm in waiting a bit
longer.

Signed-off-by: Ian Campbell <ijc@hellion.org.uk>
---
 drivers/block/ahci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/ahci.c b/drivers/block/ahci.c
index d5370fa..90a0719 100644
--- a/drivers/block/ahci.c
+++ b/drivers/block/ahci.c
@@ -41,7 +41,7 @@ u16 *ataid[AHCI_MAX_PORTS];
 #define WAIT_MS_SPINUP	20000
 #define WAIT_MS_DATAIO	5000
 #define WAIT_MS_FLUSH	5000
-#define WAIT_MS_LINKUP	4
+#define WAIT_MS_LINKUP	40
 
 static inline u32 ahci_port_base(u32 base, u32 port)
 {
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v3 4/4] ahci: provide sunxi SATA driver using AHCI platform framework
  2014-03-07  1:19 [U-Boot] [PATCH v3 0/4] uboot sata support for sunxi platform Ian Campbell
                   ` (2 preceding siblings ...)
  2014-03-07  1:20 ` [U-Boot] [PATCH v3 3/4] ahci: wait longer for link Ian Campbell
@ 2014-03-07  1:20 ` Ian Campbell
  2014-03-07  1:24 ` [U-Boot] [linux-sunxi] [PATCH v3 0/4] uboot sata support for sunxi platform Ian Campbell
  4 siblings, 0 replies; 18+ messages in thread
From: Ian Campbell @ 2014-03-07  1:20 UTC (permalink / raw)
  To: u-boot

This enables the necessary clocks, in AHB0 and in PLL6_CFG. This is done
for sun7i only since I don't have access to any other sunxi platforms
with sata included.

The bulk of the code is taken from the Linux ahci sunxi platform driver
patches, adjusted for u-boot.

This adds the "PORT_DMA" tweaks to the core driver, under a suitable
ifdef.

This option is enabled for Cubieboard, Cubieboard2, Cubietruck and
Olinuxino Micro based on contents of Linux DTS files, including SATA
power pin config taken from the DTS. All build tested, but runtime
tested on cubietruck (FEL) only.

Signed-off-by: Ian Campbell <ijc@hellion.org.uk>
---
v3:

    Drop unused register definitions

v2:

    make AHCI configurable per board, enabled for cubieboard,
    cubieboard2, cubietruck and Olinuxino Micro.
---
 arch/arm/cpu/armv7/sunxi/clock.c |  4 +++
 boards.cfg                       | 18 +++++-----
 drivers/block/Makefile           |  1 +
 drivers/block/ahci.c             | 15 +++++++-
 drivers/block/ahci_sunxi.c       | 77 ++++++++++++++++++++++++++++++++++++++++
 include/ahci.h                   |  9 +++++
 include/configs/sunxi-common.h   | 12 +++++++
 7 files changed, 126 insertions(+), 10 deletions(-)
 create mode 100644 drivers/block/ahci_sunxi.c

diff --git a/arch/arm/cpu/armv7/sunxi/clock.c b/arch/arm/cpu/armv7/sunxi/clock.c
index 06bc283..2cc274b 100644
--- a/arch/arm/cpu/armv7/sunxi/clock.c
+++ b/arch/arm/cpu/armv7/sunxi/clock.c
@@ -51,6 +51,10 @@ static void clock_init_safe(void)
 #ifdef CONFIG_SUN7I
 	writel(0x1 << 6 | readl(&ccm->ahb_gate0), &ccm->ahb_gate0);
 	writel(0x1 << 31 | readl(&ccm->pll6_cfg), &ccm->pll6_cfg);
+#ifdef CONFIG_SCSI_AHCI_SUNXI
+	writel(0x1 << 25 |readl(&ccm->ahb_gate0), &ccm->ahb_gate0);
+	writel(0x1 << 14 | readl(&ccm->pll6_cfg), &ccm->pll6_cfg);
+#endif
 #endif
 }
 #endif
diff --git a/boards.cfg b/boards.cfg
index 100acc8..987bc54 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -354,8 +354,8 @@ Active  arm         armv7          sunxi       -               sunxi
 Active  arm         armv7          sunxi       -               sunxi               A13-OLinuXinoM                       sun5i:A13_OLINUXINOM,SPL,NO_AXP,STATUSLED=201,CONS_INDEX=2                                                                        -
 Active  arm         armv7          sunxi       -               sunxi               A13-OLinuXinoM_FEL                   sun5i:A13_OLINUXINOM,SPL_FEL,NO_AXP,STATUSLED=201,CONS_INDEX=2                                                                    -
 Active  arm         armv7          sunxi       -               sunxi               A13_MID                              sun5i:A13_MID,SPL,CONS_INDEX=2                                                                                                    -
-Active  arm         armv7          sunxi       -               sunxi               A20-OLinuXino_MICRO                  sun7i:A20_OLINUXINO_M,CONS_INDEX=1,STATUSLED=226,SPL,SUNXI_EMAC                                                                   -
-Active  arm         armv7          sunxi       -               sunxi               A20-OLinuXino_MICRO_FEL              sun7i:A20_OLINUXINO_M,CONS_INDEX=1,STATUSLED=226,SPL_FEL,SUNXI_EMAC                                                               -
+Active  arm         armv7          sunxi       -               sunxi               A20-OLinuXino_MICRO                  sun7i:A20_OLINUXINO_M,CONS_INDEX=1,STATUSLED=226,SPL,SUNXI_EMAC,AHCI,SATAPWR=SUNXI_GPB(8)                                                                   -
+Active  arm         armv7          sunxi       -               sunxi               A20-OLinuXino_MICRO_FEL              sun7i:A20_OLINUXINO_M,CONS_INDEX=1,STATUSLED=226,SPL_FEL,SUNXI_EMAC,AHCI,SATAPWR=SUNXI_GPB(8)                                                               -
 Active  arm         armv7          sunxi       -               sunxi               Auxtek-T003                          sun5i:AUXTEK_T003,SPL,AXP152_POWER,STATUSLED=34                                                                                   -
 Active  arm         armv7          sunxi       -               sunxi               Auxtek-T004                          sun5i:AUXTEK_T004,SPL,AXP152_POWER,STATUSLED=34                                                                                   -
 Active  arm         armv7          sunxi       -               sunxi               ba10_tv_box                          sun4i:BA10_TV_BOX,SPL,SUNXI_EMAC                                                                                                  -
@@ -363,13 +363,13 @@ Active  arm         armv7          sunxi       -               sunxi
 Active  arm         armv7          sunxi       -               sunxi               Coby_MID8042                         sun4i:COBY_MID8042,SPL                                                                                                            -
 Active  arm         armv7          sunxi       -               sunxi               Coby_MID9742                         sun4i:COBY_MID9742,SPL                                                                                                            -
 Active  arm         armv7          sunxi       -               sunxi               Colombus                             sun6i:COLOMBUS                                                                                                                    -
-Active  arm         armv7          sunxi       -               sunxi               Cubieboard                           sun4i:CUBIEBOARD,SPL,SUNXI_EMAC,STATUSLED=244,STATUSLED1=245                                                                      -
-Active  arm         armv7          sunxi       -               sunxi               Cubieboard2                          sun7i:CUBIEBOARD2,SPL,SUNXI_GMAC,STATUSLED=244,STATUSLED1=245,FAST_MBUS                                                           -
-Active  arm         armv7          sunxi       -               sunxi               Cubieboard2_FEL                      sun7i:CUBIEBOARD2,SPL_FEL,SUNXI_GMAC,STATUSLED=244,STATUSLED1=245,FAST_MBUS                                                       -
-Active  arm         armv7          sunxi       -               sunxi               Cubietruck                           sun7i:CUBIETRUCK,SPL,SUNXI_GMAC,RGMII,STATUSLED=245,STATUSLED1=244,STATUSLED2=235,STATUSLED3=231,FAST_MBUS                        -
-Active  arm         armv7          sunxi       -               sunxi               Cubietruck_FEL                       sun7i:CUBIETRUCK,SPL_FEL,SUNXI_GMAC,RGMII,STATUSLED=245,STATUSLED1=244,STATUSLED2=235,STATUSLED3=231,FAST_MBUS                    -
-Active  arm         armv7          sunxi       -               sunxi               Cubieboard_512                       sun4i:CUBIEBOARD_512,SPL,SUNXI_EMAC,STATUSLED=244,STATUSLED1=245                                                                  -
-Active  arm         armv7          sunxi       -               sunxi               Cubieboard_FEL                       sun4i:CUBIEBOARD,SPL_FEL,SUNXI_EMAC,STATUSLED=244,STATUSLED1=245                                                                  -
+Active  arm         armv7          sunxi       -               sunxi               Cubieboard                           sun4i:CUBIEBOARD,SPL,SUNXI_EMAC,STATUSLED=244,STATUSLED1=245,AHCI,SATAPWR=SUNXI_GPB(8)                                            -
+Active  arm         armv7          sunxi       -               sunxi               Cubieboard2                          sun7i:CUBIEBOARD2,SPL,SUNXI_GMAC,STATUSLED=244,STATUSLED1=245,FAST_MBUS,AHCI,SATAPWR=SUNXI_GPB(8)                                 -
+Active  arm         armv7          sunxi       -               sunxi               Cubieboard2_FEL                      sun7i:CUBIEBOARD2,SPL_FEL,SUNXI_GMAC,STATUSLED=244,STATUSLED1=245,FAST_MBUS,AHCI,SATAPWR=SUNXI_GPB(8)                             -
+Active  arm         armv7          sunxi       -               sunxi               Cubietruck                           sun7i:CUBIETRUCK,SPL,SUNXI_GMAC,RGMII,STATUSLED=245,STATUSLED1=244,STATUSLED2=235,STATUSLED3=231,FAST_MBUS,AHCI,SATAPWR=SUNXI_GPH(12) -
+Active  arm         armv7          sunxi       -               sunxi               Cubietruck_FEL                       sun7i:CUBIETRUCK,SPL_FEL,SUNXI_GMAC,RGMII,STATUSLED=245,STATUSLED1=244,STATUSLED2=235,STATUSLED3=231,FAST_MBUS,AHCI,SATAPWR=SUNXI_GPH(12) -
+Active  arm         armv7          sunxi       -               sunxi               Cubieboard_512                       sun4i:CUBIEBOARD_512,SPL,SUNXI_EMAC,STATUSLED=244,STATUSLED1=245,AHCI,SATAPWR=SUNXI_GPB(8)                                        -
+Active  arm         armv7          sunxi       -               sunxi               Cubieboard_FEL                       sun4i:CUBIEBOARD,SPL_FEL,SUNXI_EMAC,STATUSLED=244,STATUSLED1=245,AHCI,SATAPWR=SUNXI_GPB(8)                                        -
 Active  arm         armv7          sunxi       -               sunxi               DNS_M82                              sun4i:DNS_M82,SPL                                                                                                                 -
 Active  arm         armv7          sunxi       -               sunxi               EOMA68_A10                           sun4i:EOMA68_A10,SPL,MMC_SUNXI_SLOT=3,SUNXI_EMAC                                                                                  -
 Active  arm         armv7          sunxi       -               sunxi               EOMA68_A10_FEL                       sun4i:EOMA68_A10,SPL_FEL,MMC_SUNXI_SLOT=3,SUNXI_EMAC                                                                              -
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 4e94378..e77188b 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -6,6 +6,7 @@
 #
 
 obj-$(CONFIG_SCSI_AHCI) += ahci.o
+obj-$(CONFIG_SCSI_AHCI_SUNXI) += ahci_sunxi.o
 obj-$(CONFIG_ATA_PIIX) += ata_piix.o
 obj-$(CONFIG_DWC_AHSATA) += dwc_ahsata.o
 obj-$(CONFIG_FSL_SATA) += fsl_sata.o
diff --git a/drivers/block/ahci.c b/drivers/block/ahci.c
index 90a0719..32be726 100644
--- a/drivers/block/ahci.c
+++ b/drivers/block/ahci.c
@@ -213,6 +213,13 @@ static int ahci_host_init(struct ahci_probe_ent *probe_ent)
 			msleep(500);
 		}
 
+#ifdef CONFIG_SCSI_AHCI_SUNXI
+		tmp = readl(port_mmio + PORT_DMA);
+		tmp &= ~PORT_DMA_SETUP_MASK;
+		tmp |= PORT_DMA_SETUP_INIT;
+		writel_with_flush(tmp, port_mmio + PORT_DMA);
+#endif
+
 		/* Add the spinup command to whatever mode bits may
 		 * already be on in the command register.
 		 */
@@ -490,7 +497,7 @@ static int ahci_port_start(u8 port)
 	struct ahci_ioports *pp = &(probe_ent->port[port]);
 	volatile u8 *port_mmio = (volatile u8 *)pp->port_mmio;
 	u32 port_status;
-	u32 mem;
+	u32 mem, tmp;
 
 	debug("Enter start port: %d\n", port);
 	port_status = readl(port_mmio + PORT_SCR_STAT);
@@ -540,6 +547,12 @@ static int ahci_port_start(u8 port)
 
 	writel_with_flush(pp->rx_fis, port_mmio + PORT_FIS_ADDR);
 
+#ifdef CONFIG_SCSI_AHCI_SUNXI
+	tmp = readl(port_mmio + PORT_DMA);
+	tmp &= ~PORT_DMA_SETUP_MASK;
+        tmp |= PORT_DMA_SETUP_INIT;
+	writel_with_flush(tmp, port_mmio + PORT_DMA);
+#endif
 	writel_with_flush(PORT_CMD_ICC_ACTIVE | PORT_CMD_FIS_RX |
 			  PORT_CMD_POWER_ON | PORT_CMD_SPIN_UP |
 			  PORT_CMD_START, port_mmio + PORT_CMD);
diff --git a/drivers/block/ahci_sunxi.c b/drivers/block/ahci_sunxi.c
new file mode 100644
index 0000000..6bffc76
--- /dev/null
+++ b/drivers/block/ahci_sunxi.c
@@ -0,0 +1,77 @@
+#include <common.h>
+#include <ahci.h>
+#include <scsi.h>
+#include <asm/io.h>
+#include <asm/gpio.h>
+
+#define AHCI_PHYCS0R 0x00c0
+#define AHCI_PHYCS1R 0x00c4
+#define AHCI_PHYCS2R 0x00c8
+#define AHCI_RWCR    0x00fc
+
+#define BIT(x) (1<<x)
+static u32 sunxi_getbits(u8 *reg, u8 mask, u8 shift)
+{
+	return (readl(reg) >> shift) & mask;
+}
+
+static int sunxi_ahci_phy_init(u32 base)
+{
+	u8 *reg_base = (u8 *)base;
+	u32 reg_val;
+	int timeout;
+
+	/* This magic is from the original code */
+	writel(0, reg_base + AHCI_RWCR);
+	mdelay(5);
+
+	setbits_le32(reg_base + AHCI_PHYCS1R, BIT(19));
+	clrsetbits_le32(reg_base + AHCI_PHYCS0R,
+			(0x7 << 24),
+			(0x5 << 24) | BIT(23) | BIT(18));
+	clrsetbits_le32(reg_base + AHCI_PHYCS1R,
+			(0x3 << 16) | (0x1f << 8) | (0x3 << 6),
+			(0x2 << 16) | (0x6 << 8) | (0x2 << 6));
+	setbits_le32(reg_base + AHCI_PHYCS1R, BIT(28) | BIT(15));
+	clrbits_le32(reg_base + AHCI_PHYCS1R, BIT(19));
+	clrsetbits_le32(reg_base + AHCI_PHYCS0R,
+			(0x7 << 20), (0x3 << 20));
+	clrsetbits_le32(reg_base + AHCI_PHYCS2R,
+			(0x1f << 5), (0x19 << 5));
+	mdelay(5);
+
+	setbits_le32(reg_base + AHCI_PHYCS0R, (0x1 << 19));
+
+	timeout = 0x100000;
+	do {
+		reg_val = sunxi_getbits(reg_base + AHCI_PHYCS0R, 0x7, 28);
+	} while (--timeout && (reg_val != 0x2));
+	if (!timeout)
+		printf("PHY power up failed.\n");
+
+	setbits_le32(reg_base + AHCI_PHYCS2R, (0x1 << 24));
+
+	timeout = 0x100000;
+	do {
+		reg_val = sunxi_getbits(reg_base + AHCI_PHYCS2R, 0x1, 24);
+	} while (--timeout && reg_val);
+	if (!timeout)
+		printf("PHY calibration failed.\n");
+	mdelay(15);
+
+	writel(0x7, reg_base + AHCI_RWCR);
+
+	return 0;
+}
+
+void scsi_init(void)
+{
+	printf("SUNXI SCSI INIT\n");
+#ifdef CONFIG_SATAPWR
+	gpio_direction_output(CONFIG_SATAPWR, 1);
+#endif
+
+	sunxi_ahci_phy_init(SUNXI_SATA_BASE);
+
+	ahci_init(SUNXI_SATA_BASE);
+}
diff --git a/include/ahci.h b/include/ahci.h
index 90e8509..c94689c 100644
--- a/include/ahci.h
+++ b/include/ahci.h
@@ -58,6 +58,15 @@
 #define PORT_SCR_ERR		0x30 /* SATA phy register: SError */
 #define PORT_SCR_ACT		0x34 /* SATA phy register: SActive */
 
+#ifdef CONFIG_SCSI_AHCI_SUNXI
+#define PORT_DMA		0x70 /* SUNXI specific "DMA register" */
+
+#define PORT_DMA_SETUP_OFFSET 8 /* dma setup offset */
+#define PORT_DMA_SETUP_MASK   (0xff << PORT_DMA_SETUP_OFFSET) /* dma mask */
+#define PORT_DMA_SETUP_INIT   (0x44 << PORT_DMA_SETUP_OFFSET)
+#endif
+
+
 /* PORT_IRQ_{STAT,MASK} bits */
 #define PORT_IRQ_COLD_PRES	(1 << 31) /* cold presence detect */
 #define PORT_IRQ_TF_ERR		(1 << 30) /* task file error */
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index d46a43f..be4c6b5 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -88,6 +88,18 @@
 #define CONFIG_SYS_NAND_BASE            0x00
 #endif
 
+#ifdef CONFIG_AHCI
+#define CONFIG_LIBATA
+#define CONFIG_SCSI_AHCI
+#define CONFIG_SCSI_AHCI_PLAT
+#define CONFIG_SCSI_AHCI_SUNXI
+#define CONFIG_SYS_SCSI_MAX_SCSI_ID	1
+#define CONFIG_SYS_SCSI_MAX_LUN		1
+#define CONFIG_SYS_SCSI_MAX_DEVICE	(CONFIG_SYS_SCSI_MAX_SCSI_ID * \
+			CONFIG_SYS_SCSI_MAX_LUN)
+#define CONFIG_CMD_SCSI
+#endif
+
 #define CONFIG_CMD_MEMORY
 #define CONFIG_CMD_SETEXPR
 
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [U-Boot] [linux-sunxi] [PATCH v3 0/4] uboot sata support for sunxi platform
  2014-03-07  1:19 [U-Boot] [PATCH v3 0/4] uboot sata support for sunxi platform Ian Campbell
                   ` (3 preceding siblings ...)
  2014-03-07  1:20 ` [U-Boot] [PATCH v3 4/4] ahci: provide sunxi SATA driver using AHCI platform framework Ian Campbell
@ 2014-03-07  1:24 ` Ian Campbell
  2014-03-07 16:44   ` Ezaul Zillmer
  4 siblings, 1 reply; 18+ messages in thread
From: Ian Campbell @ 2014-03-07  1:24 UTC (permalink / raw)
  To: u-boot

On Fri, 2014-03-07 at 01:19 +0000, Ian Campbell wrote:
> This is the third version of my series to add support for AHCI to the
> sunxi platform. This uses the existing ahci platform support already
> present in u-boot. Most of the sunxi specific code comes from the Linux
> platform patches.
> 
> Since last time I've cut out all the unused register #defines and made
> the Calxeda midway platform use the scsi_init hook (new patch).
> 
> I've tested this only on cubietruck, but it is enabled for Olinino
> Micro, cubieboard and cubieboard2 based on inspection of the Linux DTS
> files. I have also now tested on Calxeda midway.
> 
> Once again as requested I am also cross posting to the main uboot
> mailing list since the first two patches are generic and don't rely on

Oops:                          ^three

That is:
        ahci-plat: Provide a weak scsi_init hook
        highbank: use scsi_init hook
        ahci: wait longer for link.

are all suitable for main line.

> sunxi stuff and so could go into mainline now.
> 
> Ian.
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v3 2/4] highbank: use scsi_init hook
  2014-03-07  1:20 ` [U-Boot] [PATCH v3 2/4] highbank: use " Ian Campbell
@ 2014-03-07  2:43   ` Rob Herring
  2014-03-10 21:28   ` [U-Boot] [U-Boot,v3,2/4] " Tom Rini
  1 sibling, 0 replies; 18+ messages in thread
From: Rob Herring @ 2014-03-07  2:43 UTC (permalink / raw)
  To: u-boot

On Thu, Mar 6, 2014 at 7:20 PM, Ian Campbell <ijc@hellion.org.uk> wrote:
> Signed-off-by: Ian Campbell <ijc@hellion.org.uk>

Acked-by: Rob Herring <robh@kernel.org>

> ---
>  board/highbank/highbank.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/board/highbank/highbank.c b/board/highbank/highbank.c
> index 4b272c7..d42447d 100644
> --- a/board/highbank/highbank.c
> +++ b/board/highbank/highbank.c
> @@ -51,17 +51,23 @@ int board_eth_init(bd_t *bis)
>         return rc;
>  }
>
> -#ifdef CONFIG_MISC_INIT_R
> -int misc_init_r(void)
> +#ifdef CONFIG_SCSI_AHCI_PLAT
> +void scsi_init(void)
>  {
> -       char envbuffer[16];
> -       u32 boot_choice;
>         u32 reg = readl(HB_SREG_A9_PWRDOM_STAT);
>
>         if (reg & PWRDOM_STAT_SATA) {
>                 ahci_init(HB_AHCI_BASE);
>                 scsi_scan(1);
>         }
> +}
> +#endif
> +
> +#ifdef CONFIG_MISC_INIT_R
> +int misc_init_r(void)
> +{
> +       char envbuffer[16];
> +       u32 boot_choice;
>
>         boot_choice = readl(HB_SREG_A9_BOOT_SRC_STAT) & 0xff;
>         sprintf(envbuffer, "bootcmd%d", boot_choice);
> --
> 1.8.5.3
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [linux-sunxi] [PATCH v3 0/4] uboot sata support for sunxi platform
  2014-03-07  1:24 ` [U-Boot] [linux-sunxi] [PATCH v3 0/4] uboot sata support for sunxi platform Ian Campbell
@ 2014-03-07 16:44   ` Ezaul Zillmer
  2014-03-08  4:16     ` Ian Campbell
  0 siblings, 1 reply; 18+ messages in thread
From: Ezaul Zillmer @ 2014-03-07 16:44 UTC (permalink / raw)
  To: u-boot

Hi Ian .. 

You would have a repository with these updates where I could play with git, 
compile and test my cubieboard2 using kernel 3.14.rc5 

I'm waiting! to test your boot! 
thank you

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [linux-sunxi] [PATCH v3 0/4] uboot sata support for sunxi platform
  2014-03-07 16:44   ` Ezaul Zillmer
@ 2014-03-08  4:16     ` Ian Campbell
  2014-03-12 12:43       ` Ezaul Zillmer
  0 siblings, 1 reply; 18+ messages in thread
From: Ian Campbell @ 2014-03-08  4:16 UTC (permalink / raw)
  To: u-boot

On Fri, 2014-03-07 at 08:44 -0800, Ezaul Zillmer wrote:
> You would have a repository with these updates where I could play with
> git, 
> compile and test my cubieboard2 using kernel 3.14.rc5 

git://gitorious.org/ijc/u-boot.git ahci-sunxi

It is based on jwrdegoede/sunxi-next.

Ian.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [U-Boot, v3, 1/4] ahci-plat: Provide a weak scsi_init hook
  2014-03-07  1:20 ` [U-Boot] [PATCH v3 1/4] ahci-plat: Provide a weak scsi_init hook Ian Campbell
@ 2014-03-10 21:27   ` Tom Rini
  0 siblings, 0 replies; 18+ messages in thread
From: Tom Rini @ 2014-03-10 21:27 UTC (permalink / raw)
  To: u-boot

On Fri, Mar 07, 2014 at 01:20:56AM +0000, Ian Campbell wrote:

> This allow the platform to register the platform ahci device.
> 
> Signed-off-by: Ian Campbell <ijc@hellion.org.uk>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140310/5c1f6be8/attachment.pgp>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [U-Boot,v3,2/4] highbank: use scsi_init hook
  2014-03-07  1:20 ` [U-Boot] [PATCH v3 2/4] highbank: use " Ian Campbell
  2014-03-07  2:43   ` Rob Herring
@ 2014-03-10 21:28   ` Tom Rini
  1 sibling, 0 replies; 18+ messages in thread
From: Tom Rini @ 2014-03-10 21:28 UTC (permalink / raw)
  To: u-boot

On Fri, Mar 07, 2014 at 01:20:57AM +0000, Ian Campbell wrote:

> Signed-off-by: Ian Campbell <ijc@hellion.org.uk>
> Acked-by: Rob Herring <robh@kernel.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140310/d17cf9f1/attachment.pgp>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [U-Boot,v3,3/4] ahci: wait longer for link.
  2014-03-07  1:20 ` [U-Boot] [PATCH v3 3/4] ahci: wait longer for link Ian Campbell
@ 2014-03-10 21:28   ` Tom Rini
  0 siblings, 0 replies; 18+ messages in thread
From: Tom Rini @ 2014-03-10 21:28 UTC (permalink / raw)
  To: u-boot

On Fri, Mar 07, 2014 at 01:20:58AM +0000, Ian Campbell wrote:

> I have observed timeouts on a cubietruck.
> 
> The increase to 40ms is completely arbitrary and Works For Me(tm). I
> couldn't find a good reference for how long you are supposed to wait,
> although googling around it seems like tens of ms rather than single
> digits is more common. I don't think there is any harm in waiting a bit
> longer.
> 
> Signed-off-by: Ian Campbell <ijc@hellion.org.uk>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140310/a6b8a0ef/attachment.pgp>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [linux-sunxi] [PATCH v3 0/4] uboot sata support for sunxi platform
  2014-03-08  4:16     ` Ian Campbell
@ 2014-03-12 12:43       ` Ezaul Zillmer
  2014-03-12 12:56         ` Ian Campbell
  0 siblings, 1 reply; 18+ messages in thread
From: Ezaul Zillmer @ 2014-03-12 12:43 UTC (permalink / raw)
  To: u-boot

Hi Ian


U-Boot SPL 2014.01-rc1-gb754a91 (Mar 12 2014 - 09:11:26)
Board: Cubieboard2
DRAM: 1024 MiB
CPU: 960000000Hz, AXI/AHB/APB: 3/2/2
spl: not an uImage at 1600


U-Boot 2014.01-rc1-gb754a91 (Mar 12 2014 - 09:11:26) Allwinner Technology

CPU:   Allwinner A20 (SUN7I)
Board: Cubieboard2
I2C:   ready
DRAM:  1 GiB
WARNING: Caches not enabled
MMC:   SUNXI SD/MMC: 0
SCSI:  SUNXI SCSI INIT
SATA link 0 timeout.
AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl SATA mode
flags: ncq stag pm led clo only pmp pio slum part ccc apst 
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   mii0
Warning: failed to set MAC address

Hit any key to stop autoboot:  0 
** Unrecognized filesystem type **
** File not found boot/uEnv.txt **
** File not found uEnv.txt **
** Unrecognized filesystem type **
414 bytes read in 11 ms (36.1 KiB/s)
Jumping to boot.scr
## Executing script at 44000000
45384 bytes read in 31 ms (1.4 MiB/s)
invalid extent block
invalid extent block
ext4fs_devread read outside partition 4294967120
20752 bytes read in 16 ms (1.2 MiB/s)
Wrong Image Format for bootm command
ERROR: can't get kernel image!
45384 bytes read in 18 ms (2.4 MiB/s)
invalid extent block
invalid extent block
ext4fs_devread read outside partition 4294967120
** Unrecognized filesystem type **
** File not found /script.bin **


 
What is not wrong that the boot SCSI wheel 
Where am I going wrong with leaving boot.cmd? 
use today as well 

boot.cmd 
setenv bootargs console = tty0 console = ttyS0, 115200 = hdmi.audio EDID: 0 
= disp.screen0_output_mode EDID: 1280x800p60 root = / dev/mmcblk0p1 
rootfstype = ext4 rootwait panic = 10 
ext4load mmc 0 0x43000000 boot / script.bin 
ext4load mmc 0 0x46000000 boot / uImage 
ext4load mmc 0 0x49000000 boot/cubie2.dtb 
env September fdt_high ffffffff 
bootm 0x46000000 - 0x49000000 

MMC for swap SCSI? 

It should be assimo Boot.cmd? 

setenv bootargs console = tty0 console = ttyS0, 115200 = hdmi.audio EDID: 0 
= disp.screen0_output_mode EDID: 1280x800p60 root = / dev/sda1 rootfstype = 
ext4 rootwait panic = 10 
ext4load 0 0x43000000 scsi boot / script.bin 
ext4load 0 0x46000000 scsi boot / uImage 
ext4load scsi 0 0x49000000 boot/cubie2.dtb 
env September fdt_high ffffffff 
bootm 0x46000000 - 0x49000000 

I thank 
Hug!




Em s?bado, 8 de mar?o de 2014 01h16min30s UTC-3, Ian Campbell escreveu:
>
> On Fri, 2014-03-07 at 08:44 -0800, Ezaul Zillmer wrote: 
> > You would have a repository with these updates where I could play with 
> > git, 
> > compile and test my cubieboard2 using kernel 3.14.rc5 
>
> git://gitorious.org/ijc/u-boot.git ahci-sunxi 
>
> It is based on jwrdegoede/sunxi-next. 
>
> Ian. 
>
>
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [linux-sunxi] [PATCH v3 0/4] uboot sata support for sunxi platform
  2014-03-12 12:43       ` Ezaul Zillmer
@ 2014-03-12 12:56         ` Ian Campbell
  2014-03-12 13:17           ` Koen Kooi
  2014-03-12 13:53           ` Ezaul Zillmer
  0 siblings, 2 replies; 18+ messages in thread
From: Ian Campbell @ 2014-03-12 12:56 UTC (permalink / raw)
  To: u-boot

On Wed, 2014-03-12 at 05:43 -0700, Ezaul Zillmer wrote:

I'm afraid much of your mail was incomprehensible to me.

> setenv bootargs console = tty0 console = ttyS0, 115200 = hdmi.audio
> EDID: 0 = disp.screen0_output_mode EDID: 1280x800p60 root = / dev/sda1
> rootfstype = ext4 rootwait panic = 10 
> ext4load 0 0x43000000 scsi boot / script.bin 
> ext4load 0 0x46000000 scsi boot / uImage 
> ext4load scsi 0 0x49000000 boot/cubie2.dtb 

The first two and the last one are using a totally different syntax,
only one of them can be correct, I suggest you check the uboot help/docs
and experiment by hand on the uboot console before trying to construct a
boot.scr.

> env September fdt_high ffffffff 

WTF?

Ian.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [linux-sunxi] [PATCH v3 0/4] uboot sata support for sunxi platform
  2014-03-12 12:56         ` Ian Campbell
@ 2014-03-12 13:17           ` Koen Kooi
  2014-03-12 15:04             ` Ian Campbell
  2014-03-12 13:53           ` Ezaul Zillmer
  1 sibling, 1 reply; 18+ messages in thread
From: Koen Kooi @ 2014-03-12 13:17 UTC (permalink / raw)
  To: u-boot


Op 12 mrt. 2014, om 13:56 heeft Ian Campbell <ijc@hellion.org.uk> het volgende geschreven:

> On Wed, 2014-03-12 at 05:43 -0700, Ezaul Zillmer wrote:
> 
> I'm afraid much of your mail was incomprehensible to me.
> 
>> setenv bootargs console = tty0 console = ttyS0, 115200 = hdmi.audio
>> EDID: 0 = disp.screen0_output_mode EDID: 1280x800p60 root = / dev/sda1
>> rootfstype = ext4 rootwait panic = 10 
>> ext4load 0 0x43000000 scsi boot / script.bin 
>> ext4load 0 0x46000000 scsi boot / uImage 
>> ext4load scsi 0 0x49000000 boot/cubie2.dtb 
> 
> The first two and the last one are using a totally different syntax,
> only one of them can be correct, I suggest you check the uboot help/docs
> and experiment by hand on the uboot console before trying to construct a
> boot.scr.

I've noticed 'ext4load' twice today, once in the mail above and once in the 'fedora on panda' blog post. What's stopping people from using the generic 'fsload' commands?

regards,

Koen

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [linux-sunxi] [PATCH v3 0/4] uboot sata support for sunxi platform
  2014-03-12 12:56         ` Ian Campbell
  2014-03-12 13:17           ` Koen Kooi
@ 2014-03-12 13:53           ` Ezaul Zillmer
  2014-03-12 15:57             ` Ian Campbell
  1 sibling, 1 reply; 18+ messages in thread
From: Ezaul Zillmer @ 2014-03-12 13:53 UTC (permalink / raw)
  To: u-boot


>
> sun7i# scsi reset
>
> Reset SCSI
> scanning bus for devices...
> timeout exit!
> Found 0 device(s).
>
> this same problem not think that the drive to boot 
>
> Nothing appears scsi info
>
> :( 
> I will try to put another HD
>
> Loading the kernel 
> [3.723244] ata1.00: ATA-8: SAMSUNG HM320II, 2AC101C4, max UDMA/133 
> [3.729646] ata1.00: 625142448 sectors, multi 0: LBA48 NCQ (depth 31/32) 
> [3.748349] ata1.00: configured for UDMA/133 
> [3.752698] ATA1: EH complete 
> [3.756157] scsi 0:0:0:0: Direct-Access ATA SAMSUNG HM320II 2AC1 PQ: 0 
> ANSI: 5 
> [3.767627] sd 0:0:0:0: [sda] 625142448 512-byte logical blocks: (320 
> GB/298 GiB) 
> [3.787130] sd 0:0:0:0: [sda] Write Protect is off 
> [3.796692] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, 
> does not support DPO or FUA 
> [3.827250] sda: sda1 
> [3.836155] sd 0:0:0:0: [sda] Attached SCSI disk 
> done. 
>
>
> Ezaul Zillmer
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [linux-sunxi] [PATCH v3 0/4] uboot sata support for sunxi platform
  2014-03-12 13:17           ` Koen Kooi
@ 2014-03-12 15:04             ` Ian Campbell
  0 siblings, 0 replies; 18+ messages in thread
From: Ian Campbell @ 2014-03-12 15:04 UTC (permalink / raw)
  To: u-boot

On Wed, 2014-03-12 at 14:17 +0100, Koen Kooi wrote:
> Op 12 mrt. 2014, om 13:56 heeft Ian Campbell <ijc@hellion.org.uk> het volgende geschreven:
> 
> > On Wed, 2014-03-12 at 05:43 -0700, Ezaul Zillmer wrote:
> > 
> > I'm afraid much of your mail was incomprehensible to me.
> > 
> >> setenv bootargs console = tty0 console = ttyS0, 115200 = hdmi.audio
> >> EDID: 0 = disp.screen0_output_mode EDID: 1280x800p60 root = / dev/sda1
> >> rootfstype = ext4 rootwait panic = 10 
> >> ext4load 0 0x43000000 scsi boot / script.bin 
> >> ext4load 0 0x46000000 scsi boot / uImage 
> >> ext4load scsi 0 0x49000000 boot/cubie2.dtb 
> > 
> > The first two and the last one are using a totally different syntax,
> > only one of them can be correct, I suggest you check the uboot help/docs
> > and experiment by hand on the uboot console before trying to construct a
> > boot.scr.
> 
> I've noticed 'ext4load' twice today, once in the mail above and once
> in the 'fedora on panda' blog post. What's stopping people from using
> the generic 'fsload' commands?

Personally because I'd never heard of it ;-)

Ian.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [linux-sunxi] [PATCH v3 0/4] uboot sata support for sunxi platform
  2014-03-12 13:53           ` Ezaul Zillmer
@ 2014-03-12 15:57             ` Ian Campbell
  0 siblings, 0 replies; 18+ messages in thread
From: Ian Campbell @ 2014-03-12 15:57 UTC (permalink / raw)
  To: u-boot

On Wed, 2014-03-12 at 06:53 -0700, Ezaul Zillmer wrote:
>         
>         Nothing appears scsi info

Perhaps try increasing WAIT_MS_LINKUP some more (as per patch 3/4)?

Ian.

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2014-03-12 15:57 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-07  1:19 [U-Boot] [PATCH v3 0/4] uboot sata support for sunxi platform Ian Campbell
2014-03-07  1:20 ` [U-Boot] [PATCH v3 1/4] ahci-plat: Provide a weak scsi_init hook Ian Campbell
2014-03-10 21:27   ` [U-Boot] [U-Boot, v3, " Tom Rini
2014-03-07  1:20 ` [U-Boot] [PATCH v3 2/4] highbank: use " Ian Campbell
2014-03-07  2:43   ` Rob Herring
2014-03-10 21:28   ` [U-Boot] [U-Boot,v3,2/4] " Tom Rini
2014-03-07  1:20 ` [U-Boot] [PATCH v3 3/4] ahci: wait longer for link Ian Campbell
2014-03-10 21:28   ` [U-Boot] [U-Boot,v3,3/4] " Tom Rini
2014-03-07  1:20 ` [U-Boot] [PATCH v3 4/4] ahci: provide sunxi SATA driver using AHCI platform framework Ian Campbell
2014-03-07  1:24 ` [U-Boot] [linux-sunxi] [PATCH v3 0/4] uboot sata support for sunxi platform Ian Campbell
2014-03-07 16:44   ` Ezaul Zillmer
2014-03-08  4:16     ` Ian Campbell
2014-03-12 12:43       ` Ezaul Zillmer
2014-03-12 12:56         ` Ian Campbell
2014-03-12 13:17           ` Koen Kooi
2014-03-12 15:04             ` Ian Campbell
2014-03-12 13:53           ` Ezaul Zillmer
2014-03-12 15:57             ` Ian Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.