Commit 76a250f9 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata

Pull libata updates from Tejun Heo:
 "Nothing too interesting. Several patches to convert mdelay() to
  usleep_range(), removal of unused pata_at32, and other low level
  driver specific changes"

* 'for-4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata:
  ata: pata_pdc2027x: Replace mdelay with msleep
  ata: pata_it821x: Replace mdelay with usleep_range in it821x_firmware_command
  ata: sata_mv: Replace mdelay with usleep_range in mv_reset_channel
  ata: remove pata_at32
  phy: brcm-sata: remove unused variable
  phy: brcm-sata: fix semicolon.cocci warnings
  ata: ahci_brcm: Recover from failures to identify devices
  phy: brcm-sata: Implement calibrate callback
  ahci: Add Intel Cannon Lake PCH-H PCI ID
  ata_piix: constify pci_bits
  libata:pata_atiixp: Don't use unconnected secondary port on SB600
  ata: ahci_brcm: Avoid clobbering SATA_TOP_CTRL_BUS_CTRL
  ahci: Allow setting a default LPM policy for mobile chipsets
  ahci: Add PCI ids for Intel Bay Trail, Cherry Trail and Apollo Lake AHCI
  ahci: Annotate PCI ids for mobile Intel chipsets as such
parents f8cc87b6 b3506c7e
...@@ -92,6 +92,25 @@ config SATA_AHCI ...@@ -92,6 +92,25 @@ config SATA_AHCI
If unsure, say N. If unsure, say N.
config SATA_MOBILE_LPM_POLICY
int "Default SATA Link Power Management policy for mobile chipsets"
range 0 4
default 0
depends on SATA_AHCI
help
Select the Default SATA Link Power Management (LPM) policy to use
for mobile / laptop variants of chipsets / "South Bridges".
The value set has the following meanings:
0 => Keep firmware settings
1 => Maximum performance
2 => Medium power
3 => Medium power with Device Initiated PM enabled
4 => Minimum power
Note "Minimum power" is known to cause issues, including disk
corruption, with some disks and should not be used.
config SATA_AHCI_PLATFORM config SATA_AHCI_PLATFORM
tristate "Platform AHCI SATA support" tristate "Platform AHCI SATA support"
help help
...@@ -925,15 +944,6 @@ endif # ATA_BMDMA ...@@ -925,15 +944,6 @@ endif # ATA_BMDMA
comment "PIO-only SFF controllers" comment "PIO-only SFF controllers"
config PATA_AT32
tristate "Atmel AVR32 PATA support (Experimental)"
depends on AVR32 && PLATFORM_AT32AP
help
This option enables support for the IDE devices on the
Atmel AT32AP platform.
If unsure, say N.
config PATA_CMD640_PCI config PATA_CMD640_PCI
tristate "CMD640 PCI PATA support (Experimental)" tristate "CMD640 PCI PATA support (Experimental)"
depends on PCI depends on PCI
......
...@@ -96,7 +96,6 @@ obj-$(CONFIG_PATA_VIA) += pata_via.o ...@@ -96,7 +96,6 @@ obj-$(CONFIG_PATA_VIA) += pata_via.o
obj-$(CONFIG_PATA_WINBOND) += pata_sl82c105.o obj-$(CONFIG_PATA_WINBOND) += pata_sl82c105.o
# SFF PIO only # SFF PIO only
obj-$(CONFIG_PATA_AT32) += pata_at32.o
obj-$(CONFIG_PATA_CMD640_PCI) += pata_cmd640.o obj-$(CONFIG_PATA_CMD640_PCI) += pata_cmd640.o
obj-$(CONFIG_PATA_FALCON) += pata_falcon.o obj-$(CONFIG_PATA_FALCON) += pata_falcon.o
obj-$(CONFIG_PATA_ISAPNP) += pata_isapnp.o obj-$(CONFIG_PATA_ISAPNP) += pata_isapnp.o
......
This diff is collapsed.
...@@ -251,6 +251,9 @@ enum { ...@@ -251,6 +251,9 @@ enum {
AHCI_HFLAG_YES_ALPM = (1 << 23), /* force ALPM cap on */ AHCI_HFLAG_YES_ALPM = (1 << 23), /* force ALPM cap on */
AHCI_HFLAG_NO_WRITE_TO_RO = (1 << 24), /* don't write to read AHCI_HFLAG_NO_WRITE_TO_RO = (1 << 24), /* don't write to read
only registers */ only registers */
AHCI_HFLAG_IS_MOBILE = (1 << 25), /* mobile chipset, use
SATA_MOBILE_LPM_POLICY
as default lpm_policy */
/* ap->flags bits */ /* ap->flags bits */
......
...@@ -70,6 +70,13 @@ ...@@ -70,6 +70,13 @@
(DATA_ENDIAN << DMADESC_ENDIAN_SHIFT) | \ (DATA_ENDIAN << DMADESC_ENDIAN_SHIFT) | \
(MMIO_ENDIAN << MMIO_ENDIAN_SHIFT)) (MMIO_ENDIAN << MMIO_ENDIAN_SHIFT))
#define BUS_CTRL_ENDIAN_NSP_CONF \
(0x02 << DMADATA_ENDIAN_SHIFT | 0x02 << DMADESC_ENDIAN_SHIFT)
#define BUS_CTRL_ENDIAN_CONF_MASK \
(0x3 << MMIO_ENDIAN_SHIFT | 0x3 << DMADESC_ENDIAN_SHIFT | \
0x3 << DMADATA_ENDIAN_SHIFT | 0x3 << PIODATA_ENDIAN_SHIFT)
enum brcm_ahci_version { enum brcm_ahci_version {
BRCM_SATA_BCM7425 = 1, BRCM_SATA_BCM7425 = 1,
BRCM_SATA_BCM7445, BRCM_SATA_BCM7445,
...@@ -89,14 +96,6 @@ struct brcm_ahci_priv { ...@@ -89,14 +96,6 @@ struct brcm_ahci_priv {
enum brcm_ahci_version version; enum brcm_ahci_version version;
}; };
static const struct ata_port_info ahci_brcm_port_info = {
.flags = AHCI_FLAG_COMMON | ATA_FLAG_NO_DIPM,
.link_flags = ATA_LFLAG_NO_DB_DELAY,
.pio_mask = ATA_PIO4,
.udma_mask = ATA_UDMA6,
.port_ops = &ahci_platform_ops,
};
static inline u32 brcm_sata_readreg(void __iomem *addr) static inline u32 brcm_sata_readreg(void __iomem *addr)
{ {
/* /*
...@@ -250,20 +249,105 @@ static u32 brcm_ahci_get_portmask(struct platform_device *pdev, ...@@ -250,20 +249,105 @@ static u32 brcm_ahci_get_portmask(struct platform_device *pdev,
static void brcm_sata_init(struct brcm_ahci_priv *priv) static void brcm_sata_init(struct brcm_ahci_priv *priv)
{ {
void __iomem *ctrl = priv->top_ctrl + SATA_TOP_CTRL_BUS_CTRL; void __iomem *ctrl = priv->top_ctrl + SATA_TOP_CTRL_BUS_CTRL;
u32 data;
/* Configure endianness */ /* Configure endianness */
if (priv->version == BRCM_SATA_NSP) { data = brcm_sata_readreg(ctrl);
u32 data = brcm_sata_readreg(ctrl); data &= ~BUS_CTRL_ENDIAN_CONF_MASK;
if (priv->version == BRCM_SATA_NSP)
data &= ~((0x03 << DMADATA_ENDIAN_SHIFT) | data |= BUS_CTRL_ENDIAN_NSP_CONF;
(0x03 << DMADESC_ENDIAN_SHIFT)); else
data |= (0x02 << DMADATA_ENDIAN_SHIFT) | data |= BUS_CTRL_ENDIAN_CONF;
(0x02 << DMADESC_ENDIAN_SHIFT);
brcm_sata_writereg(data, ctrl); brcm_sata_writereg(data, ctrl);
} else
brcm_sata_writereg(BUS_CTRL_ENDIAN_CONF, ctrl);
} }
static unsigned int brcm_ahci_read_id(struct ata_device *dev,
struct ata_taskfile *tf, u16 *id)
{
struct ata_port *ap = dev->link->ap;
struct ata_host *host = ap->host;
struct ahci_host_priv *hpriv = host->private_data;
struct brcm_ahci_priv *priv = hpriv->plat_data;
void __iomem *mmio = hpriv->mmio;
unsigned int err_mask;
unsigned long flags;
int i, rc;
u32 ctl;
/* Try to read the device ID and, if this fails, proceed with the
* recovery sequence below
*/
err_mask = ata_do_dev_read_id(dev, tf, id);
if (likely(!err_mask))
return err_mask;
/* Disable host interrupts */
spin_lock_irqsave(&host->lock, flags);
ctl = readl(mmio + HOST_CTL);
ctl &= ~HOST_IRQ_EN;
writel(ctl, mmio + HOST_CTL);
readl(mmio + HOST_CTL); /* flush */
spin_unlock_irqrestore(&host->lock, flags);
/* Perform the SATA PHY reset sequence */
brcm_sata_phy_disable(priv, ap->port_no);
/* Bring the PHY back on */
brcm_sata_phy_enable(priv, ap->port_no);
/* Re-initialize and calibrate the PHY */
for (i = 0; i < hpriv->nports; i++) {
rc = phy_init(hpriv->phys[i]);
if (rc)
goto disable_phys;
rc = phy_calibrate(hpriv->phys[i]);
if (rc) {
phy_exit(hpriv->phys[i]);
goto disable_phys;
}
}
/* Re-enable host interrupts */
spin_lock_irqsave(&host->lock, flags);
ctl = readl(mmio + HOST_CTL);
ctl |= HOST_IRQ_EN;
writel(ctl, mmio + HOST_CTL);
readl(mmio + HOST_CTL); /* flush */
spin_unlock_irqrestore(&host->lock, flags);
return ata_do_dev_read_id(dev, tf, id);
disable_phys:
while (--i >= 0) {
phy_power_off(hpriv->phys[i]);
phy_exit(hpriv->phys[i]);
}
return AC_ERR_OTHER;
}
static void brcm_ahci_host_stop(struct ata_host *host)
{
struct ahci_host_priv *hpriv = host->private_data;
ahci_platform_disable_resources(hpriv);
}
static struct ata_port_operations ahci_brcm_platform_ops = {
.inherits = &ahci_ops,
.host_stop = brcm_ahci_host_stop,
.read_id = brcm_ahci_read_id,
};
static const struct ata_port_info ahci_brcm_port_info = {
.flags = AHCI_FLAG_COMMON | ATA_FLAG_NO_DIPM,
.link_flags = ATA_LFLAG_NO_DB_DELAY,
.pio_mask = ATA_PIO4,
.udma_mask = ATA_UDMA6,
.port_ops = &ahci_brcm_platform_ops,
};
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int brcm_ahci_suspend(struct device *dev) static int brcm_ahci_suspend(struct device *dev)
{ {
......
...@@ -458,7 +458,7 @@ static const struct piix_map_db *piix_map_db_table[] = { ...@@ -458,7 +458,7 @@ static const struct piix_map_db *piix_map_db_table[] = {
[ich8_2port_sata_byt] = &ich8_2port_map_db, [ich8_2port_sata_byt] = &ich8_2port_map_db,
}; };
static struct pci_bits piix_enable_bits[] = { static const struct pci_bits piix_enable_bits[] = {
{ 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */ { 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */
{ 0x43U, 1U, 0x80UL, 0x80UL }, /* port 1 */ { 0x43U, 1U, 0x80UL, 0x80UL }, /* port 1 */
}; };
......
This diff is collapsed.
...@@ -278,6 +278,10 @@ static int atiixp_init_one(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -278,6 +278,10 @@ static int atiixp_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
}; };
const struct ata_port_info *ppi[] = { &info, &info }; const struct ata_port_info *ppi[] = { &info, &info };
/* SB600 doesn't have secondary port wired */
if((pdev->device == PCI_DEVICE_ID_ATI_IXP600_IDE))
ppi[1] = &ata_dummy_port_info;
return ata_pci_bmdma_init_one(pdev, ppi, &atiixp_sht, NULL, return ata_pci_bmdma_init_one(pdev, ppi, &atiixp_sht, NULL,
ATA_HOST_PARALLEL_SCAN); ATA_HOST_PARALLEL_SCAN);
} }
......
...@@ -683,7 +683,7 @@ static u8 *it821x_firmware_command(struct ata_port *ap, u8 cmd, int len) ...@@ -683,7 +683,7 @@ static u8 *it821x_firmware_command(struct ata_port *ap, u8 cmd, int len)
ioread16_rep(ap->ioaddr.data_addr, buf, len/2); ioread16_rep(ap->ioaddr.data_addr, buf, len/2);
return (u8 *)buf; return (u8 *)buf;
} }
mdelay(1); usleep_range(500, 1000);
} }
kfree(buf); kfree(buf);
printk(KERN_ERR "it821x_firmware_command: timeout\n"); printk(KERN_ERR "it821x_firmware_command: timeout\n");
......
...@@ -580,7 +580,7 @@ static void pdc_adjust_pll(struct ata_host *host, long pll_clock, unsigned int b ...@@ -580,7 +580,7 @@ static void pdc_adjust_pll(struct ata_host *host, long pll_clock, unsigned int b
ioread16(mmio_base + PDC_PLL_CTL); /* flush */ ioread16(mmio_base + PDC_PLL_CTL); /* flush */
/* Wait the PLL circuit to be stable */ /* Wait the PLL circuit to be stable */
mdelay(30); msleep(30);
#ifdef PDC_DEBUG #ifdef PDC_DEBUG
/* /*
...@@ -620,7 +620,7 @@ static long pdc_detect_pll_input_clock(struct ata_host *host) ...@@ -620,7 +620,7 @@ static long pdc_detect_pll_input_clock(struct ata_host *host)
start_time = ktime_get(); start_time = ktime_get();
/* Let the counter run for 100 ms. */ /* Let the counter run for 100 ms. */
mdelay(100); msleep(100);
/* Read the counter values again */ /* Read the counter values again */
end_count = pdc_read_counter(host); end_count = pdc_read_counter(host);
......
...@@ -3596,7 +3596,7 @@ static void mv_reset_channel(struct mv_host_priv *hpriv, void __iomem *mmio, ...@@ -3596,7 +3596,7 @@ static void mv_reset_channel(struct mv_host_priv *hpriv, void __iomem *mmio,
hpriv->ops->phy_errata(hpriv, mmio, port_no); hpriv->ops->phy_errata(hpriv, mmio, port_no);
if (IS_GEN_I(hpriv)) if (IS_GEN_I(hpriv))
mdelay(1); usleep_range(500, 1000);
} }
static void mv_pmp_select(struct ata_port *ap, int pmp) static void mv_pmp_select(struct ata_port *ap, int pmp)
......
...@@ -150,6 +150,9 @@ enum sata_phy_regs { ...@@ -150,6 +150,9 @@ enum sata_phy_regs {
TXPMD_TX_FREQ_CTRL_CONTROL2_FMIN_MASK = 0x3ff, TXPMD_TX_FREQ_CTRL_CONTROL2_FMIN_MASK = 0x3ff,
TXPMD_TX_FREQ_CTRL_CONTROL3 = 0x84, TXPMD_TX_FREQ_CTRL_CONTROL3 = 0x84,
TXPMD_TX_FREQ_CTRL_CONTROL3_FMAX_MASK = 0x3ff, TXPMD_TX_FREQ_CTRL_CONTROL3_FMAX_MASK = 0x3ff,
RXPMD_REG_BANK = 0x1c0,
RXPMD_RX_FREQ_MON_CONTROL1 = 0x87,
}; };
enum sata_phy_ctrl_regs { enum sata_phy_ctrl_regs {
...@@ -505,8 +508,36 @@ static int brcm_sata_phy_init(struct phy *phy) ...@@ -505,8 +508,36 @@ static int brcm_sata_phy_init(struct phy *phy)
return rc; return rc;
} }
static void brcm_stb_sata_calibrate(struct brcm_sata_port *port)
{
void __iomem *base = brcm_sata_pcb_base(port);
u32 tmp = BIT(8);
brcm_sata_phy_wr(base, RXPMD_REG_BANK, RXPMD_RX_FREQ_MON_CONTROL1,
~tmp, tmp);
}
static int brcm_sata_phy_calibrate(struct phy *phy)
{
struct brcm_sata_port *port = phy_get_drvdata(phy);
int rc = -EOPNOTSUPP;
switch (port->phy_priv->version) {
case BRCM_SATA_PHY_STB_28NM:
case BRCM_SATA_PHY_STB_40NM:
brcm_stb_sata_calibrate(port);
rc = 0;
break;
default:
break;
}
return rc;
}
static const struct phy_ops phy_ops = { static const struct phy_ops phy_ops = {
.init = brcm_sata_phy_init, .init = brcm_sata_phy_init,
.calibrate = brcm_sata_phy_calibrate,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment