2017-03-13 16:36:51

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 0/2] ata: ahci-dm816: new driver

Add support for the on-board SATA controller present on TI DM816 SoCs.

This IP suffers from the same issue DA850 does, that is: if we enable
PMP, but connect the drive directly to the board, the disk cannot be
detected. A workaround similar to the one implemented in ahci-da850 is
included in this driver as well.

Bartosz Golaszewski (2):
dt-bindings: ata: add DT bindings for ahci-dm816 SATA controller
ata: ahci: add support for DaVinci DM816 SATA controller

.../devicetree/bindings/ata/ahci-dm816.txt | 20 +++
drivers/ata/Kconfig | 9 +
drivers/ata/Makefile | 1 +
drivers/ata/ahci_dm816.c | 200 +++++++++++++++++++++
4 files changed, 230 insertions(+)
create mode 100644 Documentation/devicetree/bindings/ata/ahci-dm816.txt
create mode 100644 drivers/ata/ahci_dm816.c

--
2.9.3


2017-03-13 16:36:50

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 1/2] dt-bindings: ata: add DT bindings for ahci-dm816 SATA controller

Add DT bindings for the onboard SATA controller present on the DM816x
SoCs.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
Documentation/devicetree/bindings/ata/ahci-dm816.txt | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
create mode 100644 Documentation/devicetree/bindings/ata/ahci-dm816.txt

diff --git a/Documentation/devicetree/bindings/ata/ahci-dm816.txt b/Documentation/devicetree/bindings/ata/ahci-dm816.txt
new file mode 100644
index 0000000..b87ed5a
--- /dev/null
+++ b/Documentation/devicetree/bindings/ata/ahci-dm816.txt
@@ -0,0 +1,20 @@
+Device tree binding for the TI DM816 AHCI SATA Controller
+---------------------------------------------------------
+
+Required properties:
+ - compatible: must be "ti,dm816-ahci"
+ - reg: physical base address and size of the register region used by
+ the controller (as defined by the AHCI 1.1 standard)
+ - interrupts: interrupt specifier (refer to the interrupt binding)
+ - clocks: clock specifiers (refer to the clock binding); two clocks
+ must be specified: the functional clock and an external
+ reference clock
+
+Example:
+
+ sata: sata@4a140000 {
+ compatible = "ti,dm816-ahci";
+ reg = <0x4a140000 0xffff>;
+ interrupts = <16>;
+ clocks = <&sysclk5_ck>, <&sata_refclk>;
+ };
--
2.9.3

2017-03-13 16:36:49

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH 2/2] ata: ahci: add support for DaVinci DM816 SATA controller

This SATA controller is quite similar to the one present on the DA850
SoC, but the PHY configuration is different and it supports two HBA
ports.

The IP suffers from the same PMP issue the DA850 does - if we enable
PMP but don't use it - softreset fails. Appropriate workaround was
implemented in this driver as well.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
drivers/ata/Kconfig | 9 +++
drivers/ata/Makefile | 1 +
drivers/ata/ahci_dm816.c | 200 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 210 insertions(+)
create mode 100644 drivers/ata/ahci_dm816.c

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 70b57d2..7f59a7a 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -118,6 +118,15 @@ config AHCI_DA850

If unsure, say N.

+config AHCI_DM816
+ tristate "DaVinci DM816 AHCI SATA support"
+ depends on ARCH_OMAP2PLUS
+ help
+ This option enables support for the DaVinci DM816 SoC's
+ onboard AHCI SATA controller.
+
+ If unsure, say N.
+
config AHCI_ST
tristate "ST AHCI SATA support"
depends on ARCH_STI
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 89a0a19..3052c0a 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_SATA_HIGHBANK) += sata_highbank.o libahci.o
obj-$(CONFIG_AHCI_BRCM) += ahci_brcm.o libahci.o libahci_platform.o
obj-$(CONFIG_AHCI_CEVA) += ahci_ceva.o libahci.o libahci_platform.o
obj-$(CONFIG_AHCI_DA850) += ahci_da850.o libahci.o libahci_platform.o
+obj-$(CONFIG_AHCI_DM816) += ahci_dm816.o libahci.o libahci_platform.o
obj-$(CONFIG_AHCI_IMX) += ahci_imx.o libahci.o libahci_platform.o
obj-$(CONFIG_AHCI_MVEBU) += ahci_mvebu.o libahci.o libahci_platform.o
obj-$(CONFIG_AHCI_OCTEON) += ahci_octeon.o
diff --git a/drivers/ata/ahci_dm816.c b/drivers/ata/ahci_dm816.c
new file mode 100644
index 0000000..fbd827c
--- /dev/null
+++ b/drivers/ata/ahci_dm816.c
@@ -0,0 +1,200 @@
+/*
+ * DaVinci DM816 AHCI SATA platform driver
+ *
+ * Copyright (C) 2017 BayLibre SAS
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/pm.h>
+#include <linux/platform_device.h>
+#include <linux/libata.h>
+#include <linux/ahci_platform.h>
+
+#include "ahci.h"
+
+#define AHCI_DM816_DRV_NAME "ahci-dm816"
+
+#define AHCI_DM816_PHY_ENPLL(x) ((x) << 0)
+#define AHCI_DM816_PHY_MPY(x) ((x) << 1)
+#define AHCI_DM816_PHY_LOS(x) ((x) << 12)
+#define AHCI_DM816_PHY_RXCDR(x) ((x) << 13)
+#define AHCI_DM816_PHY_RXEQ(x) ((x) << 16)
+#define AHCI_DM816_PHY_TXSWING(x) ((x) << 23)
+
+#define AHCI_DM816_P0PHYCR_REG 0x178
+#define AHCI_DM816_P1PHYCR_REG 0x1f8
+
+#define AHCI_DM816_PLL_OUT 1500000000LU
+
+static const unsigned long pll_mpy_table[] = {
+ 400, 500, 600, 800, 825, 1000, 1200,
+ 1250, 1500, 1600, 1650, 2000, 2200, 2500
+};
+
+static int ahci_dm816_get_mpy_bits(unsigned long refclk_rate)
+{
+ unsigned long 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;
+}
+
+static int ahci_dm816_phy_init(struct ahci_host_priv *hpriv, struct device *dev)
+{
+ unsigned long refclk_rate;
+ int mpy;
+ u32 val;
+
+ /*
+ * 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->clks[1]) {
+ dev_err(dev, "reference clock not supplied\n");
+ return -EINVAL;
+ }
+
+ refclk_rate = clk_get_rate(hpriv->clks[1]);
+ 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);
+
+ return 0;
+}
+
+static int ahci_dm816_softreset(struct ata_link *link,
+ unsigned int *class, unsigned long deadline)
+{
+ int pmp, ret;
+
+ pmp = sata_srst_pmp(link);
+
+ /*
+ * 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);
+
+ return ret;
+}
+
+static struct ata_port_operations ahci_dm816_port_ops = {
+ .inherits = &ahci_platform_ops,
+ .softreset = ahci_dm816_softreset,
+};
+
+static const struct ata_port_info ahci_dm816_port_info = {
+ .flags = AHCI_FLAG_COMMON,
+ .pio_mask = ATA_PIO4,
+ .udma_mask = ATA_UDMA6,
+ .port_ops = &ahci_dm816_port_ops,
+};
+
+static struct scsi_host_template ahci_dm816_platform_sht = {
+ AHCI_SHT(AHCI_DM816_DRV_NAME),
+};
+
+static int ahci_dm816_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct ahci_host_priv *hpriv;
+ int rc;
+
+ hpriv = ahci_platform_get_resources(pdev);
+ if (IS_ERR(hpriv))
+ return PTR_ERR(hpriv);
+
+ rc = ahci_platform_enable_resources(hpriv);
+ if (rc)
+ return rc;
+
+ rc = ahci_dm816_phy_init(hpriv, dev);
+ if (rc)
+ goto disable_resources;
+
+ rc = ahci_platform_init_host(pdev, hpriv,
+ &ahci_dm816_port_info,
+ &ahci_dm816_platform_sht);
+ if (rc)
+ goto disable_resources;
+
+ return 0;
+
+disable_resources:
+ ahci_platform_disable_resources(hpriv);
+
+ return rc;
+}
+
+static SIMPLE_DEV_PM_OPS(ahci_dm816_pm_ops,
+ ahci_platform_suspend,
+ ahci_platform_resume);
+
+static const struct of_device_id ahci_dm816_of_match[] = {
+ { .compatible = "ti,dm816-ahci", },
+ { },
+};
+MODULE_DEVICE_TABLE(of, ahci_dm816_of_match);
+
+static struct platform_driver ahci_dm816_driver = {
+ .probe = ahci_dm816_probe,
+ .remove = ata_platform_remove_one,
+ .driver = {
+ .name = AHCI_DM816_DRV_NAME,
+ .of_match_table = ahci_dm816_of_match,
+ .pm = &ahci_dm816_pm_ops,
+ },
+};
+module_platform_driver(ahci_dm816_driver);
+
+MODULE_DESCRIPTION("DaVinci DM816 AHCI SATA platform driver");
+MODULE_AUTHOR("Bartosz Golaszewski <[email protected]>");
+MODULE_LICENSE("GPL");
--
2.9.3

2017-03-13 16:53:14

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [PATCH 1/2] dt-bindings: ata: add DT bindings for ahci-dm816 SATA controller

Hello!

On 03/13/2017 07:36 PM, Bartosz Golaszewski wrote:

> Add DT bindings for the onboard SATA controller present on the DM816x
> SoCs.
>
> Signed-off-by: Bartosz Golaszewski <[email protected]>
> ---
> Documentation/devicetree/bindings/ata/ahci-dm816.txt | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/ata/ahci-dm816.txt
>
> diff --git a/Documentation/devicetree/bindings/ata/ahci-dm816.txt b/Documentation/devicetree/bindings/ata/ahci-dm816.txt
> new file mode 100644
> index 0000000..b87ed5a
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/ata/ahci-dm816.txt
> @@ -0,0 +1,20 @@
> +Device tree binding for the TI DM816 AHCI SATA Controller
> +---------------------------------------------------------
> +
> +Required properties:
> + - compatible: must be "ti,dm816-ahci"
> + - reg: physical base address and size of the register region used by
> + the controller (as defined by the AHCI 1.1 standard)
> + - interrupts: interrupt specifier (refer to the interrupt binding)
> + - clocks: clock specifiers (refer to the clock binding); two clocks

There should be a phandle preceding the clock specifier, all new such
props are different to the old "interrupts" (which had phandle in a separate
"interrupt-parent" prop).

> + must be specified: the functional clock and an external
> + reference clock
> +
> +Example:
> +
> + sata: sata@4a140000 {
> + compatible = "ti,dm816-ahci";
> + reg = <0x4a140000 0xffff>;

I think you meant 0x10000 ISO 0xffff -- this is a size, not limit.

> + interrupts = <16>;
> + clocks = <&sysclk5_ck>, <&sata_refclk>;
> + };
>

MBR, Sergei

2017-03-13 17:08:21

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH 1/2] dt-bindings: ata: add DT bindings for ahci-dm816 SATA controller

2017-03-13 17:53 GMT+01:00 Sergei Shtylyov <[email protected]>:
> Hello!
>
> On 03/13/2017 07:36 PM, Bartosz Golaszewski wrote:
>
>> Add DT bindings for the onboard SATA controller present on the DM816x
>> SoCs.
>>
>> Signed-off-by: Bartosz Golaszewski <[email protected]>
>> ---
>> Documentation/devicetree/bindings/ata/ahci-dm816.txt | 20
>> ++++++++++++++++++++
>> 1 file changed, 20 insertions(+)
>> create mode 100644 Documentation/devicetree/bindings/ata/ahci-dm816.txt
>>
>> diff --git a/Documentation/devicetree/bindings/ata/ahci-dm816.txt
>> b/Documentation/devicetree/bindings/ata/ahci-dm816.txt
>> new file mode 100644
>> index 0000000..b87ed5a
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/ata/ahci-dm816.txt
>> @@ -0,0 +1,20 @@
>> +Device tree binding for the TI DM816 AHCI SATA Controller
>> +---------------------------------------------------------
>> +
>> +Required properties:
>> + - compatible: must be "ti,dm816-ahci"
>> + - reg: physical base address and size of the register region used by
>> + the controller (as defined by the AHCI 1.1 standard)
>> + - interrupts: interrupt specifier (refer to the interrupt binding)
>> + - clocks: clock specifiers (refer to the clock binding); two clocks
>
>
> There should be a phandle preceding the clock specifier, all new such
> props are different to the old "interrupts" (which had phandle in a separate
> "interrupt-parent" prop).
>

I'm afraid I don't understand - could you point me to an example?

>> + must be specified: the functional clock and an external
>> + reference clock
>> +
>> +Example:
>> +
>> + sata: sata@4a140000 {
>> + compatible = "ti,dm816-ahci";
>> + reg = <0x4a140000 0xffff>;
>
>
> I think you meant 0x10000 ISO 0xffff -- this is a size, not limit.
>

Right, thanks.

>> + interrupts = <16>;
>> + clocks = <&sysclk5_ck>, <&sata_refclk>;
>> + };
>>
>
> MBR, Sergei
>

Thanks,
Bartosz Golaszewski

2017-03-13 17:27:48

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [PATCH 1/2] dt-bindings: ata: add DT bindings for ahci-dm816 SATA controller

On 03/13/2017 08:08 PM, Bartosz Golaszewski wrote:

>>> Add DT bindings for the onboard SATA controller present on the DM816x
>>> SoCs.
>>>
>>> Signed-off-by: Bartosz Golaszewski <[email protected]>
>>> ---
>>> Documentation/devicetree/bindings/ata/ahci-dm816.txt | 20
>>> ++++++++++++++++++++
>>> 1 file changed, 20 insertions(+)
>>> create mode 100644 Documentation/devicetree/bindings/ata/ahci-dm816.txt
>>>
>>> diff --git a/Documentation/devicetree/bindings/ata/ahci-dm816.txt
>>> b/Documentation/devicetree/bindings/ata/ahci-dm816.txt
>>> new file mode 100644
>>> index 0000000..b87ed5a
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/ata/ahci-dm816.txt
>>> @@ -0,0 +1,20 @@
>>> +Device tree binding for the TI DM816 AHCI SATA Controller
>>> +---------------------------------------------------------
>>> +
>>> +Required properties:
>>> + - compatible: must be "ti,dm816-ahci"
>>> + - reg: physical base address and size of the register region used by
>>> + the controller (as defined by the AHCI 1.1 standard)
>>> + - interrupts: interrupt specifier (refer to the interrupt binding)
>>> + - clocks: clock specifiers (refer to the clock binding); two clocks
>>
>>
>> There should be a phandle preceding the clock specifier, all new such
>> props are different to the old "interrupts" (which had phandle in a separate
>> "interrupt-parent" prop).

> I'm afraid I don't understand - could you point me to an example?

Have you read Documentation/devicetree/bindings/clock/clock-bindings.txt,
on clock consumers?
In fact, your own example below doesn't have clock specifiers, only phandles.

>>> + must be specified: the functional clock and an external
>>> + reference clock
>>> +
>>> +Example:
>>> +
>>> + sata: sata@4a140000 {
>>> + compatible = "ti,dm816-ahci";
>>> + reg = <0x4a140000 0xffff>;
[...]
>>> + interrupts = <16>;
>>> + clocks = <&sysclk5_ck>, <&sata_refclk>;
>>> + };
>>>

> Thanks,
> Bartosz Golaszewski

MBR, Sergei

2017-03-14 08:57:15

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [PATCH 2/2] ata: ahci: add support for DaVinci DM816 SATA controller

Hello!

On 3/13/2017 7:36 PM, Bartosz Golaszewski wrote:

> This SATA controller is quite similar to the one present on the DA850
> SoC, but the PHY configuration is different and it supports two HBA
> ports.
>
> The IP suffers from the same PMP issue the DA850 does - if we enable
> PMP but don't use it - softreset fails. Appropriate workaround was
> implemented in this driver as well.
>
> Signed-off-by: Bartosz Golaszewski <[email protected]>
> ---
> drivers/ata/Kconfig | 9 +++
> drivers/ata/Makefile | 1 +
> drivers/ata/ahci_dm816.c | 200 +++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 210 insertions(+)
> create mode 100644 drivers/ata/ahci_dm816.c
>
> diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
> index 70b57d2..7f59a7a 100644
> --- a/drivers/ata/Kconfig
> +++ b/drivers/ata/Kconfig
> @@ -118,6 +118,15 @@ config AHCI_DA850
>
> If unsure, say N.
>
> +config AHCI_DM816
> + tristate "DaVinci DM816 AHCI SATA support"

Is it really DaVinci?

> + depends on ARCH_OMAP2PLUS

Especially if it depends on OMAP...

[...]

MBR, Sergei

2017-03-14 09:00:20

by Neil Armstrong

[permalink] [raw]
Subject: Re: [PATCH 2/2] ata: ahci: add support for DaVinci DM816 SATA controller

On 03/14/2017 09:57 AM, Sergei Shtylyov wrote:
> Hello!
>
> On 3/13/2017 7:36 PM, Bartosz Golaszewski wrote:
>
>> This SATA controller is quite similar to the one present on the DA850
>> SoC, but the PHY configuration is different and it supports two HBA
>> ports.
>>
>> The IP suffers from the same PMP issue the DA850 does - if we enable
>> PMP but don't use it - softreset fails. Appropriate workaround was
>> implemented in this driver as well.
>>
>> Signed-off-by: Bartosz Golaszewski <[email protected]>
>> ---
>> drivers/ata/Kconfig | 9 +++
>> drivers/ata/Makefile | 1 +
>> drivers/ata/ahci_dm816.c | 200 +++++++++++++++++++++++++++++++++++++++++++++++
>> 3 files changed, 210 insertions(+)
>> create mode 100644 drivers/ata/ahci_dm816.c
>>
>> diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
>> index 70b57d2..7f59a7a 100644
>> --- a/drivers/ata/Kconfig
>> +++ b/drivers/ata/Kconfig
>> @@ -118,6 +118,15 @@ config AHCI_DA850
>>
>> If unsure, say N.
>>
>> +config AHCI_DM816
>> + tristate "DaVinci DM816 AHCI SATA support"
>
> Is it really DaVinci?
>
>> + depends on ARCH_OMAP2PLUS
>
> Especially if it depends on OMAP...

Hi Sergei,

Yes it's a DaVinci family SoC, but shares a lot of IPs with the OMAP family.

Neil

>
> [...]
>
> MBR, Sergei
>

2017-03-14 09:06:33

by Neil Armstrong

[permalink] [raw]
Subject: Re: [PATCH 1/2] dt-bindings: ata: add DT bindings for ahci-dm816 SATA controller

On 03/13/2017 06:27 PM, Sergei Shtylyov wrote:
> On 03/13/2017 08:08 PM, Bartosz Golaszewski wrote:
>
>>>> Add DT bindings for the onboard SATA controller present on the DM816x
>>>> SoCs.
>>>>
>>>> Signed-off-by: Bartosz Golaszewski <[email protected]>
>>>> ---
>>>> Documentation/devicetree/bindings/ata/ahci-dm816.txt | 20
>>>> ++++++++++++++++++++
>>>> 1 file changed, 20 insertions(+)
>>>> create mode 100644 Documentation/devicetree/bindings/ata/ahci-dm816.txt
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/ata/ahci-dm816.txt
>>>> b/Documentation/devicetree/bindings/ata/ahci-dm816.txt
>>>> new file mode 100644
>>>> index 0000000..b87ed5a
>>>> --- /dev/null
>>>> +++ b/Documentation/devicetree/bindings/ata/ahci-dm816.txt
>>>> @@ -0,0 +1,20 @@
>>>> +Device tree binding for the TI DM816 AHCI SATA Controller
>>>> +---------------------------------------------------------
>>>> +
>>>> +Required properties:
>>>> + - compatible: must be "ti,dm816-ahci"
>>>> + - reg: physical base address and size of the register region used by
>>>> + the controller (as defined by the AHCI 1.1 standard)
>>>> + - interrupts: interrupt specifier (refer to the interrupt binding)
>>>> + - clocks: clock specifiers (refer to the clock binding); two clocks
>>>
>>>
>>> There should be a phandle preceding the clock specifier, all new such
>>> props are different to the old "interrupts" (which had phandle in a separate
>>> "interrupt-parent" prop).
>
>> I'm afraid I don't understand - could you point me to an example?
>
> Have you read Documentation/devicetree/bindings/clock/clock-bindings.txt, on clock consumers?
> In fact, your own example below doesn't have clock specifiers, only phandles.

Hi Sergei,

I think it's perfectly clear since he mentions the "clock bindings", so it's clear the clocks
property must conform to the bindings described in the clock/clock-bindings.txt file.
The term "specifier" is alone not very clear, but it used as is in plenty of other
bindings files about this clocks property (i.e imx-sata.txt, ahci-fsl-qoriq.txt, ahci-ceva.txt).

And it's perfectly allowed to only have a single phandle without any arguments, as described
in the clock bindings actually.

Thanks,
Neil

>
>>>> + must be specified: the functional clock and an external
>>>> + reference clock
>>>> +
>>>> +Example:
>>>> +
>>>> + sata: sata@4a140000 {
>>>> + compatible = "ti,dm816-ahci";
>>>> + reg = <0x4a140000 0xffff>;
> [...]
>>>> + interrupts = <16>;
>>>> + clocks = <&sysclk5_ck>, <&sata_refclk>;
>>>> + };
>>>>
>
>> Thanks,
>> Bartosz Golaszewski
>
> MBR, Sergei
>

2017-03-14 10:43:51

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH 1/2] dt-bindings: ata: add DT bindings for ahci-dm816 SATA controller

2017-03-13 18:27 GMT+01:00 Sergei Shtylyov <[email protected]>:
> On 03/13/2017 08:08 PM, Bartosz Golaszewski wrote:
>
>>>> Add DT bindings for the onboard SATA controller present on the DM816x
>>>> SoCs.
>>>>
>>>> Signed-off-by: Bartosz Golaszewski <[email protected]>
>>>> ---
>>>> Documentation/devicetree/bindings/ata/ahci-dm816.txt | 20
>>>> ++++++++++++++++++++
>>>> 1 file changed, 20 insertions(+)
>>>> create mode 100644 Documentation/devicetree/bindings/ata/ahci-dm816.txt
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/ata/ahci-dm816.txt
>>>> b/Documentation/devicetree/bindings/ata/ahci-dm816.txt
>>>> new file mode 100644
>>>> index 0000000..b87ed5a
>>>> --- /dev/null
>>>> +++ b/Documentation/devicetree/bindings/ata/ahci-dm816.txt
>>>> @@ -0,0 +1,20 @@
>>>> +Device tree binding for the TI DM816 AHCI SATA Controller
>>>> +---------------------------------------------------------
>>>> +
>>>> +Required properties:
>>>> + - compatible: must be "ti,dm816-ahci"
>>>> + - reg: physical base address and size of the register region used by
>>>> + the controller (as defined by the AHCI 1.1 standard)
>>>> + - interrupts: interrupt specifier (refer to the interrupt binding)
>>>> + - clocks: clock specifiers (refer to the clock binding); two clocks
>>>
>>>
>>>
>>> There should be a phandle preceding the clock specifier, all new such
>>> props are different to the old "interrupts" (which had phandle in a
>>> separate
>>> "interrupt-parent" prop).
>
>
>> I'm afraid I don't understand - could you point me to an example?
>
>
> Have you read Documentation/devicetree/bindings/clock/clock-bindings.txt,
> on clock consumers?

Yes I have. It says:

66 clocks: List of phandle and clock specifier pairs, one pair
67 for each clock input to the device. Note: if the
68 clock provider specifies '0' for #clock-cells, then
69 only the phandle portion of the pair will appear.

> In fact, your own example below doesn't have clock specifiers, only
> phandles.
>

Since the SATA reference clock specifies 0 for #clock-cells I'll omit
the clock specifier. On the other hand: I'll rephrase the clocks
property description in the bindings for clarity.

Thanks,
Bartosz

2017-03-14 17:03:42

by Kevin Hilman

[permalink] [raw]
Subject: Re: [PATCH 2/2] ata: ahci: add support for DaVinci DM816 SATA controller

Neil Armstrong <[email protected]> writes:

> On 03/14/2017 09:57 AM, Sergei Shtylyov wrote:
>> Hello!
>>
>> On 3/13/2017 7:36 PM, Bartosz Golaszewski wrote:
>>
>>> This SATA controller is quite similar to the one present on the DA850
>>> SoC, but the PHY configuration is different and it supports two HBA
>>> ports.
>>>
>>> The IP suffers from the same PMP issue the DA850 does - if we enable
>>> PMP but don't use it - softreset fails. Appropriate workaround was
>>> implemented in this driver as well.
>>>
>>> Signed-off-by: Bartosz Golaszewski <[email protected]>
>>> ---
>>> drivers/ata/Kconfig | 9 +++
>>> drivers/ata/Makefile | 1 +
>>> drivers/ata/ahci_dm816.c | 200 +++++++++++++++++++++++++++++++++++++++++++++++
>>> 3 files changed, 210 insertions(+)
>>> create mode 100644 drivers/ata/ahci_dm816.c
>>>
>>> diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
>>> index 70b57d2..7f59a7a 100644
>>> --- a/drivers/ata/Kconfig
>>> +++ b/drivers/ata/Kconfig
>>> @@ -118,6 +118,15 @@ config AHCI_DA850
>>>
>>> If unsure, say N.
>>>
>>> +config AHCI_DM816
>>> + tristate "DaVinci DM816 AHCI SATA support"
>>
>> Is it really DaVinci?
>>
>>> + depends on ARCH_OMAP2PLUS
>>
>> Especially if it depends on OMAP...
>
> Hi Sergei,
>
> Yes it's a DaVinci family SoC, but shares a lot of IPs with the OMAP family.
>

Actually, this is more of an OMAP family, which shares some IP from
DaVinci family

I think in other parts of the kernel, we refer to this as TI 816x
instead of using either DaVinci or OMAP.

Kevin