Patchwork [U-Boot,1/7] ahci: use ports implemented map instead of num_ports

login
register
mail settings
Submitter Rob Herring
Date May 21, 2013, 10:44 p.m.
Message ID <1369176276-1895-1-git-send-email-robherring2@gmail.com>
Download mbox | patch
Permalink /patch/245439/
State Superseded
Delegated to: Tom Rini
Headers show

Comments

Rob Herring - May 21, 2013, 10:44 p.m.
From: Richard Gibbs <richard.gibbs@calxeda.com>

The AHCI driver was incorrectly using the Capabilities register NP (number
of ports) field to determine which ports to activate. This commit changes
it to correctly use the PORTS_IMPL register as a port map.

Signed-off-by: Richard Gibbs <richard.gibbs@calxeda.com>
---
 drivers/block/ahci.c | 4 ++++
 1 file changed, 4 insertions(+)
Tom Rini - May 24, 2013, 1:45 p.m.
On Tue, May 21, 2013 at 05:44:30PM -0500, Rob Herring wrote:

> From: Richard Gibbs <richard.gibbs@calxeda.com>
> 
> The AHCI driver was incorrectly using the Capabilities register NP (number
> of ports) field to determine which ports to activate. This commit changes
> it to correctly use the PORTS_IMPL register as a port map.
> 
> Signed-off-by: Richard Gibbs <richard.gibbs@calxeda.com>

Reviewed-by: Tom Rini <trini@ti.com>

Patch

diff --git a/drivers/block/ahci.c b/drivers/block/ahci.c
index cab7f8c..b89be06 100644
--- a/drivers/block/ahci.c
+++ b/drivers/block/ahci.c
@@ -136,6 +136,7 @@  static int ahci_host_init(struct ahci_probe_ent *probe_ent)
 	u32 tmp, cap_save, cmd;
 	int i, j;
 	volatile u8 *port_mmio;
+	u32 port_map;
 
 	debug("ahci_host_init: start\n");
 
@@ -177,6 +178,7 @@  static int ahci_host_init(struct ahci_probe_ent *probe_ent)
 #endif
 	probe_ent->cap = readl(mmio + HOST_CAP);
 	probe_ent->port_map = readl(mmio + HOST_PORTS_IMPL);
+	port_map = probe_ent->port_map;
 	probe_ent->n_ports = (probe_ent->cap & 0x1f) + 1;
 
 	debug("cap 0x%x  port_map 0x%x  n_ports %d\n",
@@ -186,6 +188,8 @@  static int ahci_host_init(struct ahci_probe_ent *probe_ent)
 		probe_ent->n_ports = CONFIG_SYS_SCSI_MAX_SCSI_ID;
 
 	for (i = 0; i < probe_ent->n_ports; i++) {
+		if (!(port_map & (1 << i)))
+			continue;
 		probe_ent->port[i].port_mmio = ahci_port_base((u32) mmio, i);
 		port_mmio = (u8 *) probe_ent->port[i].port_mmio;
 		ahci_setup_port(&probe_ent->port[i], (unsigned long)mmio, i);