[RFC] [PATCH] phy: Add new Exynos USB PHY driver
Add a new driver for the Exynos USB PHY. The new driver uses the generic PHY framework. Signed-off-by: Kamil Debski Signed-off-by: Kyungmin Park Cc: Kishon Vijay Abraham I Cc: Tomasz Figa Cc: Sylwester Nawrocki Cc: Marek Szyprowski --- Hi, This patch adds a new drive for USB PHYs for Samsung SoCs. The driver is using the Generic PHY Framework created by Kishon Vijay Abrahan I. It can be found here https://lkml.org/lkml/2013/8/21/29. This patch adds support to Exynos4 family of SoCs. Support for Exynos3 and Exynos5 is planned to be added in the near future. I welcome your comments. Best wishes, Kamil Debski --- .../devicetree/bindings/phy/samsung-usbphy.txt | 48 +++ drivers/phy/Kconfig| 23 ++ drivers/phy/Makefile |3 + drivers/phy/phy-exynos-usb.c | 245 ++ drivers/phy/phy-exynos-usb.h | 95 ++ drivers/phy/phy-exynos4210-usb.c | 315 ++ drivers/phy/phy-exynos4212-usb.c | 349 7 files changed, 1078 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/samsung-usbphy.txt create mode 100644 drivers/phy/phy-exynos-usb.c create mode 100644 drivers/phy/phy-exynos-usb.h create mode 100644 drivers/phy/phy-exynos4210-usb.c create mode 100644 drivers/phy/phy-exynos4212-usb.c diff --git a/Documentation/devicetree/bindings/phy/samsung-usbphy.txt b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt new file mode 100644 index 000..f618e8d --- /dev/null +++ b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt @@ -0,0 +1,48 @@ +Samsung S5P/EXYNOS SoC series USB PHY +- + +Required properties: +- compatible : should be one of the listed compatibles: + - "samsung,exynos4210-usbphy" + - "samsung,exynos4212-usbphy" +- reg : a list of registers used by phy driver + - first and obligatory is the location of phy modules registers + - second and also required is the location of isolation registers + (isolation registers control the physical connection between the in + SoC modules and outside of the SoC, this also can be called enable + control in the documentation of the SoC) + - third is the location of the mode switch register, this only applies + to SoCs that have such a feature; mode switching enables to have + both host and device used the same SoC pins and is commonly used + when OTG is supported +- #phy-cells : from the generic phy bindings, must be 1; + +The second cell in the PHY specifier identifies the PHY its meaning is SoC +dependent. For the currently supported SoCs (Exynos 4210 and Exynos 4212) it +is as follows: + 0 - USB device, + 1 - USB host, + 2 - HSIC0, + 3 - HSIC1, + +Example: + +For Exynos 4412 (compatible with Exynos 4212): + +exynos_usbphy: exynos-usbphy@125B { + compatible = "samsung,exynos4212-usbphy"; + reg = <0x125B 0x100>, <0x10020704 0x0c>, <0x1001021c 0x4>; + clocks = <&clock 305>, <&clock 2>, <&clock 2>, <&clock 2>, + <&clock 2>; + clock-names = "phy", "device", "host", "hsic0", "hsic1"; + status = "okay"; + #phy-cells = <1>; +}; + +Then the PHY can be used in other nodes such as: + +ehci@1258 { + status = "okay"; + phys = <&exynos_usbphy 2>; + phy-names = "hsic0"; +}; diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 108c5f6..af3c422 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -21,4 +21,27 @@ config PHY_EXYNOS_MIPI_VIDEO Support for MIPI CSI-2 and MIPI DSI DPHY found on Samsung S5P and EXYNOS SoCs. +config PHY_EXYNOS_USB + tristate "Samsung USB PHY driver (using the Generic PHY Framework)" + help + Samsung USB PHY driver + + Enable this to support Samsung USB phy helper driver for Samsung SoCs. + This driver provides common interface to interact, for Samsung + USB 2.0 PHY driver. + +config PHY_EXYNOS4210_USB + bool "Support for Exynos 4210" + depends on PHY_EXYNOS_USB + depends on CPU_EXYNOS4210 + help + Enable USB PHY support for Exynos 4210 + +config PHY_EXYNOS4212_USB + bool "Support for Exynos 4212" + depends on PHY_EXYNOS_USB + depends on (SOC_EXYNOS4212 || SOC_EXYNOS4412) + help + Enable USB PHY support for Exynos 4212 + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 71d8841..d75f932 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -4,3 +4,6 @@ obj-$(CONFIG_GENERI
RE: [RFC] [PATCH] phy: Add new Exynos USB PHY driver
Hi, > From: Vivek Gautam [mailto:gautamvivek1...@gmail.com] > Sent: Friday, September 20, 2013 1:44 PM > > On Fri, Sep 20, 2013 at 5:11 PM, Vivek Gautam > wrote: > > On Wed, Sep 11, 2013 at 4:57 PM, Kamil Debski > wrote: > >> Add a new driver for the Exynos USB PHY. The new driver uses the > >> generic PHY framework. > >> > >> Signed-off-by: Kamil Debski > >> Signed-off-by: Kyungmin Park > >> Cc: Kishon Vijay Abraham I > >> Cc: Tomasz Figa > >> Cc: Sylwester Nawrocki > >> Cc: Marek Szyprowski > >> --- > >> > >> Hi, > >> > >> This patch adds a new drive for USB PHYs for Samsung SoCs. The > driver > >> is using the Generic PHY Framework created by Kishon Vijay Abrahan I. > >> It can be found here https://lkml.org/lkml/2013/8/21/29. > >> This patch adds support to Exynos4 family of SoCs. Support for > >> Exynos3 and > >> Exynos5 is planned to be added in the near future. > >> > >> I welcome your comments. > > > > How do you plan to put support for exynos5 series. I can see you have > > made separate files for exynos4210 and 4212. > > Now for exynos5250 and above, we should be able to re-use some of the > > functions like "4212_rate_to_clk()" and "4212_iso()". I see two options. One - moving the functions that could be reused to separate file. Two - exporting these functions in let's say 4212 and using them in 5250. What do you think? I will also support for S5PC110 in the Exynos 4210 file, as they are very similar. > > > > Let me know if i can help with something for exynos5 stuff. Now, I am trying to run the USB device on Exynos5. The board I am using is the Arndale board. Unfortunately I am having trouble as the USB lines from SoC are connected both to the device port and the USB/Ethernet chip (AX88796). Did you use the Arndale board when working with Exynos 5? > > > > Also please add linux-usb and linux-samsung mailing list too. I will. [snip] Best wishes, -- Kamil Debski Linux Kernel Developer Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [RESEND PATCH v10 1/8] drivers: phy: add generic PHY framework
Hi Kishon, A small fix follows inline. > From: linux-media-ow...@vger.kernel.org [mailto:linux-media- > ow...@vger.kernel.org] On Behalf Of Kishon Vijay Abraham I > Sent: Friday, July 26, 2013 2:49 PM > > The PHY framework provides a set of APIs for the PHY drivers to > create/destroy a PHY and APIs for the PHY users to obtain a reference > to the PHY with or without using phandle. For dt-boot, the PHY drivers > should also register *PHY provider* with the framework. > > PHY drivers should create the PHY by passing id and ops like init, exit, > power_on and power_off. This framework is also pm runtime enabled. > > The documentation for the generic PHY framework is added in > Documentation/phy.txt and the documentation for dt binding can be found > at Documentation/devicetree/bindings/phy/phy-bindings.txt > > Cc: Tomasz Figa > Cc: Greg Kroah-Hartman > Signed-off-by: Kishon Vijay Abraham I > Acked-by: Felipe Balbi > Tested-by: Sylwester Nawrocki > --- > .../devicetree/bindings/phy/phy-bindings.txt | 66 ++ > Documentation/phy.txt | 166 + > MAINTAINERS|8 + > drivers/Kconfig|2 + > drivers/Makefile |2 + > drivers/phy/Kconfig| 18 + > drivers/phy/Makefile |5 + > drivers/phy/phy-core.c | 714 > > include/linux/phy/phy.h| 270 > 9 files changed, 1251 insertions(+) > create mode 100644 Documentation/devicetree/bindings/phy/phy- > bindings.txt > create mode 100644 Documentation/phy.txt create mode 100644 > drivers/phy/Kconfig create mode 100644 drivers/phy/Makefile create > mode 100644 drivers/phy/phy-core.c create mode 100644 > include/linux/phy/phy.h > [snip] > diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h new file > mode 100644 index 000..e444b23 > --- /dev/null > +++ b/include/linux/phy/phy.h > @@ -0,0 +1,270 @@ [snip] > +struct phy_init_data { > + unsigned int num_consumers; > + struct phy_consumer *consumers; > +}; > + > +#define PHY_CONSUMER(_dev_name, _port) \ > +{\ > + .dev_name = _dev_name,\ > + .port = _port,\ > +} > + > +#define to_phy(dev) (container_of((dev), struct phy, dev)) > + > +#define of_phy_provider_register(dev, xlate)\ > + __of_phy_provider_register((dev), THIS_MODULE, (xlate)) > + > +#define devm_of_phy_provider_register(dev, xlate) \ > + __of_phy_provider_register((dev), THIS_MODULE, (xlate)) I think this should be: + __devm_of_phy_provider_register((dev), THIS_MODULE, (xlate)) Right? > + > +static inline void phy_set_drvdata(struct phy *phy, void *data) { > + dev_set_drvdata(&phy->dev, data); > +} > + > +static inline void *phy_get_drvdata(struct phy *phy) { > + return dev_get_drvdata(&phy->dev); > +} > + [snip] Best wishes, -- Kamil Debski Linux Kernel Developer Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] MAINTAINERS: update email and list of Samsung HW driver maintainers
Change my email address in the MAINTAINERS file. Add new maintainers of selected Samsung HW drivers. Signed-off-by: Kamil Debski Cc: Greg Kroah-Hartman Cc: Andrew Morton Cc: Guenter Roeck Cc: Kishon Vijay Abraham I Cc: Mauro Carvalho Chehab Cc: linux-hw...@vger.kernel.org Cc: Andrzej Hajda Cc: Lukasz Majewski Cc: Sylwester Nawrocki Cc: Kamil Debski --- MAINTAINERS | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 8c20323..76e5953 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1623,7 +1623,8 @@ F:arch/arm/mach-s5pv210/ ARM/SAMSUNG S5P SERIES 2D GRAPHICS ACCELERATION (G2D) SUPPORT M: Kyungmin Park -M: Kamil Debski +M: Kamil Debski +M: Andrzej Hajda L: linux-arm-ker...@lists.infradead.org L: linux-me...@vger.kernel.org S: Maintained @@ -1631,8 +1632,9 @@ F:drivers/media/platform/s5p-g2d/ ARM/SAMSUNG S5P SERIES Multi Format Codec (MFC) SUPPORT M: Kyungmin Park -M: Kamil Debski +M: Kamil Debski M: Jeongtae Park +M: Andrzej Hajda L: linux-arm-ker...@lists.infradead.org L: linux-me...@vger.kernel.org S: Maintained @@ -9241,7 +9243,8 @@ S:Maintained F: drivers/media/usb/pwc/* PWM FAN DRIVER -M: Kamil Debski +M: Kamil Debski +M: Lukasz Majewski L: linux-hw...@vger.kernel.org S: Supported F: Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -9985,7 +9988,8 @@ T:git https://github.com/lmajewski/linux-samsung-thermal.git F: drivers/thermal/samsung/ SAMSUNG USB2 PHY DRIVER -M: Kamil Debski +M: Kamil Debski +M: Sylwester Nawrocki L: linux-kernel@vger.kernel.org S: Supported F: Documentation/devicetree/bindings/phy/samsung-phy.txt -- 1.9.1
RE: [PATCH] phy: phy-samsung-usb2: Don't use same name for driver name and global structure
Hi, > From: Vivek Gautam [mailto:gautamvivek1...@gmail.com] > Sent: Thursday, December 11, 2014 7:30 AM > To: Kishon Vijay Abraham I; Kamil Debski > Cc: linux-kernel@vger.kernel.org; Linux USB Mailing List; Vivek Gautam > Subject: Re: [PATCH] phy: phy-samsung-usb2: Don't use same name for > driver name and global structure > > On Wed, Nov 12, 2014 at 3:54 PM, Vivek Gautam > wrote: > > Using the same driver name for platform driver and a globally defined, > > structure used throughout the file, looks a bit unpleasing. > > So changing the driver name from "samsung_usb2_phy_driver" to > > "samsung_usb2_phy" > > > > Signed-off-by: Vivek Gautam > > Cc: Kamil Debski > > Cc: Kishon Vijay Abraham I > > --- > > Although just a trivial change, does it look valid ? I can agree that the naming of this variable is a bit unfortunate. Changing name of samsung_usb2_phy_driver to samsung_usb2_phy is, as you said, a minor change and does not change how the driver works. Acked-by: Kamil Debski Best wishes, -- Kamil Debski Samsung R&D Institute Poland > > > drivers/phy/phy-samsung-usb2.c |4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/phy/phy-samsung-usb2.c b/drivers/phy/phy- > samsung-usb2.c > > index 908949d..2934fb7 100644 > > --- a/drivers/phy/phy-samsung-usb2.c > > +++ b/drivers/phy/phy-samsung-usb2.c > > @@ -226,7 +226,7 @@ static int samsung_usb2_phy_probe(struct > platform_device *pdev) > > return 0; > > } > > > > -static struct platform_driver samsung_usb2_phy_driver = { > > +static struct platform_driver samsung_usb2_phy = { > > .probe = samsung_usb2_phy_probe, > > .driver = { > > .of_match_table = samsung_usb2_phy_of_match, > > @@ -234,7 +234,7 @@ static struct platform_driver > samsung_usb2_phy_driver = { > > } > > }; > > > > -module_platform_driver(samsung_usb2_phy_driver); > > +module_platform_driver(samsung_usb2_phy); > > MODULE_DESCRIPTION("Samsung S5P/EXYNOS SoC USB PHY driver"); > > MODULE_AUTHOR("Kamil Debski "); > > MODULE_LICENSE("GPL v2"); > > -- > > 1.7.10.4 > > > > -- > > To unsubscribe from this list: send the line "unsubscribe linux- > kernel" in > > the body of a message to majord...@vger.kernel.org > > More majordomo info at http://vger.kernel.org/majordomo-info.html > > Please read the FAQ at http://www.tux.org/lkml/ > > > > -- > Best Regards > Vivek Gautam > Samsung R&D Institute, Bangalore > India -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH RFC 1/4] phy: Add new Exynos5 USB 3.0 PHY driver
Hi Kishon, > From: Kishon Vijay Abraham I [mailto:kis...@ti.com] > Sent: Monday, November 04, 2013 7:55 AM > > Hi Vivek, > > On Thursday 31 October 2013 01:15 PM, Vivek Gautam wrote: > > Add a new driver for the USB 3.0 PHY on Exynos5 series of SoCs. > > The new driver uses the generic PHY framework and will interact with > > DWC3 controller present on Exynos5 series of SoCs. > > In Exynos, you have a single IP that supports both USB3 and USB2 PHY > right? I think that needs to be mentioned here. As far as I know the IP is different. > Do you have separate registers that should be used for > initializing/powerin_on/powering_off etc.. for usb2 phy and usb3 phy? > If so, then you should model this driver as a single driver that > supports two PHYs similar to what Sylwester has done before? Best wishes, Kamil > Cheers > Kishon > > > > > Signed-off-by: Vivek Gautam > > --- > > .../devicetree/bindings/phy/samsung-phy.txt| 20 + > > drivers/phy/Kconfig|7 + > > drivers/phy/Makefile |1 + > > drivers/phy/phy-exynos5-usb3.c | 562 > > > 4 files changed, 590 insertions(+), 0 deletions(-) > > create mode 100644 drivers/phy/phy-exynos5-usb3.c > > > > diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt > > b/Documentation/devicetree/bindings/phy/samsung-phy.txt > > index c0fccaa..9b5c111 100644 > > --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt > > +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt > > @@ -20,3 +20,23 @@ Required properties: > > - compatible : should be "samsung,exynos5250-dp-video-phy"; > > - reg : offset and length of the Display Port PHY register set; > > - #phy-cells : from the generic PHY bindings, must be 0; > > + > > +Samsung Exynos5 SoC seiries USB 3.0 PHY controller > > +-- > > + > > +Required properties: > > +- compatible : > > + should be "samsung,exynos5250-usb3phy" for exynos5250 SoC > > + should be "samsung,exynos5420-usb3phy" for exynos5420 SoC > > +- reg : Register offset and length array > > + - first field corresponds to USB 3.0 PHY register set; > > + - second field corresponds to PHY power isolation register > > + present in PMU; > > +- clocks: Clock IDs array as required by the controller > > +- clock-names: names of clocks correseponding to IDs in the clock > property; > > + Required clocks: > > + - first clock is main PHY clock (same as USB 3.0 controller IP > clock) > > + - second clock is reference clock (usually crystal clock) > > + optional clock: > > + - third clock is special clock used by PHY for operation > > +- #phy-cells : from the generic PHY bindings, must be 0; > > diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index > > a344f3d..9a100c6 100644 > > --- a/drivers/phy/Kconfig > > +++ b/drivers/phy/Kconfig > > @@ -51,4 +51,11 @@ config PHY_EXYNOS_DP_VIDEO > > help > > Support for Display Port PHY found on Samsung EXYNOS SoCs. > > > > +config PHY_EXYNOS5_USB3 > > + tristate "Exynos5 SoC series USB 3.0 PHY driver" > > + depends on ARCH_EXYNOS5 > > + select GENERIC_PHY > > + help > > + Enable USB 3.0 PHY support for Exynos 5 SoC series > > + > > endmenu > > diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index > > d0caae9..9c06a61 100644 > > --- a/drivers/phy/Makefile > > +++ b/drivers/phy/Makefile > > @@ -7,3 +7,4 @@ obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO) += phy-exynos-dp- > video.o > > obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO) += phy-exynos-mipi-video.o > > obj-$(CONFIG_OMAP_USB2) += phy-omap-usb2.o > > obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o > > +obj-$(CONFIG_PHY_EXYNOS5_USB3) += phy-exynos5-usb3.o > > diff --git a/drivers/phy/phy-exynos5-usb3.c > > b/drivers/phy/phy-exynos5-usb3.c new file mode 100644 index > > 000..b9a2674 > > --- /dev/null > > +++ b/drivers/phy/phy-exynos5-usb3.c > > @@ -0,0 +1,562 @@ > > +/* > > + * Samsung EXYNOS5 SoC series USB 3.0 PHY driver > > + * > > + * Copyright (C) 2013 Samsung Electronics Co., Ltd. > > + * Author: Vivek Gautam > > + * > > + * 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 > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +/* Exynos USB PHY registers */ > > +#define EXYNOS5_FSEL_9MHZ6 0x0 > > +#define EXYNOS5_FSEL_10MHZ 0x1 > > +#define EXYNOS5_FSEL_12MHZ 0x2 > > +#define EXYNOS5_FSEL_19MHZ20x3 > > +#define EXYNOS5_FSEL_20MHZ 0x4 > > +#define EXYNOS5_FSEL_24MHZ 0x5 > > +#define EXYNOS5_FSEL_50MHZ 0x7 > > + > > +/* EXYNOS5: USB 3.0 DRD PHY register
RE: [PATCH RFC 1/4] phy: Add new Exynos5 USB 3.0 PHY driver
Hi, > From: Vivek Gautam [mailto:gautamvivek1...@gmail.com] > Sent: Tuesday, November 05, 2013 8:20 AM > To: Kishon Vijay Abraham I > Cc: Kamil Debski; Vivek Gautam; Linux USB Mailing List; linux-samsung- > s...@vger.kernel.org; linux-kernel@vger.kernel.org; > devicet...@vger.kernel.org; linux-arm-ker...@lists.infradead.org; > linux-...@vger.kernel.org; Greg KH; Kukjin Kim; Sylwester Nawrocki; > Tomasz Figa; Felipe Balbi; Julius Werner; Jingoo Han > Subject: Re: [PATCH RFC 1/4] phy: Add new Exynos5 USB 3.0 PHY driver > > Hi Kishon, > > > > On Mon, Nov 4, 2013 at 6:42 PM, Kishon Vijay Abraham I > wrote: > > Hi, > > > > > > On Monday 04 November 2013 03:45 PM, Kamil Debski wrote: > >> > >> Hi Kishon, > >> > >>> From: Kishon Vijay Abraham I [mailto:kis...@ti.com] > >>> Sent: Monday, November 04, 2013 7:55 AM > >>> > >>> Hi Vivek, > >>> > >>> On Thursday 31 October 2013 01:15 PM, Vivek Gautam wrote: > >>>> > >>>> Add a new driver for the USB 3.0 PHY on Exynos5 series of SoCs. > >>>> The new driver uses the generic PHY framework and will interact > >>>> with > >>>> DWC3 controller present on Exynos5 series of SoCs. > >>> > >>> > >>> In Exynos, you have a single IP that supports both USB3 and USB2 > PHY > >>> right? I think that needs to be mentioned here. > >> > >> > >> As far as I know the IP is different. > > > > > > Ok. Sometime back Vivek was mentioning about a single IP for both > USB3 > > and USB2. Thought it should be this driver. Anyway thanks for the > clarification. > > Right Kishon, I had mentioned that Exynos5's dwc3 controller have a > single IP for USB2 and USB3 phy. > From what i see, on exynos5 systems the dwc3 controller uses a combo of > usb 2 (utmi+) and usb 3 (pipe 3) phy (with base address starting > 0x1210). > > Kamil, Tomasz, > > Please correct me if i am wrong. I have the Exynos 5250 documentation and I found two phy register ranges: 1) USB 2.0 PHY having the base address of 0x1213 Chapter 33. USB 2.0 Host Controller Subchapter 33.5.2 Phy Control Register p. 1696 First register's description is "USB2.0 phy control register" 2) USB 3.0 PHY (I guess) with the base address 0x1210 Chapter 35. USB 3.0 DRD Controller Subchapter 35.4.6 PHY Control Register p. 1872 Jingoo, could you comment on the above? You may know more than we do :) In addition, I have a question to you Vivek - does your USB 3.0 PHY support both host and device? [snip] Best wishes, Kamil Debski -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 0/3] phy: Add new Exynos USB 2.0 PHY driver
Hi, This is the third version of the patchset adding the new Exynos USB 2.0 PHY driver, which uses the Generic PHY Framework. It contains numerous fixes and cleanups, which are the results of the feedback to the second version. Best wishes, Kamil Debski Changes from v2: - rebase all patches to the usb-next branch - fixes in the documentation file - remove wrong entries in the phy node (ranges, and #address- & #size-cells) - add clocks and clock-names as required properites - rephrase a few sentences - fixes in the ehci-exynos.c file - move phy_name variable next to phy in exynos_ehci_hcd - remove otg from exynos_ehci_hcd as it was no longer used - move devm_phy_get after the Exynos5440 skip_phy check - fixes in the s3c-hsotg.c file - cosmetic fixes (remove empty line that was wrongfully added) - fixes in the main driver - remove cpu_type in favour for a boolean flag matched with the compatible value - rename files, structures, variables and Kconfig entires - change from simple "uphy" to "usb2_phy" - fix multiline comments style - simplify #ifdefs in of_device_id - fix Kconfig description - change dev_info to dev_dbg where reasonable - cosmetic changes (remove wrongful blank lines) - remove unnecessary reference counting Changes from v1: - the changes include minor fixes of the hardware initialization of the PHY module - some other minor fixes were introduced -- Original cover letter: Hi, This patch adds a new drive for USB PHYs for Samsung SoCs. The driver is using the Generic PHY Framework created by Kishon Vijay Abrahan I. It can be found here https://lkml.org/lkml/2013/8/21/29. This patch adds support to Exynos4 family of SoCs. Support for Exynos3 and Exynos5 is planned to be added in the near future. I welcome your comments. -- [1] https://lkml.org/lkml/2013/8/21/29 *** BLURB HERE *** Kamil Debski (3): phy: Add new Exynos USB PHY driver usb: ehci-s5p: Change to use phy provided by the generic phy framework usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework .../devicetree/bindings/phy/samsung-usbphy.txt | 52 drivers/phy/Kconfig| 23 +- drivers/phy/Makefile |4 + drivers/phy/phy-exynos-usb2.c | 234 ++ drivers/phy/phy-exynos-usb2.h | 87 ++ drivers/phy/phy-exynos4210-usb2.c | 272 drivers/phy/phy-exynos4212-usb2.c | 324 drivers/usb/gadget/s3c-hsotg.c | 12 +- drivers/usb/host/ehci-exynos.c | 34 +- 9 files changed, 1013 insertions(+), 29 deletions(-) create mode 100644 Documentation/devicetree/bindings/phy/samsung-usbphy.txt create mode 100644 drivers/phy/phy-exynos-usb2.c create mode 100644 drivers/phy/phy-exynos-usb2.h create mode 100644 drivers/phy/phy-exynos4210-usb2.c create mode 100644 drivers/phy/phy-exynos4212-usb2.c -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 1/3] phy: Add new Exynos USB PHY driver
Add a new driver for the Exynos USB PHY. The new driver uses the generic PHY framework. The driver includes support for the Exynos 4x10 and 4x12 SoC families. Signed-off-by: Kamil Debski Signed-off-by: Kyungmin Park --- .../devicetree/bindings/phy/samsung-usbphy.txt | 52 drivers/phy/Kconfig| 23 +- drivers/phy/Makefile |4 + drivers/phy/phy-exynos-usb2.c | 234 ++ drivers/phy/phy-exynos-usb2.h | 87 ++ drivers/phy/phy-exynos4210-usb2.c | 272 drivers/phy/phy-exynos4212-usb2.c | 324 7 files changed, 995 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/phy/samsung-usbphy.txt create mode 100644 drivers/phy/phy-exynos-usb2.c create mode 100644 drivers/phy/phy-exynos-usb2.h create mode 100644 drivers/phy/phy-exynos4210-usb2.c create mode 100644 drivers/phy/phy-exynos4212-usb2.c diff --git a/Documentation/devicetree/bindings/phy/samsung-usbphy.txt b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt new file mode 100644 index 000..c8fbc70 --- /dev/null +++ b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt @@ -0,0 +1,52 @@ +Samsung S5P/EXYNOS SoC series USB PHY +- + +Required properties: +- compatible : should be one of the listed compatibles: + - "samsung,exynos4210-usbphy" + - "samsung,exynos4212-usbphy" +- reg : a list of registers used by phy driver + - first and obligatory is the location of phy modules registers + - second and also required is the location of isolation registers + (isolation registers control the physical connection between the in + SoC modules and outside of the SoC, this also can be called enable + control in the documentation of the SoC) + - third is the location of the mode switch register, this only applies + to SoCs that have such a feature; mode switching enables to have + both host and device used the same SoC pins and is commonly used + when OTG is supported +- #phy-cells : from the generic phy bindings, must be 1; +- clocks and clock-names: + - the "phy" clocks is required by the phy module + - other clocks are associated by name with their respective phys and + are used to determine the value of the clock settings register + +The second cell in the PHY specifier identifies the PHY, its meaning is +compatible dependent. For the currently supported SoCs (Exynos 4210 and +Exynos 4212) it is as follows: + 0 - USB device, + 1 - USB host, + 2 - HSIC0, + 3 - HSIC1, + +Example: + +For Exynos 4412 (compatible with Exynos 4212): + +exynos_usbphy: exynos-usbphy@125B { + compatible = "samsung,exynos4212-usbphy"; + reg = <0x125B 0x100 0x10020704 0x0c 0x1001021c 0x4>; + clocks = <&clock 305>, <&clock 2>, <&clock 2>, <&clock 2>, + <&clock 2>; + clock-names = "phy", "device", "host", "hsic0", "hsic1"; + status = "okay"; + #phy-cells = <1>; +}; + +Then the PHY can be used in other nodes such as: + +ehci@1258 { + status = "okay"; + phys = <&exynos_usbphy 2>; + phy-names = "hsic0"; +}; diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index a344f3d..bdf0fab 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -14,7 +14,7 @@ config GENERIC_PHY API by which phy drivers can create PHY using the phy framework and phy users can obtain reference to the PHY. All the users of this framework should select this config. - + config PHY_EXYNOS_MIPI_VIDEO tristate "S5P/EXYNOS SoC series MIPI CSI-2/DSI PHY driver" help @@ -51,4 +51,25 @@ config PHY_EXYNOS_DP_VIDEO help Support for Display Port PHY found on Samsung EXYNOS SoCs. +config PHY_EXYNOS_USB2 + tristate "Samsung USB 2.0 PHY driver" + help + Enable this to support Samsung USB phy helper driver for Samsung SoCs. + This driver provides common interface to interact, for Samsung + USB 2.0 PHY driver. + +config PHY_EXYNOS4210_USB2 + bool "Support for Exynos 4210" + depends on PHY_EXYNOS_USB2 + depends on CPU_EXYNOS4210 + help + Enable USB PHY support for Exynos 4210 + +config PHY_EXYNOS4212_USB2 + bool "Support for Exynos 4212" + depends on PHY_EXYNOS_USB2 + depends on (SOC_EXYNOS4212 || SOC_EXYNOS4412) + help + Enable USB PHY support for Exynos 4212 + endmenu diff --git a/drivers/phy/Makefile b/drivers
[PATCH v3 3/3] usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework
Change the used phy driver to the new Exynos USB phy driver that uses the generic phy framework. Signed-off-by: Kamil Debski Signed-off-by: Kyungmin Park --- drivers/usb/gadget/s3c-hsotg.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index bb31262..dc7f20c 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -162,7 +163,7 @@ struct s3c_hsotg_ep { struct s3c_hsotg { struct device*dev; struct usb_gadget_driver *driver; - struct usb_phy *phy; + struct phy *phy; struct s3c_hsotg_plat*plat; spinlock_t lock; @@ -2905,9 +2906,10 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg) dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev); if (hsotg->phy) - usb_phy_init(hsotg->phy); + phy_power_on(hsotg->phy); else if (hsotg->plat->phy_init) hsotg->plat->phy_init(pdev, hsotg->plat->phy_type); + } /** @@ -2922,7 +2924,7 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg) struct platform_device *pdev = to_platform_device(hsotg->dev); if (hsotg->phy) - usb_phy_shutdown(hsotg->phy); + phy_power_off(hsotg->phy); else if (hsotg->plat->phy_exit) hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type); } @@ -3529,7 +3531,7 @@ static void s3c_hsotg_delete_debug(struct s3c_hsotg *hsotg) static int s3c_hsotg_probe(struct platform_device *pdev) { struct s3c_hsotg_plat *plat = dev_get_platdata(&pdev->dev); - struct usb_phy *phy; + struct phy *phy; struct device *dev = &pdev->dev; struct s3c_hsotg_ep *eps; struct s3c_hsotg *hsotg; @@ -3544,7 +3546,7 @@ static int s3c_hsotg_probe(struct platform_device *pdev) return -ENOMEM; } - phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); + phy = devm_phy_get(&pdev->dev, "device"); if (IS_ERR(phy)) { /* Fallback for pdata */ plat = dev_get_platdata(&pdev->dev); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 2/3] usb: ehci-s5p: Change to use phy provided by the generic phy framework
Change the phy provider used from the old usb phy specific to a new one using the generic phy framework. Signed-off-by: Kamil Debski Signed-off-by: Kyungmin Park --- drivers/usb/host/ehci-exynos.c | 34 +++--- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index 8898c01..974001b 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -19,12 +19,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include "ehci.h" @@ -44,8 +44,7 @@ static struct hc_driver __read_mostly exynos_ehci_hc_driver; struct exynos_ehci_hcd { struct clk *clk; - struct usb_phy *phy; - struct usb_otg *otg; + struct phy *phy; }; #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd *)(hcd_to_ehci(hcd)->priv) @@ -75,7 +74,8 @@ static int exynos_ehci_probe(struct platform_device *pdev) struct usb_hcd *hcd; struct ehci_hcd *ehci; struct resource *res; - struct usb_phy *phy; + struct phy *phy; + const char *phy_name; int irq; int err; @@ -98,12 +98,12 @@ static int exynos_ehci_probe(struct platform_device *pdev) return -ENOMEM; } exynos_ehci = to_exynos_ehci(hcd); - if (of_device_is_compatible(pdev->dev.of_node, "samsung,exynos5440-ehci")) goto skip_phy; - phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); + phy_name = of_get_property(pdev->dev.of_node, "phy-names", NULL); + phy = devm_phy_get(&pdev->dev, phy_name); if (IS_ERR(phy)) { usb_put_hcd(hcd); dev_warn(&pdev->dev, "no platform data or transceiver defined\n"); @@ -149,11 +149,8 @@ skip_phy: goto fail_io; } - if (exynos_ehci->otg) - exynos_ehci->otg->set_host(exynos_ehci->otg, &hcd->self); - if (exynos_ehci->phy) - usb_phy_init(exynos_ehci->phy); + phy_power_on(exynos_ehci->phy); ehci = hcd_to_ehci(hcd); ehci->caps = hcd->regs; @@ -173,7 +170,7 @@ skip_phy: fail_add_hcd: if (exynos_ehci->phy) - usb_phy_shutdown(exynos_ehci->phy); + phy_power_off(exynos_ehci->phy); fail_io: clk_disable_unprepare(exynos_ehci->clk); fail_clk: @@ -188,11 +185,8 @@ static int exynos_ehci_remove(struct platform_device *pdev) usb_remove_hcd(hcd); - if (exynos_ehci->otg) - exynos_ehci->otg->set_host(exynos_ehci->otg, &hcd->self); - if (exynos_ehci->phy) - usb_phy_shutdown(exynos_ehci->phy); + phy_power_off(exynos_ehci->phy); clk_disable_unprepare(exynos_ehci->clk); @@ -212,11 +206,8 @@ static int exynos_ehci_suspend(struct device *dev) rc = ehci_suspend(hcd, do_wakeup); - if (exynos_ehci->otg) - exynos_ehci->otg->set_host(exynos_ehci->otg, &hcd->self); - if (exynos_ehci->phy) - usb_phy_shutdown(exynos_ehci->phy); + phy_power_off(exynos_ehci->phy); clk_disable_unprepare(exynos_ehci->clk); @@ -230,11 +221,8 @@ static int exynos_ehci_resume(struct device *dev) clk_prepare_enable(exynos_ehci->clk); - if (exynos_ehci->otg) - exynos_ehci->otg->set_host(exynos_ehci->otg, &hcd->self); - if (exynos_ehci->phy) - usb_phy_init(exynos_ehci->phy); + phy_power_on(exynos_ehci->phy); /* DMA burst Enable */ writel(EHCI_INSNREG00_ENABLE_DMA_BURST, EHCI_INSNREG00(hcd->regs)); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH v3 1/3] phy: Add new Exynos USB PHY driver
Hi, > From: Jingoo Han [mailto:jg1@samsung.com] > Sent: Wednesday, November 06, 2013 2:03 AM > > On Wednesday, November 06, 2013 1:13 AM, Kamil Debski wrote: > > > > Add a new driver for the Exynos USB PHY. The new driver uses the > > generic PHY framework. The driver includes support for the Exynos > 4x10 > > and 4x12 SoC families. > > > > Signed-off-by: Kamil Debski > > Signed-off-by: Kyungmin Park > > --- > > .../devicetree/bindings/phy/samsung-usbphy.txt | 52 > > drivers/phy/Kconfig| 23 +- > > drivers/phy/Makefile |4 + > > drivers/phy/phy-exynos-usb2.c | 234 > ++ > > drivers/phy/phy-exynos-usb2.h | 87 ++ > > drivers/phy/phy-exynos4210-usb2.c | 272 > > > drivers/phy/phy-exynos4212-usb2.c | 324 > > > 7 files changed, 995 insertions(+), 1 deletion(-) create mode > 100644 > > Documentation/devicetree/bindings/phy/samsung-usbphy.txt > > create mode 100644 drivers/phy/phy-exynos-usb2.c create mode 100644 > > drivers/phy/phy-exynos-usb2.h create mode 100644 > > drivers/phy/phy-exynos4210-usb2.c create mode 100644 > > drivers/phy/phy-exynos4212-usb2.c > > [] > > > diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index > > d0caae9..c87bc65 100644 > > --- a/drivers/phy/Makefile > > +++ b/drivers/phy/Makefile > > @@ -7,3 +7,7 @@ obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO) += phy-exynos-dp- > video.o > > obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi-video.o > > obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o > > obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o > > +obj-$(CONFIG_PHY_EXYNOS5250_USB) += phy-exynos5250-usb.o > > Hi Kamil, > > Would you add 'phy-exynos5250-usb.c' file? :-) > > Now, I am testing Exynos5250 USB HOST with your patchset. > However, it makes error because there is no PHY driver for Exynos5250. > > WARNING: CPU: 0 PID: 18 at drivers/phy/phy-core.c:366 > phy_get+0x1e8/0x224() > Device: exynos-ehci > missing string > . I have to rewrite the power_on/power_off function in Exynos 5250 and I will include it in the next version. Best wishes, -- Kamil Debski Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH] phy: exynos: fix building as a module
Hi Arnd, > From: Arnd Bergmann [mailto:a...@arndb.de] > Sent: Wednesday, March 12, 2014 4:48 PM > > The top-level phy-samsung-usb2 driver may be configured as a loadable > module, which currently causes link errors because of the dependency on > the exynos{5250,4x12,4210}_usb2_phy_config > symbol. Solving this could be achieved by exporting these symbols, but > as the SoC-specific parts of the driver are not currently built as > modules, it seems better to just link everything into one module and > avoid the need for the export. Thank you for this patch and spotting this error. Acked-by: Kamil Debski Best wishes, -- Kamil Debski Samsung R&D Institute Poland > > Signed-off-by: Arnd Bergmann > > diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index > 2faf78e..7728518 100644 > --- a/drivers/phy/Makefile > +++ b/drivers/phy/Makefile > @@ -13,8 +13,9 @@ obj-$(CONFIG_TI_PIPE3) += phy-ti-pipe3.o > obj-$(CONFIG_TWL4030_USB)+= phy-twl4030-usb.o > obj-$(CONFIG_PHY_EXYNOS5250_SATA)+= phy-exynos5250-sata.o > obj-$(CONFIG_PHY_SUN4I_USB) += phy-sun4i-usb.o > -obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o > -obj-$(CONFIG_PHY_EXYNOS4210_USB2)+= phy-exynos4210-usb2.o > -obj-$(CONFIG_PHY_EXYNOS4X12_USB2)+= phy-exynos4x12-usb2.o > -obj-$(CONFIG_PHY_EXYNOS5250_USB2)+= phy-exynos5250-usb2.o > +obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-exynos-usb2.o > +phy-exynos-usb2-y+= phy-samsung-usb2.o > +phy-exynos-usb2-$(CONFIG_PHY_EXYNOS4210_USB2)+= phy-exynos4210-usb2.o > +phy-exynos-usb2-$(CONFIG_PHY_EXYNOS4X12_USB2)+= phy-exynos4x12-usb2.o > +phy-exynos-usb2-$(CONFIG_PHY_EXYNOS5250_USB2)+= phy-exynos5250-usb2.o > obj-$(CONFIG_PHY_XGENE) += phy-xgene.o -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v7 0/4] phy: Add new Exynos USB 2.0 PHY driver
Hi, This is the seventh version of this patchset. First and most significant change is that this patchset includes only patches touching the Generic PHY Framework. Patches to the USB controllers were stripped as they require additional work. S5PV210 support is also omitted - it requires more testing. Thank you to everyone who joined the discussion, reviewed the patched and contributed to making the code and consequently the Linux Kernel better. Best wishes, Kamil Debski -- Changes from v6: (not including the change that controller patches were removed form this patchset, also this patchset excludes S5PV210 support - it needs more testing) 1) phy: core: Add an exported of_phy_get function - No changes since v6. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v6. 3) phy: Add new Exynos USB 2.0 PHY driver - Changed the way clocks are supplied to the driver. Prior to version v7 there were reference clocks for every phy instance, now a single "ref" clock was introduced. - Updated documentation to match the aforementioned change. - Add offset EXYNOS_*_UPHYCLK_PHYFSEL_OFFSET to the clock register content defines. - Corrected way clock register is modified. Instead of a simple write, a proper read, modify, write sequence was introduced. - Important stability fix - added udelay after PHY reset. This fixes a bug causing instability in USB LAN adapters. Without the delay the DMA burst mode was could not be enabled. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Changed handling of clocks to use a single "ref" clock. Changes from v5: 1) phy: core: Add an exported of_phy_get function - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the of_phy_get function 2) phy: core: Add devm_of_phy_get to phy-core - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the devm_of_phy_get function 3) dts: Add usb2phy to Exynos 4 - no change 4) dts: Add usb2phy to Exynos 5250 - in the previous version, this patch included some phy-exynos5250-usb2.c code by mistake, the code has been remove and added to the proper patch 5) phy: Add new Exynos USB PHY driver - changed strings from Exynos 4212 to Exynos 4x12, as the Exynos 4212 driver is actually a driver for the whole Exynos 4x12 family - added documentation to the Exynos USB 2.0 PHY driver adaptaion layer - corrected strings HSCI -> HSIC - fixed a problem introduced by previous change - on Exynos 4x12 the HSIC did not work on its own - mode switch support was added to Exynos 4x12 (same io pins are used by host and device) - support for phy_set_bus_width introduced by Matt Porter was added 6) phy: Add support for S5PV210 to the Exynos USB PHY - setting of clk register was fixed 7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - supoprt was added for HSIC and device 8) usb: ehci-exynos: Change to use phy provided by the generic phy framework - DT documentation was moved from usb-ehci.txt to exynos-usb.txt Changes from v4: 1) phy: core: Add an exported of_phy_get function - the new exported function of_phy_get was changed to take the phy's name as a parameter instead of the index 2) phy: core: Add devm_of_phy_get to phy-core - fixes made in the comments to devm_of_phy_get 3) phy: Add new Exynos USB PHY driver - move the documentation from a new to an existing file - samsung-phy.txt - fix typos and uppercase hex addresses - add more explanations to Kconfig (checkpatch still complains, but I find it hard to think what else could I add) - add selects MFD_SYSCON as the driver needs it (Thank you, Tobias!) - cleanup included headers in both *.c and .h files - use BIT(x) macro instead of (1 << x) - replaced HOST and DEV with PHY0 and PHY1 in phy-exynos4212-usb2.c, the registers are described as PHYx in the documentation hence the decision to leave the PHYx naming - fixed typo in exynos4210_rate_to_clk reg -> *reg - change hax_mode_switch and enabled type to bool 4) usb: ehci-s5p: Change to use phy provided by the generic phy framework - Put the issue of phy->otg in order - since the new phy driver does not provide this field. With the new driver the switch between host and device is done in power_on of the respective host and device phys. 5) usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework - fixed the example in the documentation 6) phy: Add support for S5PV210 to the Exynos USB PHY driver - include files cleanup - use BIT(x) macro instead of (1 << x) 7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver - include files cleanup - use BIT(x) macro instead of (1 << x) 8) dts: Add usb2phy to Exynos 4 - no changes 9) dts: Add usb2phy to Exynos 5250 - no changes Changes from v3: - using PMU and system registers indirectly via syscon -
[PATCH v7 1/4] phy: core: Add an exported of_phy_get function
Previously the of_phy_get function took a struct device * and was declared static. It was impossible to call it from another driver and thus it was impossible to get phy defined for a given node. The old function was renamed to _of_phy_get and was left for internal use. of_phy_get function was added and it was exported. The function enables to get a phy for a given device tree node. Signed-off-by: Kamil Debski --- drivers/phy/phy-core.c | 45 - include/linux/phy/phy.h |6 ++ 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 6c73837..7c1b0e1 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -274,8 +274,8 @@ int phy_power_off(struct phy *phy) EXPORT_SYMBOL_GPL(phy_power_off); /** - * of_phy_get() - lookup and obtain a reference to a phy by phandle - * @dev: device that requests this phy + * _of_phy_get() - lookup and obtain a reference to a phy by phandle + * @np: device_node for which to get the phy * @index: the index of the phy * * Returns the phy associated with the given phandle value, @@ -284,20 +284,17 @@ EXPORT_SYMBOL_GPL(phy_power_off); * not yet loaded. This function uses of_xlate call back function provided * while registering the phy_provider to find the phy instance. */ -static struct phy *of_phy_get(struct device *dev, int index) +static struct phy *_of_phy_get(struct device_node *np, int index) { int ret; struct phy_provider *phy_provider; struct phy *phy = NULL; struct of_phandle_args args; - ret = of_parse_phandle_with_args(dev->of_node, "phys", "#phy-cells", + ret = of_parse_phandle_with_args(np, "phys", "#phy-cells", index, &args); - if (ret) { - dev_dbg(dev, "failed to get phy in %s node\n", - dev->of_node->full_name); + if (ret) return ERR_PTR(-ENODEV); - } mutex_lock(&phy_provider_mutex); phy_provider = of_phy_provider_lookup(args.np); @@ -317,6 +314,36 @@ err0: } /** + * of_phy_get() - lookup and obtain a reference to a phy using a device_node. + * @np: device_node for which to get the phy + * @con_id: name of the phy from device's point of view + * + * Returns the phy driver, after getting a refcount to it; or + * -ENODEV if there is no such phy. The caller is responsible for + * calling phy_put() to release that count. + */ +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + struct phy *phy = NULL; + int index = 0; + + if (con_id) + index = of_property_match_string(np, "phy-names", con_id); + + phy = _of_phy_get(np, index); + if (IS_ERR(phy)) + return phy; + + if (!try_module_get(phy->ops->owner)) + return ERR_PTR(-EPROBE_DEFER); + + get_device(&phy->dev); + + return phy; +} +EXPORT_SYMBOL_GPL(of_phy_get); + +/** * phy_put() - release the PHY * @phy: the phy returned by phy_get() * @@ -407,7 +434,7 @@ struct phy *phy_get(struct device *dev, const char *string) if (dev->of_node) { index = of_property_match_string(dev->of_node, "phy-names", string); - phy = of_phy_get(dev, index); + phy = _of_phy_get(dev->of_node, index); } else { phy = phy_lookup(dev, string); } diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 3f83459..2fe3194 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -151,6 +151,7 @@ struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); +struct phy *of_phy_get(struct device_node *np, const char *con_id); struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args); struct phy *phy_create(struct device *dev, const struct phy_ops *ops, @@ -259,6 +260,11 @@ static inline void devm_phy_put(struct device *dev, struct phy *phy) { } +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args) { -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v7 2/4] phy: core: Add devm_of_phy_get to phy-core
Adding devm_of_phy_get will allow to get phys by supplying a pointer to the struct device_node instead of struct device. Signed-off-by: Kamil Debski --- drivers/phy/phy-core.c | 31 +++ include/linux/phy/phy.h |8 2 files changed, 39 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 7c1b0e1..623b71c 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -526,6 +526,37 @@ struct phy *devm_phy_optional_get(struct device *dev, const char *string) EXPORT_SYMBOL_GPL(devm_phy_optional_get); /** + * devm_of_phy_get() - lookup and obtain a reference to a phy. + * @dev: device that requests this phy + * @np: node containing the phy + * @con_id: name of the phy from device's point of view + * + * Gets the phy using of_phy_get(), and associates a device with it using + * devres. On driver detach, release function is invoked on the devres data, + * then, devres data is freed. + */ +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + struct phy **ptr, *phy; + + ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + phy = of_phy_get(np, con_id); + if (!IS_ERR(phy)) { + *ptr = phy; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return phy; +} +EXPORT_SYMBOL_GPL(devm_of_phy_get); + +/** * phy_create() - create a new phy * @dev: device that is creating the new phy * @ops: function pointers for performing phy operations diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 2fe3194..bcbf96c 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -149,6 +149,8 @@ struct phy *phy_get(struct device *dev, const char *string); struct phy *phy_optional_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); struct phy *of_phy_get(struct device_node *np, const char *con_id); @@ -252,6 +254,12 @@ static inline struct phy *devm_phy_optional_get(struct device *dev, return ERR_PTR(-ENOSYS); } +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline void phy_put(struct phy *phy) { } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v7 4/4] phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver
Add support for Exynos 5250. This driver is to replace the old USB 2.0 PHY driver. Signed-off-by: Kamil Debski --- .../devicetree/bindings/phy/samsung-phy.txt|1 + drivers/phy/Kconfig| 11 + drivers/phy/Makefile |1 + drivers/phy/phy-exynos5250-usb2.c | 405 drivers/phy/phy-samsung-usb2.c |6 + drivers/phy/phy-samsung-usb2.h |1 + 6 files changed, 425 insertions(+) create mode 100644 drivers/phy/phy-exynos5250-usb2.c diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index bf955ab..28f9edb 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -28,6 +28,7 @@ Required properties: - compatible : should be one of the listed compatibles: - "samsung,exynos4210-usb2-phy" - "samsung,exynos4x12-usb2-phy" + - "samsung,exynos5250-usb2-phy" - reg : a list of registers used by phy driver - first and obligatory is the location of phy modules registers - samsung,sysreg-phandle - handle to syscon used to control the system registers diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 1890351..fe2663c 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -94,4 +94,15 @@ config PHY_EXYNOS4X12_USB2 Samsung USB 2.0 PHY driver is enabled and means that support for this particular SoC is compiled in the driver. In case of Exynos 4x12 four phys are available - device, host, HSIC0 and HSIC1. + +config PHY_EXYNOS5250_USB2 + bool "Support for Exynos 5250" + depends on PHY_SAMSUNG_USB2 + depends on SOC_EXYNOS5250 + help + Enable USB PHY support for Exynos 5250. This option requires that + Samsung USB 2.0 PHY driver is enabled and means that support for this + particular SoC is compiled in the driver. In case of Exynos 5250 four + phys are available - device, host, HSIC0 and HSIC. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 69d0b3f2..4dcd389 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -12,3 +12,4 @@ obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o obj-$(CONFIG_PHY_EXYNOS4210_USB2) += phy-exynos4210-usb2.o obj-$(CONFIG_PHY_EXYNOS4X12_USB2) += phy-exynos4x12-usb2.o +obj-$(CONFIG_PHY_EXYNOS5250_USB2) += phy-exynos5250-usb2.o diff --git a/drivers/phy/phy-exynos5250-usb2.c b/drivers/phy/phy-exynos5250-usb2.c new file mode 100644 index 000..1ba0bb30 --- /dev/null +++ b/drivers/phy/phy-exynos5250-usb2.c @@ -0,0 +1,405 @@ +/* + * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 5250 support + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Kamil Debski + * + * 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 +#include +#include +#include +#include "phy-samsung-usb2.h" + +/* Exynos USB PHY registers */ +#define EXYNOS_5250_REFCLKSEL_CRYSTAL 0x0 +#define EXYNOS_5250_REFCLKSEL_XO 0x1 +#define EXYNOS_5250_REFCLKSEL_CLKCORE 0x2 + +#define EXYNOS_5250_FSEL_9MHZ6 0x0 +#define EXYNOS_5250_FSEL_10MHZ 0x1 +#define EXYNOS_5250_FSEL_12MHZ 0x2 +#define EXYNOS_5250_FSEL_19MHZ20x3 +#define EXYNOS_5250_FSEL_20MHZ 0x4 +#define EXYNOS_5250_FSEL_24MHZ 0x5 +#define EXYNOS_5250_FSEL_50MHZ 0x7 + +/* Normal host */ +#define EXYNOS_5250_HOSTPHYCTRL0 0x0 + +#define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRSTALL BIT(31) +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT 19 +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_MASK\ + (0x3 << EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT16 +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_MASK \ + (0x7 << EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_TESTBURNINBIT(11) +#define EXYNOS_5250_HOSTPHYCTRL0_RETENABLE BIT(10) +#define EXYNOS_5250_HOSTPHYCTRL0_COMMON_ON_N BIT(9) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_MASK(0x3 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_DUAL(0x0 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ID0 (0x1 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ANALOGTEST (0x2 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_SIDDQ BIT(6) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESLEEPBIT(5) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESUSPEND
[PATCH v7 3/4] phy: Add new Exynos USB 2.0 PHY driver
Add a new driver for the Exynos USB 2.0 PHY. The new driver uses the generic PHY framework. The driver includes support for the Exynos 4210 and 4x12 SoC families. Signed-off-by: Kamil Debski --- .../devicetree/bindings/phy/samsung-phy.txt| 53 Documentation/phy/samsung-usb2.txt | 134 drivers/phy/Kconfig| 29 ++ drivers/phy/Makefile |3 + drivers/phy/phy-exynos4210-usb2.c | 262 drivers/phy/phy-exynos4x12-usb2.c | 330 drivers/phy/phy-samsung-usb2.c | 223 + drivers/phy/phy-samsung-usb2.h | 67 8 files changed, 1101 insertions(+) create mode 100644 Documentation/phy/samsung-usb2.txt create mode 100644 drivers/phy/phy-exynos4210-usb2.c create mode 100644 drivers/phy/phy-exynos4x12-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.h diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index c0fccaa..bf955ab 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -20,3 +20,56 @@ Required properties: - compatible : should be "samsung,exynos5250-dp-video-phy"; - reg : offset and length of the Display Port PHY register set; - #phy-cells : from the generic PHY bindings, must be 0; + +Samsung S5P/EXYNOS SoC series USB PHY +- + +Required properties: +- compatible : should be one of the listed compatibles: + - "samsung,exynos4210-usb2-phy" + - "samsung,exynos4x12-usb2-phy" +- reg : a list of registers used by phy driver + - first and obligatory is the location of phy modules registers +- samsung,sysreg-phandle - handle to syscon used to control the system registers +- samsung,pmureg-phandle - handle to syscon used to control PMU registers +- #phy-cells : from the generic phy bindings, must be 1; +- clocks and clock-names: + - the "phy" clock is required by the phy module, used as a gate + - the "ref" clock is used to get the rate of the clock provided to the + PHY module + +The first phandle argument in the PHY specifier identifies the PHY, its +meaning is compatible dependent. For the currently supported SoCs (Exynos 4210 +and Exynos 4212) it is as follows: + 0 - USB device ("device"), + 1 - USB host ("host"), + 2 - HSIC0 ("hsic0"), + 3 - HSIC1 ("hsic1"), + +Exynos 4210 and Exynos 4212 use mode switching and require that mode switch +register is supplied. + +Example: + +For Exynos 4412 (compatible with Exynos 4212): + +usbphy: phy@125b { + compatible = "samsung,exynos4x12-usb2-phy"; + reg = <0x125b 0x100>; + clocks = <&clock 305>, <&clock 2>; + clock-names = "phy", "ref"; + status = "okay"; + #phy-cells = <1>; + samsung,sysreg-phandle = <&sys_reg>; + samsung,pmureg-phandle = <&pmu_reg>; +}; + +Then the PHY can be used in other nodes such as: + +phy-consumer@1234 { + phys = <&usbphy 2>; + phy-names = "phy"; +}; + +Refer to DT bindings documentation of particular PHY consumer devices for more +information about required PHYs and the way of specification. diff --git a/Documentation/phy/samsung-usb2.txt b/Documentation/phy/samsung-usb2.txt new file mode 100644 index 000..0c8e260 --- /dev/null +++ b/Documentation/phy/samsung-usb2.txt @@ -0,0 +1,134 @@ +.--+ +| Samsung USB 2.0 PHY adaptation layer | ++-+' + +| 1. Description ++ + +The architecture of the USB 2.0 PHY module in Samsung SoCs is similar +among many SoCs. In spite of the similarities it proved difficult to +create a one driver that would fit all these PHY controllers. Often +the differences were minor and were found in particular bits of the +registers of the PHY. In some rare cases the order of register writes or +the PHY powering up process had to be altered. This adaptation layer is +a compromise between having separate drivers and having a single driver +with added support for many special cases. + +| 2. Files description ++-- + +- phy-samsung-usb2.c + This is the main file of the adaptation layer. This file contains + the probe function and provides two callbacks to the Generic PHY + Framework. This two callbacks are used to power on and power off the + phy. They carry out the common work that has to be d
RE: [PATCH v7 3/4] phy: Add new Exynos USB 2.0 PHY driver
Hi Sander, > From: Kamil Debski [mailto:k.deb...@samsung.com] > Sent: Tuesday, March 04, 2014 4:24 PM > > Add a new driver for the Exynos USB 2.0 PHY. The new driver uses the > generic PHY framework. The driver includes support for the Exynos 4210 > and 4x12 SoC families. > > Signed-off-by: Kamil Debski Sander, you did test the v6 of this patch, thus I am adding your "Tested-by". Could you confirm that this version works as well? Tested-by: Sander Hollaar Best wishes, -- Kamil Debski Samsung R&D Institute Poland > --- > .../devicetree/bindings/phy/samsung-phy.txt| 53 > Documentation/phy/samsung-usb2.txt | 134 > drivers/phy/Kconfig| 29 ++ > drivers/phy/Makefile |3 + > drivers/phy/phy-exynos4210-usb2.c | 262 > > drivers/phy/phy-exynos4x12-usb2.c | 330 > > drivers/phy/phy-samsung-usb2.c | 223 > + > drivers/phy/phy-samsung-usb2.h | 67 > 8 files changed, 1101 insertions(+) > create mode 100644 Documentation/phy/samsung-usb2.txt > create mode 100644 drivers/phy/phy-exynos4210-usb2.c create mode > 100644 drivers/phy/phy-exynos4x12-usb2.c create mode 100644 > drivers/phy/phy-samsung-usb2.c create mode 100644 drivers/phy/phy- > samsung-usb2.h > > diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt > b/Documentation/devicetree/bindings/phy/samsung-phy.txt > index c0fccaa..bf955ab 100644 > --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt > +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt > @@ -20,3 +20,56 @@ Required properties: > - compatible : should be "samsung,exynos5250-dp-video-phy"; > - reg : offset and length of the Display Port PHY register set; > - #phy-cells : from the generic PHY bindings, must be 0; > + > +Samsung S5P/EXYNOS SoC series USB PHY > +- > + > +Required properties: > +- compatible : should be one of the listed compatibles: > + - "samsung,exynos4210-usb2-phy" > + - "samsung,exynos4x12-usb2-phy" > +- reg : a list of registers used by phy driver > + - first and obligatory is the location of phy modules registers > +- samsung,sysreg-phandle - handle to syscon used to control the system > +registers > +- samsung,pmureg-phandle - handle to syscon used to control PMU > +registers > +- #phy-cells : from the generic phy bindings, must be 1; > +- clocks and clock-names: > + - the "phy" clock is required by the phy module, used as a gate > + - the "ref" clock is used to get the rate of the clock provided > to the > + PHY module > + > +The first phandle argument in the PHY specifier identifies the PHY, > its > +meaning is compatible dependent. For the currently supported SoCs > +(Exynos 4210 and Exynos 4212) it is as follows: > + 0 - USB device ("device"), > + 1 - USB host ("host"), > + 2 - HSIC0 ("hsic0"), > + 3 - HSIC1 ("hsic1"), > + > +Exynos 4210 and Exynos 4212 use mode switching and require that mode > +switch register is supplied. > + > +Example: > + > +For Exynos 4412 (compatible with Exynos 4212): > + > +usbphy: phy@125b { > + compatible = "samsung,exynos4x12-usb2-phy"; > + reg = <0x125b 0x100>; > + clocks = <&clock 305>, <&clock 2>; > + clock-names = "phy", "ref"; > + status = "okay"; > + #phy-cells = <1>; > + samsung,sysreg-phandle = <&sys_reg>; > + samsung,pmureg-phandle = <&pmu_reg>; > +}; > + > +Then the PHY can be used in other nodes such as: > + > +phy-consumer@1234 { > + phys = <&usbphy 2>; > + phy-names = "phy"; > +}; > + > +Refer to DT bindings documentation of particular PHY consumer devices > +for more information about required PHYs and the way of specification. > diff --git a/Documentation/phy/samsung-usb2.txt > b/Documentation/phy/samsung-usb2.txt > new file mode 100644 > index 000..0c8e260 > --- /dev/null > +++ b/Documentation/phy/samsung-usb2.txt > @@ -0,0 +1,134 @@ > +.- > - > ++ > +|Samsung USB 2.0 PHY adaptation layer > | > ++- > +' > + > +| 1. Description > ++ > + > +The architecture of the USB 2.0
[PATCH v8 0/4] phy: Add new Exynos USB 2.0 PHY driver
Hi, This is the eighth version of this patchset. First and most significant change since v6 is that this patchset includes only patches touching the Generic PHY Framework. Patches to the USB controllers were stripped as they require additional work. S5PV210 support is also omitted - it requires more testing. Since v7 this patch includes fixes for checkpath errors and was rebased onto Kishon's next branch. Best wishes, Kamil Debski -- Changes from v7: 1) phy: core: Add an exported of_phy_get function - No changes since v7. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v7. 3) phy: Add new Exynos USB 2.0 PHY driver - Fix checkpatch errors with code indentation and corrected whitespace. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Fix checkpatch errors with code indentation and corrected whitespace. -- Changes from v6: (not including the change that controller patches were removed form this patchset, also this patchset excludes S5PV210 support - it needs more testing) 1) phy: core: Add an exported of_phy_get function - No changes since v6. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v6. 3) phy: Add new Exynos USB 2.0 PHY driver - Changed the way clocks are supplied to the driver. Prior to version v7 there were reference clocks for every phy instance, now a single "ref" clock was introduced. - Updated documentation to match the aforementioned change. - Add offset EXYNOS_*_UPHYCLK_PHYFSEL_OFFSET to the clock register content defines. - Corrected way clock register is modified. Instead of a simple write, a proper read, modify, write sequence was introduced. - Important stability fix - added udelay after PHY reset. This fixes a bug causing instability in USB LAN adapters. Without the delay the DMA burst mode was could not be enabled. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Changed handling of clocks to use a single "ref" clock. Changes from v5: 1) phy: core: Add an exported of_phy_get function - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the of_phy_get function 2) phy: core: Add devm_of_phy_get to phy-core - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the devm_of_phy_get function 3) dts: Add usb2phy to Exynos 4 - no change 4) dts: Add usb2phy to Exynos 5250 - in the previous version, this patch included some phy-exynos5250-usb2.c code by mistake, the code has been remove and added to the proper patch 5) phy: Add new Exynos USB PHY driver - changed strings from Exynos 4212 to Exynos 4x12, as the Exynos 4212 driver is actually a driver for the whole Exynos 4x12 family - added documentation to the Exynos USB 2.0 PHY driver adaptaion layer - corrected strings HSCI -> HSIC - fixed a problem introduced by previous change - on Exynos 4x12 the HSIC did not work on its own - mode switch support was added to Exynos 4x12 (same io pins are used by host and device) - support for phy_set_bus_width introduced by Matt Porter was added 6) phy: Add support for S5PV210 to the Exynos USB PHY - setting of clk register was fixed 7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - supoprt was added for HSIC and device 8) usb: ehci-exynos: Change to use phy provided by the generic phy framework - DT documentation was moved from usb-ehci.txt to exynos-usb.txt Changes from v4: 1) phy: core: Add an exported of_phy_get function - the new exported function of_phy_get was changed to take the phy's name as a parameter instead of the index 2) phy: core: Add devm_of_phy_get to phy-core - fixes made in the comments to devm_of_phy_get 3) phy: Add new Exynos USB PHY driver - move the documentation from a new to an existing file - samsung-phy.txt - fix typos and uppercase hex addresses - add more explanations to Kconfig (checkpatch still complains, but I find it hard to think what else could I add) - add selects MFD_SYSCON as the driver needs it (Thank you, Tobias!) - cleanup included headers in both *.c and .h files - use BIT(x) macro instead of (1 << x) - replaced HOST and DEV with PHY0 and PHY1 in phy-exynos4212-usb2.c, the registers are described as PHYx in the documentation hence the decision to leave the PHYx naming - fixed typo in exynos4210_rate_to_clk reg -> *reg - change hax_mode_switch and enabled type to bool 4) usb: ehci-s5p: Change to use phy provided by the generic phy framework - Put the issue of phy->otg in order - since the new phy driver does not provide this field. With the new driver the switch between host and device is done in power_on of the respective host and device phys. 5) usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework - fixed the example in the documentation 6) phy: Add support for S5PV210 to the Exynos USB P
[PATCH v8 1/4] phy: core: Add an exported of_phy_get function
Previously the of_phy_get function took a struct device * and was declared static. It was impossible to call it from another driver and thus it was impossible to get phy defined for a given node. The old function was renamed to _of_phy_get and was left for internal use. of_phy_get function was added and it was exported. The function enables to get a phy for a given device tree node. Signed-off-by: Kamil Debski --- drivers/phy/phy-core.c | 45 - include/linux/phy/phy.h |6 ++ 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 6c73837..7c1b0e1 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -274,8 +274,8 @@ int phy_power_off(struct phy *phy) EXPORT_SYMBOL_GPL(phy_power_off); /** - * of_phy_get() - lookup and obtain a reference to a phy by phandle - * @dev: device that requests this phy + * _of_phy_get() - lookup and obtain a reference to a phy by phandle + * @np: device_node for which to get the phy * @index: the index of the phy * * Returns the phy associated with the given phandle value, @@ -284,20 +284,17 @@ EXPORT_SYMBOL_GPL(phy_power_off); * not yet loaded. This function uses of_xlate call back function provided * while registering the phy_provider to find the phy instance. */ -static struct phy *of_phy_get(struct device *dev, int index) +static struct phy *_of_phy_get(struct device_node *np, int index) { int ret; struct phy_provider *phy_provider; struct phy *phy = NULL; struct of_phandle_args args; - ret = of_parse_phandle_with_args(dev->of_node, "phys", "#phy-cells", + ret = of_parse_phandle_with_args(np, "phys", "#phy-cells", index, &args); - if (ret) { - dev_dbg(dev, "failed to get phy in %s node\n", - dev->of_node->full_name); + if (ret) return ERR_PTR(-ENODEV); - } mutex_lock(&phy_provider_mutex); phy_provider = of_phy_provider_lookup(args.np); @@ -317,6 +314,36 @@ err0: } /** + * of_phy_get() - lookup and obtain a reference to a phy using a device_node. + * @np: device_node for which to get the phy + * @con_id: name of the phy from device's point of view + * + * Returns the phy driver, after getting a refcount to it; or + * -ENODEV if there is no such phy. The caller is responsible for + * calling phy_put() to release that count. + */ +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + struct phy *phy = NULL; + int index = 0; + + if (con_id) + index = of_property_match_string(np, "phy-names", con_id); + + phy = _of_phy_get(np, index); + if (IS_ERR(phy)) + return phy; + + if (!try_module_get(phy->ops->owner)) + return ERR_PTR(-EPROBE_DEFER); + + get_device(&phy->dev); + + return phy; +} +EXPORT_SYMBOL_GPL(of_phy_get); + +/** * phy_put() - release the PHY * @phy: the phy returned by phy_get() * @@ -407,7 +434,7 @@ struct phy *phy_get(struct device *dev, const char *string) if (dev->of_node) { index = of_property_match_string(dev->of_node, "phy-names", string); - phy = of_phy_get(dev, index); + phy = _of_phy_get(dev->of_node, index); } else { phy = phy_lookup(dev, string); } diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 3f83459..2fe3194 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -151,6 +151,7 @@ struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); +struct phy *of_phy_get(struct device_node *np, const char *con_id); struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args); struct phy *phy_create(struct device *dev, const struct phy_ops *ops, @@ -259,6 +260,11 @@ static inline void devm_phy_put(struct device *dev, struct phy *phy) { } +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args) { -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v8 2/4] phy: core: Add devm_of_phy_get to phy-core
Adding devm_of_phy_get will allow to get phys by supplying a pointer to the struct device_node instead of struct device. Signed-off-by: Kamil Debski --- drivers/phy/phy-core.c | 31 +++ include/linux/phy/phy.h |8 2 files changed, 39 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 7c1b0e1..623b71c 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -526,6 +526,37 @@ struct phy *devm_phy_optional_get(struct device *dev, const char *string) EXPORT_SYMBOL_GPL(devm_phy_optional_get); /** + * devm_of_phy_get() - lookup and obtain a reference to a phy. + * @dev: device that requests this phy + * @np: node containing the phy + * @con_id: name of the phy from device's point of view + * + * Gets the phy using of_phy_get(), and associates a device with it using + * devres. On driver detach, release function is invoked on the devres data, + * then, devres data is freed. + */ +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + struct phy **ptr, *phy; + + ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + phy = of_phy_get(np, con_id); + if (!IS_ERR(phy)) { + *ptr = phy; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return phy; +} +EXPORT_SYMBOL_GPL(devm_of_phy_get); + +/** * phy_create() - create a new phy * @dev: device that is creating the new phy * @ops: function pointers for performing phy operations diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 2fe3194..bcbf96c 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -149,6 +149,8 @@ struct phy *phy_get(struct device *dev, const char *string); struct phy *phy_optional_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); struct phy *of_phy_get(struct device_node *np, const char *con_id); @@ -252,6 +254,12 @@ static inline struct phy *devm_phy_optional_get(struct device *dev, return ERR_PTR(-ENOSYS); } +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline void phy_put(struct phy *phy) { } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v8 3/4] phy: Add new Exynos USB 2.0 PHY driver
Add a new driver for the Exynos USB 2.0 PHY. The new driver uses the generic PHY framework. The driver includes support for the Exynos 4x10 and 4x12 SoC families. Signed-off-by: Kamil Debski --- .../devicetree/bindings/phy/samsung-phy.txt| 53 Documentation/phy/samsung-usb2.txt | 134 drivers/phy/Kconfig| 29 ++ drivers/phy/Makefile |3 + drivers/phy/phy-exynos4210-usb2.c | 262 drivers/phy/phy-exynos4x12-usb2.c | 329 drivers/phy/phy-samsung-usb2.c | 223 + drivers/phy/phy-samsung-usb2.h | 67 8 files changed, 1100 insertions(+) create mode 100644 Documentation/phy/samsung-usb2.txt create mode 100644 drivers/phy/phy-exynos4210-usb2.c create mode 100644 drivers/phy/phy-exynos4x12-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.h diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index c0fccaa..bf955ab 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -20,3 +20,56 @@ Required properties: - compatible : should be "samsung,exynos5250-dp-video-phy"; - reg : offset and length of the Display Port PHY register set; - #phy-cells : from the generic PHY bindings, must be 0; + +Samsung S5P/EXYNOS SoC series USB PHY +- + +Required properties: +- compatible : should be one of the listed compatibles: + - "samsung,exynos4210-usb2-phy" + - "samsung,exynos4x12-usb2-phy" +- reg : a list of registers used by phy driver + - first and obligatory is the location of phy modules registers +- samsung,sysreg-phandle - handle to syscon used to control the system registers +- samsung,pmureg-phandle - handle to syscon used to control PMU registers +- #phy-cells : from the generic phy bindings, must be 1; +- clocks and clock-names: + - the "phy" clock is required by the phy module, used as a gate + - the "ref" clock is used to get the rate of the clock provided to the + PHY module + +The first phandle argument in the PHY specifier identifies the PHY, its +meaning is compatible dependent. For the currently supported SoCs (Exynos 4210 +and Exynos 4212) it is as follows: + 0 - USB device ("device"), + 1 - USB host ("host"), + 2 - HSIC0 ("hsic0"), + 3 - HSIC1 ("hsic1"), + +Exynos 4210 and Exynos 4212 use mode switching and require that mode switch +register is supplied. + +Example: + +For Exynos 4412 (compatible with Exynos 4212): + +usbphy: phy@125b { + compatible = "samsung,exynos4x12-usb2-phy"; + reg = <0x125b 0x100>; + clocks = <&clock 305>, <&clock 2>; + clock-names = "phy", "ref"; + status = "okay"; + #phy-cells = <1>; + samsung,sysreg-phandle = <&sys_reg>; + samsung,pmureg-phandle = <&pmu_reg>; +}; + +Then the PHY can be used in other nodes such as: + +phy-consumer@1234 { + phys = <&usbphy 2>; + phy-names = "phy"; +}; + +Refer to DT bindings documentation of particular PHY consumer devices for more +information about required PHYs and the way of specification. diff --git a/Documentation/phy/samsung-usb2.txt b/Documentation/phy/samsung-usb2.txt new file mode 100644 index 000..0c8e260 --- /dev/null +++ b/Documentation/phy/samsung-usb2.txt @@ -0,0 +1,134 @@ +.--+ +| Samsung USB 2.0 PHY adaptation layer | ++-+' + +| 1. Description ++ + +The architecture of the USB 2.0 PHY module in Samsung SoCs is similar +among many SoCs. In spite of the similarities it proved difficult to +create a one driver that would fit all these PHY controllers. Often +the differences were minor and were found in particular bits of the +registers of the PHY. In some rare cases the order of register writes or +the PHY powering up process had to be altered. This adaptation layer is +a compromise between having separate drivers and having a single driver +with added support for many special cases. + +| 2. Files description ++-- + +- phy-samsung-usb2.c + This is the main file of the adaptation layer. This file contains + the probe function and provides two callbacks to the Generic PHY + Framework. This two callbacks are used to power on and power off the + phy. They carry out the common work that has to be d
[PATCH v8 4/4] phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver
Add support for Exynos 5250. This driver is to replace the old USB 2.0 PHY driver. Signed-off-by: Kamil Debski --- .../devicetree/bindings/phy/samsung-phy.txt|1 + drivers/phy/Kconfig| 11 + drivers/phy/Makefile |1 + drivers/phy/phy-exynos5250-usb2.c | 405 drivers/phy/phy-samsung-usb2.c |6 + drivers/phy/phy-samsung-usb2.h |1 + 6 files changed, 425 insertions(+) create mode 100644 drivers/phy/phy-exynos5250-usb2.c diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index bf955ab..28f9edb 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -28,6 +28,7 @@ Required properties: - compatible : should be one of the listed compatibles: - "samsung,exynos4210-usb2-phy" - "samsung,exynos4x12-usb2-phy" + - "samsung,exynos5250-usb2-phy" - reg : a list of registers used by phy driver - first and obligatory is the location of phy modules registers - samsung,sysreg-phandle - handle to syscon used to control the system registers diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index fc5a44a..c206e25 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -125,4 +125,15 @@ config PHY_EXYNOS4X12_USB2 Samsung USB 2.0 PHY driver is enabled and means that support for this particular SoC is compiled in the driver. In case of Exynos 4x12 four phys are available - device, host, HSIC0 and HSIC1. + +config PHY_EXYNOS5250_USB2 + bool "Support for Exynos 5250" + depends on PHY_SAMSUNG_USB2 + depends on SOC_EXYNOS5250 + help + Enable USB PHY support for Exynos 5250. This option requires that + Samsung USB 2.0 PHY driver is enabled and means that support for this + particular SoC is compiled in the driver. In case of Exynos 5250 four + phys are available - device, host, HSIC0 and HSIC. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 0ea36ff..f76c239 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -14,3 +14,4 @@ obj-$(CONFIG_PHY_SUN4I_USB) += phy-sun4i-usb.o obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o obj-$(CONFIG_PHY_EXYNOS4210_USB2) += phy-exynos4210-usb2.o obj-$(CONFIG_PHY_EXYNOS4X12_USB2) += phy-exynos4x12-usb2.o +obj-$(CONFIG_PHY_EXYNOS5250_USB2) += phy-exynos5250-usb2.o diff --git a/drivers/phy/phy-exynos5250-usb2.c b/drivers/phy/phy-exynos5250-usb2.c new file mode 100644 index 000..877994e --- /dev/null +++ b/drivers/phy/phy-exynos5250-usb2.c @@ -0,0 +1,405 @@ +/* + * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 5250 support + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Kamil Debski + * + * 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 +#include +#include +#include +#include "phy-samsung-usb2.h" + +/* Exynos USB PHY registers */ +#define EXYNOS_5250_REFCLKSEL_CRYSTAL 0x0 +#define EXYNOS_5250_REFCLKSEL_XO 0x1 +#define EXYNOS_5250_REFCLKSEL_CLKCORE 0x2 + +#define EXYNOS_5250_FSEL_9MHZ6 0x0 +#define EXYNOS_5250_FSEL_10MHZ 0x1 +#define EXYNOS_5250_FSEL_12MHZ 0x2 +#define EXYNOS_5250_FSEL_19MHZ20x3 +#define EXYNOS_5250_FSEL_20MHZ 0x4 +#define EXYNOS_5250_FSEL_24MHZ 0x5 +#define EXYNOS_5250_FSEL_50MHZ 0x7 + +/* Normal host */ +#define EXYNOS_5250_HOSTPHYCTRL0 0x0 + +#define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRSTALL BIT(31) +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT 19 +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_MASK\ + (0x3 << EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT16 +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_MASK \ + (0x7 << EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_TESTBURNINBIT(11) +#define EXYNOS_5250_HOSTPHYCTRL0_RETENABLE BIT(10) +#define EXYNOS_5250_HOSTPHYCTRL0_COMMON_ON_N BIT(9) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_MASK(0x3 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_DUAL(0x0 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ID0 (0x1 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ANALOGTEST (0x2 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_SIDDQ BIT(6) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESLEEPBIT(5) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESUSPEND
[PATCH v9 3/4] phy: Add new Exynos USB 2.0 PHY driver
Add a new driver for the Exynos USB 2.0 PHY. The new driver uses the generic PHY framework. The driver includes support for the Exynos 4x10 and 4x12 SoC families. Signed-off-by: Kamil Debski --- .../devicetree/bindings/phy/samsung-phy.txt| 53 Documentation/phy/samsung-usb2.txt | 134 drivers/phy/Kconfig| 29 ++ drivers/phy/Makefile |3 + drivers/phy/phy-exynos4210-usb2.c | 261 drivers/phy/phy-exynos4x12-usb2.c | 328 drivers/phy/phy-samsung-usb2.c | 222 + drivers/phy/phy-samsung-usb2.h | 66 8 files changed, 1096 insertions(+) create mode 100644 Documentation/phy/samsung-usb2.txt create mode 100644 drivers/phy/phy-exynos4210-usb2.c create mode 100644 drivers/phy/phy-exynos4x12-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.h diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index c0fccaa..bf955ab 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -20,3 +20,56 @@ Required properties: - compatible : should be "samsung,exynos5250-dp-video-phy"; - reg : offset and length of the Display Port PHY register set; - #phy-cells : from the generic PHY bindings, must be 0; + +Samsung S5P/EXYNOS SoC series USB PHY +- + +Required properties: +- compatible : should be one of the listed compatibles: + - "samsung,exynos4210-usb2-phy" + - "samsung,exynos4x12-usb2-phy" +- reg : a list of registers used by phy driver + - first and obligatory is the location of phy modules registers +- samsung,sysreg-phandle - handle to syscon used to control the system registers +- samsung,pmureg-phandle - handle to syscon used to control PMU registers +- #phy-cells : from the generic phy bindings, must be 1; +- clocks and clock-names: + - the "phy" clock is required by the phy module, used as a gate + - the "ref" clock is used to get the rate of the clock provided to the + PHY module + +The first phandle argument in the PHY specifier identifies the PHY, its +meaning is compatible dependent. For the currently supported SoCs (Exynos 4210 +and Exynos 4212) it is as follows: + 0 - USB device ("device"), + 1 - USB host ("host"), + 2 - HSIC0 ("hsic0"), + 3 - HSIC1 ("hsic1"), + +Exynos 4210 and Exynos 4212 use mode switching and require that mode switch +register is supplied. + +Example: + +For Exynos 4412 (compatible with Exynos 4212): + +usbphy: phy@125b { + compatible = "samsung,exynos4x12-usb2-phy"; + reg = <0x125b 0x100>; + clocks = <&clock 305>, <&clock 2>; + clock-names = "phy", "ref"; + status = "okay"; + #phy-cells = <1>; + samsung,sysreg-phandle = <&sys_reg>; + samsung,pmureg-phandle = <&pmu_reg>; +}; + +Then the PHY can be used in other nodes such as: + +phy-consumer@1234 { + phys = <&usbphy 2>; + phy-names = "phy"; +}; + +Refer to DT bindings documentation of particular PHY consumer devices for more +information about required PHYs and the way of specification. diff --git a/Documentation/phy/samsung-usb2.txt b/Documentation/phy/samsung-usb2.txt new file mode 100644 index 000..0c8e260 --- /dev/null +++ b/Documentation/phy/samsung-usb2.txt @@ -0,0 +1,134 @@ +.--+ +| Samsung USB 2.0 PHY adaptation layer | ++-+' + +| 1. Description ++ + +The architecture of the USB 2.0 PHY module in Samsung SoCs is similar +among many SoCs. In spite of the similarities it proved difficult to +create a one driver that would fit all these PHY controllers. Often +the differences were minor and were found in particular bits of the +registers of the PHY. In some rare cases the order of register writes or +the PHY powering up process had to be altered. This adaptation layer is +a compromise between having separate drivers and having a single driver +with added support for many special cases. + +| 2. Files description ++-- + +- phy-samsung-usb2.c + This is the main file of the adaptation layer. This file contains + the probe function and provides two callbacks to the Generic PHY + Framework. This two callbacks are used to power on and power off the + phy. They carry out the common work that has to be d
[PATCH v9 0/4] phy: Add new Exynos USB 2.0 PHY driver
Hi, This is the ninth version of this patchset. First and most significant change since v6 is that this patchset includes only patches touching the Generic PHY Framework. Patches to the USB controllers were stripped as they require additional work. S5PV210 support is also omitted - it requires more testing. Since v7 this patch includes fixes for checkpath errors and was rebased onto Kishon's next branch. v9 brings whitespace corrections compared to v8. Best wishes, Kamil Debski -- Changes from v8: 1) phy: core: Add an exported of_phy_get function - No changes since v8. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v8. 3) phy: Add new Exynos USB 2.0 PHY driver - Fix empty blank line at EOF errors 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Fix empty blank line at EOF error -- Changes from v7: 1) phy: core: Add an exported of_phy_get function - No changes since v7. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v7. 3) phy: Add new Exynos USB 2.0 PHY driver - Fix checkpatch errors with code indentation and corrected whitespace. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Fix checkpatch errors with code indentation and corrected whitespace. -- Changes from v6: (not including the change that controller patches were removed form this patchset, also this patchset excludes S5PV210 support - it needs more testing) 1) phy: core: Add an exported of_phy_get function - No changes since v6. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v6. 3) phy: Add new Exynos USB 2.0 PHY driver - Changed the way clocks are supplied to the driver. Prior to version v7 there were reference clocks for every phy instance, now a single "ref" clock was introduced. - Updated documentation to match the aforementioned change. - Add offset EXYNOS_*_UPHYCLK_PHYFSEL_OFFSET to the clock register content defines. - Corrected way clock register is modified. Instead of a simple write, a proper read, modify, write sequence was introduced. - Important stability fix - added udelay after PHY reset. This fixes a bug causing instability in USB LAN adapters. Without the delay the DMA burst mode was could not be enabled. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Changed handling of clocks to use a single "ref" clock. Changes from v5: 1) phy: core: Add an exported of_phy_get function - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the of_phy_get function 2) phy: core: Add devm_of_phy_get to phy-core - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the devm_of_phy_get function 3) dts: Add usb2phy to Exynos 4 - no change 4) dts: Add usb2phy to Exynos 5250 - in the previous version, this patch included some phy-exynos5250-usb2.c code by mistake, the code has been remove and added to the proper patch 5) phy: Add new Exynos USB PHY driver - changed strings from Exynos 4212 to Exynos 4x12, as the Exynos 4212 driver is actually a driver for the whole Exynos 4x12 family - added documentation to the Exynos USB 2.0 PHY driver adaptaion layer - corrected strings HSCI -> HSIC - fixed a problem introduced by previous change - on Exynos 4x12 the HSIC did not work on its own - mode switch support was added to Exynos 4x12 (same io pins are used by host and device) - support for phy_set_bus_width introduced by Matt Porter was added 6) phy: Add support for S5PV210 to the Exynos USB PHY - setting of clk register was fixed 7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - supoprt was added for HSIC and device 8) usb: ehci-exynos: Change to use phy provided by the generic phy framework - DT documentation was moved from usb-ehci.txt to exynos-usb.txt Changes from v4: 1) phy: core: Add an exported of_phy_get function - the new exported function of_phy_get was changed to take the phy's name as a parameter instead of the index 2) phy: core: Add devm_of_phy_get to phy-core - fixes made in the comments to devm_of_phy_get 3) phy: Add new Exynos USB PHY driver - move the documentation from a new to an existing file - samsung-phy.txt - fix typos and uppercase hex addresses - add more explanations to Kconfig (checkpatch still complains, but I find it hard to think what else could I add) - add selects MFD_SYSCON as the driver needs it (Thank you, Tobias!) - cleanup included headers in both *.c and .h files - use BIT(x) macro instead of (1 << x) - replaced HOST and DEV with PHY0 and PHY1 in phy-exynos4212-usb2.c, the registers are described as PHYx in the documentation hence the decision to leave the PHYx naming - fixed typo in exynos4210_rate_to_clk reg -> *reg - change hax_mode_switch and enabled type to bool 4) usb: ehci-s5p: Change to use phy provided by the generic ph
[PATCH v9 2/4] phy: core: Add devm_of_phy_get to phy-core
Adding devm_of_phy_get will allow to get phys by supplying a pointer to the struct device_node instead of struct device. Signed-off-by: Kamil Debski --- drivers/phy/phy-core.c | 31 +++ include/linux/phy/phy.h |8 2 files changed, 39 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 7c1b0e1..623b71c 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -526,6 +526,37 @@ struct phy *devm_phy_optional_get(struct device *dev, const char *string) EXPORT_SYMBOL_GPL(devm_phy_optional_get); /** + * devm_of_phy_get() - lookup and obtain a reference to a phy. + * @dev: device that requests this phy + * @np: node containing the phy + * @con_id: name of the phy from device's point of view + * + * Gets the phy using of_phy_get(), and associates a device with it using + * devres. On driver detach, release function is invoked on the devres data, + * then, devres data is freed. + */ +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + struct phy **ptr, *phy; + + ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + phy = of_phy_get(np, con_id); + if (!IS_ERR(phy)) { + *ptr = phy; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return phy; +} +EXPORT_SYMBOL_GPL(devm_of_phy_get); + +/** * phy_create() - create a new phy * @dev: device that is creating the new phy * @ops: function pointers for performing phy operations diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 2fe3194..bcbf96c 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -149,6 +149,8 @@ struct phy *phy_get(struct device *dev, const char *string); struct phy *phy_optional_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); struct phy *of_phy_get(struct device_node *np, const char *con_id); @@ -252,6 +254,12 @@ static inline struct phy *devm_phy_optional_get(struct device *dev, return ERR_PTR(-ENOSYS); } +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline void phy_put(struct phy *phy) { } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v9 1/4] phy: core: Add an exported of_phy_get function
Previously the of_phy_get function took a struct device * and was declared static. It was impossible to call it from another driver and thus it was impossible to get phy defined for a given node. The old function was renamed to _of_phy_get and was left for internal use. of_phy_get function was added and it was exported. The function enables to get a phy for a given device tree node. Signed-off-by: Kamil Debski --- drivers/phy/phy-core.c | 45 - include/linux/phy/phy.h |6 ++ 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 6c73837..7c1b0e1 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -274,8 +274,8 @@ int phy_power_off(struct phy *phy) EXPORT_SYMBOL_GPL(phy_power_off); /** - * of_phy_get() - lookup and obtain a reference to a phy by phandle - * @dev: device that requests this phy + * _of_phy_get() - lookup and obtain a reference to a phy by phandle + * @np: device_node for which to get the phy * @index: the index of the phy * * Returns the phy associated with the given phandle value, @@ -284,20 +284,17 @@ EXPORT_SYMBOL_GPL(phy_power_off); * not yet loaded. This function uses of_xlate call back function provided * while registering the phy_provider to find the phy instance. */ -static struct phy *of_phy_get(struct device *dev, int index) +static struct phy *_of_phy_get(struct device_node *np, int index) { int ret; struct phy_provider *phy_provider; struct phy *phy = NULL; struct of_phandle_args args; - ret = of_parse_phandle_with_args(dev->of_node, "phys", "#phy-cells", + ret = of_parse_phandle_with_args(np, "phys", "#phy-cells", index, &args); - if (ret) { - dev_dbg(dev, "failed to get phy in %s node\n", - dev->of_node->full_name); + if (ret) return ERR_PTR(-ENODEV); - } mutex_lock(&phy_provider_mutex); phy_provider = of_phy_provider_lookup(args.np); @@ -317,6 +314,36 @@ err0: } /** + * of_phy_get() - lookup and obtain a reference to a phy using a device_node. + * @np: device_node for which to get the phy + * @con_id: name of the phy from device's point of view + * + * Returns the phy driver, after getting a refcount to it; or + * -ENODEV if there is no such phy. The caller is responsible for + * calling phy_put() to release that count. + */ +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + struct phy *phy = NULL; + int index = 0; + + if (con_id) + index = of_property_match_string(np, "phy-names", con_id); + + phy = _of_phy_get(np, index); + if (IS_ERR(phy)) + return phy; + + if (!try_module_get(phy->ops->owner)) + return ERR_PTR(-EPROBE_DEFER); + + get_device(&phy->dev); + + return phy; +} +EXPORT_SYMBOL_GPL(of_phy_get); + +/** * phy_put() - release the PHY * @phy: the phy returned by phy_get() * @@ -407,7 +434,7 @@ struct phy *phy_get(struct device *dev, const char *string) if (dev->of_node) { index = of_property_match_string(dev->of_node, "phy-names", string); - phy = of_phy_get(dev, index); + phy = _of_phy_get(dev->of_node, index); } else { phy = phy_lookup(dev, string); } diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 3f83459..2fe3194 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -151,6 +151,7 @@ struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); +struct phy *of_phy_get(struct device_node *np, const char *con_id); struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args); struct phy *phy_create(struct device *dev, const struct phy_ops *ops, @@ -259,6 +260,11 @@ static inline void devm_phy_put(struct device *dev, struct phy *phy) { } +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args) { -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v9 4/4] phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver
Add support for Exynos 5250. This driver is to replace the old USB 2.0 PHY driver. Signed-off-by: Kamil Debski --- .../devicetree/bindings/phy/samsung-phy.txt|1 + drivers/phy/Kconfig| 11 + drivers/phy/Makefile |1 + drivers/phy/phy-exynos5250-usb2.c | 404 drivers/phy/phy-samsung-usb2.c |6 + drivers/phy/phy-samsung-usb2.h |1 + 6 files changed, 424 insertions(+) create mode 100644 drivers/phy/phy-exynos5250-usb2.c diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index bf955ab..28f9edb 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -28,6 +28,7 @@ Required properties: - compatible : should be one of the listed compatibles: - "samsung,exynos4210-usb2-phy" - "samsung,exynos4x12-usb2-phy" + - "samsung,exynos5250-usb2-phy" - reg : a list of registers used by phy driver - first and obligatory is the location of phy modules registers - samsung,sysreg-phandle - handle to syscon used to control the system registers diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index fc5a44a..c206e25 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -125,4 +125,15 @@ config PHY_EXYNOS4X12_USB2 Samsung USB 2.0 PHY driver is enabled and means that support for this particular SoC is compiled in the driver. In case of Exynos 4x12 four phys are available - device, host, HSIC0 and HSIC1. + +config PHY_EXYNOS5250_USB2 + bool "Support for Exynos 5250" + depends on PHY_SAMSUNG_USB2 + depends on SOC_EXYNOS5250 + help + Enable USB PHY support for Exynos 5250. This option requires that + Samsung USB 2.0 PHY driver is enabled and means that support for this + particular SoC is compiled in the driver. In case of Exynos 5250 four + phys are available - device, host, HSIC0 and HSIC. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 0ea36ff..f76c239 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -14,3 +14,4 @@ obj-$(CONFIG_PHY_SUN4I_USB) += phy-sun4i-usb.o obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o obj-$(CONFIG_PHY_EXYNOS4210_USB2) += phy-exynos4210-usb2.o obj-$(CONFIG_PHY_EXYNOS4X12_USB2) += phy-exynos4x12-usb2.o +obj-$(CONFIG_PHY_EXYNOS5250_USB2) += phy-exynos5250-usb2.o diff --git a/drivers/phy/phy-exynos5250-usb2.c b/drivers/phy/phy-exynos5250-usb2.c new file mode 100644 index 000..94179af --- /dev/null +++ b/drivers/phy/phy-exynos5250-usb2.c @@ -0,0 +1,404 @@ +/* + * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 5250 support + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Kamil Debski + * + * 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 +#include +#include +#include +#include "phy-samsung-usb2.h" + +/* Exynos USB PHY registers */ +#define EXYNOS_5250_REFCLKSEL_CRYSTAL 0x0 +#define EXYNOS_5250_REFCLKSEL_XO 0x1 +#define EXYNOS_5250_REFCLKSEL_CLKCORE 0x2 + +#define EXYNOS_5250_FSEL_9MHZ6 0x0 +#define EXYNOS_5250_FSEL_10MHZ 0x1 +#define EXYNOS_5250_FSEL_12MHZ 0x2 +#define EXYNOS_5250_FSEL_19MHZ20x3 +#define EXYNOS_5250_FSEL_20MHZ 0x4 +#define EXYNOS_5250_FSEL_24MHZ 0x5 +#define EXYNOS_5250_FSEL_50MHZ 0x7 + +/* Normal host */ +#define EXYNOS_5250_HOSTPHYCTRL0 0x0 + +#define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRSTALL BIT(31) +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT 19 +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_MASK\ + (0x3 << EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT16 +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_MASK \ + (0x7 << EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_TESTBURNINBIT(11) +#define EXYNOS_5250_HOSTPHYCTRL0_RETENABLE BIT(10) +#define EXYNOS_5250_HOSTPHYCTRL0_COMMON_ON_N BIT(9) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_MASK(0x3 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_DUAL(0x0 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ID0 (0x1 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ANALOGTEST (0x2 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_SIDDQ BIT(6) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESLEEPBIT(5) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESUSPEND
RE: [PATCH v9 0/4] phy: Add new Exynos USB 2.0 PHY driver
Hi Tobias, > From: Tobias Jakobi [mailto:tjak...@math.uni-bielefeld.de] > Sent: Thursday, March 06, 2014 12:08 AM > > Hello Kamil, > > this looks very good. I just tested the patchset on my ODROID-X2 > (Exynos4412-based board) and the USB stability issues I mentioned to > you before (with the older patchset) seem to be gone. This problem was related to the reset procedure not being done completely. It is corrected now. > > All devices on the USB behave normally (mass storage, ethernet and > bluetooth). Thank you for testing these patches. Would you consider adding a "Tested-by" tag? I am planning to send v10 soon, which will address comments to v9. > > With best wishes, > Tobias Best wishes, -- Kamil Debski Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH v9 3/4] phy: Add new Exynos USB 2.0 PHY driver
Hi Anton, Kishon, > From: Anton Tikhomirov [mailto:av.tikhomi...@samsung.com] > Sent: Thursday, March 06, 2014 9:26 AM > > Hi Kamil, > > ... > > > +| 3. Supporting SoCs > > ++ > > + > > +To support a new SoC a new file should be added to the drivers/phy > > +directory. Each SoC's configuration is stored in an instance of the > > +struct samsung_usb2_phy_config. > > + > > +struct samsung_usb2_phy_config { > > + const struct samsung_usb2_common_phy *phys; > > + unsigned int num_phys; > > + bool has_mode_switch; > > You missed rate_to_clk here. Thank you for spotting this. Kishon: I am sorry that this omission was made. I am happy to send an updated patchset. However, I want to give some time for any additional comments. Do you think that we have for this? Is today evening ok with you? > > > +}; > > + > > ... > > > diff --git a/drivers/phy/phy-samsung-usb2.c b/drivers/phy/phy- > samsung- > > usb2.c new file mode 100644 index 000..c3b7719 > > --- /dev/null > > +++ b/drivers/phy/phy-samsung-usb2.c > > @@ -0,0 +1,222 @@ > > +/* > > + * Samsung SoC USB 1.1/2.0 PHY driver > > + * > > + * Copyright (C) 2013 Samsung Electronics Co., Ltd. > > + * Author: Kamil Debski > > + * > > + * 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 > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include "phy-samsung-usb2.h" > > + > > +static int samsung_usb2_phy_power_on(struct phy *phy) { > > + struct samsung_usb2_phy_instance *inst = phy_get_drvdata(phy); > > + struct samsung_usb2_phy_driver *drv = inst->drv; > > + int ret; > > + > > + dev_dbg(drv->dev, "Request to power_on \"%s\" usb phy\n", > > + inst->cfg->label); > > + ret = clk_prepare_enable(drv->clk); > > clk_prepare_enable() can sleep, and therefore doesn't allow > samusng_usb2_phy_power_on() to be used in atomic context (e.g. inside > spin_lock-ed area), what sometimes may be desirable. > What about to prepare clock in probe, and just enable it here > (note: clk_enable() doesn't sleep). >From the onward discussion between you and Kishon, I draw the conclusion that this change is not necessary. Right? > > > + if (ret) > > + goto err_main_clk; > > + ret = clk_prepare_enable(drv->ref_clk); > > + if (ret) > > + goto err_instance_clk; > > + if (inst->cfg->power_on) { > > + spin_lock(&drv->lock); > > + ret = inst->cfg->power_on(inst); > > + spin_unlock(&drv->lock); > > + } > > + > > + return 0; > > Thank you Best wishes, -- Kamil Debski Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v10 0/4] phy: Add new Exynos USB 2.0 PHY driver
Hi, This is the tenth version of this patchset. The only difference since v9 is correction in the documentation. Best wishes, Kamil Debski -- Changes from v9: 1) phy: core: Add an exported of_phy_get function - No changes since v9. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v9. 3) phy: Add new Exynos USB 2.0 PHY driver - Fixed missing callback in the documentation of the samsung_usb2_phy_config structure. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - No changes since v9. -- Changes from v8: 1) phy: core: Add an exported of_phy_get function - No changes since v8. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v8. 3) phy: Add new Exynos USB 2.0 PHY driver - Fix empty blank line at EOF errors 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Fix empty blank line at EOF error -- Changes from v7: 1) phy: core: Add an exported of_phy_get function - No changes since v7. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v7. 3) phy: Add new Exynos USB 2.0 PHY driver - Fix checkpatch errors with code indentation and corrected whitespace. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Fix checkpatch errors with code indentation and corrected whitespace. -- Changes from v6: (not including the change that controller patches were removed form this patchset, also this patchset excludes S5PV210 support - it needs more testing) 1) phy: core: Add an exported of_phy_get function - No changes since v6. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v6. 3) phy: Add new Exynos USB 2.0 PHY driver - Changed the way clocks are supplied to the driver. Prior to version v7 there were reference clocks for every phy instance, now a single "ref" clock was introduced. - Updated documentation to match the aforementioned change. - Add offset EXYNOS_*_UPHYCLK_PHYFSEL_OFFSET to the clock register content defines. - Corrected way clock register is modified. Instead of a simple write, a proper read, modify, write sequence was introduced. - Important stability fix - added udelay after PHY reset. This fixes a bug causing instability in USB LAN adapters. Without the delay the DMA burst mode was could not be enabled. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Changed handling of clocks to use a single "ref" clock. Changes from v5: 1) phy: core: Add an exported of_phy_get function - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the of_phy_get function 2) phy: core: Add devm_of_phy_get to phy-core - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the devm_of_phy_get function 3) dts: Add usb2phy to Exynos 4 - no change 4) dts: Add usb2phy to Exynos 5250 - in the previous version, this patch included some phy-exynos5250-usb2.c code by mistake, the code has been remove and added to the proper patch 5) phy: Add new Exynos USB PHY driver - changed strings from Exynos 4212 to Exynos 4x12, as the Exynos 4212 driver is actually a driver for the whole Exynos 4x12 family - added documentation to the Exynos USB 2.0 PHY driver adaptaion layer - corrected strings HSCI -> HSIC - fixed a problem introduced by previous change - on Exynos 4x12 the HSIC did not work on its own - mode switch support was added to Exynos 4x12 (same io pins are used by host and device) - support for phy_set_bus_width introduced by Matt Porter was added 6) phy: Add support for S5PV210 to the Exynos USB PHY - setting of clk register was fixed 7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - supoprt was added for HSIC and device 8) usb: ehci-exynos: Change to use phy provided by the generic phy framework - DT documentation was moved from usb-ehci.txt to exynos-usb.txt Changes from v4: 1) phy: core: Add an exported of_phy_get function - the new exported function of_phy_get was changed to take the phy's name as a parameter instead of the index 2) phy: core: Add devm_of_phy_get to phy-core - fixes made in the comments to devm_of_phy_get 3) phy: Add new Exynos USB PHY driver - move the documentation from a new to an existing file - samsung-phy.txt - fix typos and uppercase hex addresses - add more explanations to Kconfig (checkpatch still complains, but I find it hard to think what else could I add) - add selects MFD_SYSCON as the driver needs it (Thank you, Tobias!) - cleanup included headers in both *.c and .h files - use BIT(x) macro instead of (1 << x) - replaced HOST and DEV with PHY0 and PHY1 in phy-exynos4212-usb2.c, the registers are described as PHYx in the documentation hence the decision to leave the PHYx naming - fixed typo in exynos4210_rate_to_clk reg -> *reg - change hax_mode_switch and enabled type to bool 4) usb: eh
[PATCH v10 1/4] phy: core: Add an exported of_phy_get function
Previously the of_phy_get function took a struct device * and was declared static. It was impossible to call it from another driver and thus it was impossible to get phy defined for a given node. The old function was renamed to _of_phy_get and was left for internal use. of_phy_get function was added and it was exported. The function enables to get a phy for a given device tree node. Signed-off-by: Kamil Debski --- drivers/phy/phy-core.c | 45 - include/linux/phy/phy.h |6 ++ 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 6c73837..7c1b0e1 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -274,8 +274,8 @@ int phy_power_off(struct phy *phy) EXPORT_SYMBOL_GPL(phy_power_off); /** - * of_phy_get() - lookup and obtain a reference to a phy by phandle - * @dev: device that requests this phy + * _of_phy_get() - lookup and obtain a reference to a phy by phandle + * @np: device_node for which to get the phy * @index: the index of the phy * * Returns the phy associated with the given phandle value, @@ -284,20 +284,17 @@ EXPORT_SYMBOL_GPL(phy_power_off); * not yet loaded. This function uses of_xlate call back function provided * while registering the phy_provider to find the phy instance. */ -static struct phy *of_phy_get(struct device *dev, int index) +static struct phy *_of_phy_get(struct device_node *np, int index) { int ret; struct phy_provider *phy_provider; struct phy *phy = NULL; struct of_phandle_args args; - ret = of_parse_phandle_with_args(dev->of_node, "phys", "#phy-cells", + ret = of_parse_phandle_with_args(np, "phys", "#phy-cells", index, &args); - if (ret) { - dev_dbg(dev, "failed to get phy in %s node\n", - dev->of_node->full_name); + if (ret) return ERR_PTR(-ENODEV); - } mutex_lock(&phy_provider_mutex); phy_provider = of_phy_provider_lookup(args.np); @@ -317,6 +314,36 @@ err0: } /** + * of_phy_get() - lookup and obtain a reference to a phy using a device_node. + * @np: device_node for which to get the phy + * @con_id: name of the phy from device's point of view + * + * Returns the phy driver, after getting a refcount to it; or + * -ENODEV if there is no such phy. The caller is responsible for + * calling phy_put() to release that count. + */ +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + struct phy *phy = NULL; + int index = 0; + + if (con_id) + index = of_property_match_string(np, "phy-names", con_id); + + phy = _of_phy_get(np, index); + if (IS_ERR(phy)) + return phy; + + if (!try_module_get(phy->ops->owner)) + return ERR_PTR(-EPROBE_DEFER); + + get_device(&phy->dev); + + return phy; +} +EXPORT_SYMBOL_GPL(of_phy_get); + +/** * phy_put() - release the PHY * @phy: the phy returned by phy_get() * @@ -407,7 +434,7 @@ struct phy *phy_get(struct device *dev, const char *string) if (dev->of_node) { index = of_property_match_string(dev->of_node, "phy-names", string); - phy = of_phy_get(dev, index); + phy = _of_phy_get(dev->of_node, index); } else { phy = phy_lookup(dev, string); } diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 3f83459..2fe3194 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -151,6 +151,7 @@ struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); +struct phy *of_phy_get(struct device_node *np, const char *con_id); struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args); struct phy *phy_create(struct device *dev, const struct phy_ops *ops, @@ -259,6 +260,11 @@ static inline void devm_phy_put(struct device *dev, struct phy *phy) { } +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args) { -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v10 4/4] phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver
Add support for Exynos 5250. This driver is to replace the old USB 2.0 PHY driver. Signed-off-by: Kamil Debski --- .../devicetree/bindings/phy/samsung-phy.txt|1 + drivers/phy/Kconfig| 11 + drivers/phy/Makefile |1 + drivers/phy/phy-exynos5250-usb2.c | 404 drivers/phy/phy-samsung-usb2.c |6 + drivers/phy/phy-samsung-usb2.h |1 + 6 files changed, 424 insertions(+) create mode 100644 drivers/phy/phy-exynos5250-usb2.c diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index bf955ab..28f9edb 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -28,6 +28,7 @@ Required properties: - compatible : should be one of the listed compatibles: - "samsung,exynos4210-usb2-phy" - "samsung,exynos4x12-usb2-phy" + - "samsung,exynos5250-usb2-phy" - reg : a list of registers used by phy driver - first and obligatory is the location of phy modules registers - samsung,sysreg-phandle - handle to syscon used to control the system registers diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 3374836..1b607d7 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -136,4 +136,15 @@ config PHY_EXYNOS4X12_USB2 Samsung USB 2.0 PHY driver is enabled and means that support for this particular SoC is compiled in the driver. In case of Exynos 4x12 four phys are available - device, host, HSIC0 and HSIC1. + +config PHY_EXYNOS5250_USB2 + bool "Support for Exynos 5250" + depends on PHY_SAMSUNG_USB2 + depends on SOC_EXYNOS5250 + help + Enable USB PHY support for Exynos 5250. This option requires that + Samsung USB 2.0 PHY driver is enabled and means that support for this + particular SoC is compiled in the driver. In case of Exynos 5250 four + phys are available - device, host, HSIC0 and HSIC. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index c4ddd23..ecf0d3f 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -15,3 +15,4 @@ obj-$(CONFIG_PHY_SUN4I_USB) += phy-sun4i-usb.o obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o obj-$(CONFIG_PHY_EXYNOS4210_USB2) += phy-exynos4210-usb2.o obj-$(CONFIG_PHY_EXYNOS4X12_USB2) += phy-exynos4x12-usb2.o +obj-$(CONFIG_PHY_EXYNOS5250_USB2) += phy-exynos5250-usb2.o diff --git a/drivers/phy/phy-exynos5250-usb2.c b/drivers/phy/phy-exynos5250-usb2.c new file mode 100644 index 000..94179af --- /dev/null +++ b/drivers/phy/phy-exynos5250-usb2.c @@ -0,0 +1,404 @@ +/* + * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 5250 support + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Kamil Debski + * + * 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 +#include +#include +#include +#include "phy-samsung-usb2.h" + +/* Exynos USB PHY registers */ +#define EXYNOS_5250_REFCLKSEL_CRYSTAL 0x0 +#define EXYNOS_5250_REFCLKSEL_XO 0x1 +#define EXYNOS_5250_REFCLKSEL_CLKCORE 0x2 + +#define EXYNOS_5250_FSEL_9MHZ6 0x0 +#define EXYNOS_5250_FSEL_10MHZ 0x1 +#define EXYNOS_5250_FSEL_12MHZ 0x2 +#define EXYNOS_5250_FSEL_19MHZ20x3 +#define EXYNOS_5250_FSEL_20MHZ 0x4 +#define EXYNOS_5250_FSEL_24MHZ 0x5 +#define EXYNOS_5250_FSEL_50MHZ 0x7 + +/* Normal host */ +#define EXYNOS_5250_HOSTPHYCTRL0 0x0 + +#define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRSTALL BIT(31) +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT 19 +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_MASK\ + (0x3 << EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT16 +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_MASK \ + (0x7 << EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_TESTBURNINBIT(11) +#define EXYNOS_5250_HOSTPHYCTRL0_RETENABLE BIT(10) +#define EXYNOS_5250_HOSTPHYCTRL0_COMMON_ON_N BIT(9) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_MASK(0x3 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_DUAL(0x0 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ID0 (0x1 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ANALOGTEST (0x2 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_SIDDQ BIT(6) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESLEEPBIT(5) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESUSPEND
[PATCH v10 2/4] phy: core: Add devm_of_phy_get to phy-core
Adding devm_of_phy_get will allow to get phys by supplying a pointer to the struct device_node instead of struct device. Signed-off-by: Kamil Debski --- drivers/phy/phy-core.c | 31 +++ include/linux/phy/phy.h |8 2 files changed, 39 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 7c1b0e1..623b71c 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -526,6 +526,37 @@ struct phy *devm_phy_optional_get(struct device *dev, const char *string) EXPORT_SYMBOL_GPL(devm_phy_optional_get); /** + * devm_of_phy_get() - lookup and obtain a reference to a phy. + * @dev: device that requests this phy + * @np: node containing the phy + * @con_id: name of the phy from device's point of view + * + * Gets the phy using of_phy_get(), and associates a device with it using + * devres. On driver detach, release function is invoked on the devres data, + * then, devres data is freed. + */ +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + struct phy **ptr, *phy; + + ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + phy = of_phy_get(np, con_id); + if (!IS_ERR(phy)) { + *ptr = phy; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return phy; +} +EXPORT_SYMBOL_GPL(devm_of_phy_get); + +/** * phy_create() - create a new phy * @dev: device that is creating the new phy * @ops: function pointers for performing phy operations diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 2fe3194..bcbf96c 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -149,6 +149,8 @@ struct phy *phy_get(struct device *dev, const char *string); struct phy *phy_optional_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); struct phy *of_phy_get(struct device_node *np, const char *con_id); @@ -252,6 +254,12 @@ static inline struct phy *devm_phy_optional_get(struct device *dev, return ERR_PTR(-ENOSYS); } +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline void phy_put(struct phy *phy) { } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v10 3/4] phy: Add new Exynos USB 2.0 PHY driver
Add a new driver for the Exynos USB 2.0 PHY. The new driver uses the generic PHY framework. The driver includes support for the Exynos 4x10 and 4x12 SoC families. Signed-off-by: Kamil Debski --- .../devicetree/bindings/phy/samsung-phy.txt| 53 Documentation/phy/samsung-usb2.txt | 135 drivers/phy/Kconfig| 29 ++ drivers/phy/Makefile |3 + drivers/phy/phy-exynos4210-usb2.c | 261 drivers/phy/phy-exynos4x12-usb2.c | 328 drivers/phy/phy-samsung-usb2.c | 222 + drivers/phy/phy-samsung-usb2.h | 66 8 files changed, 1097 insertions(+) create mode 100644 Documentation/phy/samsung-usb2.txt create mode 100644 drivers/phy/phy-exynos4210-usb2.c create mode 100644 drivers/phy/phy-exynos4x12-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.h diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index c0fccaa..bf955ab 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -20,3 +20,56 @@ Required properties: - compatible : should be "samsung,exynos5250-dp-video-phy"; - reg : offset and length of the Display Port PHY register set; - #phy-cells : from the generic PHY bindings, must be 0; + +Samsung S5P/EXYNOS SoC series USB PHY +- + +Required properties: +- compatible : should be one of the listed compatibles: + - "samsung,exynos4210-usb2-phy" + - "samsung,exynos4x12-usb2-phy" +- reg : a list of registers used by phy driver + - first and obligatory is the location of phy modules registers +- samsung,sysreg-phandle - handle to syscon used to control the system registers +- samsung,pmureg-phandle - handle to syscon used to control PMU registers +- #phy-cells : from the generic phy bindings, must be 1; +- clocks and clock-names: + - the "phy" clock is required by the phy module, used as a gate + - the "ref" clock is used to get the rate of the clock provided to the + PHY module + +The first phandle argument in the PHY specifier identifies the PHY, its +meaning is compatible dependent. For the currently supported SoCs (Exynos 4210 +and Exynos 4212) it is as follows: + 0 - USB device ("device"), + 1 - USB host ("host"), + 2 - HSIC0 ("hsic0"), + 3 - HSIC1 ("hsic1"), + +Exynos 4210 and Exynos 4212 use mode switching and require that mode switch +register is supplied. + +Example: + +For Exynos 4412 (compatible with Exynos 4212): + +usbphy: phy@125b { + compatible = "samsung,exynos4x12-usb2-phy"; + reg = <0x125b 0x100>; + clocks = <&clock 305>, <&clock 2>; + clock-names = "phy", "ref"; + status = "okay"; + #phy-cells = <1>; + samsung,sysreg-phandle = <&sys_reg>; + samsung,pmureg-phandle = <&pmu_reg>; +}; + +Then the PHY can be used in other nodes such as: + +phy-consumer@1234 { + phys = <&usbphy 2>; + phy-names = "phy"; +}; + +Refer to DT bindings documentation of particular PHY consumer devices for more +information about required PHYs and the way of specification. diff --git a/Documentation/phy/samsung-usb2.txt b/Documentation/phy/samsung-usb2.txt new file mode 100644 index 000..ed12d43 --- /dev/null +++ b/Documentation/phy/samsung-usb2.txt @@ -0,0 +1,135 @@ +.--+ +| Samsung USB 2.0 PHY adaptation layer | ++-+' + +| 1. Description ++ + +The architecture of the USB 2.0 PHY module in Samsung SoCs is similar +among many SoCs. In spite of the similarities it proved difficult to +create a one driver that would fit all these PHY controllers. Often +the differences were minor and were found in particular bits of the +registers of the PHY. In some rare cases the order of register writes or +the PHY powering up process had to be altered. This adaptation layer is +a compromise between having separate drivers and having a single driver +with added support for many special cases. + +| 2. Files description ++-- + +- phy-samsung-usb2.c + This is the main file of the adaptation layer. This file contains + the probe function and provides two callbacks to the Generic PHY + Framework. This two callbacks are used to power on and power off the + phy. They carry out the common work that has to be d
RE: [PATCH v6 5/8] phy: Add new Exynos USB PHY driver
Hi Kishon, > From: Kishon Vijay Abraham I [mailto:kis...@ti.com] > Sent: Monday, March 03, 2014 3:28 PM > > Hi, > > On Wednesday 29 January 2014 10:59 PM, Kamil Debski wrote: > > Add a new driver for the Exynos USB PHY. The new driver uses the > > generic PHY framework. The driver includes support for the Exynos > 4x10 > > and 4x12 SoC families. > > Can the PHY part of this series be merged independently of the > controller part? I see no problems with merging the PHY part independently. However, I would like to post an updated version of these patches. I am working on them now and should send them tomorrow. Best wishes, -- Kamil Debski Samsung R&D Institute Poland > > > > Signed-off-by: Kamil Debski > > --- > > .../devicetree/bindings/phy/samsung-phy.txt| 55 > > Documentation/phy/samsung-usb2.txt | 135 > > drivers/phy/Kconfig| 29 ++ > > drivers/phy/Makefile |3 + > > drivers/phy/phy-exynos4210-usb2.c | 257 > > > drivers/phy/phy-exynos4x12-usb2.c | 323 > > > drivers/phy/phy-samsung-usb2.c | 227 > ++ > > drivers/phy/phy-samsung-usb2.h | 67 > > 8 files changed, 1096 insertions(+) > > create mode 100644 Documentation/phy/samsung-usb2.txt > > create mode 100644 drivers/phy/phy-exynos4210-usb2.c > > create mode 100644 drivers/phy/phy-exynos4x12-usb2.c > > create mode 100644 drivers/phy/phy-samsung-usb2.c > > create mode 100644 drivers/phy/phy-samsung-usb2.h > > > > diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt > > b/Documentation/devicetree/bindings/phy/samsung-phy.txt > > index c0fccaa..6668c41 100644 > > --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt > > +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt > > @@ -20,3 +20,58 @@ Required properties: > > - compatible : should be "samsung,exynos5250-dp-video-phy"; > > - reg : offset and length of the Display Port PHY register set; > > - #phy-cells : from the generic PHY bindings, must be 0; > > + > > +Samsung S5P/EXYNOS SoC series USB PHY > > +- > > + > > +Required properties: > > +- compatible : should be one of the listed compatibles: > > + - "samsung,exynos4210-usb2-phy" > > + - "samsung,exynos4x12-usb2-phy" > > +- reg : a list of registers used by phy driver > > + - first and obligatory is the location of phy modules registers > > +- samsung,sysreg-phandle - handle to syscon used to control the > > +system registers > > +- samsung,pmureg-phandle - handle to syscon used to control PMU > > +registers > > +- #phy-cells : from the generic phy bindings, must be 1; > > +- clocks and clock-names: > > + - the "phy" clocks is required by the phy module > > + - next for each of the phys a clock has to be assigned, this > clock > > + will be used to determine clocking frequency for the phys > > + (the labels are specified in the paragraph below) > > + > > +The first phandle argument in the PHY specifier identifies the PHY, > > +its meaning is compatible dependent. For the currently supported > SoCs > > +(Exynos 4210 and Exynos 4212) it is as follows: > > + 0 - USB device ("device"), > > + 1 - USB host ("host"), > > + 2 - HSIC0 ("hsic0"), > > + 3 - HSIC1 ("hsic1"), > > + > > +Exynos 4210 and Exynos 4212 use mode switching and require that mode > > +switch register is supplied. > > + > > +Example: > > + > > +For Exynos 4412 (compatible with Exynos 4212): > > + > > +usbphy: phy@125b { > > + compatible = "samsung,exynos4212-usb2-phy"; > > + reg = <0x125b 0x100 0x10020704 0x0c 0x1001021c 0x4>; > > + clocks = <&clock 305>, <&clock 2>, <&clock 2>, <&clock 2>, > > + <&clock 2>; > > + clock-names = "phy", "device", "host", "hsic0", "hsic1"; > > + status = "okay"; > > + #phy-cells = <1>; > > + samsung,sysreg-phandle = <&sys_reg>; > > + samsung,pmureg-phandle = <&pmu_reg>; }; > > + > > +Then the PHY can be used in other nodes such as: > > + >
RE: [PATCH] [media] s5p-mfc: Add Horizontal and Vertical search range for Video Macro Blocks
s/media/platform/s5p-mfc/s5p_mfc_opr_v6.c > +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c > @@ -727,14 +727,10 @@ static int s5p_mfc_set_enc_params(struct > s5p_mfc_ctx *ctx) > WRITEL(reg, S5P_FIMV_E_RC_CONFIG_V6); > > /* setting for MV range [16, 256] */ > - reg = 0; > - reg &= ~(0x3FFF); > - reg = 256; > + reg = (p->horz_range & 0x3fff); /* conditional check in app */ > WRITEL(reg, S5P_FIMV_E_MV_HOR_RANGE_V6); Please add a S5P_FIMV_E_MV_HOR_RANGE_V6_MASK or something instead of this magic number. > > - reg = 0; > - reg &= ~(0x3FFF); > - reg = 256; > + reg = (p->vert_range & 0x3fff); /* conditional check in app */ Please add a S5P_FIMV_E_MV_VER_RANGE_V6_MASK or something instead of this magic number. > WRITEL(reg, S5P_FIMV_E_MV_VER_RANGE_V6); > > WRITEL(0x0, S5P_FIMV_E_FRAME_INSERTION_V6); > diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2- > core/v4l2-ctrls.c > index fb46790..7cf23d5 100644 > --- a/drivers/media/v4l2-core/v4l2-ctrls.c > +++ b/drivers/media/v4l2-core/v4l2-ctrls.c > @@ -735,6 +735,8 @@ const char *v4l2_ctrl_get_name(u32 id) > case V4L2_CID_MPEG_VIDEO_DEC_PTS: return "Video > Decoder PTS"; > case V4L2_CID_MPEG_VIDEO_DEC_FRAME: return "Video > Decoder Frame Count"; > case V4L2_CID_MPEG_VIDEO_VBV_DELAY: return "Initial > Delay for VBV Control"; > + case V4L2_CID_MPEG_VIDEO_HORZ_SEARCH_RANGE: return "hor > search range of video MB"; This should be property capitalised. Please mention the motion vectors too. > + case V4L2_CID_MPEG_VIDEO_VERT_SEARCH_RANGE: return "vert > search range of video MB"; This too should be property capitalised. Please mention the motion vectors too. > case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER: return > "Repeat Sequence Header"; > > /* VPX controls */ > @@ -905,6 +907,18 @@ void v4l2_ctrl_fill(u32 id, const char **name, > enum v4l2_ctrl_type *type, > *min = 0; > *max = *step = 1; > break; > + case V4L2_CID_MPEG_VIDEO_HORZ_SEARCH_RANGE: > + *type = V4L2_CTRL_TYPE_INTEGER; > + *min = 16; > + *max = 128; > + *step = 16; > + break; > + case V4L2_CID_MPEG_VIDEO_VERT_SEARCH_RANGE: > + *type = V4L2_CTRL_TYPE_INTEGER; > + *min = 16; > + *max = 128; > + *step = 16; > + break; > case V4L2_CID_PAN_RESET: > case V4L2_CID_TILT_RESET: > case V4L2_CID_FLASH_STROBE: > diff --git a/include/uapi/linux/v4l2-controls.h > b/include/uapi/linux/v4l2-controls.h > index 1666aab..bcce536 100644 > --- a/include/uapi/linux/v4l2-controls.h > +++ b/include/uapi/linux/v4l2-controls.h > @@ -372,6 +372,8 @@ enum v4l2_mpeg_video_multi_slice_mode { > #define V4L2_CID_MPEG_VIDEO_DEC_FRAME > (V4L2_CID_MPEG_BASE+224) > #define V4L2_CID_MPEG_VIDEO_VBV_DELAY > (V4L2_CID_MPEG_BASE+225) > #define V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER > (V4L2_CID_MPEG_BASE+226) > +#define V4L2_CID_MPEG_VIDEO_HORZ_SEARCH_RANGE > (V4L2_CID_MPEG_BASE+227) > +#define V4L2_CID_MPEG_VIDEO_VERT_SEARCH_RANGE > (V4L2_CID_MPEG_BASE+228) > > #define V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP > (V4L2_CID_MPEG_BASE+300) > #define V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP > (V4L2_CID_MPEG_BASE+301) > -- > 1.7.9.5 Best wishes, -- Kamil Debski Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH RFC alternative ver 1] phy: Exynos 421x USB 2.0 PHY support
Hi Kishon, Thank you for your review. > From: Kishon Vijay Abraham I [mailto:kis...@ti.com] > Sent: Monday, January 06, 2014 11:24 AM > > Hi, > > On Friday 20 December 2013 06:54 PM, Kamil Debski wrote: > > This the alternative version of the support for Exynos 421x USB 2.0 > > PHY in the Generic PHY framework. In this version the support for > > Exynos > > 4210 and 4212 was joined into one file. > > > > Signed-off-by: Kamil Debski > > --- > > Hi, > > > > Me and Kishon were discussing for quite a long time the way how > Exynos > > 4 should be handled. I have decided to post the original patches and > > try to make an alternative version with support for Exynos 4210 and > > 4212 joined in one file. I have prepared two versions. The first one > > has 506 lines (vs > > 563 when two files are used). When doing the second version I was a > > little more aggresive in removing code. This was done at a cost of > > adding if's deciding which SoC version the driver is dealing with in > some internal functions. > > This resulted in a better number of removed lines - the second > version > > has only 452 lines (vs 563 original and 506 version 1). > > Alright.. If the alternate approach doesn't give too much of advantage, > lets stick with the original one. I would recommend creating a > documentation (Documentation/phy/?) for the samsung PHY since that > actually creates a layer on top of generic PHY framework. That would > help while adding new samsung PHY drivers. Ok, I will prepare an updated set of patches with the documentation added. Also I will fix other issues you pointed out in reply to other patches from this series. > > Btw thank you for preparing alternate versions for your original > patches. No problem :) Best wishes, -- Kamil Debski Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH v5 3/9] phy: Add new Exynos USB 2.0 PHY driver
Hi, > From: Kishon Vijay Abraham I [mailto:kis...@ti.com] > Sent: Monday, January 06, 2014 11:12 AM > > Hi, > > On Friday 20 December 2013 06:54 PM, Kamil Debski wrote: > > Add a new driver for the Exynos USB 2.0 PHY. The new driver uses the > > generic PHY framework. The driver includes support for the Exynos > 4x10 > > and 4x12 SoC families. > > > > Signed-off-by: Kamil Debski > > Signed-off-by: Kyungmin Park > > --- > > .../devicetree/bindings/phy/samsung-phy.txt| 55 > > drivers/phy/Kconfig| 29 ++ > > drivers/phy/Makefile |3 + > > drivers/phy/phy-exynos4210-usb2.c | 257 > > > drivers/phy/phy-exynos4212-usb2.c | 306 > > > drivers/phy/phy-samsung-usb2.c | 226 > +++ > > drivers/phy/phy-samsung-usb2.h | 67 + > > 7 files changed, 943 insertions(+) > > create mode 100644 drivers/phy/phy-exynos4210-usb2.c > > create mode 100644 drivers/phy/phy-exynos4212-usb2.c > > create mode 100644 drivers/phy/phy-samsung-usb2.c > > create mode 100644 drivers/phy/phy-samsung-usb2.h > > > . > . > > . > . > > > diff --git a/drivers/phy/phy-samsung-usb2.h > > b/drivers/phy/phy-samsung-usb2.h new file mode 100644 index > > 000..ab89f91 > > --- /dev/null > > +++ b/drivers/phy/phy-samsung-usb2.h > > @@ -0,0 +1,67 @@ > > +/* > > + * Samsung SoC USB 1.1/2.0 PHY driver > > + * > > + * Copyright (C) 2013 Samsung Electronics Co., Ltd. > > + * Author: Kamil Debski > > + * > > + * 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. > > + */ > > + > > +#ifndef _PHY_EXYNOS_USB2_H > > +#define _PHY_EXYNOS_USB2_H > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#define KHZ 1000 > > +#define MHZ (KHZ * KHZ) > > + > > +struct samsung_usb2_phy_driver; > > +struct samsung_usb2_phy_instance; > > +struct samsung_usb2_phy_config; > > + > > +struct samsung_usb2_phy_instance { > > + const struct samsung_usb2_common_phy *cfg; > > + struct clk *clk; > > + struct phy *phy; > > + struct samsung_usb2_phy_driver *drv; > > + unsigned long rate; > > + u32 clk_reg_val; > > + bool enabled; > > +}; > > + > > +struct samsung_usb2_phy_driver { > > + const struct samsung_usb2_phy_config *cfg; > > + struct clk *clk; > > + struct device *dev; > > + void __iomem *reg_phy; > > + struct regmap *reg_pmu; > > + struct regmap *reg_sys; > > + spinlock_t lock; > > + struct samsung_usb2_phy_instance instances[0]; > > I think having instances as array here would allocate more space while > allocating 'samsung_usb2_phy_driver' in 'samsung_usb2_phy_probe'. > I am not sure if I understand you correctly here. Maybe I will explain what I intended to write. An array with size 0 at the end of a structure takes no space in the structure. The benefit of using it is that after the structure one can allocate a number of the array elements and address them easily. Another option would be placing pointer in the samsung_usb2_phy_instance and allocate memory separately, but this would involve two allocations and a pointer would be always present in the structure. Best wishes, -- Kamil Debski Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH v3 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support
Hi Matt, > From: Matt Porter [mailto:matt.por...@linaro.org] > Sent: Thursday, November 28, 2013 5:42 PM > > On Thu, Nov 28, 2013 at 11:23:52AM +0530, Kishon Vijay Abraham I wrote: > > On Thursday 28 November 2013 04:06 AM, Matt Porter wrote: > > > On Wed, Nov 27, 2013 at 12:13:25PM -0500, Matt Porter wrote: > > >> On Tue, Nov 26, 2013 at 03:53:32PM +0530, Kishon Vijay Abraham I > wrote: > > >>> Hi, > > >>> > > >>> On Monday 25 November 2013 11:46 PM, Matt Porter wrote: > > >>>> If a generic phy is present, call phy_init()/phy_exit(). This > > >>>> supports generic phys that must be soft reset before power on. > > >>>> > > >>>> Signed-off-by: Matt Porter > > >>>> --- > > >>>> drivers/usb/gadget/s3c-hsotg.c | 5 + > > >>>> 1 file changed, 5 insertions(+) > > >>>> > > >>>> diff --git a/drivers/usb/gadget/s3c-hsotg.c > > >>>> b/drivers/usb/gadget/s3c-hsotg.c index da3879b..8dfe33f 100644 > > >>>> --- a/drivers/usb/gadget/s3c-hsotg.c > > >>>> +++ b/drivers/usb/gadget/s3c-hsotg.c > > >>>> @@ -3622,6 +3622,9 @@ static int s3c_hsotg_probe(struct > platform_device *pdev) > > >>>>goto err_supplies; > > >>>>} > > >>>> > > >>>> + if (hsotg->phy) > > >>> > > >>> IS_ERR? If your phy_get fails *phy* will have a error value.. > > >> > > >> Yes, thanks. I'll fix these and also note that the same issue > > >> exists in Kamil's patch for these same hsotg->phy conditional uses. > > >> I'll work with Kamil to either get those addressed there or in a > follow on fix. > > > > > > I spoke too soon. If devm_phy_get fails, we don't set hsotg->phy > and > > > probe defer thus not reaching this point. Since hsotg->phy is > either > > > NULL or a valid struct phy *, this is correct as is throughout the > driver. > > > > > >>> > > >>>> + phy_init(hsotg->phy); > > >>>> + > > >>>>/* usb phy enable */ > > >>>>s3c_hsotg_phy_enable(hsotg); > > >>>> > > >>>> @@ -3715,6 +3718,8 @@ static int s3c_hsotg_remove(struct > platform_device *pdev) > > >>>>} > > >>>> > > >>>>s3c_hsotg_phy_disable(hsotg); > > >>>> + if (hsotg->phy) > > >>> > > >>> same here. > > >> > > >> Ok. > > > > > > Same above, this will be NULL on failure (but is only applicable at > > > this point on the platform data path. > > > > Ah ok.. Btw where is phy_get being called? Is it not part of this > series? > > It's in the Kamil's Exynos USB Phy -> generic phy series [1] which I > depend on here. I mentioned it in the cover letter toward the end so > it's a bit buried. > > I have some outstanding, but trivial, comments on that series but I > hear Kamil will be posting an update in the coming days. I'll wait a > few days to post v4 addressing your comments so I can hopefully rebase > against his updated s3c-hsotg patch. > I am sorry to keep you waiting. I was doing some urgent non USB work lately and that is the reason for the delay. Thank you for the review of the last version, by the way. I should post the new version on Wednesday (or Tuesday afternoon, time permitting). Also, I will have no access to my Samsung email until Tuesday. Best wishes, Kamil Debski -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [RFC PATCH 2/5] phy: Add WIP Exynos 5250 support to the Exynos USB PHY driver
Hi Kishon, > From: Kishon Vijay Abraham I [mailto:kis...@ti.com] > Sent: Friday, October 25, 2013 5:44 PM > > Hi, > > On Friday 25 October 2013 07:45 PM, Kamil Debski wrote: > > Add support for Exynos 5250. This is work-in-progress commit. Not for > > merging. > > > > Signed-off-by: Kamil Debski > > Signed-off-by: Kyungmin Park > > --- > > drivers/phy/Kconfig |7 + > > drivers/phy/Makefile |1 + > > drivers/phy/phy-exynos-usb.c | 10 + > > drivers/phy/phy-exynos-usb.h |1 + > > drivers/phy/phy-exynos5250-usb.c | 411 > > ++ > > 5 files changed, 430 insertions(+) > > create mode 100644 drivers/phy/phy-exynos5250-usb.c > > > > diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index > > 2f7ac0a..0f598d0 100644 > > --- a/drivers/phy/Kconfig > > +++ b/drivers/phy/Kconfig > > @@ -36,4 +36,11 @@ config PHY_EXYNOS4212_USB > > help > > Enable USB PHY support for Exynos 4212 > > > > +config PHY_EXYNOS5250_USB > > + bool "Support for Exynos 5250" > > + depends on PHY_EXYNOS_USB > > This should be a separate driver. Not necessary to use PHY_EXYNOS_USB. > > + depends on SOC_EXYNOS5250 > > + help > > + Enable USB PHY support for Exynos 5250 > > + > > endmenu > > diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index > > ca3dc82..0dff0dd 100644 > > --- a/drivers/phy/Makefile > > +++ b/drivers/phy/Makefile > > @@ -6,3 +6,4 @@ obj-$(CONFIG_GENERIC_PHY) += phy-core.o > > obj-$(CONFIG_PHY_EXYNOS_USB) += phy-exynos-usb.o > > obj-$(CONFIG_PHY_EXYNOS4210_USB) += phy-exynos4210-usb.o > > obj-$(CONFIG_PHY_EXYNOS4212_USB) += phy-exynos4212-usb.o > > +obj-$(CONFIG_PHY_EXYNOS5250_USB) += phy-exynos5250-usb.o > > diff --git a/drivers/phy/phy-exynos-usb.c > > b/drivers/phy/phy-exynos-usb.c index d4a26df..172b774 100644 > > --- a/drivers/phy/phy-exynos-usb.c > > +++ b/drivers/phy/phy-exynos-usb.c > > @@ -212,6 +212,10 @@ extern const struct uphy_config > > exynos4210_uphy_config; extern const struct uphy_config > > exynos4212_uphy_config; #endif > > > > +#ifdef CONFIG_PHY_EXYNOS5250_USB > > +extern const struct uphy_config exynos5250_uphy_config; #endif > > + > > static const struct of_device_id exynos_uphy_of_match[] = { #ifdef > > CONFIG_PHY_EXYNOS4210_USB > > { > > @@ -225,6 +229,12 @@ static const struct of_device_id > exynos_uphy_of_match[] = { > > .data = &exynos4212_uphy_config, > > }, > > #endif > > +#ifdef CONFIG_PHY_EXYNOS5250_USB > > + { > > + .compatible = "samsung,exynos5250-usbphy", > > + .data = &exynos5250_uphy_config, > > + }, > > +#endif > > { }, > > }; > > > > diff --git a/drivers/phy/phy-exynos-usb.h > > b/drivers/phy/phy-exynos-usb.h index f45cb3c..a9febfa 100644 > > --- a/drivers/phy/phy-exynos-usb.h > > +++ b/drivers/phy/phy-exynos-usb.h > > @@ -42,6 +42,7 @@ enum samsung_cpu_type { > > TYPE_S3C64XX, > > TYPE_EXYNOS4210, > > TYPE_EXYNOS4212, > > + TYPE_EXYNOS5250, > > No cpu types here. > > }; > > > > enum uphy_state { > > diff --git a/drivers/phy/phy-exynos5250-usb.c > > b/drivers/phy/phy-exynos5250-usb.c > > new file mode 100644 > > index 000..156093b > > --- /dev/null > > +++ b/drivers/phy/phy-exynos5250-usb.c > > @@ -0,0 +1,411 @@ > > +/* > > + * Samsung S5P/EXYNOS SoC series USB PHY driver > > + * > > + * Copyright (C) 2013 Samsung Electronics Co., Ltd. > > + * Author: Kamil Debski > > + * > > + * 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 > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include "phy-exynos-usb.h" > > + > > +/* Exynos USB PHY registers */ > > +#define EXYNOS_5250_REFCLKSEL_CRYSTAL 0x0 > > +#define EXYNOS_5250_REFCLKSEL_XO 0x1 > > +#define EXYNOS_5250_REFCLKSEL_CLKCORE 0x2 > > + > > +#define EXYNOS_5250_FSEL_9MHZ6 0x0 > > +#define EXYNOS_5250_FSEL_10MHZ 0x1 > > +#define EXYNOS_5250_
RE: [PATCH v2 1/5] phy: Add new Exynos USB PHY driver
Hi Kishon, Thank you for your review! I will answer your comments below. > From: Kishon Vijay Abraham I [mailto:kis...@ti.com] > Sent: Friday, October 25, 2013 5:40 PM > > Hi, > > On Friday 25 October 2013 07:45 PM, Kamil Debski wrote: > > Add a new driver for the Exynos USB PHY. The new driver uses the > > generic PHY framework. The driver includes support for the Exynos > 4x10 > > and 4x12 SoC families. > > > > Signed-off-by: Kamil Debski > > Signed-off-by: Kyungmin Park > > --- > > .../devicetree/bindings/phy/samsung-usbphy.txt | 51 +++ > > drivers/phy/Kconfig| 21 ++ > > drivers/phy/Makefile |3 + > > drivers/phy/phy-exynos-usb.c | 245 > ++ > > drivers/phy/phy-exynos-usb.h | 94 ++ > > drivers/phy/phy-exynos4210-usb.c | 295 > + > > drivers/phy/phy-exynos4212-usb.c | 343 > > > 7 files changed, 1052 insertions(+) > > create mode 100644 > > Documentation/devicetree/bindings/phy/samsung-usbphy.txt > > create mode 100644 drivers/phy/phy-exynos-usb.c create mode 100644 > > drivers/phy/phy-exynos-usb.h create mode 100644 > > drivers/phy/phy-exynos4210-usb.c create mode 100644 > > drivers/phy/phy-exynos4212-usb.c > > > > diff --git a/Documentation/devicetree/bindings/phy/samsung-usbphy.txt > > b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt > > new file mode 100644 > > index 000..f112b37 > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt > > @@ -0,0 +1,51 @@ > > +Samsung S5P/EXYNOS SoC series USB PHY > > +- > > + > > +Required properties: > > +- compatible : should be one of the listed compatibles: > > + - "samsung,exynos4210-usbphy" > > + - "samsung,exynos4212-usbphy" > > +- reg : a list of registers used by phy driver > > + - first and obligatory is the location of phy modules registers > > + - second and also required is the location of isolation registers > > + (isolation registers control the physical connection between > the in > > + SoC modules and outside of the SoC, this also can be called > enable > > + control in the documentation of the SoC) > > + - third is the location of the mode switch register, this only > applies > > + to SoCs that have such a feature; mode switching enables to > have > > + both host and device used the same SoC pins and is commonly > used > > + when OTG is supported > > +- #phy-cells : from the generic phy bindings, must be 1; > > + > > +The second cell in the PHY specifier identifies the PHY its meaning > > +is SoC dependent. For the currently supported SoCs (Exynos 4210 and > > +Exynos 4212) it is as follows: > > + 0 - USB device, > > + 1 - USB host, > > + 2 - HSIC0, > > + 3 - HSIC1, > > HSIC is supposedly to be transceiver less no? You have to program > something in the digital side? > You have a single IP that have all these functionalities? There is a single USB PHY controller for all the above functionalities (i.e. host, device, hsic 0 and 1). > > + > > +Example: > > + > > +For Exynos 4412 (compatible with Exynos 4212): > > + > > +exynos_usbphy: exynos-usbphy@125B { > > + compatible = "samsung,exynos4212-usbphy"; > > + reg = <0x125B 0x100 0x10020704 0x0c 0x1001021c 0x4>; > > + ranges; > > + #address-cells = <1>; > > + #size-cells = <1>; > > The above 3 properties aren't documented? Are they needed here? My bad. I was working on two branches and corrected it in only one of them. > > + clocks = <&clock 305>, <&clock 2>, <&clock 2>, <&clock 2>, > > + <&clock 2>; > > + clock-names = "phy", "device", "host", "hsic0", "hsic1"; > > + status = "okay"; > > + #phy-cells = <1>; > > +}; > > + > > +Then the PHY can be used in other nodes such as: > > + > > +ehci@1258 { > > + status = "okay"; > > + phys = <&exynos_usbphy 2>; > > + phy-names = "hsic0"; > > +}; > > diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index > > 349bef2..2f7ac0a 100644 > > --- a/drivers/phy/Kconfig > >
RE: [PATCH 4/5] usb: ehci-s5p: Change to use phy provided by the generic phy framework
Hi Vivek, > From: Vivek Gautam [mailto:gautamvivek1...@gmail.com] > Sent: Saturday, October 26, 2013 11:41 AM > > Hi Kamil, > > > On Fri, Oct 25, 2013 at 7:45 PM, Kamil Debski > wrote: > > Change the phy provider used from the old usb phy specific to a new > > one using the generic phy framework. > > > > Signed-off-by: Kamil Debski > > Signed-off-by: Kyungmin Park > > --- > > drivers/usb/host/ehci-s5p.c | 21 +++-- > > 1 file changed, 11 insertions(+), 10 deletions(-) > > > > diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci- > s5p.c > > index 7cc26e6..76606ff 100644 > > --- a/drivers/usb/host/ehci-s5p.c > > +++ b/drivers/usb/host/ehci-s5p.c > > @@ -19,6 +19,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -45,7 +46,7 @@ static struct hc_driver __read_mostly > > s5p_ehci_hc_driver; > > > > struct s5p_ehci_hcd { > > struct clk *clk; > > - struct usb_phy *phy; > > + struct phy *phy; > > struct usb_otg *otg; > > struct s5p_ehci_platdata *pdata; }; @@ -77,10 +78,11 @@ > > static int s5p_ehci_probe(struct platform_device *pdev) { > > struct s5p_ehci_platdata *pdata = pdev->dev.platform_data; > > struct s5p_ehci_hcd *s5p_ehci; > > + struct phy *phy; > > just a nit here: > Lets keep the pointer to 'phy' and 'phy_name' together ? > and move this above phy_name ? Thanks for pointing this out. > > struct usb_hcd *hcd; > > struct ehci_hcd *ehci; > > struct resource *res; > > - struct usb_phy *phy; > > + const char *phy_name; > > int irq; > > int err; > > > > @@ -103,14 +105,14 @@ static int s5p_ehci_probe(struct > platform_device *pdev) > > return -ENOMEM; > > } > > s5p_ehci = to_s5p_ehci(hcd); > > - > > + phy_name = of_get_property(pdev->dev.of_node, "phy-names", > NULL); > > + phy = devm_phy_get(&pdev->dev, phy_name); > > Below check for exynos5440 was supposed to skip any request phy. > So shouldn't we place above two assignments to the original place where > devm_usb_get_phy() was called ? > May be i am not getting you intention of changing the place. Hm... You are right - if we want to leave this check and skip phy request for 5450 then I should leave the order as it was. And if we want to use the new phy driver for 5450 then the check to skip phy requesting should be simply removed. > > > if (of_device_is_compatible(pdev->dev.of_node, > > "samsung,exynos5440-ehci")) { > > s5p_ehci->pdata = &empty_platdata; > > goto skip_phy; > > } > > > > - phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); > > if (IS_ERR(phy)) { > > /* Fallback to pdata */ > > if (!pdata) { > > @@ -122,7 +124,6 @@ static int s5p_ehci_probe(struct platform_device > *pdev) > > } > > } else { > > s5p_ehci->phy = phy; > > - s5p_ehci->otg = phy->otg; > > } > > > > skip_phy: > > @@ -166,7 +167,7 @@ skip_phy: > > s5p_ehci->otg->set_host(s5p_ehci->otg, &hcd->self); > > Lets remove this line and similar calls to 'set_host()' in the driver, > since we don't have s5p_ehci->otg anymore after the same is removed > above. > Anyways this was helping the old phy-samsung-usb2 driver, and not > needed now. Ok, I will. > > > > > if (s5p_ehci->phy) > > - usb_phy_init(s5p_ehci->phy); > > + phy_power_on(s5p_ehci->phy); > > else if (s5p_ehci->pdata->phy_init) > > s5p_ehci->pdata->phy_init(pdev, USB_PHY_TYPE_HOST); > > > > @@ -188,7 +189,7 @@ skip_phy: > > > > fail_add_hcd: > > if (s5p_ehci->phy) > > - usb_phy_shutdown(s5p_ehci->phy); > > + phy_power_off(s5p_ehci->phy); > > else if (s5p_ehci->pdata->phy_exit) > > s5p_ehci->pdata->phy_exit(pdev, USB_PHY_TYPE_HOST); > > fail_io: > > @@ -209,7 +210,7 @@ static int s5p_ehci_remove(struct platform_device > *pdev) > > s5p_ehci->otg->se
RE: [PATCH 4/5] usb: ehci-s5p: Change to use phy provided by the generic phy framework
Hi Jingoo, > From: Jingoo Han [mailto:jg1@samsung.com] > Sent: Saturday, October 26, 2013 3:27 AM > > On Friday, October 25, 2013 11:15 PM, Kamil Debski wrote: > > > > Change the phy provider used from the old usb phy specific to a new > > one using the generic phy framework. > > > > Signed-off-by: Kamil Debski > > Signed-off-by: Kyungmin Park > > --- > > drivers/usb/host/ehci-s5p.c | 21 +++-- > > 1 file changed, 11 insertions(+), 10 deletions(-) > > Hi Kamil Debski, > It looks good. :-) Thank you. > However, could you re-basing against Greg's 'usb-next' branch? > Now, the file name of 'ehci-s5p.c' is renamed to 'ehci-exynos.c'. > Also, 'Generic PHY Framework' was already merged to Greg's 'usb-next' > branch. Thanks for pointing out this. > > Thank you. > > Best regards, > Jingoo Han Best wishes, -- Kamil Debski Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH v2 1/5] phy: Add new Exynos USB PHY driver
Hi Kumar Gala, > From: Kumar Gala [mailto:ga...@codeaurora.org] > Sent: Friday, October 25, 2013 11:36 PM > > On Oct 25, 2013, at 9:15 AM, Kamil Debski wrote: > > > Add a new driver for the Exynos USB PHY. The new driver uses the > > generic PHY framework. The driver includes support for the Exynos > 4x10 > > and 4x12 SoC families. > > > > Signed-off-by: Kamil Debski > > Signed-off-by: Kyungmin Park > > --- > > .../devicetree/bindings/phy/samsung-usbphy.txt | 51 +++ > > drivers/phy/Kconfig| 21 ++ > > drivers/phy/Makefile |3 + > > drivers/phy/phy-exynos-usb.c | 245 > ++ > > drivers/phy/phy-exynos-usb.h | 94 ++ > > drivers/phy/phy-exynos4210-usb.c | 295 > + > > drivers/phy/phy-exynos4212-usb.c | 343 > > > 7 files changed, 1052 insertions(+) > > create mode 100644 > > Documentation/devicetree/bindings/phy/samsung-usbphy.txt > > create mode 100644 drivers/phy/phy-exynos-usb.c create mode 100644 > > drivers/phy/phy-exynos-usb.h create mode 100644 > > drivers/phy/phy-exynos4210-usb.c create mode 100644 > > drivers/phy/phy-exynos4212-usb.c > > > > diff --git a/Documentation/devicetree/bindings/phy/samsung-usbphy.txt > > b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt > > new file mode 100644 > > index 000..f112b37 > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt > > @@ -0,0 +1,51 @@ > > +Samsung S5P/EXYNOS SoC series USB PHY > > +- > > + > > +Required properties: > > +- compatible : should be one of the listed compatibles: > > + - "samsung,exynos4210-usbphy" > > + - "samsung,exynos4212-usbphy" > > +- reg : a list of registers used by phy driver > > + - first and obligatory is the location of phy modules registers > > + - second and also required is the location of isolation registers > > + (isolation registers control the physical connection between > the in > > + SoC modules and outside of the SoC, this also can be called > enable > > + control in the documentation of the SoC) > > + - third is the location of the mode switch register, this only > applies > > + to SoCs that have such a feature; mode switching enables to > have > > + both host and device used the same SoC pins and is commonly > used > > + when OTG is supported > > +- #phy-cells : from the generic phy bindings, must be 1; > > Please add if clock & clock-names are required properties. Ok, thanks for pointing this out. > > > + > > +The second cell in the PHY specifier identifies the PHY its meaning > > +is SoC dependent. For the currently supported SoCs (Exynos 4210 and > > +Exynos 4212) it is as follows: > > Can we say instead of 'its meaning is SoC dependent...' something like > 'its meaning is compatible dependent"? Ok, this sounds better in deed. > > + 0 - USB device, > > + 1 - USB host, > > + 2 - HSIC0, > > + 3 - HSIC1, > > + > > +Example: > > + > > +For Exynos 4412 (compatible with Exynos 4212): > > + > > +exynos_usbphy: exynos-usbphy@125B { > > + compatible = "samsung,exynos4212-usbphy"; > > + reg = <0x125B 0x100 0x10020704 0x0c 0x1001021c 0x4>; > > + ranges; > > + #address-cells = <1>; > > + #size-cells = <1>; > > Why do you have ranges, and #address-cells & #size-cells here? As, I mentioned in my reply to Kishon. I worked on two branches and I forgot to remove this in the one used to generate patches. > > > + clocks = <&clock 305>, <&clock 2>, <&clock 2>, <&clock 2>, > > + <&clock 2>; > > + clock-names = "phy", "device", "host", "hsic0", "hsic1"; > > + status = "okay"; > > + #phy-cells = <1>; > > +}; > > + > > +Then the PHY can be used in other nodes such as: > > + > > +ehci@1258 { > > + status = "okay"; > > + phys = <&exynos_usbphy 2>; > > + phy-names = "hsic0"; > > +}; > Best wishes, -- Kamil Debski Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [RFC PATCH 2/5] phy: Add WIP Exynos 5250 support to the Exynos USB PHY driver
Hi, > From: Kishon Vijay Abraham I [mailto:kis...@ti.com] > Sent: Tuesday, October 29, 2013 10:55 AM > > Hi, > > On Monday 28 October 2013 08:11 PM, Vivek Gautam wrote: > > Hi Kishon, > > > > > > On Fri, Oct 25, 2013 at 9:13 PM, Kishon Vijay Abraham I > wrote: > >> Hi, > >> > >> On Friday 25 October 2013 07:45 PM, Kamil Debski wrote: > >>> Add support for Exynos 5250. This is work-in-progress commit. Not > >>> for merging. > >>> > >>> Signed-off-by: Kamil Debski > >>> Signed-off-by: Kyungmin Park > >>> --- > >>> drivers/phy/Kconfig |7 + > >>> drivers/phy/Makefile |1 + > >>> drivers/phy/phy-exynos-usb.c | 10 + > >>> drivers/phy/phy-exynos-usb.h |1 + > >>> drivers/phy/phy-exynos5250-usb.c | 411 > >>> ++ > >>> 5 files changed, 430 insertions(+) > >>> create mode 100644 drivers/phy/phy-exynos5250-usb.c > >>> > >>> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index > >>> 2f7ac0a..0f598d0 100644 > >>> --- a/drivers/phy/Kconfig > >>> +++ b/drivers/phy/Kconfig > >>> @@ -36,4 +36,11 @@ config PHY_EXYNOS4212_USB > >>> help > >>> Enable USB PHY support for Exynos 4212 > >>> > >>> +config PHY_EXYNOS5250_USB > >>> + bool "Support for Exynos 5250" > >>> + depends on PHY_EXYNOS_USB > >> > >> This should be a separate driver. Not necessary to use > PHY_EXYNOS_USB. > >>> + depends on SOC_EXYNOS5250 > >>> + help > >>> + Enable USB PHY support for Exynos 5250 > >>> + > >>> endmenu > >>> diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index > >>> ca3dc82..0dff0dd 100644 > >>> --- a/drivers/phy/Makefile > >>> +++ b/drivers/phy/Makefile > >>> @@ -6,3 +6,4 @@ obj-$(CONFIG_GENERIC_PHY) += phy-core.o > >>> obj-$(CONFIG_PHY_EXYNOS_USB) += phy-exynos-usb.o > >>> obj-$(CONFIG_PHY_EXYNOS4210_USB) += phy-exynos4210-usb.o > >>> obj-$(CONFIG_PHY_EXYNOS4212_USB) += phy-exynos4212-usb.o > >>> +obj-$(CONFIG_PHY_EXYNOS5250_USB) += phy-exynos5250-usb.o > >>> diff --git a/drivers/phy/phy-exynos-usb.c > >>> b/drivers/phy/phy-exynos-usb.c index d4a26df..172b774 100644 > >>> --- a/drivers/phy/phy-exynos-usb.c > >>> +++ b/drivers/phy/phy-exynos-usb.c > >>> @@ -212,6 +212,10 @@ extern const struct uphy_config > >>> exynos4210_uphy_config; extern const struct uphy_config > >>> exynos4212_uphy_config; #endif > >>> > >>> +#ifdef CONFIG_PHY_EXYNOS5250_USB > >>> +extern const struct uphy_config exynos5250_uphy_config; #endif > >>> + > >>> static const struct of_device_id exynos_uphy_of_match[] = > { #ifdef > >>> CONFIG_PHY_EXYNOS4210_USB > >>> { > >>> @@ -225,6 +229,12 @@ static const struct of_device_id > exynos_uphy_of_match[] = { > >>> .data = &exynos4212_uphy_config, > >>> }, > >>> #endif > >>> +#ifdef CONFIG_PHY_EXYNOS5250_USB > >>> + { > >>> + .compatible = "samsung,exynos5250-usbphy", > >>> + .data = &exynos5250_uphy_config, > >>> + }, > >>> +#endif > >>> { }, > >>> }; > >>> > >>> diff --git a/drivers/phy/phy-exynos-usb.h > >>> b/drivers/phy/phy-exynos-usb.h index f45cb3c..a9febfa 100644 > >>> --- a/drivers/phy/phy-exynos-usb.h > >>> +++ b/drivers/phy/phy-exynos-usb.h > >>> @@ -42,6 +42,7 @@ enum samsung_cpu_type { > >>> TYPE_S3C64XX, > >>> TYPE_EXYNOS4210, > >>> TYPE_EXYNOS4212, > >>> + TYPE_EXYNOS5250, > >> > >> No cpu types here. > > > > One question here. > > In case we move to single driver for Exynos4 SoCs (4210, 4212 and > 4412 > > later) as well as S5PV210, > > there will be certain things changing from one SoC to another, how > > should we target that in case we don't have CPU types ? > > May be i am misinterpreting your suggestion ? > > We should be using the IP revision register or check for compatible > values. > In case of this driver the compatible is checked. Maybe it is not as straight forward, but the choice is based on compatible value. Compatible is matched to an appropriate data entry in the of_device_id table. The data entry contains a cpu field which contains the information which PHY version we have. Maybe the "cpu" name is confusing and should be changed to something like "version" or "revision". For example: "samsung,exynos4212-usbphy" compatible is matched to exynos4212_uphy_config via data field of of_device_id, and the cpu field of exynos4212_uphy_config is equal to TYPE_EXYNOS4212. This way in the code all what is needed is to check the value of cpu field. It already got matched through the compatible. Still, Tomasz Figa's idea sound good - using a boolean flag "has_mode_switch". Best wishes, -- Kamil Debski Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH v2 1/5] phy: Add new Exynos USB PHY driver
Hi, > From: Tomasz Figa [mailto:tomasz.f...@gmail.com] > Sent: Monday, October 28, 2013 9:00 PM > > Hi Kamil, > > On Monday 28 of October 2013 14:52:19 Kamil Debski wrote: > > Hi Kishon, > > > > Thank you for your review! I will answer your comments below. > [snip] > > > > + > > > > + switch (drv->cfg->cpu) { > > > > + case TYPE_EXYNOS4210: > > > > > > > + case TYPE_EXYNOS4212: > > > Lets not add such cpu checks inside driver. > > > > Some SoC have a special register, which switches the OTG lines > between > > device and host modes. I understand that it might not be the > prettiest > > code. I see this as a good compromise between having a single huge > > driver for all Exynos SoCs and having a multiple drivers for each SoC > > version. PHY IPs in these chips very are similar but have to be > > handled differently. Any other ideas to solve this issue? > > Maybe adding a flag in drv->cfg called, for example, .has_mode_switch > could solve this problem without having to check the SoC type > explicitly? Sounds like a good idea. > [snip] > > > > +#ifdef CONFIG_PHY_EXYNOS4210_USB > > > > > > Do we really need this? > > > > No we don't. The driver can always support all Exynos SoC versions. > > These config options were added for flexibility. > > > > > > +extern const struct uphy_config exynos4210_uphy_config; #endif > > > > + > > > > +#ifdef CONFIG_PHY_EXYNOS4212_USB > > > > > > Same here. > > > > > > > +extern const struct uphy_config exynos4212_uphy_config; #endif > > > > + > > > > +static const struct of_device_id exynos_uphy_of_match[] = { > > > > +#ifdef CONFIG_PHY_EXYNOS4210_USB > > > > > > #if not needed here. > > > > If the #ifdef CONFIG_PHY_EXYNOS4210_USB is removed then yes. > Otherwise > > it is necessary - exynos4210_uphy_config may be undefined. > > I believe this and other ifdefs below are needed, otherwise, with > support for one of the SoCs disabled, the driver could still bind to > its compatible value. > Best wishes, -- Kamil Debski Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH RESEND v2 1/2] phy: core: Add an exported of_phy_get function
Previously the of_phy_get function took a struct device * and was declared static. It was impossible to call it from another driver and thus it was impossible to get phy defined for a given node. The old function was renamed to _of_phy_get and was left for internal use. of_phy_get function was added and it was exported. The function enables to get a phy for a given device tree node. Signed-off-by: Kamil Debski --- It seems that my git send-email is playing up and sent the previous emails without from. This is a resend. Sorry for any confusion. --- drivers/phy/phy-core.c | 41 - include/linux/phy/phy.h |1 + 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 03cf8fb..f0dbd42 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -240,8 +240,8 @@ out: EXPORT_SYMBOL_GPL(phy_power_off); /** - * of_phy_get() - lookup and obtain a reference to a phy by phandle - * @dev: device that requests this phy + * _of_phy_get() - lookup and obtain a reference to a phy by phandle + * @np: device_node for which to get the phy * @index: the index of the phy * * Returns the phy associated with the given phandle value, @@ -250,20 +250,17 @@ EXPORT_SYMBOL_GPL(phy_power_off); * not yet loaded. This function uses of_xlate call back function provided * while registering the phy_provider to find the phy instance. */ -static struct phy *of_phy_get(struct device *dev, int index) +static struct phy *_of_phy_get(struct device_node *np, int index) { int ret; struct phy_provider *phy_provider; struct phy *phy = NULL; struct of_phandle_args args; - ret = of_parse_phandle_with_args(dev->of_node, "phys", "#phy-cells", + ret = of_parse_phandle_with_args(np, "phys", "#phy-cells", index, &args); - if (ret) { - dev_dbg(dev, "failed to get phy in %s node\n", - dev->of_node->full_name); + if (ret) return ERR_PTR(-ENODEV); - } mutex_lock(&phy_provider_mutex); phy_provider = of_phy_provider_lookup(args.np); @@ -283,6 +280,32 @@ err0: } /** + * of_phy_get() - lookup and obtain a reference to a phy using a device_node. + * @np: device_node for which to get the phy + * @index: the index of the phy + * + * Returns the phy driver, after getting a refcount to it; or + * -ENODEV if there is no such phy. The caller is responsible for + * calling phy_put() to release that count. + */ +struct phy *of_phy_get(struct device_node *np, int index) +{ + struct phy *phy = NULL; + + phy = _of_phy_get(np, index); + if (IS_ERR(phy)) + return phy; + + if (!try_module_get(phy->ops->owner)) + return ERR_PTR(-EPROBE_DEFER); + + get_device(&phy->dev); + + return phy; +} +EXPORT_SYMBOL_GPL(of_phy_get); + +/** * phy_put() - release the PHY * @phy: the phy returned by phy_get() * @@ -370,7 +393,7 @@ struct phy *phy_get(struct device *dev, const char *string) if (dev->of_node) { index = of_property_match_string(dev->of_node, "phy-names", string); - phy = of_phy_get(dev, index); + phy = _of_phy_get(dev->of_node, index); if (IS_ERR(phy)) { dev_err(dev, "unable to find phy\n"); return phy; diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 6d72269..169f572 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -131,6 +131,7 @@ struct phy *phy_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); +struct phy *of_phy_get(struct device_node *np, int index); struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args); struct phy *phy_create(struct device *dev, const struct phy_ops *ops, -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 2/2] phy: core: Add devm_of_phy_get to phy-core
Adding devm_of_phy_get will allow to get phys by supplying the device_node instead of by name. Signed-off-by: Kamil Debski --- It seems that my git send-email is playing up and sent the previous emails without from. This is a resend. Sorry for any confusion. --- drivers/phy/phy-core.c | 31 +++ include/linux/phy/phy.h |2 ++ 2 files changed, 33 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index f0dbd42..661f7ab 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -446,6 +446,37 @@ struct phy *devm_phy_get(struct device *dev, const char *string) EXPORT_SYMBOL_GPL(devm_phy_get); /** + * devm_of_phy_get() - lookup and obtain a reference to a phy. + * @dev: device that requests this phy + * @np: node containing the phy + * @index: the index of the phy + * + * Gets the phy using phy_get(), and associates a device with it using + * devres. On driver detach, release function is invoked on the devres data, + * then, devres data is freed. + */ +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + int index) +{ + struct phy **ptr, *phy; + + ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + phy = of_phy_get(np, index); + if (!IS_ERR(phy)) { + *ptr = phy; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return phy; +} +EXPORT_SYMBOL_GPL(devm_of_phy_get); + +/** * phy_create() - create a new phy * @dev: device that is creating the new phy * @ops: function pointers for performing phy operations diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 169f572..db36d81 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -129,6 +129,8 @@ int phy_power_on(struct phy *phy); int phy_power_off(struct phy *phy); struct phy *phy_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + int index); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); struct phy *of_phy_get(struct device_node *np, int index); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH 1/9] phy: core: Change the way of_phy_get is called
Hi, > From: Kishon Vijay Abraham I [mailto:kis...@ti.com] > Sent: Monday, December 09, 2013 8:23 AM > > On Friday 06 December 2013 04:22 PM, Kamil Debski wrote: > > Hi, > > > >> From: Kishon Vijay Abraham I [mailto:kis...@ti.com] > >> Sent: Friday, December 06, 2013 6:31 AM > >> > >> Hi, > >> > >> On Thursday 05 December 2013 05:59 PM, Kamil Debski wrote: > >>> Previously the of_phy_get function took a struct device * and was > >>> declared static. It was impossible to call it from another driver > >>> and thus it was impossible to get phy defined > >> > >> It was never intended to be called from other drivers. What's up > with > >> the wrapper of of_phy_get, phy_get()/devm_phy_get()? Why isn't that > >> enough? > > > > Implementing support for multiple phys in the ehci driver is a bit > tricky. > > Especially when we want to do it right. Please have a look at this > > part of the dts file: > > > > +ehci@1258 { > > +compatible = "samsung,exynos4210-ehci"; > > +reg = <0x1258 0x2>; > > +interrupts = <0 70 0>; > > +clocks = <&clock 304>, <&clock 305>; > > +clock-names = "usbhost", "otg"; > > +status = "disabled"; > > +#address-cells = <1>; > > +#size-cells = <0>; > > +port@0 { > > +reg = <0>; > > +phys = <&usb2phy 1>; > > +phy-names = "host"; > > +status = "disabled"; > > +}; > > +port@1 { > > +reg = <1>; > > +phys = <&usb2phy 2>; > > +phy-names = "hsic0"; > > +status = "disabled"; > > +}; > > +port@2 { > > +reg = <2>; > > +phys = <&usb2phy 3>; > > +phy-names = "hsic1"; > > +status = "disabled"; > > +}; > > +}; > > > > With the above we have a clear specification of ports and their > > respective phys. But to do this properly the ehci driver has to > > iterate over port nodes. It is much easier to use devm_of_phy_get by > > giving the node as its argument. > > I see. There are a couple of more things we do in the wrapper that gets > missed while exporting of_phy_get (get_device and try_module_get). You > might want to re-work that one. Thank you for the review. I have just sent an updated version of the core patches. Best wishes, -- Kamil Debski Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH RESEND v2 1/2] phy: core: Add an exported of_phy_get function
Hi Kishon, > From: Kishon Vijay Abraham I [mailto:kis...@ti.com] > Sent: Friday, December 13, 2013 3:45 PM > > Hi, > > On Friday 13 December 2013 07:32 PM, Kamil Debski wrote: > > Previously the of_phy_get function took a struct device * and was > > declared static. It was impossible to call it from another driver and > > thus it was impossible to get phy defined for a given node. The old > > function was renamed to _of_phy_get and was left for internal use. > > of_phy_get function was added and it was exported. The function > > enables to get a phy for a given device tree node. > > > > Signed-off-by: Kamil Debski > > --- > > It seems that my git send-email is playing up and sent the previous > > emails without from. This is a resend. Sorry for any confusion. > > --- > > drivers/phy/phy-core.c | 41 - > > > include/linux/phy/phy.h |1 + > > 2 files changed, 33 insertions(+), 9 deletions(-) > > > > diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index > > 03cf8fb..f0dbd42 100644 > > --- a/drivers/phy/phy-core.c > > +++ b/drivers/phy/phy-core.c > > @@ -240,8 +240,8 @@ out: > > EXPORT_SYMBOL_GPL(phy_power_off); > > > > /** > > - * of_phy_get() - lookup and obtain a reference to a phy by phandle > > - * @dev: device that requests this phy > > + * _of_phy_get() - lookup and obtain a reference to a phy by phandle > > + * @np: device_node for which to get the phy > > * @index: the index of the phy > > * > > * Returns the phy associated with the given phandle value, @@ > > -250,20 +250,17 @@ EXPORT_SYMBOL_GPL(phy_power_off); > > * not yet loaded. This function uses of_xlate call back function > provided > > * while registering the phy_provider to find the phy instance. > > */ > > -static struct phy *of_phy_get(struct device *dev, int index) > > +static struct phy *_of_phy_get(struct device_node *np, int index) > > { > > int ret; > > struct phy_provider *phy_provider; > > struct phy *phy = NULL; > > struct of_phandle_args args; > > > > - ret = of_parse_phandle_with_args(dev->of_node, "phys", "#phy- > cells", > > + ret = of_parse_phandle_with_args(np, "phys", "#phy-cells", > > index, &args); > > - if (ret) { > > - dev_dbg(dev, "failed to get phy in %s node\n", > > - dev->of_node->full_name); > > + if (ret) > > return ERR_PTR(-ENODEV); > > - } > > > > mutex_lock(&phy_provider_mutex); > > phy_provider = of_phy_provider_lookup(args.np); @@ -283,6 +280,32 > @@ > > err0: > > } > > > > /** > > + * of_phy_get() - lookup and obtain a reference to a phy using a > device_node. > > + * @np: device_node for which to get the phy > > + * @index: the index of the phy > > Would be better if the user can get the PHY by string instead of index. Ok, this sounds doable. I will add of_phy_get_by_name analogous to the clk framework. > > + * > > + * Returns the phy driver, after getting a refcount to it; or > > + * -ENODEV if there is no such phy. The caller is responsible for > > + * calling phy_put() to release that count. > > + */ > > +struct phy *of_phy_get(struct device_node *np, int index) { > > + struct phy *phy = NULL; > > + > > + phy = _of_phy_get(np, index); > > + if (IS_ERR(phy)) > dev_err here? dev_err requires a dev, so it is not possible with the arguments used. And we do not want to add any extra parameters to keep the function call analogous to other of_*_get (as for example of_clk_get). Best wishes, -- Kamil Debski Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 2/2] phy: core: Add devm_of_phy_get to phy-core
Adding devm_of_phy_get will allow to get phys by supplying the device_node instead of by name. Signed-off-by: Kamil Debski --- drivers/phy/phy-core.c | 31 +++ include/linux/phy/phy.h |2 ++ 2 files changed, 33 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 0107f71..d45ad87 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -450,6 +450,37 @@ struct phy *devm_phy_get(struct device *dev, const char *string) EXPORT_SYMBOL_GPL(devm_phy_get); /** + * devm_of_phy_get() - lookup and obtain a reference to a phy. + * @dev: device that requests this phy + * @np: node containing the phy + * @con_id: name of the phy from device's point of view + * + * Gets the phy using phy_get(), and associates a device with it using + * devres. On driver detach, release function is invoked on the devres data, + * then, devres data is freed. + */ +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + struct phy **ptr, *phy; + + ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + phy = of_phy_get(np, con_id); + if (!IS_ERR(phy)) { + *ptr = phy; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return phy; +} +EXPORT_SYMBOL_GPL(devm_of_phy_get); + +/** * phy_create() - create a new phy * @dev: device that is creating the new phy * @ops: function pointers for performing phy operations diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index bcb6274..864914c 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -129,6 +129,8 @@ int phy_power_on(struct phy *phy); int phy_power_off(struct phy *phy); struct phy *phy_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); struct phy *of_phy_get(struct device_node *np, const char *con_id); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 1/2] phy: core: Add an exported of_phy_get function
Previously the of_phy_get function took a struct device * and was declared static. It was impossible to call it from another driver and thus it was impossible to get phy defined for a given node. The old function was renamed to _of_phy_get and was left for internal use. of_phy_get function was added and it was exported. The function enables to get a phy for a given device tree node. Signed-off-by: Kamil Debski --- drivers/phy/phy-core.c | 45 - include/linux/phy/phy.h |1 + 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 03cf8fb..0107f71 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -240,8 +240,8 @@ out: EXPORT_SYMBOL_GPL(phy_power_off); /** - * of_phy_get() - lookup and obtain a reference to a phy by phandle - * @dev: device that requests this phy + * _of_phy_get() - lookup and obtain a reference to a phy by phandle + * @np: device_node for which to get the phy * @index: the index of the phy * * Returns the phy associated with the given phandle value, @@ -250,20 +250,17 @@ EXPORT_SYMBOL_GPL(phy_power_off); * not yet loaded. This function uses of_xlate call back function provided * while registering the phy_provider to find the phy instance. */ -static struct phy *of_phy_get(struct device *dev, int index) +static struct phy *_of_phy_get(struct device_node *np, int index) { int ret; struct phy_provider *phy_provider; struct phy *phy = NULL; struct of_phandle_args args; - ret = of_parse_phandle_with_args(dev->of_node, "phys", "#phy-cells", + ret = of_parse_phandle_with_args(np, "phys", "#phy-cells", index, &args); - if (ret) { - dev_dbg(dev, "failed to get phy in %s node\n", - dev->of_node->full_name); + if (ret) return ERR_PTR(-ENODEV); - } mutex_lock(&phy_provider_mutex); phy_provider = of_phy_provider_lookup(args.np); @@ -283,6 +280,36 @@ err0: } /** + * of_phy_get() - lookup and obtain a reference to a phy using a device_node. + * @np: device_node for which to get the phy + * @con_id: name of the phy from device's point of view + * + * Returns the phy driver, after getting a refcount to it; or + * -ENODEV if there is no such phy. The caller is responsible for + * calling phy_put() to release that count. + */ +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + struct phy *phy = NULL; + int index = 0; + + if (con_id) + index = of_property_match_string(np, "phy-names", con_id); + + phy = _of_phy_get(np, index); + if (IS_ERR(phy)) + return phy; + + if (!try_module_get(phy->ops->owner)) + return ERR_PTR(-EPROBE_DEFER); + + get_device(&phy->dev); + + return phy; +} +EXPORT_SYMBOL_GPL(of_phy_get); + +/** * phy_put() - release the PHY * @phy: the phy returned by phy_get() * @@ -370,7 +397,7 @@ struct phy *phy_get(struct device *dev, const char *string) if (dev->of_node) { index = of_property_match_string(dev->of_node, "phy-names", string); - phy = of_phy_get(dev, index); + phy = _of_phy_get(dev->of_node, index); if (IS_ERR(phy)) { dev_err(dev, "unable to find phy\n"); return phy; diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 6d72269..bcb6274 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -131,6 +131,7 @@ struct phy *phy_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); +struct phy *of_phy_get(struct device_node *np, const char *con_id); struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args); struct phy *phy_create(struct device *dev, const struct phy_ops *ops, -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH RESEND v2 1/2] phy: core: Add an exported of_phy_get function
Hi, > From: Kishon Vijay Abraham I [mailto:kis...@ti.com] > Sent: Monday, December 16, 2013 10:01 AM > > On Friday 13 December 2013 08:56 PM, Kamil Debski wrote: > > Hi Kishon, > > > >> From: Kishon Vijay Abraham I [mailto:kis...@ti.com] > >> Sent: Friday, December 13, 2013 3:45 PM > >> > >> Hi, > >> > >> On Friday 13 December 2013 07:32 PM, Kamil Debski wrote: > >>> Previously the of_phy_get function took a struct device * and was > >>> declared static. It was impossible to call it from another driver > >>> and thus it was impossible to get phy defined for a given node. The > >>> old function was renamed to _of_phy_get and was left for internal > use. > >>> of_phy_get function was added and it was exported. The function > >>> enables to get a phy for a given device tree node. > >>> > >>> Signed-off-by: Kamil Debski > >>> --- > >>> It seems that my git send-email is playing up and sent the previous > >>> emails without from. This is a resend. Sorry for any confusion. > >>> --- > >>> drivers/phy/phy-core.c | 41 --- > -- > >> > >>> include/linux/phy/phy.h |1 + > >>> 2 files changed, 33 insertions(+), 9 deletions(-) > >>> > >>> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index > >>> 03cf8fb..f0dbd42 100644 > >>> --- a/drivers/phy/phy-core.c > >>> +++ b/drivers/phy/phy-core.c > >>> @@ -240,8 +240,8 @@ out: > >>> EXPORT_SYMBOL_GPL(phy_power_off); > >>> > >>> /** > >>> - * of_phy_get() - lookup and obtain a reference to a phy by > phandle > >>> - * @dev: device that requests this phy > >>> + * _of_phy_get() - lookup and obtain a reference to a phy by > >>> + phandle > >>> + * @np: device_node for which to get the phy > >>> * @index: the index of the phy > >>> * > >>> * Returns the phy associated with the given phandle value, @@ > >>> -250,20 +250,17 @@ EXPORT_SYMBOL_GPL(phy_power_off); > >>> * not yet loaded. This function uses of_xlate call back function > >> provided > >>> * while registering the phy_provider to find the phy instance. > >>> */ > >>> -static struct phy *of_phy_get(struct device *dev, int index) > >>> +static struct phy *_of_phy_get(struct device_node *np, int index) > >>> { > >>> int ret; > >>> struct phy_provider *phy_provider; > >>> struct phy *phy = NULL; > >>> struct of_phandle_args args; > >>> > >>> - ret = of_parse_phandle_with_args(dev->of_node, "phys", "#phy- > >> cells", > >>> + ret = of_parse_phandle_with_args(np, "phys", "#phy-cells", > >>> index, &args); > >>> - if (ret) { > >>> - dev_dbg(dev, "failed to get phy in %s node\n", > >>> - dev->of_node->full_name); > >>> + if (ret) > >>> return ERR_PTR(-ENODEV); > >>> - } > >>> > >>> mutex_lock(&phy_provider_mutex); > >>> phy_provider = of_phy_provider_lookup(args.np); @@ -283,6 +280,32 > >> @@ > >>> err0: > >>> } > >>> > >>> /** > >>> + * of_phy_get() - lookup and obtain a reference to a phy using a > >> device_node. > >>> + * @np: device_node for which to get the phy > >>> + * @index: the index of the phy > >> > >> Would be better if the user can get the PHY by string instead of > index. > > > > Ok, this sounds doable. I will add of_phy_get_by_name analogous to > the > > clk framework. > > Nope. It was decided initially to have minimal no of APIs exported to > get PHYs. > So you can just get string as argument instead of index and leave the > name of the API to just of_phy_get. If you say so. I just sent a new version taking a string id instead of an index. I hope you find it satisfying. > Thanks > Kishon > > > > >>> + * > >>> + * Returns the phy driver, after getting a refcount to it; or > >>> + * -ENODEV if there is no such phy. The caller is responsible for > >>> + * calling phy_put() to release that count. > >>> + */ > >>> +struct phy *of_phy_get(struct device_node *np, int index) { > >>> + struct phy *phy = NULL; > >>> + > >>> + phy = _of_phy_get(np, index); > >>> + if (IS_ERR(phy)) > >> dev_err here? > > > > dev_err requires a dev, so it is not possible with the arguments used. > > And we do not want to add any extra parameters to keep the function > > call analogous to other of_*_get (as for example of_clk_get). > > > > Best wishes, > > Best wishes, -- Kamil Debski Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH v4 5/9] usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework
Hi Matt, I am afraid it is not possible. This patch cannot go in without the new phy driver. It would break Exynos USB functionality. This is because it changes s3c-hsotg to use the new phy driver. I am working on an updated patch series addressing all the comments. time permitting I want to post an alternative version - integrating as much as possible in a single file. This way it would be possible to have a hands-on comparison of the two approaches we were discussing with Kishon. I estimate that I post it this week. Best wishes, -- Kamil Debski Samsung R&D Institute Poland > -Original Message- > From: Matt Porter [mailto:mpor...@linaro.org] > Sent: Monday, December 16, 2013 10:40 PM > To: Kamil Debski > Cc: linux-kernel@vger.kernel.org; linux-samsung-...@vger.kernel.org; > linux-...@vger.kernel.org; devicet...@vger.kernel.org; > kyungmin.p...@samsung.com; kis...@ti.com; t.f...@samsung.com; > s.nawro...@samsung.com; m.szyprow...@samsung.com; > gautam.vi...@samsung.com; mat.krawc...@gmail.com; > yulgon@samsung.com; p.pan...@samsung.com; av.tikhomi...@samsung.com; > jg1@samsung.com; ga...@codeaurora.org; Felipe Balbi > Subject: Re: [PATCH v4 5/9] usb: s3c-hsotg: Use the new Exynos USB phy > driver with the generic phy framework > > On Thu, Dec 05, 2013 at 01:29:35PM +0100, Kamil Debski wrote: > > Change the used phy driver to the new Exynos USB phy driver that uses > > the generic phy framework. > > > > Signed-off-by: Kamil Debski > > Signed-off-by: Kyungmin Park > > --- > > .../devicetree/bindings/usb/samsung-hsotg.txt |4 > > drivers/usb/gadget/s3c-hsotg.c | 11 ++ > - > > 2 files changed, 10 insertions(+), 5 deletions(-) > > Kamil, > > Can we separate this patch out of this series? My bcm281xx series is > ready to go except for this dependency. Felipe has noted that there's > only a week until he locks his tree down for 3.14 [1]. I'm willing to > update this versus the comment Kishon made on fixing the example if you > don't have time before then. Let me know. > > [1] https://lkml.org/lkml/2013/12/16/555 > > Thanks, > Matt > > > diff --git a/Documentation/devicetree/bindings/usb/samsung-hsotg.txt > > b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt > > index b83d428..9340d06 100644 > > --- a/Documentation/devicetree/bindings/usb/samsung-hsotg.txt > > +++ b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt > > @@ -24,6 +24,8 @@ Required properties: > > - first entry: must be "otg" > > - vusb_d-supply: phandle to voltage regulator of digital section, > > - vusb_a-supply: phandle to voltage regulator of analog section. > > +- phys: from general PHY binding: phandle to the PHY device > > +- phy-names: from general PHY binding: should be "usb2-phy" > > > > Example > > - > > @@ -36,5 +38,7 @@ Example > > clock-names = "otg"; > > vusb_d-supply = <&vusb_reg>; > > vusb_a-supply = <&vusbdac_reg>; > > + phys = <&usb2phy 0>; > > + phy-names = "device"; > > }; > > > > diff --git a/drivers/usb/gadget/s3c-hsotg.c > > b/drivers/usb/gadget/s3c-hsotg.c index eccb147..db096fd 100644 > > --- a/drivers/usb/gadget/s3c-hsotg.c > > +++ b/drivers/usb/gadget/s3c-hsotg.c > > @@ -31,6 +31,7 @@ > > #include #include > > #include > > +#include > > > > #include > > #include > > @@ -162,7 +163,7 @@ struct s3c_hsotg_ep { struct s3c_hsotg { > > struct device*dev; > > struct usb_gadget_driver *driver; > > - struct usb_phy *phy; > > + struct phy *phy; > > struct s3c_hsotg_plat*plat; > > > > spinlock_t lock; > > @@ -2905,7 +2906,7 @@ static void s3c_hsotg_phy_enable(struct > s3c_hsotg *hsotg) > > dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev); > > > > if (hsotg->phy) > > - usb_phy_init(hsotg->phy); > > + phy_power_on(hsotg->phy); > > else if (hsotg->plat->phy_init) > > hsotg->plat->phy_init(pdev, hsotg->plat->phy_type); } @@ - > 2922,7 > > +2923,7 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg) > > struct platform_device *pdev = to_platform_device(hsotg->dev); > > > > if (hsotg->phy) > > - usb_phy_shutdown(hsotg->phy); > > + phy_power_off(hsotg->phy); > > else if (hsotg->plat-
RE: [PATCH v4 3/9] phy: Add new Exynos USB PHY driver
Hi Anton, > From: Anton Tikhomirov [mailto:av.tikhomi...@samsung.com] > Sent: Tuesday, December 10, 2013 3:43 AM > > Hi Kamil, > > Same USB2.0 PHY may be used by several HCDs, for example EHCI and OHCI. > Consider the situation, when EHCI stops using the PHY and calls > power_off, then OHCI becomes non-operational. In other words, PHY > power_on and power_off calls must be balanced. > > Shall we handle it in your driver? (usage count?) Please look in the drivers/phy/phy-core.c file. Usage count is handled there - see phy_power_on and phy_power_off functions. I understand that after both EHCI and OHCI power on the phy, the usage count is 2. So powering off one of them (EHCI for instance) the usage count is still 1, so the OHCI should still work properly. [snip] Best wishes, -- Kamil Debski Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH] [media] s5p-mfc: Use decode status instead of display status on MFCv5
Hi Sjoerd, > From: linux-media-ow...@vger.kernel.org [mailto:linux-media- > ow...@vger.kernel.org] On Behalf Of Sjoerd Simons > Sent: Monday, September 22, 2014 2:52 PM > To: Kyungmin Park; Kamil Debski; Arun Kumar K > Cc: Mauro Carvalho Chehab; linux-arm-ker...@lists.infradead.org; linux- > me...@vger.kernel.org; linux-kernel@vger.kernel.org; linux-samsung- > s...@vger.kernel.org; Daniel Drake; Sjoerd Simons > Subject: [PATCH] [media] s5p-mfc: Use decode status instead of display > status on MFCv5 > > Commit 90c0ae50097 changed how the frame_type of a decoded frame > gets determined, by switching from the get_dec_frame_type to > get_disp_frame_type operation. Unfortunately it seems that on MFC v5 > the > result of get_disp_frame_type is always 0 (no display) when decoding > (tested with H264), resulting in no frame ever being output from the > decoder. Could you tell me which firmware version do you use (date)? Best wishes, -- Kamil Debski Samsung R&D Institute Poland > This patch reverts MFC v5 to the previous behaviour while keeping the > new behaviour for v6 and up. > > Signed-off-by: Sjoerd Simons > --- > drivers/media/platform/s5p-mfc/s5p_mfc.c | 7 ++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c > b/drivers/media/platform/s5p-mfc/s5p_mfc.c > index d35b041..27ca9d0 100644 > --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c > +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c > @@ -264,7 +264,12 @@ static void s5p_mfc_handle_frame_new(struct > s5p_mfc_ctx *ctx, unsigned int err) > unsigned int frame_type; > > dspl_y_addr = s5p_mfc_hw_call(dev->mfc_ops, get_dspl_y_adr, dev); > - frame_type = s5p_mfc_hw_call(dev->mfc_ops, get_disp_frame_type, > ctx); > + if (IS_MFCV6_PLUS(dev)) > + frame_type = s5p_mfc_hw_call(dev->mfc_ops, > + get_disp_frame_type, ctx); > + else > + frame_type = s5p_mfc_hw_call(dev->mfc_ops, > + get_dec_frame_type, dev); > > /* If frame is same as previous then skip and do not dequeue */ > if (frame_type == S5P_FIMV_DECODE_FRAME_SKIPPED) { > -- > 2.1.0 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-media" > in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [lm-sensors] [PATCH] hwmon: pwm-fan: Add pwm-fan driver
Hi, I forgot to address one of the comments. > From: Guenter Roeck [mailto:groe...@gmail.com] On Behalf Of Guenter > Roeck > Sent: Wednesday, July 09, 2014 6:58 PM > To: Kamil Debski > Cc: devicet...@vger.kernel.org; linux-kernel@vger.kernel.org; lm- > sens...@lm-sensors.org; t.f...@samsung.com; m.szyprow...@samsung.com > Subject: Re: [lm-sensors] [PATCH] hwmon: pwm-fan: Add pwm-fan driver > > On Wed, Jul 09, 2014 at 04:53:20PM +0200, Kamil Debski wrote: > > The pwm-fan driver enables control of fans connected to PWM lines. > > This driver uses the PWM framework, so it is compatible with all PWM > > devices that provide drivers through the PWM framework. > > > > Signed-off-by: Kamil Debski > > --- > > .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ > > drivers/hwmon/Kconfig |9 + > > drivers/hwmon/Makefile |1 + > > drivers/hwmon/pwm-fan.c| 199 > > +static int pwm_fan_remove(struct platform_device *pdev) { > > + struct pwm_fan_ctx *ctx = platform_get_drvdata(pdev); > > + > > + pwm_disable(ctx->pwm); > > Is this needed ? I don't see it used by the leds-pwm driver on cleanup. The pwm-samsung driver does not disable the PWM channel according to my understanding of the code. But for example the pwm-renesas-tpu does stop the PWM timer on free. What is the correct behavior? Is the channel should be disabled on free then I agree that pwm_disable is not necessary. > > + hwmon_device_unregister(ctx->hwmon); > > + > > + return 0; > > +} > > + Best wishes, -- Kamil Debski Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2] hwmon: pwm-fan: Add pwm-fan driver
The pwm-fan driver enables control of fans connected to PWM lines. This driver uses the PWM framework, so it is compatible with all PWM devices that provide drivers through the PWM framework. Signed-off-by: Kamil Debski --- Changes since v1: - added documentation to Documentation/hwmon - fix checkpatch errors - added extra description to Kconfig - removed whitespace errors - include files rearranged to be in alphabetical order - remove unused sysfs entry pwm1_enable - changed the behavior of the set_pwm function - when 0 PWM value is set pwm_disable is run - pwm_config return value is checked for errors - use of ATTRIBUTE_GROUPS was added - removed "Not enouch memory" error message - fixed probe return value in case of devm_of_pwm_get error - changed hwmon_device_register_with_groups to devm_hwmon_device_register_with_groups - changes suspend/resume to use pwm_disable/enable - removed unnecessary CONFIG_PM_SLEEP ifdefs --- .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ Documentation/hwmon/pwm-fan| 17 ++ drivers/hwmon/Kconfig | 11 ++ drivers/hwmon/Makefile |1 + drivers/hwmon/pwm-fan.c| 199 5 files changed, 240 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/pwm-fan.txt create mode 100644 Documentation/hwmon/pwm-fan create mode 100644 drivers/hwmon/pwm-fan.c diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt new file mode 100644 index 000..f534607 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -0,0 +1,12 @@ +Bindings for a fan connected to the PWM lines + +Required properties: +- compatible: "pwm-fan" +- pwms: the PWM that is used to control the PWM fan + +Example: + pwm-fan { + compatible = "pwm-fan"; + status = "okay"; + pwms = <&pwm 0 1 0>; + }; diff --git a/Documentation/hwmon/pwm-fan b/Documentation/hwmon/pwm-fan new file mode 100644 index 000..18529d2 --- /dev/null +++ b/Documentation/hwmon/pwm-fan @@ -0,0 +1,17 @@ +Kernel driver pwm-fan += + +This driver enables the use of a PWM module to drive a fan. It uses the +generic PWM interface thus it is hardware independent. It can be used on +many SoCs, as long as the SoC supplies a PWM line driver that exposes +the generic PWM API. + +Author: Kamil Debski + +Description +--- + +The driver implements a simple interface for driving a fan connected to +a PWM output. It uses the generic PWM interface, thus it can be used with +a range of SoCs. The driver exposes the fan to the user space through +the hwmon's sysfs interface. diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 02d3d85..4ac13ab 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1105,6 +1105,17 @@ config SENSORS_PCF8591 source drivers/hwmon/pmbus/Kconfig +config SENSORS_PWM_FAN + tristate "PWM fan" + depends on PWM + help + If you say yes here you get support for fans connected to PWM lines. + The driver uses the generic PWM interface, thus it will work on a + variety of SoCs. + + This driver can also be built as a module. If so, the module + will be called pwm-fan. + config SENSORS_SHT15 tristate "Sensiron humidity and temperature sensors. SHT15 and compat." depends on GPIOLIB diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 3dc0f02..3967ecf 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -120,6 +120,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR)+= ntc_thermistor.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o +obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c new file mode 100644 index 000..2bd73c3 --- /dev/null +++ b/drivers/hwmon/pwm-fan.c @@ -0,0 +1,199 @@ +/* + * pwm-fan.c - Hwmon driver for fans connected to PWM lines. + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Author: Kamil Debski + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
[PATCH v2] phy: phy-samsung-usb2: Change phy power on/power off sequence
The Exynos4412 USB 2.0 PHY hardware differs from the description provided in the documentation. Some register bits have different function. This patch fixes the defines of register bits and changes the way how phys are powered on and off. Signed-off-by: Kamil Debski --- drivers/phy/phy-exynos4x12-usb2.c | 112 + drivers/phy/phy-exynos5250-usb2.c |2 - drivers/phy/phy-samsung-usb2.h|3 +- 3 files changed, 77 insertions(+), 40 deletions(-) diff --git a/drivers/phy/phy-exynos4x12-usb2.c b/drivers/phy/phy-exynos4x12-usb2.c index d92a7cc..63134d8 100644 --- a/drivers/phy/phy-exynos4x12-usb2.c +++ b/drivers/phy/phy-exynos4x12-usb2.c @@ -86,13 +86,23 @@ #define EXYNOS_4x12_URSTCON_OTG_HLINK BIT(1) #define EXYNOS_4x12_URSTCON_OTG_PHYLINKBIT(2) #define EXYNOS_4x12_URSTCON_HOST_PHY BIT(3) +/* The following bit defines are presented in the + * order taken from the Exynos4412 reference manual. + * + * During experiments with the hardware and debugging + * it was determined that the hardware behaves contrary + * to the manual. + * + * The following bit values were chaned accordingly to the + * results of real hardware experiments. + */ #define EXYNOS_4x12_URSTCON_PHY1 BIT(4) -#define EXYNOS_4x12_URSTCON_HSIC0 BIT(5) -#define EXYNOS_4x12_URSTCON_HSIC1 BIT(6) +#define EXYNOS_4x12_URSTCON_HSIC0 BIT(6) +#define EXYNOS_4x12_URSTCON_HSIC1 BIT(5) #define EXYNOS_4x12_URSTCON_HOST_LINK_ALL BIT(7) -#define EXYNOS_4x12_URSTCON_HOST_LINK_P0 BIT(8) +#define EXYNOS_4x12_URSTCON_HOST_LINK_P0 BIT(10) #define EXYNOS_4x12_URSTCON_HOST_LINK_P1 BIT(9) -#define EXYNOS_4x12_URSTCON_HOST_LINK_P2 BIT(10) +#define EXYNOS_4x12_URSTCON_HOST_LINK_P2 BIT(8) /* Isolation, configured in the power management unit */ #define EXYNOS_4x12_USB_ISOL_OFFSET0x704 @@ -188,6 +198,7 @@ static void exynos4x12_setup_clk(struct samsung_usb2_phy_instance *inst) clk = readl(drv->reg_phy + EXYNOS_4x12_UPHYCLK); clk &= ~EXYNOS_4x12_UPHYCLK_PHYFSEL_MASK; clk |= drv->ref_reg_val << EXYNOS_4x12_UPHYCLK_PHYFSEL_OFFSET; + clk |= EXYNOS_4x12_UPHYCLK_PHY1_COMMON_ON; writel(clk, drv->reg_phy + EXYNOS_4x12_UPHYCLK); } @@ -198,27 +209,22 @@ static void exynos4x12_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) u32 phypwr = 0; u32 rst; u32 pwr; - u32 mode = 0; - u32 switch_mode = 0; switch (inst->cfg->id) { case EXYNOS4x12_DEVICE: phypwr =EXYNOS_4x12_UPHYPWR_PHY0; rstbits = EXYNOS_4x12_URSTCON_PHY0; - mode = EXYNOS_4x12_MODE_SWITCH_DEVICE; - switch_mode = 1; break; case EXYNOS4x12_HOST: phypwr =EXYNOS_4x12_UPHYPWR_PHY1; - rstbits = EXYNOS_4x12_URSTCON_HOST_PHY; - mode = EXYNOS_4x12_MODE_SWITCH_HOST; - switch_mode = 1; + rstbits = EXYNOS_4x12_URSTCON_HOST_PHY | + EXYNOS_4x12_URSTCON_PHY1 | + EXYNOS_4x12_URSTCON_HOST_LINK_P0; break; case EXYNOS4x12_HSIC0: phypwr =EXYNOS_4x12_UPHYPWR_HSIC0; - rstbits = EXYNOS_4x12_URSTCON_HSIC1 | - EXYNOS_4x12_URSTCON_HOST_LINK_P0 | - EXYNOS_4x12_URSTCON_HOST_PHY; + rstbits = EXYNOS_4x12_URSTCON_HSIC0 | + EXYNOS_4x12_URSTCON_HOST_LINK_P1; break; case EXYNOS4x12_HSIC1: phypwr =EXYNOS_4x12_UPHYPWR_HSIC1; @@ -228,11 +234,6 @@ static void exynos4x12_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) }; if (on) { - if (switch_mode) - regmap_update_bits(drv->reg_sys, - EXYNOS_4x12_MODE_SWITCH_OFFSET, - EXYNOS_4x12_MODE_SWITCH_MASK, mode); - pwr = readl(drv->reg_phy + EXYNOS_4x12_UPHYPWR); pwr &= ~phypwr; writel(pwr, drv->reg_phy + EXYNOS_4x12_UPHYPWR); @@ -253,41 +254,78 @@ static void exynos4x12_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) } } -static int exynos4x12_power_on(struct samsung_usb2_phy_instance *inst) +static void exynos4x12_power_on_int(struct samsung_usb2_phy_instance *inst) { - struct samsung_usb2_phy_driver *drv = inst->drv; + if (inst->int_cnt++ > 0) + return; - inst->enabled = 1; exynos4x12_setup_clk(inst); - exynos4x12_phy_pwr(inst, 1); exynos4x12_isol(inst, 0); + exynos4x12_phy_pwr(ins
[PATCH] hwmon: pwm-fan: Add pwm-fan driver
The pwm-fan driver enables control of fans connected to PWM lines. This driver uses the PWM framework, so it is compatible with all PWM devices that provide drivers through the PWM framework. Signed-off-by: Kamil Debski --- .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ drivers/hwmon/Kconfig |9 + drivers/hwmon/Makefile |1 + drivers/hwmon/pwm-fan.c| 199 4 files changed, 221 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/pwm-fan.txt create mode 100644 drivers/hwmon/pwm-fan.c diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt new file mode 100644 index 000..f534607 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -0,0 +1,12 @@ +Bindings for a fan connected to the PWM lines + +Required properties: +- compatible: "pwm-fan" +- pwms: the PWM that is used to control the PWM fan + +Example: + pwm-fan { + compatible = "pwm-fan"; + status = "okay"; + pwms = <&pwm 0 1 0>; + }; diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 08531a1..838ffb8 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1104,6 +1104,15 @@ config SENSORS_PCF8591 source drivers/hwmon/pmbus/Kconfig +config SENSORS_PWM_FAN + tristate "PWM fan" + depends on PWM + help + If you say yes here you get support for fans connected to PWM lines. + + This driver can also be built as a module. If so, the module + will be called pwm-fan. + config SENSORS_SHT15 tristate "Sensiron humidity and temperature sensors. SHT15 and compat." depends on GPIOLIB diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 3dc0f02..3967ecf 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -120,6 +120,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR)+= ntc_thermistor.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o +obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c new file mode 100644 index 000..78fa627 --- /dev/null +++ b/drivers/hwmon/pwm-fan.c @@ -0,0 +1,199 @@ +/* + * pwm-fan.c - Hwmon driver for fans connected to PWM lines. + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Author: Kamil Debski + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include +#include + +#define MAX_PWM 255 + +struct pwm_fan_ctx { + struct device *hwmon; + struct mutex lock; + struct platform_device *pdev; + struct pwm_device *pwm; + unsigned int duty_cycle; + unsigned char pwm_value; +}; + +static ssize_t show_pwm_enable(struct device *dev, + struct device_attribute *attr, char *buf) +{ + /* For the sake of simplicity only mode 1 (PWM) is supported */ + return sprintf(buf, "1\n"); +} + +static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct pwm_fan_ctx *ctx = dev_get_drvdata(dev); + unsigned long pwm, duty; + + if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM) + return -EINVAL; + + mutex_lock(&ctx->lock); + + if (ctx->pwm_value == pwm) + goto exit_set_pwm; + + duty = DIV_ROUND_UP(pwm * (ctx->pwm->period - 1), MAX_PWM); + if (pwm_config(ctx->pwm, duty, ctx->pwm->period)) + goto exit_set_pwm; + + ctx->duty_cycle = duty; + ctx->pwm_value = pwm; + + +exit_set_pwm: + mutex_unlock(&ctx->lock); + + return count; +} + +static ssize_t show_pwm(struct device *dev, + struct device_attribute *attr, char *buf) +{ + st
[PATCH] hwmon: gpio-fan: Change name passed to hwmon_device_register_with_groups
Commit 648cd48c9e566f53c5df30d79857e0937ae13b09 (hwmon: Do not accept invalid name attributes) added check for "-" in the name of hwmon device. This patch changes the name supplied by gpio-fan so that it is accepted by hwmon. Signed-off-by: Kamil Debski --- drivers/hwmon/gpio-fan.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c index ba35e4d..5acd555 100644 --- a/drivers/hwmon/gpio-fan.c +++ b/drivers/hwmon/gpio-fan.c @@ -538,7 +538,7 @@ static int gpio_fan_probe(struct platform_device *pdev) /* Make this driver part of hwmon class. */ fan_data->hwmon_dev = hwmon_device_register_with_groups(&pdev->dev, - "gpio-fan", fan_data, + "gpiofan", fan_data, gpio_fan_groups); if (IS_ERR(fan_data->hwmon_dev)) return PTR_ERR(fan_data->hwmon_dev); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [lm-sensors] [PATCH] hwmon: pwm-fan: Add pwm-fan driver
Hi Guenter, Thank you for your review. > From: Guenter Roeck [mailto:groe...@gmail.com] On Behalf Of Guenter > Roeck > Sent: Wednesday, July 09, 2014 6:58 PM > > On Wed, Jul 09, 2014 at 04:53:20PM +0200, Kamil Debski wrote: > > The pwm-fan driver enables control of fans connected to PWM lines. > > This driver uses the PWM framework, so it is compatible with all PWM > > devices that provide drivers through the PWM framework. > > > > Signed-off-by: Kamil Debski > > --- > > .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ > > drivers/hwmon/Kconfig |9 + > > drivers/hwmon/Makefile |1 + > > drivers/hwmon/pwm-fan.c| 199 > > > 4 files changed, 221 insertions(+) > > create mode 100644 > > Documentation/devicetree/bindings/hwmon/pwm-fan.txt > > create mode 100644 drivers/hwmon/pwm-fan.c > > Documentation/hwmon/pwm-fan is missing. Ok, I will add it. > > > > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt > > new file mode 100644 > > index 000..f534607 > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt > > @@ -0,0 +1,12 @@ > > +Bindings for a fan connected to the PWM lines > > + > > +Required properties: > > +- compatible: "pwm-fan" > > +- pwms: the PWM that is used to control the PWM fan > > + > > +Example: > > + pwm-fan { > > + compatible = "pwm-fan"; > > + status = "okay"; > > + pwms = <&pwm 0 1 0>; > > + }; > > diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index > > 08531a1..838ffb8 100644 > > --- a/drivers/hwmon/Kconfig > > +++ b/drivers/hwmon/Kconfig > > @@ -1104,6 +1104,15 @@ config SENSORS_PCF8591 > > > > source drivers/hwmon/pmbus/Kconfig > > > > +config SENSORS_PWM_FAN > > + tristate "PWM fan" > > + depends on PWM > > + help > > + If you say yes here you get support for fans connected to PWM > lines. > > + > > + This driver can also be built as a module. If so, the module > > + will be called pwm-fan. > > + > > config SENSORS_SHT15 > > tristate "Sensiron humidity and temperature sensors. SHT15 and > compat." > > depends on GPIOLIB > > diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index > > 3dc0f02..3967ecf 100644 > > --- a/drivers/hwmon/Makefile > > +++ b/drivers/hwmon/Makefile > > @@ -120,6 +120,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR)+= > ntc_thermistor.o > > obj-$(CONFIG_SENSORS_PC87360) += pc87360.o > > obj-$(CONFIG_SENSORS_PC87427) += pc87427.o > > obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o > > +obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o > > obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o > > obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o > > obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o > > diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c new > > file mode 100644 index 000..78fa627 > > --- /dev/null > > +++ b/drivers/hwmon/pwm-fan.c > > @@ -0,0 +1,199 @@ > > +/* > > + * pwm-fan.c - Hwmon driver for fans connected to PWM lines. > > + * > > + * Copyright (c) 2014 Samsung Electronics Co., Ltd. > > + * > > + * Author: Kamil Debski > > + * > > + * 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. > > + * > > + * This program is distributed in the hope that it will be useful, > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > + * GNU General Public License for more details. > > + * > > + * You should have received a copy of the GNU General Public License > > + * along with this program; if not, write to the Free Software > > + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA > > +02111-1307 USA > > Please run the patch through checkpatch and ensure that all warnings > and errors are fixed. I did checkpatch with -f by mistake, so it missed this error. Thanks for pointing this out. > > + */ > > + > >
RE: [PATCH] hwmon: pwm-fan: Add pwm-fan driver
Hi Tobias, Thank you for your review. > From: Tobias Klauser [mailto:tklau...@distanz.ch] > Sent: Wednesday, July 09, 2014 7:50 PM > > On 2014-07-09 at 16:53:20 +0200, Kamil Debski > wrote: > > The pwm-fan driver enables control of fans connected to PWM lines. > > This driver uses the PWM framework, so it is compatible with all PWM > > devices that provide drivers through the PWM framework. > > > > Signed-off-by: Kamil Debski > > --- > > .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ > > drivers/hwmon/Kconfig |9 + > > drivers/hwmon/Makefile |1 + > > drivers/hwmon/pwm-fan.c| 199 > > > 4 files changed, 221 insertions(+) > > create mode 100644 > > Documentation/devicetree/bindings/hwmon/pwm-fan.txt > > create mode 100644 drivers/hwmon/pwm-fan.c > > [...] > > > diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c new > > file mode 100644 index 000..78fa627 > > --- /dev/null > > +++ b/drivers/hwmon/pwm-fan.c > > @@ -0,0 +1,199 @@ > > [...] > > > +#ifdef CONFIG_PM_SLEEP > > +static int pwm_fan_suspend(struct device *dev) { > > + struct pwm_fan_ctx *ctx = dev_get_drvdata(dev); > > + > > + return pwm_config(ctx->pwm, 0, ctx->pwm->period); } > > + > > +static int pwm_fan_resume(struct device *dev) { > > + struct pwm_fan_ctx *ctx = dev_get_drvdata(dev); > > + > > + return pwm_config(ctx->pwm, ctx->duty_cycle, ctx->pwm->period); } > > + > > +static SIMPLE_DEV_PM_OPS(pwm_fan_pm, pwm_fan_suspend, > > +pwm_fan_resume); > > If you move this out of #ifdef CONFIG_PM_SLEEP, you won't need the > #ifdef around driver.pm below [1]. SIMPLE_DEV_PM_OPS will just define > an empty struct dev_pm_os if CONFIG_PM_LSEEP is not defined. Thanks for this suggestion. > > > +#endif > > + > > + > > + > > +static struct of_device_id of_pwm_fan_match[] = { > > + { .compatible = "pwm-fan", }, > > + {}, > > +}; > > + > > +static struct platform_driver pwm_fan_driver = { > > + .probe = pwm_fan_probe, > > + .remove = pwm_fan_remove, > > + .driver = { > > + .name = "pwm-fan", > > +#ifdef CONFIG_PM_SLEEP > > + .pm = &pwm_fan_pm, > > +#endif > > [1] #ifdef CONFIG_PM_SLEEP not needed with the above change. > > > + .of_match_table = of_match_ptr(of_pwm_fan_match), > > + }, > > +}; > > + > > +module_platform_driver(pwm_fan_driver); > > + > > +MODULE_AUTHOR("Kamil Debski "); > > +MODULE_ALIAS("platform:pwm-fan"); > > +MODULE_DESCRIPTION("PWM FAN driver"); MODULE_LICENSE("GPL"); > > -- > > 1.7.9.5 Best wishes, -- Kamil Debski Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3] hwmon: pwm-fan: Add pwm-fan driver
The pwm-fan driver enables control of fans connected to PWM lines. This driver uses the PWM framework, so it is compatible with all PWM devices that provide drivers through the PWM framework. Signed-off-by: Kamil Debski --- Changes since v2: - add CONFIG_PM_SLEEP around pwm_fan_suspend and pwm_fan_resume Changes since v1: - added documentation to Documentation/hwmon - fix checkpatch errors - added extra description to Kconfig - removed whitespace errors - include files rearranged to be in alphabetical order - remove unused sysfs entry pwm1_enable - changed the behavior of the set_pwm function - when 0 PWM value is set pwm_disable is run - pwm_config return value is checked for errors - use of ATTRIBUTE_GROUPS was added - removed "Not enouch memory" error message - fixed probe return value in case of devm_of_pwm_get error - changed hwmon_device_register_with_groups to devm_hwmon_device_register_with_groups - changes suspend/resume to use pwm_disable/enable - removed unnecessary CONFIG_PM_SLEEP ifdefs --- .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ Documentation/hwmon/pwm-fan| 17 ++ drivers/hwmon/Kconfig | 11 ++ drivers/hwmon/Makefile |1 + drivers/hwmon/pwm-fan.c| 201 5 files changed, 242 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/pwm-fan.txt create mode 100644 Documentation/hwmon/pwm-fan create mode 100644 drivers/hwmon/pwm-fan.c diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt new file mode 100644 index 000..f534607 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -0,0 +1,12 @@ +Bindings for a fan connected to the PWM lines + +Required properties: +- compatible: "pwm-fan" +- pwms: the PWM that is used to control the PWM fan + +Example: + pwm-fan { + compatible = "pwm-fan"; + status = "okay"; + pwms = <&pwm 0 1 0>; + }; diff --git a/Documentation/hwmon/pwm-fan b/Documentation/hwmon/pwm-fan new file mode 100644 index 000..18529d2 --- /dev/null +++ b/Documentation/hwmon/pwm-fan @@ -0,0 +1,17 @@ +Kernel driver pwm-fan += + +This driver enables the use of a PWM module to drive a fan. It uses the +generic PWM interface thus it is hardware independent. It can be used on +many SoCs, as long as the SoC supplies a PWM line driver that exposes +the generic PWM API. + +Author: Kamil Debski + +Description +--- + +The driver implements a simple interface for driving a fan connected to +a PWM output. It uses the generic PWM interface, thus it can be used with +a range of SoCs. The driver exposes the fan to the user space through +the hwmon's sysfs interface. diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 02d3d85..4ac13ab 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1105,6 +1105,17 @@ config SENSORS_PCF8591 source drivers/hwmon/pmbus/Kconfig +config SENSORS_PWM_FAN + tristate "PWM fan" + depends on PWM + help + If you say yes here you get support for fans connected to PWM lines. + The driver uses the generic PWM interface, thus it will work on a + variety of SoCs. + + This driver can also be built as a module. If so, the module + will be called pwm-fan. + config SENSORS_SHT15 tristate "Sensiron humidity and temperature sensors. SHT15 and compat." depends on GPIOLIB diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 3dc0f02..3967ecf 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -120,6 +120,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR)+= ntc_thermistor.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o +obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c new file mode 100644 index 000..03d45f2 --- /dev/null +++ b/drivers/hwmon/pwm-fan.c @@ -0,0 +1,201 @@ +/* + * pwm-fan.c - Hwmon driver for fans connected to PWM lines. + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Author: Kamil Debski + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implie
[PATCH v4] hwmon: pwm-fan: Add pwm-fan driver
The pwm-fan driver enables control of fans connected to PWM lines. This driver uses the PWM framework, so it is compatible with all PWM devices that provide drivers through the PWM framework. Signed-off-by: Kamil Debski --- Changes since v3: - fix missing "\n" in error messages - remove of_match_ptr which was not necessary - change error returned in case of failed allocation to -ENOMEM Changes since v2: - add CONFIG_PM_SLEEP around pwm_fan_suspend and pwm_fan_resume Changes since v1: - added documentation to Documentation/hwmon - fix checkpatch errors - added extra description to Kconfig - removed whitespace errors - include files rearranged to be in alphabetical order - remove unused sysfs entry pwm1_enable - changed the behavior of the set_pwm function - when 0 PWM value is set pwm_disable is run - pwm_config return value is checked for errors - use of ATTRIBUTE_GROUPS was added - removed "Not enouch memory" error message - fixed probe return value in case of devm_of_pwm_get error - changed hwmon_device_register_with_groups to devm_hwmon_device_register_with_groups - changes suspend/resume to use pwm_disable/enable - removed unnecessary CONFIG_PM_SLEEP ifdefs --- .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ Documentation/hwmon/pwm-fan| 17 ++ drivers/hwmon/Kconfig | 11 ++ drivers/hwmon/Makefile |1 + drivers/hwmon/pwm-fan.c| 202 5 files changed, 243 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/pwm-fan.txt create mode 100644 Documentation/hwmon/pwm-fan create mode 100644 drivers/hwmon/pwm-fan.c diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt new file mode 100644 index 000..610757c --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -0,0 +1,12 @@ +Bindings for a fan connected to the PWM lines + +Required properties: +- compatible : "pwm-fan" +- pwms : the PWM that is used to control the PWM fan + +Example: + pwm-fan { + compatible = "pwm-fan"; + status = "okay"; + pwms = <&pwm 0 1 0>; + }; diff --git a/Documentation/hwmon/pwm-fan b/Documentation/hwmon/pwm-fan new file mode 100644 index 000..18529d2 --- /dev/null +++ b/Documentation/hwmon/pwm-fan @@ -0,0 +1,17 @@ +Kernel driver pwm-fan += + +This driver enables the use of a PWM module to drive a fan. It uses the +generic PWM interface thus it is hardware independent. It can be used on +many SoCs, as long as the SoC supplies a PWM line driver that exposes +the generic PWM API. + +Author: Kamil Debski + +Description +--- + +The driver implements a simple interface for driving a fan connected to +a PWM output. It uses the generic PWM interface, thus it can be used with +a range of SoCs. The driver exposes the fan to the user space through +the hwmon's sysfs interface. diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 02d3d85..4ac13ab 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1105,6 +1105,17 @@ config SENSORS_PCF8591 source drivers/hwmon/pmbus/Kconfig +config SENSORS_PWM_FAN + tristate "PWM fan" + depends on PWM + help + If you say yes here you get support for fans connected to PWM lines. + The driver uses the generic PWM interface, thus it will work on a + variety of SoCs. + + This driver can also be built as a module. If so, the module + will be called pwm-fan. + config SENSORS_SHT15 tristate "Sensiron humidity and temperature sensors. SHT15 and compat." depends on GPIOLIB diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 3dc0f02..3967ecf 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -120,6 +120,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR)+= ntc_thermistor.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o +obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c new file mode 100644 index 000..cacb20a --- /dev/null +++ b/drivers/hwmon/pwm-fan.c @@ -0,0 +1,202 @@ +/* + * pwm-fan.c - Hwmon driver for fans connected to PWM lines. + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Author: Kamil Debski + * + * 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
RE: [PATCH v3] hwmon: pwm-fan: Add pwm-fan driver
Hi Varka, Thank you for the review. I agree with your comments in this and your second email. I have just sent an updated version 4 of the patch. Best wishes, -- Kamil Debski Samsung R&D Institute Poland > -Original Message- > From: Varka Bhadram [mailto:varkabhad...@gmail.com] > Sent: Tuesday, July 15, 2014 2:02 PM > To: Kamil Debski; devicet...@vger.kernel.org; linux- > ker...@vger.kernel.org; lm-sens...@lm-sensors.org > Cc: t.f...@samsung.com; m.szyprow...@samsung.com; li...@roeck-us.net; > tklau...@distanz.ch; linux-...@vger.kernel.org > Subject: Re: [PATCH v3] hwmon: pwm-fan: Add pwm-fan driver > > On 07/15/2014 05:21 PM, Kamil Debski wrote: > > The pwm-fan driver enables control of fans connected to PWM lines. > > This driver uses the PWM framework, so it is compatible with all > > PWM devices that provide drivers through the PWM framework. > > > > Signed-off-by: Kamil Debski > > --- > > Changes since v2: > > - add CONFIG_PM_SLEEP around pwm_fan_suspend and pwm_fan_resume > > Changes since v1: > > - added documentation to Documentation/hwmon > > - fix checkpatch errors > > - added extra description to Kconfig > > - removed whitespace errors > > - include files rearranged to be in alphabetical order > > - remove unused sysfs entry pwm1_enable > > - changed the behavior of the set_pwm function > > - when 0 PWM value is set pwm_disable is run > > - pwm_config return value is checked for errors > > - use of ATTRIBUTE_GROUPS was added > > - removed "Not enouch memory" error message > > - fixed probe return value in case of devm_of_pwm_get error > > - changed hwmon_device_register_with_groups to > >devm_hwmon_device_register_with_groups > > - changes suspend/resume to use pwm_disable/enable > > - removed unnecessary CONFIG_PM_SLEEP ifdefs > > --- > > .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ > > Documentation/hwmon/pwm-fan| 17 ++ > > drivers/hwmon/Kconfig | 11 ++ > > drivers/hwmon/Makefile |1 + > > drivers/hwmon/pwm-fan.c| 201 > > > 5 files changed, 242 insertions(+) > > create mode 100644 Documentation/devicetree/bindings/hwmon/pwm- > fan.txt > > create mode 100644 Documentation/hwmon/pwm-fan > > create mode 100644 drivers/hwmon/pwm-fan.c > > > > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt > > new file mode 100644 > > index 000..f534607 > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt > > @@ -0,0 +1,12 @@ > > +Bindings for a fan connected to the PWM lines > > + > > +Required properties: > > +- compatible: "pwm-fan" > > +- pwms: the PWM that is used to control the PWM fan > > + > > +Example: > > + pwm-fan { > > + compatible = "pwm-fan"; > > + status = "okay"; > > + pwms = <&pwm 0 1 0>; > > + }; > > diff --git a/Documentation/hwmon/pwm-fan b/Documentation/hwmon/pwm- > fan > > new file mode 100644 > > index 000..18529d2 > > --- /dev/null > > +++ b/Documentation/hwmon/pwm-fan > > @@ -0,0 +1,17 @@ > > +Kernel driver pwm-fan > > += > > + > > +This driver enables the use of a PWM module to drive a fan. It uses > the > > +generic PWM interface thus it is hardware independent. It can be > used on > > +many SoCs, as long as the SoC supplies a PWM line driver that > exposes > > +the generic PWM API. > > + > > +Author: Kamil Debski > > + > > +Description > > +--- > > + > > +The driver implements a simple interface for driving a fan connected > to > > +a PWM output. It uses the generic PWM interface, thus it can be used > with > > +a range of SoCs. The driver exposes the fan to the user space > through > > +the hwmon's sysfs interface. > > diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig > > index 02d3d85..4ac13ab 100644 > > --- a/drivers/hwmon/Kconfig > > +++ b/drivers/hwmon/Kconfig > > @@ -1105,6 +1105,17 @@ config SENSORS_PCF8591 > > > > source drivers/hwmon/pmbus/Kconfig > > > > +config SENSORS_PWM_FAN > > + tristate "PWM fan" > > + depends on PWM > > + help > > + If you say yes here you get support for fans connected to PWM > lines.
[PATCH v5] hwmon: pwm-fan: Add pwm-fan driver
The pwm-fan driver enables control of fans connected to PWM lines. This driver uses the PWM framework, so it is compatible with all PWM devices that provide drivers through the PWM framework. Signed-off-by: Kamil Debski Reviewed-by: Varka Bhadram Reviewed-by: Tobias Klauser --- Changes since v4: - remove unused variables from pwm_fan_ctx - fixes in the set_pwm function Changes since v3: - fix missing "\n" in error messages - remove of_match_ptr which was not necessary - change error returned in case of failed allocation to -ENOMEM Changes since v2: - add CONFIG_PM_SLEEP around pwm_fan_suspend and pwm_fan_resume Changes since v1: - added documentation to Documentation/hwmon - fix checkpatch errors - added extra description to Kconfig - removed whitespace errors - include files rearranged to be in alphabetical order - remove unused sysfs entry pwm1_enable - changed the behavior of the set_pwm function - when 0 PWM value is set pwm_disable is run - pwm_config return value is checked for errors - use of ATTRIBUTE_GROUPS was added - removed "Not enouch memory" error message - fixed probe return value in case of devm_of_pwm_get error - changed hwmon_device_register_with_groups to devm_hwmon_device_register_with_groups - changes suspend/resume to use pwm_disable/enable - removed unnecessary CONFIG_PM_SLEEP ifdefs --- .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ Documentation/hwmon/pwm-fan| 17 ++ drivers/hwmon/Kconfig | 11 ++ drivers/hwmon/Makefile |1 + drivers/hwmon/pwm-fan.c| 195 5 files changed, 236 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/pwm-fan.txt create mode 100644 Documentation/hwmon/pwm-fan create mode 100644 drivers/hwmon/pwm-fan.c diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt new file mode 100644 index 000..610757c --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -0,0 +1,12 @@ +Bindings for a fan connected to the PWM lines + +Required properties: +- compatible : "pwm-fan" +- pwms : the PWM that is used to control the PWM fan + +Example: + pwm-fan { + compatible = "pwm-fan"; + status = "okay"; + pwms = <&pwm 0 1 0>; + }; diff --git a/Documentation/hwmon/pwm-fan b/Documentation/hwmon/pwm-fan new file mode 100644 index 000..18529d2 --- /dev/null +++ b/Documentation/hwmon/pwm-fan @@ -0,0 +1,17 @@ +Kernel driver pwm-fan += + +This driver enables the use of a PWM module to drive a fan. It uses the +generic PWM interface thus it is hardware independent. It can be used on +many SoCs, as long as the SoC supplies a PWM line driver that exposes +the generic PWM API. + +Author: Kamil Debski + +Description +--- + +The driver implements a simple interface for driving a fan connected to +a PWM output. It uses the generic PWM interface, thus it can be used with +a range of SoCs. The driver exposes the fan to the user space through +the hwmon's sysfs interface. diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 02d3d85..4ac13ab 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1105,6 +1105,17 @@ config SENSORS_PCF8591 source drivers/hwmon/pmbus/Kconfig +config SENSORS_PWM_FAN + tristate "PWM fan" + depends on PWM + help + If you say yes here you get support for fans connected to PWM lines. + The driver uses the generic PWM interface, thus it will work on a + variety of SoCs. + + This driver can also be built as a module. If so, the module + will be called pwm-fan. + config SENSORS_SHT15 tristate "Sensiron humidity and temperature sensors. SHT15 and compat." depends on GPIOLIB diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 3dc0f02..3967ecf 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -120,6 +120,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR)+= ntc_thermistor.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o +obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c new file mode 100644 index 000..63076d6 --- /dev/null +++ b/drivers/hwmon/pwm-fan.c @@ -0,0 +1,195 @@ +/* + * pwm-fan.c - Hwmon driver for fans connected to PWM lines. + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Author: Kamil Debski + * + * This program is free software; you can r
RE: [PATCH v4] hwmon: pwm-fan: Add pwm-fan driver
Hi Guenter, > From: Guenter Roeck [mailto:li...@roeck-us.net] > Sent: Wednesday, July 16, 2014 3:53 PM > To: Kamil Debski; devicet...@vger.kernel.org; linux- > ker...@vger.kernel.org; lm-sens...@lm-sensors.org > Cc: t.f...@samsung.com; m.szyprow...@samsung.com; tklau...@distanz.ch; > linux-...@vger.kernel.org; varkabhad...@gmail.com > Subject: Re: [PATCH v4] hwmon: pwm-fan: Add pwm-fan driver > > Hi Kamil, > > comments inline. Thank you for your review :-) > > Thanks, > Guenter > > On 07/16/2014 03:03 AM, Kamil Debski wrote: > > The pwm-fan driver enables control of fans connected to PWM lines. > > This driver uses the PWM framework, so it is compatible with all PWM > > devices that provide drivers through the PWM framework. > > > > Signed-off-by: Kamil Debski > > --- > > Changes since v3: > > - fix missing "\n" in error messages > > - remove of_match_ptr which was not necessary > > - change error returned in case of failed allocation to -ENOMEM > > Changes since v2: > > - add CONFIG_PM_SLEEP around pwm_fan_suspend and pwm_fan_resume > > Changes since v1: > > - added documentation to Documentation/hwmon > > - fix checkpatch errors > > - added extra description to Kconfig > > - removed whitespace errors > > - include files rearranged to be in alphabetical order > > - remove unused sysfs entry pwm1_enable > > - changed the behavior of the set_pwm function > > - when 0 PWM value is set pwm_disable is run > > - pwm_config return value is checked for errors > > - use of ATTRIBUTE_GROUPS was added > > - removed "Not enouch memory" error message > > - fixed probe return value in case of devm_of_pwm_get error > > - changed hwmon_device_register_with_groups to > >devm_hwmon_device_register_with_groups > > - changes suspend/resume to use pwm_disable/enable > > - removed unnecessary CONFIG_PM_SLEEP ifdefs > > --- > > .../devicetree/bindings/hwmon/pwm-fan.txt | 12 ++ > > Documentation/hwmon/pwm-fan| 17 ++ > > drivers/hwmon/Kconfig | 11 ++ > > drivers/hwmon/Makefile |1 + > > drivers/hwmon/pwm-fan.c| 202 > > > 5 files changed, 243 insertions(+) > > create mode 100644 Documentation/devicetree/bindings/hwmon/pwm- > fan.txt > > create mode 100644 Documentation/hwmon/pwm-fan > > create mode 100644 drivers/hwmon/pwm-fan.c > > > > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt > > new file mode 100644 > > index 000..610757c > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt > > @@ -0,0 +1,12 @@ > > +Bindings for a fan connected to the PWM lines > > + > > +Required properties: > > +- compatible : "pwm-fan" > > +- pwms : the PWM that is used to control the PWM fan > > + > > +Example: > > + pwm-fan { > > + compatible = "pwm-fan"; > > + status = "okay"; > > + pwms = <&pwm 0 1 0>; > > + }; > > diff --git a/Documentation/hwmon/pwm-fan b/Documentation/hwmon/pwm- > fan > > new file mode 100644 index 000..18529d2 > > --- /dev/null > > +++ b/Documentation/hwmon/pwm-fan > > @@ -0,0 +1,17 @@ > > +Kernel driver pwm-fan > > += > > + > > +This driver enables the use of a PWM module to drive a fan. It uses > > +the generic PWM interface thus it is hardware independent. It can be > > +used on many SoCs, as long as the SoC supplies a PWM line driver > that > > +exposes the generic PWM API. > > + > > +Author: Kamil Debski > > + > > +Description > > +--- > > + > > +The driver implements a simple interface for driving a fan connected > > +to a PWM output. It uses the generic PWM interface, thus it can be > > +used with a range of SoCs. The driver exposes the fan to the user > > +space through the hwmon's sysfs interface. > > diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index > > 02d3d85..4ac13ab 100644 > > --- a/drivers/hwmon/Kconfig > > +++ b/drivers/hwmon/Kconfig > > @@ -1105,6 +1105,17 @@ config SENSORS_PCF8591 > > > > source drivers/hwmon/pmbus/Kconfig > > > > +config SENSORS_PWM_FAN > > + tristate "PWM fan" > > + depends on PWM > > + help > &g
[PATCH] phy: phy-samsung-usb2: Change phy power on/power off sequence
The Exynos4412 USB 2.0 PHY hardware differs from the description provided in the documentation. Some register bits have different function. This patch fixes the defines of register bits and changes the way how phys are powered on and off. Signed-off-by: Kamil Debski --- drivers/phy/phy-exynos4x12-usb2.c | 112 + drivers/phy/phy-samsung-usb2.h|3 +- 2 files changed, 77 insertions(+), 38 deletions(-) diff --git a/drivers/phy/phy-exynos4x12-usb2.c b/drivers/phy/phy-exynos4x12-usb2.c index d92a7cc..59d8dd3 100644 --- a/drivers/phy/phy-exynos4x12-usb2.c +++ b/drivers/phy/phy-exynos4x12-usb2.c @@ -86,13 +86,23 @@ #define EXYNOS_4x12_URSTCON_OTG_HLINK BIT(1) #define EXYNOS_4x12_URSTCON_OTG_PHYLINKBIT(2) #define EXYNOS_4x12_URSTCON_HOST_PHY BIT(3) +/* The following bit defines are presented in the + * order taken from the Exynos4412 reference manual. + * + * During experiments with the hardware and debugging + * it was determined that the hardware behaves contrary + * to the manual. + * + * The following bit values were chaned accordingly to the + * results of real hardware experiments. + */ #define EXYNOS_4x12_URSTCON_PHY1 BIT(4) -#define EXYNOS_4x12_URSTCON_HSIC0 BIT(5) -#define EXYNOS_4x12_URSTCON_HSIC1 BIT(6) +#define EXYNOS_4x12_URSTCON_HSIC0 BIT(6) +#define EXYNOS_4x12_URSTCON_HSIC1 BIT(5) #define EXYNOS_4x12_URSTCON_HOST_LINK_ALL BIT(7) -#define EXYNOS_4x12_URSTCON_HOST_LINK_P0 BIT(8) +#define EXYNOS_4x12_URSTCON_HOST_LINK_P0 BIT(10) #define EXYNOS_4x12_URSTCON_HOST_LINK_P1 BIT(9) -#define EXYNOS_4x12_URSTCON_HOST_LINK_P2 BIT(10) +#define EXYNOS_4x12_URSTCON_HOST_LINK_P2 BIT(8) /* Isolation, configured in the power management unit */ #define EXYNOS_4x12_USB_ISOL_OFFSET0x704 @@ -188,6 +198,7 @@ static void exynos4x12_setup_clk(struct samsung_usb2_phy_instance *inst) clk = readl(drv->reg_phy + EXYNOS_4x12_UPHYCLK); clk &= ~EXYNOS_4x12_UPHYCLK_PHYFSEL_MASK; clk |= drv->ref_reg_val << EXYNOS_4x12_UPHYCLK_PHYFSEL_OFFSET; + clk |= EXYNOS_4x12_UPHYCLK_PHY1_COMMON_ON; writel(clk, drv->reg_phy + EXYNOS_4x12_UPHYCLK); } @@ -198,27 +209,22 @@ static void exynos4x12_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) u32 phypwr = 0; u32 rst; u32 pwr; - u32 mode = 0; - u32 switch_mode = 0; switch (inst->cfg->id) { case EXYNOS4x12_DEVICE: phypwr =EXYNOS_4x12_UPHYPWR_PHY0; rstbits = EXYNOS_4x12_URSTCON_PHY0; - mode = EXYNOS_4x12_MODE_SWITCH_DEVICE; - switch_mode = 1; break; case EXYNOS4x12_HOST: phypwr =EXYNOS_4x12_UPHYPWR_PHY1; - rstbits = EXYNOS_4x12_URSTCON_HOST_PHY; - mode = EXYNOS_4x12_MODE_SWITCH_HOST; - switch_mode = 1; + rstbits = EXYNOS_4x12_URSTCON_HOST_PHY | + EXYNOS_4x12_URSTCON_PHY1 | + EXYNOS_4x12_URSTCON_HOST_LINK_P0; break; case EXYNOS4x12_HSIC0: phypwr =EXYNOS_4x12_UPHYPWR_HSIC0; - rstbits = EXYNOS_4x12_URSTCON_HSIC1 | - EXYNOS_4x12_URSTCON_HOST_LINK_P0 | - EXYNOS_4x12_URSTCON_HOST_PHY; + rstbits = EXYNOS_4x12_URSTCON_HSIC0 | + EXYNOS_4x12_URSTCON_HOST_LINK_P1 ; break; case EXYNOS4x12_HSIC1: phypwr =EXYNOS_4x12_UPHYPWR_HSIC1; @@ -228,11 +234,6 @@ static void exynos4x12_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) }; if (on) { - if (switch_mode) - regmap_update_bits(drv->reg_sys, - EXYNOS_4x12_MODE_SWITCH_OFFSET, - EXYNOS_4x12_MODE_SWITCH_MASK, mode); - pwr = readl(drv->reg_phy + EXYNOS_4x12_UPHYPWR); pwr &= ~phypwr; writel(pwr, drv->reg_phy + EXYNOS_4x12_UPHYPWR); @@ -253,41 +254,78 @@ static void exynos4x12_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on) } } -static int exynos4x12_power_on(struct samsung_usb2_phy_instance *inst) +static void exynos4x12_power_on_internal(struct samsung_usb2_phy_instance *inst) { - struct samsung_usb2_phy_driver *drv = inst->drv; + if (inst->int_cnt++ > 0) + return; - inst->enabled = 1; exynos4x12_setup_clk(inst); - exynos4x12_phy_pwr(inst, 1); exynos4x12_isol(inst, 0); + exynos4x12_phy_pwr(inst, 1); +} + +static int exynos4x12_power_on(struct
RE: [PATCH] phy: phy-samsung-usb2: Change phy power on/power off sequence
Hi Daniel, > From: Daniel Drake [mailto:dr...@endlessm.com] > Sent: Tuesday, June 24, 2014 5:09 PM > > On Tue, Jun 24, 2014 at 1:54 PM, Kamil Debski > wrote: > > The Exynos4412 USB 2.0 PHY hardware differs from the description > > provided in the documentation. Some register bits have different > > function. This patch fixes the defines of register bits and changes > > the way how phys are powered on and off. > > I guess this replaces the patch titled "drivers: phy: exynos4x12-phy: > fix HSIC1 power on/off sequence" Yes, indeed it replaces this patch. I did some more research on how the hardware actually behaves. > > Tested on ODROID-U2. Seems to be working as well as the previous patch: Thank you very much for testing. > - Internal SMSC hub works on boot and after reboot, tested with USB > mouse > - Internal SMSC ethernet device works on boot, but disappears upon > reboot. (same as previous patch, also reproduced by Marek) By reboot I guess that you mean typing "reboot" or by using SysRq magic and not power cycling? If so, I had experienced the same symptoms. I guess that the Ethernet chip is not reset properly and fails to enumerate without power cycling (it's nRESET pin is connected to P3V3). I found that removing regulator-always-on from buck8_reg: BUCK8 in the dts file fixes this problem. Best wishes, -- Kamil Debski Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v6 1/8] phy: core: Add an exported of_phy_get function
Previously the of_phy_get function took a struct device * and was declared static. It was impossible to call it from another driver and thus it was impossible to get phy defined for a given node. The old function was renamed to _of_phy_get and was left for internal use. of_phy_get function was added and it was exported. The function enables to get a phy for a given device tree node. Signed-off-by: Kamil Debski --- drivers/phy/phy-core.c | 45 - include/linux/phy/phy.h |6 ++ 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 645c867..a1d4387 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -258,8 +258,8 @@ int phy_power_off(struct phy *phy) EXPORT_SYMBOL_GPL(phy_power_off); /** - * of_phy_get() - lookup and obtain a reference to a phy by phandle - * @dev: device that requests this phy + * _of_phy_get() - lookup and obtain a reference to a phy by phandle + * @np: device_node for which to get the phy * @index: the index of the phy * * Returns the phy associated with the given phandle value, @@ -268,20 +268,17 @@ EXPORT_SYMBOL_GPL(phy_power_off); * not yet loaded. This function uses of_xlate call back function provided * while registering the phy_provider to find the phy instance. */ -static struct phy *of_phy_get(struct device *dev, int index) +static struct phy *_of_phy_get(struct device_node *np, int index) { int ret; struct phy_provider *phy_provider; struct phy *phy = NULL; struct of_phandle_args args; - ret = of_parse_phandle_with_args(dev->of_node, "phys", "#phy-cells", + ret = of_parse_phandle_with_args(np, "phys", "#phy-cells", index, &args); - if (ret) { - dev_dbg(dev, "failed to get phy in %s node\n", - dev->of_node->full_name); + if (ret) return ERR_PTR(-ENODEV); - } mutex_lock(&phy_provider_mutex); phy_provider = of_phy_provider_lookup(args.np); @@ -301,6 +298,36 @@ err0: } /** + * of_phy_get() - lookup and obtain a reference to a phy using a device_node. + * @np: device_node for which to get the phy + * @con_id: name of the phy from device's point of view + * + * Returns the phy driver, after getting a refcount to it; or + * -ENODEV if there is no such phy. The caller is responsible for + * calling phy_put() to release that count. + */ +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + struct phy *phy = NULL; + int index = 0; + + if (con_id) + index = of_property_match_string(np, "phy-names", con_id); + + phy = _of_phy_get(np, index); + if (IS_ERR(phy)) + return phy; + + if (!try_module_get(phy->ops->owner)) + return ERR_PTR(-EPROBE_DEFER); + + get_device(&phy->dev); + + return phy; +} +EXPORT_SYMBOL_GPL(of_phy_get); + +/** * phy_put() - release the PHY * @phy: the phy returned by phy_get() * @@ -388,7 +415,7 @@ struct phy *phy_get(struct device *dev, const char *string) if (dev->of_node) { index = of_property_match_string(dev->of_node, "phy-names", string); - phy = of_phy_get(dev, index); + phy = _of_phy_get(dev->of_node, index); if (IS_ERR(phy)) { dev_err(dev, "unable to find phy\n"); return phy; diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index e273e5a..5cffc69 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -149,6 +149,7 @@ struct phy *phy_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); +struct phy *of_phy_get(struct device_node *np, const char *con_id); struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args); struct phy *phy_create(struct device *dev, const struct phy_ops *ops, @@ -245,6 +246,11 @@ static inline void devm_phy_put(struct device *dev, struct phy *phy) { } +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args) { -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v6 0/8] phy: Add new Exynos USB 2.0 PHY driver
Hi, This is the sixth version of the patchset. It adds a new Exynos USB 2.0 PHY driver. The driver uses the Generic PHY Framework. Again, I would like to thank everyone who commented and read through the fifth version of the patchset. Your input is very much appreciated. The last version had two alternative approaches included. This allowed a comparison between these approaches to the Exynos USB 2.0 PHY driver. The original idea was chosen as it gave the optimal compromise between code readability and size of the driver. These patchset depend on a patch by Leela Krishna Amudala. [PATCH V11 1/3] ARM: dts: Add pmu sysreg node to exynos5250 and exynos5420 dtsi files [1]. Best wishes, Kamil Debski [1] - http://www.spinics.net/lists/linux-samsung-soc/msg24528.html Changes from v5: 1) phy: core: Add an exported of_phy_get function - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the of_phy_get function 2) phy: core: Add devm_of_phy_get to phy-core - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the devm_of_phy_get function 3) dts: Add usb2phy to Exynos 4 - no change 4) dts: Add usb2phy to Exynos 5250 - in the previous version, this patch included some phy-exynos5250-usb2.c code by mistake, the code has been remove and added to the proper patch 5) phy: Add new Exynos USB PHY driver - changed strings from Exynos 4212 to Exynos 4x12, as the Exynos 4212 driver is actually a driver for the whole Exynos 4x12 family - added documentation to the Exynos USB 2.0 PHY driver adaptaion layer - corrected strings HSCI -> HSIC - fixed a problem introduced by previous change - on Exynos 4x12 the HSIC did not work on its own - mode switch support was added to Exynos 4x12 (same io pins are used by host and device) - support for phy_set_bus_width introduced by Matt Porter was added 6) phy: Add support for S5PV210 to the Exynos USB PHY - setting of clk register was fixed 7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - supoprt was added for HSIC and device 8) usb: ehci-exynos: Change to use phy provided by the generic phy framework - DT documentation was moved from usb-ehci.txt to exynos-usb.txt Changes from v4: 1) phy: core: Add an exported of_phy_get function - the new exported function of_phy_get was changed to take the phy's name as a parameter instead of the index 2) phy: core: Add devm_of_phy_get to phy-core - fixes made in the comments to devm_of_phy_get 3) phy: Add new Exynos USB PHY driver - move the documentation from a new to an existing file - samsung-phy.txt - fix typos and uppercase hex addresses - add more explanations to Kconfig (checkpatch still complains, but I find it hard to think what else could I add) - add selects MFD_SYSCON as the driver needs it (Thank you, Tobias!) - cleanup included headers in both *.c and .h files - use BIT(x) macro instead of (1 << x) - replaced HOST and DEV with PHY0 and PHY1 in phy-exynos4212-usb2.c, the registers are described as PHYx in the documentation hence the decision to leave the PHYx naming - fixed typo in exynos4210_rate_to_clk reg -> *reg - change hax_mode_switch and enabled type to bool 4) usb: ehci-s5p: Change to use phy provided by the generic phy framework - Put the issue of phy->otg in order - since the new phy driver does not provide this field. With the new driver the switch between host and device is done in power_on of the respective host and device phys. 5) usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework - fixed the example in the documentation 6) phy: Add support for S5PV210 to the Exynos USB PHY driver - include files cleanup - use BIT(x) macro instead of (1 << x) 7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver - include files cleanup - use BIT(x) macro instead of (1 << x) 8) dts: Add usb2phy to Exynos 4 - no changes 9) dts: Add usb2phy to Exynos 5250 - no changes Changes from v3: - using PMU and system registers indirectly via syscon - change labelling - change Kconfig name - fixed typos/stray whitespace - move of_phy_provider_register() to the end of probe - add a regular error return code to the rate_to_clk functions - cleanup code and remove unused code - change struct names to avoid collisions - add mechanism to support multiple phys by the ehci driver Changes from v2: - rebase all patches to the usb-next branch - fixes in the documentation file - remove wrong entries in the phy node (ranges, and #address- & #size-cells) - add clocks and clock-names as required properites - rephrase a few sentences - fixes in the ehci-exynos.c file - move phy_name variable next to phy in exynos_ehci_hcd - remove otg from exynos_ehci_hcd as it was no longer used - move devm_phy_get after the Exynos5440 skip_phy check - fixes in the s3c-hsotg.c file - cosmetic fixes (remove
[PATCH v6 6/8] phy: Add support for S5PV210 to the Exynos USB PHY driver
From: Mateusz Krawczuk Add support for the Samsung's S5PV210 SoC to the Exynos USB PHY driver. Signed-off-by: Mateusz Krawczuk [k.deb...@samsung.com: cleanup and commit description] [k.deb...@samsung.com: make changes accordingly to the mailing list comments] [k.deb...@samsung.com: fix bug with setting of clk register] Signed-off-by: Kamil Debski --- .../devicetree/bindings/phy/samsung-phy.txt|1 + drivers/phy/Kconfig| 10 + drivers/phy/Makefile |1 + drivers/phy/phy-s5pv210-usb2.c | 199 drivers/phy/phy-samsung-usb2.c |6 + drivers/phy/phy-samsung-usb2.h |1 + 6 files changed, 218 insertions(+) create mode 100644 drivers/phy/phy-s5pv210-usb2.c diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index 6668c41..710d41f 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -26,6 +26,7 @@ Samsung S5P/EXYNOS SoC series USB PHY Required properties: - compatible : should be one of the listed compatibles: + - "samsung,s5pv210-usb2-phy" - "samsung,exynos4210-usb2-phy" - "samsung,exynos4x12-usb2-phy" - reg : a list of registers used by phy driver diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 3691d24..a5554b5 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -73,6 +73,16 @@ config PHY_SAMSUNG_USB2 particular SoCs has to be enabled in addition to this driver. Number and type of supported phys depends on the SoC. +config PHY_S5PV210_USB2 + bool "Support for S5PV210" + depends on PHY_SAMSUNG_USB2 + depends on ARCH_S5PV210 + help + Enable USB PHY support for S5PV210. This option requires that Samsung + USB 2.0 PHY driver is enabled and means that support for this + particular SoC is compiled in the driver. In case of S5PV210 two phys + are available - device and host. + config PHY_EXYNOS4210_USB2 bool "Support for Exynos 4210" depends on PHY_SAMSUNG_USB2 diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 69d0b3f2..d738f65 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -10,5 +10,6 @@ obj-$(CONFIG_PHY_MVEBU_SATA) += phy-mvebu-sata.o obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o +obj-$(CONFIG_PHY_S5PV210_USB2) += phy-s5pv210-usb2.o obj-$(CONFIG_PHY_EXYNOS4210_USB2) += phy-exynos4210-usb2.o obj-$(CONFIG_PHY_EXYNOS4X12_USB2) += phy-exynos4x12-usb2.o diff --git a/drivers/phy/phy-s5pv210-usb2.c b/drivers/phy/phy-s5pv210-usb2.c new file mode 100644 index 000..08e5094 --- /dev/null +++ b/drivers/phy/phy-s5pv210-usb2.c @@ -0,0 +1,199 @@ +/* + * Samsung SoC USB 1.1/2.0 PHY driver - S5PV210 support + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Authors: Kamil Debski + * + * 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 +#include +#include +#include "phy-samsung-usb2.h" + +/* Exynos USB PHY registers */ + +/* PHY power control */ +#define S5PV210_UPHYPWR0x0 + +#define S5PV210_UPHYPWR_PHY0_SUSPEND BIT(0) +#define S5PV210_UPHYPWR_PHY0_PWR BIT(3) +#define S5PV210_UPHYPWR_PHY0_OTG_PWR BIT(4) +#define S5PV210_UPHYPWR_PHY0 ( \ + S5PV210_UPHYPWR_PHY0_SUSPEND | \ + S5PV210_UPHYPWR_PHY0_PWR | \ + S5PV210_UPHYPWR_PHY0_OTG_PWR) + +#define S5PV210_UPHYPWR_PHY1_SUSPEND BIT(6) +#define S5PV210_UPHYPWR_PHY1_PWR BIT(7) +#define S5PV210_UPHYPWR_PHY1 ( \ + S5PV210_UPHYPWR_PHY1_SUSPEND | \ + S5PV210_UPHYPWR_PHY1_PWR) + +/* PHY clock control */ +#define S5PV210_UPHYCLK0x4 + +#define S5PV210_UPHYCLK_PHYFSEL_MASK (0x3 << 0) +#define S5PV210_UPHYCLK_PHYFSEL_48MHZ (0x0 << 0) +#define S5PV210_UPHYCLK_PHYFSEL_24MHZ (0x3 << 0) +#define S5PV210_UPHYCLK_PHYFSEL_12MHZ (0x2 << 0) + +#define S5PV210_UPHYCLK_PHY0_ID_PULLUP BIT(2) +#define S5PV210_UPHYCLK_PHY0_COMMON_ON BIT(4) +#define S5PV210_UPHYCLK_PHY1_COMMON_ON BIT(7) + +/* PHY reset control */ +#define S5PV210_UPHYRST0x8 + +#define S5PV210_URSTCON_PHY0 BIT(0) +#define S5PV210_URSTCON_OTG_HLINK BIT(1) +#define S5PV210_URSTCON_OTG_PHYLINKBIT(2) +#define S5PV210_URSTCON_PHY1_ALL BIT(3) +#define S5PV210_URSTCON_HOST_LINK_ALL BIT(4) + +/* Isolation, configured in the power management unit */ +#define S5PV210_USB
[PATCH v6 5/8] phy: Add new Exynos USB PHY driver
Add a new driver for the Exynos USB PHY. The new driver uses the generic PHY framework. The driver includes support for the Exynos 4x10 and 4x12 SoC families. Signed-off-by: Kamil Debski --- .../devicetree/bindings/phy/samsung-phy.txt| 55 Documentation/phy/samsung-usb2.txt | 135 drivers/phy/Kconfig| 29 ++ drivers/phy/Makefile |3 + drivers/phy/phy-exynos4210-usb2.c | 257 drivers/phy/phy-exynos4x12-usb2.c | 323 drivers/phy/phy-samsung-usb2.c | 227 ++ drivers/phy/phy-samsung-usb2.h | 67 8 files changed, 1096 insertions(+) create mode 100644 Documentation/phy/samsung-usb2.txt create mode 100644 drivers/phy/phy-exynos4210-usb2.c create mode 100644 drivers/phy/phy-exynos4x12-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.h diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index c0fccaa..6668c41 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -20,3 +20,58 @@ Required properties: - compatible : should be "samsung,exynos5250-dp-video-phy"; - reg : offset and length of the Display Port PHY register set; - #phy-cells : from the generic PHY bindings, must be 0; + +Samsung S5P/EXYNOS SoC series USB PHY +- + +Required properties: +- compatible : should be one of the listed compatibles: + - "samsung,exynos4210-usb2-phy" + - "samsung,exynos4x12-usb2-phy" +- reg : a list of registers used by phy driver + - first and obligatory is the location of phy modules registers +- samsung,sysreg-phandle - handle to syscon used to control the system registers +- samsung,pmureg-phandle - handle to syscon used to control PMU registers +- #phy-cells : from the generic phy bindings, must be 1; +- clocks and clock-names: + - the "phy" clocks is required by the phy module + - next for each of the phys a clock has to be assigned, this clock + will be used to determine clocking frequency for the phys + (the labels are specified in the paragraph below) + +The first phandle argument in the PHY specifier identifies the PHY, its +meaning is compatible dependent. For the currently supported SoCs (Exynos 4210 +and Exynos 4212) it is as follows: + 0 - USB device ("device"), + 1 - USB host ("host"), + 2 - HSIC0 ("hsic0"), + 3 - HSIC1 ("hsic1"), + +Exynos 4210 and Exynos 4212 use mode switching and require that mode switch +register is supplied. + +Example: + +For Exynos 4412 (compatible with Exynos 4212): + +usbphy: phy@125b { + compatible = "samsung,exynos4212-usb2-phy"; + reg = <0x125b 0x100 0x10020704 0x0c 0x1001021c 0x4>; + clocks = <&clock 305>, <&clock 2>, <&clock 2>, <&clock 2>, + <&clock 2>; + clock-names = "phy", "device", "host", "hsic0", "hsic1"; + status = "okay"; + #phy-cells = <1>; + samsung,sysreg-phandle = <&sys_reg>; + samsung,pmureg-phandle = <&pmu_reg>; +}; + +Then the PHY can be used in other nodes such as: + +phy-consumer@1234 { + phys = <&usbphy 2>; + phy-names = "phy"; +}; + +Refer to DT bindings documentation of particular PHY consumer devices for more +information about required PHYs and the way of specification. diff --git a/Documentation/phy/samsung-usb2.txt b/Documentation/phy/samsung-usb2.txt new file mode 100644 index 000..9f5826e --- /dev/null +++ b/Documentation/phy/samsung-usb2.txt @@ -0,0 +1,135 @@ +.--+ +| Samsung USB 2.0 PHY adaptation layer | ++-+' + +| 1. Description ++ + +The architecture of the USB 2.0 PHY module in Samsung SoCs is similar +among many SoCs. In spite of the similarities it proved difficult to +create a one driver that would fit all these PHY controllers. Often +the differences were minor and were found in particular bits of the +registers of the PHY. In some rare cases the order of register writes or +the PHY powering up process had to be altered. This adaptation layer is +a compromise between having separate drivers and having a single driver +with added support for many special cases. + +| 2. Files description ++-- + +- p
[PATCH v6 4/8] dts: Add usb2phy to Exynos 5250
Add support to PHY of USB2 of the Exynos 5250 SoC. Signed-off-by: Kamil Debski --- arch/arm/boot/dts/exynos5250.dtsi | 24 1 file changed, 24 insertions(+) diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi index c4480a1..efeaf87 100644 --- a/arch/arm/boot/dts/exynos5250.dtsi +++ b/arch/arm/boot/dts/exynos5250.dtsi @@ -163,6 +163,11 @@ interrupts = <0 47 0>; }; + sys_syscon: syscon@1004 { + compatible = "samsung,exynos5250-sys", "syscon"; + reg = <0x1005 0x5000>; + }; + pmu_syscon: syscon@1004 { compatible = "samsung,exynos5250-pmu", "syscon"; reg = <0x1004 0x5000>; @@ -505,6 +510,14 @@ clocks = <&clock 285>; clock-names = "usbhost"; + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + phys = <&usb2_phy_new 1>; + phy-names = "host"; + status = "ok"; + }; }; usb@1212 { @@ -531,6 +544,17 @@ }; }; + usb2_phy_new: phy@1213 { + compatible = "samsung,exynos5250-usb2-phy"; + reg = <0x1213 0x100>; + clocks = <&clock 285>, <&clock 1>, <&clock 1>, <&clock 1>, + <&clock 1>; + clock-names = "phy", "device", "host", "hsic0", "hsic1"; + #phy-cells = <1>; + samsung,sysreg-phandle = <&sys_syscon>; + samsung,pmureg-phandle = <&pmu_syscon>; + }; + amba { #address-cells = <1>; #size-cells = <1>; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v6 3/8] dts: Add usb2phy to Exynos 4
Add support to PHY of USB2 of the Exynos 4 SoC. Signed-off-by: Kamil Debski --- .../devicetree/bindings/arm/samsung/pmu.txt|2 ++ arch/arm/boot/dts/exynos4.dtsi | 31 arch/arm/boot/dts/exynos4210.dtsi | 17 +++ arch/arm/boot/dts/exynos4x12.dtsi | 17 +++ 4 files changed, 67 insertions(+) diff --git a/Documentation/devicetree/bindings/arm/samsung/pmu.txt b/Documentation/devicetree/bindings/arm/samsung/pmu.txt index 307e727..a76f91d 100644 --- a/Documentation/devicetree/bindings/arm/samsung/pmu.txt +++ b/Documentation/devicetree/bindings/arm/samsung/pmu.txt @@ -3,6 +3,8 @@ SAMSUNG Exynos SoC series PMU Registers Properties: - name : should be 'syscon'; - compatible : should contain two values. First value must be one from following list: + - "samsung,exynos4210-pmu" - for Exynos4210 SoC, + - "samsung,exynos4x12-pmu" - for Exynos4212 SoC, - "samsung,exynos5250-pmu" - for Exynos5250 SoC, - "samsung,exynos5420-pmu" - for Exynos5420 SoC. second value must be always "syscon". diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi index a73eeb5..031d07a 100644 --- a/arch/arm/boot/dts/exynos4.dtsi +++ b/arch/arm/boot/dts/exynos4.dtsi @@ -253,6 +253,17 @@ status = "disabled"; }; + usbotg@1248 { + compatible = "samsung,s3c6400-hsotg"; + reg = <0x1248 0x2>; + interrupts = <0 71 0>; + clocks = <&clock 305>; + clock-names = "otg"; + phys = <&usb2phy 0>; + phy-names = "usb2-phy"; + status = "disabled"; + }; + ehci@1258 { compatible = "samsung,exynos4210-ehci"; reg = <0x1258 0x100>; @@ -260,6 +271,26 @@ clocks = <&clock 304>; clock-names = "usbhost"; status = "disabled"; + #address-cells = <1>; + #size-cells = <0>; + port@0 { + phys = <&usb2phy 1>; + phy-names = "host"; + reg = <0>; + status = "disabled"; + }; + port@1 { + phys = <&usb2phy 2>; + phy-names = "hsic0"; + reg = <1>; + status = "disabled"; + }; + port@2 { + phys = <&usb2phy 3>; + phy-names = "hsic1"; + reg = <2>; + status = "disabled"; + }; }; ohci@1259 { diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi index 057d682..f9d06bb 100644 --- a/arch/arm/boot/dts/exynos4210.dtsi +++ b/arch/arm/boot/dts/exynos4210.dtsi @@ -155,4 +155,21 @@ samsung,lcd-wb; }; }; + + pmu_reg: syscon@1002 { + compatible = "samsung,exynos4210-pmu", "syscon"; + reg = <0x1002 0x4000>; + }; + + usb2phy: phy@125B { + compatible = "samsung,exynos4210-usb2-phy"; + reg = <0x125B 0x100>; + clocks = <&clock 305>, <&clock 2>, <&clock 2>, <&clock 2>, + <&clock 2>; + clock-names = "phy", "device", "host", "hsic0", "hsic1"; + status = "disabled"; + #phy-cells = <1>; + samsung,sysreg-phandle = <&sys_reg>; + samsung,pmureg-phandle = <&pmu_reg>; + }; }; diff --git a/arch/arm/boot/dts/exynos4x12.dtsi b/arch/arm/boot/dts/exynos4x12.dtsi index ad531fe..63b0fe5 100644 --- a/arch/arm/boot/dts/exynos4x12.dtsi +++ b/arch/arm/boot/dts/exynos4x12.dtsi @@ -176,4 +176,21 @@ }; }; }; + + pmu_reg: syscon@1002 { + compatible = "samsung,exynos4x12-pmu", "syscon"; + reg = <0x1002 0x4000>; + }; + + usb2phy: phy@125B { + compatible = "samsung,exynos4x12-usb2-phy"; + reg = <0x125B 0x100>; + clocks = <&clock 305>, <&clock 2>, <&clock
[PATCH v6 2/8] phy: core: Add devm_of_phy_get to phy-core
Adding devm_of_phy_get will allow to get phys by supplying a pointer to the struct device_node instead of struct device. Signed-off-by: Kamil Debski --- drivers/phy/phy-core.c | 31 +++ include/linux/phy/phy.h |8 2 files changed, 39 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index a1d4387..6e32fb0 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -468,6 +468,37 @@ struct phy *devm_phy_get(struct device *dev, const char *string) EXPORT_SYMBOL_GPL(devm_phy_get); /** + * devm_of_phy_get() - lookup and obtain a reference to a phy. + * @dev: device that requests this phy + * @np: node containing the phy + * @con_id: name of the phy from device's point of view + * + * Gets the phy using of_phy_get(), and associates a device with it using + * devres. On driver detach, release function is invoked on the devres data, + * then, devres data is freed. + */ +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + struct phy **ptr, *phy; + + ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + phy = of_phy_get(np, con_id); + if (!IS_ERR(phy)) { + *ptr = phy; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return phy; +} +EXPORT_SYMBOL_GPL(devm_of_phy_get); + +/** * phy_create() - create a new phy * @dev: device that is creating the new phy * @ops: function pointers for performing phy operations diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 5cffc69..b17d6d2 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -147,6 +147,8 @@ static inline void phy_set_bus_width(struct phy *phy, int bus_width) } struct phy *phy_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); struct phy *of_phy_get(struct device_node *np, const char *con_id); @@ -238,6 +240,12 @@ static inline struct phy *devm_phy_get(struct device *dev, const char *string) return ERR_PTR(-ENOSYS); } +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline void phy_put(struct phy *phy) { } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v6 8/8] usb: ehci-exynos: Change to use phy provided by the generic phy framework
Change the phy provider used from the old one using the USB phy framework to a new one using the Generic phy framework. Signed-off-by: Kamil Debski --- .../devicetree/bindings/usb/exynos-usb.txt | 13 +++ drivers/usb/host/ehci-exynos.c | 97 +--- 2 files changed, 76 insertions(+), 34 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/exynos-usb.txt b/Documentation/devicetree/bindings/usb/exynos-usb.txt index d967ba1..25e199a 100644 --- a/Documentation/devicetree/bindings/usb/exynos-usb.txt +++ b/Documentation/devicetree/bindings/usb/exynos-usb.txt @@ -12,6 +12,10 @@ Required properties: - interrupts: interrupt number to the cpu. - clocks: from common clock binding: handle to usb clock. - clock-names: from common clock binding: Shall be "usbhost". + - port: if in the SoC there are EHCI phys, they should be listed here. +One phy per port. Each port should have its reg entry with a consecutive +number. Also it should contain phys and phy-names entries specifying the +phy used by the port. Optional properties: - samsung,vbus-gpio: if present, specifies the GPIO that @@ -27,6 +31,15 @@ Example: clocks = <&clock 285>; clock-names = "usbhost"; + + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + phys = <&usb2phy 1>; + phy-names = "host"; + status = "disabled"; + }; }; OHCI diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index d1d8c47..7c35501 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -19,12 +19,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include "ehci.h" @@ -42,10 +42,10 @@ static const char hcd_name[] = "ehci-exynos"; static struct hc_driver __read_mostly exynos_ehci_hc_driver; +#define PHY_NUMBER 3 struct exynos_ehci_hcd { struct clk *clk; - struct usb_phy *phy; - struct usb_otg *otg; + struct phy *phy[PHY_NUMBER]; }; #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd *)(hcd_to_ehci(hcd)->priv) @@ -69,13 +69,43 @@ static void exynos_setup_vbus_gpio(struct platform_device *pdev) dev_err(dev, "can't request ehci vbus gpio %d", gpio); } +static int exynos_phys_on(struct phy *p[]) +{ + int i; + int ret = 0; + + for (i = 0; ret == 0 && i < PHY_NUMBER; i++) + if (p[i]) + ret = phy_power_on(p[i]); + if (ret) + for (i--; i > 0; i--) + if (p[i]) + phy_power_off(p[i]); + + return ret; +} + +static int exynos_phys_off(struct phy *p[]) +{ + int i; + int ret = 0; + + for (i = 0; ret == 0 && i < PHY_NUMBER; i++) + if (p[i]) + ret = phy_power_off(p[i]); + + return ret; +} + static int exynos_ehci_probe(struct platform_device *pdev) { struct exynos_ehci_hcd *exynos_ehci; struct usb_hcd *hcd; struct ehci_hcd *ehci; struct resource *res; - struct usb_phy *phy; + struct phy *phy; + struct device_node *child; + int phy_number; int irq; int err; @@ -102,14 +132,26 @@ static int exynos_ehci_probe(struct platform_device *pdev) "samsung,exynos5440-ehci")) goto skip_phy; - phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); - if (IS_ERR(phy)) { - usb_put_hcd(hcd); - dev_warn(&pdev->dev, "no platform data or transceiver defined\n"); - return -EPROBE_DEFER; - } else { - exynos_ehci->phy = phy; - exynos_ehci->otg = phy->otg; + for_each_available_child_of_node(pdev->dev.of_node, child) { + err = of_property_read_u32(child, "reg", &phy_number); + if (err) { + dev_err(&pdev->dev, "Failed to parse device tree\n"); + of_node_put(child); + return err; + } + if (phy_number >= PHY_NUMBER) { + dev_err(&pdev->dev, "Failed to parse device tree - number out of range\n"); + of_node_put(child); + return -EINVAL; + } + phy = devm_of_phy_get(&pdev->dev, child, 0); + of_node_put(child); + if (IS_ERR(phy)) { + dev_err(&pdev->dev, "Failed to get phy
[PATCH v6 7/8] phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver
Add support for Exynos 5250. This driver is to replace the old USB 2.0 PHY driver. Signed-off-by: Kamil Debski --- .../devicetree/bindings/phy/samsung-phy.txt|1 + drivers/phy/Kconfig| 11 + drivers/phy/Makefile |1 + drivers/phy/phy-exynos5250-usb2.c | 406 drivers/phy/phy-samsung-usb2.c |6 + drivers/phy/phy-samsung-usb2.h |1 + 6 files changed, 426 insertions(+) create mode 100644 drivers/phy/phy-exynos5250-usb2.c diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index 710d41f..d1b534f 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -29,6 +29,7 @@ Required properties: - "samsung,s5pv210-usb2-phy" - "samsung,exynos4210-usb2-phy" - "samsung,exynos4x12-usb2-phy" + - "samsung,exynos5250-usb2-phy" - reg : a list of registers used by phy driver - first and obligatory is the location of phy modules registers - samsung,sysreg-phandle - handle to syscon used to control the system registers diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index a5554b5..645ed66 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -102,4 +102,15 @@ config PHY_EXYNOS4X12_USB2 Samsung USB 2.0 PHY driver is enabled and means that support for this particular SoC is compiled in the driver. In case of Exynos 4x12 four phys are available - device, host, HSIC0 and HSIC1. + +config PHY_EXYNOS5250_USB2 + bool "Support for Exynos 5250" + depends on PHY_SAMSUNG_USB2 + depends on SOC_EXYNOS5250 + help + Enable USB PHY support for Exynos 5250. This option requires that + Samsung USB 2.0 PHY driver is enabled and means that support for this + particular SoC is compiled in the driver. In case of Exynos 5250 four + phys are available - device, host, HSIC0 and HSIC. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index d738f65..fe7aaee 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -13,3 +13,4 @@ obj-$(CONFIG_PHY_SAMSUNG_USB2)+= phy-samsung-usb2.o obj-$(CONFIG_PHY_S5PV210_USB2) += phy-s5pv210-usb2.o obj-$(CONFIG_PHY_EXYNOS4210_USB2) += phy-exynos4210-usb2.o obj-$(CONFIG_PHY_EXYNOS4X12_USB2) += phy-exynos4x12-usb2.o +obj-$(CONFIG_PHY_EXYNOS5250_USB2) += phy-exynos5250-usb2.o diff --git a/drivers/phy/phy-exynos5250-usb2.c b/drivers/phy/phy-exynos5250-usb2.c new file mode 100644 index 000..2603d5e --- /dev/null +++ b/drivers/phy/phy-exynos5250-usb2.c @@ -0,0 +1,406 @@ +/* + * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 5250 support + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Kamil Debski + * + * 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 +#include +#include +#include +#include "phy-samsung-usb2.h" + +/* Exynos USB PHY registers */ +#define EXYNOS_5250_REFCLKSEL_CRYSTAL 0x0 +#define EXYNOS_5250_REFCLKSEL_XO 0x1 +#define EXYNOS_5250_REFCLKSEL_CLKCORE 0x2 + +#define EXYNOS_5250_FSEL_9MHZ6 0x0 +#define EXYNOS_5250_FSEL_10MHZ 0x1 +#define EXYNOS_5250_FSEL_12MHZ 0x2 +#define EXYNOS_5250_FSEL_19MHZ20x3 +#define EXYNOS_5250_FSEL_20MHZ 0x4 +#define EXYNOS_5250_FSEL_24MHZ 0x5 +#define EXYNOS_5250_FSEL_50MHZ 0x7 + +/* Normal host */ +#define EXYNOS_5250_HOSTPHYCTRL0 0x0 + +#define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRSTALL BIT(31) +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT 19 +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_MASK\ + (0x3 << EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT16 +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_MASK \ + (0x7 << EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_TESTBURNINBIT(11) +#define EXYNOS_5250_HOSTPHYCTRL0_RETENABLE BIT(10) +#define EXYNOS_5250_HOSTPHYCTRL0_COMMON_ON_N BIT(9) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_MASK(0x3 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_DUAL(0x0 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ID0 (0x1 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ANALOGTEST (0x2 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_SIDDQ BIT(6) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESLEEPBIT(5) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESUSPEND BIT(4) +#define E
RE: [PATCH v2 1/2] drivers/media: v4l2: Add settings for Horizontal and Vertical MV Search Range
; + *type = V4L2_CTRL_TYPE_INTEGER; > > + *min = 16; > > + *max = 128; > > + *step = 16; > > + break; > > case V4L2_CID_PAN_RESET: > > case V4L2_CID_TILT_RESET: > > case V4L2_CID_FLASH_STROBE: > > diff --git a/include/uapi/linux/v4l2-controls.h > > b/include/uapi/linux/v4l2-controls.h > > index 1666aab..80e1def 100644 > > --- a/include/uapi/linux/v4l2-controls.h > > +++ b/include/uapi/linux/v4l2-controls.h > > @@ -372,6 +372,8 @@ enum v4l2_mpeg_video_multi_slice_mode { > > #define V4L2_CID_MPEG_VIDEO_DEC_FRAME > (V4L2_CID_MPEG_BASE+224) > > #define V4L2_CID_MPEG_VIDEO_VBV_DELAY > (V4L2_CID_MPEG_BASE+225) > > #define V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER > (V4L2_CID_MPEG_BASE+226) > > +#define V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE > (V4L2_CID_MPEG_BASE+227) > > +#define V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE > (V4L2_CID_MPEG_BASE+228) > > > > #define V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP > (V4L2_CID_MPEG_BASE+300) > > #define V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP > (V4L2_CID_MPEG_BASE+301) > > > > Regards, > > Hans Best wishes, -- Kamil Debski Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH v6 3/8] dts: Add usb2phy to Exynos 4
Hi Olof, > From: Olof Johansson [mailto:o...@lixom.net] > Sent: Wednesday, January 29, 2014 9:51 PM > > On Wed, Jan 29, 2014 at 9:29 AM, Kamil Debski > wrote: > > Add support to PHY of USB2 of the Exynos 4 SoC. > > > > Signed-off-by: Kamil Debski > > --- > > .../devicetree/bindings/arm/samsung/pmu.txt|2 ++ > > arch/arm/boot/dts/exynos4.dtsi | 31 > > > arch/arm/boot/dts/exynos4210.dtsi | 17 > +++ > > arch/arm/boot/dts/exynos4x12.dtsi | 17 > +++ > > 4 files changed, 67 insertions(+) > > > > diff --git a/Documentation/devicetree/bindings/arm/samsung/pmu.txt > > b/Documentation/devicetree/bindings/arm/samsung/pmu.txt > > index 307e727..a76f91d 100644 > > --- a/Documentation/devicetree/bindings/arm/samsung/pmu.txt > > +++ b/Documentation/devicetree/bindings/arm/samsung/pmu.txt > > @@ -3,6 +3,8 @@ SAMSUNG Exynos SoC series PMU Registers > > Properties: > > - name : should be 'syscon'; > > - compatible : should contain two values. First value must be one > from following list: > > + - "samsung,exynos4210-pmu" - for Exynos4210 SoC, > > + - "samsung,exynos4x12-pmu" - for Exynos4212 SoC, > >- "samsung,exynos5250-pmu" - for Exynos5250 SoC, > >- "samsung,exynos5420-pmu" - for Exynos5420 SoC. > > second value must be always "syscon". > > This and other PMU related bindings/dts changes should probably go in > separate patch(es) instead of being snuck in with USB changes. O, I will move this to a separate patch. Best wishes, -- Kamil Debski Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH v6 8/8] usb: ehci-exynos: Change to use phy provided by the generic phy framework
Hi Olof, Thank you for your review. > From: Olof Johansson [mailto:o...@lixom.net] > Sent: Wednesday, January 29, 2014 9:55 PM > > Hi, > > On Wed, Jan 29, 2014 at 9:29 AM, Kamil Debski > wrote: > > Change the phy provider used from the old one using the USB phy > > framework to a new one using the Generic phy framework. > > > > Signed-off-by: Kamil Debski > > --- > > .../devicetree/bindings/usb/exynos-usb.txt | 13 +++ > > drivers/usb/host/ehci-exynos.c | 97 > +--- > > 2 files changed, 76 insertions(+), 34 deletions(-) > > > > diff --git a/Documentation/devicetree/bindings/usb/exynos-usb.txt > > b/Documentation/devicetree/bindings/usb/exynos-usb.txt > > index d967ba1..25e199a 100644 > > --- a/Documentation/devicetree/bindings/usb/exynos-usb.txt > > +++ b/Documentation/devicetree/bindings/usb/exynos-usb.txt > > @@ -12,6 +12,10 @@ Required properties: > > - interrupts: interrupt number to the cpu. > > - clocks: from common clock binding: handle to usb clock. > > - clock-names: from common clock binding: Shall be "usbhost". > > + - port: if in the SoC there are EHCI phys, they should be listed > here. > > +One phy per port. Each port should have its reg entry with a > > +consecutive number. Also it should contain phys and phy-names > entries > > +specifying the phy used by the port. > > > > Optional properties: > > - samsung,vbus-gpio: if present, specifies the GPIO that @@ -27,6 > > +31,15 @@ Example: > > > > clocks = <&clock 285>; > > clock-names = "usbhost"; > > + > > + #address-cells = <1>; > > + #size-cells = <0>; > > + port@0 { > > + reg = <0>; > > + phys = <&usb2phy 1>; > > + phy-names = "host"; > > + status = "disabled"; > > + }; > > }; > > > > OHCI > > [...] > > > @@ -102,14 +132,26 @@ static int exynos_ehci_probe(struct > platform_device *pdev) > > "samsung,exynos5440-ehci")) > > goto skip_phy; > > > > - phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); > > - if (IS_ERR(phy)) { > > - usb_put_hcd(hcd); > > - dev_warn(&pdev->dev, "no platform data or transceiver > defined\n"); > > - return -EPROBE_DEFER; > > - } else { > > - exynos_ehci->phy = phy; > > - exynos_ehci->otg = phy->otg; > > + for_each_available_child_of_node(pdev->dev.of_node, child) { > > + err = of_property_read_u32(child, "reg", > &phy_number); > > + if (err) { > > + dev_err(&pdev->dev, "Failed to parse device > tree\n"); > > + of_node_put(child); > > + return err; > > + } > > + if (phy_number >= PHY_NUMBER) { > > + dev_err(&pdev->dev, "Failed to parse device > tree - number out of range\n"); > > + of_node_put(child); > > + return -EINVAL; > > + } > > + phy = devm_of_phy_get(&pdev->dev, child, 0); > > + of_node_put(child); > > + if (IS_ERR(phy)) { > > + dev_err(&pdev->dev, "Failed to get phy number > %d", > > + > phy_number); > > + return PTR_ERR(phy); > > + } > > + exynos_ehci->phy[phy_number] = phy; > > this looks like it is now breaking older device trees, where ports > might not be described. Since device tree interfaces need to be > backwards compatible, you still need to handle the old case of not > having ports described. > > There are two ways of doing this: > > 1. Fall back to the old behavior if there are no ports 2. Use a new > compatible value for the new model with port subnodes, and if the old > compatible value is used, then fall back to the old behavior. > > I'm guessing (1) might be easiest since you can check for the presence > of #address-cells to tell if this is just an old style node, or if it's > a new-style node without any ports below it. The ultimate goal is to remove the old phy driver. Unfortunately this has to be synced with the new USB3 phy driver by Vivek Gautam. I think he is also close to completion. What about this case? In the end the old driver will be removed and no longer be supported. Having backward compatibility in mind, it is possible to have the old and the new phy driver together in one kernel release. But do we want to have two drivers doing the same thing at the same time? Best wishes, -- Kamil Debski Samsung R&D Institute Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [PATCH v6 8/8] usb: ehci-exynos: Change to use phy provided by the generic phy framework
Hi Alan, Thank you for your review. > From: Alan Stern [mailto:st...@rowland.harvard.edu] > Sent: Wednesday, January 29, 2014 9:43 PM > > On Wed, 29 Jan 2014, Kamil Debski wrote: > > > Change the phy provider used from the old one using the USB phy > > framework to a new one using the Generic phy framework. > > > > Signed-off-by: Kamil Debski > > --- > > .../devicetree/bindings/usb/exynos-usb.txt | 13 +++ > > drivers/usb/host/ehci-exynos.c | 97 > +--- > > 2 files changed, 76 insertions(+), 34 deletions(-) > > > > diff --git a/Documentation/devicetree/bindings/usb/exynos-usb.txt > > b/Documentation/devicetree/bindings/usb/exynos-usb.txt > > index d967ba1..25e199a 100644 > > --- a/Documentation/devicetree/bindings/usb/exynos-usb.txt > > +++ b/Documentation/devicetree/bindings/usb/exynos-usb.txt > > @@ -12,6 +12,10 @@ Required properties: > > - interrupts: interrupt number to the cpu. > > - clocks: from common clock binding: handle to usb clock. > > - clock-names: from common clock binding: Shall be "usbhost". > > + - port: if in the SoC there are EHCI phys, they should be listed > here. > > +One phy per port. Each port should have its reg entry with a > > +consecutive number. Also it should contain phys and phy-names > entries > > +specifying the phy used by the port. > > What is the reg entry number used for? As far as I can see, it isn't > used for anything. In which case, why have it at all? Tomasz Figa already commented this. I agree with him, that this should be better described in the documentation. > > > @@ -42,10 +42,10 @@ > > static const char hcd_name[] = "ehci-exynos"; static struct > > hc_driver __read_mostly exynos_ehci_hc_driver; > > > > +#define PHY_NUMBER 3 > > struct exynos_ehci_hcd { > > struct clk *clk; > > - struct usb_phy *phy; > > - struct usb_otg *otg; > > You have removed all the OTG stuff from the driver. This wasn't > mentioned in the patch description, and it has no connection with the > PHY work. Maybe I'll explain more about what are we trying to achieve. The goal is to replace the old phy driver with the new one. In the old driver it was difficult to add support to new SoC. It also had issues with having device and host working together. You're right that until the old phy driver is removed support for the it should remain. To be able to remove the old driver both new USB2 and new USB3 phy drivers have to be ready. The USB3 driver is written by Vivek Gautam and as I see it, he is also close to completion. Regarding the otg part. The old phy driver is the only provider of the otg structure. It sets the host field of the structure. It is then used by samsung_usb2phy_init (drivers/usb/phy/phy-samsung-usb2.c) to check which driver is requesting the phy (is it host or device). In the new driver this is determined by the entry in device tree. So no need to check the otg struct and strstr (!) to check if dev_name is ehci, ohci or other, like the old driver. > > + struct phy *phy[PHY_NUMBER]; > > }; > > > > #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd > > *)(hcd_to_ehci(hcd)->priv) @@ -69,13 +69,43 @@ static void > exynos_setup_vbus_gpio(struct platform_device *pdev) > > dev_err(dev, "can't request ehci vbus gpio %d", gpio); } > > > > +static int exynos_phys_on(struct phy *p[]) { > > + int i; > > + int ret = 0; > > + > > + for (i = 0; ret == 0 && i < PHY_NUMBER; i++) > > + if (p[i]) > > + ret = phy_power_on(p[i]); > > + if (ret) > > + for (i--; i > 0; i--) > > + if (p[i]) > > + phy_power_off(p[i]); > > This loop runs while i > 0. Therefore you will never turn off the > power to p[0]. Ups, my bad. Thank you for spotting this. > > > @@ -102,14 +132,26 @@ static int exynos_ehci_probe(struct > platform_device *pdev) > > "samsung,exynos5440-ehci")) > > goto skip_phy; > > > > - phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); > > - if (IS_ERR(phy)) { > > - usb_put_hcd(hcd); > > You omitted this line from the new error returns below. I see. > > > - dev_warn(&pdev->dev, "no platform data or transceiver > defined\n"); > > - return -EPROBE_DEFER; > > - } else { > > - exynos_ehci->phy = phy; > > - exynos_ehci->otg = phy->otg; > &
RE: [PATCH v4 3/9] phy: Add new Exynos USB PHY driver
Hi, > From: Kishon Vijay Abraham I [mailto:kis...@ti.com] > Sent: Monday, December 09, 2013 8:56 AM > > Hi, > > On Friday 06 December 2013 09:58 PM, Kamil Debski wrote: > > Hi Kishon, > > > > Thank you for the review. > > > >> From: Kishon Vijay Abraham I [mailto:kis...@ti.com] > >> Sent: Friday, December 06, 2013 11:59 AM > >> > >> Hi, > >> > >> On Thursday 05 December 2013 05:59 PM, Kamil Debski wrote: > >>> Add a new driver for the Exynos USB PHY. The new driver uses the > >>> generic PHY framework. The driver includes support for the Exynos > >> 4x10 > >>> and 4x12 SoC families. > >>> > >>> Signed-off-by: Kamil Debski > >>> Signed-off-by: Kyungmin Park > >>> --- > > > > . > . > >>> diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index > >>> d0caae9..9f4befd 100644 > >>> --- a/drivers/phy/Makefile > >>> +++ b/drivers/phy/Makefile > >>> @@ -7,3 +7,6 @@ obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO) += phy- > exynos-dp- > >> video.o > >>> obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO) += phy-exynos-mipi- > video.o > >>> obj-$(CONFIG_OMAP_USB2) += phy-omap-usb2.o > >>> obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o > >>> +obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o > >>> +obj-$(CONFIG_PHY_EXYNOS4210_USB2)+= phy-exynos4210-usb2.o > >>> +obj-$(CONFIG_PHY_EXYNOS4212_USB2)+= phy-exynos4212-usb2.o > >>> diff --git a/drivers/phy/phy-exynos4210-usb2.c > >>> b/drivers/phy/phy-exynos4210-usb2.c > >>> new file mode 100644 > >>> index 000..a02e5c2 > >>> --- /dev/null > >>> +++ b/drivers/phy/phy-exynos4210-usb2.c > >>> @@ -0,0 +1,264 @@ > >>> +/* > >>> + * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 4210 support > >>> + * > >>> + * Copyright (C) 2013 Samsung Electronics Co., Ltd. > >>> + * Author: Kamil Debski > >>> + * > >>> + * 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 > >>> +#include > >>> +#include > >>> +#include > >>> +#include > >>> +#include > >>> +#include > >>> +#include > >>> +#include > >>> +#include > >>> +#include > >> > >> You've included most of the above header files in phy-samsung-usb2.h > >> which you are including below. > > > > I agree that includes in phy-samsung-usb2.h could use a cleanup. On > > the other hand my opinion is that a .c file should include all .h > > files that are used in this .c file. Relaying on .h file to include > > another .h doesn't seem good to me. > > then remove it in .h file. > > > >>> +#include "phy-samsung-usb2.h" > >>> + > >>> +/* Exynos USB PHY registers */ > >>> + > >>> +/* PHY power control */ > >>> +#define EXYNOS_4210_UPHYPWR 0x0 > >>> + > >>> +#define EXYNOS_4210_UPHYPWR_PHY0_SUSPEND (1 << 0) > >> > >> use BIT() here and everywhere below. > > > > > . > . > > >>> +#ifdef CONFIG_PHY_EXYNOS4212_USB2 > >>> + { > >>> + .compatible = "samsung,exynos4212-usb2-phy", > >>> + .data = &exynos4212_usb2_phy_config, > >>> + }, > >>> +#endif > >>> + { }, > >>> +}; > >> > >> I think we've had enough discussion about this approach. Let's get > >> the opinion of others too. Felipe? Greg? > > > > Good idea. > > > >> Summary: > >> We have two drivers PHY_EXYNOS4210_USB2 and PHY_EXYNOS4212_USB2 with > >> almost similar register map [1] and a samsung helper driver for > these > >> two drivers. > > > > I would not call them separate drivers. It's a single USB 2.0 driver > > with the option to include support for various SoCs. This patchset > adds: > > Exynos 4210, Exynos 4212, Exynos 5250 and S5PCV210. I know that > > another person is working on supporting S3C6410. > > > >&
[PATCH v2 1/5] phy: Add new Exynos USB PHY driver
Add a new driver for the Exynos USB PHY. The new driver uses the generic PHY framework. The driver includes support for the Exynos 4x10 and 4x12 SoC families. Signed-off-by: Kamil Debski Signed-off-by: Kyungmin Park --- .../devicetree/bindings/phy/samsung-usbphy.txt | 51 +++ drivers/phy/Kconfig| 21 ++ drivers/phy/Makefile |3 + drivers/phy/phy-exynos-usb.c | 245 ++ drivers/phy/phy-exynos-usb.h | 94 ++ drivers/phy/phy-exynos4210-usb.c | 295 + drivers/phy/phy-exynos4212-usb.c | 343 7 files changed, 1052 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/samsung-usbphy.txt create mode 100644 drivers/phy/phy-exynos-usb.c create mode 100644 drivers/phy/phy-exynos-usb.h create mode 100644 drivers/phy/phy-exynos4210-usb.c create mode 100644 drivers/phy/phy-exynos4212-usb.c diff --git a/Documentation/devicetree/bindings/phy/samsung-usbphy.txt b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt new file mode 100644 index 000..f112b37 --- /dev/null +++ b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt @@ -0,0 +1,51 @@ +Samsung S5P/EXYNOS SoC series USB PHY +- + +Required properties: +- compatible : should be one of the listed compatibles: + - "samsung,exynos4210-usbphy" + - "samsung,exynos4212-usbphy" +- reg : a list of registers used by phy driver + - first and obligatory is the location of phy modules registers + - second and also required is the location of isolation registers + (isolation registers control the physical connection between the in + SoC modules and outside of the SoC, this also can be called enable + control in the documentation of the SoC) + - third is the location of the mode switch register, this only applies + to SoCs that have such a feature; mode switching enables to have + both host and device used the same SoC pins and is commonly used + when OTG is supported +- #phy-cells : from the generic phy bindings, must be 1; + +The second cell in the PHY specifier identifies the PHY its meaning is SoC +dependent. For the currently supported SoCs (Exynos 4210 and Exynos 4212) it +is as follows: + 0 - USB device, + 1 - USB host, + 2 - HSIC0, + 3 - HSIC1, + +Example: + +For Exynos 4412 (compatible with Exynos 4212): + +exynos_usbphy: exynos-usbphy@125B { + compatible = "samsung,exynos4212-usbphy"; + reg = <0x125B 0x100 0x10020704 0x0c 0x1001021c 0x4>; + ranges; + #address-cells = <1>; + #size-cells = <1>; + clocks = <&clock 305>, <&clock 2>, <&clock 2>, <&clock 2>, + <&clock 2>; + clock-names = "phy", "device", "host", "hsic0", "hsic1"; + status = "okay"; + #phy-cells = <1>; +}; + +Then the PHY can be used in other nodes such as: + +ehci@1258 { + status = "okay"; + phys = <&exynos_usbphy 2>; + phy-names = "hsic0"; +}; diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 349bef2..2f7ac0a 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -15,4 +15,25 @@ config GENERIC_PHY phy users can obtain reference to the PHY. All the users of this framework should select this config. +config PHY_EXYNOS_USB + tristate "Samsung USB PHY driver (using the Generic PHY Framework)" + help + Enable this to support Samsung USB phy helper driver for Samsung SoCs. + This driver provides common interface to interact, for Samsung + USB 2.0 PHY driver. + +config PHY_EXYNOS4210_USB + bool "Support for Exynos 4210" + depends on PHY_EXYNOS_USB + depends on CPU_EXYNOS4210 + help + Enable USB PHY support for Exynos 4210 + +config PHY_EXYNOS4212_USB + bool "Support for Exynos 4212" + depends on PHY_EXYNOS_USB + depends on (SOC_EXYNOS4212 || SOC_EXYNOS4412) + help + Enable USB PHY support for Exynos 4212 + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 9e9560f..ca3dc82 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -3,3 +3,6 @@ # obj-$(CONFIG_GENERIC_PHY) += phy-core.o +obj-$(CONFIG_PHY_EXYNOS_USB) += phy-exynos-usb.o +obj-$(CONFIG_PHY_EXYNOS4210_USB) += phy-exynos4210-usb.o +obj-$(CONFIG_PHY_EXYNOS4212_USB) += phy-exynos4212-usb.o diff --git a/drivers/phy/phy-exynos-usb.c b/drivers/phy/phy-exynos-usb.c new file mode 100644 index 000..d4a26df --- /dev/null +++ b/drive
[PATCH 0/5] phy: Add new Exynos USB PHY driver
Hi, This is the second version of the patch adding support for USB PHY module of the Exynos series of SoCs by Samsung. The driver is utilising the newly added Generic PHY Framework by Kishon Vijay Abraham I [1]. In addition to the PHY driver this patchset contains: - work in progress support for Exynos 5250 (based on the drivers/usb/phy/phy-samsung-usb2.c driver) - support for S5PV210 added by Mateusz Krawczuk during his summer internship at Samsung - change to the ehci-s5p driver which modifies the driver to use the General PHY Framework - change to the s3c-hsotg driver which modifies the driver to use the General PHY Framework Best wishes, Kamil Debski Changes from v1: - the changes include minor fixes of the hardware initialization of the PHY module - some other minor fixes were introduced -- Original cover letter: Hi, This patch adds a new drive for USB PHYs for Samsung SoCs. The driver is using the Generic PHY Framework created by Kishon Vijay Abrahan I. It can be found here https://lkml.org/lkml/2013/8/21/29. This patch adds support to Exynos4 family of SoCs. Support for Exynos3 and Exynos5 is planned to be added in the near future. I welcome your comments. -- [1] https://lkml.org/lkml/2013/8/21/29 Kamil Debski (4): phy: Add new Exynos USB PHY driver phy: Add WIP Exynos 5250 support to the Exynos USB PHY driver usb: ehci-s5p: Change to use phy provided by the generic phy framework usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework Mateusz Krawczuk (1): phy: Add support for S5PV210 to the Exynos USB PHY driver .../devicetree/bindings/phy/samsung-usbphy.txt | 51 +++ drivers/phy/Kconfig| 35 ++ drivers/phy/Makefile |4 + drivers/phy/phy-exynos-usb.c | 265 + drivers/phy/phy-exynos-usb.h | 96 + drivers/phy/phy-exynos4210-usb.c | 295 ++ drivers/phy/phy-exynos4212-usb.c | 343 drivers/phy/phy-exynos5250-usb.c | 411 drivers/phy/phy-s5pv210-usb.c | 236 +++ drivers/usb/gadget/s3c-hsotg.c | 13 +- drivers/usb/host/ehci-s5p.c| 21 +- 11 files changed, 1755 insertions(+), 15 deletions(-) create mode 100644 Documentation/devicetree/bindings/phy/samsung-usbphy.txt create mode 100644 drivers/phy/phy-exynos-usb.c create mode 100644 drivers/phy/phy-exynos-usb.h create mode 100644 drivers/phy/phy-exynos4210-usb.c create mode 100644 drivers/phy/phy-exynos4212-usb.c create mode 100644 drivers/phy/phy-exynos5250-usb.c create mode 100644 drivers/phy/phy-s5pv210-usb.c -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 5/5] usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework
Change the used phy driver to the new Exynos USB phy driver that uses the generic phy framework. Signed-off-by: Kamil Debski Signed-off-by: Kyungmin Park --- drivers/usb/gadget/s3c-hsotg.c | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 7705c41..2ce84a5 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -131,6 +132,7 @@ struct s3c_hsotg_ep { /** * struct s3c_hsotg - driver state. * @dev: The parent device supplied to the probe function + * @driver: USB gadget driver * @phy: The otg phy transceiver structure for phy control. * @plat: The platform specific configuration data. This can be removed once @@ -154,7 +156,7 @@ struct s3c_hsotg_ep { struct s3c_hsotg { struct device*dev; struct usb_gadget_driver *driver; - struct usb_phy *phy; + struct phy *phy; struct s3c_hsotg_plat*plat; spinlock_t lock; @@ -2858,9 +2860,10 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg) dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev); if (hsotg->phy) - usb_phy_init(hsotg->phy); + phy_power_on(hsotg->phy); else if (hsotg->plat->phy_init) hsotg->plat->phy_init(pdev, hsotg->plat->phy_type); + } /** @@ -2875,7 +2878,7 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg) struct platform_device *pdev = to_platform_device(hsotg->dev); if (hsotg->phy) - usb_phy_shutdown(hsotg->phy); + phy_power_off(hsotg->phy); else if (hsotg->plat->phy_exit) hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type); } @@ -3485,7 +3488,7 @@ static void s3c_hsotg_delete_debug(struct s3c_hsotg *hsotg) static int s3c_hsotg_probe(struct platform_device *pdev) { struct s3c_hsotg_plat *plat = pdev->dev.platform_data; - struct usb_phy *phy; + struct phy *phy; struct device *dev = &pdev->dev; struct s3c_hsotg_ep *eps; struct s3c_hsotg *hsotg; @@ -3500,7 +3503,7 @@ static int s3c_hsotg_probe(struct platform_device *pdev) return -ENOMEM; } - phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); + phy = devm_phy_get(&pdev->dev, "device"); if (IS_ERR(phy)) { /* Fallback for pdata */ plat = pdev->dev.platform_data; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 3/5] phy: Add support for S5PV210 to the Exynos USB PHY driver
From: Mateusz Krawczuk Add support for the Samsung's S5PV210 SoC to the Exynos USB PHY driver. Signed-off-by: Mateusz Krawczuk [k.deb...@samsung.com: whitespace cleanup and commit description] Signed-off-by: Kamil Debski --- drivers/phy/Kconfig |7 ++ drivers/phy/phy-exynos-usb.c | 10 ++ drivers/phy/phy-exynos-usb.h |1 + drivers/phy/phy-s5pv210-usb.c | 236 + 4 files changed, 254 insertions(+) create mode 100644 drivers/phy/phy-s5pv210-usb.c diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 0f598d0..d3517f9 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -22,6 +22,13 @@ config PHY_EXYNOS_USB This driver provides common interface to interact, for Samsung USB 2.0 PHY driver. +config PHY_S5PV210_USB + bool "Support for S5PV210" + depends on PHY_EXYNOS_USB + depends on ARCH_S5PV210 + help + Enable USB PHY support for S5PV210 + config PHY_EXYNOS4210_USB bool "Support for Exynos 4210" depends on PHY_EXYNOS_USB diff --git a/drivers/phy/phy-exynos-usb.c b/drivers/phy/phy-exynos-usb.c index 172b774..01fb12a 100644 --- a/drivers/phy/phy-exynos-usb.c +++ b/drivers/phy/phy-exynos-usb.c @@ -216,7 +216,17 @@ extern const struct uphy_config exynos4212_uphy_config; extern const struct uphy_config exynos5250_uphy_config; #endif +#ifdef CONFIG_PHY_S5PV210_USB +extern const struct uphy_config s5pv210_uphy_config; +#endif + static const struct of_device_id exynos_uphy_of_match[] = { +#ifdef CONFIG_PHY_S5PV210_USB + { + .compatible = "samsung,s5pv210-usbphy", + .data = &s5pv210_uphy_config, + }, +#endif #ifdef CONFIG_PHY_EXYNOS4210_USB { .compatible = "samsung,exynos4210-usbphy", diff --git a/drivers/phy/phy-exynos-usb.h b/drivers/phy/phy-exynos-usb.h index a9febfa..0f385ca 100644 --- a/drivers/phy/phy-exynos-usb.h +++ b/drivers/phy/phy-exynos-usb.h @@ -40,6 +40,7 @@ enum phy_type { enum samsung_cpu_type { TYPE_S3C64XX, + TYPE_S5PV210, TYPE_EXYNOS4210, TYPE_EXYNOS4212, TYPE_EXYNOS5250, diff --git a/drivers/phy/phy-s5pv210-usb.c b/drivers/phy/phy-s5pv210-usb.c new file mode 100644 index 000..575275d --- /dev/null +++ b/drivers/phy/phy-s5pv210-usb.c @@ -0,0 +1,236 @@ +/* + * Samsung S5P/EXYNOS SoC series USB PHY driver + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Authors: Kamil Debski + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "phy-exynos-usb.h" + +/* Exynos USB PHY registers */ + +/* PHY power control */ +#define S5PV210_UPHYPWR0x0 + +#define S5PV210_UPHYPWR_PHY0_SUSPEND (1 << 0) +#define S5PV210_UPHYPWR_PHY0_PWR (1 << 3) +#define S5PV210_UPHYPWR_PHY0_OTG_PWR (1 << 4) +#define S5PV210_UPHYPWR_PHY0 ( \ + S5PV210_UPHYPWR_PHY0_SUSPEND | \ + S5PV210_UPHYPWR_PHY0_PWR | \ + S5PV210_UPHYPWR_PHY0_OTG_PWR) + +#define S5PV210_UPHYPWR_PHY1_SUSPEND (1 << 6) +#define S5PV210_UPHYPWR_PHY1_PWR (1 << 7) +#define S5PV210_UPHYPWR_PHY1 ( \ + S5PV210_UPHYPWR_PHY1_SUSPEND | \ + S5PV210_UPHYPWR_PHY1_PWR) + +/* PHY clock control */ +#define S5PV210_UPHYCLK0x4 + +#define S5PV210_UPHYCLK_PHYFSEL_MASK (0x3 << 0) +#define S5PV210_UPHYCLK_PHYFSEL_48MHZ (0x0 << 0) +#define S5PV210_UPHYCLK_PHYFSEL_24MHZ (0x3 << 0) +#define S5PV210_UPHYCLK_PHYFSEL_12MHZ (0x2 << 0) + +#define S5PV210_UPHYCLK_PHY0_ID_PULLUP (0x1 << 2) +#define S5PV210_UPHYCLK_PHY0_COMMON_ON (0x1 << 4) +#define S5PV210_UPHYCLK_PHY1_COMMON_ON (0x1 << 7) + +/* PHY reset control */ +#define S5PV210_UPHYRST0x8 + +#define S5PV210_URSTCON_PHY0 (1 << 0) +#define S5PV210_URSTCON_OTG_HLINK (1 << 1) +#define S5PV210_URSTCON_OTG_PHYLINK(1 << 2) +#define S5PV210_URSTCON_PHY1_ALL (1 << 3) +#define S5PV210_URSTCON_HOST_LINK_ALL (1 << 4) + +/* Isolation, configured in the power management unit */ +#define S5PV210_USB_ISOL_DEVICE_OFFSET 0x0 +#define S5PV210_USB_ISOL_DEVICE(1 << 0) +#define S5PV210_USB_ISOL_HOST_OFFSET 0x4 +#define S5PV210_USB_ISOL_HOST (1 << 1) + + +enum s5pv210_phy_id { + S5PV210_DEVICE, + S5PV210_HOST, + S5PV210_NUM_PHYS, +}; + +/* s5pv210_rate_to_clk() converts the supplied clock rate to the value that + * can be written to the phy register. */ +static u32 s5pv210_rate_to_clk(unsigned long rate) +{ + unsign
[PATCH 4/5] usb: ehci-s5p: Change to use phy provided by the generic phy framework
Change the phy provider used from the old usb phy specific to a new one using the generic phy framework. Signed-off-by: Kamil Debski Signed-off-by: Kyungmin Park --- drivers/usb/host/ehci-s5p.c | 21 +++-- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c index 7cc26e6..76606ff 100644 --- a/drivers/usb/host/ehci-s5p.c +++ b/drivers/usb/host/ehci-s5p.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -45,7 +46,7 @@ static struct hc_driver __read_mostly s5p_ehci_hc_driver; struct s5p_ehci_hcd { struct clk *clk; - struct usb_phy *phy; + struct phy *phy; struct usb_otg *otg; struct s5p_ehci_platdata *pdata; }; @@ -77,10 +78,11 @@ static int s5p_ehci_probe(struct platform_device *pdev) { struct s5p_ehci_platdata *pdata = pdev->dev.platform_data; struct s5p_ehci_hcd *s5p_ehci; + struct phy *phy; struct usb_hcd *hcd; struct ehci_hcd *ehci; struct resource *res; - struct usb_phy *phy; + const char *phy_name; int irq; int err; @@ -103,14 +105,14 @@ static int s5p_ehci_probe(struct platform_device *pdev) return -ENOMEM; } s5p_ehci = to_s5p_ehci(hcd); - + phy_name = of_get_property(pdev->dev.of_node, "phy-names", NULL); + phy = devm_phy_get(&pdev->dev, phy_name); if (of_device_is_compatible(pdev->dev.of_node, "samsung,exynos5440-ehci")) { s5p_ehci->pdata = &empty_platdata; goto skip_phy; } - phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); if (IS_ERR(phy)) { /* Fallback to pdata */ if (!pdata) { @@ -122,7 +124,6 @@ static int s5p_ehci_probe(struct platform_device *pdev) } } else { s5p_ehci->phy = phy; - s5p_ehci->otg = phy->otg; } skip_phy: @@ -166,7 +167,7 @@ skip_phy: s5p_ehci->otg->set_host(s5p_ehci->otg, &hcd->self); if (s5p_ehci->phy) - usb_phy_init(s5p_ehci->phy); + phy_power_on(s5p_ehci->phy); else if (s5p_ehci->pdata->phy_init) s5p_ehci->pdata->phy_init(pdev, USB_PHY_TYPE_HOST); @@ -188,7 +189,7 @@ skip_phy: fail_add_hcd: if (s5p_ehci->phy) - usb_phy_shutdown(s5p_ehci->phy); + phy_power_off(s5p_ehci->phy); else if (s5p_ehci->pdata->phy_exit) s5p_ehci->pdata->phy_exit(pdev, USB_PHY_TYPE_HOST); fail_io: @@ -209,7 +210,7 @@ static int s5p_ehci_remove(struct platform_device *pdev) s5p_ehci->otg->set_host(s5p_ehci->otg, &hcd->self); if (s5p_ehci->phy) - usb_phy_shutdown(s5p_ehci->phy); + phy_power_off(s5p_ehci->phy); else if (s5p_ehci->pdata->phy_exit) s5p_ehci->pdata->phy_exit(pdev, USB_PHY_TYPE_HOST); @@ -244,7 +245,7 @@ static int s5p_ehci_suspend(struct device *dev) s5p_ehci->otg->set_host(s5p_ehci->otg, &hcd->self); if (s5p_ehci->phy) - usb_phy_shutdown(s5p_ehci->phy); + phy_power_off(s5p_ehci->phy); else if (s5p_ehci->pdata->phy_exit) s5p_ehci->pdata->phy_exit(pdev, USB_PHY_TYPE_HOST); @@ -265,7 +266,7 @@ static int s5p_ehci_resume(struct device *dev) s5p_ehci->otg->set_host(s5p_ehci->otg, &hcd->self); if (s5p_ehci->phy) - usb_phy_init(s5p_ehci->phy); + phy_power_on(s5p_ehci->phy); else if (s5p_ehci->pdata->phy_init) s5p_ehci->pdata->phy_init(pdev, USB_PHY_TYPE_HOST); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH 2/5] phy: Add WIP Exynos 5250 support to the Exynos USB PHY driver
Add support for Exynos 5250. This is work-in-progress commit. Not for merging. Signed-off-by: Kamil Debski Signed-off-by: Kyungmin Park --- drivers/phy/Kconfig |7 + drivers/phy/Makefile |1 + drivers/phy/phy-exynos-usb.c | 10 + drivers/phy/phy-exynos-usb.h |1 + drivers/phy/phy-exynos5250-usb.c | 411 ++ 5 files changed, 430 insertions(+) create mode 100644 drivers/phy/phy-exynos5250-usb.c diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 2f7ac0a..0f598d0 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -36,4 +36,11 @@ config PHY_EXYNOS4212_USB help Enable USB PHY support for Exynos 4212 +config PHY_EXYNOS5250_USB + bool "Support for Exynos 5250" + depends on PHY_EXYNOS_USB + depends on SOC_EXYNOS5250 + help + Enable USB PHY support for Exynos 5250 + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index ca3dc82..0dff0dd 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -6,3 +6,4 @@ obj-$(CONFIG_GENERIC_PHY) += phy-core.o obj-$(CONFIG_PHY_EXYNOS_USB) += phy-exynos-usb.o obj-$(CONFIG_PHY_EXYNOS4210_USB) += phy-exynos4210-usb.o obj-$(CONFIG_PHY_EXYNOS4212_USB) += phy-exynos4212-usb.o +obj-$(CONFIG_PHY_EXYNOS5250_USB) += phy-exynos5250-usb.o diff --git a/drivers/phy/phy-exynos-usb.c b/drivers/phy/phy-exynos-usb.c index d4a26df..172b774 100644 --- a/drivers/phy/phy-exynos-usb.c +++ b/drivers/phy/phy-exynos-usb.c @@ -212,6 +212,10 @@ extern const struct uphy_config exynos4210_uphy_config; extern const struct uphy_config exynos4212_uphy_config; #endif +#ifdef CONFIG_PHY_EXYNOS5250_USB +extern const struct uphy_config exynos5250_uphy_config; +#endif + static const struct of_device_id exynos_uphy_of_match[] = { #ifdef CONFIG_PHY_EXYNOS4210_USB { @@ -225,6 +229,12 @@ static const struct of_device_id exynos_uphy_of_match[] = { .data = &exynos4212_uphy_config, }, #endif +#ifdef CONFIG_PHY_EXYNOS5250_USB + { + .compatible = "samsung,exynos5250-usbphy", + .data = &exynos5250_uphy_config, + }, +#endif { }, }; diff --git a/drivers/phy/phy-exynos-usb.h b/drivers/phy/phy-exynos-usb.h index f45cb3c..a9febfa 100644 --- a/drivers/phy/phy-exynos-usb.h +++ b/drivers/phy/phy-exynos-usb.h @@ -42,6 +42,7 @@ enum samsung_cpu_type { TYPE_S3C64XX, TYPE_EXYNOS4210, TYPE_EXYNOS4212, + TYPE_EXYNOS5250, }; enum uphy_state { diff --git a/drivers/phy/phy-exynos5250-usb.c b/drivers/phy/phy-exynos5250-usb.c new file mode 100644 index 000..156093b --- /dev/null +++ b/drivers/phy/phy-exynos5250-usb.c @@ -0,0 +1,411 @@ +/* + * Samsung S5P/EXYNOS SoC series USB PHY driver + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Kamil Debski + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "phy-exynos-usb.h" + +/* Exynos USB PHY registers */ +#define EXYNOS_5250_REFCLKSEL_CRYSTAL 0x0 +#define EXYNOS_5250_REFCLKSEL_XO 0x1 +#define EXYNOS_5250_REFCLKSEL_CLKCORE 0x2 + +#define EXYNOS_5250_FSEL_9MHZ6 0x0 +#define EXYNOS_5250_FSEL_10MHZ 0x1 +#define EXYNOS_5250_FSEL_12MHZ 0x2 +#define EXYNOS_5250_FSEL_19MHZ20x3 +#define EXYNOS_5250_FSEL_20MHZ 0x4 +#define EXYNOS_5250_FSEL_24MHZ 0x5 +#define EXYNOS_5250_FSEL_50MHZ 0x7 + +/* Normal host */ +#define EXYNOS_5250_HOSTPHYCTRL0 0x0 + +#define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRSTALL (0x1 << 31) +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT 19 +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_MASK\ + (0x3 << EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT16 +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_MASK \ + (0x7 << EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_TESTBURNIN(0x1 << 11) +#define EXYNOS_5250_HOSTPHYCTRL0_RETENABLE (0x1 << 10) +#define EXYNOS_5250_HOSTPHYCTRL0_COMMON_ON_N (0x1 << 9) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_MASK(0x3 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_DUAL(0x0 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ID0 (0x1 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ANALOGTEST (0x2 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_SIDDQ (0x1 << 6) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESLEEP(0x1 << 5) +#define EXYNOS_5
[PATCH v4 0/9] phy: Add new Exynos USB 2.0 PHY driver
Hi, This is the fourth version of the patchset adding the new Exynos USB 2.0 PHY driver. The driver uses the Generic PHY Framework. A month has passed since the last version. I have addressed numerous comments that appeared on the mailing list in this patch. I would like to specially thank Kishon, Tomasz, Matt and Vivek for their comments. This patch contains two necessary patches to the phy core. It is very useful to be able to get phy using a device tree node. In addition this patch depends on: [PATCH V11 1/3] ARM: dts: Add pmu sysreg node to exynos5250 and exynos5420 dtsi files [1]. Best wishes, Kamil Debski [1] - http://www.spinics.net/lists/linux-samsung-soc/msg24528.html Changes from v3: - using PMU and system registers indirectly via syscon - change labelling - change Kconfig name - fixed typos/stray whitespace - move of_phy_provider_register() to the end of probe - add a regular error return code to the rate_to_clk functions - cleanup code and remove unused code - change struct names to avoid collisions - add mechanism to support multiple phys by the ehci driver Changes from v2: - rebase all patches to the usb-next branch - fixes in the documentation file - remove wrong entries in the phy node (ranges, and #address- & #size-cells) - add clocks and clock-names as required properites - rephrase a few sentences - fixes in the ehci-exynos.c file - move phy_name variable next to phy in exynos_ehci_hcd - remove otg from exynos_ehci_hcd as it was no longer used - move devm_phy_get after the Exynos5440 skip_phy check - fixes in the s3c-hsotg.c file - cosmetic fixes (remove empty line that was wrongfully added) - fixes in the main driver - remove cpu_type in favour for a boolean flag matched with the compatible value - rename files, structures, variables and Kconfig entires - change from simple "uphy" to "usb2_phy" - fix multiline comments style - simplify #ifdefs in of_device_id - fix Kconfig description - change dev_info to dev_dbg where reasonable - cosmetic changes (remove wrongful blank lines) - remove unnecessary reference counting Changes from v1: - the changes include minor fixes of the hardware initialization of the PHY module - some other minor fixes were introduced -- Original cover letter: Hi, This patch adds a new drive for USB PHYs for Samsung SoCs. The driver is using the Generic PHY Framework created by Kishon Vijay Abrahan I. It can be found here https://lkml.org/lkml/2013/8/21/29. This patch adds support to Exynos4 family of SoCs. Support for Exynos3 and Exynos5 is planned to be added in the near future. I welcome your comments. -- [1] https://lkml.org/lkml/2013/8/21/29 Kamil Debski (8): phy: core: Change the way of_phy_get is called phy: core: Add devm_of_phy_get to phy-core phy: Add new Exynos USB PHY driver usb: ehci-s5p: Change to use phy provided by the generic phy framework usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver dts: Add usb2phy to Exynos 4 dts: Add usb2phy to Exynos 5250 Mateusz Krawczuk (1): phy: Add support for S5PV210 to the Exynos USB PHY driver .../devicetree/bindings/arm/samsung/pmu.txt|2 + .../devicetree/bindings/phy/samsung-usbphy.txt | 56 +++ .../devicetree/bindings/usb/samsung-hsotg.txt |4 + Documentation/devicetree/bindings/usb/usb-ehci.txt | 35 ++ arch/arm/boot/dts/exynos4.dtsi | 31 ++ arch/arm/boot/dts/exynos4210.dtsi | 17 + arch/arm/boot/dts/exynos4x12.dtsi | 17 + arch/arm/boot/dts/exynos5250.dtsi | 33 +- drivers/phy/Kconfig| 35 ++ drivers/phy/Makefile |5 + drivers/phy/phy-core.c | 43 ++- drivers/phy/phy-exynos4210-usb2.c | 264 ++ drivers/phy/phy-exynos4212-usb2.c | 312 + drivers/phy/phy-exynos5250-usb2.c | 363 drivers/phy/phy-s5pv210-usb2.c | 206 +++ drivers/phy/phy-samsung-usb2.c | 240 + drivers/phy/phy-samsung-usb2.h | 74 drivers/usb/gadget/s3c-hsotg.c | 11 +- drivers/usb/host/ehci-exynos.c | 95 +++-- include/linux/phy/phy.h|3 + 20 files changed, 1789 insertions(+), 57 deletions(-) create mode 100644 Documentation/devicetree/bindings/phy/samsung-usbphy.txt create mode 100644 drivers/phy/phy-exynos4210-usb2.c create mode 100644 drivers/phy/phy-exynos4212-usb2.c create mode 100644 drivers/phy/phy-exynos5250-usb2.c create mode 100644 drivers/phy/phy-s5pv210-usb2.c create mod
[PATCH v4 5/9] usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework
Change the used phy driver to the new Exynos USB phy driver that uses the generic phy framework. Signed-off-by: Kamil Debski Signed-off-by: Kyungmin Park --- .../devicetree/bindings/usb/samsung-hsotg.txt |4 drivers/usb/gadget/s3c-hsotg.c | 11 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/samsung-hsotg.txt b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt index b83d428..9340d06 100644 --- a/Documentation/devicetree/bindings/usb/samsung-hsotg.txt +++ b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt @@ -24,6 +24,8 @@ Required properties: - first entry: must be "otg" - vusb_d-supply: phandle to voltage regulator of digital section, - vusb_a-supply: phandle to voltage regulator of analog section. +- phys: from general PHY binding: phandle to the PHY device +- phy-names: from general PHY binding: should be "usb2-phy" Example - @@ -36,5 +38,7 @@ Example clock-names = "otg"; vusb_d-supply = <&vusb_reg>; vusb_a-supply = <&vusbdac_reg>; + phys = <&usb2phy 0>; + phy-names = "device"; }; diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index eccb147..db096fd 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -162,7 +163,7 @@ struct s3c_hsotg_ep { struct s3c_hsotg { struct device*dev; struct usb_gadget_driver *driver; - struct usb_phy *phy; + struct phy *phy; struct s3c_hsotg_plat*plat; spinlock_t lock; @@ -2905,7 +2906,7 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg) dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev); if (hsotg->phy) - usb_phy_init(hsotg->phy); + phy_power_on(hsotg->phy); else if (hsotg->plat->phy_init) hsotg->plat->phy_init(pdev, hsotg->plat->phy_type); } @@ -2922,7 +2923,7 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg) struct platform_device *pdev = to_platform_device(hsotg->dev); if (hsotg->phy) - usb_phy_shutdown(hsotg->phy); + phy_power_off(hsotg->phy); else if (hsotg->plat->phy_exit) hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type); } @@ -3529,7 +3530,7 @@ static void s3c_hsotg_delete_debug(struct s3c_hsotg *hsotg) static int s3c_hsotg_probe(struct platform_device *pdev) { struct s3c_hsotg_plat *plat = dev_get_platdata(&pdev->dev); - struct usb_phy *phy; + struct phy *phy; struct device *dev = &pdev->dev; struct s3c_hsotg_ep *eps; struct s3c_hsotg *hsotg; @@ -3544,7 +3545,7 @@ static int s3c_hsotg_probe(struct platform_device *pdev) return -ENOMEM; } - phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); + phy = devm_phy_get(&pdev->dev, "usb2-phy"); if (IS_ERR(phy)) { /* Fallback for pdata */ plat = dev_get_platdata(&pdev->dev); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/9] phy: core: Change the way of_phy_get is called
Previously the of_phy_get function took a struct device * and was declared static. It was impossible to call it from another driver and thus it was impossible to get phy defined for a given node. Signed-off-by: Kamil Debski Signed-off-by: Kyungmin Park --- drivers/phy/phy-core.c | 12 +--- include/linux/phy/phy.h |1 + 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 03cf8fb..7fb3474 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -250,20 +250,17 @@ EXPORT_SYMBOL_GPL(phy_power_off); * not yet loaded. This function uses of_xlate call back function provided * while registering the phy_provider to find the phy instance. */ -static struct phy *of_phy_get(struct device *dev, int index) +struct phy *of_phy_get(struct device_node *np, int index) { int ret; struct phy_provider *phy_provider; struct phy *phy = NULL; struct of_phandle_args args; - ret = of_parse_phandle_with_args(dev->of_node, "phys", "#phy-cells", + ret = of_parse_phandle_with_args(np, "phys", "#phy-cells", index, &args); - if (ret) { - dev_dbg(dev, "failed to get phy in %s node\n", - dev->of_node->full_name); + if (ret) return ERR_PTR(-ENODEV); - } mutex_lock(&phy_provider_mutex); phy_provider = of_phy_provider_lookup(args.np); @@ -281,6 +278,7 @@ err0: return phy; } +EXPORT_SYMBOL_GPL(of_phy_get); /** * phy_put() - release the PHY @@ -370,7 +368,7 @@ struct phy *phy_get(struct device *dev, const char *string) if (dev->of_node) { index = of_property_match_string(dev->of_node, "phy-names", string); - phy = of_phy_get(dev, index); + phy = of_phy_get(dev->of_node, index); if (IS_ERR(phy)) { dev_err(dev, "unable to find phy\n"); return phy; diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 6d72269..169f572 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -131,6 +131,7 @@ struct phy *phy_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); +struct phy *of_phy_get(struct device_node *np, int index); struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args); struct phy *phy_create(struct device *dev, const struct phy_ops *ops, -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v4 3/9] phy: Add new Exynos USB PHY driver
Add a new driver for the Exynos USB PHY. The new driver uses the generic PHY framework. The driver includes support for the Exynos 4x10 and 4x12 SoC families. Signed-off-by: Kamil Debski Signed-off-by: Kyungmin Park --- .../devicetree/bindings/phy/samsung-usbphy.txt | 54 drivers/phy/Kconfig| 20 ++ drivers/phy/Makefile |3 + drivers/phy/phy-exynos4210-usb2.c | 264 + drivers/phy/phy-exynos4212-usb2.c | 312 drivers/phy/phy-samsung-usb2.c | 228 ++ drivers/phy/phy-samsung-usb2.h | 72 + 7 files changed, 953 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/samsung-usbphy.txt create mode 100644 drivers/phy/phy-exynos4210-usb2.c create mode 100644 drivers/phy/phy-exynos4212-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.h diff --git a/Documentation/devicetree/bindings/phy/samsung-usbphy.txt b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt new file mode 100644 index 000..cadbf70 --- /dev/null +++ b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt @@ -0,0 +1,54 @@ +Samsung S5P/EXYNOS SoC series USB PHY +- + +Required properties: +- compatible : should be one of the listed compatibles: + - "samsung,exynos4210-usb2-phy" + - "samsung,exynos4212-usb2-phy" +- reg : a list of registers used by phy driver + - first and obligatory is the location of phy modules registers +- samsung,sysreg-phandle - handle to syscon used to control the system registers +- samsung,pmureg-phandle - handle to syscon used to control PMU registers +- #phy-cells : from the generic phy bindings, must be 1; +- clocks and clock-names: + - the "phy" clocks is required by the phy module + - next for each of the phys a clock has to be assidned, this clock + will be used to determine clocking frequency for the phys + (the labels are specified in the paragraph below) + +The first phandle argument in the PHY specifier identifies the PHY, its +meaning is compatible dependent. For the currently supported SoCs (Exynos 4210 +and Exynos 4212) it is as follows: + 0 - USB device ("device"), + 1 - USB host ("host"), + 2 - HSIC0 ("hsic0"), + 3 - HSIC1 ("hsic1"), + +Exynos 4210 and Exynos 4212 use mode switching and require that mode switch +register is supplied. + +Example: + +For Exynos 4412 (compatible with Exynos 4212): + +usbphy: phy@125B { + compatible = "samsung,exynos4212-usb2-phy"; + reg = <0x125B 0x100 0x10020704 0x0c 0x1001021c 0x4>; + clocks = <&clock 305>, <&clock 2>, <&clock 2>, <&clock 2>, + <&clock 2>; + clock-names = "phy", "device", "host", "hsic0", "hsic1"; + status = "okay"; + #phy-cells = <1>; + samsung,sysreg-phandle = <&sys_reg>; + samsung,pmureg-phandle = <&pmu_reg>; +}; + +Then the PHY can be used in other nodes such as: + +phy-consumer@1234 { + phys = <&usbphy 2>; + phy-names = "phy"; +}; + +Refer to DT bindings documentation of particular PHY consumer devices for more +information about required PHYs and the way of specification. diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index a344f3d..b29018f 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -51,4 +51,24 @@ config PHY_EXYNOS_DP_VIDEO help Support for Display Port PHY found on Samsung EXYNOS SoCs. +config PHY_SAMSUNG_USB2 + tristate "Samsung USB 2.0 PHY driver" + help + Enable this to support Samsung USB phy helper driver for Samsung SoCs. + This driver provides common interface to interact, for Samsung + USB 2.0 PHY driver. + +config PHY_EXYNOS4210_USB2 + bool "Support for Exynos 4210" + depends on PHY_SAMSUNG_USB2 + depends on CPU_EXYNOS4210 + help + Enable USB PHY support for Exynos 4210 + +config PHY_EXYNOS4212_USB2 + bool "Support for Exynos 4212" + depends on PHY_SAMSUNG_USB2 + depends on (SOC_EXYNOS4212 || SOC_EXYNOS4412) + help + Enable USB PHY support for Exynos 4212 endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index d0caae9..9f4befd 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -7,3 +7,6 @@ obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO) += phy-exynos-dp-video.o obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi-video.o obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o
[PATCH v4 4/9] usb: ehci-s5p: Change to use phy provided by the generic phy framework
Change the phy provider used from the old usb phy specific to a new one using the generic phy framework. Signed-off-by: Kamil Debski Signed-off-by: Kyungmin Park --- Documentation/devicetree/bindings/usb/usb-ehci.txt | 35 drivers/usb/host/ehci-exynos.c | 95 +--- 2 files changed, 97 insertions(+), 33 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/usb-ehci.txt b/Documentation/devicetree/bindings/usb/usb-ehci.txt index fa18612..413f7cd 100644 --- a/Documentation/devicetree/bindings/usb/usb-ehci.txt +++ b/Documentation/devicetree/bindings/usb/usb-ehci.txt @@ -14,6 +14,10 @@ If controller implementation operates with big endian descriptors, If both big endian registers and descriptors are used by the controller implementation, "big-endian" property can be specified instead of having both "big-endian-regs" and "big-endian-desc". + - port: if in the SoC there are EHCI phys, they should be listed here. +One phy per port. Each port should have its reg entry with a consecutive +number. Also it should contain phys and phy-names entries specifying the +phy used by the port. Example (Sequoia 440EPx): ehci@e300 { @@ -23,3 +27,34 @@ Example (Sequoia 440EPx): reg = <0 e300 90 0 e390 70>; big-endian; }; + +Example (Exynos 4212): +ehci@1258 { +compatible = "samsung,exynos4210-ehci"; +reg = <0x1258 0x2>; +interrupts = <0 70 0>; +clocks = <&clock 304>, <&clock 305>; +clock-names = "usbhost", "otg"; +status = "disabled"; +#address-cells = <1>; +#size-cells = <0>; +port@0 { +reg = <0>; +phys = <&usb2phy 1>; +phy-names = "host"; +status = "disabled"; +}; +port@1 { +reg = <1>; +phys = <&usb2phy 2>; +phy-names = "hsic0"; +status = "disabled"; +}; +port@2 { +reg = <2>; +phys = <&usb2phy 3>; +phy-names = "hsic1"; +status = "disabled"; +}; +}; + diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index e97c198..bb81809 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -19,12 +19,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include "ehci.h" @@ -42,10 +42,10 @@ static const char hcd_name[] = "ehci-exynos"; static struct hc_driver __read_mostly exynos_ehci_hc_driver; +#define PHY_NUMBER 3 struct exynos_ehci_hcd { struct clk *clk; - struct usb_phy *phy; - struct usb_otg *otg; + struct phy *phy[PHY_NUMBER]; }; #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd *)(hcd_to_ehci(hcd)->priv) @@ -69,13 +69,43 @@ static void exynos_setup_vbus_gpio(struct platform_device *pdev) dev_err(dev, "can't request ehci vbus gpio %d", gpio); } +static int exynos_phys_on(struct phy *p[]) +{ + int i; + int ret = 0; + + for (i = 0; ret == 0 && i < PHY_NUMBER; i++) + if (p[i]) + ret = phy_power_on(p[i]); + if (ret) + for (i--; i > 0; i--) + if (p[i]) + phy_power_off(p[i]); + + return ret; +} + +static int exynos_phys_off(struct phy *p[]) +{ + int i; + int ret = 0; + + for (i = 0; ret == 0 && i < PHY_NUMBER; i++) + if (p[i]) + ret = phy_power_off(p[i]); + + return ret; +} + static int exynos_ehci_probe(struct platform_device *pdev) { struct exynos_ehci_hcd *exynos_ehci; struct usb_hcd *hcd; struct ehci_hcd *ehci; struct resource *res; - struct usb_phy *phy; + struct phy *phy; + struct device_node *child; + int phy_number; int irq; int err; @@ -102,13 +132,24 @@ static int exynos_ehci_probe(struct platform_device *pdev) "samsung,exynos5440-ehci")) goto skip_phy; - phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); - if (IS_ERR(phy)) { - usb_put_hcd(hcd); - dev_warn(&pdev->dev, "no platform data or transceiver defined\n"); - return -EPROBE_DEFER; - } else { - exynos_ehci->phy = phy; + for_each_available_child_of_node(pdev->dev.of_node, child) { + err = of_property_read_u32(child, "reg", &phy_number); +
[PATCH 2/9] phy: core: Add devm_of_phy_get to phy-core
Adding devm_of_phy_get will allow to get phys by supplying the device_node instead of by name. Signed-off-by: Kamil Debski Signed-off-by: Kyungmin Park --- drivers/phy/phy-core.c | 31 +++ include/linux/phy/phy.h |2 ++ 2 files changed, 33 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 7fb3474..b39b48c 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -421,6 +421,37 @@ struct phy *devm_phy_get(struct device *dev, const char *string) EXPORT_SYMBOL_GPL(devm_phy_get); /** + * devm_of_phy_get() - lookup and obtain a reference to a phy. + * @dev: device that requests this phy + * @np: node containing the phy + * @index: the index of the phy + * + * Gets the phy using phy_get(), and associates a device with it using + * devres. On driver detach, release function is invoked on the devres data, + * then, devres data is freed. + */ +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, int + index) +{ + struct phy **ptr, *phy; + + ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + phy = of_phy_get(np, index); + if (!IS_ERR(phy)) { + *ptr = phy; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return phy; +} +EXPORT_SYMBOL_GPL(devm_of_phy_get); + +/** * phy_create() - create a new phy * @dev: device that is creating the new phy * @ops: function pointers for performing phy operations diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 169f572..f143ee8 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -129,6 +129,8 @@ int phy_power_on(struct phy *phy); int phy_power_off(struct phy *phy); struct phy *phy_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, int + index); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); struct phy *of_phy_get(struct device_node *np, int index); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v4 6/9] phy: Add support for S5PV210 to the Exynos USB PHY driver
From: Mateusz Krawczuk Add support for the Samsung's S5PV210 SoC to the Exynos USB PHY driver. Signed-off-by: Mateusz Krawczuk [k.deb...@samsung.com: cleanup and commit description] [k.deb...@samsung.com: make changes accordingly to the mailing list comments] Signed-off-by: Kamil Debski Signed-off-by: Kyungmin Park --- .../devicetree/bindings/phy/samsung-usbphy.txt |1 + drivers/phy/Kconfig|7 + drivers/phy/Makefile |1 + drivers/phy/phy-s5pv210-usb2.c | 206 drivers/phy/phy-samsung-usb2.c |6 + drivers/phy/phy-samsung-usb2.h |1 + 6 files changed, 222 insertions(+) create mode 100644 drivers/phy/phy-s5pv210-usb2.c diff --git a/Documentation/devicetree/bindings/phy/samsung-usbphy.txt b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt index cadbf70..77a8e9c 100644 --- a/Documentation/devicetree/bindings/phy/samsung-usbphy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt @@ -3,6 +3,7 @@ Samsung S5P/EXYNOS SoC series USB PHY Required properties: - compatible : should be one of the listed compatibles: + - "samsung,s5pv210-usb2-phy" - "samsung,exynos4210-usb2-phy" - "samsung,exynos4212-usb2-phy" - reg : a list of registers used by phy driver diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index b29018f..2e433cd 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -58,6 +58,13 @@ config PHY_SAMSUNG_USB2 This driver provides common interface to interact, for Samsung USB 2.0 PHY driver. +config PHY_S5PV210_USB2 + bool "Support for S5PV210" + depends on PHY_SAMSUNG_USB2 + depends on ARCH_S5PV210 + help + Enable USB PHY support for S5PV210 + config PHY_EXYNOS4210_USB2 bool "Support for Exynos 4210" depends on PHY_SAMSUNG_USB2 diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 9f4befd..fefc6c2 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -8,5 +8,6 @@ obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO) += phy-exynos-mipi-video.o obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o +obj-$(CONFIG_PHY_S5PV210_USB2) += phy-s5pv210-usb2.o obj-$(CONFIG_PHY_EXYNOS4210_USB2) += phy-exynos4210-usb2.o obj-$(CONFIG_PHY_EXYNOS4212_USB2) += phy-exynos4212-usb2.o diff --git a/drivers/phy/phy-s5pv210-usb2.c b/drivers/phy/phy-s5pv210-usb2.c new file mode 100644 index 000..528a114 --- /dev/null +++ b/drivers/phy/phy-s5pv210-usb2.c @@ -0,0 +1,206 @@ +/* + * Samsung SoC USB 1.1/2.0 PHY driver - S5PV210 support + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Authors: Kamil Debski + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "phy-samsung-usb2.h" + +/* Exynos USB PHY registers */ + +/* PHY power control */ +#define S5PV210_UPHYPWR0x0 + +#define S5PV210_UPHYPWR_PHY0_SUSPEND (1 << 0) +#define S5PV210_UPHYPWR_PHY0_PWR (1 << 3) +#define S5PV210_UPHYPWR_PHY0_OTG_PWR (1 << 4) +#define S5PV210_UPHYPWR_PHY0 ( \ + S5PV210_UPHYPWR_PHY0_SUSPEND | \ + S5PV210_UPHYPWR_PHY0_PWR | \ + S5PV210_UPHYPWR_PHY0_OTG_PWR) + +#define S5PV210_UPHYPWR_PHY1_SUSPEND (1 << 6) +#define S5PV210_UPHYPWR_PHY1_PWR (1 << 7) +#define S5PV210_UPHYPWR_PHY1 ( \ + S5PV210_UPHYPWR_PHY1_SUSPEND | \ + S5PV210_UPHYPWR_PHY1_PWR) + +/* PHY clock control */ +#define S5PV210_UPHYCLK0x4 + +#define S5PV210_UPHYCLK_PHYFSEL_MASK (0x3 << 0) +#define S5PV210_UPHYCLK_PHYFSEL_48MHZ (0x0 << 0) +#define S5PV210_UPHYCLK_PHYFSEL_24MHZ (0x3 << 0) +#define S5PV210_UPHYCLK_PHYFSEL_12MHZ (0x2 << 0) + +#define S5PV210_UPHYCLK_PHY0_ID_PULLUP (0x1 << 2) +#define S5PV210_UPHYCLK_PHY0_COMMON_ON (0x1 << 4) +#define S5PV210_UPHYCLK_PHY1_COMMON_ON (0x1 << 7) + +/* PHY reset control */ +#define S5PV210_UPHYRST0x8 + +#define S5PV210_URSTCON_PHY0 (1 << 0) +#define S5PV210_URSTCON_OTG_HLINK (1 << 1) +#define S5PV210_URSTCON_OTG_PHYLINK(1 << 2) +#define S5PV210_URSTCON_PHY1_ALL (1 << 3) +#define S5PV210_URSTCON_HOST_LINK_ALL (1 << 4) + +/* Isolation, configured in the power management unit */ +#define S5PV210_USB_ISOL_DEVICE_OFFSET 0x704 +#define S5PV210_USB_ISOL_DEVICE
[PATCH v4 7/9] phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver
Add support for Exynos 5250. This driver is to replace the old USB 2.0 PHY driver. Signed-off-by: Kamil Debski Signed-off-by: Kyungmin Park --- .../devicetree/bindings/phy/samsung-usbphy.txt |1 + drivers/phy/Kconfig|8 + drivers/phy/Makefile |1 + drivers/phy/phy-exynos5250-usb2.c | 363 drivers/phy/phy-samsung-usb2.c |6 + drivers/phy/phy-samsung-usb2.h |1 + 6 files changed, 380 insertions(+) create mode 100644 drivers/phy/phy-exynos5250-usb2.c diff --git a/Documentation/devicetree/bindings/phy/samsung-usbphy.txt b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt index 77a8e9c..94096fc 100644 --- a/Documentation/devicetree/bindings/phy/samsung-usbphy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt @@ -6,6 +6,7 @@ Required properties: - "samsung,s5pv210-usb2-phy" - "samsung,exynos4210-usb2-phy" - "samsung,exynos4212-usb2-phy" + - "samsung,exynos5250-usb2-phy" - reg : a list of registers used by phy driver - first and obligatory is the location of phy modules registers - samsung,sysreg-phandle - handle to syscon used to control the system registers diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 2e433cd..74e9064 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -78,4 +78,12 @@ config PHY_EXYNOS4212_USB2 depends on (SOC_EXYNOS4212 || SOC_EXYNOS4412) help Enable USB PHY support for Exynos 4212 + +config PHY_EXYNOS5250_USB2 + bool "Support for Exynos 5250" + depends on PHY_SAMSUNG_USB2 + depends on SOC_EXYNOS5250 + help + Enable USB PHY support for Exynos 5250 + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index fefc6c2..33c3ac1 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -11,3 +11,4 @@ obj-$(CONFIG_PHY_SAMSUNG_USB2)+= phy-samsung-usb2.o obj-$(CONFIG_PHY_S5PV210_USB2) += phy-s5pv210-usb2.o obj-$(CONFIG_PHY_EXYNOS4210_USB2) += phy-exynos4210-usb2.o obj-$(CONFIG_PHY_EXYNOS4212_USB2) += phy-exynos4212-usb2.o +obj-$(CONFIG_PHY_EXYNOS5250_USB2) += phy-exynos5250-usb2.o diff --git a/drivers/phy/phy-exynos5250-usb2.c b/drivers/phy/phy-exynos5250-usb2.c new file mode 100644 index 000..7aeebc8 --- /dev/null +++ b/drivers/phy/phy-exynos5250-usb2.c @@ -0,0 +1,363 @@ +/* + * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 5250 support + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Kamil Debski + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "phy-samsung-usb2.h" + +/* Exynos USB PHY registers */ +#define EXYNOS_5250_REFCLKSEL_CRYSTAL 0x0 +#define EXYNOS_5250_REFCLKSEL_XO 0x1 +#define EXYNOS_5250_REFCLKSEL_CLKCORE 0x2 + +#define EXYNOS_5250_FSEL_9MHZ6 0x0 +#define EXYNOS_5250_FSEL_10MHZ 0x1 +#define EXYNOS_5250_FSEL_12MHZ 0x2 +#define EXYNOS_5250_FSEL_19MHZ20x3 +#define EXYNOS_5250_FSEL_20MHZ 0x4 +#define EXYNOS_5250_FSEL_24MHZ 0x5 +#define EXYNOS_5250_FSEL_50MHZ 0x7 + +/* Normal host */ +#define EXYNOS_5250_HOSTPHYCTRL0 0x0 + +#define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRSTALL (0x1 << 31) +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT 19 +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_MASK\ + (0x3 << EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT16 +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_MASK \ + (0x7 << EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_TESTBURNIN(0x1 << 11) +#define EXYNOS_5250_HOSTPHYCTRL0_RETENABLE (0x1 << 10) +#define EXYNOS_5250_HOSTPHYCTRL0_COMMON_ON_N (0x1 << 9) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_MASK(0x3 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_DUAL(0x0 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ID0 (0x1 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ANALOGTEST (0x2 << 7) +#define EXYNOS_5250_HOSTPHYCTRL0_SIDDQ (0x1 << 6) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESLEEP(0x1 << 5) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESUSPEND (0x1 << 4) +#define EXYNOS_5250_HOSTPHYCTRL0_WORDINTERFACE (0x1 << 3) +#define EXYNOS_5250_HOSTPHYCTRL0_UTMISWRST (0x1 << 2) +#define EXYNOS