From: Rob Herring <robherring2@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/7] ahci: move link bring-up handling to separate function
Date: Tue, 21 May 2013 17:44:33 -0500 [thread overview]
Message-ID: <1369176276-1895-4-git-send-email-robherring2@gmail.com> (raw)
In-Reply-To: <1369176276-1895-1-git-send-email-robherring2@gmail.com>
From: Rob Herring <rob.herring@calxeda.com>
Move the link bring-up handling to a separate weak function in order to
allow platforms to override it. This is needed on highbank platform which
needs special phy handling.
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
drivers/block/ahci.c | 39 +++++++++++++++++++++++++--------------
1 file changed, 25 insertions(+), 14 deletions(-)
diff --git a/drivers/block/ahci.c b/drivers/block/ahci.c
index a2aa433..79710ef 100644
--- a/drivers/block/ahci.c
+++ b/drivers/block/ahci.c
@@ -124,6 +124,27 @@ static int waiting_for_cmd_completed(volatile u8 *offset,
return (i < timeout_msec) ? 0 : -1;
}
+static int __ahci_link_up(struct ahci_probe_ent *probe_ent, u8 port)
+{
+ u32 tmp;
+ int j = 0;
+ u8 *port_mmio = (u8 *)probe_ent->port[port].port_mmio;
+
+ /* Bring up SATA link.
+ * SATA link bringup time is usually less than 1 ms; only very
+ * rarely has it taken between 1-2 ms. Never seen it above 2 ms.
+ */
+ while (j < WAIT_MS_LINKUP) {
+ tmp = readl(port_mmio + PORT_SCR_STAT);
+ if ((tmp & 0xf) == 0x3)
+ return 0;
+ udelay(1000);
+ j++;
+ }
+ return 1;
+}
+int ahci_link_up(struct ahci_probe_ent *probe_ent, u8 port)
+ __attribute__((weak, alias("__ahci_link_up")));
static int ahci_host_init(struct ahci_probe_ent *probe_ent)
{
@@ -134,7 +155,7 @@ static int ahci_host_init(struct ahci_probe_ent *probe_ent)
#endif
volatile u8 *mmio = (volatile u8 *)probe_ent->mmio_base;
u32 tmp, cap_save, cmd;
- int i, j;
+ int i, j, ret;
volatile u8 *port_mmio;
u32 port_map;
@@ -217,19 +238,9 @@ static int ahci_host_init(struct ahci_probe_ent *probe_ent)
cmd |= PORT_CMD_SPIN_UP;
writel_with_flush(cmd, port_mmio + PORT_CMD);
- /* Bring up SATA link.
- * SATA link bringup time is usually less than 1 ms; only very
- * rarely has it taken between 1-2 ms. Never seen it above 2 ms.
- */
- j = 0;
- while (j < WAIT_MS_LINKUP) {
- tmp = readl(port_mmio + PORT_SCR_STAT);
- if ((tmp & 0xf) == 0x3)
- break;
- udelay(1000);
- j++;
- }
- if (j == WAIT_MS_LINKUP) {
+ /* Bring up SATA link. */
+ ret = ahci_link_up(probe_ent, i);
+ if (ret) {
printf("SATA link %d timeout.\n", i);
continue;
} else {
--
1.8.1.2
next prev parent reply other threads:[~2013-05-21 22:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-21 22:44 [U-Boot] [PATCH 1/7] ahci: use ports implemented map instead of num_ports Rob Herring
2013-05-21 22:44 ` [U-Boot] [PATCH 2/7] ahci: fix unaligned access Rob Herring
2013-05-24 13:45 ` Tom Rini
2013-05-24 18:35 ` Wolfgang Denk
2013-05-21 22:44 ` [U-Boot] [PATCH 3/7] ahci: fix memory leak in ata_scsiop_inquiry Rob Herring
2013-05-24 13:46 ` Tom Rini
2013-05-21 22:44 ` Rob Herring [this message]
2013-05-24 13:44 ` [U-Boot] [PATCH 4/7] ahci: move link bring-up handling to separate function Tom Rini
2013-05-21 22:44 ` [U-Boot] [PATCH 5/7] ahci: handle COMINIT received during spin-up Rob Herring
2013-05-24 13:47 ` Tom Rini
2013-05-21 22:44 ` [U-Boot] [PATCH 6/7] ahci: increase spin-up timeout to 20 sec Rob Herring
2013-05-24 13:51 ` Tom Rini
2013-05-21 22:44 ` [U-Boot] [PATCH 7/7] ahci: convert to use libata functions and definitions Rob Herring
2013-05-24 13:53 ` Tom Rini
2013-05-24 13:45 ` [U-Boot] [PATCH 1/7] ahci: use ports implemented map instead of num_ports Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1369176276-1895-4-git-send-email-robherring2@gmail.com \
--to=robherring2@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox