Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1558383
| From | Bartosz Golaszewski <bgolaszewski@baylibre.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 07/10] sata: ahci_da850: add support for the da850,clk_multiplier DT property |
| Date | 2017-01-13 13:50 +0100 |
| Message-ID | <sZ9sS-Vi-35@gated-at.bofh.it> (permalink) |
| References | <sZ9sR-Vi-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Currently the clock multiplier is hardcoded in the driver for
the da850-evm board. Make it configurable over DT, but keep the
previous value as default in case the property is missing.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/ata/ahci_da850.c | 83 +++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 75 insertions(+), 8 deletions(-)
diff --git a/drivers/ata/ahci_da850.c b/drivers/ata/ahci_da850.c
index bb9eb4c..cd04caf 100644
--- a/drivers/ata/ahci_da850.c
+++ b/drivers/ata/ahci_da850.c
@@ -28,17 +28,70 @@
#define SATA_PHY_TXSWING(x) ((x) << 19)
#define SATA_PHY_ENPLL(x) ((x) << 31)
+struct da850_sata_mpy_mapping {
+ unsigned int multiplier;
+ unsigned int regval;
+};
+
+static const struct da850_sata_mpy_mapping da850_sata_mpy_table[] = {
+ {
+ .multiplier = 5,
+ .regval = 0x01,
+ },
+ {
+ .multiplier = 6,
+ .regval = 0x02,
+ },
+ {
+ .multiplier = 8,
+ .regval = 0x04,
+ },
+ {
+ .multiplier = 10,
+ .regval = 0x05,
+ },
+ {
+ .multiplier = 12,
+ .regval = 0x06,
+ },
+ /* TODO Add 12.5 multiplier. */
+ {
+ .multiplier = 15,
+ .regval = 0x08,
+ },
+ {
+ .multiplier = 20,
+ .regval = 0x09,
+ },
+ {
+ .multiplier = 25,
+ .regval = 0x0a,
+ }
+};
+
+static const struct da850_sata_mpy_mapping *
+da850_sata_get_mpy(unsigned int multiplier)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(da850_sata_mpy_table); i++)
+ if (da850_sata_mpy_table[i].multiplier == multiplier)
+ return &da850_sata_mpy_table[i];
+
+ return NULL;
+}
+
/*
* The multiplier needed for 1.5GHz PLL output.
*
- * NOTE: This is currently hardcoded to be suitable for 100MHz crystal
- * frequency (which is used by DA850 EVM board) and may need to be changed
- * if you would like to use this driver on some other board.
+ * This is the default value suitable for the 100MHz crystal frequency
+ * used by DA850 EVM board, which doesn't use DT.
*/
-#define DA850_SATA_CLK_MULTIPLIER 7
+#define DA850_SATA_CLK_MULTIPLIER_DEFAULT 15
static void da850_sata_init(struct device *dev, void __iomem *pwrdn_reg,
- void __iomem *ahci_base)
+ void __iomem *ahci_base,
+ const struct da850_sata_mpy_mapping *mpy)
{
unsigned int val;
@@ -47,7 +100,7 @@ static void da850_sata_init(struct device *dev, void __iomem *pwrdn_reg,
val &= ~BIT(0);
writel(val, pwrdn_reg);
- val = SATA_PHY_MPY(DA850_SATA_CLK_MULTIPLIER + 1) | SATA_PHY_LOS(1) |
+ val = SATA_PHY_MPY(mpy->regval) | SATA_PHY_LOS(1) |
SATA_PHY_RXCDR(4) | SATA_PHY_RXEQ(1) | SATA_PHY_TXSWING(3) |
SATA_PHY_ENPLL(1);
@@ -87,10 +140,12 @@ static struct scsi_host_template ahci_platform_sht = {
static int ahci_da850_probe(struct platform_device *pdev)
{
+ const struct da850_sata_mpy_mapping *mpy;
struct device *dev = &pdev->dev;
struct ahci_host_priv *hpriv;
- struct resource *res;
+ unsigned int multiplier;
void __iomem *pwrdn_reg;
+ struct resource *res;
int rc;
hpriv = ahci_platform_get_resources(pdev);
@@ -109,7 +164,19 @@ static int ahci_da850_probe(struct platform_device *pdev)
if (!pwrdn_reg)
goto disable_resources;
- da850_sata_init(dev, pwrdn_reg, hpriv->mmio);
+ rc = of_property_read_u32(dev->of_node,
+ "da850,clk_multiplier", &multiplier);
+ if (rc)
+ multiplier = DA850_SATA_CLK_MULTIPLIER_DEFAULT;
+
+ mpy = da850_sata_get_mpy(multiplier);
+ if (!mpy) {
+ dev_err(dev, "invalid multiplier value: %u\n", multiplier);
+ rc = -EINVAL;
+ goto disable_resources;
+ }
+
+ da850_sata_init(dev, pwrdn_reg, hpriv->mmio, mpy);
rc = ahci_platform_init_host(pdev, hpriv, &ahci_da850_port_info,
&ahci_platform_sht);
--
2.9.3
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/10] ARM: da850-lcdk: add SATA support Bartosz Golaszewski <bgolaszewski@baylibre.com> - 2017-01-13 13:50 +0100
[PATCH 06/10] sata: ahci_da850: implement a softreset quirk Bartosz Golaszewski <bgolaszewski@baylibre.com> - 2017-01-13 13:50 +0100
Re: [PATCH 06/10] sata: ahci_da850: implement a softreset quirk Tejun Heo <tj@kernel.org> - 2017-01-16 00:20 +0100
Re: [PATCH 06/10] sata: ahci_da850: implement a softreset quirk Bartosz Golaszewski <bgolaszewski@baylibre.com> - 2017-01-16 11:20 +0100
[PATCH 01/10] ARM: davinci: add a clock lookup entry for the SATA clock Bartosz Golaszewski <bgolaszewski@baylibre.com> - 2017-01-13 13:50 +0100
[PATCH 09/10] ARM: dts: da850: add the SATA node Bartosz Golaszewski <bgolaszewski@baylibre.com> - 2017-01-13 13:50 +0100
Re: [PATCH 09/10] ARM: dts: da850: add the SATA node David Lechner <david@lechnology.com> - 2017-01-13 20:40 +0100
Re: [PATCH 09/10] ARM: dts: da850: add the SATA node Bartosz Golaszewski <bgolaszewski@baylibre.com> - 2017-01-16 11:10 +0100
[PATCH 03/10] devicetree: bindings: add bindings for ahci-da850 Bartosz Golaszewski <bgolaszewski@baylibre.com> - 2017-01-13 13:50 +0100
Re: [PATCH 03/10] devicetree: bindings: add bindings for ahci-da850 David Lechner <david@lechnology.com> - 2017-01-13 20:30 +0100
Re: [PATCH 03/10] devicetree: bindings: add bindings for ahci-da850 Bartosz Golaszewski <bgolaszewski@baylibre.com> - 2017-01-16 11:20 +0100
Re: [PATCH 03/10] devicetree: bindings: add bindings for ahci-da850 Sekhar Nori <nsekhar@ti.com> - 2017-01-16 13:50 +0100
Re: [PATCH 03/10] devicetree: bindings: add bindings for ahci-da850 Bartosz Golaszewski <bgolaszewski@baylibre.com> - 2017-01-16 15:40 +0100
Re: [PATCH 03/10] devicetree: bindings: add bindings for ahci-da850 David Lechner <david@lechnology.com> - 2017-01-16 19:50 +0100
[PATCH 05/10] sata: ahci_da850: add device tree match table Bartosz Golaszewski <bgolaszewski@baylibre.com> - 2017-01-13 13:50 +0100
[PATCH 08/10] ARM: dts: da850: add pinmux settings for the SATA controller Bartosz Golaszewski <bgolaszewski@baylibre.com> - 2017-01-13 13:50 +0100
[PATCH 07/10] sata: ahci_da850: add support for the da850,clk_multiplier DT property Bartosz Golaszewski <bgolaszewski@baylibre.com> - 2017-01-13 13:50 +0100
Re: [PATCH 07/10] sata: ahci_da850: add support for the da850,clk_multiplier DT property David Lechner <david@lechnology.com> - 2017-01-13 21:40 +0100
[PATCH 04/10] sata: hardreset: retry if phys link is down Bartosz Golaszewski <bgolaszewski@baylibre.com> - 2017-01-13 13:50 +0100
Re: [PATCH 04/10] sata: hardreset: retry if phys link is down Tejun Heo <tj@kernel.org> - 2017-01-16 00:20 +0100
Re: [PATCH 04/10] sata: hardreset: retry if phys link is down Bartosz Golaszewski <bgolaszewski@baylibre.com> - 2017-01-16 13:30 +0100
[PATCH 02/10] ARM: davinci_all_defconfig: enable SATA modules Bartosz Golaszewski <bgolaszewski@baylibre.com> - 2017-01-13 14:50 +0100
Re: [PATCH 00/10] ARM: da850-lcdk: add SATA support Sekhar Nori <nsekhar@ti.com> - 2017-01-13 15:40 +0100
csiph-web