Skip to contentSkip to conversation

ARM: S5P64x0: Adding OTG PHY control code

RFC PATCH New Praveen Paneri 2 participants 4 messages Jun 22, 2011 – Jul 6, 2011 1 message not in the archive Arm Samsung Exynos

lore
Share & tools
lore
#1 lore raw

RFC PATCH 4/5 ARM: S5P64x0: Adding OTG PHY control code

In reply to a message not in the archive

Hi,

Quoted 52 lines · PRAVEEN PANERI

Hi,

Quoted 46 lines · p.paneri at samsung.com

From: Praveen Paneri

A generic method to initialize and exit OTG PHY which can be used for all the samsung SoCs.
OTG platdata structure added in platform to pass required platform specific functions and data to the driver.

Signed-off-by Praveen Paneri

---

??arch/arm/mach-s5p64x0/Makefile?????????? |????1 +
??arch/arm/mach-s5p64x0/include/mach/map.h |????4 +
??arch/arm/mach-s5p64x0/setup-otg-phy.c????|?? 89 ++++++++++++++++++++++++++++++
??arch/arm/plat-s5p/include/plat/otg.h???? |?? 29 ++++++++++

??4 files changed, 123 insertions(+), 0 deletions(-) ??create mode 100644 arch/arm/mach-s5p64x0/setup-otg-phy.c ??create mode 100644 arch/arm/plat-s5p/include/plat/otg.h

arch/arm/mach-s5p64x0/Makefile +0 -0
index ae6bf6f..611fb3a 100644
@@ -28,3 +28,4 @@ obj-y += dev-audio.o

??obj-$(CONFIG_S3C64XX_DEV_SPI) += dev-spi.o

??obj-$(CONFIG_S5P64X0_SETUP_I2C1) += setup-i2c1.o

arch/arm/mach-s5p64x0/Makefile +1 -0
+obj-$(CONFIG_S3C_DEV_DWC_OTG) += setup-otg-phy.o
arch/arm/mach-s5p64x0/include/mach/map.h +0 -0
index 95c9125..717c279 100644
@@ -44,6 +44,8 @@

??#define S5P64X0_PA_SPI1 0xEC500000

??#define S5P64X0_PA_HSOTG 0xED100000

arch/arm/mach-s5p64x0/include/mach/map.h +2 -0
+#define S5P64X0_PA_USB_HSPHY 0xED200000
+#define S5P64X0_VA_USB_HSPHY S3C_ADDR_CPU(0x00100000)

??#define S5P64X0_PA_HSMMC(x) (0xED800000 + ((x) * 0x100000))

arch/arm/mach-s5p64x0/include/mach/map.h +0 -0
@@ -71,6 +73,8 @@

??#define S5P_PA_TIMER S5P64X0_PA_TIMER

??#define SAMSUNG_PA_ADC S5P64X0_PA_ADC

arch/arm/mach-s5p64x0/include/mach/map.h +2 -0
+#define S3C_PA_USB_HSOTG S5P64X0_PA_HSOTG
+#define S3C_VA_USB_HSPHY????????S5P64X0_VA_USB_HSPHY
Quoted 6 lines

arch/arm/mach-s5p64x0/setup-otg-phy.c

Quoted 3 lines

??/* UART */

arch/arm/mach-s5p64x0/setup-otg-phy.c +0 -0

drivers should not live in arch/arm/*, why don't you move this to drivers/usb/otg where the PHYs are staying right now ?

PHY init/exit code can vary across SoCs. Wouldn't it be better to have it in the SoC specific location?

Quoted 98 lines
Quoted 85 lines

new file mode 100644
index 0000000..c351554

arch/arm/mach-s5p64x0/setup-otg-phy.c new file +79 -0
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2011 Samsung Electronics Co.Ltd
+ * Author: Praveen Paneri
+ * based on arch/arm/mach-exynos4/setup-usb-phy.c
+ * written by Joonyoung Shim
+ *
+ *??This program is free software; you can redistribute??it and/or modify it
+ *??under??the terms of??the GNU General??Public License as published by the
+ *??Free Software Foundation;??either version 2 of the??License, or (at your
+ *??option) any later version.
+ *
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+struct clk *otg_clk;
+static int s5p64x0_otg_phy_init(struct platform_device *pdev)
+{
+ int err;
+
+ otg_clk = clk_get(&pdev->dev, "otg");
+ if (IS_ERR(otg_clk)) {
+ dev_err(&pdev->dev, "Failed to get otg clock\n");
+ return PTR_ERR(otg_clk);
+ }
+
+ err = clk_enable(otg_clk);
+ if (err) {
+ clk_put(otg_clk);
+ return err;
+ }
+
+ if (gpio_is_valid(S5P6440_GPN(1))) {
+ err = gpio_request(S5P6440_GPN(1), "GPN");
+ if (err)
+ printk(KERN_ERR "failed to request GPN1\n");
+ gpio_direction_output(S5P6440_GPN(1), 1);
+ }
+
+ writel(readl(S5P64X0_OTHERS)&~S5P64X0_OTHERS_USB_SIG_MASK,
+ S5P64X0_OTHERS);
+ writel(0x0, S3C_PHYPWR);???????? /* Power up */
+ writel(S3C_PHYCLK_CLKSEL_12M, S3C_PHYCLK);
+ writel(S3C_RSTCON_PHY, S3C_RSTCON);
+
+ udelay(50);
+ writel(0x0, S3C_RSTCON);
+ udelay(50);
+
+ return 0;
+}
+
+static int s5p64x0_otg_phy_exit(struct platform_device *pdev)
+{
+ writel(readl(S3C_PHYPWR)|(0x1F<<1), S3C_PHYPWR);
+ writel(readl(S5P64X0_OTHERS)&~S5P64X0_OTHERS_USB_SIG_MASK,
+ S5P64X0_OTHERS);
+
+ gpio_free(S5P6440_GPN(1));
+
+ clk_disable(otg_clk);
+ clk_put(otg_clk);
+
+ return 0;
+}
+
+int s5p_usb_phy_init(struct platform_device *pdev, int type)
+{
+ if (type == S5P_USB_PHY_DEVICE)
+ return s5p64x0_otg_phy_init(pdev);
+

arch/arm/mach-s5p64x0/setup-otg-phy.c line 89

Quoted 10 lines
arch/arm/mach-s5p64x0/setup-otg-phy.c new file +10 -0
+ return -EINVAL;
+}
+
+int s5p_usb_phy_exit(struct platform_device *pdev, int type)
+{
+ if (type == S5P_USB_PHY_DEVICE)
+ return s5p64x0_otg_phy_exit(pdev);
+
+ return -EINVAL;
+}

no way to make this a real driver instead of set a exported functions ??

Quoted 3 lines

--
balbi

paneri

#2 lore raw

RFC PATCH 4/5 ARM: S5P64x0: Adding OTG PHY control code

Hi,

Quoted 29 lines · Praveen Paneri
Quoted 29 lines
Quoted 29 lines
arch/arm/mach-s5p64x0/Makefile +0 -0
index ae6bf6f..611fb3a 100644
@@ -28,3 +28,4 @@ obj-y += dev-audio.o

??obj-$(CONFIG_S3C64XX_DEV_SPI) += dev-spi.o

??obj-$(CONFIG_S5P64X0_SETUP_I2C1) += setup-i2c1.o

arch/arm/mach-s5p64x0/Makefile +1 -0
+obj-$(CONFIG_S3C_DEV_DWC_OTG) += setup-otg-phy.o
arch/arm/mach-s5p64x0/include/mach/map.h +0 -0
index 95c9125..717c279 100644
@@ -44,6 +44,8 @@

??#define S5P64X0_PA_SPI1 0xEC500000

??#define S5P64X0_PA_HSOTG 0xED100000

arch/arm/mach-s5p64x0/include/mach/map.h +2 -0
+#define S5P64X0_PA_USB_HSPHY 0xED200000
+#define S5P64X0_VA_USB_HSPHY S3C_ADDR_CPU(0x00100000)

??#define S5P64X0_PA_HSMMC(x) (0xED800000 + ((x) * 0x100000))

arch/arm/mach-s5p64x0/include/mach/map.h +0 -0
@@ -71,6 +73,8 @@

??#define S5P_PA_TIMER S5P64X0_PA_TIMER

??#define SAMSUNG_PA_ADC S5P64X0_PA_ADC

arch/arm/mach-s5p64x0/include/mach/map.h +2 -0
+#define S3C_PA_USB_HSOTG S5P64X0_PA_HSOTG
+#define S3C_VA_USB_HSPHY????????S5P64X0_VA_USB_HSPHY
Quoted 8 lines
Quoted 6 lines

arch/arm/mach-s5p64x0/setup-otg-phy.c

Quoted 3 lines

??/* UART */

arch/arm/mach-s5p64x0/setup-otg-phy.c +0 -0

drivers should not live in arch/arm/*, why don't you move this to drivers/usb/otg where the PHYs are staying right now ?

PHY init/exit code can vary across SoCs. Wouldn't it be better to have it in the SoC specific location?

It will vary how ? If it's only regarding e.g. a different GPIO pin or a different IRQ number, you handle that by passing data down to driver (via platform_data or struct resource), now if it varies because a different board uses a different PHY, then another driver should be written (well, as long as it's really different from the one you have now, otherwise you should see if it's worth making the existing driver more flexible).

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110622/40104a24/attachment-0001.sig>
#3 lore raw

RFC PATCH 4/5 ARM: S5P64x0: Adding OTG PHY control code

Hi Felipe,

Sorry for a delayed response to your comment. I have been addressing all the comment given
by you, following two points remain where I need your suggestion.

Quoted 41 lines · Felipe Balbi

Hi,

Quoted 29 lines · Praveen Paneri
Quoted 29 lines
Quoted 29 lines
arch/arm/mach-s5p64x0/Makefile +0 -0
index ae6bf6f..611fb3a 100644
@@ -28,3 +28,4 @@ obj-y += dev-audio.o

??obj-$(CONFIG_S3C64XX_DEV_SPI) += dev-spi.o

??obj-$(CONFIG_S5P64X0_SETUP_I2C1) += setup-i2c1.o

arch/arm/mach-s5p64x0/Makefile +1 -0
+obj-$(CONFIG_S3C_DEV_DWC_OTG) += setup-otg-phy.o
arch/arm/mach-s5p64x0/include/mach/map.h +0 -0
index 95c9125..717c279 100644
@@ -44,6 +44,8 @@

??#define S5P64X0_PA_SPI1 0xEC500000

??#define S5P64X0_PA_HSOTG 0xED100000

arch/arm/mach-s5p64x0/include/mach/map.h +2 -0
+#define S5P64X0_PA_USB_HSPHY 0xED200000
+#define S5P64X0_VA_USB_HSPHY S3C_ADDR_CPU(0x00100000)

??#define S5P64X0_PA_HSMMC(x) (0xED800000 + ((x) * 0x100000))

arch/arm/mach-s5p64x0/include/mach/map.h +0 -0
@@ -71,6 +73,8 @@

??#define S5P_PA_TIMER S5P64X0_PA_TIMER

??#define SAMSUNG_PA_ADC S5P64X0_PA_ADC

arch/arm/mach-s5p64x0/include/mach/map.h +2 -0
+#define S3C_PA_USB_HSOTG S5P64X0_PA_HSOTG
+#define S3C_VA_USB_HSPHY????????S5P64X0_VA_USB_HSPHY
Quoted 8 lines
Quoted 6 lines

arch/arm/mach-s5p64x0/setup-otg-phy.c

Quoted 3 lines

??/* UART */

arch/arm/mach-s5p64x0/setup-otg-phy.c +0 -0

drivers should not live in arch/arm/*, why don't you move this to drivers/usb/otg where the PHYs are staying right now ?

PHY init/exit code can vary across SoCs. Wouldn't it be better to have it in the SoC specific location?

Quoted 7 lines

It will vary how ? If it's only regarding e.g. a different GPIO pin or a different IRQ number, you handle that by passing data down to driver (via platform_data or struct resource), now if it varies because a different board uses a different PHY, then another driver should be written (well, as long as it's really different from the one you have now, otherwise you should see if it's worth making the existing driver more flexible).

We have only 4 registers which are used for phy control. The bit structure of these registers vary across the SoCs.
1) PHY power control
2) PHY clock control
3) OTG reset control
4) PHY tune

To init/de-init the phy we just need to set the above 4 registers appropriately. Do you still think there is a necessity for a separate driver ?

I have gone through the reference drivers suggested by you. Functionality of this PHY
control remains very less relative to those drivers.

I have removed a lot of ifdefery from the initial patches. The only problem I am facing is
in implementing a generic register I/O method which can work for both ARM and PPC.
Existing code for PPC was using following funtions in_le32, in_be32, out_le32, out_be32
while in ARM readl and writel functions are used.
kindly suggest a way out of it.

Quoted 4 lines

--
balbi

#4 lore raw

RFC PATCH 4/5 ARM: S5P64x0: Adding OTG PHY control code

Hi,

Quoted 19 lines · Praveen Paneri
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

drivers should not live in arch/arm/*, why don't you move this to drivers/usb/otg where the PHYs are staying right now ?

PHY init/exit code can vary across SoCs. Wouldn't it be better to have it in the SoC specific location?

Quoted 7 lines

It will vary how ? If it's only regarding e.g. a different GPIO pin or a different IRQ number, you handle that by passing data down to driver (via platform_data or struct resource), now if it varies because a different board uses a different PHY, then another driver should be written (well, as long as it's really different from the one you have now, otherwise you should see if it's worth making the existing driver more flexible).

We have only 4 registers which are used for phy control. The bit structure of these registers vary across the SoCs.
1) PHY power control
2) PHY clock control
3) OTG reset control
4) PHY tune

Quoted 2 lines

To init/de-init the phy we just need to set the above 4 registers appropriately. Do you still think there is a necessity for a separate driver ?

well, we do have the otg utilities on drivers/usb/otg/ ;-)

Quoted 3 lines

I have gone through the reference drivers suggested by you. Functionality of this PHY
control remains very less relative to those drivers.

on OMAP4 we have one "PHY" which actually only handle VBUS and ID pin detection :-p

Quoted 8 lines

I have removed a lot of ifdefery from the initial patches. The only problem I am facing is
in implementing a generic register I/O method which can work for both ARM and PPC.
Existing code for PPC was using following funtions in_le32, in_be32, out_le32, out_be32
while in ARM readl and writel functions are used.
kindly suggest a way out of it.

Can you use the versions on include/asm-generic/io.h ? ioread8(addr), ioread16(addr), ioread32(addr)

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110706/f9eb3262/attachment.sig>