Re: [resend PATCH v3 4/4] usb: phy: add phy-hi6220-usb
On Wed, Feb 11, 2015 at 11:10:31AM +0200, Baruch Siach wrote: > Hi Peter, Felipe, > > > > new drivers only on drivers/phy/, sorry. > > > > This driver has many USB dependencies, like otg, gadget. I don't know it > > can use generic phy currently. > > I would like to remind you the thread at > http://thread.gmane.org/gmane.linux.kernel/1858137. I have a USB PHY driver > here that depends on notify_connect/notify_disconnect, which are not > currently > provided by the generic phy infrastructure (drivers/phy/). What would be > acceptable solution for this case? work with Kishon (generic phy maintainer) to add missing pieces you need. -- balbi signature.asc Description: Digital signature
Re: [resend PATCH v3 4/4] usb: phy: add phy-hi6220-usb
On Tue, Feb 10, 2015 at 10:53:23PM +0800, zhangfei wrote: > > > On 02/10/2015 10:48 PM, Felipe Balbi wrote: > >On Tue, Feb 10, 2015 at 05:10:04PM +0800, Zhangfei Gao wrote: > >>Add usb phy controller for hi6220 platform > >> > >>Signed-off-by: Zhangfei Gao > >>--- > >> drivers/usb/phy/Kconfig | 9 ++ > >> drivers/usb/phy/Makefile | 1 + > >> drivers/usb/phy/phy-hi6220-usb.c | 306 > >> +++ > >> 3 files changed, 316 insertions(+) > >> create mode 100644 drivers/usb/phy/phy-hi6220-usb.c > >> > >>diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig > >>index c6d0c8e..405a3d0 100644 > >>--- a/drivers/usb/phy/Kconfig > >>+++ b/drivers/usb/phy/Kconfig > >>@@ -173,6 +173,15 @@ config USB_MXS_PHY > >> > >> MXS Phy is used by some of the i.MX SoCs, for example imx23/28/6x. > >> > >>+config USB_HI6220_PHY > >>+ tristate "hi6220 USB PHY support" > >>+ select USB_PHY > >>+ select MFD_SYSCON > >>+ help > >>+ Enable this to support the HISILICON HI6220 USB PHY. > >>+ > >>+ To compile this driver as a module, choose M here. > >>+ > >> config USB_RCAR_PHY > >>tristate "Renesas R-Car USB PHY support" > >>depends on USB || USB_GADGET > >>diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile > >>index 75f2bba..00172d3 100644 > >>--- a/drivers/usb/phy/Makefile > >>+++ b/drivers/usb/phy/Makefile > >>@@ -18,6 +18,7 @@ obj-$(CONFIG_SAMSUNG_USBPHY) += > >>phy-samsung-usb.o > >> obj-$(CONFIG_TWL6030_USB) += phy-twl6030-usb.o > >> obj-$(CONFIG_USB_EHCI_TEGRA) += phy-tegra-usb.o > >> obj-$(CONFIG_USB_GPIO_VBUS) += phy-gpio-vbus-usb.o > >>+obj-$(CONFIG_USB_HI6220_PHY) += phy-hi6220-usb.o > > > >new drivers only on drivers/phy/, sorry. > > > OK, thanks for the info, I don't know this at all. > So even usb phy should be put under drivers/phy/. > > Will change that. yes, thank you -- balbi signature.asc Description: Digital signature
Re: [resend PATCH v3 4/4] usb: phy: add phy-hi6220-usb
On Wed, Feb 11, 2015 at 01:30:53AM +, Peter Chen wrote: > > > > Signed-off-by: Zhangfei Gao > > > --- > > > drivers/usb/phy/Kconfig | 9 ++ > > > drivers/usb/phy/Makefile | 1 + > > > drivers/usb/phy/phy-hi6220-usb.c | 306 > > > +++ > > > 3 files changed, 316 insertions(+) > > > create mode 100644 drivers/usb/phy/phy-hi6220-usb.c > > > > > > diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index > > > c6d0c8e..405a3d0 100644 > > > --- a/drivers/usb/phy/Kconfig > > > +++ b/drivers/usb/phy/Kconfig > > > @@ -173,6 +173,15 @@ config USB_MXS_PHY > > > > > > MXS Phy is used by some of the i.MX SoCs, for example imx23/28/6x. > > > > > > +config USB_HI6220_PHY > > > + tristate "hi6220 USB PHY support" > > > + select USB_PHY > > > + select MFD_SYSCON > > > + help > > > + Enable this to support the HISILICON HI6220 USB PHY. > > > + > > > + To compile this driver as a module, choose M here. > > > + > > > config USB_RCAR_PHY > > > tristate "Renesas R-Car USB PHY support" > > > depends on USB || USB_GADGET > > > diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index > > > 75f2bba..00172d3 100644 > > > --- a/drivers/usb/phy/Makefile > > > +++ b/drivers/usb/phy/Makefile > > > @@ -18,6 +18,7 @@ obj-$(CONFIG_SAMSUNG_USBPHY)+= phy- > > samsung-usb.o > > > obj-$(CONFIG_TWL6030_USB)+= phy-twl6030-usb.o > > > obj-$(CONFIG_USB_EHCI_TEGRA) += phy-tegra-usb.o > > > obj-$(CONFIG_USB_GPIO_VBUS) += phy-gpio-vbus-usb.o > > > +obj-$(CONFIG_USB_HI6220_PHY) += phy-hi6220-usb.o > > > > new drivers only on drivers/phy/, sorry. > > > > This driver has many USB dependencies, like otg, gadget. I don't know it > can use generic phy currently. then we improve generic phy framework. It's about time we moved everything to that anyway. -- balbi signature.asc Description: Digital signature
Re: [resend PATCH v3 4/4] usb: phy: add phy-hi6220-usb
On 02/10/2015 10:48 PM, Felipe Balbi wrote: diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index c6d0c8e..405a3d0 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -173,6 +173,15 @@ config USB_MXS_PHY MXS Phy is used by some of the i.MX SoCs, for example imx23/28/6x. +config USB_HI6220_PHY + tristate "hi6220 USB PHY support" + select USB_PHY + select MFD_SYSCON + help + Enable this to support the HISILICON HI6220 USB PHY. + + To compile this driver as a module, choose M here. + config USB_RCAR_PHY tristate "Renesas R-Car USB PHY support" depends on USB || USB_GADGET diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index 75f2bba..00172d3 100644 --- a/drivers/usb/phy/Makefile +++ b/drivers/usb/phy/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_SAMSUNG_USBPHY) += phy-samsung-usb.o obj-$(CONFIG_TWL6030_USB) += phy-twl6030-usb.o obj-$(CONFIG_USB_EHCI_TEGRA) += phy-tegra-usb.o obj-$(CONFIG_USB_GPIO_VBUS) += phy-gpio-vbus-usb.o +obj-$(CONFIG_USB_HI6220_PHY) += phy-hi6220-usb.o new drivers only on drivers/phy/, sorry. One more quesiton. Should I also move Documentation/devicetree/bindings/usb/hi6220-usb.txt to Documentation/devicetree/bindings/phy/? I describing both usb controller and phy here, is it still should be put under Documentation/devicetree/bindings/usb/? Hisilicon hi6220 SoC USB controller - usb controller is inherited from dwc2, refer dwc2.txt - Required properties: - compatible: "hisilicon,hi6220-usb" Refer to dwc2.txt for dwc2 usb properties PHY: - Required properties: - compatible: "hisilicon,hi6220-usb-phy" - vcc-supply: phandle to the regulator that provides power to the PHY. - clocks: phandle and clock specifier of the PHY clock. - hisilicon,peripheral-syscon: phandle of syscon used to control peripheral. - hisilicon,vbus-gpios: gpio of detecting vbus. - hisilicon,id-gpios: gpio of detecting id. Example: sys_ctrl: syscon@f703 { compatible = "hisilicon,sysctrl", "syscon"; reg = <0x0 0xf703 0x0 0x1000>; }; usb_phy: usb-phy { compatible = "hisilicon,hi6220-usb-phy"; vcc-supply = <&fixed_5v_hub>; hisilicon,vbus-gpios = <&gpio2 6 0>; hisilicon,id-gpios = <&gpio2 5 0>; hisilicon,peripheral-syscon = <&sys_ctrl>; clocks = <&clock_sys HI6220_USBOTG_HCLK>; }; usb: usb@f72c { compatible = "hisilicon,hi6220-usb"; reg = <0x0 0xf72c 0x0 0x4>; phys = <&usb_phy>; dr_mode = "otg"; g-use-dma; g-rx-fifo-size = <512>; g-np-tx-fifo-size = <128>; g-tx-fifo-size = <128>; interrupts = <0 77 0x4>; }; -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [resend PATCH v3 4/4] usb: phy: add phy-hi6220-usb
Hi Peter, Felipe, > > new drivers only on drivers/phy/, sorry. > > This driver has many USB dependencies, like otg, gadget. I don't know it > can use generic phy currently. I would like to remind you the thread at http://thread.gmane.org/gmane.linux.kernel/1858137. I have a USB PHY driver here that depends on notify_connect/notify_disconnect, which are not currently provided by the generic phy infrastructure (drivers/phy/). What would be acceptable solution for this case? baruch -- http://baruch.siach.name/blog/ ~. .~ Tk Open Systems =}ooO--U--Ooo{= - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il - -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [resend PATCH v3 4/4] usb: phy: add phy-hi6220-usb
> > Signed-off-by: Zhangfei Gao > > --- > > drivers/usb/phy/Kconfig | 9 ++ > > drivers/usb/phy/Makefile | 1 + > > drivers/usb/phy/phy-hi6220-usb.c | 306 > > +++ > > 3 files changed, 316 insertions(+) > > create mode 100644 drivers/usb/phy/phy-hi6220-usb.c > > > > diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index > > c6d0c8e..405a3d0 100644 > > --- a/drivers/usb/phy/Kconfig > > +++ b/drivers/usb/phy/Kconfig > > @@ -173,6 +173,15 @@ config USB_MXS_PHY > > > > MXS Phy is used by some of the i.MX SoCs, for example imx23/28/6x. > > > > +config USB_HI6220_PHY > > + tristate "hi6220 USB PHY support" > > + select USB_PHY > > + select MFD_SYSCON > > + help > > + Enable this to support the HISILICON HI6220 USB PHY. > > + > > + To compile this driver as a module, choose M here. > > + > > config USB_RCAR_PHY > > tristate "Renesas R-Car USB PHY support" > > depends on USB || USB_GADGET > > diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index > > 75f2bba..00172d3 100644 > > --- a/drivers/usb/phy/Makefile > > +++ b/drivers/usb/phy/Makefile > > @@ -18,6 +18,7 @@ obj-$(CONFIG_SAMSUNG_USBPHY) += phy- > samsung-usb.o > > obj-$(CONFIG_TWL6030_USB) += phy-twl6030-usb.o > > obj-$(CONFIG_USB_EHCI_TEGRA) += phy-tegra-usb.o > > obj-$(CONFIG_USB_GPIO_VBUS)+= phy-gpio-vbus-usb.o > > +obj-$(CONFIG_USB_HI6220_PHY) += phy-hi6220-usb.o > > new drivers only on drivers/phy/, sorry. > This driver has many USB dependencies, like otg, gadget. I don't know it can use generic phy currently. Peter -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [resend PATCH v3 4/4] usb: phy: add phy-hi6220-usb
On 02/10/2015 10:48 PM, Felipe Balbi wrote: On Tue, Feb 10, 2015 at 05:10:04PM +0800, Zhangfei Gao wrote: Add usb phy controller for hi6220 platform Signed-off-by: Zhangfei Gao --- drivers/usb/phy/Kconfig | 9 ++ drivers/usb/phy/Makefile | 1 + drivers/usb/phy/phy-hi6220-usb.c | 306 +++ 3 files changed, 316 insertions(+) create mode 100644 drivers/usb/phy/phy-hi6220-usb.c diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index c6d0c8e..405a3d0 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -173,6 +173,15 @@ config USB_MXS_PHY MXS Phy is used by some of the i.MX SoCs, for example imx23/28/6x. +config USB_HI6220_PHY + tristate "hi6220 USB PHY support" + select USB_PHY + select MFD_SYSCON + help + Enable this to support the HISILICON HI6220 USB PHY. + + To compile this driver as a module, choose M here. + config USB_RCAR_PHY tristate "Renesas R-Car USB PHY support" depends on USB || USB_GADGET diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index 75f2bba..00172d3 100644 --- a/drivers/usb/phy/Makefile +++ b/drivers/usb/phy/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_SAMSUNG_USBPHY) += phy-samsung-usb.o obj-$(CONFIG_TWL6030_USB) += phy-twl6030-usb.o obj-$(CONFIG_USB_EHCI_TEGRA) += phy-tegra-usb.o obj-$(CONFIG_USB_GPIO_VBUS) += phy-gpio-vbus-usb.o +obj-$(CONFIG_USB_HI6220_PHY) += phy-hi6220-usb.o new drivers only on drivers/phy/, sorry. OK, thanks for the info, I don't know this at all. So even usb phy should be put under drivers/phy/. Will change that. Thanks Felipe -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [resend PATCH v3 4/4] usb: phy: add phy-hi6220-usb
On Tue, Feb 10, 2015 at 05:10:04PM +0800, Zhangfei Gao wrote: > Add usb phy controller for hi6220 platform > > Signed-off-by: Zhangfei Gao > --- > drivers/usb/phy/Kconfig | 9 ++ > drivers/usb/phy/Makefile | 1 + > drivers/usb/phy/phy-hi6220-usb.c | 306 > +++ > 3 files changed, 316 insertions(+) > create mode 100644 drivers/usb/phy/phy-hi6220-usb.c > > diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig > index c6d0c8e..405a3d0 100644 > --- a/drivers/usb/phy/Kconfig > +++ b/drivers/usb/phy/Kconfig > @@ -173,6 +173,15 @@ config USB_MXS_PHY > > MXS Phy is used by some of the i.MX SoCs, for example imx23/28/6x. > > +config USB_HI6220_PHY > + tristate "hi6220 USB PHY support" > + select USB_PHY > + select MFD_SYSCON > + help > + Enable this to support the HISILICON HI6220 USB PHY. > + > + To compile this driver as a module, choose M here. > + > config USB_RCAR_PHY > tristate "Renesas R-Car USB PHY support" > depends on USB || USB_GADGET > diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile > index 75f2bba..00172d3 100644 > --- a/drivers/usb/phy/Makefile > +++ b/drivers/usb/phy/Makefile > @@ -18,6 +18,7 @@ obj-$(CONFIG_SAMSUNG_USBPHY)+= > phy-samsung-usb.o > obj-$(CONFIG_TWL6030_USB)+= phy-twl6030-usb.o > obj-$(CONFIG_USB_EHCI_TEGRA) += phy-tegra-usb.o > obj-$(CONFIG_USB_GPIO_VBUS) += phy-gpio-vbus-usb.o > +obj-$(CONFIG_USB_HI6220_PHY) += phy-hi6220-usb.o new drivers only on drivers/phy/, sorry. -- balbi signature.asc Description: Digital signature
[resend PATCH v3 4/4] usb: phy: add phy-hi6220-usb
Add usb phy controller for hi6220 platform Signed-off-by: Zhangfei Gao --- drivers/usb/phy/Kconfig | 9 ++ drivers/usb/phy/Makefile | 1 + drivers/usb/phy/phy-hi6220-usb.c | 306 +++ 3 files changed, 316 insertions(+) create mode 100644 drivers/usb/phy/phy-hi6220-usb.c diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index c6d0c8e..405a3d0 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -173,6 +173,15 @@ config USB_MXS_PHY MXS Phy is used by some of the i.MX SoCs, for example imx23/28/6x. +config USB_HI6220_PHY + tristate "hi6220 USB PHY support" + select USB_PHY + select MFD_SYSCON + help + Enable this to support the HISILICON HI6220 USB PHY. + + To compile this driver as a module, choose M here. + config USB_RCAR_PHY tristate "Renesas R-Car USB PHY support" depends on USB || USB_GADGET diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index 75f2bba..00172d3 100644 --- a/drivers/usb/phy/Makefile +++ b/drivers/usb/phy/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_SAMSUNG_USBPHY) += phy-samsung-usb.o obj-$(CONFIG_TWL6030_USB) += phy-twl6030-usb.o obj-$(CONFIG_USB_EHCI_TEGRA) += phy-tegra-usb.o obj-$(CONFIG_USB_GPIO_VBUS)+= phy-gpio-vbus-usb.o +obj-$(CONFIG_USB_HI6220_PHY) += phy-hi6220-usb.o obj-$(CONFIG_USB_ISP1301) += phy-isp1301.o obj-$(CONFIG_USB_MSM_OTG) += phy-msm-usb.o obj-$(CONFIG_USB_MV_OTG) += phy-mv-usb.o diff --git a/drivers/usb/phy/phy-hi6220-usb.c b/drivers/usb/phy/phy-hi6220-usb.c new file mode 100644 index 000..efb4bbb --- /dev/null +++ b/drivers/usb/phy/phy-hi6220-usb.c @@ -0,0 +1,306 @@ +/* + * Copyright (c) 2015 Linaro Ltd. + * Copyright (c) 2015 Hisilicon Limited. + * + * 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 of the License, or + * (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define SC_PERIPH_CTRL40x00c + +#define CTRL4_PICO_SIDDQ BIT(6) +#define CTRL4_PICO_OGDISABLE BIT(8) +#define CTRL4_PICO_VBUSVLDEXT BIT(10) +#define CTRL4_PICO_VBUSVLDEXTSEL BIT(11) +#define CTRL4_OTG_PHY_SEL BIT(21) + +#define SC_PERIPH_CTRL50x010 + +#define CTRL5_USBOTG_RES_SEL BIT(3) +#define CTRL5_PICOPHY_ACAENB BIT(4) +#define CTRL5_PICOPHY_BC_MODE BIT(5) +#define CTRL5_PICOPHY_CHRGSEL BIT(6) +#define CTRL5_PICOPHY_VDATSRCEND BIT(7) +#define CTRL5_PICOPHY_VDATDETENB BIT(8) +#define CTRL5_PICOPHY_DCDENB BIT(9) +#define CTRL5_PICOPHY_IDDIGBIT(10) + +#define SC_PERIPH_CTRL80x018 +#define SC_PERIPH_RSTEN0 0x300 +#define SC_PERIPH_RSTDIS0 0x304 + +#define RST0_USBOTG_BUSBIT(4) +#define RST0_POR_PICOPHY BIT(5) +#define RST0_USBOTGBIT(6) +#define RST0_USBOTG_32KBIT(7) + +#define EYE_PATTERN_PARA 0x7053348c + +struct hi6220_priv { + struct usb_phy phy; + struct delayed_work work; + struct regmap *reg; + struct clk *clk; + struct regulator *vcc; + struct device *dev; + int gpio_vbus; + int gpio_id; + enum usb_otg_state state; +}; + +static void hi6220_start_periphrals(struct hi6220_priv *priv, bool on) +{ + struct usb_otg *otg = priv->phy.otg; + + if (!otg->gadget) + return; + + if (on) + usb_gadget_connect(otg->gadget); + else + usb_gadget_disconnect(otg->gadget); +} + +static void hi6220_detect_work(struct work_struct *work) +{ + struct hi6220_priv *priv = + container_of(work, struct hi6220_priv, work.work); + int gpio_id, gpio_vbus; + enum usb_otg_state state; + + if (!gpio_is_valid(priv->gpio_id) || !gpio_is_valid(priv->gpio_vbus)) + return; + + gpio_id = gpio_get_value_cansleep(priv->gpio_id); + gpio_vbus = gpio_get_value_cansleep(priv->gpio_vbus); + + if (gpio_vbus == 0) { + if (gpio_id == 1) + state = OTG_STATE_B_PERIPHERAL; + else + state = OTG_STATE_A_HOST; + } else { + state = OTG_STATE_A_HOST; + } + + if (priv->state != state) { + hi6220_start_periphrals(priv, state == OTG_STATE_B_PERIPHERAL); + priv->state = state; + } +} + +static irqreturn_t hiusb_gpio_intr(int irq, void *data) +{ + struct hi6220_priv *priv = (struct hi6220_priv *)data; + + /*