svn commit: r189794 - in user/mav/ata/sys/dev/ata: . chipsets
Alexander Motin
mav at FreeBSD.org
Sat Mar 14 08:32:05 PDT 2009
Author: mav
Date: Sat Mar 14 15:32:04 2009
New Revision: 189794
URL: http://svn.freebsd.org/changeset/base/189794
Log:
Unify ata_sata_phy_reset() function to allow it be used for port multiplier
ports. Make it's legacy behaviour of not resetting connected ports
controllable.
Modified:
user/mav/ata/sys/dev/ata/ata-pci.h
user/mav/ata/sys/dev/ata/ata-sata.c
user/mav/ata/sys/dev/ata/chipsets/ata-ahci.c
user/mav/ata/sys/dev/ata/chipsets/ata-intel.c
user/mav/ata/sys/dev/ata/chipsets/ata-marvell.c
user/mav/ata/sys/dev/ata/chipsets/ata-nvidia.c
user/mav/ata/sys/dev/ata/chipsets/ata-promise.c
user/mav/ata/sys/dev/ata/chipsets/ata-siliconimage.c
user/mav/ata/sys/dev/ata/chipsets/ata-sis.c
user/mav/ata/sys/dev/ata/chipsets/ata-via.c
Modified: user/mav/ata/sys/dev/ata/ata-pci.h
==============================================================================
--- user/mav/ata/sys/dev/ata/ata-pci.h Sat Mar 14 15:25:05 2009 (r189793)
+++ user/mav/ata/sys/dev/ata/ata-pci.h Sat Mar 14 15:32:04 2009 (r189794)
@@ -443,7 +443,9 @@ int ata_mode2idx(int mode);
/* global prototypes ata-sata.c */
void ata_sata_phy_check_events(device_t dev);
-int ata_sata_phy_reset(device_t dev);
+int ata_sata_scr_read(struct ata_channel *ch, int port, int reg, uint32_t *val);
+int ata_sata_scr_write(struct ata_channel *ch, int port, int reg, uint32_t val);
+int ata_sata_phy_reset(device_t dev, int port, int quick);
void ata_sata_setmode(device_t dev, int mode);
int ata_request2fis_h2d(struct ata_request *request, u_int8_t *fis);
void ata_pm_identify(device_t dev);
Modified: user/mav/ata/sys/dev/ata/ata-sata.c
==============================================================================
--- user/mav/ata/sys/dev/ata/ata-sata.c Sat Mar 14 15:25:05 2009 (r189793)
+++ user/mav/ata/sys/dev/ata/ata-sata.c Sat Mar 14 15:32:04 2009 (r189794)
@@ -73,59 +73,128 @@ ata_sata_phy_check_events(device_t dev)
}
}
+int
+ata_sata_scr_read(struct ata_channel *ch, int port, int reg, uint32_t *val)
+{
+ int r;
+
+ if (port < 0) {
+ *val = ATA_IDX_INL(ch, reg);
+ return (0);
+ } else {
+ switch (reg) {
+ case ATA_SSTATUS:
+ r = 0;
+ break;
+ case ATA_SERROR:
+ r = 1;
+ break;
+ case ATA_SCONTROL:
+ r = 2;
+ break;
+ default:
+ return (EINVAL);
+ }
+ return (ch->hw.pm_read(ch->dev, port, r, val));
+ }
+}
+
+int
+ata_sata_scr_write(struct ata_channel *ch, int port, int reg, uint32_t val)
+{
+ int r;
+
+ if (port < 0) {
+ ATA_IDX_OUTL(ch, reg, val);
+ return (0);
+ } else {
+ switch (reg) {
+ case ATA_SERROR:
+ r = 1;
+ break;
+ case ATA_SCONTROL:
+ r = 2;
+ break;
+ default:
+ return (EINVAL);
+ }
+ return (ch->hw.pm_write(ch->dev, port, r, val));
+ }
+}
+
static int
-ata_sata_connect(struct ata_channel *ch)
+ata_sata_connect(struct ata_channel *ch, int port)
{
u_int32_t status;
int timeout;
/* wait up to 1 second for "connect well" */
for (timeout = 0; timeout < 100 ; timeout++) {
- status = ATA_IDX_INL(ch, ATA_SSTATUS);
+ ata_sata_scr_read(ch, port, ATA_SSTATUS, &status);
if ((status & ATA_SS_CONWELL_MASK) == ATA_SS_CONWELL_GEN1 ||
(status & ATA_SS_CONWELL_MASK) == ATA_SS_CONWELL_GEN2)
break;
ata_udelay(10000);
}
if (timeout >= 100) {
- if (bootverbose)
- device_printf(ch->dev, "SATA connect status=%08x\n", status);
+ if (bootverbose) {
+ if (port < 0) {
+ device_printf(ch->dev, "SATA connect timeout status=%08x\n",
+ status);
+ } else {
+ device_printf(ch->dev, "p%d: SATA connect timeout status=%08x\n",
+ port, status);
+ }
+ }
return 0;
}
- if (bootverbose)
- device_printf(ch->dev, "SATA connect time=%dms\n", timeout * 10);
+ if (bootverbose) {
+ if (port < 0) {
+ device_printf(ch->dev, "SATA connect time=%dms status=%08x\n",
+ timeout * 10, status);
+ } else {
+ device_printf(ch->dev, "p%d: SATA connect time=%dms status=%08x\n",
+ port, timeout * 10, status);
+ }
+ }
/* clear SATA error register */
- ATA_IDX_OUTL(ch, ATA_SERROR, ATA_IDX_INL(ch, ATA_SERROR));
+ ata_sata_scr_write(ch, port, ATA_SERROR, 0xffffffff);
return 1;
}
int
-ata_sata_phy_reset(device_t dev)
+ata_sata_phy_reset(device_t dev, int port, int quick)
{
struct ata_channel *ch = device_get_softc(dev);
int loop, retry;
+ uint32_t val;
- if ((ATA_IDX_INL(ch, ATA_SCONTROL) & ATA_SC_DET_MASK) == ATA_SC_DET_IDLE)
- return ata_sata_connect(ch);
+ if (quick) {
+ ata_sata_scr_read(ch, port, ATA_SCONTROL, &val);
+ if ((val & ATA_SC_DET_MASK) == ATA_SC_DET_IDLE)
+ return ata_sata_connect(ch, port);
+ }
for (retry = 0; retry < 10; retry++) {
for (loop = 0; loop < 10; loop++) {
- ATA_IDX_OUTL(ch, ATA_SCONTROL, ATA_SC_DET_RESET);
+ ata_sata_scr_write(ch, port, ATA_SCONTROL, ATA_SC_DET_RESET);
ata_udelay(100);
- if ((ATA_IDX_INL(ch, ATA_SCONTROL) & ATA_SC_DET_MASK) ==
- ATA_SC_DET_RESET)
+ ata_sata_scr_read(ch, port, ATA_SCONTROL, &val);
+ if ((val & ATA_SC_DET_MASK) == ATA_SC_DET_RESET)
break;
}
ata_udelay(5000);
for (loop = 0; loop < 10; loop++) {
- ATA_IDX_OUTL(ch, ATA_SCONTROL, ATA_SC_DET_IDLE |
- ATA_SC_IPM_DIS_PARTIAL |
- ATA_SC_IPM_DIS_SLUMBER);
+ ata_sata_scr_write(ch, port, ATA_SCONTROL,
+ ATA_SC_DET_IDLE |
+ ATA_SC_IPM_DIS_PARTIAL |
+ ATA_SC_IPM_DIS_SLUMBER);
ata_udelay(100);
- if ((ATA_IDX_INL(ch, ATA_SCONTROL) & ATA_SC_DET_MASK) == 0)
- return ata_sata_connect(ch);
+ ata_sata_scr_read(ch, port, ATA_SCONTROL, &val);
+ if ((val & ATA_SC_DET_MASK) == 0)
+ return ata_sata_connect(ch, port);
}
}
return 0;
@@ -253,41 +322,10 @@ ata_pm_identify(device_t dev)
/* reset all ports and register if anything connected */
for (port=0; port < pm_ports; port++) {
- u_int32_t signature, status;
- int timeout;
-
- if (ch->hw.pm_write(dev, port, 2, ATA_SC_DET_RESET)) {
- device_printf(dev, "p%d: writing ATA_SC_DET_RESET failed\n", port);
- continue;
- }
-
- ata_udelay(5000);
+ u_int32_t signature;
- if (ch->hw.pm_write(dev, port, 2, ATA_SC_DET_IDLE)) {
- device_printf(dev, "p%d: writing ATA_SC_DET_idle failed\n", port);
+ if (!ata_sata_phy_reset(dev, port, 1))
continue;
- }
-
- ata_udelay(5000);
-
- /* wait up to 1 second for "connect well" */
- for (timeout = 0; timeout < 100 ; timeout++) {
- ch->hw.pm_read(dev, port, 0, &status);
- if ((status & ATA_SS_CONWELL_MASK) == ATA_SS_CONWELL_GEN1 ||
- (status & ATA_SS_CONWELL_MASK) == ATA_SS_CONWELL_GEN2)
- break;
- ata_udelay(10000);
- }
- if (timeout >= 100) {
- if (bootverbose)
- device_printf(dev, "p%d: connect status=%08x\n", port, status);
- continue;
- }
- if (bootverbose)
- device_printf(dev, "p%d: connect time %dms\n", port, timeout * 10);
-
- /* clear SERROR register */
- ch->hw.pm_write(dev, port, 1, 0xffffffff);
signature = ch->hw.softreset(dev, port);
Modified: user/mav/ata/sys/dev/ata/chipsets/ata-ahci.c
==============================================================================
--- user/mav/ata/sys/dev/ata/chipsets/ata-ahci.c Sat Mar 14 15:25:05 2009 (r189793)
+++ user/mav/ata/sys/dev/ata/chipsets/ata-ahci.c Sat Mar 14 15:32:04 2009 (r189794)
@@ -722,7 +722,7 @@ ata_ahci_reset(device_t dev)
/* enable FIS based switching */
//ATA_OUTL(ctlr->r_res2, ATA_AHCI_P_FBS + offset, 0x00000003);
- if (!ata_sata_phy_reset(dev)) {
+ if (!ata_sata_phy_reset(dev, -1, 0)) {
if (bootverbose)
device_printf(dev, "AHCI reset done: phy reset found no device\n");
ch->devices = 0;
Modified: user/mav/ata/sys/dev/ata/chipsets/ata-intel.c
==============================================================================
--- user/mav/ata/sys/dev/ata/chipsets/ata-intel.c Sat Mar 14 15:25:05 2009 (r189793)
+++ user/mav/ata/sys/dev/ata/chipsets/ata-intel.c Sat Mar 14 15:32:04 2009 (r189794)
@@ -517,7 +517,7 @@ ata_intel_31244_tf_write(struct ata_requ
static void
ata_intel_31244_reset(device_t dev)
{
- if (ata_sata_phy_reset(dev))
+ if (ata_sata_phy_reset(dev, -1, 1))
ata_generic_reset(dev);
}
Modified: user/mav/ata/sys/dev/ata/chipsets/ata-marvell.c
==============================================================================
--- user/mav/ata/sys/dev/ata/chipsets/ata-marvell.c Sat Mar 14 15:25:05 2009 (r189793)
+++ user/mav/ata/sys/dev/ata/chipsets/ata-marvell.c Sat Mar 14 15:32:04 2009 (r189794)
@@ -503,7 +503,7 @@ ata_marvell_edma_reset(device_t dev)
ATA_OUTL(ctlr->r_res1, 0x0200c + ATA_MV_EDMA_BASE(ch), ~0x0);
/* enable channel and test for devices */
- if (ata_sata_phy_reset(dev))
+ if (ata_sata_phy_reset(dev, -1, 1))
ata_generic_reset(dev);
/* enable EDMA machinery */
Modified: user/mav/ata/sys/dev/ata/chipsets/ata-nvidia.c
==============================================================================
--- user/mav/ata/sys/dev/ata/chipsets/ata-nvidia.c Sat Mar 14 15:25:05 2009 (r189793)
+++ user/mav/ata/sys/dev/ata/chipsets/ata-nvidia.c Sat Mar 14 15:32:04 2009 (r189794)
@@ -249,7 +249,7 @@ ata_nvidia_status(device_t dev)
static void
ata_nvidia_reset(device_t dev)
{
- if (ata_sata_phy_reset(dev))
+ if (ata_sata_phy_reset(dev, -1, 1))
ata_generic_reset(dev);
}
Modified: user/mav/ata/sys/dev/ata/chipsets/ata-promise.c
==============================================================================
--- user/mav/ata/sys/dev/ata/chipsets/ata-promise.c Sat Mar 14 15:25:05 2009 (r189793)
+++ user/mav/ata/sys/dev/ata/chipsets/ata-promise.c Sat Mar 14 15:32:04 2009 (r189794)
@@ -769,7 +769,7 @@ ata_promise_mio_reset(device_t dev)
if ((ctlr->chip->cfg2 == PR_SATA) ||
((ctlr->chip->cfg2 == PR_CMBO) && (ch->unit < 2))) {
- if (ata_sata_phy_reset(dev))
+ if (ata_sata_phy_reset(dev, -1, 1))
ata_generic_reset(dev);
/* reset and enable plug/unplug intr */
@@ -805,7 +805,7 @@ ata_promise_mio_reset(device_t dev)
(ATA_INL(ctlr->r_res2, 0x414 + (ch->unit << 8)) &
~0x00000003) | 0x00000001);
- if (ata_sata_phy_reset(dev)) {
+ if (ata_sata_phy_reset(dev, -1, 1)) {
u_int32_t signature = ch->hw.softreset(dev, ATA_PM);
if (1 | bootverbose)
Modified: user/mav/ata/sys/dev/ata/chipsets/ata-siliconimage.c
==============================================================================
--- user/mav/ata/sys/dev/ata/chipsets/ata-siliconimage.c Sat Mar 14 15:25:05 2009 (r189793)
+++ user/mav/ata/sys/dev/ata/chipsets/ata-siliconimage.c Sat Mar 14 15:32:04 2009 (r189794)
@@ -380,7 +380,7 @@ ata_sii_status(device_t dev)
static void
ata_sii_reset(device_t dev)
{
- if (ata_sata_phy_reset(dev))
+ if (ata_sata_phy_reset(dev, -1, 1))
ata_generic_reset(dev);
}
@@ -832,7 +832,7 @@ ata_siiprb_reset(device_t dev)
}
/* reset phy */
- if (!ata_sata_phy_reset(dev)) {
+ if (!ata_sata_phy_reset(dev, -1, 1)) {
if (bootverbose)
device_printf(dev, "phy reset found no device\n");
ch->devices = 0;
Modified: user/mav/ata/sys/dev/ata/chipsets/ata-sis.c
==============================================================================
--- user/mav/ata/sys/dev/ata/chipsets/ata-sis.c Sat Mar 14 15:25:05 2009 (r189793)
+++ user/mav/ata/sys/dev/ata/chipsets/ata-sis.c Sat Mar 14 15:32:04 2009 (r189794)
@@ -226,7 +226,7 @@ ata_sis_ch_attach(device_t dev)
static void
ata_sis_reset(device_t dev)
{
- if (ata_sata_phy_reset(dev))
+ if (ata_sata_phy_reset(dev, -1, 1))
ata_generic_reset(dev);
}
Modified: user/mav/ata/sys/dev/ata/chipsets/ata-via.c
==============================================================================
--- user/mav/ata/sys/dev/ata/chipsets/ata-via.c Sat Mar 14 15:25:05 2009 (r189793)
+++ user/mav/ata/sys/dev/ata/chipsets/ata-via.c Sat Mar 14 15:32:04 2009 (r189794)
@@ -269,7 +269,7 @@ ata_via_reset(device_t dev)
if ((ctlr->chip->cfg2 & VIABAR) && (ch->unit > 1))
ata_generic_reset(dev);
else
- if (ata_sata_phy_reset(dev))
+ if (ata_sata_phy_reset(dev, -1, 1))
ata_generic_reset(dev);
}
More information about the svn-src-user
mailing list