Re: [PATCHv3 1/4] phy: phy-core: Make GENERIC_PHY an invisible option
Hi, On Friday 29 May 2015 08:34 PM, Felipe Balbi wrote: Hi, On Fri, May 29, 2015 at 05:04:38PM +0530, Kishon Vijay Abraham I wrote: Hi Felipe, On Wednesday 27 May 2015 12:09 AM, Felipe Balbi wrote: On Tue, May 26, 2015 at 11:37:17AM -0700, Arun Ramamurthy wrote: Hi On 15-05-26 07:19 AM, Felipe Balbi wrote: HI, On Mon, May 25, 2015 at 02:19:58PM -0700, Arun Ramamurthy wrote: On 15-05-14 05:52 PM, Felipe Balbi wrote: Hi, On Wed, Apr 22, 2015 at 04:04:10PM -0700, Arun Ramamurthy wrote: Most of the phy providers use select to enable GENERIC_PHY. Since select is only recommended when the config is not visible, GENERIC_PHY is changed an invisible option. To maintain consistency, all phy providers are changed to select GENERIC_PHY and all non-phy drivers use depends on when the phy framework is explicity required. USB_MUSB_OMAP2PLUS has a cyclic dependency, so it is left as select. Signed-off-by: Arun Ramamurthy arun.ramamur...@broadcom.com --- drivers/ata/Kconfig | 1 - drivers/media/platform/exynos4-is/Kconfig | 2 +- drivers/phy/Kconfig | 4 ++-- drivers/usb/host/Kconfig | 4 ++-- drivers/video/fbdev/exynos/Kconfig| 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index 5f60155..6d2e881 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig @@ -301,7 +301,6 @@ config SATA_MV tristate Marvell SATA support depends on PCI || ARCH_DOVE || ARCH_MV78XX0 || \ ARCH_MVEBU || ARCH_ORION5X || COMPILE_TEST - select GENERIC_PHY help This option enables support for the Marvell Serial ATA family. Currently supports 88SX[56]0[48][01] PCI(-X) chips, diff --git a/drivers/media/platform/exynos4-is/Kconfig b/drivers/media/platform/exynos4-is/Kconfig index b7b2e47..b6f3eaa 100644 --- a/drivers/media/platform/exynos4-is/Kconfig +++ b/drivers/media/platform/exynos4-is/Kconfig @@ -31,7 +31,7 @@ config VIDEO_S5P_FIMC config VIDEO_S5P_MIPI_CSIS tristate S5P/EXYNOS MIPI-CSI2 receiver (MIPI-CSIS) driver depends on REGULATOR - select GENERIC_PHY + depends on GENERIC_PHY help This is a V4L2 driver for Samsung S5P and EXYNOS4 SoC MIPI-CSI2 receiver (MIPI-CSIS) devices. diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 2962de2..edecdb1 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -5,7 +5,7 @@ menu PHY Subsystem config GENERIC_PHY - bool PHY Core + bool help Generic PHY support. @@ -72,7 +72,7 @@ config PHY_MIPHY365X config PHY_RCAR_GEN2 tristate Renesas R-Car generation 2 USB PHY driver depends on ARCH_SHMOBILE - depends on GENERIC_PHY + select GENERIC_PHY so some you changed from depends to select... help Support for USB PHY found on Renesas R-Car generation 2 SoCs. diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 5ad60e4..e2197e2 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -182,7 +182,7 @@ config USB_EHCI_HCD_SPEAR config USB_EHCI_HCD_STI tristate Support for ST STiHxxx on-chip EHCI USB controller depends on ARCH_STI OF - select GENERIC_PHY + depends on GENERIC_PHY while others you changed from select to depends. NAK. Felipe, I dont understand your concern, could you please explain it more detail? The logic behind the changes is that in cases where there was an explicit dependency, I changed it to depends on and in other cases I changed it to selects. Thanks Since GENERIC_PHY is visible from Kconfig, it would be much nicer to avoid select altogether. Felipe, after discussion with the maintainers, I have made GENERIC_PHY an invisible option as part of this change. Thanks Then, if the option is invisible, how can you depend on it ? It can never be selected by poking around in Kconfig. IMO, it's counterintuitive that you need to enable a PHY driver before you can see your EHCI/OHCI/whatever controller listed in Kconfig. If the controller requires PHY for it to be functional, it is okay to make the controller depend on PHY IMHO. We want to try and minimize the usage of 'select' wherever possible or else 'select' is the most intuitive way. The other option is just to leave the 'depends on' and let the user select PHY. How can you 'depend' on something that the user can't select by navigating through Kconfig ? hmm... Actually it's selected when the user selects the PHY driver. Maybe we should directly depend on the PHY driver instead of Generic PHY? Thanks Kishon -- 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
Re: [PATCHv3 1/4] phy: phy-core: Make GENERIC_PHY an invisible option
Hi Felipe, On Wednesday 27 May 2015 12:09 AM, Felipe Balbi wrote: On Tue, May 26, 2015 at 11:37:17AM -0700, Arun Ramamurthy wrote: Hi On 15-05-26 07:19 AM, Felipe Balbi wrote: HI, On Mon, May 25, 2015 at 02:19:58PM -0700, Arun Ramamurthy wrote: On 15-05-14 05:52 PM, Felipe Balbi wrote: Hi, On Wed, Apr 22, 2015 at 04:04:10PM -0700, Arun Ramamurthy wrote: Most of the phy providers use select to enable GENERIC_PHY. Since select is only recommended when the config is not visible, GENERIC_PHY is changed an invisible option. To maintain consistency, all phy providers are changed to select GENERIC_PHY and all non-phy drivers use depends on when the phy framework is explicity required. USB_MUSB_OMAP2PLUS has a cyclic dependency, so it is left as select. Signed-off-by: Arun Ramamurthy arun.ramamur...@broadcom.com --- drivers/ata/Kconfig | 1 - drivers/media/platform/exynos4-is/Kconfig | 2 +- drivers/phy/Kconfig | 4 ++-- drivers/usb/host/Kconfig | 4 ++-- drivers/video/fbdev/exynos/Kconfig| 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index 5f60155..6d2e881 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig @@ -301,7 +301,6 @@ config SATA_MV tristate Marvell SATA support depends on PCI || ARCH_DOVE || ARCH_MV78XX0 || \ ARCH_MVEBU || ARCH_ORION5X || COMPILE_TEST - select GENERIC_PHY help This option enables support for the Marvell Serial ATA family. Currently supports 88SX[56]0[48][01] PCI(-X) chips, diff --git a/drivers/media/platform/exynos4-is/Kconfig b/drivers/media/platform/exynos4-is/Kconfig index b7b2e47..b6f3eaa 100644 --- a/drivers/media/platform/exynos4-is/Kconfig +++ b/drivers/media/platform/exynos4-is/Kconfig @@ -31,7 +31,7 @@ config VIDEO_S5P_FIMC config VIDEO_S5P_MIPI_CSIS tristate S5P/EXYNOS MIPI-CSI2 receiver (MIPI-CSIS) driver depends on REGULATOR - select GENERIC_PHY + depends on GENERIC_PHY help This is a V4L2 driver for Samsung S5P and EXYNOS4 SoC MIPI-CSI2 receiver (MIPI-CSIS) devices. diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 2962de2..edecdb1 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -5,7 +5,7 @@ menu PHY Subsystem config GENERIC_PHY - bool PHY Core + bool help Generic PHY support. @@ -72,7 +72,7 @@ config PHY_MIPHY365X config PHY_RCAR_GEN2 tristate Renesas R-Car generation 2 USB PHY driver depends on ARCH_SHMOBILE - depends on GENERIC_PHY + select GENERIC_PHY so some you changed from depends to select... help Support for USB PHY found on Renesas R-Car generation 2 SoCs. diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 5ad60e4..e2197e2 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -182,7 +182,7 @@ config USB_EHCI_HCD_SPEAR config USB_EHCI_HCD_STI tristate Support for ST STiHxxx on-chip EHCI USB controller depends on ARCH_STI OF - select GENERIC_PHY + depends on GENERIC_PHY while others you changed from select to depends. NAK. Felipe, I dont understand your concern, could you please explain it more detail? The logic behind the changes is that in cases where there was an explicit dependency, I changed it to depends on and in other cases I changed it to selects. Thanks Since GENERIC_PHY is visible from Kconfig, it would be much nicer to avoid select altogether. Felipe, after discussion with the maintainers, I have made GENERIC_PHY an invisible option as part of this change. Thanks Then, if the option is invisible, how can you depend on it ? It can never be selected by poking around in Kconfig. IMO, it's counterintuitive that you need to enable a PHY driver before you can see your EHCI/OHCI/whatever controller listed in Kconfig. If the controller requires PHY for it to be functional, it is okay to make the controller depend on PHY IMHO. We want to try and minimize the usage of 'select' wherever possible or else 'select' is the most intuitive way. The other option is just to leave the 'depends on' and let the user select PHY. Thanks Kishon -- 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
Re: [PATCHv3 1/4] phy: phy-core: Make GENERIC_PHY an invisible option
Tejun, Maxime, Sylwester, Kyungmin On Thursday 23 April 2015 04:34 AM, Arun Ramamurthy wrote: Most of the phy providers use select to enable GENERIC_PHY. Since select is only recommended when the config is not visible, GENERIC_PHY is changed an invisible option. To maintain consistency, all phy providers are changed to select GENERIC_PHY and all non-phy drivers use depends on when the phy framework is explicity required. USB_MUSB_OMAP2PLUS has a cyclic dependency, so it is left as select. Signed-off-by: Arun Ramamurthy arun.ramamur...@broadcom.com Need your ACK for this patch. Thanks Kishon --- drivers/ata/Kconfig | 1 - drivers/media/platform/exynos4-is/Kconfig | 2 +- drivers/phy/Kconfig | 4 ++-- drivers/usb/host/Kconfig | 4 ++-- drivers/video/fbdev/exynos/Kconfig| 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index 5f60155..6d2e881 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig @@ -301,7 +301,6 @@ config SATA_MV tristate Marvell SATA support depends on PCI || ARCH_DOVE || ARCH_MV78XX0 || \ ARCH_MVEBU || ARCH_ORION5X || COMPILE_TEST - select GENERIC_PHY help This option enables support for the Marvell Serial ATA family. Currently supports 88SX[56]0[48][01] PCI(-X) chips, diff --git a/drivers/media/platform/exynos4-is/Kconfig b/drivers/media/platform/exynos4-is/Kconfig index b7b2e47..b6f3eaa 100644 --- a/drivers/media/platform/exynos4-is/Kconfig +++ b/drivers/media/platform/exynos4-is/Kconfig @@ -31,7 +31,7 @@ config VIDEO_S5P_FIMC config VIDEO_S5P_MIPI_CSIS tristate S5P/EXYNOS MIPI-CSI2 receiver (MIPI-CSIS) driver depends on REGULATOR - select GENERIC_PHY + depends on GENERIC_PHY help This is a V4L2 driver for Samsung S5P and EXYNOS4 SoC MIPI-CSI2 receiver (MIPI-CSIS) devices. diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 2962de2..edecdb1 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -5,7 +5,7 @@ menu PHY Subsystem config GENERIC_PHY - bool PHY Core + bool help Generic PHY support. @@ -72,7 +72,7 @@ config PHY_MIPHY365X config PHY_RCAR_GEN2 tristate Renesas R-Car generation 2 USB PHY driver depends on ARCH_SHMOBILE - depends on GENERIC_PHY + select GENERIC_PHY help Support for USB PHY found on Renesas R-Car generation 2 SoCs. diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 5ad60e4..e2197e2 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -182,7 +182,7 @@ config USB_EHCI_HCD_SPEAR config USB_EHCI_HCD_STI tristate Support for ST STiHxxx on-chip EHCI USB controller depends on ARCH_STI OF - select GENERIC_PHY + depends on GENERIC_PHY select USB_EHCI_HCD_PLATFORM help Enable support for the on-chip EHCI controller found on @@ -409,7 +409,7 @@ config USB_OHCI_HCD_SPEAR config USB_OHCI_HCD_STI tristate Support for ST STiHxxx on-chip OHCI USB controller depends on ARCH_STI OF - select GENERIC_PHY + depends on GENERIC_PHY select USB_OHCI_HCD_PLATFORM help Enable support for the on-chip OHCI controller found on diff --git a/drivers/video/fbdev/exynos/Kconfig b/drivers/video/fbdev/exynos/Kconfig index 1f16b46..6c53894 100644 --- a/drivers/video/fbdev/exynos/Kconfig +++ b/drivers/video/fbdev/exynos/Kconfig @@ -16,7 +16,7 @@ if EXYNOS_VIDEO config EXYNOS_MIPI_DSI bool EXYNOS MIPI DSI driver support. - select GENERIC_PHY + depends on GENERIC_PHY help This enables support for MIPI-DSI device. -- 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
Re: [PATCHv3 0/4] add devm_of_phy_get_by_index and update platform drivers
Hi, On Thursday 23 April 2015 08:01 PM, Alan Stern wrote: On Wed, 22 Apr 2015, Arun Ramamurthy wrote: This patch set adds a new API to get phy by index when multiple phys are present. This patch is based on discussion with Arnd Bergmann about dt bindings for multiple phys. History: v1: - Removed null pointers on Dmitry's suggestion - Improved documentation in commit messages - Exported new phy api v2: - EHCI and OHCI platform Kconfigs select Generic Phy to fix build errors in certain configs. v3: - Made GENERIC_PHY an invisible option so that other configs can select it - Added stubs for devm_of_phy_get_by_index - Reformated code Arun Ramamurthy (4): phy: phy-core: Make GENERIC_PHY an invisible option phy: core: Add devm_of_phy_get_by_index to phy-core usb: ehci-platform: Use devm_of_phy_get_by_index usb: ohci-platform: Use devm_of_phy_get_by_index For patches 3 and 4: Acked-by: Alan Stern st...@rowland.harvard.edu merged this to linux-phy. Thanks Kishon -- 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
Re: [PATCHv3 2/4] phy: core: Add devm_of_phy_get_by_index to phy-core
Hi, On Thursday 23 April 2015 04:34 AM, Arun Ramamurthy wrote: Some generic drivers, such as ehci, may use multiple phys and for such drivers referencing phy(s) by name(s) does not make sense. Instead of inventing new naming schemes and using custom code to iterate through them, such drivers are better of using nameless phy bindings and using this newly introduced API to iterate through them. Signed-off-by: Arun Ramamurthy arun.ramamur...@broadcom.com Reviewed-by: Ray Jui r...@broadcom.com Reviewed-by: Scott Branden sbran...@broadcom.com --- Documentation/phy.txt | 7 ++- drivers/phy/phy-core.c | 32 include/linux/phy/phy.h | 8 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Documentation/phy.txt b/Documentation/phy.txt index 371361c..b388c5a 100644 --- a/Documentation/phy.txt +++ b/Documentation/phy.txt @@ -76,6 +76,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_by_index(struct device *dev, struct device_node *np, +int index); phy_get, phy_optional_get, devm_phy_get and devm_phy_optional_get can be used to get the PHY. In the case of dt boot, the string arguments @@ -86,7 +88,10 @@ successful PHY get. On driver detach, release function is invoked on the the devres data and devres data is freed. phy_optional_get and devm_phy_optional_get should be used when the phy is optional. These two functions will never return -ENODEV, but instead returns NULL when -the phy cannot be found. +the phy cannot be found.Some generic drivers, such as ehci, may use multiple +phys and for such drivers referencing phy(s) by name(s) does not make sense. In +this case, devm_of_phy_get_by_index can be used to get a phy reference based on +the index. It should be noted that NULL is a valid phy reference. All phy consumer calls on the NULL phy become NOPs. That is the release calls, diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 3791838..964a84d 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -623,6 +623,38 @@ struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, EXPORT_SYMBOL_GPL(devm_of_phy_get); /** + * devm_of_phy_get_by_index() - lookup and obtain a reference to a phy by index. + * @dev: device that requests this phy + * @np: node containing the phy + * @index: index of the phy + * + * 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_by_index(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_by_index); + +/** * phy_create() - create a new phy * @dev: device that is creating the new phy * @node: device node of the phy diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index a0197fa..978d5af 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -133,6 +133,8 @@ 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); +struct phy *devm_of_phy_get_by_index(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, const char *con_id); @@ -261,6 +263,12 @@ static inline struct phy *devm_of_phy_get(struct device *dev, return ERR_PTR(-ENOSYS); } +struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np, +int index); Fixed the compilation error because of the ';' in the end and merged it to linux-phy. Thanks Kishon -- 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
Re: [PATCHv2 1/3] phy: Add exynos-simple-phy driver
Hi, On Wednesday 09 April 2014 03:31 PM, Sylwester Nawrocki wrote: Hi, On 09/04/14 11:12, Rahul Sharma wrote: Idea looks good. How about keeping compatible which is independent of SoC, something like samsung,exynos-simple-phy and provide Reg and Bit through phy provider node. This way we can avoid SoC specific hardcoding in phy driver and don't need to look into dt bindings for each new SoC. I believe it is a not recommended approach. Why not? We should try to avoid hard coding in the driver code. Moreover by avoiding hardcoding we can make it a generic driver for single bit PHYs. Cheers Kishon -- 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
Re: [PATCH 3/7] video: exynos_mipi_dsim: Use the generic PHY driver
Hi, On Thursday 24 October 2013 09:12 PM, Sachin Kamat wrote: Hi Olof, On 24 October 2013 20:00, Olof Johansson o...@lixom.net wrote: Hi Kishon, On Wed, Oct 16, 2013 at 9:28 AM, Kishon Vijay Abraham I kis...@ti.com wrote: diff --git a/drivers/video/exynos/exynos_mipi_dsi.c b/drivers/video/exynos/exynos_mipi_dsi.c index 32e5406..00b3a52 100644 --- a/drivers/video/exynos/exynos_mipi_dsi.c +++ b/drivers/video/exynos/exynos_mipi_dsi.c @@ -156,8 +157,7 @@ static int exynos_mipi_dsi_blank_mode(struct mipi_dsim_device *dsim, int power) exynos_mipi_regulator_enable(dsim); /* enable MIPI-DSI PHY. */ - if (dsim-pd-phy_enable) - dsim-pd-phy_enable(pdev, true); + phy_power_on(dsim-phy); clk_enable(dsim-clock); This introduces the below with exynos_defconfig: ../../drivers/video/exynos/exynos_mipi_dsi.c: In function 'exynos_mipi_dsi_blank_mode': ../../drivers/video/exynos/exynos_mipi_dsi.c:144:26: warning: unused variable 'pdev' [-Wunused-variable] struct platform_device *pdev = to_platform_device(dsim-dev); I have already submitted a patch to fix this [1] [1] http://marc.info/?l=linux-fbdevm=138233359617936w=2 Sorry, missed that :-( Thanks Kishon -- 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
[PATCH 0/7] video phy's adaptation to *generic phy framework*
Hi Greg, This series includes video PHY adaptation to Generic PHY Framework. With the adaptation they were able to get rid of plat data callbacks. Since you've taken the Generic PHY Framework, I think this series should also go into your tree. We should thank Sylwester for actively testing and giving comments from the initial versions of Generic Phy Framework. Both Sylwester and Jingoo had been floating many revisions of their adaptation to Generic PHY Framework. This has been in my repo for quite some time and has got acks from samsung maintainer and video maintainer. If you want me to change anything, please let me know. This patch series can be found @ git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git testing Jingoo Han (3): phy: Add driver for Exynos DP PHY video: exynos_dp: remove non-DT support for Exynos Display Port video: exynos_dp: Use the generic PHY driver Sylwester Nawrocki (4): phy: Add driver for Exynos MIPI CSIS/DSIM DPHYs exynos4-is: Use the generic MIPI CSIS PHY driver video: exynos_mipi_dsim: Use the generic PHY driver ARM: Samsung: Remove the MIPI PHY setup code .../devicetree/bindings/phy/samsung-phy.txt| 22 +++ .../devicetree/bindings/video/exynos_dp.txt| 17 +- arch/arm/mach-exynos/include/mach/regs-pmu.h |5 - arch/arm/mach-s5pv210/include/mach/regs-clock.h|4 - arch/arm/plat-samsung/Kconfig |5 - arch/arm/plat-samsung/Makefile |1 - arch/arm/plat-samsung/setup-mipiphy.c | 60 --- drivers/media/platform/exynos4-is/Kconfig |2 +- drivers/media/platform/exynos4-is/mipi-csis.c | 13 +- drivers/phy/Kconfig| 13 ++ drivers/phy/Makefile |8 +- drivers/phy/phy-exynos-dp-video.c | 111 drivers/phy/phy-exynos-mipi-video.c| 176 drivers/video/exynos/Kconfig |3 +- drivers/video/exynos/exynos_dp_core.c | 132 --- drivers/video/exynos/exynos_dp_core.h | 110 drivers/video/exynos/exynos_dp_reg.c |2 - drivers/video/exynos/exynos_mipi_dsi.c | 19 ++- include/linux/platform_data/mipi-csis.h|9 - include/video/exynos_dp.h | 131 --- include/video/exynos_mipi_dsim.h |5 +- 21 files changed, 508 insertions(+), 340 deletions(-) create mode 100644 Documentation/devicetree/bindings/phy/samsung-phy.txt delete mode 100644 arch/arm/plat-samsung/setup-mipiphy.c create mode 100644 drivers/phy/phy-exynos-dp-video.c create mode 100644 drivers/phy/phy-exynos-mipi-video.c delete mode 100644 include/video/exynos_dp.h -- 1.7.10.4 -- 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
[PATCH 7/7] video: exynos_dp: Use the generic PHY driver
From: Jingoo Han jg1@samsung.com Use the generic PHY API to control the DP PHY. Signed-off-by: Jingoo Han jg1@samsung.com Reviewed-by: Tomasz Figa t.f...@samsung.com Signed-off-by: Kishon Vijay Abraham I kis...@ti.com --- Documentation/devicetree/bindings/video/exynos_dp.txt | 17 + drivers/video/exynos/exynos_dp_core.c | 16 drivers/video/exynos/exynos_dp_core.h |1 + 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Documentation/devicetree/bindings/video/exynos_dp.txt b/Documentation/devicetree/bindings/video/exynos_dp.txt index 84f10c1..3289d76 100644 --- a/Documentation/devicetree/bindings/video/exynos_dp.txt +++ b/Documentation/devicetree/bindings/video/exynos_dp.txt @@ -6,10 +6,10 @@ We use two nodes: -dptx-phy node(defined inside dp-controller node) For the DP-PHY initialization, we use the dptx-phy node. -Required properties for dptx-phy: - -reg: +Required properties for dptx-phy: deprecated, use phys and phy-names + -reg: deprecated Base address of DP PHY register. - -samsung,enable-mask: + -samsung,enable-mask: deprecated The bit-mask used to enable/disable DP PHY. For the Panel initialization, we read data from dp-controller node. @@ -27,6 +27,10 @@ Required properties for dp-controller: from common clock binding: Shall be dp. -interrupt-parent: phandle to Interrupt combiner node. + -phys: + from general PHY binding: the phandle for the PHY device. + -phy-names: + from general PHY binding: Should be dp. -samsung,color-space: input video data format. COLOR_RGB = 0, COLOR_YCBCR422 = 1, COLOR_YCBCR444 = 2 @@ -68,11 +72,8 @@ SOC specific portion: clocks = clock 342; clock-names = dp; - dptx-phy { - reg = 0x10040720; - samsung,enable-mask = 1; - }; - + phys = dp_phy; + phy-names = dp; }; Board Specific portion: diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c index 05fed7d..5e1a715 100644 --- a/drivers/video/exynos/exynos_dp_core.c +++ b/drivers/video/exynos/exynos_dp_core.c @@ -19,6 +19,7 @@ #include linux/interrupt.h #include linux/delay.h #include linux/of.h +#include linux/phy/phy.h #include exynos_dp_core.h @@ -960,8 +961,11 @@ static int exynos_dp_dt_parse_phydata(struct exynos_dp_device *dp) dp_phy_node = of_find_node_by_name(dp_phy_node, dptx-phy); if (!dp_phy_node) { - dev_err(dp-dev, could not find dptx-phy node\n); - return -ENODEV; + dp-phy = devm_phy_get(dp-dev, dp); + if (IS_ERR(dp-phy)) + return PTR_ERR(dp-phy); + else + return 0; } if (of_property_read_u32(dp_phy_node, reg, phy_base)) { @@ -992,7 +996,9 @@ err: static void exynos_dp_phy_init(struct exynos_dp_device *dp) { - if (dp-phy_addr) { + if (dp-phy) { + phy_power_on(dp-phy); + } else if (dp-phy_addr) { u32 reg; reg = __raw_readl(dp-phy_addr); @@ -1003,7 +1009,9 @@ static void exynos_dp_phy_init(struct exynos_dp_device *dp) static void exynos_dp_phy_exit(struct exynos_dp_device *dp) { - if (dp-phy_addr) { + if (dp-phy) { + phy_power_off(dp-phy); + } else if (dp-phy_addr) { u32 reg; reg = __raw_readl(dp-phy_addr); diff --git a/drivers/video/exynos/exynos_dp_core.h b/drivers/video/exynos/exynos_dp_core.h index 56cfec8..607e36d 100644 --- a/drivers/video/exynos/exynos_dp_core.h +++ b/drivers/video/exynos/exynos_dp_core.h @@ -151,6 +151,7 @@ struct exynos_dp_device { struct video_info *video_info; struct link_train link_train; struct work_struct hotplug_work; + struct phy *phy; }; /* exynos_dp_reg.c */ -- 1.7.10.4 -- 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
[PATCH 4/7] ARM: Samsung: Remove the MIPI PHY setup code
From: Sylwester Nawrocki sylvester.nawro...@gmail.com Generic PHY drivers are used to handle the MIPI CSIS and MIPI DSIM DPHYs so we can remove now unused code at arch/arm/plat-samsung. In case there is any board file for S5PV210 platforms using MIPI CSIS/DSIM (not any upstream currently) it should use the generic PHY API to bind the PHYs to respective PHY consumer drivers and a platform device for the PHY provider should be defined. Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com Acked-by: Felipe Balbi ba...@ti.com Acked-by: Kukjin Kim kgene@samsung.com Signed-off-by: Kishon Vijay Abraham I kis...@ti.com --- arch/arm/mach-exynos/include/mach/regs-pmu.h|5 -- arch/arm/mach-s5pv210/include/mach/regs-clock.h |4 -- arch/arm/plat-samsung/Kconfig |5 -- arch/arm/plat-samsung/Makefile |1 - arch/arm/plat-samsung/setup-mipiphy.c | 60 --- 5 files changed, 75 deletions(-) delete mode 100644 arch/arm/plat-samsung/setup-mipiphy.c diff --git a/arch/arm/mach-exynos/include/mach/regs-pmu.h b/arch/arm/mach-exynos/include/mach/regs-pmu.h index 57344b7..2cdb63e 100644 --- a/arch/arm/mach-exynos/include/mach/regs-pmu.h +++ b/arch/arm/mach-exynos/include/mach/regs-pmu.h @@ -44,11 +44,6 @@ #define S5P_DAC_PHY_CONTROLS5P_PMUREG(0x070C) #define S5P_DAC_PHY_ENABLE (1 0) -#define S5P_MIPI_DPHY_CONTROL(n) S5P_PMUREG(0x0710 + (n) * 4) -#define S5P_MIPI_DPHY_ENABLE (1 0) -#define S5P_MIPI_DPHY_SRESETN (1 1) -#define S5P_MIPI_DPHY_MRESETN (1 2) - #define S5P_INFORM0S5P_PMUREG(0x0800) #define S5P_INFORM1S5P_PMUREG(0x0804) #define S5P_INFORM2S5P_PMUREG(0x0808) diff --git a/arch/arm/mach-s5pv210/include/mach/regs-clock.h b/arch/arm/mach-s5pv210/include/mach/regs-clock.h index 032de66..e345584 100644 --- a/arch/arm/mach-s5pv210/include/mach/regs-clock.h +++ b/arch/arm/mach-s5pv210/include/mach/regs-clock.h @@ -147,10 +147,6 @@ #define S5P_HDMI_PHY_CONTROL S5P_CLKREG(0xE804) #define S5P_USB_PHY_CONTROLS5P_CLKREG(0xE80C) #define S5P_DAC_PHY_CONTROLS5P_CLKREG(0xE810) -#define S5P_MIPI_DPHY_CONTROL(x) S5P_CLKREG(0xE814) -#define S5P_MIPI_DPHY_ENABLE (1 0) -#define S5P_MIPI_DPHY_SRESETN (1 1) -#define S5P_MIPI_DPHY_MRESETN (1 2) #define S5P_INFORM0S5P_CLKREG(0xF000) #define S5P_INFORM1S5P_CLKREG(0xF004) diff --git a/arch/arm/plat-samsung/Kconfig b/arch/arm/plat-samsung/Kconfig index 7dfba93..ec882ad 100644 --- a/arch/arm/plat-samsung/Kconfig +++ b/arch/arm/plat-samsung/Kconfig @@ -395,11 +395,6 @@ config S3C24XX_PWM Support for exporting the PWM timer blocks via the pwm device system -config S5P_SETUP_MIPIPHY - bool - help - Compile in common setup code for MIPI-CSIS and MIPI-DSIM devices - config S3C_SETUP_CAMIF bool help diff --git a/arch/arm/plat-samsung/Makefile b/arch/arm/plat-samsung/Makefile index 498c7c2..9267d29 100644 --- a/arch/arm/plat-samsung/Makefile +++ b/arch/arm/plat-samsung/Makefile @@ -38,7 +38,6 @@ obj-$(CONFIG_S5P_DEV_UART)+= s5p-dev-uart.o obj-$(CONFIG_SAMSUNG_DEV_BACKLIGHT)+= dev-backlight.o obj-$(CONFIG_S3C_SETUP_CAMIF) += setup-camif.o -obj-$(CONFIG_S5P_SETUP_MIPIPHY)+= setup-mipiphy.o # DMA support diff --git a/arch/arm/plat-samsung/setup-mipiphy.c b/arch/arm/plat-samsung/setup-mipiphy.c deleted file mode 100644 index 66df315..000 --- a/arch/arm/plat-samsung/setup-mipiphy.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2011 Samsung Electronics Co., Ltd. - * - * S5P - Helper functions for MIPI-CSIS and MIPI-DSIM D-PHY control - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#include linux/export.h -#include linux/kernel.h -#include linux/platform_device.h -#include linux/io.h -#include linux/spinlock.h -#include mach/regs-clock.h - -static int __s5p_mipi_phy_control(int id, bool on, u32 reset) -{ - static DEFINE_SPINLOCK(lock); - void __iomem *addr; - unsigned long flags; - u32 cfg; - - id = max(0, id); - if (id 1) - return -EINVAL; - - addr = S5P_MIPI_DPHY_CONTROL(id); - - spin_lock_irqsave(lock, flags); - - cfg = __raw_readl(addr); - cfg = on ? (cfg | reset) : (cfg ~reset); - __raw_writel(cfg, addr); - - if (on) { - cfg |= S5P_MIPI_DPHY_ENABLE; - } else if (!(cfg (S5P_MIPI_DPHY_SRESETN | - S5P_MIPI_DPHY_MRESETN) ~reset)) { - cfg = ~S5P_MIPI_DPHY_ENABLE; - } - - __raw_writel(cfg, addr
[PATCH 2/7] exynos4-is: Use the generic MIPI CSIS PHY driver
From: Sylwester Nawrocki sylvester.nawro...@gmail.com Use the generic PHY API instead of the platform callback to control the MIPI CSIS DPHY. Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com Acked-by: Felipe Balbi ba...@ti.com Acked-by: Mauro Carvalho Chehab mche...@redhat.com Signed-off-by: Kishon Vijay Abraham I kis...@ti.com --- drivers/media/platform/exynos4-is/Kconfig |2 +- drivers/media/platform/exynos4-is/mipi-csis.c | 13 ++--- include/linux/platform_data/mipi-csis.h |9 - 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/media/platform/exynos4-is/Kconfig b/drivers/media/platform/exynos4-is/Kconfig index 53ad0f0..d2d3b4b 100644 --- a/drivers/media/platform/exynos4-is/Kconfig +++ b/drivers/media/platform/exynos4-is/Kconfig @@ -29,7 +29,7 @@ config VIDEO_S5P_FIMC config VIDEO_S5P_MIPI_CSIS tristate S5P/EXYNOS MIPI-CSI2 receiver (MIPI-CSIS) driver depends on REGULATOR - select S5P_SETUP_MIPIPHY + select GENERIC_PHY help This is a V4L2 driver for Samsung S5P and EXYNOS4 SoC MIPI-CSI2 receiver (MIPI-CSIS) devices. diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c b/drivers/media/platform/exynos4-is/mipi-csis.c index 0914230..9fc2af6 100644 --- a/drivers/media/platform/exynos4-is/mipi-csis.c +++ b/drivers/media/platform/exynos4-is/mipi-csis.c @@ -20,6 +20,7 @@ #include linux/memory.h #include linux/module.h #include linux/of.h +#include linux/phy/phy.h #include linux/platform_data/mipi-csis.h #include linux/platform_device.h #include linux/pm_runtime.h @@ -180,6 +181,7 @@ struct csis_drvdata { * @sd: v4l2_subdev associated with CSIS device instance * @index: the hardware instance index * @pdev: CSIS platform device + * @phy: pointer to the CSIS generic PHY * @regs: mmaped I/O registers memory * @supplies: CSIS regulator supplies * @clock: CSIS clocks @@ -203,6 +205,7 @@ struct csis_state { struct v4l2_subdev sd; u8 index; struct platform_device *pdev; + struct phy *phy; void __iomem *regs; struct regulator_bulk_data supplies[CSIS_NUM_SUPPLIES]; struct clk *clock[NUM_CSIS_CLOCKS]; @@ -779,8 +782,8 @@ static int s5pcsis_parse_dt(struct platform_device *pdev, samsung,csis-wclk); state-num_lanes = endpoint.bus.mipi_csi2.num_data_lanes; - of_node_put(node); + return 0; } #else @@ -829,6 +832,10 @@ static int s5pcsis_probe(struct platform_device *pdev) return -EINVAL; } + state-phy = devm_phy_get(dev, csis); + if (IS_ERR(state-phy)) + return PTR_ERR(state-phy); + mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); state-regs = devm_ioremap_resource(dev, mem_res); if (IS_ERR(state-regs)) @@ -922,7 +929,7 @@ static int s5pcsis_pm_suspend(struct device *dev, bool runtime) mutex_lock(state-lock); if (state-flags ST_POWERED) { s5pcsis_stop_stream(state); - ret = s5p_csis_phy_enable(state-index, false); + ret = phy_power_off(state-phy); if (ret) goto unlock; ret = regulator_bulk_disable(CSIS_NUM_SUPPLIES, @@ -958,7 +965,7 @@ static int s5pcsis_pm_resume(struct device *dev, bool runtime) state-supplies); if (ret) goto unlock; - ret = s5p_csis_phy_enable(state-index, true); + ret = phy_power_on(state-phy); if (!ret) { state-flags |= ST_POWERED; } else { diff --git a/include/linux/platform_data/mipi-csis.h b/include/linux/platform_data/mipi-csis.h index bf34e17..c2fd902 100644 --- a/include/linux/platform_data/mipi-csis.h +++ b/include/linux/platform_data/mipi-csis.h @@ -25,13 +25,4 @@ struct s5p_platform_mipi_csis { u8 hs_settle; }; -/** - * s5p_csis_phy_enable - global MIPI-CSI receiver D-PHY control - * @id: MIPI-CSIS harware instance index (0...1) - * @on: true to enable D-PHY and deassert its reset - * false to disable D-PHY - * @return: 0 on success, or negative error code on failure - */ -int s5p_csis_phy_enable(int id, bool on); - #endif /* __PLAT_SAMSUNG_MIPI_CSIS_H_ */ -- 1.7.10.4 -- 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
[PATCH 3/7] video: exynos_mipi_dsim: Use the generic PHY driver
From: Sylwester Nawrocki sylvester.nawro...@gmail.com Use the generic PHY API instead of the platform callback for the MIPI DSIM DPHY enable/reset control. Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com Acked-by: Felipe Balbi ba...@ti.com Acked-by: Donghwa Lee dh09@samsung.com Acked-by: Tomi Valkeinen tomi.valkei...@ti.com Signed-off-by: Kishon Vijay Abraham I kis...@ti.com --- drivers/video/exynos/Kconfig |1 + drivers/video/exynos/exynos_mipi_dsi.c | 19 ++- include/video/exynos_mipi_dsim.h |5 ++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/video/exynos/Kconfig b/drivers/video/exynos/Kconfig index 1b035b2..976594d 100644 --- a/drivers/video/exynos/Kconfig +++ b/drivers/video/exynos/Kconfig @@ -16,6 +16,7 @@ if EXYNOS_VIDEO config EXYNOS_MIPI_DSI bool EXYNOS MIPI DSI driver support. depends on ARCH_S5PV210 || ARCH_EXYNOS + select GENERIC_PHY help This enables support for MIPI-DSI device. diff --git a/drivers/video/exynos/exynos_mipi_dsi.c b/drivers/video/exynos/exynos_mipi_dsi.c index 32e5406..00b3a52 100644 --- a/drivers/video/exynos/exynos_mipi_dsi.c +++ b/drivers/video/exynos/exynos_mipi_dsi.c @@ -30,6 +30,7 @@ #include linux/interrupt.h #include linux/kthread.h #include linux/notifier.h +#include linux/phy/phy.h #include linux/regulator/consumer.h #include linux/pm_runtime.h #include linux/err.h @@ -156,8 +157,7 @@ static int exynos_mipi_dsi_blank_mode(struct mipi_dsim_device *dsim, int power) exynos_mipi_regulator_enable(dsim); /* enable MIPI-DSI PHY. */ - if (dsim-pd-phy_enable) - dsim-pd-phy_enable(pdev, true); + phy_power_on(dsim-phy); clk_enable(dsim-clock); @@ -373,6 +373,10 @@ static int exynos_mipi_dsi_probe(struct platform_device *pdev) return ret; } + dsim-phy = devm_phy_get(pdev-dev, dsim); + if (IS_ERR(dsim-phy)) + return PTR_ERR(dsim-phy); + dsim-clock = devm_clk_get(pdev-dev, dsim0); if (IS_ERR(dsim-clock)) { dev_err(pdev-dev, failed to get dsim clock source\n); @@ -439,8 +443,7 @@ static int exynos_mipi_dsi_probe(struct platform_device *pdev) exynos_mipi_regulator_enable(dsim); /* enable MIPI-DSI PHY. */ - if (dsim-pd-phy_enable) - dsim-pd-phy_enable(pdev, true); + phy_power_on(dsim-phy); exynos_mipi_update_cfg(dsim); @@ -504,9 +507,8 @@ static int exynos_mipi_dsi_suspend(struct device *dev) if (client_drv client_drv-suspend) client_drv-suspend(client_dev); - /* enable MIPI-DSI PHY. */ - if (dsim-pd-phy_enable) - dsim-pd-phy_enable(pdev, false); + /* disable MIPI-DSI PHY. */ + phy_power_off(dsim-phy); clk_disable(dsim-clock); @@ -536,8 +538,7 @@ static int exynos_mipi_dsi_resume(struct device *dev) exynos_mipi_regulator_enable(dsim); /* enable MIPI-DSI PHY. */ - if (dsim-pd-phy_enable) - dsim-pd-phy_enable(pdev, true); + phy_power_on(dsim-phy); clk_enable(dsim-clock); diff --git a/include/video/exynos_mipi_dsim.h b/include/video/exynos_mipi_dsim.h index 89dc88a..6a578f8 100644 --- a/include/video/exynos_mipi_dsim.h +++ b/include/video/exynos_mipi_dsim.h @@ -216,6 +216,7 @@ struct mipi_dsim_config { * automatically. * @e_clk_src: select byte clock source. * @pd: pointer to MIPI-DSI driver platform data. + * @phy: pointer to the MIPI-DSI PHY */ struct mipi_dsim_device { struct device *dev; @@ -236,6 +237,7 @@ struct mipi_dsim_device { boolsuspended; struct mipi_dsim_platform_data *pd; + struct phy *phy; }; /* @@ -248,7 +250,6 @@ struct mipi_dsim_device { * @enabled: indicate whether mipi controller got enabled or not. * @lcd_panel_info: pointer for lcd panel specific structure. * this structure specifies width, height, timing and polarity and so on. - * @phy_enable: pointer to a callback controlling D-PHY enable/reset */ struct mipi_dsim_platform_data { charlcd_panel_name[PANEL_NAME_SIZE]; @@ -256,8 +257,6 @@ struct mipi_dsim_platform_data { struct mipi_dsim_config *dsim_config; unsigned intenabled; void*lcd_panel_info; - - int (*phy_enable)(struct platform_device *pdev, bool on); }; /* -- 1.7.10.4 -- 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
[PATCH 6/7] video: exynos_dp: remove non-DT support for Exynos Display Port
From: Jingoo Han jg1@samsung.com Exynos Display Port can be used only for Exynos SoCs. In addition, non-DT for EXYNOS SoCs is not supported from v3.11; thus, there is no need to support non-DT for Exynos Display Port. The 'include/video/exynos_dp.h' file has been used for non-DT support and the content of file include/video/exynos_dp.h is moved to drivers/video/exynos/exynos_dp_core.h. Thus, the 'exynos_dp.h' file is removed. Also, 'struct exynos_dp_platdata' is removed, because it is not used any more. Signed-off-by: Jingoo Han jg1@samsung.com Reviewed-by: Tomasz Figa t.f...@samsung.com Signed-off-by: Kishon Vijay Abraham I kis...@ti.com --- drivers/video/exynos/Kconfig |2 +- drivers/video/exynos/exynos_dp_core.c | 116 +++-- drivers/video/exynos/exynos_dp_core.h | 109 +++ drivers/video/exynos/exynos_dp_reg.c |2 - include/video/exynos_dp.h | 131 - 5 files changed, 135 insertions(+), 225 deletions(-) delete mode 100644 include/video/exynos_dp.h diff --git a/drivers/video/exynos/Kconfig b/drivers/video/exynos/Kconfig index 976594d..1129d0e 100644 --- a/drivers/video/exynos/Kconfig +++ b/drivers/video/exynos/Kconfig @@ -30,7 +30,7 @@ config EXYNOS_LCD_S6E8AX0 config EXYNOS_DP bool EXYNOS DP driver support - depends on ARCH_EXYNOS + depends on OF ARCH_EXYNOS default n help This enables support for DP device. diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c index 12bbede..05fed7d 100644 --- a/drivers/video/exynos/exynos_dp_core.c +++ b/drivers/video/exynos/exynos_dp_core.c @@ -20,8 +20,6 @@ #include linux/delay.h #include linux/of.h -#include video/exynos_dp.h - #include exynos_dp_core.h static int exynos_dp_init_dp(struct exynos_dp_device *dp) @@ -894,26 +892,17 @@ static void exynos_dp_hotplug(struct work_struct *work) dev_err(dp-dev, unable to config video\n); } -#ifdef CONFIG_OF -static struct exynos_dp_platdata *exynos_dp_dt_parse_pdata(struct device *dev) +static struct video_info *exynos_dp_dt_parse_pdata(struct device *dev) { struct device_node *dp_node = dev-of_node; - struct exynos_dp_platdata *pd; struct video_info *dp_video_config; - pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); - if (!pd) { - dev_err(dev, memory allocation for pdata failed\n); - return ERR_PTR(-ENOMEM); - } dp_video_config = devm_kzalloc(dev, sizeof(*dp_video_config), GFP_KERNEL); - if (!dp_video_config) { dev_err(dev, memory allocation for video config failed\n); return ERR_PTR(-ENOMEM); } - pd-video_info = dp_video_config; dp_video_config-h_sync_polarity = of_property_read_bool(dp_node, hsync-active-high); @@ -960,7 +949,7 @@ static struct exynos_dp_platdata *exynos_dp_dt_parse_pdata(struct device *dev) return ERR_PTR(-EINVAL); } - return pd; + return dp_video_config; } static int exynos_dp_dt_parse_phydata(struct exynos_dp_device *dp) @@ -1003,48 +992,30 @@ err: static void exynos_dp_phy_init(struct exynos_dp_device *dp) { - u32 reg; + if (dp-phy_addr) { + u32 reg; - reg = __raw_readl(dp-phy_addr); - reg |= dp-enable_mask; - __raw_writel(reg, dp-phy_addr); + reg = __raw_readl(dp-phy_addr); + reg |= dp-enable_mask; + __raw_writel(reg, dp-phy_addr); + } } static void exynos_dp_phy_exit(struct exynos_dp_device *dp) { - u32 reg; - - reg = __raw_readl(dp-phy_addr); - reg = ~(dp-enable_mask); - __raw_writel(reg, dp-phy_addr); -} -#else -static struct exynos_dp_platdata *exynos_dp_dt_parse_pdata(struct device *dev) -{ - return NULL; -} - -static int exynos_dp_dt_parse_phydata(struct exynos_dp_device *dp) -{ - return -EINVAL; -} - -static void exynos_dp_phy_init(struct exynos_dp_device *dp) -{ - return; -} + if (dp-phy_addr) { + u32 reg; -static void exynos_dp_phy_exit(struct exynos_dp_device *dp) -{ - return; + reg = __raw_readl(dp-phy_addr); + reg = ~(dp-enable_mask); + __raw_writel(reg, dp-phy_addr); + } } -#endif /* CONFIG_OF */ static int exynos_dp_probe(struct platform_device *pdev) { struct resource *res; struct exynos_dp_device *dp; - struct exynos_dp_platdata *pdata; int ret = 0; @@ -1057,21 +1028,13 @@ static int exynos_dp_probe(struct platform_device *pdev) dp-dev = pdev-dev; - if (pdev-dev.of_node) { - pdata = exynos_dp_dt_parse_pdata(pdev-dev); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); + dp-video_info
[PATCH 1/7] phy: Add driver for Exynos MIPI CSIS/DSIM DPHYs
From: Sylwester Nawrocki sylvester.nawro...@gmail.com Add a PHY provider driver for the Samsung S5P/Exynos SoC MIPI CSI-2 receiver and MIPI DSI transmitter DPHYs. Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com Signed-off-by: Kishon Vijay Abraham I kis...@ti.com --- .../devicetree/bindings/phy/samsung-phy.txt| 14 ++ drivers/phy/Kconfig|6 + drivers/phy/Makefile |7 +- drivers/phy/phy-exynos-mipi-video.c| 176 4 files changed, 200 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/phy/samsung-phy.txt create mode 100644 drivers/phy/phy-exynos-mipi-video.c diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt new file mode 100644 index 000..5ff208c --- /dev/null +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -0,0 +1,14 @@ +Samsung S5P/EXYNOS SoC series MIPI CSIS/DSIM DPHY +- + +Required properties: +- compatible : should be samsung,s5pv210-mipi-video-phy; +- reg : offset and length of the MIPI DPHY register set; +- #phy-cells : from the generic phy bindings, must be 1; + +For samsung,s5pv210-mipi-video-phy compatible PHYs the second cell in +the PHY specifier identifies the PHY and its meaning is as follows: + 0 - MIPI CSIS 0, + 1 - MIPI DSIM 0, + 2 - MIPI CSIS 1, + 3 - MIPI DSIM 1. diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index ac239ac..0062d7e 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -15,6 +15,12 @@ config GENERIC_PHY 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 + Support for MIPI CSI-2 and MIPI DSI DPHY found on Samsung S5P + and EXYNOS SoCs. + config OMAP_USB2 tristate OMAP USB2 PHY Driver depends on ARCH_OMAP2PLUS diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 0dd8a98..6344053 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -2,6 +2,7 @@ # Makefile for the phy drivers. # -obj-$(CONFIG_GENERIC_PHY) += phy-core.o -obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o -obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o +obj-$(CONFIG_GENERIC_PHY) += phy-core.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 diff --git a/drivers/phy/phy-exynos-mipi-video.c b/drivers/phy/phy-exynos-mipi-video.c new file mode 100644 index 000..b73b86a --- /dev/null +++ b/drivers/phy/phy-exynos-mipi-video.c @@ -0,0 +1,176 @@ +/* + * Samsung S5P/EXYNOS SoC series MIPI CSIS/DSIM DPHY driver + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Sylwester Nawrocki s.nawro...@samsung.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include linux/io.h +#include linux/kernel.h +#include linux/module.h +#include linux/of.h +#include linux/of_address.h +#include linux/phy/phy.h +#include linux/platform_device.h +#include linux/spinlock.h + +/* MIPI_PHYn_CONTROL register offset: n = 0..1 */ +#define EXYNOS_MIPI_PHY_CONTROL(n) ((n) * 4) +#define EXYNOS_MIPI_PHY_ENABLE (1 0) +#define EXYNOS_MIPI_PHY_SRESETN(1 1) +#define EXYNOS_MIPI_PHY_MRESETN(1 2) +#define EXYNOS_MIPI_PHY_RESET_MASK (3 1) + +enum exynos_mipi_phy_id { + EXYNOS_MIPI_PHY_ID_CSIS0, + EXYNOS_MIPI_PHY_ID_DSIM0, + EXYNOS_MIPI_PHY_ID_CSIS1, + EXYNOS_MIPI_PHY_ID_DSIM1, + EXYNOS_MIPI_PHYS_NUM +}; + +#define is_mipi_dsim_phy_id(id) \ + ((id) == EXYNOS_MIPI_PHY_ID_DSIM0 || (id) == EXYNOS_MIPI_PHY_ID_DSIM1) + +struct exynos_mipi_video_phy { + spinlock_t slock; + struct video_phy_desc { + struct phy *phy; + unsigned int index; + } phys[EXYNOS_MIPI_PHYS_NUM]; + void __iomem *regs; +}; + +static int __set_phy_state(struct exynos_mipi_video_phy *state, + enum exynos_mipi_phy_id id, unsigned int on) +{ + void __iomem *addr; + u32 reg, reset; + + addr = state-regs + EXYNOS_MIPI_PHY_CONTROL(id / 2); + + if (is_mipi_dsim_phy_id(id)) + reset = EXYNOS_MIPI_PHY_MRESETN; + else + reset = EXYNOS_MIPI_PHY_SRESETN; + + spin_lock(state-slock); + reg = readl(addr); + if (on) + reg |= reset; + else + reg = ~reset; + writel(reg, addr
[PATCH 5/7] phy: Add driver for Exynos DP PHY
From: Jingoo Han jg1@samsung.com Add a PHY provider driver for the Samsung Exynos SoC Display Port PHY. Signed-off-by: Jingoo Han jg1@samsung.com Reviewed-by: Tomasz Figa t.f...@samsung.com Cc: Sylwester Nawrocki s.nawro...@samsung.com Acked-by: Felipe Balbi ba...@ti.com Signed-off-by: Kishon Vijay Abraham I kis...@ti.com --- .../devicetree/bindings/phy/samsung-phy.txt|8 ++ drivers/phy/Kconfig|7 ++ drivers/phy/Makefile |1 + drivers/phy/phy-exynos-dp-video.c | 111 4 files changed, 127 insertions(+) create mode 100644 drivers/phy/phy-exynos-dp-video.c diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index 5ff208c..c0fccaa 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -12,3 +12,11 @@ the PHY specifier identifies the PHY and its meaning is as follows: 1 - MIPI DSIM 0, 2 - MIPI CSIS 1, 3 - MIPI DSIM 1. + +Samsung EXYNOS SoC series Display Port PHY +- + +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; diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 0062d7e..a344f3d 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -44,4 +44,11 @@ config TWL4030_USB This transceiver supports high and full speed devices plus, in host mode, low speed. +config PHY_EXYNOS_DP_VIDEO + tristate EXYNOS SoC series Display Port PHY driver + depends on OF + select GENERIC_PHY + help + Support for Display Port PHY found on Samsung EXYNOS SoCs. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 6344053..d0caae9 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -3,6 +3,7 @@ # obj-$(CONFIG_GENERIC_PHY) += phy-core.o +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 diff --git a/drivers/phy/phy-exynos-dp-video.c b/drivers/phy/phy-exynos-dp-video.c new file mode 100644 index 000..1dbe6ce --- /dev/null +++ b/drivers/phy/phy-exynos-dp-video.c @@ -0,0 +1,111 @@ +/* + * Samsung EXYNOS SoC series Display Port PHY driver + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Jingoo Han jg1@samsung.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include linux/io.h +#include linux/kernel.h +#include linux/module.h +#include linux/of.h +#include linux/of_address.h +#include linux/phy/phy.h +#include linux/platform_device.h + +/* DPTX_PHY_CONTROL register */ +#define EXYNOS_DPTX_PHY_ENABLE (1 0) + +struct exynos_dp_video_phy { + void __iomem *regs; +}; + +static int __set_phy_state(struct exynos_dp_video_phy *state, unsigned int on) +{ + u32 reg; + + reg = readl(state-regs); + if (on) + reg |= EXYNOS_DPTX_PHY_ENABLE; + else + reg = ~EXYNOS_DPTX_PHY_ENABLE; + writel(reg, state-regs); + + return 0; +} + +static int exynos_dp_video_phy_power_on(struct phy *phy) +{ + struct exynos_dp_video_phy *state = phy_get_drvdata(phy); + + return __set_phy_state(state, 1); +} + +static int exynos_dp_video_phy_power_off(struct phy *phy) +{ + struct exynos_dp_video_phy *state = phy_get_drvdata(phy); + + return __set_phy_state(state, 0); +} + +static struct phy_ops exynos_dp_video_phy_ops = { + .power_on = exynos_dp_video_phy_power_on, + .power_off = exynos_dp_video_phy_power_off, + .owner = THIS_MODULE, +}; + +static int exynos_dp_video_phy_probe(struct platform_device *pdev) +{ + struct exynos_dp_video_phy *state; + struct device *dev = pdev-dev; + struct resource *res; + struct phy_provider *phy_provider; + struct phy *phy; + + state = devm_kzalloc(dev, sizeof(*state), GFP_KERNEL); + if (!state) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + + state-regs = devm_ioremap_resource(dev, res); + if (IS_ERR(state-regs)) + return PTR_ERR(state-regs); + + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); + if (IS_ERR(phy_provider)) + return PTR_ERR(phy_provider); + + phy = devm_phy_create(dev, exynos_dp_video_phy_ops, NULL); + if (IS_ERR(phy
Re: [PATCH V5 1/5] ARM: dts: Add MIPI PHY node to exynos4.dtsi
On Wednesday 02 October 2013 02:43 AM, Sylwester Nawrocki wrote: On 10/01/2013 07:28 AM, Kishon Vijay Abraham I wrote: On Sunday 29 September 2013 12:57 AM, Sylwester Nawrocki wrote: Add PHY provider node for the MIPI CSIS and MIPI DSIM PHYs. Signed-off-by: Sylwester Nawrockis.nawro...@samsung.com Signed-off-by: Kyungmin Parkkyungmin.p...@samsung.com Acked-by: Felipe Balbiba...@ti.com Can this patch be taken through exynos dt tree? Yes, that makes more sense indeed. Kukjin, would you mind taking this patch to your tree ? FWIW Acked-by: Kishon Vijay Abraham I kis...@ti.com Thanks, Sylwester -- 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
Re: [PATCH V5 1/5] ARM: dts: Add MIPI PHY node to exynos4.dtsi
Hi, On Sunday 29 September 2013 12:57 AM, Sylwester Nawrocki wrote: Add PHY provider node for the MIPI CSIS and MIPI DSIM PHYs. Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com Acked-by: Felipe Balbi ba...@ti.com Can this patch be taken through exynos dt tree? Thanks Kishon --- arch/arm/boot/dts/exynos4.dtsi | 10 ++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi index caadc02..a73eeb5 100644 --- a/arch/arm/boot/dts/exynos4.dtsi +++ b/arch/arm/boot/dts/exynos4.dtsi @@ -49,6 +49,12 @@ reg = 0x1000 0x100; }; + mipi_phy: video-phy@10020710 { + compatible = samsung,s5pv210-mipi-video-phy; + reg = 0x10020710 8; + #phy-cells = 1; + }; + pd_mfc: mfc-power-domain@10023C40 { compatible = samsung,exynos4210-pd; reg = 0x10023C40 0x20; @@ -161,6 +167,8 @@ clock-names = csis, sclk_csis; bus-width = 4; samsung,power-domain = pd_cam; + phys = mipi_phy 0; + phy-names = csis; status = disabled; #address-cells = 1; #size-cells = 0; @@ -174,6 +182,8 @@ clock-names = csis, sclk_csis; bus-width = 2; samsung,power-domain = pd_cam; + phys = mipi_phy 2; + phy-names = csis; status = disabled; #address-cells = 1; #size-cells = 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
Re: [PATCH v11 2/8] usb: phy: omap-usb2: use the new generic PHY framework
Hi Greg, On Friday 27 September 2013 12:21 AM, Greg KH wrote: On Wed, Aug 21, 2013 at 11:16:07AM +0530, Kishon Vijay Abraham I wrote: Used the generic PHY framework API to create the PHY. Now the power off and power on are done in omap_usb_power_off and omap_usb_power_on respectively. The omap-usb2 driver is also moved to driver/phy. However using the old USB PHY library cannot be completely removed because OTG is intertwined with PHY and moving to the new framework will break OTG. Once we have a separate OTG state machine, we can get rid of the USB PHY library. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com Acked-by: Felipe Balbi ba...@ti.com --- drivers/phy/Kconfig | 12 + drivers/phy/Makefile |1 + drivers/{usb = }/phy/phy-omap-usb2.c | 45 ++--- drivers/usb/phy/Kconfig | 10 drivers/usb/phy/Makefile |1 - 5 files changed, 54 insertions(+), 15 deletions(-) rename drivers/{usb = }/phy/phy-omap-usb2.c (88%) I tried to apply this to my USB branch, but it fails. Kishon, you were going to refresh this patch series, right? Please do, because as-is, I can't take it. Just sent. Thanks Kishon -- 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
Re: [PATCH v11 0/8] PHY framework
Hi Greg, On Tuesday 17 September 2013 09:11 PM, Felipe Balbi wrote: On Wed, Sep 04, 2013 at 02:27:06PM +0530, Kishon Vijay Abraham I wrote: On Tuesday 03 September 2013 09:20 PM, Greg KH wrote: On Tue, Sep 03, 2013 at 08:55:23PM +0530, Kishon Vijay Abraham I wrote: Hi Greg, On Wednesday 28 August 2013 12:50 AM, Felipe Balbi wrote: Hi, On Mon, Aug 26, 2013 at 01:44:49PM +0530, Kishon Vijay Abraham I wrote: On Wednesday 21 August 2013 11:16 AM, Kishon Vijay Abraham I wrote: Added a generic PHY framework that 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. This framework will be of use only to devices that uses external PHY (PHY functionality is not embedded within the controller). The intention of creating this framework is to bring the phy drivers spread all over the Linux kernel to drivers/phy to increase code re-use and to increase code maintainability. Comments to make PHY as bus wasn't done because PHY devices can be part of other bus and making a same device attached to multiple bus leads to bad design. If the PHY driver has to send notification on connect/disconnect, the PHY driver should make use of the extcon framework. Using this susbsystem to use extcon framwork will have to be analysed. You can find this patch series @ git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git testing Looks like there are not further comments on this series. Can you take this in your misc tree? Do you want me to queue these for you ? There are quite a few users for this framework already and I know of at least 2 others which will show up for v3.13. Can you queue this patch series? There are quite a few users already for this framework. It will have to wait for 3.13 as the merge window for new features has been closed for a week or so. Sorry, I'll queue this up after 3.12-rc1 is out. Alright, thanks. Just a gentle ping on this one... Let me know if you want me to rebase this patch series on the latest mainline HEAD. Thanks Kishon -- 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
Re: [PATCH v11 0/8] PHY framework
On Tuesday 03 September 2013 09:20 PM, Greg KH wrote: On Tue, Sep 03, 2013 at 08:55:23PM +0530, Kishon Vijay Abraham I wrote: Hi Greg, On Wednesday 28 August 2013 12:50 AM, Felipe Balbi wrote: Hi, On Mon, Aug 26, 2013 at 01:44:49PM +0530, Kishon Vijay Abraham I wrote: On Wednesday 21 August 2013 11:16 AM, Kishon Vijay Abraham I wrote: Added a generic PHY framework that 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. This framework will be of use only to devices that uses external PHY (PHY functionality is not embedded within the controller). The intention of creating this framework is to bring the phy drivers spread all over the Linux kernel to drivers/phy to increase code re-use and to increase code maintainability. Comments to make PHY as bus wasn't done because PHY devices can be part of other bus and making a same device attached to multiple bus leads to bad design. If the PHY driver has to send notification on connect/disconnect, the PHY driver should make use of the extcon framework. Using this susbsystem to use extcon framwork will have to be analysed. You can find this patch series @ git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git testing Looks like there are not further comments on this series. Can you take this in your misc tree? Do you want me to queue these for you ? There are quite a few users for this framework already and I know of at least 2 others which will show up for v3.13. Can you queue this patch series? There are quite a few users already for this framework. It will have to wait for 3.13 as the merge window for new features has been closed for a week or so. Sorry, I'll queue this up after 3.12-rc1 is out. Alright, thanks. -Kishon -- 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
Re: [PATCH v11 0/8] PHY framework
Hi Greg, On Wednesday 28 August 2013 12:50 AM, Felipe Balbi wrote: Hi, On Mon, Aug 26, 2013 at 01:44:49PM +0530, Kishon Vijay Abraham I wrote: On Wednesday 21 August 2013 11:16 AM, Kishon Vijay Abraham I wrote: Added a generic PHY framework that 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. This framework will be of use only to devices that uses external PHY (PHY functionality is not embedded within the controller). The intention of creating this framework is to bring the phy drivers spread all over the Linux kernel to drivers/phy to increase code re-use and to increase code maintainability. Comments to make PHY as bus wasn't done because PHY devices can be part of other bus and making a same device attached to multiple bus leads to bad design. If the PHY driver has to send notification on connect/disconnect, the PHY driver should make use of the extcon framework. Using this susbsystem to use extcon framwork will have to be analysed. You can find this patch series @ git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git testing Looks like there are not further comments on this series. Can you take this in your misc tree? Do you want me to queue these for you ? There are quite a few users for this framework already and I know of at least 2 others which will show up for v3.13. Can you queue this patch series? There are quite a few users already for this framework. Thanks Kishon -- 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
Re: [PATCH v11 0/8] PHY framework
Hi, On Wednesday 28 August 2013 12:50 AM, Felipe Balbi wrote: Hi, On Mon, Aug 26, 2013 at 01:44:49PM +0530, Kishon Vijay Abraham I wrote: On Wednesday 21 August 2013 11:16 AM, Kishon Vijay Abraham I wrote: Added a generic PHY framework that 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. This framework will be of use only to devices that uses external PHY (PHY functionality is not embedded within the controller). The intention of creating this framework is to bring the phy drivers spread all over the Linux kernel to drivers/phy to increase code re-use and to increase code maintainability. Comments to make PHY as bus wasn't done because PHY devices can be part of other bus and making a same device attached to multiple bus leads to bad design. If the PHY driver has to send notification on connect/disconnect, the PHY driver should make use of the extcon framework. Using this susbsystem to use extcon framwork will have to be analysed. You can find this patch series @ git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git testing Looks like there are not further comments on this series. Can you take this in your misc tree? Do you want me to queue these for you ? There are quite a few users for this framework already and I know of at least 2 others which will show up for v3.13. yeah sure. That would be better I think. Thanks Kishon -- 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
Re: [PATCH v11 0/8] PHY framework
Hi Greg, On Wednesday 21 August 2013 11:16 AM, Kishon Vijay Abraham I wrote: Added a generic PHY framework that 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. This framework will be of use only to devices that uses external PHY (PHY functionality is not embedded within the controller). The intention of creating this framework is to bring the phy drivers spread all over the Linux kernel to drivers/phy to increase code re-use and to increase code maintainability. Comments to make PHY as bus wasn't done because PHY devices can be part of other bus and making a same device attached to multiple bus leads to bad design. If the PHY driver has to send notification on connect/disconnect, the PHY driver should make use of the extcon framework. Using this susbsystem to use extcon framwork will have to be analysed. You can find this patch series @ git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git testing Looks like there are not further comments on this series. Can you take this in your misc tree? Thanks Kishon -- 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
[PATCH v11 8/8] usb: phy: twl4030-usb: remove *set_suspend* and *phy_init* ops
Now that twl4030-usb is adapted to the new generic PHY framework, *set_suspend* and *phy_init* ops can be removed from twl4030-usb driver. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- drivers/phy/phy-twl4030-usb.c | 57 ++--- 1 file changed, 13 insertions(+), 44 deletions(-) diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c index 494f107..c437211 100644 --- a/drivers/phy/phy-twl4030-usb.c +++ b/drivers/phy/phy-twl4030-usb.c @@ -422,25 +422,20 @@ static void twl4030_phy_power(struct twl4030_usb *twl, int on) } } -static void twl4030_phy_suspend(struct twl4030_usb *twl, int controller_off) +static int twl4030_phy_power_off(struct phy *phy) { + struct twl4030_usb *twl = phy_get_drvdata(phy); + if (twl-asleep) - return; + return 0; twl4030_phy_power(twl, 0); twl-asleep = 1; dev_dbg(twl-dev, %s\n, __func__); -} - -static int twl4030_phy_power_off(struct phy *phy) -{ - struct twl4030_usb *twl = phy_get_drvdata(phy); - - twl4030_phy_suspend(twl, 0); return 0; } -static void __twl4030_phy_resume(struct twl4030_usb *twl) +static void __twl4030_phy_power_on(struct twl4030_usb *twl) { twl4030_phy_power(twl, 1); twl4030_i2c_access(twl, 1); @@ -449,11 +444,13 @@ static void __twl4030_phy_resume(struct twl4030_usb *twl) twl4030_i2c_access(twl, 0); } -static void twl4030_phy_resume(struct twl4030_usb *twl) +static int twl4030_phy_power_on(struct phy *phy) { + struct twl4030_usb *twl = phy_get_drvdata(phy); + if (!twl-asleep) - return; - __twl4030_phy_resume(twl); + return 0; + __twl4030_phy_power_on(twl); twl-asleep = 0; dev_dbg(twl-dev, %s\n, __func__); @@ -466,13 +463,6 @@ static void twl4030_phy_resume(struct twl4030_usb *twl) cancel_delayed_work(twl-id_workaround_work); schedule_delayed_work(twl-id_workaround_work, HZ); } -} - -static int twl4030_phy_power_on(struct phy *phy) -{ - struct twl4030_usb *twl = phy_get_drvdata(phy); - - twl4030_phy_resume(twl); return 0; } @@ -604,9 +594,9 @@ static void twl4030_id_workaround_work(struct work_struct *work) } } -static int twl4030_usb_phy_init(struct usb_phy *phy) +static int twl4030_phy_init(struct phy *phy) { - struct twl4030_usb *twl = phy_to_twl(phy); + struct twl4030_usb *twl = phy_get_drvdata(phy); enum omap_musb_vbus_id_status status; /* @@ -621,32 +611,13 @@ static int twl4030_usb_phy_init(struct usb_phy *phy) if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) { omap_musb_mailbox(twl-linkstat); - twl4030_phy_resume(twl); + twl4030_phy_power_on(phy); } sysfs_notify(twl-dev-kobj, NULL, vbus); return 0; } -static int twl4030_phy_init(struct phy *phy) -{ - struct twl4030_usb *twl = phy_get_drvdata(phy); - - return twl4030_usb_phy_init(twl-phy); -} - -static int twl4030_set_suspend(struct usb_phy *x, int suspend) -{ - struct twl4030_usb *twl = phy_to_twl(x); - - if (suspend) - twl4030_phy_suspend(twl, 1); - else - twl4030_phy_resume(twl); - - return 0; -} - static int twl4030_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget) { @@ -719,8 +690,6 @@ static int twl4030_usb_probe(struct platform_device *pdev) twl-phy.label = twl4030; twl-phy.otg= otg; twl-phy.type = USB_PHY_TYPE_USB2; - twl-phy.set_suspend= twl4030_set_suspend; - twl-phy.init = twl4030_usb_phy_init; otg-phy= twl-phy; otg-set_host = twl4030_set_host; -- 1.7.10.4 -- 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
[PATCH v11 1/8] drivers: phy: add generic PHY framework
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 t.f...@samsung.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Tested-by: Sylwester Nawrocki s.nawro...@samsung.com --- .../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 | 698 include/linux/phy/phy.h| 270 9 files changed, 1235 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 diff --git a/Documentation/devicetree/bindings/phy/phy-bindings.txt b/Documentation/devicetree/bindings/phy/phy-bindings.txt new file mode 100644 index 000..8ae844f --- /dev/null +++ b/Documentation/devicetree/bindings/phy/phy-bindings.txt @@ -0,0 +1,66 @@ +This document explains only the device tree data binding. For general +information about PHY subsystem refer to Documentation/phy.txt + +PHY device node +=== + +Required Properties: +#phy-cells:Number of cells in a PHY specifier; The meaning of all those + cells is defined by the binding for the phy node. The PHY + provider can use the values in cells to find the appropriate + PHY. + +For example: + +phys: phy { +compatible = xxx; +reg = ...; +. +. +#phy-cells = 1; +. +. +}; + +That node describes an IP block (PHY provider) that implements 2 different PHYs. +In order to differentiate between these 2 PHYs, an additonal specifier should be +given while trying to get a reference to it. + +PHY user node += + +Required Properties: +phys : the phandle for the PHY device (used by the PHY subsystem) +phy-names : the names of the PHY corresponding to the PHYs present in the + *phys* phandle + +Example 1: +usb1: usb_otg_ss@xxx { +compatible = xxx; +reg = xxx; +. +. +phys = usb2_phy, usb3_phy; +phy-names = usb2phy, usb3phy; +. +. +}; + +This node represents a controller that uses two PHYs, one for usb2 and one for +usb3. + +Example 2: +usb2: usb_otg_ss@xxx { +compatible = xxx; +reg = xxx; +. +. +phys = phys 1; +phy-names = usbphy; +. +. +}; + +This node represents a controller that uses one of the PHYs of the PHY provider +device defined previously. Note that the phy handle has an additional specifier +1 to differentiate between the two PHYs. diff --git a/Documentation/phy.txt b/Documentation/phy.txt new file mode 100644 index 000..0103e4b --- /dev/null +++ b/Documentation/phy.txt @@ -0,0 +1,166 @@ + PHY SUBSYSTEM + Kishon Vijay Abraham I kis...@ti.com + +This document explains the Generic PHY Framework along with the APIs provided, +and how-to-use. + +1. Introduction + +*PHY* is the abbreviation for physical layer. It is used to connect a device +to the physical medium e.g., the USB controller has a PHY to provide functions +such as serialization, de-serialization, encoding, decoding and is responsible +for obtaining the required data transmission rate. Note that some USB +controllers have PHY functionality embedded into it and others use an external +PHY. Other peripherals that use PHY include Wireless LAN, Ethernet, +SATA etc. + +The intention of creating this framework is to bring the PHY drivers spread +all over the Linux kernel to drivers/phy to increase code re-use and for +better code maintainability. + +This framework will be of use only to devices that use external PHY (PHY +functionality is not embedded within the controller). + +2. Registering/Unregistering the PHY provider + +PHY provider refers to an entity that implements one or more PHY instances. +For the simple case where the PHY provider implements only a single instance
[PATCH v11 6/8] usb: musb: omap2430: use the new generic PHY framework
Use the generic PHY framework API to get the PHY. The usb_phy_set_resume and usb_phy_set_suspend is replaced with power_on and power_off to align with the new PHY framework. musb-xceiv can't be removed as of now because musb core uses xceiv.state and xceiv.otg. Once there is a separate state machine to handle otg, these can be moved out of xceiv and then we can start using the generic PHY framework. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com Acked-by: Felipe Balbi ba...@ti.com --- drivers/usb/musb/Kconfig |1 + drivers/usb/musb/musb_core.h |2 ++ drivers/usb/musb/omap2430.c | 26 -- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 797e3fd..25e2e57 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -76,6 +76,7 @@ config USB_MUSB_TUSB6010 config USB_MUSB_OMAP2PLUS tristate OMAP2430 and onwards depends on ARCH_OMAP2PLUS + select GENERIC_PHY config USB_MUSB_AM35X tristate AM35x diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 7d341c3..6e567bd 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -46,6 +46,7 @@ #include linux/usb.h #include linux/usb/otg.h #include linux/usb/musb.h +#include linux/phy/phy.h struct musb; struct musb_hw_ep; @@ -346,6 +347,7 @@ struct musb { u16 int_tx; struct usb_phy *xceiv; + struct phy *phy; int nIrq; unsignedirq_wake:1; diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index f44e8b5..063773a 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -348,11 +348,21 @@ static int omap2430_musb_init(struct musb *musb) * up through ULPI. TWL4030-family PMICs include one, * which needs a driver, drivers aren't always needed. */ - if (dev-parent-of_node) + if (dev-parent-of_node) { + musb-phy = devm_phy_get(dev-parent, usb2-phy); + + /* We can't totally remove musb-xceiv as of now because +* musb core uses xceiv.state and xceiv.otg. Once we have +* a separate state machine to handle otg, these can be moved +* out of xceiv and then we can start using the generic PHY +* framework +*/ musb-xceiv = devm_usb_get_phy_by_phandle(dev-parent, usb-phy, 0); - else + } else { musb-xceiv = devm_usb_get_phy_dev(dev, 0); + musb-phy = devm_phy_get(dev, usb); + } if (IS_ERR(musb-xceiv)) { status = PTR_ERR(musb-xceiv); @@ -364,6 +374,10 @@ static int omap2430_musb_init(struct musb *musb) return -EPROBE_DEFER; } + if (IS_ERR(musb-phy)) { + pr_err(HS USB OTG: no PHY configured\n); + return PTR_ERR(musb-phy); + } musb-isr = omap2430_musb_interrupt; status = pm_runtime_get_sync(dev); @@ -397,7 +411,7 @@ static int omap2430_musb_init(struct musb *musb) if (glue-status != OMAP_MUSB_UNKNOWN) omap_musb_set_mailbox(glue); - usb_phy_init(musb-xceiv); + phy_init(musb-phy); pm_runtime_put_noidle(musb-controller); return 0; @@ -460,6 +474,7 @@ static int omap2430_musb_exit(struct musb *musb) del_timer_sync(musb_idle_timer); omap2430_low_level_exit(musb); + phy_exit(musb-phy); return 0; } @@ -638,7 +653,7 @@ static int omap2430_runtime_suspend(struct device *dev) OTG_INTERFSEL); omap2430_low_level_exit(musb); - usb_phy_set_suspend(musb-xceiv, 1); + phy_power_off(musb-phy); } return 0; @@ -653,8 +668,7 @@ static int omap2430_runtime_resume(struct device *dev) omap2430_low_level_init(musb); musb_writel(musb-mregs, OTG_INTERFSEL, musb-context.otg_interfsel); - - usb_phy_set_suspend(musb-xceiv, 0); + phy_power_on(musb-phy); } return 0; -- 1.7.10.4 -- 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
[PATCH v11 5/8] ARM: dts: omap: update usb_otg_hs data
Updated the usb_otg_hs dt data to include the *phy* and *phy-names* binding in order for the driver to use the new generic PHY framework. Also updated the Documentation to include the binding information. The PHY binding information can be found at Documentation/devicetree/bindings/phy/phy-bindings.txt Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Acked-by: Tony Lindgren t...@atomide.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- Documentation/devicetree/bindings/usb/omap-usb.txt |5 + Documentation/devicetree/bindings/usb/usb-phy.txt |6 ++ arch/arm/boot/dts/omap3-beagle-xm.dts |2 ++ arch/arm/boot/dts/omap3-evm.dts|2 ++ arch/arm/boot/dts/omap3-overo.dtsi |2 ++ arch/arm/boot/dts/omap4.dtsi |3 +++ arch/arm/boot/dts/twl4030.dtsi |1 + 7 files changed, 21 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt b/Documentation/devicetree/bindings/usb/omap-usb.txt index 57e71f6..825790d 100644 --- a/Documentation/devicetree/bindings/usb/omap-usb.txt +++ b/Documentation/devicetree/bindings/usb/omap-usb.txt @@ -19,6 +19,9 @@ OMAP MUSB GLUE - power : Should be 50. This signifies the controller can supply up to 100mA when operating in host mode. - usb-phy : the phandle for the PHY device + - phys : the phandle for the PHY device (used by generic PHY framework) + - phy-names : the names of the PHY corresponding to the PHYs present in the + *phy* phandle. Optional properties: - ctrl-module : phandle of the control module this glue uses to write to @@ -33,6 +36,8 @@ usb_otg_hs: usb_otg_hs@4a0ab000 { num-eps = 16; ram-bits = 12; ctrl-module = omap_control_usb; + phys = usb2_phy; + phy-names = usb2-phy; }; Board specific device node entry diff --git a/Documentation/devicetree/bindings/usb/usb-phy.txt b/Documentation/devicetree/bindings/usb/usb-phy.txt index 61496f5..c0245c8 100644 --- a/Documentation/devicetree/bindings/usb/usb-phy.txt +++ b/Documentation/devicetree/bindings/usb/usb-phy.txt @@ -5,6 +5,8 @@ OMAP USB2 PHY Required properties: - compatible: Should be ti,omap-usb2 - reg : Address and length of the register set for the device. + - #phy-cells: determine the number of cells that should be given in the + phandle while referencing this phy. Optional properties: - ctrl-module : phandle of the control module used by PHY driver to power on @@ -16,6 +18,7 @@ usb2phy@4a0ad080 { compatible = ti,omap-usb2; reg = 0x4a0ad080 0x58; ctrl-module = omap_control_usb; + #phy-cells = 0; }; OMAP USB3 PHY @@ -25,6 +28,8 @@ Required properties: - reg : Address and length of the register set for the device. - reg-names: The names of the register addresses corresponding to the registers filled in reg. + - #phy-cells: determine the number of cells that should be given in the + phandle while referencing this phy. Optional properties: - ctrl-module : phandle of the control module used by PHY driver to power on @@ -39,4 +44,5 @@ usb3phy@4a084400 { 0x4a084c00 0x40; reg-names = phy_rx, phy_tx, pll_ctrl; ctrl-module = omap_control_usb; + #phy-cells = 0; }; diff --git a/arch/arm/boot/dts/omap3-beagle-xm.dts b/arch/arm/boot/dts/omap3-beagle-xm.dts index afdb164..533b2da 100644 --- a/arch/arm/boot/dts/omap3-beagle-xm.dts +++ b/arch/arm/boot/dts/omap3-beagle-xm.dts @@ -144,6 +144,8 @@ usb_otg_hs { interface-type = 0; usb-phy = usb2_phy; + phys = usb2_phy; + phy-names = usb2-phy; mode = 3; power = 50; }; diff --git a/arch/arm/boot/dts/omap3-evm.dts b/arch/arm/boot/dts/omap3-evm.dts index 7d4329d..4134dd0 100644 --- a/arch/arm/boot/dts/omap3-evm.dts +++ b/arch/arm/boot/dts/omap3-evm.dts @@ -70,6 +70,8 @@ usb_otg_hs { interface-type = 0; usb-phy = usb2_phy; + phys = usb2_phy; + phy-names = usb2-phy; mode = 3; power = 50; }; diff --git a/arch/arm/boot/dts/omap3-overo.dtsi b/arch/arm/boot/dts/omap3-overo.dtsi index 8f1abec..a461d2f 100644 --- a/arch/arm/boot/dts/omap3-overo.dtsi +++ b/arch/arm/boot/dts/omap3-overo.dtsi @@ -76,6 +76,8 @@ usb_otg_hs { interface-type = 0; usb-phy = usb2_phy; + phys = usb2_phy; + phy-names = usb2-phy; mode = 3; power = 50; }; diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi index 22d9f2b..1e8e2fe 100644 --- a/arch/arm/boot/dts/omap4.dtsi +++ b/arch/arm/boot/dts/omap4.dtsi @@ -520,6 +520,7 @@ compatible = ti,omap-usb2; reg = 0x4a0ad080 0x58; ctrl-module = omap_control_usb; + #phy-cells = 0; }; }; @@ -658,6 +659,8
[PATCH v11 4/8] arm: omap3: twl: add phy consumer data in twl4030_usb_data
The PHY framework uses the phy consumer data populated in platform data in the case of non-dt boot to return the reference to the PHY when the controller (PHY consumer) requests for it. So populated the phy consumer data in the platform data of twl usb. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com --- arch/arm/mach-omap2/twl-common.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c index c05898f..b0d54da 100644 --- a/arch/arm/mach-omap2/twl-common.c +++ b/arch/arm/mach-omap2/twl-common.c @@ -24,6 +24,7 @@ #include linux/i2c/twl.h #include linux/gpio.h #include linux/string.h +#include linux/phy/phy.h #include linux/regulator/machine.h #include linux/regulator/fixed.h @@ -90,8 +91,18 @@ void __init omap_pmic_late_init(void) } #if defined(CONFIG_ARCH_OMAP3) +struct phy_consumer consumers[] = { + PHY_CONSUMER(musb-hdrc.0, usb), +}; + +struct phy_init_data init_data = { + .consumers = consumers, + .num_consumers = ARRAY_SIZE(consumers), +}; + static struct twl4030_usb_data omap3_usb_pdata = { .usb_mode = T2_USB_MODE_ULPI, + .init_data = init_data, }; static int omap3_batt_table[] = { -- 1.7.10.4 -- 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
[PATCH v11 7/8] usb: phy: omap-usb2: remove *set_suspend* callback from omap-usb2
Now that omap-usb2 is adapted to the new generic PHY framework, *set_suspend* ops can be removed from omap-usb2 driver. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- drivers/phy/phy-omap-usb2.c | 25 - 1 file changed, 25 deletions(-) diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c index 25e0f3c..dec3fab 100644 --- a/drivers/phy/phy-omap-usb2.c +++ b/drivers/phy/phy-omap-usb2.c @@ -97,29 +97,6 @@ static int omap_usb_set_peripheral(struct usb_otg *otg, return 0; } -static int omap_usb2_suspend(struct usb_phy *x, int suspend) -{ - u32 ret; - struct omap_usb *phy = phy_to_omapusb(x); - - if (suspend !phy-is_suspended) { - omap_control_usb_phy_power(phy-control_dev, 0); - pm_runtime_put_sync(phy-dev); - phy-is_suspended = 1; - } else if (!suspend phy-is_suspended) { - ret = pm_runtime_get_sync(phy-dev); - if (ret 0) { - dev_err(phy-dev, get_sync failed with err %d\n, - ret); - return ret; - } - omap_control_usb_phy_power(phy-control_dev, 1); - phy-is_suspended = 0; - } - - return 0; -} - static int omap_usb_power_off(struct phy *x) { struct omap_usb *phy = phy_get_drvdata(x); @@ -167,7 +144,6 @@ static int omap_usb2_probe(struct platform_device *pdev) phy-phy.dev= phy-dev; phy-phy.label = omap-usb2; - phy-phy.set_suspend= omap_usb2_suspend; phy-phy.otg= otg; phy-phy.type = USB_PHY_TYPE_USB2; @@ -182,7 +158,6 @@ static int omap_usb2_probe(struct platform_device *pdev) return -ENODEV; } - phy-is_suspended = 1; omap_control_usb_phy_power(phy-control_dev, 0); otg-set_host = omap_usb_set_host; -- 1.7.10.4 -- 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
[PATCH v11 0/8] PHY framework
Documentation for the PHY framework * Added few more APIs mostly w.r.t devres * Modified omap-usb2 and twl4030 to make use of the new framework Kishon Vijay Abraham I (8): drivers: phy: add generic PHY framework usb: phy: omap-usb2: use the new generic PHY framework usb: phy: twl4030: use the new generic PHY framework arm: omap3: twl: add phy consumer data in twl4030_usb_data ARM: dts: omap: update usb_otg_hs data usb: musb: omap2430: use the new generic PHY framework usb: phy: omap-usb2: remove *set_suspend* callback from omap-usb2 usb: phy: twl4030-usb: remove *set_suspend* and *phy_init* ops .../devicetree/bindings/phy/phy-bindings.txt | 66 ++ Documentation/devicetree/bindings/usb/omap-usb.txt |5 + Documentation/devicetree/bindings/usb/usb-phy.txt |6 + Documentation/phy.txt | 166 + MAINTAINERS|8 + arch/arm/boot/dts/omap3-beagle-xm.dts |2 + arch/arm/boot/dts/omap3-evm.dts|2 + arch/arm/boot/dts/omap3-overo.dtsi |2 + arch/arm/boot/dts/omap4.dtsi |3 + arch/arm/boot/dts/twl4030.dtsi |1 + arch/arm/mach-omap2/twl-common.c | 11 + drivers/Kconfig|2 + drivers/Makefile |2 + drivers/phy/Kconfig| 41 ++ drivers/phy/Makefile |7 + drivers/phy/phy-core.c | 698 drivers/{usb = }/phy/phy-omap-usb2.c | 60 +- drivers/{usb = }/phy/phy-twl4030-usb.c| 69 +- drivers/usb/musb/Kconfig |1 + drivers/usb/musb/musb_core.h |2 + drivers/usb/musb/omap2430.c| 26 +- drivers/usb/phy/Kconfig| 19 - drivers/usb/phy/Makefile |2 - include/linux/i2c/twl.h|2 + include/linux/phy/phy.h| 270 25 files changed, 1397 insertions(+), 76 deletions(-) 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 rename drivers/{usb = }/phy/phy-omap-usb2.c (88%) rename drivers/{usb = }/phy/phy-twl4030-usb.c (94%) create mode 100644 include/linux/phy/phy.h -- 1.7.10.4 -- 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
[PATCH v11 2/8] usb: phy: omap-usb2: use the new generic PHY framework
Used the generic PHY framework API to create the PHY. Now the power off and power on are done in omap_usb_power_off and omap_usb_power_on respectively. The omap-usb2 driver is also moved to driver/phy. However using the old USB PHY library cannot be completely removed because OTG is intertwined with PHY and moving to the new framework will break OTG. Once we have a separate OTG state machine, we can get rid of the USB PHY library. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com Acked-by: Felipe Balbi ba...@ti.com --- drivers/phy/Kconfig | 12 + drivers/phy/Makefile |1 + drivers/{usb = }/phy/phy-omap-usb2.c | 45 ++--- drivers/usb/phy/Kconfig | 10 drivers/usb/phy/Makefile |1 - 5 files changed, 54 insertions(+), 15 deletions(-) rename drivers/{usb = }/phy/phy-omap-usb2.c (88%) diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 349bef2..38c3477 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -15,4 +15,16 @@ config GENERIC_PHY phy users can obtain reference to the PHY. All the users of this framework should select this config. +config OMAP_USB2 + tristate OMAP USB2 PHY Driver + depends on ARCH_OMAP2PLUS + select GENERIC_PHY + select USB_PHY + select OMAP_CONTROL_USB + help + Enable this to support the transceiver that is part of SOC. This + driver takes care of all the PHY functionality apart from comparator. + The USB OTG controller communicates with the comparator using this + driver. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 9e9560f..ed5b088 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -3,3 +3,4 @@ # obj-$(CONFIG_GENERIC_PHY) += phy-core.o +obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o diff --git a/drivers/usb/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c similarity index 88% rename from drivers/usb/phy/phy-omap-usb2.c rename to drivers/phy/phy-omap-usb2.c index 844ab68..25e0f3c 100644 --- a/drivers/usb/phy/phy-omap-usb2.c +++ b/drivers/phy/phy-omap-usb2.c @@ -28,6 +28,7 @@ #include linux/pm_runtime.h #include linux/delay.h #include linux/usb/omap_control_usb.h +#include linux/phy/phy.h /** * omap_usb2_set_comparator - links the comparator present in the sytem with @@ -119,10 +120,36 @@ static int omap_usb2_suspend(struct usb_phy *x, int suspend) return 0; } +static int omap_usb_power_off(struct phy *x) +{ + struct omap_usb *phy = phy_get_drvdata(x); + + omap_control_usb_phy_power(phy-control_dev, 0); + + return 0; +} + +static int omap_usb_power_on(struct phy *x) +{ + struct omap_usb *phy = phy_get_drvdata(x); + + omap_control_usb_phy_power(phy-control_dev, 1); + + return 0; +} + +static struct phy_ops ops = { + .power_on = omap_usb_power_on, + .power_off = omap_usb_power_off, + .owner = THIS_MODULE, +}; + static int omap_usb2_probe(struct platform_device *pdev) { struct omap_usb *phy; + struct phy *generic_phy; struct usb_otg *otg; + struct phy_provider *phy_provider; phy = devm_kzalloc(pdev-dev, sizeof(*phy), GFP_KERNEL); if (!phy) { @@ -144,6 +171,11 @@ static int omap_usb2_probe(struct platform_device *pdev) phy-phy.otg= otg; phy-phy.type = USB_PHY_TYPE_USB2; + phy_provider = devm_of_phy_provider_register(phy-dev, + of_phy_simple_xlate); + if (IS_ERR(phy_provider)) + return PTR_ERR(phy_provider); + phy-control_dev = omap_get_control_dev(); if (IS_ERR(phy-control_dev)) { dev_dbg(pdev-dev, Failed to get control device\n); @@ -159,6 +191,15 @@ static int omap_usb2_probe(struct platform_device *pdev) otg-start_srp = omap_usb_start_srp; otg-phy= phy-phy; + platform_set_drvdata(pdev, phy); + pm_runtime_enable(phy-dev); + + generic_phy = devm_phy_create(phy-dev, ops, NULL); + if (IS_ERR(generic_phy)) + return PTR_ERR(generic_phy); + + phy_set_drvdata(generic_phy, phy); + phy-wkupclk = devm_clk_get(phy-dev, usb_phy_cm_clk32k); if (IS_ERR(phy-wkupclk)) { dev_err(pdev-dev, unable to get usb_phy_cm_clk32k\n); @@ -174,10 +215,6 @@ static int omap_usb2_probe(struct platform_device *pdev) usb_add_phy_dev(phy-phy); - platform_set_drvdata(pdev, phy); - - pm_runtime_enable(phy-dev); - return 0; } diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 3622fff..7813238 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -72,16 +72,6 @@ config
[PATCH v11 3/8] usb: phy: twl4030: use the new generic PHY framework
Used the generic PHY framework API to create the PHY. For powering on and powering off the PHY, power_on and power_off ops are used. Once the MUSB OMAP glue is adapted to the new framework, the suspend and resume ops of usb phy library will be removed. Also twl4030-usb driver is moved to drivers/phy/. However using the old usb phy library cannot be completely removed because otg is intertwined with phy and moving to the new framework completely will break otg. Once we have a separate otg state machine, we can get rid of the usb phy library. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- drivers/phy/Kconfig | 11 ++ drivers/phy/Makefile|1 + drivers/{usb = }/phy/phy-twl4030-usb.c | 56 +-- drivers/usb/phy/Kconfig |9 - drivers/usb/phy/Makefile|1 - include/linux/i2c/twl.h |2 ++ 6 files changed, 67 insertions(+), 13 deletions(-) rename drivers/{usb = }/phy/phy-twl4030-usb.c (95%) diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 38c3477..ac239ac 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -27,4 +27,15 @@ config OMAP_USB2 The USB OTG controller communicates with the comparator using this driver. +config TWL4030_USB + tristate TWL4030 USB Transceiver Driver + depends on TWL4030_CORE REGULATOR_TWL4030 USB_MUSB_OMAP2PLUS + select GENERIC_PHY + select USB_PHY + help + Enable this to support the USB OTG transceiver on TWL4030 + family chips (including the TWL5030 and TPS659x0 devices). + This transceiver supports high and full speed devices plus, + in host mode, low speed. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index ed5b088..0dd8a98 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_GENERIC_PHY) += phy-core.o obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o +obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o diff --git a/drivers/usb/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c similarity index 95% rename from drivers/usb/phy/phy-twl4030-usb.c rename to drivers/phy/phy-twl4030-usb.c index 8f78d2d..494f107 100644 --- a/drivers/usb/phy/phy-twl4030-usb.c +++ b/drivers/phy/phy-twl4030-usb.c @@ -33,6 +33,7 @@ #include linux/io.h #include linux/delay.h #include linux/usb/otg.h +#include linux/phy/phy.h #include linux/usb/musb-omap.h #include linux/usb/ulpi.h #include linux/i2c/twl.h @@ -431,6 +432,14 @@ static void twl4030_phy_suspend(struct twl4030_usb *twl, int controller_off) dev_dbg(twl-dev, %s\n, __func__); } +static int twl4030_phy_power_off(struct phy *phy) +{ + struct twl4030_usb *twl = phy_get_drvdata(phy); + + twl4030_phy_suspend(twl, 0); + return 0; +} + static void __twl4030_phy_resume(struct twl4030_usb *twl) { twl4030_phy_power(twl, 1); @@ -459,6 +468,14 @@ static void twl4030_phy_resume(struct twl4030_usb *twl) } } +static int twl4030_phy_power_on(struct phy *phy) +{ + struct twl4030_usb *twl = phy_get_drvdata(phy); + + twl4030_phy_resume(twl); + return 0; +} + static int twl4030_usb_ldo_init(struct twl4030_usb *twl) { /* Enable writing to power configuration registers */ @@ -602,13 +619,22 @@ static int twl4030_usb_phy_init(struct usb_phy *phy) status = twl4030_usb_linkstat(twl); twl-linkstat = status; - if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) + if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) { omap_musb_mailbox(twl-linkstat); + twl4030_phy_resume(twl); + } sysfs_notify(twl-dev-kobj, NULL, vbus); return 0; } +static int twl4030_phy_init(struct phy *phy) +{ + struct twl4030_usb *twl = phy_get_drvdata(phy); + + return twl4030_usb_phy_init(twl-phy); +} + static int twl4030_set_suspend(struct usb_phy *x, int suspend) { struct twl4030_usb *twl = phy_to_twl(x); @@ -646,13 +672,23 @@ static int twl4030_set_host(struct usb_otg *otg, struct usb_bus *host) return 0; } +static const struct phy_ops ops = { + .init = twl4030_phy_init, + .power_on = twl4030_phy_power_on, + .power_off = twl4030_phy_power_off, + .owner = THIS_MODULE, +}; + static int twl4030_usb_probe(struct platform_device *pdev) { struct twl4030_usb_data *pdata = pdev-dev.platform_data; struct twl4030_usb *twl; + struct phy *phy; int status, err; struct usb_otg *otg; struct device_node *np = pdev-dev.of_node; + struct phy_provider *phy_provider; + struct phy_init_data
Re: [PATCH 01/15] drivers: phy: add generic PHY framework
Felipe, ping.. On Wednesday 14 August 2013 08:35 PM, Kishon Vijay Abraham I wrote: Hi, On Wednesday 14 August 2013 04:34 AM, Tomasz Figa wrote: On Wednesday 14 of August 2013 00:19:28 Sylwester Nawrocki wrote: W dniu 2013-08-13 14:05, Kishon Vijay Abraham I pisze: On Tuesday 13 August 2013 05:07 PM, Tomasz Figa wrote: On Tuesday 13 of August 2013 16:14:44 Kishon Vijay Abraham I wrote: On Wednesday 31 July 2013 11:45 AM, Felipe Balbi wrote: On Wed, Jul 31, 2013 at 11:14:32AM +0530, Kishon Vijay Abraham I wrote: IMHO we need a lookup method for PHYs, just like for clocks, regulators, PWMs or even i2c busses because there are complex cases when passing just a name using platform data will not work. I would second what Stephen said [1] and define a structure doing things in a DT-like way. Example; [platform code] static const struct phy_lookup my_phy_lookup[] = { PHY_LOOKUP(s3c-hsotg.0, otg, samsung-usbphy.1, phy.2), The only problem here is that if *PLATFORM_DEVID_AUTO* is used while creating the device, the ids in the device name would change and PHY_LOOKUP wont be useful. I don't think this is a problem. All the existing lookup methods already use ID to identify devices (see regulators, clkdev, PWMs, i2c, ...). You can simply add a requirement that the ID must be assigned manually, without using PLATFORM_DEVID_AUTO to use PHY lookup. And I'm saying that this idea, of using a specific name and id, is frought with fragility and will break in the future in various ways when devices get added to systems, making these strings constantly have to be kept up to date with different board configurations. People, NEVER, hardcode something like an id. The fact that this happens today with the clock code, doesn't make it right, it makes the clock code wrong. Others have already said that this is wrong there as well, as systems change and dynamic ids get used more and more. Let's not repeat the same mistakes of the past just because we refuse to learn from them... So again, the find a phy by a string functions should be removed, the device id should be automatically created by the phy core just to make things unique in sysfs, and no driver code should _ever_ be reliant on the number that is being created, and the pointer to the phy structure should be used everywhere instead. With those types of changes, I will consider merging this subsystem, but without them, sorry, I will not. I'll agree with Greg here, the very fact that we see people trying to add a requirement of *NOT* using PLATFORM_DEVID_AUTO already points to a big problem in the framework. The fact is that if we don't allow PLATFORM_DEVID_AUTO we will end up adding similar infrastructure to the driver themselves to make sure we don't end up with duplicate names in sysfs in case we have multiple instances of the same IP in the SoC (or several of the same PCIe card). I really don't want to go back to that. If we are using PLATFORM_DEVID_AUTO, then I dont see any way we can give the correct binding information to the PHY framework. I think we can drop having this non-dt support in PHY framework? I see only one platform (OMAP3) going to be needing this non-dt support and we can use the USB PHY library for it. you shouldn't drop support for non-DT platform, in any case we lived without DT (and still do) for years. Gotta find a better way ;-) hmm.. how about passing the device names of PHY in platform data of the controller? It should be deterministic as the PHY framework assigns its own id and we *don't* want to add any requirement that the ID must be assigned manually without using PLATFORM_DEVID_AUTO. We can get rid of *phy_init_data* in the v10 patch series. OK, so the PHY device name would have a fixed part, passed as platform data of the controller and a variable part appended by the PHY core, depending on the number of registered PHYs ? Then same PHY names would be passed as the PHY provider driver's platform data ? Then if there are 2 instances of the above (same names in platform data) how would be determined which PHY controller is linked to which PHY supplier ? I guess you want each device instance to have different PHY device names already in platform data ? That might work. We probably will be focused mostly on DT anyway. It seem without DT we are trying to find some layer that would allow us to couple relevant devices and overcome driver core inconvenience that it provides to means to identify specific devices in advance. :) Your proposal sounds reasonable, however I might be missing some details or corner cases. What about slightly altering the concept of v9 to pass a pointer to struct device instead of device name inside phy_init_data? As Felipe said, we don't want to pass pointers in platform_data to/from random subsystems. We pass data, passing pointers would be a total mess IMHO. Well
Re: [PATCH 01/15] drivers: phy: add generic PHY framework
Hi, On Wednesday 14 August 2013 04:34 AM, Tomasz Figa wrote: On Wednesday 14 of August 2013 00:19:28 Sylwester Nawrocki wrote: W dniu 2013-08-13 14:05, Kishon Vijay Abraham I pisze: On Tuesday 13 August 2013 05:07 PM, Tomasz Figa wrote: On Tuesday 13 of August 2013 16:14:44 Kishon Vijay Abraham I wrote: On Wednesday 31 July 2013 11:45 AM, Felipe Balbi wrote: On Wed, Jul 31, 2013 at 11:14:32AM +0530, Kishon Vijay Abraham I wrote: IMHO we need a lookup method for PHYs, just like for clocks, regulators, PWMs or even i2c busses because there are complex cases when passing just a name using platform data will not work. I would second what Stephen said [1] and define a structure doing things in a DT-like way. Example; [platform code] static const struct phy_lookup my_phy_lookup[] = { PHY_LOOKUP(s3c-hsotg.0, otg, samsung-usbphy.1, phy.2), The only problem here is that if *PLATFORM_DEVID_AUTO* is used while creating the device, the ids in the device name would change and PHY_LOOKUP wont be useful. I don't think this is a problem. All the existing lookup methods already use ID to identify devices (see regulators, clkdev, PWMs, i2c, ...). You can simply add a requirement that the ID must be assigned manually, without using PLATFORM_DEVID_AUTO to use PHY lookup. And I'm saying that this idea, of using a specific name and id, is frought with fragility and will break in the future in various ways when devices get added to systems, making these strings constantly have to be kept up to date with different board configurations. People, NEVER, hardcode something like an id. The fact that this happens today with the clock code, doesn't make it right, it makes the clock code wrong. Others have already said that this is wrong there as well, as systems change and dynamic ids get used more and more. Let's not repeat the same mistakes of the past just because we refuse to learn from them... So again, the find a phy by a string functions should be removed, the device id should be automatically created by the phy core just to make things unique in sysfs, and no driver code should _ever_ be reliant on the number that is being created, and the pointer to the phy structure should be used everywhere instead. With those types of changes, I will consider merging this subsystem, but without them, sorry, I will not. I'll agree with Greg here, the very fact that we see people trying to add a requirement of *NOT* using PLATFORM_DEVID_AUTO already points to a big problem in the framework. The fact is that if we don't allow PLATFORM_DEVID_AUTO we will end up adding similar infrastructure to the driver themselves to make sure we don't end up with duplicate names in sysfs in case we have multiple instances of the same IP in the SoC (or several of the same PCIe card). I really don't want to go back to that. If we are using PLATFORM_DEVID_AUTO, then I dont see any way we can give the correct binding information to the PHY framework. I think we can drop having this non-dt support in PHY framework? I see only one platform (OMAP3) going to be needing this non-dt support and we can use the USB PHY library for it. you shouldn't drop support for non-DT platform, in any case we lived without DT (and still do) for years. Gotta find a better way ;-) hmm.. how about passing the device names of PHY in platform data of the controller? It should be deterministic as the PHY framework assigns its own id and we *don't* want to add any requirement that the ID must be assigned manually without using PLATFORM_DEVID_AUTO. We can get rid of *phy_init_data* in the v10 patch series. OK, so the PHY device name would have a fixed part, passed as platform data of the controller and a variable part appended by the PHY core, depending on the number of registered PHYs ? Then same PHY names would be passed as the PHY provider driver's platform data ? Then if there are 2 instances of the above (same names in platform data) how would be determined which PHY controller is linked to which PHY supplier ? I guess you want each device instance to have different PHY device names already in platform data ? That might work. We probably will be focused mostly on DT anyway. It seem without DT we are trying to find some layer that would allow us to couple relevant devices and overcome driver core inconvenience that it provides to means to identify specific devices in advance. :) Your proposal sounds reasonable, however I might be missing some details or corner cases. What about slightly altering the concept of v9 to pass a pointer to struct device instead of device name inside phy_init_data? As Felipe said, we don't want to pass pointers in platform_data to/from random subsystems. We pass data, passing pointers would be a total mess IMHO. Well, this is a total mess anyway... I don't really get the point of using
Re: [PATCH 01/15] drivers: phy: add generic PHY framework
Hi, On Wednesday 31 July 2013 11:45 AM, Felipe Balbi wrote: Hi, On Wed, Jul 31, 2013 at 11:14:32AM +0530, Kishon Vijay Abraham I wrote: IMHO we need a lookup method for PHYs, just like for clocks, regulators, PWMs or even i2c busses because there are complex cases when passing just a name using platform data will not work. I would second what Stephen said [1] and define a structure doing things in a DT-like way. Example; [platform code] static const struct phy_lookup my_phy_lookup[] = { PHY_LOOKUP(s3c-hsotg.0, otg, samsung-usbphy.1, phy.2), The only problem here is that if *PLATFORM_DEVID_AUTO* is used while creating the device, the ids in the device name would change and PHY_LOOKUP wont be useful. I don't think this is a problem. All the existing lookup methods already use ID to identify devices (see regulators, clkdev, PWMs, i2c, ...). You can simply add a requirement that the ID must be assigned manually, without using PLATFORM_DEVID_AUTO to use PHY lookup. And I'm saying that this idea, of using a specific name and id, is frought with fragility and will break in the future in various ways when devices get added to systems, making these strings constantly have to be kept up to date with different board configurations. People, NEVER, hardcode something like an id. The fact that this happens today with the clock code, doesn't make it right, it makes the clock code wrong. Others have already said that this is wrong there as well, as systems change and dynamic ids get used more and more. Let's not repeat the same mistakes of the past just because we refuse to learn from them... So again, the find a phy by a string functions should be removed, the device id should be automatically created by the phy core just to make things unique in sysfs, and no driver code should _ever_ be reliant on the number that is being created, and the pointer to the phy structure should be used everywhere instead. With those types of changes, I will consider merging this subsystem, but without them, sorry, I will not. I'll agree with Greg here, the very fact that we see people trying to add a requirement of *NOT* using PLATFORM_DEVID_AUTO already points to a big problem in the framework. The fact is that if we don't allow PLATFORM_DEVID_AUTO we will end up adding similar infrastructure to the driver themselves to make sure we don't end up with duplicate names in sysfs in case we have multiple instances of the same IP in the SoC (or several of the same PCIe card). I really don't want to go back to that. If we are using PLATFORM_DEVID_AUTO, then I dont see any way we can give the correct binding information to the PHY framework. I think we can drop having this non-dt support in PHY framework? I see only one platform (OMAP3) going to be needing this non-dt support and we can use the USB PHY library for it. you shouldn't drop support for non-DT platform, in any case we lived without DT (and still do) for years. Gotta find a better way ;-) hmm.. how about passing the device names of PHY in platform data of the controller? It should be deterministic as the PHY framework assigns its own id and we *don't* want to add any requirement that the ID must be assigned manually without using PLATFORM_DEVID_AUTO. We can get rid of *phy_init_data* in the v10 patch series. Thanks Kishon -- 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
Re: [PATCH 01/15] drivers: phy: add generic PHY framework
On Tuesday 13 August 2013 05:07 PM, Tomasz Figa wrote: On Tuesday 13 of August 2013 16:14:44 Kishon Vijay Abraham I wrote: Hi, On Wednesday 31 July 2013 11:45 AM, Felipe Balbi wrote: Hi, On Wed, Jul 31, 2013 at 11:14:32AM +0530, Kishon Vijay Abraham I wrote: IMHO we need a lookup method for PHYs, just like for clocks, regulators, PWMs or even i2c busses because there are complex cases when passing just a name using platform data will not work. I would second what Stephen said [1] and define a structure doing things in a DT-like way. Example; [platform code] static const struct phy_lookup my_phy_lookup[] = { PHY_LOOKUP(s3c-hsotg.0, otg, samsung-usbphy.1, phy.2), The only problem here is that if *PLATFORM_DEVID_AUTO* is used while creating the device, the ids in the device name would change and PHY_LOOKUP wont be useful. I don't think this is a problem. All the existing lookup methods already use ID to identify devices (see regulators, clkdev, PWMs, i2c, ...). You can simply add a requirement that the ID must be assigned manually, without using PLATFORM_DEVID_AUTO to use PHY lookup. And I'm saying that this idea, of using a specific name and id, is frought with fragility and will break in the future in various ways when devices get added to systems, making these strings constantly have to be kept up to date with different board configurations. People, NEVER, hardcode something like an id. The fact that this happens today with the clock code, doesn't make it right, it makes the clock code wrong. Others have already said that this is wrong there as well, as systems change and dynamic ids get used more and more. Let's not repeat the same mistakes of the past just because we refuse to learn from them... So again, the find a phy by a string functions should be removed, the device id should be automatically created by the phy core just to make things unique in sysfs, and no driver code should _ever_ be reliant on the number that is being created, and the pointer to the phy structure should be used everywhere instead. With those types of changes, I will consider merging this subsystem, but without them, sorry, I will not. I'll agree with Greg here, the very fact that we see people trying to add a requirement of *NOT* using PLATFORM_DEVID_AUTO already points to a big problem in the framework. The fact is that if we don't allow PLATFORM_DEVID_AUTO we will end up adding similar infrastructure to the driver themselves to make sure we don't end up with duplicate names in sysfs in case we have multiple instances of the same IP in the SoC (or several of the same PCIe card). I really don't want to go back to that. If we are using PLATFORM_DEVID_AUTO, then I dont see any way we can give the correct binding information to the PHY framework. I think we can drop having this non-dt support in PHY framework? I see only one platform (OMAP3) going to be needing this non-dt support and we can use the USB PHY library for it. you shouldn't drop support for non-DT platform, in any case we lived without DT (and still do) for years. Gotta find a better way ;-) hmm.. how about passing the device names of PHY in platform data of the controller? It should be deterministic as the PHY framework assigns its own id and we *don't* want to add any requirement that the ID must be assigned manually without using PLATFORM_DEVID_AUTO. We can get rid of *phy_init_data* in the v10 patch series. What about slightly altering the concept of v9 to pass a pointer to struct device instead of device name inside phy_init_data? The problem is device might be created very late. (For example in omap4, usb2 phy device gets created when ocp2scp bus is probed). And we have to pass the init data in board file. Thanks Kishon -- 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
Re: [PATCH 01/15] drivers: phy: add generic PHY framework
Hi, On Tuesday 30 July 2013 12:41 PM, Felipe Balbi wrote: On Sun, Jul 21, 2013 at 08:46:53AM -0700, Greg KH wrote: On Sun, Jul 21, 2013 at 01:12:07PM +0200, Tomasz Figa wrote: On Sunday 21 of July 2013 16:37:33 Kishon Vijay Abraham I wrote: Hi, On Sunday 21 July 2013 04:01 PM, Tomasz Figa wrote: Hi, On Saturday 20 of July 2013 19:59:10 Greg KH wrote: On Sat, Jul 20, 2013 at 10:32:26PM -0400, Alan Stern wrote: On Sat, 20 Jul 2013, Greg KH wrote: That should be passed using platform data. Ick, don't pass strings around, pass pointers. If you have platform data you can get to, then put the pointer there, don't use a name. I don't think I understood you here :-s We wont have phy pointer when we create the device for the controller no?(it'll be done in board file). Probably I'm missing something. Why will you not have that pointer? You can't rely on the name as the device id will not match up, so you should be able to rely on the pointer being in the structure that the board sets up, right? Don't use names, especially as ids can, and will, change, that is going to cause big problems. Use pointers, this is C, we are supposed to be doing that :) Kishon, I think what Greg means is this: The name you are using must be stored somewhere in a data structure constructed by the board file, right? Or at least, associated with some data structure somehow. Otherwise the platform code wouldn't know which PHY hardware corresponded to a particular name. Greg's suggestion is that you store the address of that data structure in the platform data instead of storing the name string. Have the consumer pass the data structure's address when it calls phy_create, instead of passing the name. Then you don't have to worry about two PHYs accidentally ending up with the same name or any other similar problems. Close, but the issue is that whatever returns from phy_create() should then be used, no need to call any find functions, as you can just use the pointer that phy_create() returns. Much like all other class api functions in the kernel work. I think there is a confusion here about who registers the PHYs. All platform code does is registering a platform/i2c/whatever device, which causes a driver (located in drivers/phy/) to be instantiated. Such drivers call phy_create(), usually in their probe() callbacks, so platform_code has no way (and should have no way, for the sake of layering) to get what phy_create() returns. Why not put pointers in the platform data structure that can hold these pointers? I thought that is why we created those structures in the first place. If not, what are they there for? heh, IMO we shouldn't pass pointers of any kind through platform_data, we want to pass data :-) Allowing to pass pointers through that, is one of the reasons which got us in such a big mess in ARM land, well it was much easier for a board-file/driver writer to pass a function pointer then to create a generic framework :-) IMHO we need a lookup method for PHYs, just like for clocks, regulators, PWMs or even i2c busses because there are complex cases when passing just a name using platform data will not work. I would second what Stephen said [1] and define a structure doing things in a DT-like way. Example; [platform code] static const struct phy_lookup my_phy_lookup[] = { PHY_LOOKUP(s3c-hsotg.0, otg, samsung-usbphy.1, phy.2), The only problem here is that if *PLATFORM_DEVID_AUTO* is used while creating the device, the ids in the device name would change and PHY_LOOKUP wont be useful. I don't think this is a problem. All the existing lookup methods already use ID to identify devices (see regulators, clkdev, PWMs, i2c, ...). You can simply add a requirement that the ID must be assigned manually, without using PLATFORM_DEVID_AUTO to use PHY lookup. And I'm saying that this idea, of using a specific name and id, is frought with fragility and will break in the future in various ways when devices get added to systems, making these strings constantly have to be kept up to date with different board configurations. People, NEVER, hardcode something like an id. The fact that this happens today with the clock code, doesn't make it right, it makes the clock code wrong. Others have already said that this is wrong there as well, as systems change and dynamic ids get used more and more. Let's not repeat the same mistakes of the past just because we refuse to learn from them... So again, the find a phy by a string functions should be removed, the device id should be automatically created by the phy core just to make things unique in sysfs, and no driver code should _ever_ be reliant on the number that is being created, and the pointer to the phy structure should be used everywhere instead. With those types of changes, I will consider merging this subsystem, but without them, sorry, I will not. I'll agree with Greg
Re: [RESEND PATCH v10 1/8] drivers: phy: add generic PHY framework
On Monday 29 July 2013 08:58 PM, Kamil Debski wrote: 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 t.f...@samsung.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Tested-by: Sylwester Nawrocki s.nawro...@samsung.com --- .../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? right.. thanks for spotting this. Regards Kishon -- 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
Re: [RESEND PATCH v10 1/8] drivers: phy: add generic PHY framework
Hi, On Monday 29 July 2013 09:21 PM, Sylwester Nawrocki wrote: On 07/26/2013 02:49 PM, Kishon Vijay Abraham I wrote: 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 t.f...@samsung.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Tested-by: Sylwester Nawrocki s.nawro...@samsung.com --- .../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 diff --git a/Documentation/devicetree/bindings/phy/phy-bindings.txt b/Documentation/devicetree/bindings/phy/phy-bindings.txt new file mode 100644 index 000..8ae844f --- /dev/null +++ b/Documentation/devicetree/bindings/phy/phy-bindings.txt @@ -0,0 +1,66 @@ +This document explains only the device tree data binding. For general +information about PHY subsystem refer to Documentation/phy.txt [...] @@ -0,0 +1,166 @@ +PHY SUBSYSTEM + Kishon Vijay Abraham I kis...@ti.com + +This document explains the Generic PHY Framework along with the APIs provided, +and how-to-use. + +1. Introduction + +*PHY* is the abbreviation for physical layer. It is used to connect a device +to the physical medium e.g., the USB controller has a PHY to provide functions +such as serialization, de-serialization, encoding, decoding and is responsible +for obtaining the required data transmission rate. Note that some USB +controllers have PHY functionality embedded into it and others use an external +PHY. Other peripherals that use PHY include Wireless LAN, Ethernet, +SATA etc. + +The intention of creating this framework is to bring the PHY drivers spread +all over the Linux kernel to drivers/phy to increase code re-use and for +better code maintainability. + +This framework will be of use only to devices that use external PHY (PHY +functionality is not embedded within the controller). + +2. Registering/Unregistering the PHY provider + +PHY provider refers to an entity that implements one or more PHY instances. +For the simple case where the PHY provider implements only a single instance of +the PHY, the framework provides its own implementation of of_xlate in +of_phy_simple_xlate. If the PHY provider implements multiple instances, it +should provide its own implementation of of_xlate. of_xlate is used only for +dt boot case. + +#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)) This needs to be: __devm_of_phy_provider_register((dev), THIS_MODULE, (xlate)) as Kamil pointed out. We've tested it here with v9 and it makes Bad Things happen. ;) +of_phy_provider_register and devm_of_phy_provider_register macros can be used to +register the phy_provider and it takes device and of_xlate as +arguments. For the dt boot case, all PHY providers should use one of the above +2 macros to register the PHY provider. + +void devm_of_phy_provider_unregister(struct device *dev, +struct phy_provider *phy_provider); +void of_phy_provider_unregister(struct phy_provider *phy_provider); + +devm_of_phy_provider_unregister and of_phy_provider_unregister can be used to +unregister the PHY. + [...] diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c new file mode 100644 index 000..f1d15e5 --- /dev/null +++ b/drivers/phy/phy-core.c @@ -0,0 +1,714 @@ [...] +static struct phy
[PATCH v10 3/8] usb: phy: twl4030: use the new generic PHY framework
Used the generic PHY framework API to create the PHY. For powering on and powering off the PHY, power_on and power_off ops are used. Once the MUSB OMAP glue is adapted to the new framework, the suspend and resume ops of usb phy library will be removed. Also twl4030-usb driver is moved to drivers/phy/. However using the old usb phy library cannot be completely removed because otg is intertwined with phy and moving to the new framework completely will break otg. Once we have a separate otg state machine, we can get rid of the usb phy library. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- drivers/phy/Kconfig | 11 ++ drivers/phy/Makefile|1 + drivers/{usb = }/phy/phy-twl4030-usb.c | 56 +-- drivers/usb/phy/Kconfig |9 - drivers/usb/phy/Makefile|1 - include/linux/i2c/twl.h |2 ++ 6 files changed, 67 insertions(+), 13 deletions(-) rename drivers/{usb = }/phy/phy-twl4030-usb.c (95%) diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 38c3477..ac239ac 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -27,4 +27,15 @@ config OMAP_USB2 The USB OTG controller communicates with the comparator using this driver. +config TWL4030_USB + tristate TWL4030 USB Transceiver Driver + depends on TWL4030_CORE REGULATOR_TWL4030 USB_MUSB_OMAP2PLUS + select GENERIC_PHY + select USB_PHY + help + Enable this to support the USB OTG transceiver on TWL4030 + family chips (including the TWL5030 and TPS659x0 devices). + This transceiver supports high and full speed devices plus, + in host mode, low speed. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index ed5b088..0dd8a98 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_GENERIC_PHY) += phy-core.o obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o +obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o diff --git a/drivers/usb/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c similarity index 95% rename from drivers/usb/phy/phy-twl4030-usb.c rename to drivers/phy/phy-twl4030-usb.c index 8f78d2d..494f107 100644 --- a/drivers/usb/phy/phy-twl4030-usb.c +++ b/drivers/phy/phy-twl4030-usb.c @@ -33,6 +33,7 @@ #include linux/io.h #include linux/delay.h #include linux/usb/otg.h +#include linux/phy/phy.h #include linux/usb/musb-omap.h #include linux/usb/ulpi.h #include linux/i2c/twl.h @@ -431,6 +432,14 @@ static void twl4030_phy_suspend(struct twl4030_usb *twl, int controller_off) dev_dbg(twl-dev, %s\n, __func__); } +static int twl4030_phy_power_off(struct phy *phy) +{ + struct twl4030_usb *twl = phy_get_drvdata(phy); + + twl4030_phy_suspend(twl, 0); + return 0; +} + static void __twl4030_phy_resume(struct twl4030_usb *twl) { twl4030_phy_power(twl, 1); @@ -459,6 +468,14 @@ static void twl4030_phy_resume(struct twl4030_usb *twl) } } +static int twl4030_phy_power_on(struct phy *phy) +{ + struct twl4030_usb *twl = phy_get_drvdata(phy); + + twl4030_phy_resume(twl); + return 0; +} + static int twl4030_usb_ldo_init(struct twl4030_usb *twl) { /* Enable writing to power configuration registers */ @@ -602,13 +619,22 @@ static int twl4030_usb_phy_init(struct usb_phy *phy) status = twl4030_usb_linkstat(twl); twl-linkstat = status; - if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) + if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) { omap_musb_mailbox(twl-linkstat); + twl4030_phy_resume(twl); + } sysfs_notify(twl-dev-kobj, NULL, vbus); return 0; } +static int twl4030_phy_init(struct phy *phy) +{ + struct twl4030_usb *twl = phy_get_drvdata(phy); + + return twl4030_usb_phy_init(twl-phy); +} + static int twl4030_set_suspend(struct usb_phy *x, int suspend) { struct twl4030_usb *twl = phy_to_twl(x); @@ -646,13 +672,23 @@ static int twl4030_set_host(struct usb_otg *otg, struct usb_bus *host) return 0; } +static const struct phy_ops ops = { + .init = twl4030_phy_init, + .power_on = twl4030_phy_power_on, + .power_off = twl4030_phy_power_off, + .owner = THIS_MODULE, +}; + static int twl4030_usb_probe(struct platform_device *pdev) { struct twl4030_usb_data *pdata = pdev-dev.platform_data; struct twl4030_usb *twl; + struct phy *phy; int status, err; struct usb_otg *otg; struct device_node *np = pdev-dev.of_node; + struct phy_provider *phy_provider; + struct phy_init_data
[PATCH v10 0/8] PHY framework
Added a generic PHY framework that 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. This framework will be of use only to devices that uses external PHY (PHY functionality is not embedded within the controller). The intention of creating this framework is to bring the phy drivers spread all over the Linux kernel to drivers/phy to increase code re-use and to increase code maintainability. Comments to make PHY as bus wasn't done because PHY devices can be part of other bus and making a same device attached to multiple bus leads to bad design. If the PHY driver has to send notification on connect/disconnect, the PHY driver should make use of the extcon framework. Using this susbsystem to use extcon framwork will have to be analysed. You can find this patch series @ git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git testing I'll create a new branch *next* once this patch series is finalized. All the PHY driver development that depends on PHY framework can be based on this branch. Did USB enumeration testing in panda and beagle after applying [1] [1] - https://lkml.org/lkml/2013/7/26/88 Changes from v9: * Fixed Greg's concern on having *find PHY by string* and changed it to Tomasz pseudo code. * move omap-usb2 phy and twl4030-usb phy to drivers/phy * made all the dependent drivers select GENERIC_PHY instead of having depends on * Made PHY core to assign the id's (so changed the phy_create API). * Adapted twl4030-usb to the new design. Changes from v8: * Added phy_set_drvdata and phy_get_drvdata in phy.h. * Changed phy_create API not to take void *priv. private data should now be set using phy_set_drvdata now. Changes from v7: * Fixed Documentation * Added to_phy, of_phy_provider_register and devm_of_phy_provider_register * modified runtime_pm usage in phy_init, phy_exit, phy_power_on and phy_power_off. Now phy_power_on will enable the clocks and phy_power_off will disable the clocks. * pm_runtime_no_callbacks() is added so that pm_runtime_get_sync doesn't fail * modified other patches to adhere to the changes in the PHY framework * removed usb: phy: twl4030: twl4030 shouldn't be subsys_initcall as it will be merged separately. * reference counting has been added to protect phy ops when the PHY is shared by multiple consumers. Changes from v6 * corrected few typos in Documentation * Changed PHY Subsystem to *bool* in Kconfig (to avoid compilation errors when PHY Subsystem is kept as module and the dependent modules are built-in) * Added if pm_runtime_enabled check before runtime pm calls. Changes from v5: * removed the new sysfs entries as it dint have any new information other than what is already there in /sys/devices/... * removed a bunch of APIs added to get the PHY and now only phy_get and devm_phy_get are used. * Added new APIs to register/unregister the PHY provider. This is needed for dt boot case. * Enabled pm runtime and incorporated the comments given by Alan Stern in a different patch series by Gautam. * Removed the *phy_bind* API. Now the phy binding information should be passed using the platform data to the controller devices. * Fixed a few typos. Changes from v4: * removed of_phy_get_with_args/devm_of_phy_get_with_args. Now the *phy providers* should use their custom implementation of of_xlate or use of_phy_xlate to get *phy instance* from *phy providers*. * Added of_phy_xlate to be used by *phy providers* if it provides only one PHY. * changed phy_core from having subsys_initcall to module_init. * other minor fixes. Changes from v3: * Changed the return value of PHY APIs to ENOSYS * Added APIs of_phy_get_with_args/devm_of_phy_get_with_args to support getting PHYs if the same IP implements multiple PHYs. * modified phy_bind API so that the binding information can now be _updated_. In effect of this removed the binding information added in board files and added only in usb-musb.c. If a particular board uses a different phy binding, it can update it in board file after usb_musb_init(). * Added Documentation/devicetree/bindings/phy/phy-bindings.txt for dt binding information. Changes from v2: * removed phy_descriptor structure completely so changed the APIs which were taking phy_descriptor as parameters * Added 2 more APIs *of_phy_get_byname* and *devm_of_phy_get_byname* to be used by PHY user drivers which has *phy* and *phy-names* binding in the dt data * Fixed a few typos * Removed phy_list and we now use class_dev_iter_init, class_dev_iter_next and class_dev_iter_exit for traversing through the phy list. (Note we still need phy_bind list and phy_bind_mutex). * Changed the sysfs entry name from *bind* to *phy_bind*. Changes from v1: * Added Documentation for the PHY framework * Added few more APIs mostly w.r.t devres * Modified omap-usb2 and twl4030 to make use of the new framework Kishon Vijay Abraham I (8
[PATCH v10 7/8] usb: phy: omap-usb2: remove *set_suspend* callback from omap-usb2
Now that omap-usb2 is adapted to the new generic PHY framework, *set_suspend* ops can be removed from omap-usb2 driver. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- drivers/phy/phy-omap-usb2.c | 25 - 1 file changed, 25 deletions(-) diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c index 25e0f3c..dec3fab 100644 --- a/drivers/phy/phy-omap-usb2.c +++ b/drivers/phy/phy-omap-usb2.c @@ -97,29 +97,6 @@ static int omap_usb_set_peripheral(struct usb_otg *otg, return 0; } -static int omap_usb2_suspend(struct usb_phy *x, int suspend) -{ - u32 ret; - struct omap_usb *phy = phy_to_omapusb(x); - - if (suspend !phy-is_suspended) { - omap_control_usb_phy_power(phy-control_dev, 0); - pm_runtime_put_sync(phy-dev); - phy-is_suspended = 1; - } else if (!suspend phy-is_suspended) { - ret = pm_runtime_get_sync(phy-dev); - if (ret 0) { - dev_err(phy-dev, get_sync failed with err %d\n, - ret); - return ret; - } - omap_control_usb_phy_power(phy-control_dev, 1); - phy-is_suspended = 0; - } - - return 0; -} - static int omap_usb_power_off(struct phy *x) { struct omap_usb *phy = phy_get_drvdata(x); @@ -167,7 +144,6 @@ static int omap_usb2_probe(struct platform_device *pdev) phy-phy.dev= phy-dev; phy-phy.label = omap-usb2; - phy-phy.set_suspend= omap_usb2_suspend; phy-phy.otg= otg; phy-phy.type = USB_PHY_TYPE_USB2; @@ -182,7 +158,6 @@ static int omap_usb2_probe(struct platform_device *pdev) return -ENODEV; } - phy-is_suspended = 1; omap_control_usb_phy_power(phy-control_dev, 0); otg-set_host = omap_usb_set_host; -- 1.7.10.4 -- 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
[PATCH v10 8/8] usb: phy: twl4030-usb: remove *set_suspend* and *phy_init* ops
Now that twl4030-usb is adapted to the new generic PHY framework, *set_suspend* and *phy_init* ops can be removed from twl4030-usb driver. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- drivers/phy/phy-twl4030-usb.c | 57 ++--- 1 file changed, 13 insertions(+), 44 deletions(-) diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c index 494f107..c437211 100644 --- a/drivers/phy/phy-twl4030-usb.c +++ b/drivers/phy/phy-twl4030-usb.c @@ -422,25 +422,20 @@ static void twl4030_phy_power(struct twl4030_usb *twl, int on) } } -static void twl4030_phy_suspend(struct twl4030_usb *twl, int controller_off) +static int twl4030_phy_power_off(struct phy *phy) { + struct twl4030_usb *twl = phy_get_drvdata(phy); + if (twl-asleep) - return; + return 0; twl4030_phy_power(twl, 0); twl-asleep = 1; dev_dbg(twl-dev, %s\n, __func__); -} - -static int twl4030_phy_power_off(struct phy *phy) -{ - struct twl4030_usb *twl = phy_get_drvdata(phy); - - twl4030_phy_suspend(twl, 0); return 0; } -static void __twl4030_phy_resume(struct twl4030_usb *twl) +static void __twl4030_phy_power_on(struct twl4030_usb *twl) { twl4030_phy_power(twl, 1); twl4030_i2c_access(twl, 1); @@ -449,11 +444,13 @@ static void __twl4030_phy_resume(struct twl4030_usb *twl) twl4030_i2c_access(twl, 0); } -static void twl4030_phy_resume(struct twl4030_usb *twl) +static int twl4030_phy_power_on(struct phy *phy) { + struct twl4030_usb *twl = phy_get_drvdata(phy); + if (!twl-asleep) - return; - __twl4030_phy_resume(twl); + return 0; + __twl4030_phy_power_on(twl); twl-asleep = 0; dev_dbg(twl-dev, %s\n, __func__); @@ -466,13 +463,6 @@ static void twl4030_phy_resume(struct twl4030_usb *twl) cancel_delayed_work(twl-id_workaround_work); schedule_delayed_work(twl-id_workaround_work, HZ); } -} - -static int twl4030_phy_power_on(struct phy *phy) -{ - struct twl4030_usb *twl = phy_get_drvdata(phy); - - twl4030_phy_resume(twl); return 0; } @@ -604,9 +594,9 @@ static void twl4030_id_workaround_work(struct work_struct *work) } } -static int twl4030_usb_phy_init(struct usb_phy *phy) +static int twl4030_phy_init(struct phy *phy) { - struct twl4030_usb *twl = phy_to_twl(phy); + struct twl4030_usb *twl = phy_get_drvdata(phy); enum omap_musb_vbus_id_status status; /* @@ -621,32 +611,13 @@ static int twl4030_usb_phy_init(struct usb_phy *phy) if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) { omap_musb_mailbox(twl-linkstat); - twl4030_phy_resume(twl); + twl4030_phy_power_on(phy); } sysfs_notify(twl-dev-kobj, NULL, vbus); return 0; } -static int twl4030_phy_init(struct phy *phy) -{ - struct twl4030_usb *twl = phy_get_drvdata(phy); - - return twl4030_usb_phy_init(twl-phy); -} - -static int twl4030_set_suspend(struct usb_phy *x, int suspend) -{ - struct twl4030_usb *twl = phy_to_twl(x); - - if (suspend) - twl4030_phy_suspend(twl, 1); - else - twl4030_phy_resume(twl); - - return 0; -} - static int twl4030_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget) { @@ -719,8 +690,6 @@ static int twl4030_usb_probe(struct platform_device *pdev) twl-phy.label = twl4030; twl-phy.otg= otg; twl-phy.type = USB_PHY_TYPE_USB2; - twl-phy.set_suspend= twl4030_set_suspend; - twl-phy.init = twl4030_usb_phy_init; otg-phy= twl-phy; otg-set_host = twl4030_set_host; -- 1.7.10.4 -- 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
[PATCH v10 5/8] ARM: dts: omap: update usb_otg_hs data
Updated the usb_otg_hs dt data to include the *phy* and *phy-names* binding in order for the driver to use the new generic PHY framework. Also updated the Documentation to include the binding information. The PHY binding information can be found at Documentation/devicetree/bindings/phy/phy-bindings.txt Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- Documentation/devicetree/bindings/usb/omap-usb.txt |5 + Documentation/devicetree/bindings/usb/usb-phy.txt |6 ++ arch/arm/boot/dts/omap3-beagle-xm.dts |2 ++ arch/arm/boot/dts/omap3-evm.dts|2 ++ arch/arm/boot/dts/omap3-overo.dtsi |2 ++ arch/arm/boot/dts/omap4.dtsi |3 +++ arch/arm/boot/dts/twl4030.dtsi |1 + 7 files changed, 21 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt b/Documentation/devicetree/bindings/usb/omap-usb.txt index 57e71f6..825790d 100644 --- a/Documentation/devicetree/bindings/usb/omap-usb.txt +++ b/Documentation/devicetree/bindings/usb/omap-usb.txt @@ -19,6 +19,9 @@ OMAP MUSB GLUE - power : Should be 50. This signifies the controller can supply up to 100mA when operating in host mode. - usb-phy : the phandle for the PHY device + - phys : the phandle for the PHY device (used by generic PHY framework) + - phy-names : the names of the PHY corresponding to the PHYs present in the + *phy* phandle. Optional properties: - ctrl-module : phandle of the control module this glue uses to write to @@ -33,6 +36,8 @@ usb_otg_hs: usb_otg_hs@4a0ab000 { num-eps = 16; ram-bits = 12; ctrl-module = omap_control_usb; + phys = usb2_phy; + phy-names = usb2-phy; }; Board specific device node entry diff --git a/Documentation/devicetree/bindings/usb/usb-phy.txt b/Documentation/devicetree/bindings/usb/usb-phy.txt index 61496f5..c0245c8 100644 --- a/Documentation/devicetree/bindings/usb/usb-phy.txt +++ b/Documentation/devicetree/bindings/usb/usb-phy.txt @@ -5,6 +5,8 @@ OMAP USB2 PHY Required properties: - compatible: Should be ti,omap-usb2 - reg : Address and length of the register set for the device. + - #phy-cells: determine the number of cells that should be given in the + phandle while referencing this phy. Optional properties: - ctrl-module : phandle of the control module used by PHY driver to power on @@ -16,6 +18,7 @@ usb2phy@4a0ad080 { compatible = ti,omap-usb2; reg = 0x4a0ad080 0x58; ctrl-module = omap_control_usb; + #phy-cells = 0; }; OMAP USB3 PHY @@ -25,6 +28,8 @@ Required properties: - reg : Address and length of the register set for the device. - reg-names: The names of the register addresses corresponding to the registers filled in reg. + - #phy-cells: determine the number of cells that should be given in the + phandle while referencing this phy. Optional properties: - ctrl-module : phandle of the control module used by PHY driver to power on @@ -39,4 +44,5 @@ usb3phy@4a084400 { 0x4a084c00 0x40; reg-names = phy_rx, phy_tx, pll_ctrl; ctrl-module = omap_control_usb; + #phy-cells = 0; }; diff --git a/arch/arm/boot/dts/omap3-beagle-xm.dts b/arch/arm/boot/dts/omap3-beagle-xm.dts index afdb164..533b2da 100644 --- a/arch/arm/boot/dts/omap3-beagle-xm.dts +++ b/arch/arm/boot/dts/omap3-beagle-xm.dts @@ -144,6 +144,8 @@ usb_otg_hs { interface-type = 0; usb-phy = usb2_phy; + phys = usb2_phy; + phy-names = usb2-phy; mode = 3; power = 50; }; diff --git a/arch/arm/boot/dts/omap3-evm.dts b/arch/arm/boot/dts/omap3-evm.dts index 7d4329d..4134dd0 100644 --- a/arch/arm/boot/dts/omap3-evm.dts +++ b/arch/arm/boot/dts/omap3-evm.dts @@ -70,6 +70,8 @@ usb_otg_hs { interface-type = 0; usb-phy = usb2_phy; + phys = usb2_phy; + phy-names = usb2-phy; mode = 3; power = 50; }; diff --git a/arch/arm/boot/dts/omap3-overo.dtsi b/arch/arm/boot/dts/omap3-overo.dtsi index 8f1abec..a461d2f 100644 --- a/arch/arm/boot/dts/omap3-overo.dtsi +++ b/arch/arm/boot/dts/omap3-overo.dtsi @@ -76,6 +76,8 @@ usb_otg_hs { interface-type = 0; usb-phy = usb2_phy; + phys = usb2_phy; + phy-names = usb2-phy; mode = 3; power = 50; }; diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi index 22d9f2b..1e8e2fe 100644 --- a/arch/arm/boot/dts/omap4.dtsi +++ b/arch/arm/boot/dts/omap4.dtsi @@ -520,6 +520,7 @@ compatible = ti,omap-usb2; reg = 0x4a0ad080 0x58; ctrl-module = omap_control_usb; + #phy-cells = 0; }; }; @@ -658,6 +659,8 @@ interrupt-names = mc, dma
[PATCH v10 6/8] usb: musb: omap2430: use the new generic PHY framework
Use the generic PHY framework API to get the PHY. The usb_phy_set_resume and usb_phy_set_suspend is replaced with power_on and power_off to align with the new PHY framework. musb-xceiv can't be removed as of now because musb core uses xceiv.state and xceiv.otg. Once there is a separate state machine to handle otg, these can be moved out of xceiv and then we can start using the generic PHY framework. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com Acked-by: Felipe Balbi ba...@ti.com --- drivers/usb/musb/Kconfig |1 + drivers/usb/musb/musb_core.h |2 ++ drivers/usb/musb/omap2430.c | 26 -- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 797e3fd..25e2e57 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -76,6 +76,7 @@ config USB_MUSB_TUSB6010 config USB_MUSB_OMAP2PLUS tristate OMAP2430 and onwards depends on ARCH_OMAP2PLUS + select GENERIC_PHY config USB_MUSB_AM35X tristate AM35x diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 7d341c3..6e567bd 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -46,6 +46,7 @@ #include linux/usb.h #include linux/usb/otg.h #include linux/usb/musb.h +#include linux/phy/phy.h struct musb; struct musb_hw_ep; @@ -346,6 +347,7 @@ struct musb { u16 int_tx; struct usb_phy *xceiv; + struct phy *phy; int nIrq; unsignedirq_wake:1; diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 6708a3b..f7b33f4 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -348,11 +348,21 @@ static int omap2430_musb_init(struct musb *musb) * up through ULPI. TWL4030-family PMICs include one, * which needs a driver, drivers aren't always needed. */ - if (dev-parent-of_node) + if (dev-parent-of_node) { + musb-phy = devm_phy_get(dev-parent, usb2-phy); + + /* We can't totally remove musb-xceiv as of now because +* musb core uses xceiv.state and xceiv.otg. Once we have +* a separate state machine to handle otg, these can be moved +* out of xceiv and then we can start using the generic PHY +* framework +*/ musb-xceiv = devm_usb_get_phy_by_phandle(dev-parent, usb-phy, 0); - else + } else { musb-xceiv = devm_usb_get_phy_dev(dev, 0); + musb-phy = devm_phy_get(dev, usb); + } if (IS_ERR(musb-xceiv)) { status = PTR_ERR(musb-xceiv); @@ -364,6 +374,10 @@ static int omap2430_musb_init(struct musb *musb) return -EPROBE_DEFER; } + if (IS_ERR(musb-phy)) { + pr_err(HS USB OTG: no PHY configured\n); + return PTR_ERR(musb-phy); + } musb-isr = omap2430_musb_interrupt; status = pm_runtime_get_sync(dev); @@ -397,7 +411,7 @@ static int omap2430_musb_init(struct musb *musb) if (glue-status != OMAP_MUSB_UNKNOWN) omap_musb_set_mailbox(glue); - usb_phy_init(musb-xceiv); + phy_init(musb-phy); pm_runtime_put_noidle(musb-controller); return 0; @@ -460,6 +474,7 @@ static int omap2430_musb_exit(struct musb *musb) del_timer_sync(musb_idle_timer); omap2430_low_level_exit(musb); + phy_exit(musb-phy); return 0; } @@ -633,7 +648,7 @@ static int omap2430_runtime_suspend(struct device *dev) OTG_INTERFSEL); omap2430_low_level_exit(musb); - usb_phy_set_suspend(musb-xceiv, 1); + phy_power_off(musb-phy); } return 0; @@ -648,8 +663,7 @@ static int omap2430_runtime_resume(struct device *dev) omap2430_low_level_init(musb); musb_writel(musb-mregs, OTG_INTERFSEL, musb-context.otg_interfsel); - - usb_phy_set_suspend(musb-xceiv, 0); + phy_power_on(musb-phy); } return 0; -- 1.7.10.4 -- 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
[PATCH v10 1/8] drivers: phy: add generic PHY framework
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 t.f...@samsung.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Tested-by: Sylwester Nawrocki s.nawro...@samsung.com --- .../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 diff --git a/Documentation/devicetree/bindings/phy/phy-bindings.txt b/Documentation/devicetree/bindings/phy/phy-bindings.txt new file mode 100644 index 000..8ae844f --- /dev/null +++ b/Documentation/devicetree/bindings/phy/phy-bindings.txt @@ -0,0 +1,66 @@ +This document explains only the device tree data binding. For general +information about PHY subsystem refer to Documentation/phy.txt + +PHY device node +=== + +Required Properties: +#phy-cells:Number of cells in a PHY specifier; The meaning of all those + cells is defined by the binding for the phy node. The PHY + provider can use the values in cells to find the appropriate + PHY. + +For example: + +phys: phy { +compatible = xxx; +reg = ...; +. +. +#phy-cells = 1; +. +. +}; + +That node describes an IP block (PHY provider) that implements 2 different PHYs. +In order to differentiate between these 2 PHYs, an additonal specifier should be +given while trying to get a reference to it. + +PHY user node += + +Required Properties: +phys : the phandle for the PHY device (used by the PHY subsystem) +phy-names : the names of the PHY corresponding to the PHYs present in the + *phys* phandle + +Example 1: +usb1: usb_otg_ss@xxx { +compatible = xxx; +reg = xxx; +. +. +phys = usb2_phy, usb3_phy; +phy-names = usb2phy, usb3phy; +. +. +}; + +This node represents a controller that uses two PHYs, one for usb2 and one for +usb3. + +Example 2: +usb2: usb_otg_ss@xxx { +compatible = xxx; +reg = xxx; +. +. +phys = phys 1; +phy-names = usbphy; +. +. +}; + +This node represents a controller that uses one of the PHYs of the PHY provider +device defined previously. Note that the phy handle has an additional specifier +1 to differentiate between the two PHYs. diff --git a/Documentation/phy.txt b/Documentation/phy.txt new file mode 100644 index 000..4e056c4 --- /dev/null +++ b/Documentation/phy.txt @@ -0,0 +1,166 @@ + PHY SUBSYSTEM + Kishon Vijay Abraham I kis...@ti.com + +This document explains the Generic PHY Framework along with the APIs provided, +and how-to-use. + +1. Introduction + +*PHY* is the abbreviation for physical layer. It is used to connect a device +to the physical medium e.g., the USB controller has a PHY to provide functions +such as serialization, de-serialization, encoding, decoding and is responsible +for obtaining the required data transmission rate. Note that some USB +controllers have PHY functionality embedded into it and others use an external +PHY. Other peripherals that use PHY include Wireless LAN, Ethernet, +SATA etc. + +The intention of creating this framework is to bring the PHY drivers spread +all over the Linux kernel to drivers/phy to increase code re-use and for +better code maintainability. + +This framework will be of use only to devices that use external PHY (PHY +functionality is not embedded within the controller). + +2. Registering/Unregistering the PHY provider + +PHY provider refers to an entity that implements one or more PHY instances. +For the simple case where the PHY provider implements only a single instance
[PATCH v10 4/8] arm: omap3: twl: add phy consumer data in twl4030_usb_data
The PHY framework uses the phy consumer data populated in platform data in the case of non-dt boot to return the reference to the PHY when the controller (PHY consumer) requests for it. So populated the phy consumer data in the platform data of twl usb. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com --- arch/arm/mach-omap2/twl-common.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c index c05898f..b0d54da 100644 --- a/arch/arm/mach-omap2/twl-common.c +++ b/arch/arm/mach-omap2/twl-common.c @@ -24,6 +24,7 @@ #include linux/i2c/twl.h #include linux/gpio.h #include linux/string.h +#include linux/phy/phy.h #include linux/regulator/machine.h #include linux/regulator/fixed.h @@ -90,8 +91,18 @@ void __init omap_pmic_late_init(void) } #if defined(CONFIG_ARCH_OMAP3) +struct phy_consumer consumers[] = { + PHY_CONSUMER(musb-hdrc.0, usb), +}; + +struct phy_init_data init_data = { + .consumers = consumers, + .num_consumers = ARRAY_SIZE(consumers), +}; + static struct twl4030_usb_data omap3_usb_pdata = { .usb_mode = T2_USB_MODE_ULPI, + .init_data = init_data, }; static int omap3_batt_table[] = { -- 1.7.10.4 -- 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
[PATCH v10 2/8] usb: phy: omap-usb2: use the new generic PHY framework
Used the generic PHY framework API to create the PHY. Now the power off and power on are done in omap_usb_power_off and omap_usb_power_on respectively. The omap-usb2 driver is also moved to driver/phy. However using the old USB PHY library cannot be completely removed because OTG is intertwined with PHY and moving to the new framework will break OTG. Once we have a separate OTG state machine, we can get rid of the USB PHY library. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com Acked-by: Felipe Balbi ba...@ti.com --- drivers/phy/Kconfig | 12 + drivers/phy/Makefile |1 + drivers/{usb = }/phy/phy-omap-usb2.c | 45 ++--- drivers/usb/phy/Kconfig | 10 drivers/usb/phy/Makefile |1 - 5 files changed, 54 insertions(+), 15 deletions(-) rename drivers/{usb = }/phy/phy-omap-usb2.c (88%) diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 349bef2..38c3477 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -15,4 +15,16 @@ config GENERIC_PHY phy users can obtain reference to the PHY. All the users of this framework should select this config. +config OMAP_USB2 + tristate OMAP USB2 PHY Driver + depends on ARCH_OMAP2PLUS + select GENERIC_PHY + select USB_PHY + select OMAP_CONTROL_USB + help + Enable this to support the transceiver that is part of SOC. This + driver takes care of all the PHY functionality apart from comparator. + The USB OTG controller communicates with the comparator using this + driver. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 9e9560f..ed5b088 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -3,3 +3,4 @@ # obj-$(CONFIG_GENERIC_PHY) += phy-core.o +obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o diff --git a/drivers/usb/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c similarity index 88% rename from drivers/usb/phy/phy-omap-usb2.c rename to drivers/phy/phy-omap-usb2.c index 844ab68..25e0f3c 100644 --- a/drivers/usb/phy/phy-omap-usb2.c +++ b/drivers/phy/phy-omap-usb2.c @@ -28,6 +28,7 @@ #include linux/pm_runtime.h #include linux/delay.h #include linux/usb/omap_control_usb.h +#include linux/phy/phy.h /** * omap_usb2_set_comparator - links the comparator present in the sytem with @@ -119,10 +120,36 @@ static int omap_usb2_suspend(struct usb_phy *x, int suspend) return 0; } +static int omap_usb_power_off(struct phy *x) +{ + struct omap_usb *phy = phy_get_drvdata(x); + + omap_control_usb_phy_power(phy-control_dev, 0); + + return 0; +} + +static int omap_usb_power_on(struct phy *x) +{ + struct omap_usb *phy = phy_get_drvdata(x); + + omap_control_usb_phy_power(phy-control_dev, 1); + + return 0; +} + +static struct phy_ops ops = { + .power_on = omap_usb_power_on, + .power_off = omap_usb_power_off, + .owner = THIS_MODULE, +}; + static int omap_usb2_probe(struct platform_device *pdev) { struct omap_usb *phy; + struct phy *generic_phy; struct usb_otg *otg; + struct phy_provider *phy_provider; phy = devm_kzalloc(pdev-dev, sizeof(*phy), GFP_KERNEL); if (!phy) { @@ -144,6 +171,11 @@ static int omap_usb2_probe(struct platform_device *pdev) phy-phy.otg= otg; phy-phy.type = USB_PHY_TYPE_USB2; + phy_provider = devm_of_phy_provider_register(phy-dev, + of_phy_simple_xlate); + if (IS_ERR(phy_provider)) + return PTR_ERR(phy_provider); + phy-control_dev = omap_get_control_dev(); if (IS_ERR(phy-control_dev)) { dev_dbg(pdev-dev, Failed to get control device\n); @@ -159,6 +191,15 @@ static int omap_usb2_probe(struct platform_device *pdev) otg-start_srp = omap_usb_start_srp; otg-phy= phy-phy; + platform_set_drvdata(pdev, phy); + pm_runtime_enable(phy-dev); + + generic_phy = devm_phy_create(phy-dev, ops, NULL); + if (IS_ERR(generic_phy)) + return PTR_ERR(generic_phy); + + phy_set_drvdata(generic_phy, phy); + phy-wkupclk = devm_clk_get(phy-dev, usb_phy_cm_clk32k); if (IS_ERR(phy-wkupclk)) { dev_err(pdev-dev, unable to get usb_phy_cm_clk32k\n); @@ -174,10 +215,6 @@ static int omap_usb2_probe(struct platform_device *pdev) usb_add_phy_dev(phy-phy); - platform_set_drvdata(pdev, phy); - - pm_runtime_enable(phy-dev); - return 0; } diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 3622fff..7813238 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -72,16 +72,6 @@ config
[RESEND PATCH v10 2/8] usb: phy: omap-usb2: use the new generic PHY framework
Used the generic PHY framework API to create the PHY. Now the power off and power on are done in omap_usb_power_off and omap_usb_power_on respectively. The omap-usb2 driver is also moved to driver/phy. However using the old USB PHY library cannot be completely removed because OTG is intertwined with PHY and moving to the new framework will break OTG. Once we have a separate OTG state machine, we can get rid of the USB PHY library. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com Acked-by: Felipe Balbi ba...@ti.com --- drivers/phy/Kconfig | 12 + drivers/phy/Makefile |1 + drivers/{usb = }/phy/phy-omap-usb2.c | 45 ++--- drivers/usb/phy/Kconfig | 10 drivers/usb/phy/Makefile |1 - 5 files changed, 54 insertions(+), 15 deletions(-) rename drivers/{usb = }/phy/phy-omap-usb2.c (88%) diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 349bef2..38c3477 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -15,4 +15,16 @@ config GENERIC_PHY phy users can obtain reference to the PHY. All the users of this framework should select this config. +config OMAP_USB2 + tristate OMAP USB2 PHY Driver + depends on ARCH_OMAP2PLUS + select GENERIC_PHY + select USB_PHY + select OMAP_CONTROL_USB + help + Enable this to support the transceiver that is part of SOC. This + driver takes care of all the PHY functionality apart from comparator. + The USB OTG controller communicates with the comparator using this + driver. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 9e9560f..ed5b088 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -3,3 +3,4 @@ # obj-$(CONFIG_GENERIC_PHY) += phy-core.o +obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o diff --git a/drivers/usb/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c similarity index 88% rename from drivers/usb/phy/phy-omap-usb2.c rename to drivers/phy/phy-omap-usb2.c index 844ab68..25e0f3c 100644 --- a/drivers/usb/phy/phy-omap-usb2.c +++ b/drivers/phy/phy-omap-usb2.c @@ -28,6 +28,7 @@ #include linux/pm_runtime.h #include linux/delay.h #include linux/usb/omap_control_usb.h +#include linux/phy/phy.h /** * omap_usb2_set_comparator - links the comparator present in the sytem with @@ -119,10 +120,36 @@ static int omap_usb2_suspend(struct usb_phy *x, int suspend) return 0; } +static int omap_usb_power_off(struct phy *x) +{ + struct omap_usb *phy = phy_get_drvdata(x); + + omap_control_usb_phy_power(phy-control_dev, 0); + + return 0; +} + +static int omap_usb_power_on(struct phy *x) +{ + struct omap_usb *phy = phy_get_drvdata(x); + + omap_control_usb_phy_power(phy-control_dev, 1); + + return 0; +} + +static struct phy_ops ops = { + .power_on = omap_usb_power_on, + .power_off = omap_usb_power_off, + .owner = THIS_MODULE, +}; + static int omap_usb2_probe(struct platform_device *pdev) { struct omap_usb *phy; + struct phy *generic_phy; struct usb_otg *otg; + struct phy_provider *phy_provider; phy = devm_kzalloc(pdev-dev, sizeof(*phy), GFP_KERNEL); if (!phy) { @@ -144,6 +171,11 @@ static int omap_usb2_probe(struct platform_device *pdev) phy-phy.otg= otg; phy-phy.type = USB_PHY_TYPE_USB2; + phy_provider = devm_of_phy_provider_register(phy-dev, + of_phy_simple_xlate); + if (IS_ERR(phy_provider)) + return PTR_ERR(phy_provider); + phy-control_dev = omap_get_control_dev(); if (IS_ERR(phy-control_dev)) { dev_dbg(pdev-dev, Failed to get control device\n); @@ -159,6 +191,15 @@ static int omap_usb2_probe(struct platform_device *pdev) otg-start_srp = omap_usb_start_srp; otg-phy= phy-phy; + platform_set_drvdata(pdev, phy); + pm_runtime_enable(phy-dev); + + generic_phy = devm_phy_create(phy-dev, ops, NULL); + if (IS_ERR(generic_phy)) + return PTR_ERR(generic_phy); + + phy_set_drvdata(generic_phy, phy); + phy-wkupclk = devm_clk_get(phy-dev, usb_phy_cm_clk32k); if (IS_ERR(phy-wkupclk)) { dev_err(pdev-dev, unable to get usb_phy_cm_clk32k\n); @@ -174,10 +215,6 @@ static int omap_usb2_probe(struct platform_device *pdev) usb_add_phy_dev(phy-phy); - platform_set_drvdata(pdev, phy); - - pm_runtime_enable(phy-dev); - return 0; } diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 3622fff..7813238 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -72,16 +72,6 @@ config
[RESEND PATCH v10 3/8] usb: phy: twl4030: use the new generic PHY framework
Used the generic PHY framework API to create the PHY. For powering on and powering off the PHY, power_on and power_off ops are used. Once the MUSB OMAP glue is adapted to the new framework, the suspend and resume ops of usb phy library will be removed. Also twl4030-usb driver is moved to drivers/phy/. However using the old usb phy library cannot be completely removed because otg is intertwined with phy and moving to the new framework completely will break otg. Once we have a separate otg state machine, we can get rid of the usb phy library. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- drivers/phy/Kconfig | 11 ++ drivers/phy/Makefile|1 + drivers/{usb = }/phy/phy-twl4030-usb.c | 56 +-- drivers/usb/phy/Kconfig |9 - drivers/usb/phy/Makefile|1 - include/linux/i2c/twl.h |2 ++ 6 files changed, 67 insertions(+), 13 deletions(-) rename drivers/{usb = }/phy/phy-twl4030-usb.c (95%) diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 38c3477..ac239ac 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -27,4 +27,15 @@ config OMAP_USB2 The USB OTG controller communicates with the comparator using this driver. +config TWL4030_USB + tristate TWL4030 USB Transceiver Driver + depends on TWL4030_CORE REGULATOR_TWL4030 USB_MUSB_OMAP2PLUS + select GENERIC_PHY + select USB_PHY + help + Enable this to support the USB OTG transceiver on TWL4030 + family chips (including the TWL5030 and TPS659x0 devices). + This transceiver supports high and full speed devices plus, + in host mode, low speed. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index ed5b088..0dd8a98 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_GENERIC_PHY) += phy-core.o obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o +obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o diff --git a/drivers/usb/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c similarity index 95% rename from drivers/usb/phy/phy-twl4030-usb.c rename to drivers/phy/phy-twl4030-usb.c index 8f78d2d..494f107 100644 --- a/drivers/usb/phy/phy-twl4030-usb.c +++ b/drivers/phy/phy-twl4030-usb.c @@ -33,6 +33,7 @@ #include linux/io.h #include linux/delay.h #include linux/usb/otg.h +#include linux/phy/phy.h #include linux/usb/musb-omap.h #include linux/usb/ulpi.h #include linux/i2c/twl.h @@ -431,6 +432,14 @@ static void twl4030_phy_suspend(struct twl4030_usb *twl, int controller_off) dev_dbg(twl-dev, %s\n, __func__); } +static int twl4030_phy_power_off(struct phy *phy) +{ + struct twl4030_usb *twl = phy_get_drvdata(phy); + + twl4030_phy_suspend(twl, 0); + return 0; +} + static void __twl4030_phy_resume(struct twl4030_usb *twl) { twl4030_phy_power(twl, 1); @@ -459,6 +468,14 @@ static void twl4030_phy_resume(struct twl4030_usb *twl) } } +static int twl4030_phy_power_on(struct phy *phy) +{ + struct twl4030_usb *twl = phy_get_drvdata(phy); + + twl4030_phy_resume(twl); + return 0; +} + static int twl4030_usb_ldo_init(struct twl4030_usb *twl) { /* Enable writing to power configuration registers */ @@ -602,13 +619,22 @@ static int twl4030_usb_phy_init(struct usb_phy *phy) status = twl4030_usb_linkstat(twl); twl-linkstat = status; - if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) + if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) { omap_musb_mailbox(twl-linkstat); + twl4030_phy_resume(twl); + } sysfs_notify(twl-dev-kobj, NULL, vbus); return 0; } +static int twl4030_phy_init(struct phy *phy) +{ + struct twl4030_usb *twl = phy_get_drvdata(phy); + + return twl4030_usb_phy_init(twl-phy); +} + static int twl4030_set_suspend(struct usb_phy *x, int suspend) { struct twl4030_usb *twl = phy_to_twl(x); @@ -646,13 +672,23 @@ static int twl4030_set_host(struct usb_otg *otg, struct usb_bus *host) return 0; } +static const struct phy_ops ops = { + .init = twl4030_phy_init, + .power_on = twl4030_phy_power_on, + .power_off = twl4030_phy_power_off, + .owner = THIS_MODULE, +}; + static int twl4030_usb_probe(struct platform_device *pdev) { struct twl4030_usb_data *pdata = pdev-dev.platform_data; struct twl4030_usb *twl; + struct phy *phy; int status, err; struct usb_otg *otg; struct device_node *np = pdev-dev.of_node; + struct phy_provider *phy_provider; + struct phy_init_data
[RESEND PATCH v10 4/8] arm: omap3: twl: add phy consumer data in twl4030_usb_data
The PHY framework uses the phy consumer data populated in platform data in the case of non-dt boot to return the reference to the PHY when the controller (PHY consumer) requests for it. So populated the phy consumer data in the platform data of twl usb. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com --- arch/arm/mach-omap2/twl-common.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c index c05898f..b0d54da 100644 --- a/arch/arm/mach-omap2/twl-common.c +++ b/arch/arm/mach-omap2/twl-common.c @@ -24,6 +24,7 @@ #include linux/i2c/twl.h #include linux/gpio.h #include linux/string.h +#include linux/phy/phy.h #include linux/regulator/machine.h #include linux/regulator/fixed.h @@ -90,8 +91,18 @@ void __init omap_pmic_late_init(void) } #if defined(CONFIG_ARCH_OMAP3) +struct phy_consumer consumers[] = { + PHY_CONSUMER(musb-hdrc.0, usb), +}; + +struct phy_init_data init_data = { + .consumers = consumers, + .num_consumers = ARRAY_SIZE(consumers), +}; + static struct twl4030_usb_data omap3_usb_pdata = { .usb_mode = T2_USB_MODE_ULPI, + .init_data = init_data, }; static int omap3_batt_table[] = { -- 1.7.10.4 -- 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
[RESEND PATCH v10 7/8] usb: phy: omap-usb2: remove *set_suspend* callback from omap-usb2
Now that omap-usb2 is adapted to the new generic PHY framework, *set_suspend* ops can be removed from omap-usb2 driver. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- drivers/phy/phy-omap-usb2.c | 25 - 1 file changed, 25 deletions(-) diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c index 25e0f3c..dec3fab 100644 --- a/drivers/phy/phy-omap-usb2.c +++ b/drivers/phy/phy-omap-usb2.c @@ -97,29 +97,6 @@ static int omap_usb_set_peripheral(struct usb_otg *otg, return 0; } -static int omap_usb2_suspend(struct usb_phy *x, int suspend) -{ - u32 ret; - struct omap_usb *phy = phy_to_omapusb(x); - - if (suspend !phy-is_suspended) { - omap_control_usb_phy_power(phy-control_dev, 0); - pm_runtime_put_sync(phy-dev); - phy-is_suspended = 1; - } else if (!suspend phy-is_suspended) { - ret = pm_runtime_get_sync(phy-dev); - if (ret 0) { - dev_err(phy-dev, get_sync failed with err %d\n, - ret); - return ret; - } - omap_control_usb_phy_power(phy-control_dev, 1); - phy-is_suspended = 0; - } - - return 0; -} - static int omap_usb_power_off(struct phy *x) { struct omap_usb *phy = phy_get_drvdata(x); @@ -167,7 +144,6 @@ static int omap_usb2_probe(struct platform_device *pdev) phy-phy.dev= phy-dev; phy-phy.label = omap-usb2; - phy-phy.set_suspend= omap_usb2_suspend; phy-phy.otg= otg; phy-phy.type = USB_PHY_TYPE_USB2; @@ -182,7 +158,6 @@ static int omap_usb2_probe(struct platform_device *pdev) return -ENODEV; } - phy-is_suspended = 1; omap_control_usb_phy_power(phy-control_dev, 0); otg-set_host = omap_usb_set_host; -- 1.7.10.4 -- 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
[RESEND PATCH v10 8/8] usb: phy: twl4030-usb: remove *set_suspend* and *phy_init* ops
Now that twl4030-usb is adapted to the new generic PHY framework, *set_suspend* and *phy_init* ops can be removed from twl4030-usb driver. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- drivers/phy/phy-twl4030-usb.c | 57 ++--- 1 file changed, 13 insertions(+), 44 deletions(-) diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c index 494f107..c437211 100644 --- a/drivers/phy/phy-twl4030-usb.c +++ b/drivers/phy/phy-twl4030-usb.c @@ -422,25 +422,20 @@ static void twl4030_phy_power(struct twl4030_usb *twl, int on) } } -static void twl4030_phy_suspend(struct twl4030_usb *twl, int controller_off) +static int twl4030_phy_power_off(struct phy *phy) { + struct twl4030_usb *twl = phy_get_drvdata(phy); + if (twl-asleep) - return; + return 0; twl4030_phy_power(twl, 0); twl-asleep = 1; dev_dbg(twl-dev, %s\n, __func__); -} - -static int twl4030_phy_power_off(struct phy *phy) -{ - struct twl4030_usb *twl = phy_get_drvdata(phy); - - twl4030_phy_suspend(twl, 0); return 0; } -static void __twl4030_phy_resume(struct twl4030_usb *twl) +static void __twl4030_phy_power_on(struct twl4030_usb *twl) { twl4030_phy_power(twl, 1); twl4030_i2c_access(twl, 1); @@ -449,11 +444,13 @@ static void __twl4030_phy_resume(struct twl4030_usb *twl) twl4030_i2c_access(twl, 0); } -static void twl4030_phy_resume(struct twl4030_usb *twl) +static int twl4030_phy_power_on(struct phy *phy) { + struct twl4030_usb *twl = phy_get_drvdata(phy); + if (!twl-asleep) - return; - __twl4030_phy_resume(twl); + return 0; + __twl4030_phy_power_on(twl); twl-asleep = 0; dev_dbg(twl-dev, %s\n, __func__); @@ -466,13 +463,6 @@ static void twl4030_phy_resume(struct twl4030_usb *twl) cancel_delayed_work(twl-id_workaround_work); schedule_delayed_work(twl-id_workaround_work, HZ); } -} - -static int twl4030_phy_power_on(struct phy *phy) -{ - struct twl4030_usb *twl = phy_get_drvdata(phy); - - twl4030_phy_resume(twl); return 0; } @@ -604,9 +594,9 @@ static void twl4030_id_workaround_work(struct work_struct *work) } } -static int twl4030_usb_phy_init(struct usb_phy *phy) +static int twl4030_phy_init(struct phy *phy) { - struct twl4030_usb *twl = phy_to_twl(phy); + struct twl4030_usb *twl = phy_get_drvdata(phy); enum omap_musb_vbus_id_status status; /* @@ -621,32 +611,13 @@ static int twl4030_usb_phy_init(struct usb_phy *phy) if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) { omap_musb_mailbox(twl-linkstat); - twl4030_phy_resume(twl); + twl4030_phy_power_on(phy); } sysfs_notify(twl-dev-kobj, NULL, vbus); return 0; } -static int twl4030_phy_init(struct phy *phy) -{ - struct twl4030_usb *twl = phy_get_drvdata(phy); - - return twl4030_usb_phy_init(twl-phy); -} - -static int twl4030_set_suspend(struct usb_phy *x, int suspend) -{ - struct twl4030_usb *twl = phy_to_twl(x); - - if (suspend) - twl4030_phy_suspend(twl, 1); - else - twl4030_phy_resume(twl); - - return 0; -} - static int twl4030_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget) { @@ -719,8 +690,6 @@ static int twl4030_usb_probe(struct platform_device *pdev) twl-phy.label = twl4030; twl-phy.otg= otg; twl-phy.type = USB_PHY_TYPE_USB2; - twl-phy.set_suspend= twl4030_set_suspend; - twl-phy.init = twl4030_usb_phy_init; otg-phy= twl-phy; otg-set_host = twl4030_set_host; -- 1.7.10.4 -- 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
[RESEND PATCH v10 6/8] usb: musb: omap2430: use the new generic PHY framework
Use the generic PHY framework API to get the PHY. The usb_phy_set_resume and usb_phy_set_suspend is replaced with power_on and power_off to align with the new PHY framework. musb-xceiv can't be removed as of now because musb core uses xceiv.state and xceiv.otg. Once there is a separate state machine to handle otg, these can be moved out of xceiv and then we can start using the generic PHY framework. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com Acked-by: Felipe Balbi ba...@ti.com --- drivers/usb/musb/Kconfig |1 + drivers/usb/musb/musb_core.h |2 ++ drivers/usb/musb/omap2430.c | 26 -- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 797e3fd..25e2e57 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -76,6 +76,7 @@ config USB_MUSB_TUSB6010 config USB_MUSB_OMAP2PLUS tristate OMAP2430 and onwards depends on ARCH_OMAP2PLUS + select GENERIC_PHY config USB_MUSB_AM35X tristate AM35x diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 7d341c3..6e567bd 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -46,6 +46,7 @@ #include linux/usb.h #include linux/usb/otg.h #include linux/usb/musb.h +#include linux/phy/phy.h struct musb; struct musb_hw_ep; @@ -346,6 +347,7 @@ struct musb { u16 int_tx; struct usb_phy *xceiv; + struct phy *phy; int nIrq; unsignedirq_wake:1; diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 6708a3b..f7b33f4 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -348,11 +348,21 @@ static int omap2430_musb_init(struct musb *musb) * up through ULPI. TWL4030-family PMICs include one, * which needs a driver, drivers aren't always needed. */ - if (dev-parent-of_node) + if (dev-parent-of_node) { + musb-phy = devm_phy_get(dev-parent, usb2-phy); + + /* We can't totally remove musb-xceiv as of now because +* musb core uses xceiv.state and xceiv.otg. Once we have +* a separate state machine to handle otg, these can be moved +* out of xceiv and then we can start using the generic PHY +* framework +*/ musb-xceiv = devm_usb_get_phy_by_phandle(dev-parent, usb-phy, 0); - else + } else { musb-xceiv = devm_usb_get_phy_dev(dev, 0); + musb-phy = devm_phy_get(dev, usb); + } if (IS_ERR(musb-xceiv)) { status = PTR_ERR(musb-xceiv); @@ -364,6 +374,10 @@ static int omap2430_musb_init(struct musb *musb) return -EPROBE_DEFER; } + if (IS_ERR(musb-phy)) { + pr_err(HS USB OTG: no PHY configured\n); + return PTR_ERR(musb-phy); + } musb-isr = omap2430_musb_interrupt; status = pm_runtime_get_sync(dev); @@ -397,7 +411,7 @@ static int omap2430_musb_init(struct musb *musb) if (glue-status != OMAP_MUSB_UNKNOWN) omap_musb_set_mailbox(glue); - usb_phy_init(musb-xceiv); + phy_init(musb-phy); pm_runtime_put_noidle(musb-controller); return 0; @@ -460,6 +474,7 @@ static int omap2430_musb_exit(struct musb *musb) del_timer_sync(musb_idle_timer); omap2430_low_level_exit(musb); + phy_exit(musb-phy); return 0; } @@ -633,7 +648,7 @@ static int omap2430_runtime_suspend(struct device *dev) OTG_INTERFSEL); omap2430_low_level_exit(musb); - usb_phy_set_suspend(musb-xceiv, 1); + phy_power_off(musb-phy); } return 0; @@ -648,8 +663,7 @@ static int omap2430_runtime_resume(struct device *dev) omap2430_low_level_init(musb); musb_writel(musb-mregs, OTG_INTERFSEL, musb-context.otg_interfsel); - - usb_phy_set_suspend(musb-xceiv, 0); + phy_power_on(musb-phy); } return 0; -- 1.7.10.4 -- 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
[RESEND PATCH v10 5/8] ARM: dts: omap: update usb_otg_hs data
Updated the usb_otg_hs dt data to include the *phy* and *phy-names* binding in order for the driver to use the new generic PHY framework. Also updated the Documentation to include the binding information. The PHY binding information can be found at Documentation/devicetree/bindings/phy/phy-bindings.txt Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- Documentation/devicetree/bindings/usb/omap-usb.txt |5 + Documentation/devicetree/bindings/usb/usb-phy.txt |6 ++ arch/arm/boot/dts/omap3-beagle-xm.dts |2 ++ arch/arm/boot/dts/omap3-evm.dts|2 ++ arch/arm/boot/dts/omap3-overo.dtsi |2 ++ arch/arm/boot/dts/omap4.dtsi |3 +++ arch/arm/boot/dts/twl4030.dtsi |1 + 7 files changed, 21 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt b/Documentation/devicetree/bindings/usb/omap-usb.txt index 57e71f6..825790d 100644 --- a/Documentation/devicetree/bindings/usb/omap-usb.txt +++ b/Documentation/devicetree/bindings/usb/omap-usb.txt @@ -19,6 +19,9 @@ OMAP MUSB GLUE - power : Should be 50. This signifies the controller can supply up to 100mA when operating in host mode. - usb-phy : the phandle for the PHY device + - phys : the phandle for the PHY device (used by generic PHY framework) + - phy-names : the names of the PHY corresponding to the PHYs present in the + *phy* phandle. Optional properties: - ctrl-module : phandle of the control module this glue uses to write to @@ -33,6 +36,8 @@ usb_otg_hs: usb_otg_hs@4a0ab000 { num-eps = 16; ram-bits = 12; ctrl-module = omap_control_usb; + phys = usb2_phy; + phy-names = usb2-phy; }; Board specific device node entry diff --git a/Documentation/devicetree/bindings/usb/usb-phy.txt b/Documentation/devicetree/bindings/usb/usb-phy.txt index 61496f5..c0245c8 100644 --- a/Documentation/devicetree/bindings/usb/usb-phy.txt +++ b/Documentation/devicetree/bindings/usb/usb-phy.txt @@ -5,6 +5,8 @@ OMAP USB2 PHY Required properties: - compatible: Should be ti,omap-usb2 - reg : Address and length of the register set for the device. + - #phy-cells: determine the number of cells that should be given in the + phandle while referencing this phy. Optional properties: - ctrl-module : phandle of the control module used by PHY driver to power on @@ -16,6 +18,7 @@ usb2phy@4a0ad080 { compatible = ti,omap-usb2; reg = 0x4a0ad080 0x58; ctrl-module = omap_control_usb; + #phy-cells = 0; }; OMAP USB3 PHY @@ -25,6 +28,8 @@ Required properties: - reg : Address and length of the register set for the device. - reg-names: The names of the register addresses corresponding to the registers filled in reg. + - #phy-cells: determine the number of cells that should be given in the + phandle while referencing this phy. Optional properties: - ctrl-module : phandle of the control module used by PHY driver to power on @@ -39,4 +44,5 @@ usb3phy@4a084400 { 0x4a084c00 0x40; reg-names = phy_rx, phy_tx, pll_ctrl; ctrl-module = omap_control_usb; + #phy-cells = 0; }; diff --git a/arch/arm/boot/dts/omap3-beagle-xm.dts b/arch/arm/boot/dts/omap3-beagle-xm.dts index afdb164..533b2da 100644 --- a/arch/arm/boot/dts/omap3-beagle-xm.dts +++ b/arch/arm/boot/dts/omap3-beagle-xm.dts @@ -144,6 +144,8 @@ usb_otg_hs { interface-type = 0; usb-phy = usb2_phy; + phys = usb2_phy; + phy-names = usb2-phy; mode = 3; power = 50; }; diff --git a/arch/arm/boot/dts/omap3-evm.dts b/arch/arm/boot/dts/omap3-evm.dts index 7d4329d..4134dd0 100644 --- a/arch/arm/boot/dts/omap3-evm.dts +++ b/arch/arm/boot/dts/omap3-evm.dts @@ -70,6 +70,8 @@ usb_otg_hs { interface-type = 0; usb-phy = usb2_phy; + phys = usb2_phy; + phy-names = usb2-phy; mode = 3; power = 50; }; diff --git a/arch/arm/boot/dts/omap3-overo.dtsi b/arch/arm/boot/dts/omap3-overo.dtsi index 8f1abec..a461d2f 100644 --- a/arch/arm/boot/dts/omap3-overo.dtsi +++ b/arch/arm/boot/dts/omap3-overo.dtsi @@ -76,6 +76,8 @@ usb_otg_hs { interface-type = 0; usb-phy = usb2_phy; + phys = usb2_phy; + phy-names = usb2-phy; mode = 3; power = 50; }; diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi index 22d9f2b..1e8e2fe 100644 --- a/arch/arm/boot/dts/omap4.dtsi +++ b/arch/arm/boot/dts/omap4.dtsi @@ -520,6 +520,7 @@ compatible = ti,omap-usb2; reg = 0x4a0ad080 0x58; ctrl-module = omap_control_usb; + #phy-cells = 0; }; }; @@ -658,6 +659,8 @@ interrupt-names = mc, dma
[RESEND PATCH v10 0/8] PHY framework
use of the new framework Kishon Vijay Abraham I (8): drivers: phy: add generic PHY framework usb: phy: omap-usb2: use the new generic PHY framework usb: phy: twl4030: use the new generic PHY framework arm: omap3: twl: add phy consumer data in twl4030_usb_data ARM: dts: omap: update usb_otg_hs data usb: musb: omap2430: use the new generic PHY framework usb: phy: omap-usb2: remove *set_suspend* callback from omap-usb2 usb: phy: twl4030-usb: remove *set_suspend* and *phy_init* ops .../devicetree/bindings/phy/phy-bindings.txt | 66 ++ Documentation/devicetree/bindings/usb/omap-usb.txt |5 + Documentation/devicetree/bindings/usb/usb-phy.txt |6 + Documentation/phy.txt | 166 + MAINTAINERS|8 + arch/arm/boot/dts/omap3-beagle-xm.dts |2 + arch/arm/boot/dts/omap3-evm.dts|2 + arch/arm/boot/dts/omap3-overo.dtsi |2 + arch/arm/boot/dts/omap4.dtsi |3 + arch/arm/boot/dts/twl4030.dtsi |1 + arch/arm/mach-omap2/twl-common.c | 11 + drivers/Kconfig|2 + drivers/Makefile |2 + drivers/phy/Kconfig| 41 ++ drivers/phy/Makefile |7 + drivers/phy/phy-core.c | 714 drivers/{usb = }/phy/phy-omap-usb2.c | 60 +- drivers/{usb = }/phy/phy-twl4030-usb.c| 69 +- drivers/usb/musb/Kconfig |1 + drivers/usb/musb/musb_core.h |2 + drivers/usb/musb/omap2430.c| 26 +- drivers/usb/phy/Kconfig| 19 - drivers/usb/phy/Makefile |2 - include/linux/i2c/twl.h|2 + include/linux/phy/phy.h| 270 25 files changed, 1413 insertions(+), 76 deletions(-) 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 rename drivers/{usb = }/phy/phy-omap-usb2.c (88%) rename drivers/{usb = }/phy/phy-twl4030-usb.c (94%) create mode 100644 include/linux/phy/phy.h -- 1.7.10.4 -- 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
[RESEND PATCH v10 1/8] drivers: phy: add generic PHY framework
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 t.f...@samsung.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Tested-by: Sylwester Nawrocki s.nawro...@samsung.com --- .../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 diff --git a/Documentation/devicetree/bindings/phy/phy-bindings.txt b/Documentation/devicetree/bindings/phy/phy-bindings.txt new file mode 100644 index 000..8ae844f --- /dev/null +++ b/Documentation/devicetree/bindings/phy/phy-bindings.txt @@ -0,0 +1,66 @@ +This document explains only the device tree data binding. For general +information about PHY subsystem refer to Documentation/phy.txt + +PHY device node +=== + +Required Properties: +#phy-cells:Number of cells in a PHY specifier; The meaning of all those + cells is defined by the binding for the phy node. The PHY + provider can use the values in cells to find the appropriate + PHY. + +For example: + +phys: phy { +compatible = xxx; +reg = ...; +. +. +#phy-cells = 1; +. +. +}; + +That node describes an IP block (PHY provider) that implements 2 different PHYs. +In order to differentiate between these 2 PHYs, an additonal specifier should be +given while trying to get a reference to it. + +PHY user node += + +Required Properties: +phys : the phandle for the PHY device (used by the PHY subsystem) +phy-names : the names of the PHY corresponding to the PHYs present in the + *phys* phandle + +Example 1: +usb1: usb_otg_ss@xxx { +compatible = xxx; +reg = xxx; +. +. +phys = usb2_phy, usb3_phy; +phy-names = usb2phy, usb3phy; +. +. +}; + +This node represents a controller that uses two PHYs, one for usb2 and one for +usb3. + +Example 2: +usb2: usb_otg_ss@xxx { +compatible = xxx; +reg = xxx; +. +. +phys = phys 1; +phy-names = usbphy; +. +. +}; + +This node represents a controller that uses one of the PHYs of the PHY provider +device defined previously. Note that the phy handle has an additional specifier +1 to differentiate between the two PHYs. diff --git a/Documentation/phy.txt b/Documentation/phy.txt new file mode 100644 index 000..4e056c4 --- /dev/null +++ b/Documentation/phy.txt @@ -0,0 +1,166 @@ + PHY SUBSYSTEM + Kishon Vijay Abraham I kis...@ti.com + +This document explains the Generic PHY Framework along with the APIs provided, +and how-to-use. + +1. Introduction + +*PHY* is the abbreviation for physical layer. It is used to connect a device +to the physical medium e.g., the USB controller has a PHY to provide functions +such as serialization, de-serialization, encoding, decoding and is responsible +for obtaining the required data transmission rate. Note that some USB +controllers have PHY functionality embedded into it and others use an external +PHY. Other peripherals that use PHY include Wireless LAN, Ethernet, +SATA etc. + +The intention of creating this framework is to bring the PHY drivers spread +all over the Linux kernel to drivers/phy to increase code re-use and for +better code maintainability. + +This framework will be of use only to devices that use external PHY (PHY +functionality is not embedded within the controller). + +2. Registering/Unregistering the PHY provider + +PHY provider refers to an entity that implements one or more PHY instances. +For the simple case where the PHY provider implements only a single instance
Re: [PATCH 01/15] drivers: phy: add generic PHY framework
Hi, On Tuesday 23 July 2013 08:07 PM, Alan Stern wrote: On Tue, 23 Jul 2013, Tomasz Figa wrote: On Tuesday 23 of July 2013 09:29:32 Tomasz Figa wrote: Hi Alan, Thanks for helping to clarify the issues here. Okay. Are PHYs _always_ platform devices? They can be i2c, spi or any other device types as well. In those other cases, presumably there is no platform data associated with the PHY since it isn't a platform device. Then how does the kernel know which controller is attached to the PHY? Is this spelled out in platform data associated with the PHY's i2c/spi/whatever parent? Yes. I think we could use i2c_board_info for passing platform data. PHY. Currently this information is represented by name or ID strings embedded in platform data. right. It's embedded in the platform data of the controller. It must also be embedded in the PHY's platform data somehow. Otherwise, how would the kernel know which PHY to use? By using a PHY lookup as Stephen and I suggested in our previous replies. Without any extra data in platform data. (I have even posted a code example.) I don't understand, because I don't know what a PHY lookup does. It is how the PHY framework finds a PHY, when the controller (say USB)requests a PHY from the PHY framework. In this case, it doesn't matter where the platform_device structures are created or where the driver source code is. Let's take a simple example. Suppose the system design includes a PHY named foo. Then the board file could contain: struct phy_info { ... } phy_foo; EXPORT_SYMBOL_GPL(phy_foo); and a header file would contain: extern struct phy_info phy_foo; The PHY supplier could then call phy_create(phy_foo), and the PHY client could call phy_find(phy_foo). Or something like that; make up your own structure tags and function names. It's still possible to have conflicts, but now two PHYs with the same name (or a misspelled name somewhere) will cause an error at link time. This is incorrect, sorry. First of all it's a layering violation - you export random driver-specific symbols from one driver to another. Then No, that's not what I said. Neither the PHY driver nor the controller driver exports anything to the other. Instead, both drivers use data exported by the board file. I think instead we can use the same data while creating the platform data of the controller and the PHY. The PHY driver while creating the PHY (using PHY framework) will also pass the *data* it actually got from the platform data to the framework. The PHY user driver (USB), while requesting for the PHY (from the PHY framework) will pass the *data* it got from its platform data. The PHY framework can do a comparison of the *data* pointers it has and return the appropriate PHY to the controller. imagine 4 SoCs - A, B, C, D. There are two PHY types PHY1 and PHY2 and there are two types of consumer drivers (e.g. USB host controllers). Now consider following mapping: SoC PHY consumer A PHY1HOST1 B PHY1HOST2 C PHY2HOST1 D PHY2HOST2 So we have to be able to use any of the PHYs with any of the host drivers. This means you would have to export symbol with the same name from both PHY drivers, which obviously would not work in this case, because having both drivers enabled (in a multiplatform aware configuration) would lead to linking conflict. You're right; the scheme was too simple. Instead, the board file must export two types of data structures, one for PHYs and one for controllers. Like this: struct phy_info { /* Info for the controller attached to this PHY */ struct controller_info *hinfo; }; struct controller_info { /* Info for the PHY which this controller is attached to */ struct phy_info *pinfo; }; The board file for SoC A would contain: struct phy_info phy1 = {host1); EXPORT_SYMBOL(phy1); struct controller_info host1 = {phy1}; EXPORT_SYMBOL(host1); The board file for SoC B would contain: struct phy_info phy1 = {host2); EXPORT_SYMBOL(phy1); struct controller_info host2 = {phy1}; EXPORT_SYMBOL(host2); I meant something like this struct phy_info { const char *name; }; struct phy_platform_data { . . struct phy_info *info; }; struct usb_controller_platform_data { . . struct phy_info *info; }; struct phy_info phy_info; While creating the phy device struct phy_platform_data phy_data; phy_data.info = info; platform_device_add_data(pdev, phy_data, sizeof(*phy_data)) platform_device_add(); While creating the controller device struct usb_controller_platform_data controller_data; controller_data.info = info; platform_device_add_data(pdev, controller_data, sizeof(*controller_data)) platform_device_add(); Then modify PHY framework API phy create phy_create((struct device *dev, const struct phy_ops
Re: [PATCH 01/15] drivers: phy: add generic PHY framework
Hi Greg, On Tuesday 23 July 2013 09:48 PM, Greg KH wrote: On Tue, Jul 23, 2013 at 08:48:24PM +0530, Kishon Vijay Abraham I wrote: Hi, On Tuesday 23 July 2013 08:07 PM, Alan Stern wrote: On Tue, 23 Jul 2013, Tomasz Figa wrote: On Tuesday 23 of July 2013 09:29:32 Tomasz Figa wrote: Hi Alan, Thanks for helping to clarify the issues here. Okay. Are PHYs _always_ platform devices? They can be i2c, spi or any other device types as well. In those other cases, presumably there is no platform data associated with the PHY since it isn't a platform device. Then how does the kernel know which controller is attached to the PHY? Is this spelled out in platform data associated with the PHY's i2c/spi/whatever parent? . . snip . . static struct phy *phy_lookup(void *priv) { . . if (phy-priv==priv) //instead of string comparison, we'll use pointer return phy; } PHY driver should be like phy_create((dev, ops, pdata-info); The controller driver would do phy_get(dev, NULL, pdata-info); Now the PHY framework will check for a match of *priv* pointer and return the PHY. I think this should be possible? Ick, no. Why can't you just pass the pointer to the phy itself? If you had a priv pointer to search from, then you could have just passed the original phy pointer in the first place, right? The issue is that a string name is not going to scale at all, as it requires hard-coded information that will change over time (as the existing clock interface is already showing.) Please just pass the real phy pointer around, that's what it is there for. Your board binding logic/code should be able to handle this, as it somehow was going to do the same thing with a name. The problem is the board file won't have the *phy* pointer. *phy* pointer is created at a much later time when the phy driver is probed. Thanks Kishon -- 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
Re: [PATCH 01/15] drivers: phy: add generic PHY framework
Hi, On Monday 22 July 2013 12:52 AM, Alan Stern wrote: On Sun, 21 Jul 2013, Sylwester Nawrocki wrote: What's wrong with the platform_data structure, why can't that be used for this? At the point the platform data of some driver is initialized, e.g. in board setup code the PHY pointer is not known, since the PHY supplier driver has not initialized yet. Even though we wanted to pass pointer to a PHY through some notifier call, it would have been not clear which PHY user driver should match on such notifier. A single PHY supplier driver can create M PHY objects and this needs to be mapped to N PHY user drivers. This mapping needs to be defined somewhere by the system integrator. It works well with device tree, but except that there seems to be no other reliable infrastructure in the kernel to define links/dependencies between devices, since device identifiers are not known in advance in all cases. What Tomasz proposed seems currently most reasonable to me for non-dt. Or, if not, we can always add pointers to the platform device structure, or even the main 'struct device' as well, that's what it is there for. Still we would need to solve a problem which platform device structure gets which PHY pointer. Can you explain the issues in more detail? I don't fully understand the situation. Here's what I think I know: The PHY and the controller it is attached to are both physical devices. The connection between them is hardwired by the system manufacturer and cannot be changed by software. PHYs are generally described by fixed system-specific board files or by Device Tree information. Are they ever discovered dynamically? No. They are created just like any other platform devices are created. Is the same true for the controllers attached to the PHYs? If not -- if both a PHY and a controller are discovered dynamically -- how does the kernel know whether they are connected to each other? No differences here. Both PHY and controller will have dt information or hwmod data using which platform devices will be created. The kernel needs to know which controller is attached to which PHY. Currently this information is represented by name or ID strings embedded in platform data. right. It's embedded in the platform data of the controller. The PHY's driver (the supplier) uses the platform data to construct a platform_device structure that represents the PHY. Currently the driver assigns static labels (corresponding to the label used in the platform data of the controller). Until this is done, the controller's driver (the client) cannot use the PHY. right. Since there is no parent-child relation between the PHY and the controller, there is no guarantee that the PHY's driver will be ready when the controller's driver wants to use it. A deferred probe may be needed. right. The issue (or one of the issues) in this discussion is that Greg does not like the idea of using names or IDs to associate PHYs with controllers, because they are too prone to duplications or other errors. Pointers are more reliable. But pointers to what? Since the only data known to be available to both the PHY driver and controller driver is the platform data, the obvious answer is a pointer to platform data (either for the PHY or for the controller, or maybe both). hmm.. it's not going to be simple though as the platform device for the PHY and controller can be created in entirely different places. e.g., in some cases the PHY device is a child of some mfd core device (the device will be created in drivers/mfd) and the controller driver (usually) is created in board file. I guess then we have to come up with something to share a pointer in two different files. Probably some of the details above are wrong; please indicate where I have gone astray. Also, I'm not clear about the role played by various APIs. For example, where does phy_create() fit into this picture? phy_create is the API by which the PHY's driver (the supplier) hook into the PHY framework. It's like the controller driver will always interact with the PHY driver through the PHY framework. Thanks Kishon -- 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
Re: [PATCH 01/15] drivers: phy: add generic PHY framework
Hi, On Monday 22 July 2013 08:34 PM, Greg KH wrote: On Mon, Jul 22, 2013 at 12:55:18PM +0530, Kishon Vijay Abraham I wrote: The issue (or one of the issues) in this discussion is that Greg does not like the idea of using names or IDs to associate PHYs with controllers, because they are too prone to duplications or other errors. Pointers are more reliable. But pointers to what? Since the only data known to be available to both the PHY driver and controller driver is the platform data, the obvious answer is a pointer to platform data (either for the PHY or for the controller, or maybe both). hmm.. it's not going to be simple though as the platform device for the PHY and controller can be created in entirely different places. e.g., in some cases the PHY device is a child of some mfd core device (the device will be created in drivers/mfd) and the controller driver (usually) is created in board file. I guess then we have to come up with something to share a pointer in two different files. What's wrong with using the platform_data structure that is unique to all boards (see include/platform_data/ for examples)? Isn't that what this structure is there for? Alright. I got some ideas from Alan Stern. I'll use it with platform_data and repost the series. Thanks Kishon -- 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
Re: [PATCH 01/15] drivers: phy: add generic PHY framework
Hi, On Monday 22 July 2013 08:14 PM, Alan Stern wrote: On Mon, 22 Jul 2013, Kishon Vijay Abraham I wrote: The PHY and the controller it is attached to are both physical devices. The connection between them is hardwired by the system manufacturer and cannot be changed by software. PHYs are generally described by fixed system-specific board files or by Device Tree information. Are they ever discovered dynamically? No. They are created just like any other platform devices are created. Okay. Are PHYs _always_ platform devices? Not always. It can be any other device also. Is the same true for the controllers attached to the PHYs? If not -- if both a PHY and a controller are discovered dynamically -- how does the kernel know whether they are connected to each other? No differences here. Both PHY and controller will have dt information or hwmod data using which platform devices will be created. The kernel needs to know which controller is attached to which PHY. Currently this information is represented by name or ID strings embedded in platform data. right. It's embedded in the platform data of the controller. It must also be embedded in the PHY's platform data somehow. Otherwise, how would the kernel know which PHY to use? The PHY's driver (the supplier) uses the platform data to construct a platform_device structure that represents the PHY. Currently the driver assigns static labels (corresponding to the label used in the platform data of the controller). Until this is done, the controller's driver (the client) cannot use the PHY. right. Since there is no parent-child relation between the PHY and the controller, there is no guarantee that the PHY's driver will be ready when the controller's driver wants to use it. A deferred probe may be needed. right. The issue (or one of the issues) in this discussion is that Greg does not like the idea of using names or IDs to associate PHYs with controllers, because they are too prone to duplications or other errors. Pointers are more reliable. But pointers to what? Since the only data known to be available to both the PHY driver and controller driver is the platform data, the obvious answer is a pointer to platform data (either for the PHY or for the controller, or maybe both). hmm.. it's not going to be simple though as the platform device for the PHY and controller can be created in entirely different places. e.g., in some cases the PHY device is a child of some mfd core device (the device will be created in drivers/mfd) and the controller driver (usually) is created in board file. I guess then we have to come up with something to share a pointer in two different files. The ability for two different source files to share a pointer to a data item defined in a third source file has been around since long before the C language was invented. :-) In this case, it doesn't matter where the platform_device structures are created or where the driver source code is. Let's take a simple example. Suppose the system design includes a PHY named foo. Then the board file could contain: struct phy_info { ... } phy_foo; EXPORT_SYMBOL_GPL(phy_foo); and a header file would contain: extern struct phy_info phy_foo; The PHY supplier could then call phy_create(phy_foo), and the PHY client could call phy_find(phy_foo). Or something like that; make up your own structure tags and function names. Alright. Thanks for the hint :-) Thanks Kishon -- 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
Re: [PATCH 01/15] drivers: phy: add generic PHY framework
Hi, On Sunday 21 July 2013 04:01 PM, Tomasz Figa wrote: Hi, On Saturday 20 of July 2013 19:59:10 Greg KH wrote: On Sat, Jul 20, 2013 at 10:32:26PM -0400, Alan Stern wrote: On Sat, 20 Jul 2013, Greg KH wrote: That should be passed using platform data. Ick, don't pass strings around, pass pointers. If you have platform data you can get to, then put the pointer there, don't use a name. I don't think I understood you here :-s We wont have phy pointer when we create the device for the controller no?(it'll be done in board file). Probably I'm missing something. Why will you not have that pointer? You can't rely on the name as the device id will not match up, so you should be able to rely on the pointer being in the structure that the board sets up, right? Don't use names, especially as ids can, and will, change, that is going to cause big problems. Use pointers, this is C, we are supposed to be doing that :) Kishon, I think what Greg means is this: The name you are using must be stored somewhere in a data structure constructed by the board file, right? Or at least, associated with some data structure somehow. Otherwise the platform code wouldn't know which PHY hardware corresponded to a particular name. Greg's suggestion is that you store the address of that data structure in the platform data instead of storing the name string. Have the consumer pass the data structure's address when it calls phy_create, instead of passing the name. Then you don't have to worry about two PHYs accidentally ending up with the same name or any other similar problems. Close, but the issue is that whatever returns from phy_create() should then be used, no need to call any find functions, as you can just use the pointer that phy_create() returns. Much like all other class api functions in the kernel work. I think there is a confusion here about who registers the PHYs. All platform code does is registering a platform/i2c/whatever device, which causes a driver (located in drivers/phy/) to be instantiated. Such drivers call phy_create(), usually in their probe() callbacks, so platform_code has no way (and should have no way, for the sake of layering) to get what phy_create() returns. right. IMHO we need a lookup method for PHYs, just like for clocks, regulators, PWMs or even i2c busses because there are complex cases when passing just a name using platform data will not work. I would second what Stephen said [1] and define a structure doing things in a DT-like way. Example; [platform code] static const struct phy_lookup my_phy_lookup[] = { PHY_LOOKUP(s3c-hsotg.0, otg, samsung-usbphy.1, phy.2), The only problem here is that if *PLATFORM_DEVID_AUTO* is used while creating the device, the ids in the device name would change and PHY_LOOKUP wont be useful. Thanks Kishon -- 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
Re: [PATCH 01/15] drivers: phy: add generic PHY framework
Hi, On Friday 19 July 2013 11:59 AM, Greg KH wrote: On Fri, Jul 19, 2013 at 11:25:44AM +0530, Kishon Vijay Abraham I wrote: Hi, On Friday 19 July 2013 11:13 AM, Greg KH wrote: On Fri, Jul 19, 2013 at 11:07:10AM +0530, Kishon Vijay Abraham I wrote: + ret = dev_set_name(phy-dev, %s.%d, dev_name(dev), id); Your naming is odd, no phy anywhere in it? You rely on the sender to never send a duplicate name.id pair? Why not create your own ids based on the number of phys in the system, like almost all other classes and subsystems do? hmm.. some PHY drivers use the id they provide to perform some of their internal operation as in [1] (This is used only if a single PHY provider implements multiple PHYS). Probably I'll add an option like PLATFORM_DEVID_AUTO to give the PHY drivers an option to use auto id. [1] - http://archive.arm.linux.org.uk/lurker/message/20130628.134308.4a8f7668.ca.html No, who cares about the id? No one outside of the phy core ever should, because you pass back the only pointer that they really do care about, if they need to do anything with the device. Use that, and then you can hmm.. ok. rip out all of the search for a phy by a string logic, as that's not Actually this is needed for non-dt boot case. In the case of dt boot, we use a phandle by which the controller can get a reference to the phy. But in the case of non-dt boot, the controller can get a reference to the phy only by label. I don't understand. They registered the phy, and got back a pointer to it. Why can't they save it in their local structure to use it again later if needed? They should never have to ask for the device, as the One is a *PHY provider* driver which is a driver for some PHY device. This will use phy_create to create the phy. The other is a *PHY consumer* driver which might be any controller driver (can be USB/SATA/PCIE). The PHY consumer will use phy_get to get a reference to the phy (by *phandle* in the case of dt boot and *label* in the case of non-dt boot). device id might be unknown if there are multiple devices in the system. I agree with you on the device id part. That need not be known to the PHY driver. How does a consumer know which label to use in a non-dt system if there are multiple PHYs in the system? That should be passed using platform data. Do you have any drivers that are non-dt using this yet? yes. tw4030 (used in OMAP3) supports non-dt. [PATCH 04/15] ARM: OMAP: USB: Add phy binding information [PATCH 06/15] usb: musb: omap2430: use the new generic PHY framework of this patch series shows how it's used. Thanks Kishon -- 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
Re: [PATCH 01/15] drivers: phy: add generic PHY framework
Hi, On Friday 19 July 2013 09:24 PM, Stephen Warren wrote: On 07/19/2013 12:36 AM, Kishon Vijay Abraham I wrote: Hi, On Friday 19 July 2013 11:59 AM, Greg KH wrote: On Fri, Jul 19, 2013 at 11:25:44AM +0530, Kishon Vijay Abraham I wrote: Hi, On Friday 19 July 2013 11:13 AM, Greg KH wrote: On Fri, Jul 19, 2013 at 11:07:10AM +0530, Kishon Vijay Abraham I wrote: + ret = dev_set_name(phy-dev, %s.%d, dev_name(dev), id); Your naming is odd, no phy anywhere in it? You rely on the sender to never send a duplicate name.id pair? Why not create your own ids based on the number of phys in the system, like almost all other classes and subsystems do? hmm.. some PHY drivers use the id they provide to perform some of their internal operation as in [1] (This is used only if a single PHY provider implements multiple PHYS). Probably I'll add an option like PLATFORM_DEVID_AUTO to give the PHY drivers an option to use auto id. [1] - http://archive.arm.linux.org.uk/lurker/message/20130628.134308.4a8f7668.ca.html No, who cares about the id? No one outside of the phy core ever should, because you pass back the only pointer that they really do care about, if they need to do anything with the device. Use that, and then you can hmm.. ok. rip out all of the search for a phy by a string logic, as that's not Actually this is needed for non-dt boot case. In the case of dt boot, we use a phandle by which the controller can get a reference to the phy. But in the case of non-dt boot, the controller can get a reference to the phy only by label. I don't understand. They registered the phy, and got back a pointer to it. Why can't they save it in their local structure to use it again later if needed? They should never have to ask for the device, as the One is a *PHY provider* driver which is a driver for some PHY device. This will use phy_create to create the phy. The other is a *PHY consumer* driver which might be any controller driver (can be USB/SATA/PCIE). The PHY consumer will use phy_get to get a reference to the phy (by *phandle* in the case of dt boot and *label* in the case of non-dt boot). device id might be unknown if there are multiple devices in the system. I agree with you on the device id part. That need not be known to the PHY driver. How does a consumer know which label to use in a non-dt system if there are multiple PHYs in the system? That should be passed using platform data. I don't think that's right. That's just like passing clock names in platform data, which I believe is frowned upon. Instead, why not take the approach that e.g. regulators have taken? Each driver defines the names of the objects that it requires. There is a table (registered by a board file) that has lookup key (device name, We were using a similar approach with USB PHY layer but things started breaking after the device names are created using PLATFORM_DEVID_AUTO. Now theres no way to reliably know the device names in advance. Btw I had such device name binding in my v3 of this patch series [1] and had some discussion with Grant during that time [2]. [1] - http://archive.arm.linux.org.uk/lurker/message/20130320.091200.721a6fb5.hu.html [2] - https://lkml.org/lkml/2013/4/22/26 Thanks Kishon -- 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
Re: [PATCH 01/15] drivers: phy: add generic PHY framework
Hi, On Saturday 20 July 2013 05:20 AM, Greg KH wrote: On Fri, Jul 19, 2013 at 12:06:01PM +0530, Kishon Vijay Abraham I wrote: Hi, On Friday 19 July 2013 11:59 AM, Greg KH wrote: On Fri, Jul 19, 2013 at 11:25:44AM +0530, Kishon Vijay Abraham I wrote: Hi, On Friday 19 July 2013 11:13 AM, Greg KH wrote: On Fri, Jul 19, 2013 at 11:07:10AM +0530, Kishon Vijay Abraham I wrote: + ret = dev_set_name(phy-dev, %s.%d, dev_name(dev), id); Your naming is odd, no phy anywhere in it? You rely on the sender to never send a duplicate name.id pair? Why not create your own ids based on the number of phys in the system, like almost all other classes and subsystems do? hmm.. some PHY drivers use the id they provide to perform some of their internal operation as in [1] (This is used only if a single PHY provider implements multiple PHYS). Probably I'll add an option like PLATFORM_DEVID_AUTO to give the PHY drivers an option to use auto id. [1] - http://archive.arm.linux.org.uk/lurker/message/20130628.134308.4a8f7668.ca.html No, who cares about the id? No one outside of the phy core ever should, because you pass back the only pointer that they really do care about, if they need to do anything with the device. Use that, and then you can hmm.. ok. rip out all of the search for a phy by a string logic, as that's not Actually this is needed for non-dt boot case. In the case of dt boot, we use a phandle by which the controller can get a reference to the phy. But in the case of non-dt boot, the controller can get a reference to the phy only by label. I don't understand. They registered the phy, and got back a pointer to it. Why can't they save it in their local structure to use it again later if needed? They should never have to ask for the device, as the One is a *PHY provider* driver which is a driver for some PHY device. This will use phy_create to create the phy. The other is a *PHY consumer* driver which might be any controller driver (can be USB/SATA/PCIE). The PHY consumer will use phy_get to get a reference to the phy (by *phandle* in the case of dt boot and *label* in the case of non-dt boot). device id might be unknown if there are multiple devices in the system. I agree with you on the device id part. That need not be known to the PHY driver. How does a consumer know which label to use in a non-dt system if there are multiple PHYs in the system? That should be passed using platform data. Ick, don't pass strings around, pass pointers. If you have platform data you can get to, then put the pointer there, don't use a name. I don't think I understood you here :-s We wont have phy pointer when we create the device for the controller no?(it'll be done in board file). Probably I'm missing something. Thanks Kishon -- 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
[PATCH 15/15] video: exynos_dp: Use the generic PHY driver
From: Jingoo Han jg1@samsung.com Use the generic PHY API to control the DP PHY. Signed-off-by: Jingoo Han jg1@samsung.com Reviewed-by: Tomasz Figa t.f...@samsung.com Signed-off-by: Kishon Vijay Abraham I kis...@ti.com --- .../devicetree/bindings/video/exynos_dp.txt | 18 +- drivers/video/exynos/exynos_dp_core.c| 16 drivers/video/exynos/exynos_dp_core.h|1 + 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Documentation/devicetree/bindings/video/exynos_dp.txt b/Documentation/devicetree/bindings/video/exynos_dp.txt index 84f10c1..2f56376 100644 --- a/Documentation/devicetree/bindings/video/exynos_dp.txt +++ b/Documentation/devicetree/bindings/video/exynos_dp.txt @@ -6,10 +6,10 @@ We use two nodes: -dptx-phy node(defined inside dp-controller node) For the DP-PHY initialization, we use the dptx-phy node. -Required properties for dptx-phy: - -reg: +Required properties for dptx-phy: deprecated, use phys and phy-names + -reg: deprecated Base address of DP PHY register. - -samsung,enable-mask: + -samsung,enable-mask: deprecated The bit-mask used to enable/disable DP PHY. For the Panel initialization, we read data from dp-controller node. @@ -25,6 +25,10 @@ Required properties for dp-controller: from common clock binding: handle to dp clock. -clock-names: from common clock binding: Shall be dp. + -phys: + from general PHY binding: the phandle for the PHY device. + -phy-names: + from general PHY binding: Should be dp. -interrupt-parent: phandle to Interrupt combiner node. -samsung,color-space: @@ -67,12 +71,8 @@ SOC specific portion: interrupt-parent = combiner; clocks = clock 342; clock-names = dp; - - dptx-phy { - reg = 0x10040720; - samsung,enable-mask = 1; - }; - + phys = dp_phy; + phy-names = dp; }; Board Specific portion: diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c index 05fed7d..5e1a715 100644 --- a/drivers/video/exynos/exynos_dp_core.c +++ b/drivers/video/exynos/exynos_dp_core.c @@ -19,6 +19,7 @@ #include linux/interrupt.h #include linux/delay.h #include linux/of.h +#include linux/phy/phy.h #include exynos_dp_core.h @@ -960,8 +961,11 @@ static int exynos_dp_dt_parse_phydata(struct exynos_dp_device *dp) dp_phy_node = of_find_node_by_name(dp_phy_node, dptx-phy); if (!dp_phy_node) { - dev_err(dp-dev, could not find dptx-phy node\n); - return -ENODEV; + dp-phy = devm_phy_get(dp-dev, dp); + if (IS_ERR(dp-phy)) + return PTR_ERR(dp-phy); + else + return 0; } if (of_property_read_u32(dp_phy_node, reg, phy_base)) { @@ -992,7 +996,9 @@ err: static void exynos_dp_phy_init(struct exynos_dp_device *dp) { - if (dp-phy_addr) { + if (dp-phy) { + phy_power_on(dp-phy); + } else if (dp-phy_addr) { u32 reg; reg = __raw_readl(dp-phy_addr); @@ -1003,7 +1009,9 @@ static void exynos_dp_phy_init(struct exynos_dp_device *dp) static void exynos_dp_phy_exit(struct exynos_dp_device *dp) { - if (dp-phy_addr) { + if (dp-phy) { + phy_power_off(dp-phy); + } else if (dp-phy_addr) { u32 reg; reg = __raw_readl(dp-phy_addr); diff --git a/drivers/video/exynos/exynos_dp_core.h b/drivers/video/exynos/exynos_dp_core.h index 56cfec8..607e36d 100644 --- a/drivers/video/exynos/exynos_dp_core.h +++ b/drivers/video/exynos/exynos_dp_core.h @@ -151,6 +151,7 @@ struct exynos_dp_device { struct video_info *video_info; struct link_train link_train; struct work_struct hotplug_work; + struct phy *phy; }; /* exynos_dp_reg.c */ -- 1.7.10.4 -- 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
[PATCH 14/15] video: exynos_dp: remove non-DT support for Exynos Display Port
From: Jingoo Han jg1@samsung.com Exynos Display Port can be used only for Exynos SoCs. In addition, non-DT for EXYNOS SoCs is not supported from v3.11; thus, there is no need to support non-DT for Exynos Display Port. The 'include/video/exynos_dp.h' file has been used for non-DT support and the content of file include/video/exynos_dp.h is moved to drivers/video/exynos/exynos_dp_core.h. Thus, the 'exynos_dp.h' file is removed. Also, 'struct exynos_dp_platdata' is removed, because it is not used any more. Signed-off-by: Jingoo Han jg1@samsung.com Reviewed-by: Tomasz Figa t.f...@samsung.com Signed-off-by: Kishon Vijay Abraham I kis...@ti.com --- drivers/video/exynos/Kconfig |2 +- drivers/video/exynos/exynos_dp_core.c | 116 +++-- drivers/video/exynos/exynos_dp_core.h | 109 +++ drivers/video/exynos/exynos_dp_reg.c |2 - include/video/exynos_dp.h | 131 - 5 files changed, 135 insertions(+), 225 deletions(-) delete mode 100644 include/video/exynos_dp.h diff --git a/drivers/video/exynos/Kconfig b/drivers/video/exynos/Kconfig index 1b035b2..fab9019 100644 --- a/drivers/video/exynos/Kconfig +++ b/drivers/video/exynos/Kconfig @@ -29,7 +29,7 @@ config EXYNOS_LCD_S6E8AX0 config EXYNOS_DP bool EXYNOS DP driver support - depends on ARCH_EXYNOS + depends on OF ARCH_EXYNOS default n help This enables support for DP device. diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c index 12bbede..05fed7d 100644 --- a/drivers/video/exynos/exynos_dp_core.c +++ b/drivers/video/exynos/exynos_dp_core.c @@ -20,8 +20,6 @@ #include linux/delay.h #include linux/of.h -#include video/exynos_dp.h - #include exynos_dp_core.h static int exynos_dp_init_dp(struct exynos_dp_device *dp) @@ -894,26 +892,17 @@ static void exynos_dp_hotplug(struct work_struct *work) dev_err(dp-dev, unable to config video\n); } -#ifdef CONFIG_OF -static struct exynos_dp_platdata *exynos_dp_dt_parse_pdata(struct device *dev) +static struct video_info *exynos_dp_dt_parse_pdata(struct device *dev) { struct device_node *dp_node = dev-of_node; - struct exynos_dp_platdata *pd; struct video_info *dp_video_config; - pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); - if (!pd) { - dev_err(dev, memory allocation for pdata failed\n); - return ERR_PTR(-ENOMEM); - } dp_video_config = devm_kzalloc(dev, sizeof(*dp_video_config), GFP_KERNEL); - if (!dp_video_config) { dev_err(dev, memory allocation for video config failed\n); return ERR_PTR(-ENOMEM); } - pd-video_info = dp_video_config; dp_video_config-h_sync_polarity = of_property_read_bool(dp_node, hsync-active-high); @@ -960,7 +949,7 @@ static struct exynos_dp_platdata *exynos_dp_dt_parse_pdata(struct device *dev) return ERR_PTR(-EINVAL); } - return pd; + return dp_video_config; } static int exynos_dp_dt_parse_phydata(struct exynos_dp_device *dp) @@ -1003,48 +992,30 @@ err: static void exynos_dp_phy_init(struct exynos_dp_device *dp) { - u32 reg; + if (dp-phy_addr) { + u32 reg; - reg = __raw_readl(dp-phy_addr); - reg |= dp-enable_mask; - __raw_writel(reg, dp-phy_addr); + reg = __raw_readl(dp-phy_addr); + reg |= dp-enable_mask; + __raw_writel(reg, dp-phy_addr); + } } static void exynos_dp_phy_exit(struct exynos_dp_device *dp) { - u32 reg; - - reg = __raw_readl(dp-phy_addr); - reg = ~(dp-enable_mask); - __raw_writel(reg, dp-phy_addr); -} -#else -static struct exynos_dp_platdata *exynos_dp_dt_parse_pdata(struct device *dev) -{ - return NULL; -} - -static int exynos_dp_dt_parse_phydata(struct exynos_dp_device *dp) -{ - return -EINVAL; -} - -static void exynos_dp_phy_init(struct exynos_dp_device *dp) -{ - return; -} + if (dp-phy_addr) { + u32 reg; -static void exynos_dp_phy_exit(struct exynos_dp_device *dp) -{ - return; + reg = __raw_readl(dp-phy_addr); + reg = ~(dp-enable_mask); + __raw_writel(reg, dp-phy_addr); + } } -#endif /* CONFIG_OF */ static int exynos_dp_probe(struct platform_device *pdev) { struct resource *res; struct exynos_dp_device *dp; - struct exynos_dp_platdata *pdata; int ret = 0; @@ -1057,21 +1028,13 @@ static int exynos_dp_probe(struct platform_device *pdev) dp-dev = pdev-dev; - if (pdev-dev.of_node) { - pdata = exynos_dp_dt_parse_pdata(pdev-dev); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); + dp-video_info
[PATCH 05/15] ARM: dts: omap: update usb_otg_hs data
Updated the usb_otg_hs dt data to include the *phy* and *phy-names* binding in order for the driver to use the new generic PHY framework. Also updated the Documentation to include the binding information. The PHY binding information can be found at Documentation/devicetree/bindings/phy/phy-bindings.txt Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- Documentation/devicetree/bindings/usb/omap-usb.txt |5 + Documentation/devicetree/bindings/usb/usb-phy.txt |6 ++ arch/arm/boot/dts/omap3-beagle-xm.dts |2 ++ arch/arm/boot/dts/omap3-evm.dts|2 ++ arch/arm/boot/dts/omap3-overo.dtsi |2 ++ arch/arm/boot/dts/omap4.dtsi |3 +++ arch/arm/boot/dts/twl4030.dtsi |1 + 7 files changed, 21 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt b/Documentation/devicetree/bindings/usb/omap-usb.txt index 57e71f6..825790d 100644 --- a/Documentation/devicetree/bindings/usb/omap-usb.txt +++ b/Documentation/devicetree/bindings/usb/omap-usb.txt @@ -19,6 +19,9 @@ OMAP MUSB GLUE - power : Should be 50. This signifies the controller can supply up to 100mA when operating in host mode. - usb-phy : the phandle for the PHY device + - phys : the phandle for the PHY device (used by generic PHY framework) + - phy-names : the names of the PHY corresponding to the PHYs present in the + *phy* phandle. Optional properties: - ctrl-module : phandle of the control module this glue uses to write to @@ -33,6 +36,8 @@ usb_otg_hs: usb_otg_hs@4a0ab000 { num-eps = 16; ram-bits = 12; ctrl-module = omap_control_usb; + phys = usb2_phy; + phy-names = usb2-phy; }; Board specific device node entry diff --git a/Documentation/devicetree/bindings/usb/usb-phy.txt b/Documentation/devicetree/bindings/usb/usb-phy.txt index 61496f5..c0245c8 100644 --- a/Documentation/devicetree/bindings/usb/usb-phy.txt +++ b/Documentation/devicetree/bindings/usb/usb-phy.txt @@ -5,6 +5,8 @@ OMAP USB2 PHY Required properties: - compatible: Should be ti,omap-usb2 - reg : Address and length of the register set for the device. + - #phy-cells: determine the number of cells that should be given in the + phandle while referencing this phy. Optional properties: - ctrl-module : phandle of the control module used by PHY driver to power on @@ -16,6 +18,7 @@ usb2phy@4a0ad080 { compatible = ti,omap-usb2; reg = 0x4a0ad080 0x58; ctrl-module = omap_control_usb; + #phy-cells = 0; }; OMAP USB3 PHY @@ -25,6 +28,8 @@ Required properties: - reg : Address and length of the register set for the device. - reg-names: The names of the register addresses corresponding to the registers filled in reg. + - #phy-cells: determine the number of cells that should be given in the + phandle while referencing this phy. Optional properties: - ctrl-module : phandle of the control module used by PHY driver to power on @@ -39,4 +44,5 @@ usb3phy@4a084400 { 0x4a084c00 0x40; reg-names = phy_rx, phy_tx, pll_ctrl; ctrl-module = omap_control_usb; + #phy-cells = 0; }; diff --git a/arch/arm/boot/dts/omap3-beagle-xm.dts b/arch/arm/boot/dts/omap3-beagle-xm.dts index afdb164..533b2da 100644 --- a/arch/arm/boot/dts/omap3-beagle-xm.dts +++ b/arch/arm/boot/dts/omap3-beagle-xm.dts @@ -144,6 +144,8 @@ usb_otg_hs { interface-type = 0; usb-phy = usb2_phy; + phys = usb2_phy; + phy-names = usb2-phy; mode = 3; power = 50; }; diff --git a/arch/arm/boot/dts/omap3-evm.dts b/arch/arm/boot/dts/omap3-evm.dts index 7d4329d..4134dd0 100644 --- a/arch/arm/boot/dts/omap3-evm.dts +++ b/arch/arm/boot/dts/omap3-evm.dts @@ -70,6 +70,8 @@ usb_otg_hs { interface-type = 0; usb-phy = usb2_phy; + phys = usb2_phy; + phy-names = usb2-phy; mode = 3; power = 50; }; diff --git a/arch/arm/boot/dts/omap3-overo.dtsi b/arch/arm/boot/dts/omap3-overo.dtsi index 8f1abec..a461d2f 100644 --- a/arch/arm/boot/dts/omap3-overo.dtsi +++ b/arch/arm/boot/dts/omap3-overo.dtsi @@ -76,6 +76,8 @@ usb_otg_hs { interface-type = 0; usb-phy = usb2_phy; + phys = usb2_phy; + phy-names = usb2-phy; mode = 3; power = 50; }; diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi index 22d9f2b..1e8e2fe 100644 --- a/arch/arm/boot/dts/omap4.dtsi +++ b/arch/arm/boot/dts/omap4.dtsi @@ -520,6 +520,7 @@ compatible = ti,omap-usb2; reg = 0x4a0ad080 0x58; ctrl-module = omap_control_usb; + #phy-cells = 0; }; }; @@ -658,6 +659,8 @@ interrupt-names = mc, dma
[PATCH 09/15] phy: Add driver for Exynos MIPI CSIS/DSIM DPHYs
From: Sylwester Nawrocki s.nawro...@samsung.com Add a PHY provider driver for the Samsung S5P/Exynos SoC MIPI CSI-2 receiver and MIPI DSI transmitter DPHYs. Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com Acked-by: Felipe Balbi ba...@ti.com Signed-off-by: Kishon Vijay Abraham I kis...@ti.com --- .../devicetree/bindings/phy/samsung-phy.txt| 14 ++ drivers/phy/Kconfig|9 ++ drivers/phy/Makefile |3 +- drivers/phy/phy-exynos-mipi-video.c| 169 4 files changed, 194 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/phy/samsung-phy.txt create mode 100644 drivers/phy/phy-exynos-mipi-video.c diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt new file mode 100644 index 000..5ff208c --- /dev/null +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -0,0 +1,14 @@ +Samsung S5P/EXYNOS SoC series MIPI CSIS/DSIM DPHY +- + +Required properties: +- compatible : should be samsung,s5pv210-mipi-video-phy; +- reg : offset and length of the MIPI DPHY register set; +- #phy-cells : from the generic phy bindings, must be 1; + +For samsung,s5pv210-mipi-video-phy compatible PHYs the second cell in +the PHY specifier identifies the PHY and its meaning is as follows: + 0 - MIPI CSIS 0, + 1 - MIPI DSIM 0, + 2 - MIPI CSIS 1, + 3 - MIPI DSIM 1. diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 5f85909..6f446d0 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -11,3 +11,12 @@ menuconfig GENERIC_PHY devices present in the kernel. This layer will have the generic API by which phy drivers can create PHY using the phy framework and phy users can obtain reference to the PHY. + +if GENERIC_PHY + +config PHY_EXYNOS_MIPI_VIDEO + tristate S5P/EXYNOS SoC series MIPI CSI-2/DSI PHY driver + help + Support for MIPI CSI-2 and MIPI DSI DPHY found on Samsung + S5P and EXYNOS SoCs. +endif diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 9e9560f..71d8841 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -2,4 +2,5 @@ # Makefile for the phy drivers. # -obj-$(CONFIG_GENERIC_PHY) += phy-core.o +obj-$(CONFIG_GENERIC_PHY) += phy-core.o +obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi-video.o diff --git a/drivers/phy/phy-exynos-mipi-video.c b/drivers/phy/phy-exynos-mipi-video.c new file mode 100644 index 000..7e7fcd7 --- /dev/null +++ b/drivers/phy/phy-exynos-mipi-video.c @@ -0,0 +1,169 @@ +/* + * Samsung S5P/EXYNOS SoC series MIPI CSIS/DSIM DPHY driver + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Sylwester Nawrocki s.nawro...@samsung.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include linux/io.h +#include linux/kernel.h +#include linux/module.h +#include linux/of.h +#include linux/of_address.h +#include linux/phy/phy.h +#include linux/platform_device.h +#include linux/spinlock.h + +/* MIPI_PHYn_CONTROL register offset: n = 0..1 */ +#define EXYNOS_MIPI_PHY_CONTROL(n) ((n) * 4) +#define EXYNOS_MIPI_PHY_ENABLE (1 0) +#define EXYNOS_MIPI_PHY_SRESETN(1 1) +#define EXYNOS_MIPI_PHY_MRESETN(1 2) +#define EXYNOS_MIPI_PHY_RESET_MASK (3 1) + +enum exynos_mipi_phy_id { + EXYNOS_MIPI_PHY_ID_CSIS0, + EXYNOS_MIPI_PHY_ID_DSIM0, + EXYNOS_MIPI_PHY_ID_CSIS1, + EXYNOS_MIPI_PHY_ID_DSIM1, + EXYNOS_MIPI_PHYS_NUM +}; + +#define IS_EXYNOS_MIPI_DSIM_PHY_ID(id) \ + ((id) == EXYNOS_MIPI_PHY_ID_DSIM0 || (id) == EXYNOS_MIPI_PHY_ID_DSIM0) + +struct exynos_mipi_video_phy { + spinlock_t slock; + struct phy *phys[EXYNOS_MIPI_PHYS_NUM]; + void __iomem *regs; +}; + +static int __set_phy_state(struct exynos_mipi_video_phy *state, + enum exynos_mipi_phy_id id, unsigned int on) +{ + void __iomem *addr; + u32 reg, reset; + + addr = state-regs + EXYNOS_MIPI_PHY_CONTROL(id / 2); + + if (IS_EXYNOS_MIPI_DSIM_PHY_ID(id)) + reset = EXYNOS_MIPI_PHY_MRESETN; + else + reset = EXYNOS_MIPI_PHY_SRESETN; + + spin_lock(state-slock); + reg = readl(addr); + if (on) + reg |= reset; + else + reg = ~reset; + writel(reg, addr); + + /* Clear ENABLE bit only if MRESETN, SRESETN bits are not set. */ + if (on) + reg |= EXYNOS_MIPI_PHY_ENABLE; + else if (!(reg EXYNOS_MIPI_PHY_RESET_MASK)) + reg = ~EXYNOS_MIPI_PHY_ENABLE; + + writel(reg, addr
[PATCH 07/15] usb: phy: omap-usb2: remove *set_suspend* callback from omap-usb2
Now that omap-usb2 is adapted to the new generic PHY framework, *set_suspend* ops can be removed from omap-usb2 driver. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- drivers/usb/phy/phy-omap-usb2.c | 25 - 1 file changed, 25 deletions(-) diff --git a/drivers/usb/phy/phy-omap-usb2.c b/drivers/usb/phy/phy-omap-usb2.c index 751b30f..3f2b125 100644 --- a/drivers/usb/phy/phy-omap-usb2.c +++ b/drivers/usb/phy/phy-omap-usb2.c @@ -97,29 +97,6 @@ static int omap_usb_set_peripheral(struct usb_otg *otg, return 0; } -static int omap_usb2_suspend(struct usb_phy *x, int suspend) -{ - u32 ret; - struct omap_usb *phy = phy_to_omapusb(x); - - if (suspend !phy-is_suspended) { - omap_control_usb_phy_power(phy-control_dev, 0); - pm_runtime_put_sync(phy-dev); - phy-is_suspended = 1; - } else if (!suspend phy-is_suspended) { - ret = pm_runtime_get_sync(phy-dev); - if (ret 0) { - dev_err(phy-dev, get_sync failed with err %d\n, - ret); - return ret; - } - omap_control_usb_phy_power(phy-control_dev, 1); - phy-is_suspended = 0; - } - - return 0; -} - static int omap_usb_power_off(struct phy *x) { struct omap_usb *phy = phy_get_drvdata(x); @@ -167,7 +144,6 @@ static int omap_usb2_probe(struct platform_device *pdev) phy-phy.dev= phy-dev; phy-phy.label = omap-usb2; - phy-phy.set_suspend= omap_usb2_suspend; phy-phy.otg= otg; phy-phy.type = USB_PHY_TYPE_USB2; @@ -182,7 +158,6 @@ static int omap_usb2_probe(struct platform_device *pdev) return -ENODEV; } - phy-is_suspended = 1; omap_control_usb_phy_power(phy-control_dev, 0); otg-set_host = omap_usb_set_host; -- 1.7.10.4 -- 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
[PATCH 06/15] usb: musb: omap2430: use the new generic PHY framework
Use the generic PHY framework API to get the PHY. The usb_phy_set_resume and usb_phy_set_suspend is replaced with power_on and power_off to align with the new PHY framework. musb-xceiv can't be removed as of now because musb core uses xceiv.state and xceiv.otg. Once there is a separate state machine to handle otg, these can be moved out of xceiv and then we can start using the generic PHY framework. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com Acked-by: Felipe Balbi ba...@ti.com --- drivers/usb/musb/Kconfig |1 + drivers/usb/musb/musb_core.c |1 + drivers/usb/musb/musb_core.h |3 +++ drivers/usb/musb/omap2430.c | 26 -- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 797e3fd..01381ac 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -76,6 +76,7 @@ config USB_MUSB_TUSB6010 config USB_MUSB_OMAP2PLUS tristate OMAP2430 and onwards depends on ARCH_OMAP2PLUS + depends on GENERIC_PHY config USB_MUSB_AM35X tristate AM35x diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 29a24ce..cca12c0 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -1814,6 +1814,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) musb-min_power = plat-min_power; musb-ops = plat-platform_ops; musb-port_mode = plat-mode; + musb-phy_label = plat-phy_label; /* The musb_platform_init() call: * - adjusts musb-mregs diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 7d341c3..8f017ab 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -46,6 +46,7 @@ #include linux/usb.h #include linux/usb/otg.h #include linux/usb/musb.h +#include linux/phy/phy.h struct musb; struct musb_hw_ep; @@ -346,6 +347,7 @@ struct musb { u16 int_tx; struct usb_phy *xceiv; + struct phy *phy; int nIrq; unsignedirq_wake:1; @@ -424,6 +426,7 @@ struct musb { unsigneddouble_buffer_not_ok:1; struct musb_hdrc_config *config; + const char *phy_label; #ifdef MUSB_CONFIG_PROC_FS struct proc_dir_entry *proc_entry; diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 6708a3b..87dac0f 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -348,11 +348,21 @@ static int omap2430_musb_init(struct musb *musb) * up through ULPI. TWL4030-family PMICs include one, * which needs a driver, drivers aren't always needed. */ - if (dev-parent-of_node) + if (dev-parent-of_node) { + musb-phy = devm_phy_get(dev-parent, usb2-phy); + + /* We can't totally remove musb-xceiv as of now because +* musb core uses xceiv.state and xceiv.otg. Once we have +* a separate state machine to handle otg, these can be moved +* out of xceiv and then we can start using the generic PHY +* framework +*/ musb-xceiv = devm_usb_get_phy_by_phandle(dev-parent, usb-phy, 0); - else + } else { musb-xceiv = devm_usb_get_phy_dev(dev, 0); + musb-phy = devm_phy_get(dev, musb-phy_label); + } if (IS_ERR(musb-xceiv)) { status = PTR_ERR(musb-xceiv); @@ -364,6 +374,10 @@ static int omap2430_musb_init(struct musb *musb) return -EPROBE_DEFER; } + if (IS_ERR(musb-phy)) { + pr_err(HS USB OTG: no PHY configured\n); + return PTR_ERR(musb-phy); + } musb-isr = omap2430_musb_interrupt; status = pm_runtime_get_sync(dev); @@ -397,7 +411,7 @@ static int omap2430_musb_init(struct musb *musb) if (glue-status != OMAP_MUSB_UNKNOWN) omap_musb_set_mailbox(glue); - usb_phy_init(musb-xceiv); + phy_init(musb-phy); pm_runtime_put_noidle(musb-controller); return 0; @@ -460,6 +474,7 @@ static int omap2430_musb_exit(struct musb *musb) del_timer_sync(musb_idle_timer); omap2430_low_level_exit(musb); + phy_exit(musb-phy); return 0; } @@ -633,7 +648,7 @@ static int omap2430_runtime_suspend(struct device *dev) OTG_INTERFSEL); omap2430_low_level_exit(musb); - usb_phy_set_suspend(musb-xceiv, 1); + phy_power_off(musb-phy); } return 0; @@ -648,8 +663,7 @@ static int omap2430_runtime_resume(struct device *dev) omap2430_low_level_init(musb); musb_writel(musb-mregs, OTG_INTERFSEL
[PATCH 13/15] phy: Add driver for Exynos DP PHY
From: Jingoo Han jg1@samsung.com Add a PHY provider driver for the Samsung Exynos SoC Display Port PHY. Signed-off-by: Jingoo Han jg1@samsung.com Reviewed-by: Tomasz Figa t.f...@samsung.com Cc: Sylwester Nawrocki s.nawro...@samsung.com Acked-by: Felipe Balbi ba...@ti.com Signed-off-by: Kishon Vijay Abraham I kis...@ti.com --- .../devicetree/bindings/phy/samsung-phy.txt|8 ++ drivers/phy/Kconfig|6 ++ drivers/phy/Makefile |1 + drivers/phy/phy-exynos-dp-video.c | 111 4 files changed, 126 insertions(+) create mode 100644 drivers/phy/phy-exynos-dp-video.c diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index 5ff208c..c0fccaa 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -12,3 +12,11 @@ the PHY specifier identifies the PHY and its meaning is as follows: 1 - MIPI DSIM 0, 2 - MIPI CSIS 1, 3 - MIPI DSIM 1. + +Samsung EXYNOS SoC series Display Port PHY +- + +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; diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 6f446d0..ed0b1b8 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -19,4 +19,10 @@ config PHY_EXYNOS_MIPI_VIDEO help Support for MIPI CSI-2 and MIPI DSI DPHY found on Samsung S5P and EXYNOS SoCs. + +config PHY_EXYNOS_DP_VIDEO + tristate EXYNOS SoC series Display Port PHY driver + depends on OF + help + Support for Display Port PHY found on Samsung EXYNOS SoCs. endif diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 71d8841..0fd1340 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_GENERIC_PHY) += phy-core.o obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi-video.o +obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO) += phy-exynos-dp-video.o diff --git a/drivers/phy/phy-exynos-dp-video.c b/drivers/phy/phy-exynos-dp-video.c new file mode 100644 index 000..3c8e247 --- /dev/null +++ b/drivers/phy/phy-exynos-dp-video.c @@ -0,0 +1,111 @@ +/* + * Samsung EXYNOS SoC series Display Port PHY driver + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Jingoo Han jg1@samsung.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include linux/io.h +#include linux/kernel.h +#include linux/module.h +#include linux/of.h +#include linux/of_address.h +#include linux/phy/phy.h +#include linux/platform_device.h + +/* DPTX_PHY_CONTROL register */ +#define EXYNOS_DPTX_PHY_ENABLE (1 0) + +struct exynos_dp_video_phy { + void __iomem *regs; +}; + +static int __set_phy_state(struct exynos_dp_video_phy *state, unsigned int on) +{ + u32 reg; + + reg = readl(state-regs); + if (on) + reg |= EXYNOS_DPTX_PHY_ENABLE; + else + reg = ~EXYNOS_DPTX_PHY_ENABLE; + writel(reg, state-regs); + + return 0; +} + +static int exynos_dp_video_phy_power_on(struct phy *phy) +{ + struct exynos_dp_video_phy *state = phy_get_drvdata(phy); + + return __set_phy_state(state, 1); +} + +static int exynos_dp_video_phy_power_off(struct phy *phy) +{ + struct exynos_dp_video_phy *state = phy_get_drvdata(phy); + + return __set_phy_state(state, 0); +} + +static struct phy_ops exynos_dp_video_phy_ops = { + .power_on = exynos_dp_video_phy_power_on, + .power_off = exynos_dp_video_phy_power_off, + .owner = THIS_MODULE, +}; + +static int exynos_dp_video_phy_probe(struct platform_device *pdev) +{ + struct exynos_dp_video_phy *state; + struct device *dev = pdev-dev; + struct resource *res; + struct phy_provider *phy_provider; + struct phy *phy; + + state = devm_kzalloc(dev, sizeof(*state), GFP_KERNEL); + if (!state) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + + state-regs = devm_ioremap_resource(dev, res); + if (IS_ERR(state-regs)) + return PTR_ERR(state-regs); + + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); + if (IS_ERR(phy_provider)) + return PTR_ERR(phy_provider); + + phy = devm_phy_create(dev, 0, exynos_dp_video_phy_ops, NULL); + if (IS_ERR(phy)) { + dev_err(dev, failed to create Display Port PHY\n); + return PTR_ERR(phy); + } + phy_set_drvdata(phy
[PATCH 11/15] exynos4-is: Use the generic MIPI CSIS PHY driver
From: Sylwester Nawrocki s.nawro...@samsung.com Use the generic PHY API instead of the platform callback to control the MIPI CSIS DPHY. The 'phy_label' field is added to the platform data structure to allow PHY lookup on non-dt platforms Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com Acked-by: Felipe Balbi ba...@ti.com Acked-by: Mauro Carvalho Chehab mche...@redhat.com Signed-off-by: Kishon Vijay Abraham I kis...@ti.com --- drivers/media/platform/exynos4-is/mipi-csis.c | 16 +--- include/linux/platform_data/mipi-csis.h | 11 ++- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c b/drivers/media/platform/exynos4-is/mipi-csis.c index 0914230..94028ce 100644 --- a/drivers/media/platform/exynos4-is/mipi-csis.c +++ b/drivers/media/platform/exynos4-is/mipi-csis.c @@ -20,6 +20,7 @@ #include linux/memory.h #include linux/module.h #include linux/of.h +#include linux/phy/phy.h #include linux/platform_data/mipi-csis.h #include linux/platform_device.h #include linux/pm_runtime.h @@ -180,6 +181,7 @@ struct csis_drvdata { * @sd: v4l2_subdev associated with CSIS device instance * @index: the hardware instance index * @pdev: CSIS platform device + * @phy: pointer to the CSIS generic PHY * @regs: mmaped I/O registers memory * @supplies: CSIS regulator supplies * @clock: CSIS clocks @@ -203,6 +205,8 @@ struct csis_state { struct v4l2_subdev sd; u8 index; struct platform_device *pdev; + struct phy *phy; + const char *phy_label; void __iomem *regs; struct regulator_bulk_data supplies[CSIS_NUM_SUPPLIES]; struct clk *clock[NUM_CSIS_CLOCKS]; @@ -742,6 +746,7 @@ static int s5pcsis_get_platform_data(struct platform_device *pdev, state-index = max(0, pdev-id); state-max_num_lanes = state-index ? CSIS1_MAX_LANES : CSIS0_MAX_LANES; + state-phy_label = pdata-phy_label; return 0; } @@ -779,8 +784,9 @@ static int s5pcsis_parse_dt(struct platform_device *pdev, samsung,csis-wclk); state-num_lanes = endpoint.bus.mipi_csi2.num_data_lanes; - of_node_put(node); + + state-phy_label = csis; return 0; } #else @@ -829,6 +835,10 @@ static int s5pcsis_probe(struct platform_device *pdev) return -EINVAL; } + state-phy = devm_phy_get(dev, state-phy_label); + if (IS_ERR(state-phy)) + return PTR_ERR(state-phy); + mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); state-regs = devm_ioremap_resource(dev, mem_res); if (IS_ERR(state-regs)) @@ -922,7 +932,7 @@ static int s5pcsis_pm_suspend(struct device *dev, bool runtime) mutex_lock(state-lock); if (state-flags ST_POWERED) { s5pcsis_stop_stream(state); - ret = s5p_csis_phy_enable(state-index, false); + ret = phy_power_off(state-phy); if (ret) goto unlock; ret = regulator_bulk_disable(CSIS_NUM_SUPPLIES, @@ -958,7 +968,7 @@ static int s5pcsis_pm_resume(struct device *dev, bool runtime) state-supplies); if (ret) goto unlock; - ret = s5p_csis_phy_enable(state-index, true); + ret = phy_power_on(state-phy); if (!ret) { state-flags |= ST_POWERED; } else { diff --git a/include/linux/platform_data/mipi-csis.h b/include/linux/platform_data/mipi-csis.h index bf34e17..9214317 100644 --- a/include/linux/platform_data/mipi-csis.h +++ b/include/linux/platform_data/mipi-csis.h @@ -17,21 +17,14 @@ * @wclk_source: CSI wrapper clock selection: 0 - bus clock, 1 - ext. SCLK_CAM * @lanes: number of data lanes used * @hs_settle: HS-RX settle time + * @phy_label: the generic PHY label */ struct s5p_platform_mipi_csis { unsigned long clk_rate; u8 wclk_source; u8 lanes; u8 hs_settle; + const char *phy_label; }; -/** - * s5p_csis_phy_enable - global MIPI-CSI receiver D-PHY control - * @id: MIPI-CSIS harware instance index (0...1) - * @on: true to enable D-PHY and deassert its reset - * false to disable D-PHY - * @return: 0 on success, or negative error code on failure - */ -int s5p_csis_phy_enable(int id, bool on); - #endif /* __PLAT_SAMSUNG_MIPI_CSIS_H_ */ -- 1.7.10.4 -- 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
[PATCH 10/15] video: exynos_mipi_dsim: Use the generic PHY driver
From: Sylwester Nawrocki s.nawro...@samsung.com Use the generic PHY API instead of the platform callback to control the MIPI DSIM DPHY. The 'phy_label' field is added to the platform data structure to allow PHY lookup on non-dt platforms. Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com Acked-by: Felipe Balbi ba...@ti.com Acked-by: Donghwa Lee dh09@samsung.com Signed-off-by: Kishon Vijay Abraham I kis...@ti.com --- drivers/video/exynos/exynos_mipi_dsi.c | 19 ++- include/video/exynos_mipi_dsim.h |6 -- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/video/exynos/exynos_mipi_dsi.c b/drivers/video/exynos/exynos_mipi_dsi.c index 32e5406..248e444 100644 --- a/drivers/video/exynos/exynos_mipi_dsi.c +++ b/drivers/video/exynos/exynos_mipi_dsi.c @@ -30,6 +30,7 @@ #include linux/interrupt.h #include linux/kthread.h #include linux/notifier.h +#include linux/phy/phy.h #include linux/regulator/consumer.h #include linux/pm_runtime.h #include linux/err.h @@ -156,8 +157,7 @@ static int exynos_mipi_dsi_blank_mode(struct mipi_dsim_device *dsim, int power) exynos_mipi_regulator_enable(dsim); /* enable MIPI-DSI PHY. */ - if (dsim-pd-phy_enable) - dsim-pd-phy_enable(pdev, true); + phy_power_on(dsim-phy); clk_enable(dsim-clock); @@ -373,6 +373,10 @@ static int exynos_mipi_dsi_probe(struct platform_device *pdev) return ret; } + dsim-phy = devm_phy_get(pdev-dev, dsim_pd-phy_label); + if (IS_ERR(dsim-phy)) + return PTR_ERR(dsim-phy); + dsim-clock = devm_clk_get(pdev-dev, dsim0); if (IS_ERR(dsim-clock)) { dev_err(pdev-dev, failed to get dsim clock source\n); @@ -439,8 +443,7 @@ static int exynos_mipi_dsi_probe(struct platform_device *pdev) exynos_mipi_regulator_enable(dsim); /* enable MIPI-DSI PHY. */ - if (dsim-pd-phy_enable) - dsim-pd-phy_enable(pdev, true); + phy_power_on(dsim-phy); exynos_mipi_update_cfg(dsim); @@ -504,9 +507,8 @@ static int exynos_mipi_dsi_suspend(struct device *dev) if (client_drv client_drv-suspend) client_drv-suspend(client_dev); - /* enable MIPI-DSI PHY. */ - if (dsim-pd-phy_enable) - dsim-pd-phy_enable(pdev, false); + /* disable MIPI-DSI PHY. */ + phy_power_off(dsim-phy); clk_disable(dsim-clock); @@ -536,8 +538,7 @@ static int exynos_mipi_dsi_resume(struct device *dev) exynos_mipi_regulator_enable(dsim); /* enable MIPI-DSI PHY. */ - if (dsim-pd-phy_enable) - dsim-pd-phy_enable(pdev, true); + phy_power_on(dsim-phy); clk_enable(dsim-clock); diff --git a/include/video/exynos_mipi_dsim.h b/include/video/exynos_mipi_dsim.h index 89dc88a..0e7e43b 100644 --- a/include/video/exynos_mipi_dsim.h +++ b/include/video/exynos_mipi_dsim.h @@ -216,6 +216,7 @@ struct mipi_dsim_config { * automatically. * @e_clk_src: select byte clock source. * @pd: pointer to MIPI-DSI driver platform data. + * @phy: pointer to the generic PHY */ struct mipi_dsim_device { struct device *dev; @@ -236,6 +237,7 @@ struct mipi_dsim_device { boolsuspended; struct mipi_dsim_platform_data *pd; + struct phy *phy; }; /* @@ -248,7 +250,7 @@ struct mipi_dsim_device { * @enabled: indicate whether mipi controller got enabled or not. * @lcd_panel_info: pointer for lcd panel specific structure. * this structure specifies width, height, timing and polarity and so on. - * @phy_enable: pointer to a callback controlling D-PHY enable/reset + * @phy_label: the generic PHY label */ struct mipi_dsim_platform_data { charlcd_panel_name[PANEL_NAME_SIZE]; @@ -257,7 +259,7 @@ struct mipi_dsim_platform_data { unsigned intenabled; void*lcd_panel_info; - int (*phy_enable)(struct platform_device *pdev, bool on); + const char *phy_label; }; /* -- 1.7.10.4 -- 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
[PATCH 08/15] usb: phy: twl4030-usb: remove *set_suspend* and *phy_init* ops
Now that twl4030-usb is adapted to the new generic PHY framework, *set_suspend* and *phy_init* ops can be removed from twl4030-usb driver. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- drivers/usb/phy/phy-twl4030-usb.c | 57 + 1 file changed, 13 insertions(+), 44 deletions(-) diff --git a/drivers/usb/phy/phy-twl4030-usb.c b/drivers/usb/phy/phy-twl4030-usb.c index 9051756..44f8b1b 100644 --- a/drivers/usb/phy/phy-twl4030-usb.c +++ b/drivers/usb/phy/phy-twl4030-usb.c @@ -422,25 +422,20 @@ static void twl4030_phy_power(struct twl4030_usb *twl, int on) } } -static void twl4030_phy_suspend(struct twl4030_usb *twl, int controller_off) +static int twl4030_phy_power_off(struct phy *phy) { + struct twl4030_usb *twl = phy_get_drvdata(phy); + if (twl-asleep) - return; + return 0; twl4030_phy_power(twl, 0); twl-asleep = 1; dev_dbg(twl-dev, %s\n, __func__); -} - -static int twl4030_phy_power_off(struct phy *phy) -{ - struct twl4030_usb *twl = phy_get_drvdata(phy); - - twl4030_phy_suspend(twl, 0); return 0; } -static void __twl4030_phy_resume(struct twl4030_usb *twl) +static void __twl4030_phy_power_on(struct twl4030_usb *twl) { twl4030_phy_power(twl, 1); twl4030_i2c_access(twl, 1); @@ -449,11 +444,13 @@ static void __twl4030_phy_resume(struct twl4030_usb *twl) twl4030_i2c_access(twl, 0); } -static void twl4030_phy_resume(struct twl4030_usb *twl) +static int twl4030_phy_power_on(struct phy *phy) { + struct twl4030_usb *twl = phy_get_drvdata(phy); + if (!twl-asleep) - return; - __twl4030_phy_resume(twl); + return 0; + __twl4030_phy_power_on(twl); twl-asleep = 0; dev_dbg(twl-dev, %s\n, __func__); @@ -466,13 +463,6 @@ static void twl4030_phy_resume(struct twl4030_usb *twl) cancel_delayed_work(twl-id_workaround_work); schedule_delayed_work(twl-id_workaround_work, HZ); } -} - -static int twl4030_phy_power_on(struct phy *phy) -{ - struct twl4030_usb *twl = phy_get_drvdata(phy); - - twl4030_phy_resume(twl); return 0; } @@ -604,9 +594,9 @@ static void twl4030_id_workaround_work(struct work_struct *work) } } -static int twl4030_usb_phy_init(struct usb_phy *phy) +static int twl4030_phy_init(struct phy *phy) { - struct twl4030_usb *twl = phy_to_twl(phy); + struct twl4030_usb *twl = phy_get_drvdata(phy); enum omap_musb_vbus_id_status status; /* @@ -621,32 +611,13 @@ static int twl4030_usb_phy_init(struct usb_phy *phy) if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) { omap_musb_mailbox(twl-linkstat); - twl4030_phy_resume(twl); + twl4030_phy_power_on(phy); } sysfs_notify(twl-dev-kobj, NULL, vbus); return 0; } -static int twl4030_phy_init(struct phy *phy) -{ - struct twl4030_usb *twl = phy_get_drvdata(phy); - - return twl4030_usb_phy_init(twl-phy); -} - -static int twl4030_set_suspend(struct usb_phy *x, int suspend) -{ - struct twl4030_usb *twl = phy_to_twl(x); - - if (suspend) - twl4030_phy_suspend(twl, 1); - else - twl4030_phy_resume(twl); - - return 0; -} - static int twl4030_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget) { @@ -717,8 +688,6 @@ static int twl4030_usb_probe(struct platform_device *pdev) twl-phy.label = twl4030; twl-phy.otg= otg; twl-phy.type = USB_PHY_TYPE_USB2; - twl-phy.set_suspend= twl4030_set_suspend; - twl-phy.init = twl4030_usb_phy_init; otg-phy= twl-phy; otg-set_host = twl4030_set_host; -- 1.7.10.4 -- 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
[PATCH 04/15] ARM: OMAP: USB: Add phy binding information
In order for controllers to get PHY in case of non dt boot, the phy binding information (phy device name) should be added in the platform data of the controller. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com Acked-by: Felipe Balbi ba...@ti.com --- arch/arm/mach-omap2/usb-musb.c |3 +++ include/linux/usb/musb.h |3 +++ 2 files changed, 6 insertions(+) diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c index 8c4de27..6aa7cbf 100644 --- a/arch/arm/mach-omap2/usb-musb.c +++ b/arch/arm/mach-omap2/usb-musb.c @@ -85,6 +85,9 @@ void __init usb_musb_init(struct omap_musb_board_data *musb_board_data) musb_plat.mode = board_data-mode; musb_plat.extvbus = board_data-extvbus; + if (cpu_is_omap34xx()) + musb_plat.phy_label = twl4030; + if (soc_is_am35xx()) { oh_name = am35x_otg_hs; name = musb-am35x; diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h index 053c268..596f8c8 100644 --- a/include/linux/usb/musb.h +++ b/include/linux/usb/musb.h @@ -104,6 +104,9 @@ struct musb_hdrc_platform_data { /* for clk_get() */ const char *clock; + /* phy label */ + const char *phy_label; + /* (HOST or OTG) switch VBUS on/off */ int (*set_vbus)(struct device *dev, int is_on); -- 1.7.10.4 -- 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
[PATCH 02/15] usb: phy: omap-usb2: use the new generic PHY framework
Used the generic PHY framework API to create the PHY. Now the power off and power on are done in omap_usb_power_off and omap_usb_power_on respectively. However using the old USB PHY library cannot be completely removed because OTG is intertwined with PHY and moving to the new framework will break OTG. Once we have a separate OTG state machine, we can get rid of the USB PHY library. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com Acked-by: Felipe Balbi ba...@ti.com --- drivers/usb/phy/Kconfig |1 + drivers/usb/phy/phy-omap-usb2.c | 45 +++ 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 3622fff..cc55993 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -75,6 +75,7 @@ config OMAP_CONTROL_USB config OMAP_USB2 tristate OMAP USB2 PHY Driver depends on ARCH_OMAP2PLUS + depends on GENERIC_PHY select OMAP_CONTROL_USB help Enable this to support the transceiver that is part of SOC. This diff --git a/drivers/usb/phy/phy-omap-usb2.c b/drivers/usb/phy/phy-omap-usb2.c index 844ab68..751b30f 100644 --- a/drivers/usb/phy/phy-omap-usb2.c +++ b/drivers/usb/phy/phy-omap-usb2.c @@ -28,6 +28,7 @@ #include linux/pm_runtime.h #include linux/delay.h #include linux/usb/omap_control_usb.h +#include linux/phy/phy.h /** * omap_usb2_set_comparator - links the comparator present in the sytem with @@ -119,10 +120,36 @@ static int omap_usb2_suspend(struct usb_phy *x, int suspend) return 0; } +static int omap_usb_power_off(struct phy *x) +{ + struct omap_usb *phy = phy_get_drvdata(x); + + omap_control_usb_phy_power(phy-control_dev, 0); + + return 0; +} + +static int omap_usb_power_on(struct phy *x) +{ + struct omap_usb *phy = phy_get_drvdata(x); + + omap_control_usb_phy_power(phy-control_dev, 1); + + return 0; +} + +static struct phy_ops ops = { + .power_on = omap_usb_power_on, + .power_off = omap_usb_power_off, + .owner = THIS_MODULE, +}; + static int omap_usb2_probe(struct platform_device *pdev) { struct omap_usb *phy; + struct phy *generic_phy; struct usb_otg *otg; + struct phy_provider *phy_provider; phy = devm_kzalloc(pdev-dev, sizeof(*phy), GFP_KERNEL); if (!phy) { @@ -144,6 +171,11 @@ static int omap_usb2_probe(struct platform_device *pdev) phy-phy.otg= otg; phy-phy.type = USB_PHY_TYPE_USB2; + phy_provider = devm_of_phy_provider_register(phy-dev, + of_phy_simple_xlate); + if (IS_ERR(phy_provider)) + return PTR_ERR(phy_provider); + phy-control_dev = omap_get_control_dev(); if (IS_ERR(phy-control_dev)) { dev_dbg(pdev-dev, Failed to get control device\n); @@ -159,6 +191,15 @@ static int omap_usb2_probe(struct platform_device *pdev) otg-start_srp = omap_usb_start_srp; otg-phy= phy-phy; + platform_set_drvdata(pdev, phy); + pm_runtime_enable(phy-dev); + + generic_phy = devm_phy_create(phy-dev, 0, ops, omap-usb2); + if (IS_ERR(generic_phy)) + return PTR_ERR(generic_phy); + + phy_set_drvdata(generic_phy, phy); + phy-wkupclk = devm_clk_get(phy-dev, usb_phy_cm_clk32k); if (IS_ERR(phy-wkupclk)) { dev_err(pdev-dev, unable to get usb_phy_cm_clk32k\n); @@ -174,10 +215,6 @@ static int omap_usb2_probe(struct platform_device *pdev) usb_add_phy_dev(phy-phy); - platform_set_drvdata(pdev, phy); - - pm_runtime_enable(phy-dev); - return 0; } -- 1.7.10.4 -- 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
[PATCH 03/15] usb: phy: twl4030: use the new generic PHY framework
Used the generic PHY framework API to create the PHY. For powering on and powering off the PHY, power_on and power_off ops are used. Once the MUSB OMAP glue is adapted to the new framework, the suspend and resume ops of usb phy library will be removed. However using the old usb phy library cannot be completely removed because otg is intertwined with phy and moving to the new framework completely will break otg. Once we have a separate otg state machine, we can get rid of the usb phy library. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- drivers/usb/phy/phy-twl4030-usb.c | 50 - 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/drivers/usb/phy/phy-twl4030-usb.c b/drivers/usb/phy/phy-twl4030-usb.c index 8f78d2d..9051756 100644 --- a/drivers/usb/phy/phy-twl4030-usb.c +++ b/drivers/usb/phy/phy-twl4030-usb.c @@ -33,6 +33,7 @@ #include linux/io.h #include linux/delay.h #include linux/usb/otg.h +#include linux/phy/phy.h #include linux/usb/musb-omap.h #include linux/usb/ulpi.h #include linux/i2c/twl.h @@ -431,6 +432,14 @@ static void twl4030_phy_suspend(struct twl4030_usb *twl, int controller_off) dev_dbg(twl-dev, %s\n, __func__); } +static int twl4030_phy_power_off(struct phy *phy) +{ + struct twl4030_usb *twl = phy_get_drvdata(phy); + + twl4030_phy_suspend(twl, 0); + return 0; +} + static void __twl4030_phy_resume(struct twl4030_usb *twl) { twl4030_phy_power(twl, 1); @@ -459,6 +468,14 @@ static void twl4030_phy_resume(struct twl4030_usb *twl) } } +static int twl4030_phy_power_on(struct phy *phy) +{ + struct twl4030_usb *twl = phy_get_drvdata(phy); + + twl4030_phy_resume(twl); + return 0; +} + static int twl4030_usb_ldo_init(struct twl4030_usb *twl) { /* Enable writing to power configuration registers */ @@ -602,13 +619,22 @@ static int twl4030_usb_phy_init(struct usb_phy *phy) status = twl4030_usb_linkstat(twl); twl-linkstat = status; - if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) + if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) { omap_musb_mailbox(twl-linkstat); + twl4030_phy_resume(twl); + } sysfs_notify(twl-dev-kobj, NULL, vbus); return 0; } +static int twl4030_phy_init(struct phy *phy) +{ + struct twl4030_usb *twl = phy_get_drvdata(phy); + + return twl4030_usb_phy_init(twl-phy); +} + static int twl4030_set_suspend(struct usb_phy *x, int suspend) { struct twl4030_usb *twl = phy_to_twl(x); @@ -646,13 +672,22 @@ static int twl4030_set_host(struct usb_otg *otg, struct usb_bus *host) return 0; } +static const struct phy_ops ops = { + .init = twl4030_phy_init, + .power_on = twl4030_phy_power_on, + .power_off = twl4030_phy_power_off, + .owner = THIS_MODULE, +}; + static int twl4030_usb_probe(struct platform_device *pdev) { struct twl4030_usb_data *pdata = pdev-dev.platform_data; struct twl4030_usb *twl; + struct phy *phy; int status, err; struct usb_otg *otg; struct device_node *np = pdev-dev.of_node; + struct phy_provider *phy_provider; twl = devm_kzalloc(pdev-dev, sizeof *twl, GFP_KERNEL); if (!twl) @@ -689,6 +724,19 @@ static int twl4030_usb_probe(struct platform_device *pdev) otg-set_host = twl4030_set_host; otg-set_peripheral = twl4030_set_peripheral; + phy_provider = devm_of_phy_provider_register(twl-dev, + of_phy_simple_xlate); + if (IS_ERR(phy_provider)) + return PTR_ERR(phy_provider); + + phy = devm_phy_create(twl-dev, 0, ops, twl4030); + if (IS_ERR(phy)) { + dev_dbg(pdev-dev, Failed to create PHY\n); + return PTR_ERR(phy); + } + + phy_set_drvdata(phy, twl); + /* init spinlock for workqueue */ spin_lock_init(twl-lock); -- 1.7.10.4 -- 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
[PATCH 01/15] drivers: phy: add generic PHY framework
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 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Tested-by: Sylwester Nawrocki s.nawro...@samsung.com --- .../devicetree/bindings/phy/phy-bindings.txt | 66 +++ Documentation/phy.txt | 129 + MAINTAINERS|7 + drivers/Kconfig|2 + drivers/Makefile |2 + drivers/phy/Kconfig| 13 + drivers/phy/Makefile |5 + drivers/phy/phy-core.c | 544 include/linux/phy/phy.h| 344 + 9 files changed, 1112 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 diff --git a/Documentation/devicetree/bindings/phy/phy-bindings.txt b/Documentation/devicetree/bindings/phy/phy-bindings.txt new file mode 100644 index 000..8ae844f --- /dev/null +++ b/Documentation/devicetree/bindings/phy/phy-bindings.txt @@ -0,0 +1,66 @@ +This document explains only the device tree data binding. For general +information about PHY subsystem refer to Documentation/phy.txt + +PHY device node +=== + +Required Properties: +#phy-cells:Number of cells in a PHY specifier; The meaning of all those + cells is defined by the binding for the phy node. The PHY + provider can use the values in cells to find the appropriate + PHY. + +For example: + +phys: phy { +compatible = xxx; +reg = ...; +. +. +#phy-cells = 1; +. +. +}; + +That node describes an IP block (PHY provider) that implements 2 different PHYs. +In order to differentiate between these 2 PHYs, an additonal specifier should be +given while trying to get a reference to it. + +PHY user node += + +Required Properties: +phys : the phandle for the PHY device (used by the PHY subsystem) +phy-names : the names of the PHY corresponding to the PHYs present in the + *phys* phandle + +Example 1: +usb1: usb_otg_ss@xxx { +compatible = xxx; +reg = xxx; +. +. +phys = usb2_phy, usb3_phy; +phy-names = usb2phy, usb3phy; +. +. +}; + +This node represents a controller that uses two PHYs, one for usb2 and one for +usb3. + +Example 2: +usb2: usb_otg_ss@xxx { +compatible = xxx; +reg = xxx; +. +. +phys = phys 1; +phy-names = usbphy; +. +. +}; + +This node represents a controller that uses one of the PHYs of the PHY provider +device defined previously. Note that the phy handle has an additional specifier +1 to differentiate between the two PHYs. diff --git a/Documentation/phy.txt b/Documentation/phy.txt new file mode 100644 index 000..05f8fda --- /dev/null +++ b/Documentation/phy.txt @@ -0,0 +1,129 @@ + PHY SUBSYSTEM + Kishon Vijay Abraham I kis...@ti.com + +This document explains the Generic PHY Framework along with the APIs provided, +and how-to-use. + +1. Introduction + +*PHY* is the abbreviation for physical layer. It is used to connect a device +to the physical medium e.g., the USB controller has a PHY to provide functions +such as serialization, de-serialization, encoding, decoding and is responsible +for obtaining the required data transmission rate. Note that some USB +controllers have PHY functionality embedded into it and others use an external +PHY. Other peripherals that use PHY include Wireless LAN, Ethernet, +SATA etc. + +The intention of creating this framework is to bring the PHY drivers spread +all over the Linux kernel to drivers/phy to increase code re-use and for +better code maintainability. + +This framework will be of use only to devices that use external PHY (PHY +functionality is not embedded within the controller). + +2. Registering/Unregistering the PHY provider + +PHY provider refers to an entity that implements one or more PHY instances. +For the simple case where the PHY provider implements only a single instance of +the PHY, the framework provides its own implementation of of_xlate
[PATCH 00/15] PHY framework
Added a generic PHY framework that 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. This framework will be of use only to devices that uses external PHY (PHY functionality is not embedded within the controller). The intention of creating this framework is to bring the phy drivers spread all over the Linux kernel to drivers/phy to increase code re-use and to increase code maintainability. Comments to make PHY as bus wasn't done because PHY devices can be part of other bus and making a same device attached to multiple bus leads to bad design. If the PHY driver has to send notification on connect/disconnect, the PHY driver should make use of the extcon framework. Using this susbsystem to use extcon framwork will have to be analysed. Exynos MIPI CSIS/DSIM PHY and Displayport PHY have started using this framework. Have included those patches also in this series. twl4030-usb and omap-usb2 have also been adapted to this framework. These patches are also available @ git://gitorious.org/linuxphy/linuxphy.git tags/phy-for-v3.12 Jingoo Han (3): phy: Add driver for Exynos DP PHY video: exynos_dp: remove non-DT support for Exynos Display Port video: exynos_dp: Use the generic PHY driver Kishon Vijay Abraham I (8): drivers: phy: add generic PHY framework usb: phy: omap-usb2: use the new generic PHY framework usb: phy: twl4030: use the new generic PHY framework ARM: OMAP: USB: Add phy binding information ARM: dts: omap: update usb_otg_hs data usb: musb: omap2430: use the new generic PHY framework usb: phy: omap-usb2: remove *set_suspend* callback from omap-usb2 usb: phy: twl4030-usb: remove *set_suspend* and *phy_init* ops Sylwester Nawrocki (4): phy: Add driver for Exynos MIPI CSIS/DSIM DPHYs video: exynos_mipi_dsim: Use the generic PHY driver exynos4-is: Use the generic MIPI CSIS PHY driver ARM: Samsung: Remove the MIPI PHY setup code .../devicetree/bindings/phy/phy-bindings.txt | 66 +++ .../devicetree/bindings/phy/samsung-phy.txt| 22 + Documentation/devicetree/bindings/usb/omap-usb.txt |5 + Documentation/devicetree/bindings/usb/usb-phy.txt |6 + .../devicetree/bindings/video/exynos_dp.txt| 18 +- Documentation/phy.txt | 129 + MAINTAINERS|7 + arch/arm/boot/dts/omap3-beagle-xm.dts |2 + arch/arm/boot/dts/omap3-evm.dts|2 + arch/arm/boot/dts/omap3-overo.dtsi |2 + arch/arm/boot/dts/omap4.dtsi |3 + arch/arm/boot/dts/twl4030.dtsi |1 + arch/arm/mach-exynos/include/mach/regs-pmu.h |5 - arch/arm/mach-omap2/usb-musb.c |3 + arch/arm/mach-s5pv210/include/mach/regs-clock.h|4 - arch/arm/plat-samsung/Kconfig |5 - arch/arm/plat-samsung/Makefile |1 - arch/arm/plat-samsung/setup-mipiphy.c | 60 --- drivers/Kconfig|2 + drivers/Makefile |2 + drivers/media/platform/exynos4-is/mipi-csis.c | 16 +- drivers/phy/Kconfig| 28 + drivers/phy/Makefile |7 + drivers/phy/phy-core.c | 544 drivers/phy/phy-exynos-dp-video.c | 111 drivers/phy/phy-exynos-mipi-video.c| 169 ++ drivers/usb/musb/Kconfig |1 + drivers/usb/musb/musb_core.c |1 + drivers/usb/musb/musb_core.h |3 + drivers/usb/musb/omap2430.c| 26 +- drivers/usb/phy/Kconfig|1 + drivers/usb/phy/phy-omap-usb2.c| 60 ++- drivers/usb/phy/phy-twl4030-usb.c | 63 ++- drivers/video/exynos/Kconfig |2 +- drivers/video/exynos/exynos_dp_core.c | 132 ++--- drivers/video/exynos/exynos_dp_core.h | 110 drivers/video/exynos/exynos_dp_reg.c |2 - drivers/video/exynos/exynos_mipi_dsi.c | 19 +- include/linux/phy/phy.h| 344 + include/linux/platform_data/mipi-csis.h| 11 +- include/linux/usb/musb.h |3 + include/video/exynos_dp.h | 131 - include/video/exynos_mipi_dsim.h |6 +- 43 files changed, 1746 insertions(+), 389 deletions(-) create mode 100644 Documentation/devicetree/bindings/phy/phy-bindings.txt create mode 100644 Documentation/devicetree/bindings/phy/samsung-phy.txt create mode 100644 Documentation/phy.txt delete mode 100644 arch/arm/plat-samsung/setup
Re: [PATCH 01/15] drivers: phy: add generic PHY framework
Hi, On Thursday 18 July 2013 12:50 PM, Greg KH wrote: On Thu, Jul 18, 2013 at 12:16:10PM +0530, Kishon Vijay Abraham I wrote: +struct phy_provider *__of_phy_provider_register(struct device *dev, +struct module *owner, struct phy * (*of_xlate)(struct device *dev, +struct of_phandle_args *args)); +struct phy_provider *__devm_of_phy_provider_register(struct device *dev, +struct module *owner, struct phy * (*of_xlate)(struct device *dev, +struct of_phandle_args *args)) + +__of_phy_provider_register and __devm_of_phy_provider_register can be used to +register the phy_provider and it takes device, owner and of_xlate as +arguments. For the dt boot case, all PHY providers should use one of the above +2 APIs to register the PHY provider. Why do you have __ for the prefix of a public function? Is that really the way that OF handles this type of thing? I have a macro of_phy_provider_register/devm_of_phy_provider_register that calls these functions and should be used by the PHY drivers. Probably I should make a mention of it in the Documentation. --- /dev/null +++ b/drivers/phy/Kconfig @@ -0,0 +1,13 @@ +# +# PHY +# + +menuconfig GENERIC_PHY +tristate PHY Subsystem +help + Generic PHY support. + + This framework is designed to provide a generic interface for PHY + devices present in the kernel. This layer will have the generic + API by which phy drivers can create PHY using the phy framework and + phy users can obtain reference to the PHY. Again, please reverse this. The drivers that use it should select it, not depend on it, which will then enable this option. I will never know if I need to enable it, and based on your follow-on patches, if I don't, drivers that were working just fine, now disappeared from my build, which isn't nice, and a pain to notice and fix up. ok. +/** + * phy_create() - create a new phy + * @dev: device that is creating the new phy + * @id: id of the phy + * @ops: function pointers for performing phy operations + * @label: label given to the phy + * + * Called to create a phy using phy framework. + */ +struct phy *phy_create(struct device *dev, u8 id, const struct phy_ops *ops, +const char *label) +{ +int ret; +struct phy *phy; + +if (!dev) { +dev_WARN(dev, no device provided for PHY\n); +ret = -EINVAL; +goto err0; +} + +phy = kzalloc(sizeof(*phy), GFP_KERNEL); +if (!phy) { +ret = -ENOMEM; +goto err0; +} + +device_initialize(phy-dev); +mutex_init(phy-mutex); + +phy-dev.class = phy_class; +phy-dev.parent = dev; +phy-dev.of_node = dev-of_node; +phy-id = id; +phy-ops = ops; +phy-label = kstrdup(label, GFP_KERNEL); + +ret = dev_set_name(phy-dev, %s.%d, dev_name(dev), id); Your naming is odd, no phy anywhere in it? You rely on the sender to never send a duplicate name.id pair? Why not create your own ids based on the number of phys in the system, like almost all other classes and subsystems do? hmm.. some PHY drivers use the id they provide to perform some of their internal operation as in [1] (This is used only if a single PHY provider implements multiple PHYS). Probably I'll add an option like PLATFORM_DEVID_AUTO to give the PHY drivers an option to use auto id. [1] - http://archive.arm.linux.org.uk/lurker/message/20130628.134308.4a8f7668.ca.html +static inline int phy_pm_runtime_get(struct phy *phy) +{ +if (WARN(IS_ERR(phy), Invalid PHY reference\n)) +return -EINVAL; Why would phy ever not be valid and a error pointer? And why dump the stack if that happens, that seems really extreme. hmm.. there might be cases where the same controller in one soc needs PHY control and in some other soc does not need PHY control. In such cases, we might get error pointer here. I'll change WARN to dev_err. + +if (!pm_runtime_enabled(phy-dev)) +return -ENOTSUPP; + +return pm_runtime_get(phy-dev); +} This, and the other inline functions in this .h file seem huge, why are they inline and not in the .c file? There's no speed issues, and it should save space overall in the .c file. Please move them. ok +static inline int phy_init(struct phy *phy) +{ +int ret; + +ret = phy_pm_runtime_get_sync(phy); +if (ret 0 ret != -ENOTSUPP) +return ret; + +mutex_lock(phy-mutex); +if (phy-init_count++ == 0 phy-ops-init) { +ret = phy-ops-init(phy); +if (ret 0) { +dev_err(phy-dev, phy init failed -- %d\n, ret); +goto out; +} +} + +out: +mutex_unlock(phy-mutex); +phy_pm_runtime_put(phy); +return ret; +} + +static inline int phy_exit(struct phy *phy) +{ +int ret; + +ret = phy_pm_runtime_get_sync(phy); +if (ret 0 ret != -ENOTSUPP
Re: [PATCH 02/15] usb: phy: omap-usb2: use the new generic PHY framework
On Thursday 18 July 2013 12:51 PM, Greg KH wrote: On Thu, Jul 18, 2013 at 12:16:11PM +0530, Kishon Vijay Abraham I wrote: Used the generic PHY framework API to create the PHY. Now the power off and power on are done in omap_usb_power_off and omap_usb_power_on respectively. However using the old USB PHY library cannot be completely removed because OTG is intertwined with PHY and moving to the new framework will break OTG. Once we have a separate OTG state machine, we can get rid of the USB PHY library. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com Acked-by: Felipe Balbi ba...@ti.com --- drivers/usb/phy/Kconfig |1 + drivers/usb/phy/phy-omap-usb2.c | 45 +++ 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 3622fff..cc55993 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -75,6 +75,7 @@ config OMAP_CONTROL_USB config OMAP_USB2 tristate OMAP USB2 PHY Driver depends on ARCH_OMAP2PLUS +depends on GENERIC_PHY select OMAP_CONTROL_USB help Enable this to support the transceiver that is part of SOC. This diff --git a/drivers/usb/phy/phy-omap-usb2.c b/drivers/usb/phy/phy-omap-usb2.c index 844ab68..751b30f 100644 --- a/drivers/usb/phy/phy-omap-usb2.c +++ b/drivers/usb/phy/phy-omap-usb2.c @@ -28,6 +28,7 @@ #include linux/pm_runtime.h #include linux/delay.h #include linux/usb/omap_control_usb.h +#include linux/phy/phy.h /** * omap_usb2_set_comparator - links the comparator present in the sytem with @@ -119,10 +120,36 @@ static int omap_usb2_suspend(struct usb_phy *x, int suspend) return 0; } +static int omap_usb_power_off(struct phy *x) +{ +struct omap_usb *phy = phy_get_drvdata(x); + +omap_control_usb_phy_power(phy-control_dev, 0); + +return 0; +} + +static int omap_usb_power_on(struct phy *x) +{ +struct omap_usb *phy = phy_get_drvdata(x); + +omap_control_usb_phy_power(phy-control_dev, 1); + +return 0; +} + +static struct phy_ops ops = { +.power_on = omap_usb_power_on, +.power_off = omap_usb_power_off, +.owner = THIS_MODULE, +}; + static int omap_usb2_probe(struct platform_device *pdev) { struct omap_usb *phy; +struct phy *generic_phy; struct usb_otg *otg; +struct phy_provider *phy_provider; phy = devm_kzalloc(pdev-dev, sizeof(*phy), GFP_KERNEL); if (!phy) { @@ -144,6 +171,11 @@ static int omap_usb2_probe(struct platform_device *pdev) phy-phy.otg= otg; phy-phy.type = USB_PHY_TYPE_USB2; +phy_provider = devm_of_phy_provider_register(phy-dev, +of_phy_simple_xlate); +if (IS_ERR(phy_provider)) +return PTR_ERR(phy_provider); + phy-control_dev = omap_get_control_dev(); if (IS_ERR(phy-control_dev)) { dev_dbg(pdev-dev, Failed to get control device\n); @@ -159,6 +191,15 @@ static int omap_usb2_probe(struct platform_device *pdev) otg-start_srp = omap_usb_start_srp; otg-phy= phy-phy; +platform_set_drvdata(pdev, phy); +pm_runtime_enable(phy-dev); + +generic_phy = devm_phy_create(phy-dev, 0, ops, omap-usb2); +if (IS_ERR(generic_phy)) +return PTR_ERR(generic_phy); So, if I have two of these controllers in my system, I can't create the second phy because the name for it will be identical to the first? That's why the phy core should handle the id, and not rely on the drivers to set it, as they have no idea how many they have in the system. hmm.. for such cases I'll have something like PLATFORM_DEVID_AUTO. Thanks Kishon -- 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
Re: [PATCH 01/15] drivers: phy: add generic PHY framework
Hi, On Thursday 18 July 2013 09:19 PM, Greg KH wrote: On Thu, Jul 18, 2013 at 02:29:52PM +0530, Kishon Vijay Abraham I wrote: Hi, On Thursday 18 July 2013 12:50 PM, Greg KH wrote: On Thu, Jul 18, 2013 at 12:16:10PM +0530, Kishon Vijay Abraham I wrote: +struct phy_provider *__of_phy_provider_register(struct device *dev, + struct module *owner, struct phy * (*of_xlate)(struct device *dev, + struct of_phandle_args *args)); +struct phy_provider *__devm_of_phy_provider_register(struct device *dev, + struct module *owner, struct phy * (*of_xlate)(struct device *dev, + struct of_phandle_args *args)) + +__of_phy_provider_register and __devm_of_phy_provider_register can be used to +register the phy_provider and it takes device, owner and of_xlate as +arguments. For the dt boot case, all PHY providers should use one of the above +2 APIs to register the PHY provider. Why do you have __ for the prefix of a public function? Is that really the way that OF handles this type of thing? I have a macro of_phy_provider_register/devm_of_phy_provider_register that calls these functions and should be used by the PHY drivers. Probably I should make a mention of it in the Documentation. Yes, mention those as you never want to be calling __* functions directly, right? correct. + ret = dev_set_name(phy-dev, %s.%d, dev_name(dev), id); Your naming is odd, no phy anywhere in it? You rely on the sender to never send a duplicate name.id pair? Why not create your own ids based on the number of phys in the system, like almost all other classes and subsystems do? hmm.. some PHY drivers use the id they provide to perform some of their internal operation as in [1] (This is used only if a single PHY provider implements multiple PHYS). Probably I'll add an option like PLATFORM_DEVID_AUTO to give the PHY drivers an option to use auto id. [1] - http://archive.arm.linux.org.uk/lurker/message/20130628.134308.4a8f7668.ca.html No, who cares about the id? No one outside of the phy core ever should, because you pass back the only pointer that they really do care about, if they need to do anything with the device. Use that, and then you can hmm.. ok. rip out all of the search for a phy by a string logic, as that's not Actually this is needed for non-dt boot case. In the case of dt boot, we use a phandle by which the controller can get a reference to the phy. But in the case of non-dt boot, the controller can get a reference to the phy only by label. needed either. Just stick to the pointer, it's easier, and safer that way. +static inline int phy_pm_runtime_get(struct phy *phy) +{ + if (WARN(IS_ERR(phy), Invalid PHY reference\n)) + return -EINVAL; Why would phy ever not be valid and a error pointer? And why dump the stack if that happens, that seems really extreme. hmm.. there might be cases where the same controller in one soc needs PHY control and in some other soc does not need PHY control. In such cases, we might get error pointer here. I'll change WARN to dev_err. I still don't understand. You have control over the code that calls these functions, just ensure that they pass in a valid pointer, it's that simple. Or am I missing something? You are right. Valid pointer check can be done in controller code as well. Thanks Kishon -- 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
Re: [PATCH 01/15] drivers: phy: add generic PHY framework
Hi, On Friday 19 July 2013 11:13 AM, Greg KH wrote: On Fri, Jul 19, 2013 at 11:07:10AM +0530, Kishon Vijay Abraham I wrote: +ret = dev_set_name(phy-dev, %s.%d, dev_name(dev), id); Your naming is odd, no phy anywhere in it? You rely on the sender to never send a duplicate name.id pair? Why not create your own ids based on the number of phys in the system, like almost all other classes and subsystems do? hmm.. some PHY drivers use the id they provide to perform some of their internal operation as in [1] (This is used only if a single PHY provider implements multiple PHYS). Probably I'll add an option like PLATFORM_DEVID_AUTO to give the PHY drivers an option to use auto id. [1] - http://archive.arm.linux.org.uk/lurker/message/20130628.134308.4a8f7668.ca.html No, who cares about the id? No one outside of the phy core ever should, because you pass back the only pointer that they really do care about, if they need to do anything with the device. Use that, and then you can hmm.. ok. rip out all of the search for a phy by a string logic, as that's not Actually this is needed for non-dt boot case. In the case of dt boot, we use a phandle by which the controller can get a reference to the phy. But in the case of non-dt boot, the controller can get a reference to the phy only by label. I don't understand. They registered the phy, and got back a pointer to it. Why can't they save it in their local structure to use it again later if needed? They should never have to ask for the device, as the One is a *PHY provider* driver which is a driver for some PHY device. This will use phy_create to create the phy. The other is a *PHY consumer* driver which might be any controller driver (can be USB/SATA/PCIE). The PHY consumer will use phy_get to get a reference to the phy (by *phandle* in the case of dt boot and *label* in the case of non-dt boot). device id might be unknown if there are multiple devices in the system. I agree with you on the device id part. That need not be known to the PHY driver. Thanks Kishon -- 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
Re: [PATCH V3 3/3] video: exynos_dp: Use the generic PHY driver
Hi, On Monday 01 July 2013 10:54 AM, Jingoo Han wrote: Use the generic PHY API instead of the platform callback to control the DP PHY. The 'phy_label' field is added to the platform data structure to allow PHY lookup on non-dt platforms. Signed-off-by: Jingoo Han jg1@samsung.com Acked-by: Felipe Balbi ba...@ti.com --- .../devicetree/bindings/video/exynos_dp.txt| 23 +--- drivers/video/exynos/exynos_dp_core.c | 118 ++-- drivers/video/exynos/exynos_dp_core.h |2 + include/video/exynos_dp.h |6 +- 4 files changed, 21 insertions(+), 128 deletions(-) diff --git a/Documentation/devicetree/bindings/video/exynos_dp.txt b/Documentation/devicetree/bindings/video/exynos_dp.txt index 84f10c1..71645dc 100644 --- a/Documentation/devicetree/bindings/video/exynos_dp.txt +++ b/Documentation/devicetree/bindings/video/exynos_dp.txt @@ -1,17 +1,6 @@ The Exynos display port interface should be configured based on the type of panel connected to it. -We use two nodes: - -dp-controller node - -dptx-phy node(defined inside dp-controller node) - -For the DP-PHY initialization, we use the dptx-phy node. -Required properties for dptx-phy: - -reg: - Base address of DP PHY register. - -samsung,enable-mask: - The bit-mask used to enable/disable DP PHY. - For the Panel initialization, we read data from dp-controller node. Required properties for dp-controller: -compatible: @@ -25,6 +14,10 @@ Required properties for dp-controller: from common clock binding: handle to dp clock. -clock-names: from common clock binding: Shall be dp. + -phys: + from general phy binding: the phandle for the PHY device. + -phy-names: + from general phy binding: Should be dp. -interrupt-parent: phandle to Interrupt combiner node. -samsung,color-space: @@ -67,12 +60,8 @@ SOC specific portion: interrupt-parent = combiner; clocks = clock 342; clock-names = dp; - - dptx-phy { - reg = 0x10040720; - samsung,enable-mask = 1; - }; - + phys = dp_phy; + phy-names = dp; }; Board Specific portion: diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c index 12bbede..bac515b 100644 --- a/drivers/video/exynos/exynos_dp_core.c +++ b/drivers/video/exynos/exynos_dp_core.c @@ -19,6 +19,7 @@ #include linux/interrupt.h #include linux/delay.h #include linux/of.h +#include linux/phy/phy.h #include video/exynos_dp.h @@ -960,84 +961,15 @@ static struct exynos_dp_platdata *exynos_dp_dt_parse_pdata(struct device *dev) return ERR_PTR(-EINVAL); } - return pd; -} - -static int exynos_dp_dt_parse_phydata(struct exynos_dp_device *dp) -{ - struct device_node *dp_phy_node = of_node_get(dp-dev-of_node); - u32 phy_base; - int ret = 0; - - dp_phy_node = of_find_node_by_name(dp_phy_node, dptx-phy); - if (!dp_phy_node) { - dev_err(dp-dev, could not find dptx-phy node\n); - return -ENODEV; - } - - if (of_property_read_u32(dp_phy_node, reg, phy_base)) { - dev_err(dp-dev, failed to get reg for dptx-phy\n); - ret = -EINVAL; - goto err; - } - - if (of_property_read_u32(dp_phy_node, samsung,enable-mask, - dp-enable_mask)) { - dev_err(dp-dev, failed to get enable-mask for dptx-phy\n); - ret = -EINVAL; - goto err; - } - - dp-phy_addr = ioremap(phy_base, SZ_4); - if (!dp-phy_addr) { - dev_err(dp-dev, failed to ioremap dp-phy\n); - ret = -ENOMEM; - goto err; - } - -err: - of_node_put(dp_phy_node); - - return ret; -} - -static void exynos_dp_phy_init(struct exynos_dp_device *dp) -{ - u32 reg; - - reg = __raw_readl(dp-phy_addr); - reg |= dp-enable_mask; - __raw_writel(reg, dp-phy_addr); -} - -static void exynos_dp_phy_exit(struct exynos_dp_device *dp) -{ - u32 reg; + pd-phy_label = dp; Felipe had a comment to change the label to *display-port* no? Thanks Kishon -- 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
Re: [PATCH v3 1/5] phy: Add driver for Exynos MIPI CSIS/DSIM DPHYs
Hi, On Sunday 30 June 2013 01:04 AM, Sylwester Nawrocki wrote: Hi, On 06/29/2013 10:57 AM, Kishon Vijay Abraham I wrote: On Friday 28 June 2013 03:41 PM, Sylwester Nawrocki wrote: On 06/28/2013 10:17 AM, Hui Wang wrote: On 06/26/2013 11:02 PM, Sylwester Nawrocki wrote: Add a PHY provider driver for the Samsung S5P/Exynos SoC MIPI CSI-2 receiver and MIPI DSI transmitter DPHYs. Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- Changes since v2: - adapted to the generic PHY API v9: use phy_set/get_drvdata(), - fixed of_xlate callback to return ERR_PTR() instead of NULL, - namespace cleanup, put GPL v2 as MODULE_LICENSE, removed pr_debug, - removed phy id check in __set_phy_state(). --- [...] + + if (IS_EXYNOS_MIPI_DSIM_PHY_ID(id)) + reset = EXYNOS_MIPI_PHY_MRESETN; + else + reset = EXYNOS_MIPI_PHY_SRESETN; + + spin_lock_irqsave(state-slock, flags); Sorry for one stupid question here, why do you use spin_lock_irqsave() rather than spin_lock(), I don't see the irq handler will use this spinlock anywhere in this c file. Yes, there is no chance the PHY users could call the phy ops from within an interrupt context. Especially now when there is a per phy object mutex used in the PHY operation helpers. So I'll replace it with plain spin_lock/unlock. Thank you for the review. Now that PHY ops is already protected, do you really need a spin_lock here? It is still needed, to synchronize access to the control register from two separate PHY objects. The mutex is per PHY object, while the spinlock is per PHY provider. Ok. Makes sense. Thanks Kishon -- 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
Re: [PATCH v3 1/5] phy: Add driver for Exynos MIPI CSIS/DSIM DPHYs
Hi, On Friday 28 June 2013 03:41 PM, Sylwester Nawrocki wrote: On 06/28/2013 10:17 AM, Hui Wang wrote: On 06/26/2013 11:02 PM, Sylwester Nawrocki wrote: Add a PHY provider driver for the Samsung S5P/Exynos SoC MIPI CSI-2 receiver and MIPI DSI transmitter DPHYs. Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- Changes since v2: - adapted to the generic PHY API v9: use phy_set/get_drvdata(), - fixed of_xlate callback to return ERR_PTR() instead of NULL, - namespace cleanup, put GPL v2 as MODULE_LICENSE, removed pr_debug, - removed phy id check in __set_phy_state(). --- [...] + + if (IS_EXYNOS_MIPI_DSIM_PHY_ID(id)) + reset = EXYNOS_MIPI_PHY_MRESETN; + else + reset = EXYNOS_MIPI_PHY_SRESETN; + + spin_lock_irqsave(state-slock, flags); Sorry for one stupid question here, why do you use spin_lock_irqsave() rather than spin_lock(), I don't see the irq handler will use this spinlock anywhere in this c file. Yes, there is no chance the PHY users could call the phy ops from within an interrupt context. Especially now when there is a per phy object mutex used in the PHY operation helpers. So I'll replace it with plain spin_lock/unlock. Thank you for the review. Now that PHY ops is already protected, do you really need a spin_lock here? Thanks Kishon -- 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
Re: [PATCH V2 1/3] phy: Add driver for Exynos DP PHY
Hi, On Friday 28 June 2013 12:45 PM, Jingoo Han wrote: Add a PHY provider driver for the Samsung Exynos SoC DP PHY. Signed-off-by: Jingoo Han jg1@samsung.com --- .../phy/samsung,exynos5250-dp-video-phy.txt|7 ++ drivers/phy/Kconfig|8 ++ drivers/phy/Makefile |3 +- drivers/phy/phy-exynos-dp-video.c | 122 4 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/phy/samsung,exynos5250-dp-video-phy.txt create mode 100644 drivers/phy/phy-exynos-dp-video.c diff --git a/Documentation/devicetree/bindings/phy/samsung,exynos5250-dp-video-phy.txt b/Documentation/devicetree/bindings/phy/samsung,exynos5250-dp-video-phy.txt new file mode 100644 index 000..d1771ef --- /dev/null +++ b/Documentation/devicetree/bindings/phy/samsung,exynos5250-dp-video-phy.txt @@ -0,0 +1,7 @@ +Samsung EXYNOS SoC series DP PHY +- + +Required properties: +- compatible : should be samsung,exynos5250-dp-video-phy; +- reg : offset and length of the DP PHY register set; +- #phy-cells : from the generic phy bindings, must be 0; diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 5f85909..6d10e3b 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -11,3 +11,11 @@ menuconfig GENERIC_PHY devices present in the kernel. This layer will have the generic API by which phy drivers can create PHY using the phy framework and phy users can obtain reference to the PHY. + +if GENERIC_PHY + +config PHY_EXYNOS_DP_VIDEO + tristate EXYNOS SoC series DP PHY driver + help + Support for DP PHY found on Samsung EXYNOS SoCs. +endif diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 9e9560f..d8d861c 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -2,4 +2,5 @@ # Makefile for the phy drivers. # -obj-$(CONFIG_GENERIC_PHY) += phy-core.o +obj-$(CONFIG_GENERIC_PHY) += phy-core.o +obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO) += phy-exynos-dp-video.o diff --git a/drivers/phy/phy-exynos-dp-video.c b/drivers/phy/phy-exynos-dp-video.c new file mode 100644 index 000..9a3d6f1 --- /dev/null +++ b/drivers/phy/phy-exynos-dp-video.c @@ -0,0 +1,122 @@ +/* + * Samsung EXYNOS SoC series DP PHY driver + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Jingoo Han jg1@samsung.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include linux/io.h +#include linux/kernel.h +#include linux/module.h +#include linux/of.h +#include linux/of_address.h +#include linux/phy/phy.h +#include linux/platform_device.h +#include linux/spinlock.h + +/* DPTX_PHY_CONTROL register */ +#define EXYNOS_DPTX_PHY_ENABLE (1 0) + +struct exynos_dp_video_phy { + spinlock_t slock; I think spinlock is not needed at all since the PHY ops is already protected by a mutex. + struct phy *phys; _phys_ no longer need to part of this structure. + void __iomem *regs; +}; Thanks Kishon -- 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
Re: [PATCH 1/3] phy: Add driver for Exynos DP PHY
Hi, On Friday 28 June 2013 11:24 AM, Jingoo Han wrote: On Friday, June 28, 2013 2:31 PM, Kishon Vijay Abraham I wrote: Hi, On Friday 28 June 2013 10:52 AM, Jingoo Han wrote: Add a PHY provider driver for the Samsung Exynos SoC DP PHY. Signed-off-by: Jingoo Han jg1@samsung.com --- .../phy/samsung,exynos5250-dp-video-phy.txt|7 ++ drivers/phy/Kconfig|8 ++ drivers/phy/Makefile |3 +- drivers/phy/phy-exynos-dp-video.c | 130 4 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/phy/samsung,exynos5250-dp-video-phy.txt create mode 100644 drivers/phy/phy-exynos-dp-video.c diff --git a/Documentation/devicetree/bindings/phy/samsung,exynos5250-dp-video-phy.txt b/Documentation/devicetree/bindings/phy/samsung,exynos5250-dp-video-phy.txt new file mode 100644 index 000..8b6fa79 --- /dev/null +++ b/Documentation/devicetree/bindings/phy/samsung,exynos5250-dp-video-phy.txt @@ -0,0 +1,7 @@ +Samsung EXYNOS SoC series DP PHY +- + +Required properties: +- compatible : should be samsung,exynos5250-dp-video-phy; +- reg : offset and length of the DP PHY register set; +- #phy-cells : from the generic phy bindings, must be 1; diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 5f85909..6d10e3b 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -11,3 +11,11 @@ menuconfig GENERIC_PHY devices present in the kernel. This layer will have the generic API by which phy drivers can create PHY using the phy framework and phy users can obtain reference to the PHY. + +if GENERIC_PHY + +config PHY_EXYNOS_DP_VIDEO + tristate EXYNOS SoC series DP PHY driver + help + Support for DP PHY found on Samsung EXYNOS SoCs. +endif diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 9e9560f..d8d861c 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -2,4 +2,5 @@ # Makefile for the phy drivers. # -obj-$(CONFIG_GENERIC_PHY) += phy-core.o +obj-$(CONFIG_GENERIC_PHY) += phy-core.o +obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO) += phy-exynos-dp-video.o diff --git a/drivers/phy/phy-exynos-dp-video.c b/drivers/phy/phy-exynos-dp-video.c new file mode 100644 index 000..376b3bc2 --- /dev/null +++ b/drivers/phy/phy-exynos-dp-video.c @@ -0,0 +1,130 @@ +/* + * Samsung EXYNOS SoC series DP PHY driver + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Jingoo Han jg1@samsung.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include linux/delay.h this header file is not needed here. OK, I will remove it. +#include linux/io.h +#include linux/kernel.h +#include linux/module.h +#include linux/of.h +#include linux/of_address.h +#include linux/phy/phy.h +#include linux/platform_device.h +#include linux/spinlock.h + +/* DPTX_PHY_CONTROL register */ +#define EXYNOS_DPTX_PHY_ENABLE (1 0) + +struct exynos_dp_video_phy { + spinlock_t slock; + struct phy *phys; + void __iomem *regs; +}; + +static int __set_phy_state(struct exynos_dp_video_phy *state, unsigned int on) +{ + void __iomem *addr; + unsigned long flags; + u32 reg; + + addr = state-regs; + + spin_lock_irqsave(state-slock, flags); + reg = readl(addr); + if (on) + reg |= EXYNOS_DPTX_PHY_ENABLE; + else + reg = ~EXYNOS_DPTX_PHY_ENABLE; + writel(reg, addr); + spin_unlock_irqrestore(state-slock, flags); + return 0; +} + +static int exynos_dp_video_phy_power_on(struct phy *phy) +{ + struct exynos_dp_video_phy *state = phy_get_drvdata(phy); + + return __set_phy_state(state, 1); +} + +static int exynos_dp_video_phy_power_off(struct phy *phy) +{ + struct exynos_dp_video_phy *state = phy_get_drvdata(phy); + + return __set_phy_state(state, 0); +} + +static struct phy *exynos_dp_video_phy_xlate(struct device *dev, + struct of_phandle_args *args) +{ + struct exynos_dp_video_phy *state = dev_get_drvdata(dev); + + return state-phys; you can instead use of_phy_simple_xlate for such simple cases. OK, I will use of_phy_simple_xlate(). +} + +static struct phy_ops exynos_dp_video_phy_ops = { + .power_on = exynos_dp_video_phy_power_on, + .power_off = exynos_dp_video_phy_power_off, + .owner = THIS_MODULE, +}; + +static int exynos_dp_video_phy_probe(struct platform_device *pdev) +{ + struct exynos_dp_video_phy *state; + struct device *dev = pdev-dev; + struct resource *res; + struct phy_provider *phy_provider; + + state = devm_kzalloc
Re: [PATCH 3/3] video: exynos_dp: Use the generic PHY driver
Hi, On Friday 28 June 2013 11:34 AM, Jingoo Han wrote: On Friday, June 28, 2013 2:58 PM, Kishon Vijay Abraham I wrote: Hi, On Friday 28 June 2013 10:54 AM, Jingoo Han wrote: Use the generic PHY API instead of the platform callback to control the DP PHY. The 'phy_label' field is added to the platform data structure to allow PHY lookup on non-dt platforms. Signed-off-by: Jingoo Han jg1@samsung.com --- .../devicetree/bindings/video/exynos_dp.txt| 17 --- drivers/video/exynos/exynos_dp_core.c | 118 ++-- drivers/video/exynos/exynos_dp_core.h |2 + include/video/exynos_dp.h |6 +- 4 files changed, 15 insertions(+), 128 deletions(-) diff --git a/Documentation/devicetree/bindings/video/exynos_dp.txt b/Documentation/devicetree/bindings/video/exynos_dp.txt index 84f10c1..a8320e3 100644 --- a/Documentation/devicetree/bindings/video/exynos_dp.txt +++ b/Documentation/devicetree/bindings/video/exynos_dp.txt @@ -1,17 +1,6 @@ The Exynos display port interface should be configured based on the type of panel connected to it. -We use two nodes: - -dp-controller node - -dptx-phy node(defined inside dp-controller node) - -For the DP-PHY initialization, we use the dptx-phy node. -Required properties for dptx-phy: - -reg: - Base address of DP PHY register. - -samsung,enable-mask: - The bit-mask used to enable/disable DP PHY. - For the Panel initialization, we read data from dp-controller node. Required properties for dp-controller: -compatible: @@ -67,12 +56,6 @@ SOC specific portion: interrupt-parent = combiner; clocks = clock 342; clock-names = dp; - - dptx-phy { - reg = 0x10040720; - samsung,enable-mask = 1; - }; - }; Board Specific portion: diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c index 12bbede..bac515b 100644 --- a/drivers/video/exynos/exynos_dp_core.c +++ b/drivers/video/exynos/exynos_dp_core.c @@ -19,6 +19,7 @@ #include linux/interrupt.h #include linux/delay.h #include linux/of.h +#include linux/phy/phy.h #include video/exynos_dp.h @@ -960,84 +961,15 @@ static struct exynos_dp_platdata *exynos_dp_dt_parse_pdata(struct device *dev) return ERR_PTR(-EINVAL); } - return pd; -} - -static int exynos_dp_dt_parse_phydata(struct exynos_dp_device *dp) -{ - struct device_node *dp_phy_node = of_node_get(dp-dev-of_node); - u32 phy_base; - int ret = 0; - - dp_phy_node = of_find_node_by_name(dp_phy_node, dptx-phy); - if (!dp_phy_node) { - dev_err(dp-dev, could not find dptx-phy node\n); - return -ENODEV; - } - - if (of_property_read_u32(dp_phy_node, reg, phy_base)) { - dev_err(dp-dev, failed to get reg for dptx-phy\n); - ret = -EINVAL; - goto err; - } - - if (of_property_read_u32(dp_phy_node, samsung,enable-mask, - dp-enable_mask)) { - dev_err(dp-dev, failed to get enable-mask for dptx-phy\n); - ret = -EINVAL; - goto err; - } - - dp-phy_addr = ioremap(phy_base, SZ_4); - if (!dp-phy_addr) { - dev_err(dp-dev, failed to ioremap dp-phy\n); - ret = -ENOMEM; - goto err; - } - -err: - of_node_put(dp_phy_node); - - return ret; -} - -static void exynos_dp_phy_init(struct exynos_dp_device *dp) -{ - u32 reg; - - reg = __raw_readl(dp-phy_addr); - reg |= dp-enable_mask; - __raw_writel(reg, dp-phy_addr); -} - -static void exynos_dp_phy_exit(struct exynos_dp_device *dp) -{ - u32 reg; + pd-phy_label = dp; In the case of non-dt boot, this phy_label should have ideally come from platform code. No, this is NOT the case of non-dt. 'pd-phy_label = dp;' is included in exynos_dp_dt_parse_pdata(), not exynos_dp_phy_exit(). Also, exynos_dp_dt_parse_pdata() is called in the case of dt. ah.. right. Do you support non-dt boot. I dont see any modifications in the platform code? Thanks Kishon -- 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
Re: [PATCH 1/3] phy: Add driver for Exynos DP PHY
Hi, On Friday 28 June 2013 10:52 AM, Jingoo Han wrote: Add a PHY provider driver for the Samsung Exynos SoC DP PHY. Signed-off-by: Jingoo Han jg1@samsung.com --- .../phy/samsung,exynos5250-dp-video-phy.txt|7 ++ drivers/phy/Kconfig|8 ++ drivers/phy/Makefile |3 +- drivers/phy/phy-exynos-dp-video.c | 130 4 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/phy/samsung,exynos5250-dp-video-phy.txt create mode 100644 drivers/phy/phy-exynos-dp-video.c diff --git a/Documentation/devicetree/bindings/phy/samsung,exynos5250-dp-video-phy.txt b/Documentation/devicetree/bindings/phy/samsung,exynos5250-dp-video-phy.txt new file mode 100644 index 000..8b6fa79 --- /dev/null +++ b/Documentation/devicetree/bindings/phy/samsung,exynos5250-dp-video-phy.txt How about creating a single Documentation file for all samsung video phys? Sylwester? Thanks Kishon -- 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
Re: [PATCH 1/3] phy: Add driver for Exynos DP PHY
Hi, On Friday 28 June 2013 10:52 AM, Jingoo Han wrote: Add a PHY provider driver for the Samsung Exynos SoC DP PHY. Signed-off-by: Jingoo Han jg1@samsung.com --- .../phy/samsung,exynos5250-dp-video-phy.txt|7 ++ drivers/phy/Kconfig|8 ++ drivers/phy/Makefile |3 +- drivers/phy/phy-exynos-dp-video.c | 130 4 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/phy/samsung,exynos5250-dp-video-phy.txt create mode 100644 drivers/phy/phy-exynos-dp-video.c diff --git a/Documentation/devicetree/bindings/phy/samsung,exynos5250-dp-video-phy.txt b/Documentation/devicetree/bindings/phy/samsung,exynos5250-dp-video-phy.txt new file mode 100644 index 000..8b6fa79 --- /dev/null +++ b/Documentation/devicetree/bindings/phy/samsung,exynos5250-dp-video-phy.txt @@ -0,0 +1,7 @@ +Samsung EXYNOS SoC series DP PHY +- + +Required properties: +- compatible : should be samsung,exynos5250-dp-video-phy; +- reg : offset and length of the DP PHY register set; +- #phy-cells : from the generic phy bindings, must be 1; diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 5f85909..6d10e3b 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -11,3 +11,11 @@ menuconfig GENERIC_PHY devices present in the kernel. This layer will have the generic API by which phy drivers can create PHY using the phy framework and phy users can obtain reference to the PHY. + +if GENERIC_PHY + +config PHY_EXYNOS_DP_VIDEO + tristate EXYNOS SoC series DP PHY driver + help + Support for DP PHY found on Samsung EXYNOS SoCs. +endif diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 9e9560f..d8d861c 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -2,4 +2,5 @@ # Makefile for the phy drivers. # -obj-$(CONFIG_GENERIC_PHY) += phy-core.o +obj-$(CONFIG_GENERIC_PHY) += phy-core.o +obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO) += phy-exynos-dp-video.o diff --git a/drivers/phy/phy-exynos-dp-video.c b/drivers/phy/phy-exynos-dp-video.c new file mode 100644 index 000..376b3bc2 --- /dev/null +++ b/drivers/phy/phy-exynos-dp-video.c @@ -0,0 +1,130 @@ +/* + * Samsung EXYNOS SoC series DP PHY driver + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Jingoo Han jg1@samsung.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include linux/delay.h this header file is not needed here. +#include linux/io.h +#include linux/kernel.h +#include linux/module.h +#include linux/of.h +#include linux/of_address.h +#include linux/phy/phy.h +#include linux/platform_device.h +#include linux/spinlock.h + +/* DPTX_PHY_CONTROL register */ +#define EXYNOS_DPTX_PHY_ENABLE (1 0) + +struct exynos_dp_video_phy { + spinlock_t slock; + struct phy *phys; + void __iomem *regs; +}; + +static int __set_phy_state(struct exynos_dp_video_phy *state, unsigned int on) +{ + void __iomem *addr; + unsigned long flags; + u32 reg; + + addr = state-regs; + + spin_lock_irqsave(state-slock, flags); + reg = readl(addr); + if (on) + reg |= EXYNOS_DPTX_PHY_ENABLE; + else + reg = ~EXYNOS_DPTX_PHY_ENABLE; + writel(reg, addr); + spin_unlock_irqrestore(state-slock, flags); + return 0; +} + +static int exynos_dp_video_phy_power_on(struct phy *phy) +{ + struct exynos_dp_video_phy *state = phy_get_drvdata(phy); + + return __set_phy_state(state, 1); +} + +static int exynos_dp_video_phy_power_off(struct phy *phy) +{ + struct exynos_dp_video_phy *state = phy_get_drvdata(phy); + + return __set_phy_state(state, 0); +} + +static struct phy *exynos_dp_video_phy_xlate(struct device *dev, + struct of_phandle_args *args) +{ + struct exynos_dp_video_phy *state = dev_get_drvdata(dev); + + return state-phys; you can instead use of_phy_simple_xlate for such simple cases. +} + +static struct phy_ops exynos_dp_video_phy_ops = { + .power_on = exynos_dp_video_phy_power_on, + .power_off = exynos_dp_video_phy_power_off, + .owner = THIS_MODULE, +}; + +static int exynos_dp_video_phy_probe(struct platform_device *pdev) +{ + struct exynos_dp_video_phy *state; + struct device *dev = pdev-dev; + struct resource *res; + struct phy_provider *phy_provider; + + state = devm_kzalloc(dev, sizeof(*state), GFP_KERNEL); + if (!state) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + + state-regs = devm_ioremap_resource(dev,
Re: [PATCH 2/3] ARM: dts: Add DP PHY node to exynos5250.dtsi
Hi, On Friday 28 June 2013 10:53 AM, Jingoo Han wrote: Add PHY provider node for the DP PHY. Signed-off-by: Jingoo Han jg1@samsung.com --- arch/arm/boot/dts/exynos5250.dtsi | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi index 41cd625..d1d6e14 100644 --- a/arch/arm/boot/dts/exynos5250.dtsi +++ b/arch/arm/boot/dts/exynos5250.dtsi @@ -614,6 +614,12 @@ interrupts = 0 94 0; }; + dp_phy: video-phy@10040720 { + compatible = samsung,exynos5250-dp-video-phy; + reg = 0x10040720 4; + #phy-cells = 1; phy-cells can be '0' here since this phy_provider implements only one PHY. Thanks Kishon -- 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
Re: [PATCH 3/3] video: exynos_dp: Use the generic PHY driver
Hi, On Friday 28 June 2013 10:54 AM, Jingoo Han wrote: Use the generic PHY API instead of the platform callback to control the DP PHY. The 'phy_label' field is added to the platform data structure to allow PHY lookup on non-dt platforms. Signed-off-by: Jingoo Han jg1@samsung.com --- .../devicetree/bindings/video/exynos_dp.txt| 17 --- drivers/video/exynos/exynos_dp_core.c | 118 ++-- drivers/video/exynos/exynos_dp_core.h |2 + include/video/exynos_dp.h |6 +- 4 files changed, 15 insertions(+), 128 deletions(-) diff --git a/Documentation/devicetree/bindings/video/exynos_dp.txt b/Documentation/devicetree/bindings/video/exynos_dp.txt index 84f10c1..a8320e3 100644 --- a/Documentation/devicetree/bindings/video/exynos_dp.txt +++ b/Documentation/devicetree/bindings/video/exynos_dp.txt @@ -1,17 +1,6 @@ The Exynos display port interface should be configured based on the type of panel connected to it. -We use two nodes: - -dp-controller node - -dptx-phy node(defined inside dp-controller node) - -For the DP-PHY initialization, we use the dptx-phy node. -Required properties for dptx-phy: - -reg: - Base address of DP PHY register. - -samsung,enable-mask: - The bit-mask used to enable/disable DP PHY. - For the Panel initialization, we read data from dp-controller node. Required properties for dp-controller: -compatible: @@ -67,12 +56,6 @@ SOC specific portion: interrupt-parent = combiner; clocks = clock 342; clock-names = dp; - - dptx-phy { - reg = 0x10040720; - samsung,enable-mask = 1; - }; - }; Board Specific portion: diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c index 12bbede..bac515b 100644 --- a/drivers/video/exynos/exynos_dp_core.c +++ b/drivers/video/exynos/exynos_dp_core.c @@ -19,6 +19,7 @@ #include linux/interrupt.h #include linux/delay.h #include linux/of.h +#include linux/phy/phy.h #include video/exynos_dp.h @@ -960,84 +961,15 @@ static struct exynos_dp_platdata *exynos_dp_dt_parse_pdata(struct device *dev) return ERR_PTR(-EINVAL); } - return pd; -} - -static int exynos_dp_dt_parse_phydata(struct exynos_dp_device *dp) -{ - struct device_node *dp_phy_node = of_node_get(dp-dev-of_node); - u32 phy_base; - int ret = 0; - - dp_phy_node = of_find_node_by_name(dp_phy_node, dptx-phy); - if (!dp_phy_node) { - dev_err(dp-dev, could not find dptx-phy node\n); - return -ENODEV; - } - - if (of_property_read_u32(dp_phy_node, reg, phy_base)) { - dev_err(dp-dev, failed to get reg for dptx-phy\n); - ret = -EINVAL; - goto err; - } - - if (of_property_read_u32(dp_phy_node, samsung,enable-mask, - dp-enable_mask)) { - dev_err(dp-dev, failed to get enable-mask for dptx-phy\n); - ret = -EINVAL; - goto err; - } - - dp-phy_addr = ioremap(phy_base, SZ_4); - if (!dp-phy_addr) { - dev_err(dp-dev, failed to ioremap dp-phy\n); - ret = -ENOMEM; - goto err; - } - -err: - of_node_put(dp_phy_node); - - return ret; -} - -static void exynos_dp_phy_init(struct exynos_dp_device *dp) -{ - u32 reg; - - reg = __raw_readl(dp-phy_addr); - reg |= dp-enable_mask; - __raw_writel(reg, dp-phy_addr); -} - -static void exynos_dp_phy_exit(struct exynos_dp_device *dp) -{ - u32 reg; + pd-phy_label = dp; In the case of non-dt boot, this phy_label should have ideally come from platform code. Thanks Kishon -- 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
Re: [PATCH v2 1/5] phy: Add driver for Exynos MIPI CSIS/DSIM DPHYs
Hi, On Wednesday 26 June 2013 02:24 AM, Felipe Balbi wrote: Hi, On Tue, Jun 25, 2013 at 07:44:52PM +0200, Sylwester Nawrocki wrote: +struct exynos_video_phy { + spinlock_t slock; + struct phy *phys[NUM_PHYS]; more than one phy ? This means you should instantiate driver multiple drivers. Each phy id should call probe again. Why ? This single PHY _provider_ can well handle multiple PHYs. I don't see a good reason to further complicate this driver like this. Please note that MIPI-CSIS 0 and MIPI DSIM 0 share MMIO register, so does MIPI CSIS 1 and MIPI DSIM 1. There are only 2 registers for those 4 PHYs. I could have the involved object multiplied, but it would have been just a waste of resources with no difference to the PHY consumers. alright, I misunderstood your code then. When I looked over your id usage I missed the /2 part and assumed that you would have separate EXYNOS_MIPI_PHY_CONTROL() register for each ;-) My bad, you can disregard the other comments. +static int exynos_video_phy_probe(struct platform_device *pdev) +{ + struct exynos_video_phy *state; + struct device *dev = pdev-dev; + struct resource *res; + struct phy_provider *phy_provider; + int i; + + state = devm_kzalloc(dev, sizeof(*state), GFP_KERNEL); + if (!state) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + + state-regs = devm_ioremap_resource(dev, res); + if (IS_ERR(state-regs)) + return PTR_ERR(state-regs); + + dev_set_drvdata(dev, state); you can use platform_set_drvdata(pdev, state); I had it in the previous version, but changed for symmetry with dev_set_drvdata(). I guess those could be replaced with phy_{get, set}_drvdata as you suggested. right. currently I was setting dev_set_drvdata of phy (core) device in phy-core.c and the corresponding dev_get_drvdata in phy provider driver which is little confusing. So I'll add phy_set_drvdata and phy_get_drvdata in phy.h (as suggested by Felipe) to be used by phy provider drivers. So after creating the PHY, the phy provider should use phy_set_drvdata and in phy_ops, it can use phy_get_drvdata. (I'll remove the dev_set_drvdata in phy_create). This also means _void *priv_ in phy_create is useless. So I'll be removing _priv_ from phy_create. Thanks Kishon hmm, you do need to set the drvdata() to the phy object, but also to the pdev object (should you need it on a suspend/resume callback, for instance). Those are separate struct device instances. -- 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
Re: [PATCH v2 1/5] phy: Add driver for Exynos MIPI CSIS/DSIM DPHYs
On Wednesday 26 June 2013 05:33 PM, Sylwester Nawrocki wrote: On 06/26/2013 01:21 PM, Kishon Vijay Abraham I wrote: +static int exynos_video_phy_probe(struct platform_device *pdev) +{ + struct exynos_video_phy *state; + struct device *dev = pdev-dev; + struct resource *res; + struct phy_provider *phy_provider; + int i; + + state = devm_kzalloc(dev, sizeof(*state), GFP_KERNEL); + if (!state) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + + state-regs = devm_ioremap_resource(dev, res); + if (IS_ERR(state-regs)) + return PTR_ERR(state-regs); + + dev_set_drvdata(dev, state); you can use platform_set_drvdata(pdev, state); I had it in the previous version, but changed for symmetry with dev_set_drvdata(). I guess those could be replaced with phy_{get, set}_drvdata as you suggested. right. currently I was setting dev_set_drvdata of phy (core) device in phy-core.c and the corresponding dev_get_drvdata in phy provider driver which is little confusing. So I'll add phy_set_drvdata and phy_get_drvdata in phy.h (as suggested by Felipe) to be used by phy provider drivers. So after creating the PHY, the phy provider should use phy_set_drvdata and in phy_ops, it can use phy_get_drvdata. (I'll remove the dev_set_drvdata in phy_create). This also means _void *priv_ in phy_create is useless. So I'll be removing _priv_ from phy_create. Yeah, sounds good. Then in the phy ops phy_get_drvdata(phy-dev) would be used and in a custom of_xlate dev_get_drvdata(dev) (assuming the phy provider sets drvdata on its device beforehand). thats correct. btw when you send the next version just have MODULE_LICENSE set to GPL v2. Apart from that this patch looks good to me. Thanks Kishon -- 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
Re: [PATCH v2 1/5] phy: Add driver for Exynos MIPI CSIS/DSIM DPHYs
On Wednesday 26 June 2013 05:52 PM, Felipe Balbi wrote: On Wed, Jun 26, 2013 at 02:03:42PM +0200, Sylwester Nawrocki wrote: On 06/26/2013 01:21 PM, Kishon Vijay Abraham I wrote: +static int exynos_video_phy_probe(struct platform_device *pdev) +{ + struct exynos_video_phy *state; + struct device *dev = pdev-dev; + struct resource *res; + struct phy_provider *phy_provider; + int i; + + state = devm_kzalloc(dev, sizeof(*state), GFP_KERNEL); + if (!state) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + + state-regs = devm_ioremap_resource(dev, res); + if (IS_ERR(state-regs)) + return PTR_ERR(state-regs); + + dev_set_drvdata(dev, state); you can use platform_set_drvdata(pdev, state); I had it in the previous version, but changed for symmetry with dev_set_drvdata(). I guess those could be replaced with phy_{get, set}_drvdata as you suggested. right. currently I was setting dev_set_drvdata of phy (core) device in phy-core.c and the corresponding dev_get_drvdata in phy provider driver which is little confusing. So I'll add phy_set_drvdata and phy_get_drvdata in phy.h (as suggested by Felipe) to be used by phy provider drivers. So after creating the PHY, the phy provider should use phy_set_drvdata and in phy_ops, it can use phy_get_drvdata. (I'll remove the dev_set_drvdata in phy_create). This also means _void *priv_ in phy_create is useless. So I'll be removing _priv_ from phy_create. Yeah, sounds good. Then in the phy ops phy_get_drvdata(phy-dev) would phy_get_drvdata(phy); accessing the dev pointer will be done inside the helper :-) right :-) -Kishon -- 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
[no subject]
Dear linux-media team, The MSI Digi vox Trio DVB (usb) does not work on my 64bit linux (ubuntu 10.10)PC with kernel version 2.6.35-28-generic. It however works on a windows machine so the device is confirmed to work. The lsusb shows Bus 001 Device 006: ID eb1a:2885 eMPIA Technology,Inc. Search on google gives me an impression that some of the em28xx devices are supported. However the device I have,em2885, does not work. Is this device supported ? If yes, how can I make it work ? If not, will it be supported at later on. Cheers, Vinux -- 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