* [PATCH] phy: Add USB HSIC PHY driver for Marvell MMP3 SoC
@ 2020-03-09 12:58 Lubomir Rintel
2020-03-13 11:22 ` Kishon Vijay Abraham I
0 siblings, 1 reply; 3+ messages in thread
From: Lubomir Rintel @ 2020-03-09 12:58 UTC (permalink / raw)
To: Kishon Vijay Abraham I; +Cc: linux-kernel, Lubomir Rintel
Add PHY driver for the HSICs found on Marvell MMP3 SoC. The driver is
rather straightforward -- the PHY essentially just needs to be enabled.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
drivers/phy/marvell/Kconfig | 12 +++++
drivers/phy/marvell/Makefile | 1 +
drivers/phy/marvell/phy-mmp3-hsic.c | 82 +++++++++++++++++++++++++++++
3 files changed, 95 insertions(+)
create mode 100644 drivers/phy/marvell/phy-mmp3-hsic.c
diff --git a/drivers/phy/marvell/Kconfig b/drivers/phy/marvell/Kconfig
index 8f6273c837ec3..6c96f2bf52665 100644
--- a/drivers/phy/marvell/Kconfig
+++ b/drivers/phy/marvell/Kconfig
@@ -116,3 +116,15 @@ config PHY_MMP3_USB
The PHY driver will be used by Marvell udc/ehci/otg driver.
To compile this driver as a module, choose M here.
+
+config PHY_MMP3_HSIC
+ tristate "Marvell MMP3 USB HSIC PHY Driver"
+ depends on MACH_MMP3_DT || COMPILE_TEST
+ select GENERIC_PHY
+ help
+ Enable this to support Marvell MMP3 USB HSIC PHY driver for
+ Marvell MMP3 SoC. This driver will be used my the Marvell EHCI
+ driver to initialize the interface to internal USB HSIC
+ components on MMP3-based boards.
+
+ To compile this driver as a module, choose M here.
diff --git a/drivers/phy/marvell/Makefile b/drivers/phy/marvell/Makefile
index 5a106b1549f41..7f296ef028292 100644
--- a/drivers/phy/marvell/Makefile
+++ b/drivers/phy/marvell/Makefile
@@ -3,6 +3,7 @@ obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY) += phy-armada375-usb2.o
obj-$(CONFIG_PHY_BERLIN_SATA) += phy-berlin-sata.o
obj-$(CONFIG_PHY_BERLIN_USB) += phy-berlin-usb.o
obj-$(CONFIG_PHY_MMP3_USB) += phy-mmp3-usb.o
+obj-$(CONFIG_PHY_MMP3_HSIC) += phy-mmp3-hsic.o
obj-$(CONFIG_PHY_MVEBU_A3700_COMPHY) += phy-mvebu-a3700-comphy.o
obj-$(CONFIG_PHY_MVEBU_A3700_UTMI) += phy-mvebu-a3700-utmi.o
obj-$(CONFIG_PHY_MVEBU_A38X_COMPHY) += phy-armada38x-comphy.o
diff --git a/drivers/phy/marvell/phy-mmp3-hsic.c b/drivers/phy/marvell/phy-mmp3-hsic.c
new file mode 100644
index 0000000000000..f7b430f6f6f05
--- /dev/null
+++ b/drivers/phy/marvell/phy-mmp3-hsic.c
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2020 Lubomir Rintel <lkundrak@v3.sk>
+ */
+
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/phy/phy.h>
+#include <linux/platform_device.h>
+
+#define HSIC_CTRL 0x08
+#define HSIC_ENABLE BIT(7)
+#define PLL_BYPASS BIT(4)
+
+static int mmp3_hsic_phy_init(struct phy *phy)
+{
+ void __iomem *base = phy_get_drvdata(phy);
+ u32 hsic_ctrl;
+
+ hsic_ctrl = readl_relaxed(base + HSIC_CTRL);
+ hsic_ctrl |= HSIC_ENABLE;
+ hsic_ctrl |= PLL_BYPASS;
+ writel_relaxed(hsic_ctrl, base + HSIC_CTRL);
+
+ return 0;
+}
+
+static const struct phy_ops mmp3_hsic_phy_ops = {
+ .init = mmp3_hsic_phy_init,
+ .owner = THIS_MODULE,
+};
+
+static const struct of_device_id mmp3_hsic_phy_of_match[] = {
+ { .compatible = "marvell,mmp3-hsic-phy", },
+ { },
+};
+MODULE_DEVICE_TABLE(of, mmp3_hsic_phy_of_match);
+
+static int mmp3_hsic_phy_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct phy_provider *provider;
+ struct resource *resource;
+ void __iomem *base;
+ struct phy *phy;
+
+ resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ base = devm_ioremap_resource(dev, resource);
+ if (IS_ERR(base)) {
+ dev_err(dev, "failed to remap PHY regs\n");
+ return PTR_ERR(base);
+ }
+
+ phy = devm_phy_create(dev, NULL, &mmp3_hsic_phy_ops);
+ if (IS_ERR(phy)) {
+ dev_err(dev, "failed to create PHY\n");
+ return PTR_ERR(phy);
+ }
+
+ phy_set_drvdata(phy, base);
+ provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
+ if (IS_ERR(provider)) {
+ dev_err(dev, "failed to register PHY provider\n");
+ return PTR_ERR(provider);
+ }
+
+ return 0;
+}
+
+static struct platform_driver mmp3_hsic_phy_driver = {
+ .probe = mmp3_hsic_phy_probe,
+ .driver = {
+ .name = "mmp3-hsic-phy",
+ .of_match_table = mmp3_hsic_phy_of_match,
+ },
+};
+module_platform_driver(mmp3_hsic_phy_driver);
+
+MODULE_AUTHOR("Lubomir Rintel <lkundrak@v3.sk>");
+MODULE_DESCRIPTION("Marvell MMP3 USB HSIC PHY Driver");
+MODULE_LICENSE("GPL");
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] phy: Add USB HSIC PHY driver for Marvell MMP3 SoC
2020-03-09 12:58 [PATCH] phy: Add USB HSIC PHY driver for Marvell MMP3 SoC Lubomir Rintel
@ 2020-03-13 11:22 ` Kishon Vijay Abraham I
2020-03-14 16:38 ` Lubomir Rintel
0 siblings, 1 reply; 3+ messages in thread
From: Kishon Vijay Abraham I @ 2020-03-13 11:22 UTC (permalink / raw)
To: Lubomir Rintel; +Cc: linux-kernel
Hi,
On 09/03/20 6:28 pm, Lubomir Rintel wrote:
> Add PHY driver for the HSICs found on Marvell MMP3 SoC. The driver is
> rather straightforward -- the PHY essentially just needs to be enabled.
>
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> ---
> drivers/phy/marvell/Kconfig | 12 +++++
> drivers/phy/marvell/Makefile | 1 +
> drivers/phy/marvell/phy-mmp3-hsic.c | 82 +++++++++++++++++++++++++++++
> 3 files changed, 95 insertions(+)
> create mode 100644 drivers/phy/marvell/phy-mmp3-hsic.c
>
> diff --git a/drivers/phy/marvell/Kconfig b/drivers/phy/marvell/Kconfig
> index 8f6273c837ec3..6c96f2bf52665 100644
> --- a/drivers/phy/marvell/Kconfig
> +++ b/drivers/phy/marvell/Kconfig
> @@ -116,3 +116,15 @@ config PHY_MMP3_USB
> The PHY driver will be used by Marvell udc/ehci/otg driver.
>
> To compile this driver as a module, choose M here.
> +
> +config PHY_MMP3_HSIC
> + tristate "Marvell MMP3 USB HSIC PHY Driver"
> + depends on MACH_MMP3_DT || COMPILE_TEST
> + select GENERIC_PHY
> + help
> + Enable this to support Marvell MMP3 USB HSIC PHY driver for
> + Marvell MMP3 SoC. This driver will be used my the Marvell EHCI
> + driver to initialize the interface to internal USB HSIC
> + components on MMP3-based boards.
> +
> + To compile this driver as a module, choose M here.
> diff --git a/drivers/phy/marvell/Makefile b/drivers/phy/marvell/Makefile
> index 5a106b1549f41..7f296ef028292 100644
> --- a/drivers/phy/marvell/Makefile
> +++ b/drivers/phy/marvell/Makefile
> @@ -3,6 +3,7 @@ obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY) += phy-armada375-usb2.o
> obj-$(CONFIG_PHY_BERLIN_SATA) += phy-berlin-sata.o
> obj-$(CONFIG_PHY_BERLIN_USB) += phy-berlin-usb.o
> obj-$(CONFIG_PHY_MMP3_USB) += phy-mmp3-usb.o
> +obj-$(CONFIG_PHY_MMP3_HSIC) += phy-mmp3-hsic.o
> obj-$(CONFIG_PHY_MVEBU_A3700_COMPHY) += phy-mvebu-a3700-comphy.o
> obj-$(CONFIG_PHY_MVEBU_A3700_UTMI) += phy-mvebu-a3700-utmi.o
> obj-$(CONFIG_PHY_MVEBU_A38X_COMPHY) += phy-armada38x-comphy.o
> diff --git a/drivers/phy/marvell/phy-mmp3-hsic.c b/drivers/phy/marvell/phy-mmp3-hsic.c
> new file mode 100644
> index 0000000000000..f7b430f6f6f05
> --- /dev/null
> +++ b/drivers/phy/marvell/phy-mmp3-hsic.c
> @@ -0,0 +1,82 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2020 Lubomir Rintel <lkundrak@v3.sk>
> + */
> +
> +#include <linux/delay.h>
> +#include <linux/io.h>
> +#include <linux/module.h>
> +#include <linux/phy/phy.h>
> +#include <linux/platform_device.h>
> +
> +#define HSIC_CTRL 0x08
> +#define HSIC_ENABLE BIT(7)
> +#define PLL_BYPASS BIT(4)
> +
> +static int mmp3_hsic_phy_init(struct phy *phy)
> +{
> + void __iomem *base = phy_get_drvdata(phy);
> + u32 hsic_ctrl;
> +
> + hsic_ctrl = readl_relaxed(base + HSIC_CTRL);
> + hsic_ctrl |= HSIC_ENABLE;
> + hsic_ctrl |= PLL_BYPASS;
> + writel_relaxed(hsic_ctrl, base + HSIC_CTRL);
> +
> + return 0;
> +}
> +
> +static const struct phy_ops mmp3_hsic_phy_ops = {
> + .init = mmp3_hsic_phy_init,
> + .owner = THIS_MODULE,
> +};
> +
> +static const struct of_device_id mmp3_hsic_phy_of_match[] = {
> + { .compatible = "marvell,mmp3-hsic-phy", },
Where is the binding documentation for this?
Thanks
Kishon
> + { },
> +};
> +MODULE_DEVICE_TABLE(of, mmp3_hsic_phy_of_match);
> +
> +static int mmp3_hsic_phy_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct phy_provider *provider;
> + struct resource *resource;
> + void __iomem *base;
> + struct phy *phy;
> +
> + resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + base = devm_ioremap_resource(dev, resource);
> + if (IS_ERR(base)) {
> + dev_err(dev, "failed to remap PHY regs\n");
> + return PTR_ERR(base);
> + }
> +
> + phy = devm_phy_create(dev, NULL, &mmp3_hsic_phy_ops);
> + if (IS_ERR(phy)) {
> + dev_err(dev, "failed to create PHY\n");
> + return PTR_ERR(phy);
> + }
> +
> + phy_set_drvdata(phy, base);
> + provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
> + if (IS_ERR(provider)) {
> + dev_err(dev, "failed to register PHY provider\n");
> + return PTR_ERR(provider);
> + }
> +
> + return 0;
> +}
> +
> +static struct platform_driver mmp3_hsic_phy_driver = {
> + .probe = mmp3_hsic_phy_probe,
> + .driver = {
> + .name = "mmp3-hsic-phy",
> + .of_match_table = mmp3_hsic_phy_of_match,
> + },
> +};
> +module_platform_driver(mmp3_hsic_phy_driver);
> +
> +MODULE_AUTHOR("Lubomir Rintel <lkundrak@v3.sk>");
> +MODULE_DESCRIPTION("Marvell MMP3 USB HSIC PHY Driver");
> +MODULE_LICENSE("GPL");
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] phy: Add USB HSIC PHY driver for Marvell MMP3 SoC
2020-03-13 11:22 ` Kishon Vijay Abraham I
@ 2020-03-14 16:38 ` Lubomir Rintel
0 siblings, 0 replies; 3+ messages in thread
From: Lubomir Rintel @ 2020-03-14 16:38 UTC (permalink / raw)
To: Kishon Vijay Abraham I; +Cc: linux-kernel
On Fri, Mar 13, 2020 at 04:52:00PM +0530, Kishon Vijay Abraham I wrote:
> Hi,
>
> On 09/03/20 6:28 pm, Lubomir Rintel wrote:
> > Add PHY driver for the HSICs found on Marvell MMP3 SoC. The driver is
> > rather straightforward -- the PHY essentially just needs to be enabled.
> >
> > Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> > ---
> > drivers/phy/marvell/Kconfig | 12 +++++
> > drivers/phy/marvell/Makefile | 1 +
> > drivers/phy/marvell/phy-mmp3-hsic.c | 82 +++++++++++++++++++++++++++++
> > 3 files changed, 95 insertions(+)
> > create mode 100644 drivers/phy/marvell/phy-mmp3-hsic.c
> >
...
> > diff --git a/drivers/phy/marvell/phy-mmp3-hsic.c b/drivers/phy/marvell/phy-mmp3-hsic.c
> > new file mode 100644
> > index 0000000000000..f7b430f6f6f05
> > --- /dev/null
> > +++ b/drivers/phy/marvell/phy-mmp3-hsic.c
...
> > +static const struct of_device_id mmp3_hsic_phy_of_match[] = {
> > + { .compatible = "marvell,mmp3-hsic-phy", },
>
> Where is the binding documentation for this?
There's one in mainline:
Documentation/devicetree/bindings/phy/marvell,mmp3-hsic-phy.yaml
It got added just to document the compatible string at the time I thought
usb-nop-xceiv would be sufficient to support the hardware.
It needs some fixing -- the "reset-gpios" shouldn't be there. I'll
follow up with a patch that removes it; please let me know if anything
else needs to be fixed there.
> Thanks
> Kishon
Thank you,
Lubo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-03-15 2:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-09 12:58 [PATCH] phy: Add USB HSIC PHY driver for Marvell MMP3 SoC Lubomir Rintel
2020-03-13 11:22 ` Kishon Vijay Abraham I
2020-03-14 16:38 ` Lubomir Rintel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).