staticint ahci_dm816_get_mpy_bits(unsignedlong refclk_rate)
{ unsignedlong pll_multiplier; int i;
/* * We need to determine the value of the multiplier (MPY) bits. * In order to include the 8.25 multiplier we need to first divide * the refclk rate by 100.
*/
pll_multiplier = AHCI_DM816_PLL_OUT / (refclk_rate / 100);
for (i = 0; i < ARRAY_SIZE(pll_mpy_table); i++) { if (pll_mpy_table[i] == pll_multiplier) return i;
}
/* * We should have divided evenly - if not, return an invalid * value.
*/ return -1;
}
/* * We should have been supplied two clocks: the functional and * keep-alive clock and the external reference clock. We need the * rate of the latter to calculate the correct value of MPY bits.
*/ if (hpriv->n_clks < 2) {
dev_err(dev, "reference clock not supplied\n"); return -EINVAL;
}
refclk_rate = clk_get_rate(hpriv->clks[1].clk); if ((refclk_rate % 100) != 0) {
dev_err(dev, "reference clock rate must be divisible by 100\n"); return -EINVAL;
}
mpy = ahci_dm816_get_mpy_bits(refclk_rate); if (mpy < 0) {
dev_err(dev, "can't calculate the MPY bits value\n"); return -EINVAL;
}
/* Enable the PHY and configure the first HBA port. */
val = AHCI_DM816_PHY_MPY(mpy) | AHCI_DM816_PHY_LOS(1) |
AHCI_DM816_PHY_RXCDR(4) | AHCI_DM816_PHY_RXEQ(1) |
AHCI_DM816_PHY_TXSWING(3) | AHCI_DM816_PHY_ENPLL(1);
writel(val, hpriv->mmio + AHCI_DM816_P0PHYCR_REG);
/* Configure the second HBA port. */
val = AHCI_DM816_PHY_LOS(1) | AHCI_DM816_PHY_RXCDR(4) |
AHCI_DM816_PHY_RXEQ(1) | AHCI_DM816_PHY_TXSWING(3);
writel(val, hpriv->mmio + AHCI_DM816_P1PHYCR_REG);
/* * There's an issue with the SATA controller on DM816 SoC: if we * enable Port Multiplier support, but the drive is connected directly * to the board, it can't be detected. As a workaround: if PMP is * enabled, we first call ahci_do_softreset() and pass it the result of * sata_srst_pmp(). If this call fails, we retry with pmp = 0.
*/
ret = ahci_do_softreset(link, class, pmp, deadline, ahci_check_ready); if (pmp && ret == -EBUSY) return ahci_do_softreset(link, class, 0,
deadline, ahci_check_ready);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.