* [PATCH v3 0/4] Add usb phy support for STiH41x SoCs. @ 2014-09-08 9:30 Peter Griffin 2014-09-08 9:30 ` [PATCH v3 1/4] phy: phy-stih41x-usb: " Peter Griffin ` (3 more replies) 0 siblings, 4 replies; 8+ messages in thread From: Peter Griffin @ 2014-09-08 9:30 UTC (permalink / raw) To: linux-arm-kernel This series adds support for the on-chip PHY used for USB 1.1 and 2.0 found on STiH415 and STiH416 consumer electronics SoC's from STMicroelectronics. Changes since v2: - Rebased on top of 3.17-rc3 - Enable driver in multi_v7_defconfig Changes since v1: - Change to select GENERIC_PHY rather than depends for uniformity - Ensure phy_provider_register is called after PHY is created - Add extra commit message for MAINTAINERS patch Peter Griffin (4): phy: phy-stih41x-usb: Add usb phy support for STiH41x SoCs. phy: phy-stih41x-usb: Add dt documentation for USB phy on STiH415/6 MAINTAINERS: Add phy-stih41x-usb.c to ARCH/STI architecture ARM: multi_v7_defconfig: Enable stih41x usb phy driver. .../devicetree/bindings/phy/phy-stih41x-usb.txt | 24 +++ MAINTAINERS | 1 + arch/arm/configs/multi_v7_defconfig | 1 + drivers/phy/Kconfig | 8 + drivers/phy/Makefile | 1 + drivers/phy/phy-stih41x-usb.c | 192 +++++++++++++++++++++ 6 files changed, 227 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/phy-stih41x-usb.txt create mode 100644 drivers/phy/phy-stih41x-usb.c -- 1.9.1 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3 1/4] phy: phy-stih41x-usb: Add usb phy support for STiH41x SoCs. 2014-09-08 9:30 [PATCH v3 0/4] Add usb phy support for STiH41x SoCs Peter Griffin @ 2014-09-08 9:30 ` Peter Griffin 2014-09-08 9:39 ` Kishon Vijay Abraham I 2014-09-08 9:30 ` [PATCH v3 2/4] phy: phy-stih41x-usb: Add dt documentation for USB phy on STiH415/6 Peter Griffin ` (2 subsequent siblings) 3 siblings, 1 reply; 8+ messages in thread From: Peter Griffin @ 2014-09-08 9:30 UTC (permalink / raw) To: linux-arm-kernel This driver adds support for USB (1.1 and 2.0) phy for STiH415 and STiH416 System-On-Chips from STMicroelectronics. Signed-off-by: Maxime Coquelin <maxime.coquelin@st.com> Signed-off-by: Peter Griffin <peter.griffin@linaro.org> --- drivers/phy/Kconfig | 8 ++ drivers/phy/Makefile | 1 + drivers/phy/phy-stih41x-usb.c | 192 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 201 insertions(+) create mode 100644 drivers/phy/phy-stih41x-usb.c diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 0dd7427..26f8a86 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -230,4 +230,12 @@ config PHY_XGENE help This option enables support for APM X-Gene SoC multi-purpose PHY. +config PHY_STIH41X_USB + tristate "STMicroelectronics USB2 PHY driver for STiH41x series" + depends on ARCH_STI + select GENERIC_PHY + help + Enable this to support the USB transceiver that is part of + STMicroelectronics STiH41x SoC series. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 95c69ed..d02f365 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -28,3 +28,4 @@ obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA) += phy-qcom-ipq806x-sata.o obj-$(CONFIG_PHY_ST_SPEAR1310_MIPHY) += phy-spear1310-miphy.o obj-$(CONFIG_PHY_ST_SPEAR1340_MIPHY) += phy-spear1340-miphy.o obj-$(CONFIG_PHY_XGENE) += phy-xgene.o +obj-$(CONFIG_PHY_STIH41X_USB) += phy-stih41x-usb.o diff --git a/drivers/phy/phy-stih41x-usb.c b/drivers/phy/phy-stih41x-usb.c new file mode 100644 index 0000000..7d0a5d4 --- /dev/null +++ b/drivers/phy/phy-stih41x-usb.c @@ -0,0 +1,192 @@ +/* + * Copyright (C) 2014 STMicroelectronics + * + * STMicroelectronics PHY driver for STiH41x USB. + * + * Author: Maxime Coquelin <maxime.coquelin@st.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, as + * published by the Free Software Foundation. + * + */ + +#include <linux/platform_device.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_platform.h> +#include <linux/clk.h> +#include <linux/phy/phy.h> +#include <linux/regmap.h> +#include <linux/mfd/syscon.h> + +#define SYSCFG332 0x80 +#define SYSCFG2520 0x820 + +/** + * struct stih41x_usb_cfg - SoC specific PHY register mapping + * @syscfg: Offset in syscfg registers bank + * @cfg_mask: Bits mask for PHY configuration + * @cfg: Static configuration value for PHY + * @oscok: Notify the PHY oscillator clock is ready + * Setting this bit enable the PHY + */ +struct stih41x_usb_cfg { + u32 syscfg; + u32 cfg_mask; + u32 cfg; + u32 oscok; +}; + +/** + * struct stih41x_usb_phy - Private data for the PHY + * @dev: device for this controller + * @regmap: Syscfg registers bank in which PHY is configured + * @cfg: SoC specific PHY register mapping + * @clk: Oscillator used by the PHY + */ +struct stih41x_usb_phy { + struct device *dev; + struct regmap *regmap; + const struct stih41x_usb_cfg *cfg; + struct clk *clk; +}; + +static struct stih41x_usb_cfg stih415_usb_phy_cfg = { + .syscfg = SYSCFG332, + .cfg_mask = 0x3f, + .cfg = 0x38, + .oscok = BIT(6), +}; + +static struct stih41x_usb_cfg stih416_usb_phy_cfg = { + .syscfg = SYSCFG2520, + .cfg_mask = 0x33f, + .cfg = 0x238, + .oscok = BIT(6), +}; + +static int stih41x_usb_phy_init(struct phy *phy) +{ + struct stih41x_usb_phy *phy_dev = phy_get_drvdata(phy); + + return regmap_update_bits(phy_dev->regmap, phy_dev->cfg->syscfg, + phy_dev->cfg->cfg_mask, phy_dev->cfg->cfg); +} + +static int stih41x_usb_phy_power_on(struct phy *phy) +{ + struct stih41x_usb_phy *phy_dev = phy_get_drvdata(phy); + int ret; + + ret = clk_prepare_enable(phy_dev->clk); + if (ret) { + dev_err(phy_dev->dev, "Failed to enable osc_phy clock\n"); + return ret; + } + + return regmap_update_bits(phy_dev->regmap, phy_dev->cfg->syscfg, + phy_dev->cfg->oscok, phy_dev->cfg->oscok); +} + +static int stih41x_usb_phy_power_off(struct phy *phy) +{ + struct stih41x_usb_phy *phy_dev = phy_get_drvdata(phy); + int ret; + + ret = regmap_update_bits(phy_dev->regmap, phy_dev->cfg->syscfg, + phy_dev->cfg->oscok, 0); + if (ret) { + dev_err(phy_dev->dev, "Failed to clear oscok bit\n"); + return ret; + } + + clk_disable_unprepare(phy_dev->clk); + + return 0; +} + +static struct phy_ops stih41x_usb_phy_ops = { + .init = stih41x_usb_phy_init, + .power_on = stih41x_usb_phy_power_on, + .power_off = stih41x_usb_phy_power_off, + .owner = THIS_MODULE, +}; + +static const struct of_device_id stih41x_usb_phy_of_match[]; + +static int stih41x_usb_phy_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + const struct of_device_id *match; + struct stih41x_usb_phy *phy_dev; + struct device *dev = &pdev->dev; + struct phy_provider *phy_provider; + struct phy *phy; + + phy_dev = devm_kzalloc(dev, sizeof(*phy_dev), GFP_KERNEL); + if (!phy_dev) + return -ENOMEM; + + match = of_match_device(stih41x_usb_phy_of_match, &pdev->dev); + if (!match) + return -ENODEV; + + phy_dev->cfg = match->data; + + phy_dev->regmap = syscon_regmap_lookup_by_phandle(np, "st,syscfg"); + if (IS_ERR(phy_dev->regmap)) { + dev_err(dev, "No syscfg phandle specified\n"); + return PTR_ERR(phy_dev->regmap); + } + + phy_dev->clk = devm_clk_get(dev, "osc_phy"); + if (IS_ERR(phy_dev->clk)) { + dev_err(dev, "osc_phy clk not found\n"); + return PTR_ERR(phy_dev->clk); + } + + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); + if (IS_ERR(phy_provider)) + return PTR_ERR(phy_provider); + + phy = devm_phy_create(dev, NULL, &stih41x_usb_phy_ops, NULL); + + if (IS_ERR(phy)) { + dev_err(dev, "failed to create Display Port PHY\n"); + return PTR_ERR(phy); + } + + phy_dev->dev = dev; + + phy_set_drvdata(phy, phy_dev); + + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); + if (IS_ERR(phy_provider)) + return PTR_ERR(phy_provider); + + return 0; +} + +static const struct of_device_id stih41x_usb_phy_of_match[] = { + { .compatible = "st,stih415-usb-phy", .data = &stih415_usb_phy_cfg }, + { .compatible = "st,stih416-usb-phy", .data = &stih416_usb_phy_cfg }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, stih41x_usb_phy_of_match); + +static struct platform_driver stih41x_usb_phy_driver = { + .probe = stih41x_usb_phy_probe, + .driver = { + .name = "stih41x-usb-phy", + .owner = THIS_MODULE, + .of_match_table = stih41x_usb_phy_of_match, + } +}; +module_platform_driver(stih41x_usb_phy_driver); + +MODULE_AUTHOR("Maxime Coquelin <maxime.coquelin@st.com>"); +MODULE_DESCRIPTION("STMicroelectronics USB PHY driver for STiH41x series"); +MODULE_LICENSE("GPL v2"); -- 1.9.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 1/4] phy: phy-stih41x-usb: Add usb phy support for STiH41x SoCs. 2014-09-08 9:30 ` [PATCH v3 1/4] phy: phy-stih41x-usb: " Peter Griffin @ 2014-09-08 9:39 ` Kishon Vijay Abraham I 2014-09-08 10:31 ` Peter Griffin 0 siblings, 1 reply; 8+ messages in thread From: Kishon Vijay Abraham I @ 2014-09-08 9:39 UTC (permalink / raw) To: linux-arm-kernel Hi, On Monday 08 September 2014 03:00 PM, Peter Griffin wrote: > This driver adds support for USB (1.1 and 2.0) phy for STiH415 and > STiH416 System-On-Chips from STMicroelectronics. > > Signed-off-by: Maxime Coquelin <maxime.coquelin@st.com> > Signed-off-by: Peter Griffin <peter.griffin@linaro.org> > --- > drivers/phy/Kconfig | 8 ++ > drivers/phy/Makefile | 1 + > drivers/phy/phy-stih41x-usb.c | 192 ++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 201 insertions(+) > create mode 100644 drivers/phy/phy-stih41x-usb.c > > diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig > index 0dd7427..26f8a86 100644 > --- a/drivers/phy/Kconfig > +++ b/drivers/phy/Kconfig > @@ -230,4 +230,12 @@ config PHY_XGENE > help > This option enables support for APM X-Gene SoC multi-purpose PHY. > > +config PHY_STIH41X_USB > + tristate "STMicroelectronics USB2 PHY driver for STiH41x series" > + depends on ARCH_STI > + select GENERIC_PHY > + help > + Enable this to support the USB transceiver that is part of > + STMicroelectronics STiH41x SoC series. > + > endmenu > diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile > index 95c69ed..d02f365 100644 > --- a/drivers/phy/Makefile > +++ b/drivers/phy/Makefile > @@ -28,3 +28,4 @@ obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA) += phy-qcom-ipq806x-sata.o > obj-$(CONFIG_PHY_ST_SPEAR1310_MIPHY) += phy-spear1310-miphy.o > obj-$(CONFIG_PHY_ST_SPEAR1340_MIPHY) += phy-spear1340-miphy.o > obj-$(CONFIG_PHY_XGENE) += phy-xgene.o > +obj-$(CONFIG_PHY_STIH41X_USB) += phy-stih41x-usb.o > diff --git a/drivers/phy/phy-stih41x-usb.c b/drivers/phy/phy-stih41x-usb.c > new file mode 100644 > index 0000000..7d0a5d4 > --- /dev/null > +++ b/drivers/phy/phy-stih41x-usb.c > @@ -0,0 +1,192 @@ . . <skip> . . > + > + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); > + if (IS_ERR(phy_provider)) > + return PTR_ERR(phy_provider); > + > + phy = devm_phy_create(dev, NULL, &stih41x_usb_phy_ops, NULL); > + > + if (IS_ERR(phy)) { > + dev_err(dev, "failed to create Display Port PHY\n"); > + return PTR_ERR(phy); > + } > + > + phy_dev->dev = dev; > + > + phy_set_drvdata(phy, phy_dev); > + > + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); > + if (IS_ERR(phy_provider)) > + return PTR_ERR(phy_provider); registering phy provider multiple times.. Thanks Kishon ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3 1/4] phy: phy-stih41x-usb: Add usb phy support for STiH41x SoCs. 2014-09-08 9:39 ` Kishon Vijay Abraham I @ 2014-09-08 10:31 ` Peter Griffin 0 siblings, 0 replies; 8+ messages in thread From: Peter Griffin @ 2014-09-08 10:31 UTC (permalink / raw) To: linux-arm-kernel Hi Kishon, > > + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); > > + if (IS_ERR(phy_provider)) > > + return PTR_ERR(phy_provider); > > registering phy provider multiple times.. Doh. Sorry for the noise, will send a v4 shortly. regards, Peter. ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3 2/4] phy: phy-stih41x-usb: Add dt documentation for USB phy on STiH415/6 2014-09-08 9:30 [PATCH v3 0/4] Add usb phy support for STiH41x SoCs Peter Griffin 2014-09-08 9:30 ` [PATCH v3 1/4] phy: phy-stih41x-usb: " Peter Griffin @ 2014-09-08 9:30 ` Peter Griffin 2014-09-08 9:30 ` [PATCH v3 3/4] MAINTAINERS: Add phy-stih41x-usb.c to ARCH/STI architecture Peter Griffin 2014-09-08 9:30 ` [PATCH v3 4/4] ARM: multi_v7_defconfig: Enable stih41x usb phy driver Peter Griffin 3 siblings, 0 replies; 8+ messages in thread From: Peter Griffin @ 2014-09-08 9:30 UTC (permalink / raw) To: linux-arm-kernel This patch adds dt documentation bindings for the usb phy found on STiH415/5 SoC's from STMicroelectronics, which support USB 1.1 and 2.0. Signed-off-by: Maxime Coquelin <maxime.coquelin@st.com> Signed-off-by: Peter Griffin <peter.griffin@linaro.org> --- .../devicetree/bindings/phy/phy-stih41x-usb.txt | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/phy-stih41x-usb.txt diff --git a/Documentation/devicetree/bindings/phy/phy-stih41x-usb.txt b/Documentation/devicetree/bindings/phy/phy-stih41x-usb.txt new file mode 100644 index 0000000..00944a0 --- /dev/null +++ b/Documentation/devicetree/bindings/phy/phy-stih41x-usb.txt @@ -0,0 +1,24 @@ +STMicroelectronics STiH41x USB PHY binding +------------------------------------------ + +This file contains documentation for the usb phy found in STiH415/6 SoCs from +STMicroelectronics. + +Required properties: +- compatible : should be "st,stih416-usb-phy" or "st,stih415-usb-phy" +- st,syscfg : should be a phandle of the syscfg node +- clock-names : must contain "osc_phy" +- clocks : must contain an entry for each name in clock-names. +See: Documentation/devicetree/bindings/clock/clock-bindings.txt +- #phy-cells : must be 0 for this phy +See: Documentation/devicetree/bindings/phy/phy-bindings.txt + +Example: + +usb2_phy: usb2phy at 0 { + compatible = "st,stih416-usb-phy"; + #phy-cell = <0>; + st,syscfg = <&syscfg_rear>; + clocks = <&clk_sysin>; + clock-names = "osc_phy"; +}; -- 1.9.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 3/4] MAINTAINERS: Add phy-stih41x-usb.c to ARCH/STI architecture 2014-09-08 9:30 [PATCH v3 0/4] Add usb phy support for STiH41x SoCs Peter Griffin 2014-09-08 9:30 ` [PATCH v3 1/4] phy: phy-stih41x-usb: " Peter Griffin 2014-09-08 9:30 ` [PATCH v3 2/4] phy: phy-stih41x-usb: Add dt documentation for USB phy on STiH415/6 Peter Griffin @ 2014-09-08 9:30 ` Peter Griffin 2014-09-08 9:30 ` [PATCH v3 4/4] ARM: multi_v7_defconfig: Enable stih41x usb phy driver Peter Griffin 3 siblings, 0 replies; 8+ messages in thread From: Peter Griffin @ 2014-09-08 9:30 UTC (permalink / raw) To: linux-arm-kernel This patch adds the new phy-sti41x-usb.c PHY driver found on STMicroelectronics stih41x consumer electronics SoC's into the STI arch section of the maintainers file. Signed-off-by: Peter Griffin <peter.griffin@linaro.org> --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index cf24bb5..4cb59cf 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1398,6 +1398,7 @@ F: drivers/media/rc/st_rc.c F: drivers/i2c/busses/i2c-st.c F: drivers/tty/serial/st-asc.c F: drivers/mmc/host/sdhci-st.c +F: drivers/phy/phy-stih41x-usb.c ARM/TECHNOLOGIC SYSTEMS TS7250 MACHINE SUPPORT M: Lennert Buytenhek <kernel@wantstofly.org> -- 1.9.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 4/4] ARM: multi_v7_defconfig: Enable stih41x usb phy driver. 2014-09-08 9:30 [PATCH v3 0/4] Add usb phy support for STiH41x SoCs Peter Griffin ` (2 preceding siblings ...) 2014-09-08 9:30 ` [PATCH v3 3/4] MAINTAINERS: Add phy-stih41x-usb.c to ARCH/STI architecture Peter Griffin @ 2014-09-08 9:30 ` Peter Griffin 2014-09-08 9:41 ` Kishon Vijay Abraham I 3 siblings, 1 reply; 8+ messages in thread From: Peter Griffin @ 2014-09-08 9:30 UTC (permalink / raw) To: linux-arm-kernel This driver is used by the ehci / ohci usb controllers on stih41x SoCs. Signed-off-by: Peter Griffin <peter.griffin@linaro.org> --- arch/arm/configs/multi_v7_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig index 5fb95fb..74fd4a1 100644 --- a/arch/arm/configs/multi_v7_defconfig +++ b/arch/arm/configs/multi_v7_defconfig @@ -387,6 +387,7 @@ CONFIG_PWM_VT8500=y CONFIG_OMAP_USB2=y CONFIG_TI_PIPE3=y CONFIG_PHY_MIPHY365X=y +CONFIG_PHY_STIH41X_USB=y CONFIG_PHY_SUN4I_USB=y CONFIG_EXT4_FS=y CONFIG_VFAT_FS=y -- 1.9.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 4/4] ARM: multi_v7_defconfig: Enable stih41x usb phy driver. 2014-09-08 9:30 ` [PATCH v3 4/4] ARM: multi_v7_defconfig: Enable stih41x usb phy driver Peter Griffin @ 2014-09-08 9:41 ` Kishon Vijay Abraham I 0 siblings, 0 replies; 8+ messages in thread From: Kishon Vijay Abraham I @ 2014-09-08 9:41 UTC (permalink / raw) To: linux-arm-kernel On Monday 08 September 2014 03:00 PM, Peter Griffin wrote: > This driver is used by the ehci / ohci usb controllers on stih41x SoCs. > > Signed-off-by: Peter Griffin <peter.griffin@linaro.org> FWIW Acked-by: Kishon Vijay Abraham I <kishon@ti.com> > --- > arch/arm/configs/multi_v7_defconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig > index 5fb95fb..74fd4a1 100644 > --- a/arch/arm/configs/multi_v7_defconfig > +++ b/arch/arm/configs/multi_v7_defconfig > @@ -387,6 +387,7 @@ CONFIG_PWM_VT8500=y > CONFIG_OMAP_USB2=y > CONFIG_TI_PIPE3=y > CONFIG_PHY_MIPHY365X=y > +CONFIG_PHY_STIH41X_USB=y > CONFIG_PHY_SUN4I_USB=y > CONFIG_EXT4_FS=y > CONFIG_VFAT_FS=y > ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-09-08 10:31 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-09-08 9:30 [PATCH v3 0/4] Add usb phy support for STiH41x SoCs Peter Griffin 2014-09-08 9:30 ` [PATCH v3 1/4] phy: phy-stih41x-usb: " Peter Griffin 2014-09-08 9:39 ` Kishon Vijay Abraham I 2014-09-08 10:31 ` Peter Griffin 2014-09-08 9:30 ` [PATCH v3 2/4] phy: phy-stih41x-usb: Add dt documentation for USB phy on STiH415/6 Peter Griffin 2014-09-08 9:30 ` [PATCH v3 3/4] MAINTAINERS: Add phy-stih41x-usb.c to ARCH/STI architecture Peter Griffin 2014-09-08 9:30 ` [PATCH v3 4/4] ARM: multi_v7_defconfig: Enable stih41x usb phy driver Peter Griffin 2014-09-08 9:41 ` Kishon Vijay Abraham I
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).