Re: [PATCH 1/4] drivers: usb: phy: add a new driver for usb part of control module

2013-01-18 Thread Felipe Balbi
Hi,

On Fri, Jan 18, 2013 at 03:10:42PM +0530, Kishon Vijay Abraham I wrote:
> Added a new driver for the usb part of control module. This has an API
> to power on the USB2 phy and an API to write to the mailbox depending on
> whether MUSB has to act in host mode or in device mode.
> 
> Writing to control module registers for doing the above task which was
> previously done in omap glue and in omap-usb2 phy will be removed.
> 
> Signed-off-by: Kishon Vijay Abraham I 
> ---
>  Documentation/devicetree/bindings/usb/omap-usb.txt |   26 ++-
>  Documentation/devicetree/bindings/usb/usb-phy.txt  |5 +
>  drivers/usb/phy/Kconfig|9 +
>  drivers/usb/phy/Makefile   |1 +
>  drivers/usb/phy/omap-control-usb.c |  204 
> 
>  include/linux/usb/omap_control_usb.h   |   72 +++
>  6 files changed, 316 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/usb/phy/omap-control-usb.c
>  create mode 100644 include/linux/usb/omap_control_usb.h
> 
> diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt 
> b/Documentation/devicetree/bindings/usb/omap-usb.txt
> index 29a043e..ead6ba9 100644
> --- a/Documentation/devicetree/bindings/usb/omap-usb.txt
> +++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
> @@ -1,4 +1,4 @@
> -OMAP GLUE
> +OMAP GLUE AND OTHER OMAP SPECIFIC COMPONENTS
>  
>  OMAP MUSB GLUE
>   - compatible : Should be "ti,omap4-musb" or "ti,omap3-musb"
> @@ -16,6 +16,10 @@ OMAP MUSB GLUE
>   - power : Should be "50". This signifies the controller can supply upto
> 100mA when operating in host mode.
>  
> +Optional properties:
> + - ctrl_module : phandle of the control module this glue uses to write to
> +   mailbox
> +
>  SOC specific device node entry
>  usb_otg_hs: usb_otg_hs@4a0ab000 {
>   compatible = "ti,omap4-musb";
> @@ -23,6 +27,7 @@ usb_otg_hs: usb_otg_hs@4a0ab000 {
>   multipoint = <1>;
>   num_eps = <16>;
>   ram_bits = <12>;
> + ctrl_module = <&omap_control_usb>;
>  };
>  
>  Board specific device node entry
> @@ -31,3 +36,22 @@ Board specific device node entry
>   mode = <3>;
>   power = <50>;
>  };
> +
> +OMAP CONTROL USB
> +
> +Required properties:
> + - compatible: Should be "ti,omap-control-usb"
> + - reg : Address and length of the register set for the device. It contains
> +   the address of "control_dev_conf" and "otghs_control".
> + - reg-names: The names of the register addresses corresponding to the 
> registers
> +   filled in "reg".
> + - ti,has_mailbox: This is used to specify if the platform has mailbox in
> +   control module.
> +
> +omap_control_usb: omap-control-usb@4a002300 {
> + compatible = "ti,omap-control-usb";
> + reg = <0x4a002300 0x4>,
> +   <0x4a00233c 0x4>;
> + reg-names = "control_dev_conf", "otghs_control";
> + ti,has_mailbox;
> +};
> diff --git a/Documentation/devicetree/bindings/usb/usb-phy.txt 
> b/Documentation/devicetree/bindings/usb/usb-phy.txt
> index 80d4148..2466b6f 100644
> --- a/Documentation/devicetree/bindings/usb/usb-phy.txt
> +++ b/Documentation/devicetree/bindings/usb/usb-phy.txt
> @@ -8,10 +8,15 @@ Required properties:
>  add the address of control module dev conf register until a driver for
>  control module is added
>  
> +Optional properties:
> + - ctrl_module : phandle of the control module used by PHY driver to power on
> +   the PHY.
> +
>  This is usually a subnode of ocp2scp to which it is connected.
>  
>  usb2phy@4a0ad080 {
>   compatible = "ti,omap-usb2";
>   reg = <0x4a0ad080 0x58>,
> <0x4a002300 0x4>;
> + ctrl_module = <&omap_control_usb>;
>  };
> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
> index 5de6e7f..a7277ee 100644
> --- a/drivers/usb/phy/Kconfig
> +++ b/drivers/usb/phy/Kconfig
> @@ -14,6 +14,15 @@ config OMAP_USB2
> The USB OTG controller communicates with the comparator using this
> driver.
>  
> +config OMAP_CONTROL_USB
> + tristate "OMAP CONTROL USB Driver"
> + depends on ARCH_OMAP2PLUS
> + help
> +   Enable this to add support for the USB part present in the control
> +   module. This driver has API to power on the PHY and to write to the
> +   mailbox. The mailbox is present only in omap4 and the register to
> +   power on the PHY is present in omap4 and omap5.
> +
>  config USB_ISP1301
>   tristate "NXP ISP1301 USB transceiver support"
>   depends on USB || USB_GADGET
> diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
> index 1a579a8..0dea4d2 100644
> --- a/drivers/usb/phy/Makefile
> +++ b/drivers/usb/phy/Makefile
> @@ -5,6 +5,7 @@
>  ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
>  
>  obj-$(CONFIG_OMAP_USB2)  += omap-usb2.o
> +obj-$(CONFIG_OMAP_CONTROL_USB)   += omap-control-usb.o
>  obj-$(CONFIG_USB_ISP1301)+= isp1301.o
>  obj-$(CONFIG_MV_U3D_PHY) += mv_u3d_phy.o
>  obj-$(CONFIG_USB_EHCI_T

Re: [PATCH 1/4] drivers: usb: phy: add a new driver for usb part of control module

2013-01-18 Thread kishon

Hi,

On Friday 18 January 2013 05:29 PM, Felipe Balbi wrote:

Hi,

On Fri, Jan 18, 2013 at 03:10:42PM +0530, Kishon Vijay Abraham I wrote:

Added a new driver for the usb part of control module. This has an API
to power on the USB2 phy and an API to write to the mailbox depending on
whether MUSB has to act in host mode or in device mode.

Writing to control module registers for doing the above task which was
previously done in omap glue and in omap-usb2 phy will be removed.

Signed-off-by: Kishon Vijay Abraham I 
---
  Documentation/devicetree/bindings/usb/omap-usb.txt |   26 ++-
  Documentation/devicetree/bindings/usb/usb-phy.txt  |5 +
  drivers/usb/phy/Kconfig|9 +
  drivers/usb/phy/Makefile   |1 +
  drivers/usb/phy/omap-control-usb.c |  204 
  include/linux/usb/omap_control_usb.h   |   72 +++
  6 files changed, 316 insertions(+), 1 deletion(-)
  create mode 100644 drivers/usb/phy/omap-control-usb.c
  create mode 100644 include/linux/usb/omap_control_usb.h

diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt 
b/Documentation/devicetree/bindings/usb/omap-usb.txt
index 29a043e..ead6ba9 100644
--- a/Documentation/devicetree/bindings/usb/omap-usb.txt
+++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
@@ -1,4 +1,4 @@
-OMAP GLUE
+OMAP GLUE AND OTHER OMAP SPECIFIC COMPONENTS

  OMAP MUSB GLUE
   - compatible : Should be "ti,omap4-musb" or "ti,omap3-musb"
@@ -16,6 +16,10 @@ OMAP MUSB GLUE
   - power : Should be "50". This signifies the controller can supply upto
 100mA when operating in host mode.

+Optional properties:
+ - ctrl_module : phandle of the control module this glue uses to write to
+   mailbox
+
  SOC specific device node entry
  usb_otg_hs: usb_otg_hs@4a0ab000 {
compatible = "ti,omap4-musb";
@@ -23,6 +27,7 @@ usb_otg_hs: usb_otg_hs@4a0ab000 {
multipoint = <1>;
num_eps = <16>;
ram_bits = <12>;
+   ctrl_module = <&omap_control_usb>;
  };

  Board specific device node entry
@@ -31,3 +36,22 @@ Board specific device node entry
mode = <3>;
power = <50>;
  };
+
+OMAP CONTROL USB
+
+Required properties:
+ - compatible: Should be "ti,omap-control-usb"
+ - reg : Address and length of the register set for the device. It contains
+   the address of "control_dev_conf" and "otghs_control".
+ - reg-names: The names of the register addresses corresponding to the 
registers
+   filled in "reg".
+ - ti,has_mailbox: This is used to specify if the platform has mailbox in
+   control module.
+
+omap_control_usb: omap-control-usb@4a002300 {
+   compatible = "ti,omap-control-usb";
+   reg = <0x4a002300 0x4>,
+ <0x4a00233c 0x4>;
+   reg-names = "control_dev_conf", "otghs_control";
+   ti,has_mailbox;
+};
diff --git a/Documentation/devicetree/bindings/usb/usb-phy.txt 
b/Documentation/devicetree/bindings/usb/usb-phy.txt
index 80d4148..2466b6f 100644
--- a/Documentation/devicetree/bindings/usb/usb-phy.txt
+++ b/Documentation/devicetree/bindings/usb/usb-phy.txt
@@ -8,10 +8,15 @@ Required properties:
  add the address of control module dev conf register until a driver for
  control module is added

+Optional properties:
+ - ctrl_module : phandle of the control module used by PHY driver to power on
+   the PHY.
+
  This is usually a subnode of ocp2scp to which it is connected.

  usb2phy@4a0ad080 {
compatible = "ti,omap-usb2";
reg = <0x4a0ad080 0x58>,
  <0x4a002300 0x4>;
+   ctrl_module = <&omap_control_usb>;
  };
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 5de6e7f..a7277ee 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -14,6 +14,15 @@ config OMAP_USB2
  The USB OTG controller communicates with the comparator using this
  driver.

+config OMAP_CONTROL_USB
+   tristate "OMAP CONTROL USB Driver"
+   depends on ARCH_OMAP2PLUS
+   help
+ Enable this to add support for the USB part present in the control
+ module. This driver has API to power on the PHY and to write to the
+ mailbox. The mailbox is present only in omap4 and the register to
+ power on the PHY is present in omap4 and omap5.
+
  config USB_ISP1301
tristate "NXP ISP1301 USB transceiver support"
depends on USB || USB_GADGET
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index 1a579a8..0dea4d2 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -5,6 +5,7 @@
  ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG

  obj-$(CONFIG_OMAP_USB2)   += omap-usb2.o
+obj-$(CONFIG_OMAP_CONTROL_USB) += omap-control-usb.o
  obj-$(CONFIG_USB_ISP1301) += isp1301.o
  obj-$(CONFIG_MV_U3D_PHY)  += mv_u3d_phy.o
  obj-$(CONFIG_USB_EHCI_TEGRA)  += tegra_usb_phy.o
diff --git a/drivers/usb/phy/omap-control-usb.c 
b/drivers/usb/phy/omap-control-usb.c
new fi

Re: [PATCH 1/4] drivers: usb: phy: add a new driver for usb part of control module

2013-01-18 Thread Felipe Balbi
Hi,

On Fri, Jan 18, 2013 at 05:40:04PM +0530, kishon wrote:
> >>+void omap_control_usb_host_mode(struct device *dev)
> >>+{
> >>+   u32 val;
> >>+   struct omap_control_usb *control_usb = dev_get_drvdata(dev);
> >>+
> >>+   val = AVALID | VBUSVALID;
> >>+
> >>+   writel(val, control_usb->otghs_control);
> >
> >I would like to make this future proof too:
> >
> >val = readl(ctrl->otghs_control);
> >val |= OMAP_CTRL_DEV_AVALID | OMAP_CTRL_DEV_VBUSVALID;
> >writel(val, ctrl->otghs_control);
> 
> I think we might then have to add
> val &= ~(IDDIG | SESSEND) right?

right, my bad ;-)

> >Another idea is to try to get the extra resource below, if it fails you
> >try to continue without it ;-)
> 
> I prefer the way it is now because mailbox is needed for MUSB to be
> functional in OMAP4 and we should fail if we don't have it. No?

could be, that would mean an error on DT data though.

-- 
balbi


signature.asc
Description: Digital signature
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss