Re: [RFC PATCH 1/6] usb: otg: Add an API to bind the USB controller and PHY

2013-02-03 Thread Roger Quadros
On 01/16/2013 05:00 PM, Kishon Vijay Abraham I wrote:
 New platforms are added which has multiple PHY's (of same type) and
 which has multiple USB controllers. The binding information has to be
 present in the PHY library (otg.c) in order for it to return the
 appropriate PHY whenever the USB controller request for the PHY. So
 added a new API to pass the binding information. This API should be
 called by platform specific initialization code.
 
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  drivers/usb/otg/otg.c   |   37 +
  include/linux/usb/phy.h |   22 ++
  2 files changed, 59 insertions(+)
 
 diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
 index a30c041..492ba2f 100644
 --- a/drivers/usb/otg/otg.c
 +++ b/drivers/usb/otg/otg.c
 @@ -18,6 +18,7 @@
  #include linux/usb/otg.h
  
  static LIST_HEAD(phy_list);
 +static LIST_HEAD(phy_bind_list);
  static DEFINE_SPINLOCK(phy_lock);
  
  static struct usb_phy *__usb_find_phy(struct list_head *list,
 @@ -201,6 +202,42 @@ void usb_remove_phy(struct usb_phy *x)
  }
  EXPORT_SYMBOL(usb_remove_phy);
  
 +/**
 + * usb_bind_phy - bind the phy and the controller that uses the phy
 + * @dev_name: the device name of the device that will bind to the phy
 + * @index: index to specify the port number
 + * @phy_dev_name: the device name of the phy
 + *
 + * Fills the phy_bind structure with the dev_name and phy_dev_name. This will
 + * be used when the phy driver registers the phy and when the controller
 + * requests this phy.
 + *
 + * To be used by platform specific initialization code.
 + */
 +struct usb_phy_bind __init *usb_bind_phy(const char *dev_name, u8 index,
 + const char *phy_dev_name)
 +{
 + struct usb_phy_bind *phy_bind;
 + unsigned long flags;
 +
 + phy_bind = kzalloc(sizeof(*phy_bind), GFP_KERNEL);
 + if (!phy_bind) {
 + pr_err(phy_bind(): No memory for phy_bind);

Function name in comment doesn't match the actual.
Instead, you could use
pr_err(%s ..., __func__);

 + return ERR_PTR(-ENOMEM);
 + }
 +
 + phy_bind-dev_name = dev_name;
 + phy_bind-phy_dev_name = phy_dev_name;
 + phy_bind-index = index;
 +
 + spin_lock_irqsave(phy_lock, flags);
 + list_add_tail(phy_bind-list, phy_bind_list);
 + spin_unlock_irqrestore(phy_lock, flags);
 +
 + return phy_bind;
 +}
 +EXPORT_SYMBOL_GPL(usb_bind_phy);
 +
  const char *otg_state_string(enum usb_otg_state state)
  {
   switch (state) {
 diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
 index a29ae1e..fbeab1a 100644
 --- a/include/linux/usb/phy.h
 +++ b/include/linux/usb/phy.h
 @@ -106,6 +106,21 @@ struct usb_phy {
   enum usb_device_speed speed);
  };
  
 +/**
 + * struct usb_phy_bind - represent the binding for the phy
 + * @dev_name: the device name of the device that will bind to the phy
 + * @phy_dev_name: the device name of the phy
 + * @index: used if a single controller uses multiple phys
 + * @phy: reference to the phy
 + * @list: to maintain a linked list of the binding information
 + */
 +struct usb_phy_bind {
 + const char  *dev_name;
 + const char  *phy_dev_name;
 + u8  index;
 + struct usb_phy  *phy;
 + struct list_head list;
 +};
  
  /* for board-specific init logic */
  extern int usb_add_phy(struct usb_phy *, enum usb_phy_type type);
 @@ -151,6 +166,8 @@ extern struct usb_phy *devm_usb_get_phy(struct device 
 *dev,
   enum usb_phy_type type);
  extern void usb_put_phy(struct usb_phy *);
  extern void devm_usb_put_phy(struct device *dev, struct usb_phy *x);
 +extern struct usb_phy_bind *usb_bind_phy(const char *dev_name, u8 index,
 + const char *phy_dev_name);
  #else
  static inline struct usb_phy *usb_get_phy(enum usb_phy_type type)
  {
 @@ -171,6 +188,11 @@ static inline void devm_usb_put_phy(struct device *dev, 
 struct usb_phy *x)
  {
  }
  
 +static inline struct usb_phy_bind *usb_bind_phy(const char *dev_name, u8 
 index,
 + const char *phy_dev_name)
 +{
 + return NULL;
 +}
  #endif
  
  static inline int
 

Controllers like ehci-omap which don't need OTG functionality would
benefit from this API. Can we make these PHY APIs not dependent on OTG /
OTG_UTILS?

cheers,
-roger

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [RFC PATCH 2/6] ARM: OMAP: USB: Add phy binding information

2013-02-03 Thread Roger Quadros
On 01/16/2013 05:00 PM, Kishon Vijay Abraham I wrote:
 This is in preparation for the changes in PHY library to support adding
 and getting multiple PHYs of the same type. In the new design, the
 binding information between the PHY and the USB controller should be
 specified in the platform specific initialization code. So it's been
 done for OMAP platforms here.
 
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
 This kind-of binding should be done in all the platforms (I've done only
 for OMAP platform). 
  arch/arm/mach-omap2/usb-musb.c |7 ++-
  1 file changed, 6 insertions(+), 1 deletion(-)
 
 diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
 index 9d27e3f..bbe2fa5 100644
 --- a/arch/arm/mach-omap2/usb-musb.c
 +++ b/arch/arm/mach-omap2/usb-musb.c
 @@ -24,6 +24,7 @@
  #include linux/dma-mapping.h
  #include linux/io.h
  #include linux/usb/musb.h
 +#include linux/usb/phy.h
  
  #include omap_device.h
  #include soc.h
 @@ -85,8 +86,12 @@ 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_omap44xx())
 + if (cpu_is_omap44xx()) {
   musb_plat.has_mailbox = true;
 + usb_bind_phy(musb-hdrc.0.auto, 0, omap-usb2.1.auto);
 + } else if (cpu_is_omap34xx()) {
 + usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb);
 + }

Are you sure than these OMAP platforms cannot be wired in any other way
to the PHY?

If they can be then this association must come from the board files or
device tree.

  
   if (soc_is_am35xx()) {
   oh_name = am35x_otg_hs;
 

--
cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [RFC PATCH 3/6] usb: otg: utils: change the phy lib to support multiple PHYs of same type

2013-02-03 Thread Roger Quadros
On 01/16/2013 05:00 PM, Kishon Vijay Abraham I wrote:
 In order to add support for multipe PHY's of the same type, the API's
 for adding PHY and getting PHY has been changed. Now the binding
 information of the PHY and controller should be done in platform file
 using usb_bind_phy API. And for getting a PHY, the device pointer of the
 USB controller and an index should be passed. Based on the binding
 information that is added in the platform file, get_phy will return the
 approappropriate PHY.
 
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  arch/arm/mach-shmobile/board-marzen.c |2 +-
  drivers/power/ab8500_charger.c|2 +-
  drivers/power/isp1704_charger.c   |2 +-
  drivers/power/pda_power.c |2 +-
  drivers/power/twl4030_charger.c   |2 +-
  drivers/usb/chipidea/udc.c|2 +-
  drivers/usb/dwc3/core.c   |4 +-
  drivers/usb/gadget/fsl_udc_core.c |2 +-
  drivers/usb/gadget/mv_udc_core.c  |2 +-
  drivers/usb/gadget/omap_udc.c |2 +-
  drivers/usb/gadget/pxa25x_udc.c   |2 +-
  drivers/usb/gadget/pxa27x_udc.c   |2 +-
  drivers/usb/gadget/s3c-hsudc.c|2 +-
  drivers/usb/host/ehci-fsl.c   |2 +-
  drivers/usb/host/ehci-msm.c   |2 +-
  drivers/usb/host/ehci-mv.c|2 +-
  drivers/usb/host/ehci-tegra.c |2 +-
  drivers/usb/host/ohci-omap.c  |2 +-
  drivers/usb/musb/am35x.c  |2 +-
  drivers/usb/musb/blackfin.c   |2 +-
  drivers/usb/musb/da8xx.c  |2 +-
  drivers/usb/musb/davinci.c|2 +-
  drivers/usb/musb/musb_dsps.c  |2 +-
  drivers/usb/musb/omap2430.c   |2 +-
  drivers/usb/musb/tusb6010.c   |2 +-
  drivers/usb/musb/ux500.c  |2 +-
  drivers/usb/otg/ab8500-usb.c  |3 +-
  drivers/usb/otg/fsl_otg.c |5 ++-
  drivers/usb/otg/gpio_vbus.c   |3 +-
  drivers/usb/otg/isp1301_omap.c|3 +-
  drivers/usb/otg/msm_otg.c |3 +-
  drivers/usb/otg/mv_otg.c  |3 +-
  drivers/usb/otg/nop-usb-xceiv.c   |3 +-
  drivers/usb/otg/otg.c |   67 
 +++--
  drivers/usb/otg/twl4030-usb.c |3 +-
  drivers/usb/phy/mv_u3d_phy.c  |3 +-
  drivers/usb/phy/omap-usb2.c   |   11 ++
  drivers/usb/phy/rcar-phy.c|3 +-
  include/linux/usb/phy.h   |   12 +++---
  39 files changed, 87 insertions(+), 89 deletions(-)

I think it better to leave the existing add/get APIs as they are add add
new APIs that support multiple PHYs. You could probably mark the old
ones as deprecated.

That way you don't need to wait till all users are converted and tested.

e.g. you could name the new APIs as

usb_add_phy_dev(struct usb_phy *phy);
usb_get_phy_dev(struct device *dev, int index);

--
cheers,
-roger

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [RFC PATCH 6/6] USB: MUSB: OMAP: get PHY by phandle for dt boot

2013-02-03 Thread Roger Quadros
On 01/16/2013 05:01 PM, Kishon Vijay Abraham I wrote:
 The OMAP glue has been modified to get PHY by phandle for dt boot.
 
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  drivers/usb/musb/omap2430.c |7 ++-
  1 file changed, 6 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
 index 3628a50..08709cf 100644
 --- a/drivers/usb/musb/omap2430.c
 +++ b/drivers/usb/musb/omap2430.c
 @@ -346,7 +346,12 @@ 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.
*/
 - musb-xceiv = devm_usb_get_phy(dev, 0);
 + if (dev-parent-of_node)
 + musb-xceiv = devm_usb_get_phy_by_phandle(dev-parent,
 + usb_phy, 0);

Why dev-parent and not just dev?

 + else
 + musb-xceiv = devm_usb_get_phy(dev, 0);
 +
   if (IS_ERR_OR_NULL(musb-xceiv)) {
   pr_err(HS USB OTG: no transceiver configured\n);
   return -ENODEV;
 

--
cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [RFC PATCH 5/6] usb: otg: add device tree support to otg library

2013-02-03 Thread Roger Quadros
On 01/16/2013 05:01 PM, Kishon Vijay Abraham I wrote:
 Added an API devm_usb_get_phy_by_phandle(), to get usb phy by passing a
 device node phandle value. This function will return a pointer to
 the phy on success, -EPROBE_DEFER if there is a device_node for the phandle,
 but the phy has not been added, or a ERR_PTR() otherwise.
 
 Cc: Marc Kleine-Budde m...@pengutronix.de
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  drivers/usb/otg/otg.c   |   77 
 +++
  include/linux/usb/phy.h |8 +
  2 files changed, 85 insertions(+)
 
 diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
 index dbf2043..e9799bb 100644
 --- a/drivers/usb/otg/otg.c
 +++ b/drivers/usb/otg/otg.c
 @@ -13,7 +13,9 @@
  #include linux/export.h
  #include linux/err.h
  #include linux/device.h
 +#include linux/module.h
  #include linux/slab.h
 +#include linux/of.h
  
  #include linux/usb/otg.h
  
 @@ -34,6 +36,20 @@ static struct usb_phy *__usb_find_phy(struct device *dev, 
 u8 index)
   return ERR_PTR(-ENODEV);
  }
  
 +static struct usb_phy *__of_usb_find_phy(struct device_node *node)
 +{
 + struct usb_phy  *phy;
 +
 + list_for_each_entry(phy, phy_list, head) {
 + if (node != phy-dev-of_node)
 + continue;
 +
 + return phy;
 + }
 +
 + return ERR_PTR(-ENODEV);
 +}
 +
  static void devm_usb_phy_release(struct device *dev, void *res)
  {
   struct usb_phy *phy = *(struct usb_phy **)res;
 @@ -109,6 +125,67 @@ err0:
  }
  EXPORT_SYMBOL(usb_get_phy);
  
 + /**
 + * devm_usb_get_phy_by_phandle - find the USB PHY by phandle
 + * @dev - device that requests this phy
 + * @phandle - name of the property holding the phy phandle value
 + * @index - the index of the phy
 + *
 + * Returns the phy driver associated with the given phandle value,
 + * after getting a refcount to it, -ENODEV if there is no such phy or
 + * -EPROBE_DEFER if there is a phandle to the phy, but the device is
 + * not yet loaded. While at that, it also associates the device with
 + * the phy using devres. On driver detach, release function is invoked
 + * on the devres data, then, devres data is freed.
 + *
 + * For use by USB host and peripheral drivers.
 + */
 +struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev,
 + const char *phandle, u8 index)
 +{
 + struct usb_phy  *phy = NULL, **ptr;
 + unsigned long   flags;
 + struct device_node *node;
 +
 + if (!dev-of_node) {
 + dev_dbg(dev, device does not have a device node entry\n);
 + return ERR_PTR(-EINVAL);
 + }
 +
 + node = of_parse_phandle(dev-of_node, phandle, index);
 + if (!node) {
 + dev_dbg(dev, failed to get %s phandle in %s node\n, phandle,
 + dev-of_node-full_name);
 + return ERR_PTR(-ENODEV);
 + }
 +
 + ptr = devres_alloc(devm_usb_phy_release, sizeof(*ptr), GFP_KERNEL);
 + if (!ptr) {
 + dev_dbg(dev, failed to allocate memory for devres\n);
 + return ERR_PTR(-ENOMEM);
 + }

I fail to understand why you need ptr at all and why do devres_alloc()
for it.

 +
 + spin_lock_irqsave(phy_lock, flags);
 +
 + phy = __of_usb_find_phy(node);
 + if (IS_ERR(phy) || !try_module_get(phy-dev-driver-owner)) {
 + phy = ERR_PTR(-EPROBE_DEFER);
 + devres_free(ptr);
 + goto err0;
 + }
 +
 + *ptr = phy;
 + devres_add(dev, ptr);
 +
 + get_device(phy-dev);
 +
 +err0:
 + spin_unlock_irqrestore(phy_lock, flags);
 +
 + return phy;
 +}
 +EXPORT_SYMBOL(devm_usb_get_phy_by_phandle);
 +

--
cheers,
-roger

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [RFC PATCH 5/6] usb: otg: add device tree support to otg library

2013-02-03 Thread Roger Quadros
On 01/21/2013 03:34 PM, kishon wrote:
 On Monday 21 January 2013 06:51 PM, Roger Quadros wrote:
 On 01/16/2013 05:01 PM, Kishon Vijay Abraham I wrote:
 Added an API devm_usb_get_phy_by_phandle(), to get usb phy by passing a
 device node phandle value. This function will return a pointer to
 the phy on success, -EPROBE_DEFER if there is a device_node for the
 phandle,
 but the phy has not been added, or a ERR_PTR() otherwise.

 Cc: Marc Kleine-Budde m...@pengutronix.de
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
   drivers/usb/otg/otg.c   |   77
 +++
   include/linux/usb/phy.h |8 +
   2 files changed, 85 insertions(+)

 diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
 index dbf2043..e9799bb 100644
 --- a/drivers/usb/otg/otg.c
 +++ b/drivers/usb/otg/otg.c
 @@ -13,7 +13,9 @@
   #include linux/export.h
   #include linux/err.h
   #include linux/device.h
 +#include linux/module.h
   #include linux/slab.h
 +#include linux/of.h

   #include linux/usb/otg.h

 @@ -34,6 +36,20 @@ static struct usb_phy *__usb_find_phy(struct
 device *dev, u8 index)
   return ERR_PTR(-ENODEV);
   }

 +static struct usb_phy *__of_usb_find_phy(struct device_node *node)
 +{
 +struct usb_phy  *phy;
 +
 +list_for_each_entry(phy, phy_list, head) {
 +if (node != phy-dev-of_node)
 +continue;
 +
 +return phy;
 +}
 +
 +return ERR_PTR(-ENODEV);
 +}
 +
   static void devm_usb_phy_release(struct device *dev, void *res)
   {
   struct usb_phy *phy = *(struct usb_phy **)res;
 @@ -109,6 +125,67 @@ err0:
   }
   EXPORT_SYMBOL(usb_get_phy);

 + /**
 + * devm_usb_get_phy_by_phandle - find the USB PHY by phandle
 + * @dev - device that requests this phy
 + * @phandle - name of the property holding the phy phandle value
 + * @index - the index of the phy
 + *
 + * Returns the phy driver associated with the given phandle value,
 + * after getting a refcount to it, -ENODEV if there is no such phy or
 + * -EPROBE_DEFER if there is a phandle to the phy, but the device is
 + * not yet loaded. While at that, it also associates the device with
 + * the phy using devres. On driver detach, release function is invoked
 + * on the devres data, then, devres data is freed.
 + *
 + * For use by USB host and peripheral drivers.
 + */
 +struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev,
 +const char *phandle, u8 index)
 +{
 +struct usb_phy*phy = NULL, **ptr;
 +unsigned longflags;
 +struct device_node *node;
 +
 +if (!dev-of_node) {
 +dev_dbg(dev, device does not have a device node entry\n);
 +return ERR_PTR(-EINVAL);
 +}
 +
 +node = of_parse_phandle(dev-of_node, phandle, index);
 +if (!node) {
 +dev_dbg(dev, failed to get %s phandle in %s node\n, phandle,
 +dev-of_node-full_name);
 +return ERR_PTR(-ENODEV);
 +}
 +
 +ptr = devres_alloc(devm_usb_phy_release, sizeof(*ptr), GFP_KERNEL);
 +if (!ptr) {
 +dev_dbg(dev, failed to allocate memory for devres\n);
 +return ERR_PTR(-ENOMEM);
 +}

 I fail to understand why you need ptr at all and why do devres_alloc()
 for it.
 
 Thats how we create a managed device resource. You can have a look at
 Documentation/driver-model/devres.txt and drivers/base/devres.c.

OK, I get it now. You might want to update the text file too since you
are adding a automagically managed interface.

regards,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [RFC PATCH 6/6] USB: MUSB: OMAP: get PHY by phandle for dt boot

2013-02-03 Thread Roger Quadros
On 01/21/2013 03:41 PM, kishon wrote:
 Hi,
 
 On Monday 21 January 2013 06:48 PM, Roger Quadros wrote:
 On 01/16/2013 05:01 PM, Kishon Vijay Abraham I wrote:
 The OMAP glue has been modified to get PHY by phandle for dt boot.

 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
   drivers/usb/musb/omap2430.c |7 ++-
   1 file changed, 6 insertions(+), 1 deletion(-)

 diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
 index 3628a50..08709cf 100644
 --- a/drivers/usb/musb/omap2430.c
 +++ b/drivers/usb/musb/omap2430.c
 @@ -346,7 +346,12 @@ 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.
*/
 -musb-xceiv = devm_usb_get_phy(dev, 0);
 +if (dev-parent-of_node)
 +musb-xceiv = devm_usb_get_phy_by_phandle(dev-parent,
 +usb_phy, 0);

 Why dev-parent and not just dev?
 
 Right now MUSB core is not converted to dt and hence we don't have
 separate dt node for MUSB core.
 So the PHY information is added to the glue dt data.
 

OK. Got it :).

--
cheers,
-roger


___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH v1 2/6] usb: otg: utils: add facilities in phy lib to support multiple PHYs of same type

2013-02-03 Thread Roger Quadros
On 01/22/2013 11:58 AM, Kishon Vijay Abraham I wrote:
 In order to add support for multipe PHY's of the same type, new API's
 for adding PHY and getting PHY has been added. Now the binding
 information for the PHY and controller should be done in platform file
 using usb_bind_phy API. And for getting a PHY, the device pointer of the
 USB controller and an index should be passed. Based on the binding
 information that is added in the platform file, usb_get_phy_dev will return 
 the
 appropriate PHY.
 Already existing API's to add and get phy by type is not removed. These
 API's are deprecated and will be removed once all the platforms start to
 use the new API.
 
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  drivers/usb/otg/otg.c   |  114 
 ++-
  include/linux/usb/phy.h |   13 ++
  2 files changed, 126 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
 index 492ba2f..1f30b22 100644
 --- a/drivers/usb/otg/otg.c
 +++ b/drivers/usb/otg/otg.c
 @@ -36,6 +36,20 @@ static struct usb_phy *__usb_find_phy(struct list_head 
 *list,
   return ERR_PTR(-ENODEV);
  }
  
 +static struct usb_phy *__usb_find_phy_dev(struct device *dev,
 + struct list_head *list, u8 index)
 +{
 + struct usb_phy_bind *phy_bind = NULL;
 +
 + list_for_each_entry(phy_bind, list, list) {
 + if (!(strcmp(phy_bind-dev_name, dev_name(dev))) 
 + phy_bind-index == index)
 + return phy_bind-phy;

If the PHY driver has not yet called usb_add_phy_dev() (e.g. driver not yet 
loaeded)
then this will return NULL.

 + }
 +
 + return ERR_PTR(-ENODEV);
 +}
 +
  static void devm_usb_phy_release(struct device *dev, void *res)
  {
   struct usb_phy *phy = *(struct usb_phy **)res;
 @@ -112,6 +126,69 @@ err0:
  EXPORT_SYMBOL(usb_get_phy);
  
  /**
 + * usb_get_phy_dev - find the USB PHY
 + * @dev - device that requests this phy
 + * @index - the index of the phy
 + *
 + * Returns the phy driver, after getting a refcount to it; or
 + * -ENODEV if there is no such phy.  The caller is responsible for
 + * calling usb_put_phy() to release that count.
 + *
 + * For use by USB host and peripheral drivers.
 + */
 +struct usb_phy *usb_get_phy_dev(struct device *dev, u8 index)
 +{
 + struct usb_phy  *phy = NULL;
 + unsigned long   flags;
 +
 + spin_lock_irqsave(phy_lock, flags);
 +
 + phy = __usb_find_phy_dev(dev, phy_bind_list, index);
 + if (IS_ERR(phy)) {
 + pr_err(unable to find transceiver\n);
 + goto err0;
 + }

Since NULL is not IS_ERR(), you will do a NULL pointer reference below.

In such cases we would want to use the deferred probe mechanism. So should we 
return
-EPROBE_DEFER?

 +
 + get_device(phy-dev);
 +
 +err0:
 + spin_unlock_irqrestore(phy_lock, flags);
 +
 + return phy;
 +}
 +EXPORT_SYMBOL(usb_get_phy_dev);
 +

--
cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH v1 4/6] drivers: usb: musb: omap: make use of the new PHY lib APIs

2013-02-03 Thread Roger Quadros
On 01/22/2013 11:58 AM, Kishon Vijay Abraham I wrote:
 New PHY lib APIs like usb_add_phy_dev() and devm_usb_get_phy_dev() are
 used in MUSB (OMAP), in order to make use of the binding information
 provided in the board file (of OMAP platforms).
 All the platforms should be modified similar to this to add and get the
 PHY.
 
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  drivers/usb/musb/omap2430.c   |2 +-
  drivers/usb/otg/twl4030-usb.c |3 ++-
  drivers/usb/phy/omap-usb2.c   |3 ++-
  3 files changed, 5 insertions(+), 3 deletions(-)
 
 diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
 index bf6cfe0..1a8cf6d 100644
 --- a/drivers/usb/musb/omap2430.c
 +++ b/drivers/usb/musb/omap2430.c
 @@ -345,7 +345,7 @@ 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.
*/
 - musb-xceiv = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
 + musb-xceiv = devm_usb_get_phy_dev(dev, 0);
   if (IS_ERR_OR_NULL(musb-xceiv)) {
   pr_err(HS USB OTG: no transceiver configured\n);
   return -ENODEV;
 diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c
 index 0a70193..a994715 100644
 --- a/drivers/usb/otg/twl4030-usb.c
 +++ b/drivers/usb/otg/twl4030-usb.c
 @@ -610,6 +610,7 @@ static int twl4030_usb_probe(struct platform_device *pdev)
   twl-phy.dev= twl-dev;
   twl-phy.label  = twl4030;
   twl-phy.otg= otg;
 + twl-phy.type   = USB_PHY_TYPE_USB2;

What is the need to set phy.type? I think this should be deprecated along with 
the old API.

   twl-phy.set_suspend= twl4030_set_suspend;
  
   otg-phy= twl-phy;
 @@ -624,7 +625,7 @@ static int twl4030_usb_probe(struct platform_device *pdev)
   dev_err(pdev-dev, ldo init failed\n);
   return err;
   }
 - usb_add_phy(twl-phy, USB_PHY_TYPE_USB2);
 + usb_add_phy_dev(twl-phy);
  
   platform_set_drvdata(pdev, twl);
   if (device_create_file(pdev-dev, dev_attr_vbus))
 diff --git a/drivers/usb/phy/omap-usb2.c b/drivers/usb/phy/omap-usb2.c
 index 4b59b39..b5c759c 100644
 --- a/drivers/usb/phy/omap-usb2.c
 +++ b/drivers/usb/phy/omap-usb2.c
 @@ -143,6 +143,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
   phy-phy.label  = omap-usb2;
   phy-phy.set_suspend= omap_usb2_suspend;
   phy-phy.otg= otg;
 + phy-phy.type   = USB_PHY_TYPE_USB2;

same here.

  
   res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
  
 @@ -168,7 +169,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
   }
   clk_prepare(phy-wkupclk);
  
 - usb_add_phy(phy-phy, USB_PHY_TYPE_USB2);
 + usb_add_phy_dev(phy-phy);
  
   platform_set_drvdata(pdev, phy);
  
 

--
cheers,
-roger

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH v1 6/6] USB: MUSB: OMAP: get PHY by phandle for dt boot

2013-02-03 Thread Roger Quadros
On 01/22/2013 11:58 AM, Kishon Vijay Abraham I wrote:
 The OMAP glue has been modified to get PHY by phandle for dt boot.
 
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  drivers/usb/musb/omap2430.c |7 ++-
  1 file changed, 6 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
 index 1a8cf6d..e43faeb 100644
 --- a/drivers/usb/musb/omap2430.c
 +++ b/drivers/usb/musb/omap2430.c
 @@ -345,7 +345,12 @@ 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.
*/
 - musb-xceiv = devm_usb_get_phy_dev(dev, 0);
 + if (dev-parent-of_node)
 + musb-xceiv = devm_usb_get_phy_by_phandle(dev-parent,
 + usb_phy, 0);
 + else
 + musb-xceiv = devm_usb_get_phy_dev(dev, 0);
 +
   if (IS_ERR_OR_NULL(musb-xceiv)) {
   pr_err(HS USB OTG: no transceiver configured\n);
   return -ENODEV;

This will not work with PHY driver as a module. You need to use deferred 
probing mechanism here
after you have addressed my comment in patch 2 and also 
devm_usb_get_phy_by_phandle()

e.g.

if (IS_ERR(musb-xceiv)) {
int ret = PTR_ERR(musb-xveiv);

if (ret == -ENODEV)
pr_err(HS USB OTG: no transceiver configured\n);

return ret;
}

--
cheers,
-roger
 

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH v1 6/6] USB: MUSB: OMAP: get PHY by phandle for dt boot

2013-02-03 Thread Roger Quadros
On 01/22/2013 04:37 PM, kishon wrote:
 On Tuesday 22 January 2013 07:47 PM, Roger Quadros wrote:
 On 01/22/2013 11:58 AM, Kishon Vijay Abraham I wrote:
 The OMAP glue has been modified to get PHY by phandle for dt boot.

 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
   drivers/usb/musb/omap2430.c |7 ++-
   1 file changed, 6 insertions(+), 1 deletion(-)

 diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
 index 1a8cf6d..e43faeb 100644
 --- a/drivers/usb/musb/omap2430.c
 +++ b/drivers/usb/musb/omap2430.c
 @@ -345,7 +345,12 @@ 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.
*/
 -musb-xceiv = devm_usb_get_phy_dev(dev, 0);
 +if (dev-parent-of_node)
 +musb-xceiv = devm_usb_get_phy_by_phandle(dev-parent,
 +usb_phy, 0);
 +else
 +musb-xceiv = devm_usb_get_phy_dev(dev, 0);
 +
   if (IS_ERR_OR_NULL(musb-xceiv)) {
   pr_err(HS USB OTG: no transceiver configured\n);
   return -ENODEV;

 This will not work with PHY driver as a module. You need to use deferred 
 probing mechanism here
 after you have addressed my comment in patch 2 and also 
 devm_usb_get_phy_by_phandle()
 
 IIUC, even using -EPROBE_DEFER might not help if we are making the PHY driver 
 as module, since the kernel will try to probe only till the prompt comes.
 
Oh really? I thought deferred probing takes place whenever a new driver is 
bound to a device. What does prompt comes have to do with it?


 And having -EPROBE_DEFER instead of -ENODEV might also not help since, the 
 gadget driver wont be able to bind to UDC (usb_gadget_probe_driver will fail).
 
 A lot of things need to be changed before we change to -EPROBE_DEFER IMO.

OK.

--
cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 00/13] Device tree support for OMAP HS USB Host

2013-02-04 Thread Roger Quadros
Hi,

This patchset adds device tree support for OMAP's High Speed USB Host
subsystem. Board adaptation for Panda and Beagleboard is also provided.

Tested on Beagleboard.

Will only work with Panda if we provide a reference to the PHY clock
generator in the device tree in PATCH 11. I do not know how to do that
as there is no way to provide a phandle to any of the OMAP generated clocks
in the device tree. Suggestions welcome :).

Based on linux-next:next-20130204

Depends on USB: omap-ehci: Move PHY management to PHY driver
g...@github.com:rogerq/linux.git next-usbhost16

The following changes since commit 8c00470e1308d08df1f2b2c7e9a561d868ec0526:

  USB: ehci-omap: Select NOP USB transceiver driver (2013-02-04 16:36:06 +0200)

are available in the git repository at:
  g...@github.com:rogerq/linux.git next-usbhost16-dt

Roger Quadros (13):
  usb: phy: nop: Add device tree support and binding information
  USB: phy: nop: Defer probe if device needs VCC/RESET
  mfd: omap-usb-tll: move configuration code to omap_tll_init()
  mfd: omap-usb-tll: Add device tree support
  USB: ehci-omap: Get platform resources by index rather than by name
  USB: ohci-omap3: Get platform resources by index rather than by name
  USB: ohci-omap3: Add device tree support and binding information
  USB: ehci-omap: Add device tree support and binding information
  mfd: omap-usb-host: Add device tree support and binding information
  ARM: dts: OMAP4: Add HS USB Host IP nodes
  ARM: dts: omap4-panda: Add USB Host support
  ARM: dts: OMAP3: Add HS USB Host IP nodes
  ARM: dts: omap3-beagle: Add USB Host support

 .../devicetree/bindings/mfd/omap-usb-host.txt  |   68 +++
 .../devicetree/bindings/mfd/omap-usb-tll.txt   |   17 ++
 .../devicetree/bindings/usb/omap-ehci.txt  |   34 +++
 .../devicetree/bindings/usb/omap3-ohci.txt |   17 ++
 .../devicetree/bindings/usb/usb-nop-xceiv.txt  |   34 +++
 arch/arm/boot/dts/omap3-beagle.dts |   71 +++
 arch/arm/boot/dts/omap3.dtsi   |   31 +++
 arch/arm/boot/dts/omap4-panda.dts  |   55 +
 arch/arm/boot/dts/omap4.dtsi   |   30 +++
 drivers/mfd/omap-usb-host.c|   90 -
 drivers/mfd/omap-usb-tll.c |  213 ++--
 drivers/mfd/omap-usb.h |5 +-
 drivers/usb/host/ehci-omap.c   |   41 -
 drivers/usb/host/ohci-omap3.c  |   24 ++-
 drivers/usb/otg/nop-usb-xceiv.c|   39 
 include/linux/usb/nop-usb-xceiv.h  |4 +
 16 files changed, 651 insertions(+), 122 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/omap-usb-host.txt
 create mode 100644 Documentation/devicetree/bindings/mfd/omap-usb-tll.txt
 create mode 100644 Documentation/devicetree/bindings/usb/omap-ehci.txt
 create mode 100644 Documentation/devicetree/bindings/usb/omap3-ohci.txt
 create mode 100644 Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt

-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 01/13] usb: phy: nop: Add device tree support and binding information

2013-02-04 Thread Roger Quadros
The PHY clock, clock rate, VCC regulator and RESET regulator
can now be provided via device tree.

Signed-off-by: Roger Quadros rog...@ti.com
---
 .../devicetree/bindings/usb/usb-nop-xceiv.txt  |   34 
 drivers/usb/otg/nop-usb-xceiv.c|   31 ++
 2 files changed, 65 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt

diff --git a/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt 
b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt
new file mode 100644
index 000..d7e2726
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt
@@ -0,0 +1,34 @@
+USB NOP PHY
+
+Required properties:
+- compatible: should be usb-nop-xceiv
+
+Optional properties:
+- clocks: phandle to the PHY clock. Use as per Documentation/devicetree
+  /bindings/clock/clock-bindings.txt
+  This property is required if clock-frequency is specified.
+
+- clock-names: Should be main_clk
+
+- clock-frequency: the clock frequency (in Hz) that the PHY clock must
+  be configured to.
+
+- vcc-supply: phandle to the regulator that provides RESET to the PHY.
+
+- reset-supply: phandle to the regulator that provides power to the PHY.
+
+Example:
+
+   hsusb1_phy {
+   compatible = usb-nop-xceiv;
+   clock-frequency = 1920;
+   clocks = osc 0;
+   clock-names = main_clk;
+   vcc-supply = hsusb1_vcc_regulator;
+   reset-supply = hsusb1_reset_regulator;
+   };
+
+hsusb1_phy is a NOP USB PHY device that gets its clock from an oscillator
+and expects that clock to be configured to 19.2MHz by the NOP PHY driver.
+hsusb1_vcc_regulator provides power to the PHY and hsusb1_reset_regulator
+controls RESET.
diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
index ac027a1..adbb7ab 100644
--- a/drivers/usb/otg/nop-usb-xceiv.c
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -34,6 +34,7 @@
 #include linux/slab.h
 #include linux/clk.h
 #include linux/regulator/consumer.h
+#include linux/of.h
 
 struct nop_usb_xceiv {
struct usb_phy  phy;
@@ -138,8 +139,19 @@ static int nop_set_host(struct usb_otg *otg, struct 
usb_bus *host)
return 0;
 }
 
+static void nop_xeiv_get_dt_pdata(struct device *dev,
+   struct nop_usb_xceiv_platform_data *pdata)
+{
+   struct device_node *node = dev-of_node;
+   u32 clk_rate;
+
+   if (!of_property_read_u32(node, clock-frequency, clk_rate))
+   pdata-clk_rate = clk_rate;
+}
+
 static int nop_usb_xceiv_probe(struct platform_device *pdev)
 {
+   struct device *dev = pdev-dev;
struct nop_usb_xceiv_platform_data *pdata = pdev-dev.platform_data;
struct nop_usb_xceiv*nop;
enum usb_phy_type   type = USB_PHY_TYPE_USB2;
@@ -153,6 +165,17 @@ static int nop_usb_xceiv_probe(struct platform_device 
*pdev)
if (!nop-phy.otg)
return -ENOMEM;
 
+   if (dev-of_node) {
+   pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+   if (!pdata) {
+   dev_err(dev, Memory allocation failure\n);
+   return -ENOMEM;
+   }
+   nop_xeiv_get_dt_pdata(dev, pdata);
+   } else {
+   pdata = dev-platform_data;
+   }
+
if (pdata)
type = pdata-type;
 
@@ -236,12 +259,20 @@ static int nop_usb_xceiv_remove(struct platform_device 
*pdev)
return 0;
 }
 
+static const struct of_device_id nop_xceiv_dt_ids[] = {
+   { .compatible = usb-nop-xceiv },
+   { }
+};
+
+MODULE_DEVICE_TABLE(of, nop_xceiv_dt_ids);
+
 static struct platform_driver nop_usb_xceiv_driver = {
.probe  = nop_usb_xceiv_probe,
.remove = nop_usb_xceiv_remove,
.driver = {
.name   = nop_usb_xceiv,
.owner  = THIS_MODULE,
+   .of_match_table = of_match_ptr(nop_xceiv_dt_ids),
},
 };
 
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 02/13] USB: phy: nop: Defer probe if device needs VCC/RESET

2013-02-04 Thread Roger Quadros
Add 2 flags, needs_vcc and needs_reset to platform data.
If the flag is set and the regulator couldn't be found
then we bail out with -EPROBE_DEFER.

For device tree boot we depend on presensce of vcc-supply/
reset-supply properties to decide if we should bail out
with -EPROBE_DEFER or just continue in case the regulator
can't be found.

This is required for proper functionality in cases where the
regulator is needed but is probed later than the PHY device.

Signed-off-by: Roger Quadros rog...@ti.com
---
 drivers/usb/otg/nop-usb-xceiv.c   |8 
 include/linux/usb/nop-usb-xceiv.h |4 
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
index adbb7ab..7860e7569 100644
--- a/drivers/usb/otg/nop-usb-xceiv.c
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -147,6 +147,10 @@ static void nop_xeiv_get_dt_pdata(struct device *dev,
 
if (!of_property_read_u32(node, clock-frequency, clk_rate))
pdata-clk_rate = clk_rate;
+   if (of_property_read_bool(node, vcc-supply))
+   pdata-needs_vcc = true;
+   if (of_property_read_bool(node, reset-supply))
+   pdata-needs_reset = true;
 }
 
 static int nop_usb_xceiv_probe(struct platform_device *pdev)
@@ -205,12 +209,16 @@ static int nop_usb_xceiv_probe(struct platform_device 
*pdev)
if (IS_ERR(nop-vcc)) {
dev_dbg(pdev-dev, Error getting vcc regulator: %ld\n,
PTR_ERR(nop-vcc));
+   if (pdata-needs_vcc)
+   return -EPROBE_DEFER;
}
 
nop-reset = devm_regulator_get(pdev-dev, reset);
if (IS_ERR(nop-reset)) {
dev_dbg(pdev-dev, Error getting reset regulator: %ld\n,
PTR_ERR(nop-reset));
+   if (pdata-needs_reset)
+   return -EPROBE_DEFER;
}
 
nop-dev= pdev-dev;
diff --git a/include/linux/usb/nop-usb-xceiv.h 
b/include/linux/usb/nop-usb-xceiv.h
index 3265b61..148d351 100644
--- a/include/linux/usb/nop-usb-xceiv.h
+++ b/include/linux/usb/nop-usb-xceiv.h
@@ -6,6 +6,10 @@
 struct nop_usb_xceiv_platform_data {
enum usb_phy_type type;
unsigned long clk_rate;
+
+   /* if set fails with -EPROBE_DEFER if can't get regulator */
+   unsigned int needs_vcc:1;
+   unsigned int needs_reset:1;
 };
 
 #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE)  
defined(MODULE))
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 04/13] mfd: omap-usb-tll: Add device tree support

2013-02-04 Thread Roger Quadros
Enable this driver to probe in device tree boot.

CC: Samuel Ortiz sa...@linux.intel.com
Signed-off-by: Roger Quadros rog...@ti.com
---
 .../devicetree/bindings/mfd/omap-usb-tll.txt   |   17 +
 drivers/mfd/omap-usb-tll.c |9 +
 2 files changed, 26 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/omap-usb-tll.txt

diff --git a/Documentation/devicetree/bindings/mfd/omap-usb-tll.txt 
b/Documentation/devicetree/bindings/mfd/omap-usb-tll.txt
new file mode 100644
index 000..835cf4f
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/omap-usb-tll.txt
@@ -0,0 +1,17 @@
+OMAP HS USB Host TLL (Transceiver-Less Interface)
+
+Required properties:
+
+- compatible : should be ti,usbhs-tll
+- reg : should contain one register range i.e. start and length
+- interrupts : should contain the TLL module's interrupt
+- ti,hwmod : must contain usb_tll_hs
+
+Example:
+
+   usbhstll: usbhstll@0x4a062000 {
+   compatible = ti,usbhs-tll;
+   reg = 0x4a062000 0x1000;
+   interrupts = 78;
+   ti,hwmods = usb_tll_hs;
+ };
diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index f7d2568..f7afb22 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -28,6 +28,7 @@
 #include linux/err.h
 #include linux/pm_runtime.h
 #include linux/platform_data/usb-omap.h
+#include linux/of.h
 
 #define USBTLL_DRIVER_NAME usbhs_tll
 
@@ -311,10 +312,18 @@ static int usbtll_omap_remove(struct platform_device 
*pdev)
return 0;
 }
 
+static const struct of_device_id usbtll_omap_dt_ids[] = {
+   { .compatible = ti,usbhs-tll },
+   { }
+};
+
+MODULE_DEVICE_TABLE(of, usbtll_omap_dt_ids);
+
 static struct platform_driver usbtll_omap_driver = {
.driver = {
.name   = (char *)usbtll_driver_name,
.owner  = THIS_MODULE,
+   .of_match_table = of_match_ptr(usbtll_omap_dt_ids),
},
.probe  = usbtll_omap_probe,
.remove = usbtll_omap_remove,
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 05/13] USB: ehci-omap: Get platform resources by index rather than by name

2013-02-04 Thread Roger Quadros
Since there is only one resource per type we don't really need
to use resource name to obtain it. This also also makes it easier
for device tree adaptation.

Signed-off-by: Roger Quadros rog...@ti.com
---
 drivers/usb/host/ehci-omap.c |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 60c4a2d..5a831aef 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -148,14 +148,13 @@ static int ehci_hcd_omap_probe(struct platform_device 
*pdev)
return -ENODEV;
}
 
-   irq = platform_get_irq_byname(pdev, ehci-irq);
+   irq = platform_get_irq(pdev, 0);
if (irq  0) {
dev_err(dev, EHCI irq failed\n);
return -ENODEV;
}
 
-   res =  platform_get_resource_byname(pdev,
-   IORESOURCE_MEM, ehci);
+   res =  platform_get_resource(pdev, IORESOURCE_MEM, 0);
regs = devm_ioremap_resource(dev, res);
if (IS_ERR(regs)) {
dev_err(dev, Resource request/ioremap failed\n);
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 03/13] mfd: omap-usb-tll: move configuration code to omap_tll_init()

2013-02-04 Thread Roger Quadros
This is because we want to get rid of platform_data usage from probe().
The only information we need is PORT_MODE, and this can be supplied
to us by the user (i.e. omap-usb-host.c).

We also move channel clock management from runtime PM handlers into
omap_tll_enable/disable().

CC: Samuel Ortiz sa...@linux.intel.com
Signed-off-by: Roger Quadros rog...@ti.com
---
 drivers/mfd/omap-usb-host.c |7 +-
 drivers/mfd/omap-usb-tll.c  |  204 +--
 drivers/mfd/omap-usb.h  |5 +-
 3 files changed, 107 insertions(+), 109 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 502a779..f8ed08e 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -278,7 +278,7 @@ static int usbhs_runtime_resume(struct device *dev)
 
dev_dbg(dev, usbhs_runtime_resume\n);
 
-   omap_tll_enable();
+   omap_tll_enable(pdata);
 
if (!IS_ERR(omap-ehci_logic_fck))
clk_enable(omap-ehci_logic_fck);
@@ -353,7 +353,7 @@ static int usbhs_runtime_suspend(struct device *dev)
if (!IS_ERR(omap-ehci_logic_fck))
clk_disable(omap-ehci_logic_fck);
 
-   omap_tll_disable();
+   omap_tll_disable(pdata);
 
return 0;
 }
@@ -499,6 +499,9 @@ static int usbhs_omap_probe(struct platform_device *pdev)
 
omap-pdata = pdata;
 
+   /* Initialize the TLL subsystem */
+   omap_tll_init(pdata);
+
pm_runtime_enable(dev);
 
platform_set_drvdata(pdev, omap);
diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index 0aef1a7..f7d2568 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -1,8 +1,9 @@
 /**
  * omap-usb-tll.c - The USB TLL driver for OMAP EHCI  OHCI
  *
- * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com
+ * Copyright (C) 2012-2013 Texas Instruments Incorporated - http://www.ti.com
  * Author: Keshava Munegowda keshava_mgo...@ti.com
+ * Author: Roger Quadros rog...@ti.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  of
@@ -105,8 +106,8 @@
 
 struct usbtll_omap {
int nch;/* num. of channels */
-   struct usbhs_omap_platform_data *pdata;
struct clk  **ch_clk;
+   void __iomem*base;
 };
 
 /*-*/
@@ -210,14 +211,10 @@ static unsigned ohci_omap3_fslsmode(enum 
usbhs_omap_port_mode mode)
 static int usbtll_omap_probe(struct platform_device *pdev)
 {
struct device   *dev =  pdev-dev;
-   struct usbhs_omap_platform_data *pdata = dev-platform_data;
-   void __iomem*base;
struct resource *res;
struct usbtll_omap  *tll;
-   unsignedreg;
int ret = 0;
int i, ver;
-   bool needs_tll;
 
dev_dbg(dev, starting TI HSUSB TLL Controller\n);
 
@@ -227,16 +224,9 @@ static int usbtll_omap_probe(struct platform_device *pdev)
return -ENOMEM;
}
 
-   if (!pdata) {
-   dev_err(dev, Platform data missing\n);
-   return -ENODEV;
-   }
-
-   tll-pdata = pdata;
-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   base = devm_request_and_ioremap(dev, res);
-   if (!base) {
+   tll-base = devm_request_and_ioremap(dev, res);
+   if (!tll-base) {
ret = -EADDRNOTAVAIL;
dev_err(dev, Resource request/ioremap failed:%d\n, ret);
return ret;
@@ -246,7 +236,7 @@ static int usbtll_omap_probe(struct platform_device *pdev)
pm_runtime_enable(dev);
pm_runtime_get_sync(dev);
 
-   ver =  usbtll_read(base, OMAP_USBTLL_REVISION);
+   ver =  usbtll_read(tll-base, OMAP_USBTLL_REVISION);
switch (ver) {
case OMAP_USBTLL_REV1:
case OMAP_USBTLL_REV4:
@@ -283,11 +273,77 @@ static int usbtll_omap_probe(struct platform_device *pdev)
dev_dbg(dev, can't get clock : %s\n, clkname);
}
 
+   pm_runtime_put_sync(dev);
+   /* only after this can omap_tll_enable/disable work */
+   spin_lock(tll_lock);
+   tll_dev = dev;
+   spin_unlock(tll_lock);
+
+   return 0;
+
+err_clk_alloc:
+   pm_runtime_put_sync(dev);
+   pm_runtime_disable(dev);
+
+   return ret;
+}
+
+/**
+ * usbtll_omap_remove - shutdown processing for UHH  TLL HCDs
+ * @pdev: USB Host Controller being removed
+ *
+ * Reverses the effect of usbtll_omap_probe().
+ */
+static int usbtll_omap_remove(struct platform_device *pdev)
+{
+   struct usbtll_omap *tll

[PATCH 06/13] USB: ohci-omap3: Get platform resources by index rather than by name

2013-02-04 Thread Roger Quadros
Since there is only one resource per type we don't really need
to use resource name to obtain it. This also also makes it easier
for device tree adaptation.

Signed-off-by: Roger Quadros rog...@ti.com
---
 drivers/usb/host/ohci-omap3.c |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/ohci-omap3.c b/drivers/usb/host/ohci-omap3.c
index eb35d96..5ed28c5 100644
--- a/drivers/usb/host/ohci-omap3.c
+++ b/drivers/usb/host/ohci-omap3.c
@@ -141,14 +141,13 @@ static int ohci_hcd_omap3_probe(struct platform_device 
*pdev)
return -ENODEV;
}
 
-   irq = platform_get_irq_byname(pdev, ohci-irq);
+   irq = platform_get_irq(pdev, 0);
if (irq  0) {
dev_err(dev, OHCI irq failed\n);
return -ENODEV;
}
 
-   res = platform_get_resource_byname(pdev,
-   IORESOURCE_MEM, ohci);
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(dev, UHH OHCI get resource failed\n);
return -ENOMEM;
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 07/13] USB: ohci-omap3: Add device tree support and binding information

2013-02-04 Thread Roger Quadros
Allows the OHCI controller found in OMAP3 and later chips to
be specified via device tree.

Signed-off-by: Roger Quadros rog...@ti.com
---
 .../devicetree/bindings/usb/omap3-ohci.txt |   17 +
 drivers/usb/host/ohci-omap3.c  |   19 +++
 2 files changed, 36 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/omap3-ohci.txt

diff --git a/Documentation/devicetree/bindings/usb/omap3-ohci.txt 
b/Documentation/devicetree/bindings/usb/omap3-ohci.txt
new file mode 100644
index 000..aabbfdc
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/omap3-ohci.txt
@@ -0,0 +1,17 @@
+OMAP HS USB OHCI controller (OMAP3 and later)
+
+Required properties:
+
+- compatible: should be ti,omap3-ohci
+- reg: should contain one register range i.e. start and length
+- interrupt-parent: phandle to the interrupt controller
+- interrupts: description of the interrupt line
+
+Example for OMAP4:
+
+usbhsohci: ohci@0x4a064800 {
+   compatible = ti,omap3-ohci, usb-ohci;
+   reg = 0x4a064800 0x400;
+   interrupt-parent = gic;
+   interrupts = 0 76 0x4;
+};
diff --git a/drivers/usb/host/ohci-omap3.c b/drivers/usb/host/ohci-omap3.c
index 5ed28c5..b0bfab1 100644
--- a/drivers/usb/host/ohci-omap3.c
+++ b/drivers/usb/host/ohci-omap3.c
@@ -31,6 +31,8 @@
 
 #include linux/platform_device.h
 #include linux/pm_runtime.h
+#include linux/of.h
+#include linux/dma-mapping.h
 
 /*-*/
 
@@ -112,6 +114,8 @@ static const struct hc_driver ohci_omap3_hc_driver = {
 
 /*-*/
 
+static u64 omap_ohci_dma_mask = DMA_BIT_MASK(32);
+
 /*
  * configure so an HC device and id are always provided
  * always called with process context; sleeping is OK
@@ -159,6 +163,13 @@ static int ohci_hcd_omap3_probe(struct platform_device 
*pdev)
return -ENOMEM;
}
 
+   /*
+* Right now device-tree probed devices don't get dma_mask set.
+* Since shared usb code relies on it, set it here for now.
+* Once we have dma capability bindings this can go away.
+*/
+   if (!pdev-dev.dma_mask)
+   pdev-dev.dma_mask = omap_ohci_dma_mask;
 
hcd = usb_create_hcd(ohci_omap3_hc_driver, dev,
dev_name(dev));
@@ -228,12 +239,20 @@ static void ohci_hcd_omap3_shutdown(struct 
platform_device *pdev)
hcd-driver-shutdown(hcd);
 }
 
+static const struct of_device_id omap_ohci_dt_ids[] = {
+   { .compatible = ti,omap3-ohci },
+   { }
+};
+
+MODULE_DEVICE_TABLE(of, omap_ohci_dt_ids);
+
 static struct platform_driver ohci_hcd_omap3_driver = {
.probe  = ohci_hcd_omap3_probe,
.remove = ohci_hcd_omap3_remove,
.shutdown   = ohci_hcd_omap3_shutdown,
.driver = {
.name   = ohci-omap3,
+   .of_match_table = of_match_ptr(omap_ohci_dt_ids),
},
 };
 
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 08/13] USB: ehci-omap: Add device tree support and binding information

2013-02-04 Thread Roger Quadros
Allows the OMAP EHCI controller to be specified via device tree.

Signed-off-by: Roger Quadros rog...@ti.com
---
 .../devicetree/bindings/usb/omap-ehci.txt  |   34 ++
 drivers/usb/host/ehci-omap.c   |   36 +++-
 2 files changed, 69 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/omap-ehci.txt

diff --git a/Documentation/devicetree/bindings/usb/omap-ehci.txt 
b/Documentation/devicetree/bindings/usb/omap-ehci.txt
new file mode 100644
index 000..90e6e3a
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/omap-ehci.txt
@@ -0,0 +1,34 @@
+OMAP HS USB EHCI controller
+
+This device is usually the child of the omap-usb-host
+Documentation/devicetree/bindings/mfd/omap-usb-host.txt
+
+Required properties:
+
+- compatible: should be ti,omap-ehci
+- reg: should contain one register range i.e. start and length
+- interrupt-parent: phandle to the interrupt controller
+- interrupts: description of the interrupt line
+
+Optional properties:
+
+- phy: list of phandles to PHY nodes.
+  This property is required if at least one of the ports are in
+  PHY mode i.e. OMAP_EHCI_PORT_MODE_PHY
+
+To specify the port mode, see
+Documentation/devicetree/bindings/mfd/omap-usb-host.txt
+
+Example for OMAP4:
+
+usbhsehci: ehci@0x4a064c00 {
+   compatible = ti,omap-ehci, usb-ehci;
+   reg = 0x4a064c00 0x400;
+   interrupt-parent = gic;
+   interrupts = 0 77 0x4;
+};
+
+usbhsehci {
+   phy = hsusb1_phy 0 hsusb3_phy;
+};
+
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 5a831aef..15cc419 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -48,6 +48,8 @@
 #include linux/clk.h
 #include linux/usb.h
 #include linux/usb/hcd.h
+#include linux/of.h
+#include linux/dma-mapping.h
 
 #include ehci.h
 
@@ -121,6 +123,8 @@ static const struct ehci_driver_overrides 
ehci_omap_overrides __initdata = {
.extra_priv_size = sizeof(struct omap_hcd),
 };
 
+static u64 omap_ehci_dma_mask = DMA_BIT_MASK(32);
+
 /**
  * ehci_hcd_omap_probe - initialize TI-based HCDs
  *
@@ -148,6 +152,17 @@ static int ehci_hcd_omap_probe(struct platform_device 
*pdev)
return -ENODEV;
}
 
+   /* For DT boot, get platform data from parent. i.e. usbhshost */
+   if (dev-of_node) {
+   pdata = dev-parent-platform_data;
+   dev-platform_data = pdata;
+   }
+
+   if (!pdata) {
+   dev_err(dev, Missing platform data\n);
+   return -ENODEV;
+   }
+
irq = platform_get_irq(pdev, 0);
if (irq  0) {
dev_err(dev, EHCI irq failed\n);
@@ -161,6 +176,14 @@ static int ehci_hcd_omap_probe(struct platform_device 
*pdev)
return PTR_ERR(regs);
}
 
+   /*
+* Right now device-tree probed devices don't get dma_mask set.
+* Since shared usb code relies on it, set it here for now.
+* Once we have dma capability bindings this can go away.
+*/
+   if (!pdev-dev.dma_mask)
+   pdev-dev.dma_mask = omap_ehci_dma_mask;
+
hcd = usb_create_hcd(ehci_omap_hc_driver, dev,
dev_name(dev));
if (!hcd) {
@@ -185,7 +208,10 @@ static int ehci_hcd_omap_probe(struct platform_device 
*pdev)
continue;
 
/* get the PHY device */
-   phy = devm_usb_get_phy_dev(dev, i);
+   if (dev-of_node)
+   phy = devm_usb_get_phy_by_phandle(dev, phy, i);
+   else
+   phy = devm_usb_get_phy_dev(dev, i);
if (IS_ERR(phy) || !phy) {
ret = IS_ERR(phy) ? PTR_ERR(phy) : -ENODEV;
dev_err(dev, Can't get PHY device for port %d: %d\n,
@@ -275,6 +301,13 @@ static void ehci_hcd_omap_shutdown(struct platform_device 
*pdev)
hcd-driver-shutdown(hcd);
 }
 
+static const struct of_device_id omap_ehci_dt_ids[] = {
+   { .compatible = ti,omap-ehci },
+   { }
+};
+
+MODULE_DEVICE_TABLE(of, omap_ehci_dt_ids);
+
 static struct platform_driver ehci_hcd_omap_driver = {
.probe  = ehci_hcd_omap_probe,
.remove = ehci_hcd_omap_remove,
@@ -283,6 +316,7 @@ static struct platform_driver ehci_hcd_omap_driver = {
/*.resume   = ehci_hcd_omap_resume, */
.driver = {
.name   = hcd_name,
+   .of_match_table = of_match_ptr(omap_ehci_dt_ids),
}
 };
 
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 09/13] mfd: omap-usb-host: Add device tree support and binding information

2013-02-04 Thread Roger Quadros
Allows the OMAP HS USB host controller to be specified
via device tree.

CC: Samuel Ortiz sa...@linux.intel.com
Signed-off-by: Roger Quadros rog...@ti.com
---
 .../devicetree/bindings/mfd/omap-usb-host.txt  |   68 
 drivers/mfd/omap-usb-host.c|   83 ++--
 2 files changed, 145 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/omap-usb-host.txt

diff --git a/Documentation/devicetree/bindings/mfd/omap-usb-host.txt 
b/Documentation/devicetree/bindings/mfd/omap-usb-host.txt
new file mode 100644
index 000..2196893
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/omap-usb-host.txt
@@ -0,0 +1,68 @@
+OMAP HS USB Host
+
+Required properties:
+
+- compatible: should be ti,usbhs-host
+- reg: should contain one register range i.e. start and length
+- ti,hwmods: must contain usb_host_hs
+
+Optional properties:
+
+- nports: number of USB ports. Usually this is automatically detected
+  from the IP's revision register but can be overridden by specifying
+  this property.
+
+- portN_mode: Integer specifying the port mode for port N, where N can be
+  from 1 to nports. The port mode must be as per enum usbhs_omap_port_mode
+  in include/linux/platform_data/usb-omap.h
+  If the port mode is not specified, that port is treated as unused.
+
+- single_ulpi_bypass: Must be present if the controller contains a single
+  ULPI bypass control bit. e.g. OMAP3 silicon = ES2.1
+
+Required properties if child node exists:
+
+- #address-cells: Must be 1
+- #size-cells: Must be 1
+- ranges: must be present
+
+Properties for children:
+
+The OMAP HS USB Host subsystem contains EHCI and OHCI controllers.
+See Documentation/devicetree/bindings/usb/omap-ehci.txt and
+omap3-ohci.txt
+
+Example for OMAP4:
+
+usbhshost: usbhshost@0x4a064000 {
+   compatible = ti,usbhs-host;
+   reg = 0x4a064000 0x800;
+   ti,hwmods = usb_host_hs;
+   #address-cells = 1;
+   #size-cells = 1;
+   ranges;
+
+   usbhsohci: ohci@0x4a064800 {
+   compatible = ti,omap3-ohci, usb-ohci;
+   reg = 0x4a064800 0x400;
+   interrupt-parent = gic;
+   interrupts = 0 76 0x4;
+   };
+
+   usbhsehci: ehci@0x4a064c00 {
+   compatible = ti,omap-ehci, usb-ehci;
+   reg = 0x4a064c00 0x400;
+   interrupt-parent = gic;
+   interrupts = 0 77 0x4;
+   };
+};
+
+usbhshost {
+   port1_mode = 1; /* OMAP_EHCI_PORT_MODE_PHY */
+   port2_mode = 2; /* OMAP_EHCI_PORT_MODE_TLL */
+   port3_mode = 1; /* OMAP_EHCI_PORT_MODE_PHY */
+};
+
+usbhsehci {
+   phy = hsusb1_phy 0 hsusb3_phy;
+};
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index f8ed08e..0f67856 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -1,8 +1,9 @@
 /**
  * omap-usb-host.c - The USBHS core driver for OMAP EHCI  OHCI
  *
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com
+ * Copyright (C) 2011-2013 Texas Instruments Incorporated - http://www.ti.com
  * Author: Keshava Munegowda keshava_mgo...@ti.com
+ * Author: Roger Quadros rog...@ti.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  of
@@ -27,6 +28,8 @@
 #include linux/platform_device.h
 #include linux/platform_data/usb-omap.h
 #include linux/pm_runtime.h
+#include linux/of.h
+#include linux/of_platform.h
 
 #include omap-usb.h
 
@@ -464,6 +467,37 @@ static void omap_usbhs_init(struct device *dev)
pm_runtime_put_sync(dev);
 }
 
+static int usbhs_omap_get_dt_pdata(struct device_node *node,
+   struct usbhs_omap_platform_data *pdata)
+{
+   int ret, i;
+
+   ret = of_property_read_u32(node, nports, pdata-nports);
+   if (ret)
+   pdata-nports = 0;
+
+   /* get port modes */
+   for (i = 0; i  OMAP3_HS_USB_PORTS; i++) {
+   char prop[11];
+
+   snprintf(prop, sizeof(prop), port%d_mode, i + 1);
+   ret = of_property_read_u32(node, prop, pdata-port_mode[i]);
+   if (ret)
+   pdata-port_mode[i] = OMAP_USBHS_PORT_MODE_UNUSED;
+   }
+
+   /* get flags */
+   pdata-single_ulpi_bypass = of_property_read_bool(node,
+   single_ulpi_bypass);
+   return 0;
+}
+
+static struct of_device_id usbhs_child_match_table[] __initdata = {
+   { .compatible = ti,omap-ehci, },
+   { .compatible = ti,omap-ohci, },
+   { }
+};
+
 /**
  * usbhs_omap_probe - initialize TI-based HCDs
  *
@@ -479,6 +513,21 @@ static int usbhs_omap_probe(struct platform_device *pdev)
int i;
boolneed_logic_fck;
 
+   if (dev-of_node) {
+   /* For DT boot we populate platform data from OF node

[PATCH 10/13] ARM: dts: OMAP4: Add HS USB Host IP nodes

2013-02-04 Thread Roger Quadros
Adds device nodes for HS USB Host module, TLL module,
OHCI and EHCI controllers.

Signed-off-by: Roger Quadros rog...@ti.com
---
 arch/arm/boot/dts/omap4.dtsi |   30 ++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 739bb79..3429280 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -529,5 +529,35 @@
ti,hwmods = timer11;
ti,timer-pwm;
};
+
+   usbhstll: usbhstll@0x4a062000 {
+   compatible = ti,usbhs-tll;
+   reg = 0x4a062000 0x1000;
+   interrupts = 0 78 0x4;
+   ti,hwmods = usb_tll_hs;
+   };
+
+   usbhshost: usbhshost@0x4a064000 {
+   compatible = ti,usbhs-host;
+   reg = 0x4a064000 0x800;
+   ti,hwmods = usb_host_hs;
+   #address-cells = 1;
+   #size-cells = 1;
+   ranges;
+
+   usbhsohci: ohci@0x4a064800 {
+   compatible = ti,omap3-ohci, usb-ohci;
+   reg = 0x4a064800 0x400;
+   interrupt-parent = gic;
+   interrupts = 0 76 0x4;
+   };
+
+   usbhsehci: ehci@0x4a064c00 {
+   compatible = ti,omap-ehci, usb-ehci;
+   reg = 0x4a064c00 0x400;
+   interrupt-parent = gic;
+   interrupts = 0 77 0x4;
+   };
+   };
};
 };
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 11/13] ARM: dts: omap4-panda: Add USB Host support

2013-02-04 Thread Roger Quadros
Provide the RESET and Power regulators for the USB PHY,
the USB Host port mode and the PHY device.

Also provide pin multiplexer information for the USB host
pins.

Signed-off-by: Roger Quadros rog...@ti.com
---
 arch/arm/boot/dts/omap4-panda.dts |   55 +
 1 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/omap4-panda.dts 
b/arch/arm/boot/dts/omap4-panda.dts
index 4122efe..fe2d3d4 100644
--- a/arch/arm/boot/dts/omap4-panda.dts
+++ b/arch/arm/boot/dts/omap4-panda.dts
@@ -57,6 +57,35 @@
AFML, Line In,
AFMR, Line In;
};
+
+   /* HS USB Port 1 RESET */
+   hsusb1_reset: hsusb1_reset_reg {
+   compatible = regulator-fixed;
+   regulator-name = hsusb1_reset;
+   regulator-min-microvolt = 330;
+   regulator-max-microvolt = 330;
+   gpio = gpio2 30 0;   /* gpio_62 */
+   startup-delay-us = 7;
+   enable-active-high;
+   };
+
+   /* HS USB Port 1 Power */
+   hsusb1_power: hsusb1_power_reg {
+   compatible = regulator-fixed;
+   regulator-name = hsusb1_vbus;
+   regulator-min-microvolt = 330;
+   regulator-max-microvolt = 330;
+   gpio = gpio1 1 0;/* gpio_1 */
+   startup-delay-us = 7;
+   enable-active-high;
+   };
+
+   /* HS USB Host PHY on PORT 1 */
+   hsusb1_phy: hsusb1_phy {
+   compatible = usb-nop-xceiv;
+   reset-supply = hsusb1_reset;
+   vcc-supply = hsusb1_power;
+   };
 };
 
 omap4_pmx_core {
@@ -67,6 +96,7 @@
mcbsp1_pins
dss_hdmi_pins
tpd12s015_pins
+   hsusbb1_pins
;
 
twl6040_pins: pinmux_twl6040_pins {
@@ -110,6 +140,23 @@
0x58 0x10b  /* hdmi_hpd.gpio_63 INPUT PULLDOWN | 
MODE3 */
;
};
+
+   hsusbb1_pins: pinmux_hsusbb1_pins {
+   pinctrl-single,pins = 
+   0x82 0x10C  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_clk INPUT | PULLDOWN */
+   0x84 0x4/* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_stp OUTPUT */
+   0x86 0x104  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dir INPUT | PULLDOWN */
+   0x88 0x104  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_nxt INPUT | PULLDOWN */
+   0x8a 0x104  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat0 INPUT | PULLDOWN */
+   0x8c 0x104  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat1 INPUT | PULLDOWN */
+   0x8e 0x104  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat2 INPUT | PULLDOWN */
+   0x90 0x104  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat3 INPUT | PULLDOWN */
+   0x92 0x104  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat4 INPUT | PULLDOWN */
+   0x94 0x104  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat5 INPUT | PULLDOWN */
+   0x96 0x104  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat6 INPUT | PULLDOWN */
+   0x98 0x104  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat7 INPUT | PULLDOWN */
+   ;
+   };
 };
 
 i2c1 {
@@ -206,3 +253,11 @@
 twl_usb_comparator {
usb-supply = vusb;
 };
+
+usbhshost {
+   port1_mode = 1; /* OMAP_EHCI_PORT_MODE_PHY */
+};
+
+usbhsehci {
+   phy = hsusb1_phy;
+};
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 12/13] ARM: dts: OMAP3: Add HS USB Host IP nodes

2013-02-04 Thread Roger Quadros
Adds device nodes for HS USB Host module, TLL module,
OHCI and EHCI controllers.

Signed-off-by: Roger Quadros rog...@ti.com
---
 arch/arm/boot/dts/omap3.dtsi |   31 +++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 1acc261..39442b4 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -397,5 +397,36 @@
ti,timer-alwon;
ti,timer-secure;
};
+
+   usbhstll: usbhstll@0x48062000 {
+   compatible = ti,usbhs-tll;
+   reg = 0x48062000 0x1000;
+   interrupts = 78;
+   ti,hwmods = usb_tll_hs;
+   };
+
+   usbhshost: usbhshost@0x48064000 {
+   compatible = ti,usbhs-host;
+   reg = 0x48064000 0x400;
+   ti,hwmods = usb_host_hs;
+   #address-cells = 1;
+   #size-cells = 1;
+   ranges;
+
+   usbhsohci: ohci@0x48064400 {
+   compatible = ti,omap3-ohci, usb-ohci;
+   reg = 0x48064400 0x400;
+   interrupt-parent = intc;
+   interrupts = 76;
+   };
+
+   usbhsehci: ehci@0x48064800 {
+   compatible = ti,omap-ehci, usb-ehci;
+   reg = 0x48064800 0x400;
+   interrupt-parent = intc;
+   interrupts = 77;
+   };
+   };
+
};
 };
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 13/13] ARM: dts: omap3-beagle: Add USB Host support

2013-02-04 Thread Roger Quadros
Provide RESET and Power regulators for the USB PHY,
the USB Host port mode and the PHY device.

Also provide pin multiplexer information for USB host
pins.

Signed-off-by: Roger Quadros rog...@ti.com
---
 arch/arm/boot/dts/omap3-beagle.dts |   71 
 1 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/omap3-beagle.dts 
b/arch/arm/boot/dts/omap3-beagle.dts
index f624dc8..2c4a6d6 100644
--- a/arch/arm/boot/dts/omap3-beagle.dts
+++ b/arch/arm/boot/dts/omap3-beagle.dts
@@ -38,6 +38,57 @@
};
};
 
+   /* HS USB Port 2 RESET */
+   hsusb2_reset: hsusb2_reset_reg {
+   compatible = regulator-fixed;
+   regulator-name = hsusb2_reset;
+   regulator-min-microvolt = 330;
+   regulator-max-microvolt = 330;
+   gpio = gpio5 19 0;   /* gpio_147 */
+   startup-delay-us = 7;
+   enable-active-high;
+   };
+
+   /* HS USB Port 2 Power */
+   hsusb2_power: hsusb2_power_reg {
+   compatible = regulator-fixed;
+   regulator-name = hsusb2_vbus;
+   regulator-min-microvolt = 330;
+   regulator-max-microvolt = 330;
+   gpio = twl_gpio 18 0;/* GPIO LEDA */
+   startup-delay-us = 7;
+   };
+
+   /* HS USB Host PHY on PORT 2 */
+   hsusb2_phy: hsusb2_phy {
+   compatible = usb-nop-xceiv;
+   reset-supply = hsusb2_reset;
+   vcc-supply = hsusb2_power;
+   };
+};
+
+omap3_pmx_core {
+   pinctrl-names = default;
+   pinctrl-0 = 
+   hsusbb2_pins
+   ;
+
+   hsusbb2_pins: pinmux_hsusbb2_pins {
+   pinctrl-single,pins = 
+   0x5c0 0x3  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_clk OUTPUT */
+   0x5c2 0x3  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_stp OUTPUT */
+   0x5c4 0x10b  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dir INPUT | PULLDOWN */
+   0x5c6 0x10b  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_nxt INPUT | PULLDOWN */
+   0x5c8 0x10b  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat0 INPUT | PULLDOWN */
+   0x5cA 0x10b  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat1 INPUT | PULLDOWN */
+   0x1a4 0x10b  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat2 INPUT | PULLDOWN */
+   0x1a6 0x10b  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat3 INPUT | PULLDOWN */
+   0x1a8 0x10b  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat4 INPUT | PULLDOWN */
+   0x1aa 0x10b  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat5 INPUT | PULLDOWN */
+   0x1ac 0x10b  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat6 INPUT | PULLDOWN */
+   0x1ae 0x10b  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat7 INPUT | PULLDOWN */
+   ;
+   };
 };
 
 i2c1 {
@@ -65,3 +116,23 @@
 mmc3 {
status = disabled;
 };
+
+usbhshost {
+   port2_mode = 1; /* OMAP_EHCI_PORT_MODE_PHY */
+};
+
+usbhsehci {
+   phy = 0 hsusb2_phy;
+};
+
+twl_gpio {
+   ti,use-leds;
+   /* pullups: BIT(1) */
+   ti,pullups = 0x02;
+   /*
+* pulldowns:
+* BIT(2), BIT(6), BIT(7), BIT(8), BIT(13)
+* BIT(15), BIT(16), BIT(17)
+*/
+   ti,pulldowns = 0x03a1c4;
+};
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 01/13] usb: phy: nop: Add device tree support and binding information

2013-02-05 Thread Roger Quadros
On 02/05/2013 09:26 AM, Felipe Balbi wrote:
 Hi,
 
 On Mon, Feb 04, 2013 at 05:58:48PM +0200, Roger Quadros wrote:
 The PHY clock, clock rate, VCC regulator and RESET regulator
 can now be provided via device tree.

 Signed-off-by: Roger Quadros rog...@ti.com
 ---
  .../devicetree/bindings/usb/usb-nop-xceiv.txt  |   34 
 
  drivers/usb/otg/nop-usb-xceiv.c|   31 ++
  2 files changed, 65 insertions(+), 0 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt

 diff --git a/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt 
 b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt
 new file mode 100644
 index 000..d7e2726
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt
 @@ -0,0 +1,34 @@
 +USB NOP PHY
 +
 +Required properties:
 +- compatible: should be usb-nop-xceiv
 +
 +Optional properties:
 +- clocks: phandle to the PHY clock. Use as per Documentation/devicetree
 +  /bindings/clock/clock-bindings.txt
 +  This property is required if clock-frequency is specified.
 +
 +- clock-names: Should be main_clk
 +
 +- clock-frequency: the clock frequency (in Hz) that the PHY clock must
 +  be configured to.
 +
 +- vcc-supply: phandle to the regulator that provides RESET to the PHY.
 +
 +- reset-supply: phandle to the regulator that provides power to the PHY.
 +
 +Example:
 +
 +hsusb1_phy {
 +compatible = usb-nop-xceiv;
 +clock-frequency = 1920;
 +clocks = osc 0;
 +clock-names = main_clk;
 +vcc-supply = hsusb1_vcc_regulator;
 +reset-supply = hsusb1_reset_regulator;
 +};
 +
 +hsusb1_phy is a NOP USB PHY device that gets its clock from an oscillator
 +and expects that clock to be configured to 19.2MHz by the NOP PHY driver.
 +hsusb1_vcc_regulator provides power to the PHY and hsusb1_reset_regulator
 +controls RESET.
 diff --git a/drivers/usb/otg/nop-usb-xceiv.c 
 b/drivers/usb/otg/nop-usb-xceiv.c
 index ac027a1..adbb7ab 100644
 --- a/drivers/usb/otg/nop-usb-xceiv.c
 +++ b/drivers/usb/otg/nop-usb-xceiv.c
 @@ -34,6 +34,7 @@
  #include linux/slab.h
  #include linux/clk.h
  #include linux/regulator/consumer.h
 +#include linux/of.h
  
  struct nop_usb_xceiv {
  struct usb_phy  phy;
 @@ -138,8 +139,19 @@ static int nop_set_host(struct usb_otg *otg, struct 
 usb_bus *host)
  return 0;
  }
  
 +static void nop_xeiv_get_dt_pdata(struct device *dev,
 
 asking to remove, but xeiv != xceiv :-)
 
 +struct nop_usb_xceiv_platform_data *pdata)
 +{
 +struct device_node *node = dev-of_node;
 +u32 clk_rate;
 +
 +if (!of_property_read_u32(node, clock-frequency, clk_rate))
 +pdata-clk_rate = clk_rate;
 +}
 +
  static int nop_usb_xceiv_probe(struct platform_device *pdev)
  {
 +struct device *dev = pdev-dev;
  struct nop_usb_xceiv_platform_data *pdata = pdev-dev.platform_data;
  struct nop_usb_xceiv*nop;
  enum usb_phy_type   type = USB_PHY_TYPE_USB2;
 @@ -153,6 +165,17 @@ static int nop_usb_xceiv_probe(struct platform_device 
 *pdev)
  if (!nop-phy.otg)
  return -ENOMEM;
  
 +if (dev-of_node) {
 +pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
 +if (!pdata) {
 +dev_err(dev, Memory allocation failure\n);
 +return -ENOMEM;
 +}
 +nop_xeiv_get_dt_pdata(dev, pdata);
 
 actually, I would prefer to not create pdata at all. I mean, ideally
 pdata would be used to initialize fields in your own structure, so first
 move clk_rate to your own private structure, copy pdata's clk_rate value
 to that, then you don't need this hackery when using DT.
 
OK, got it. Will revise.

cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 02/13] USB: phy: nop: Defer probe if device needs VCC/RESET

2013-02-05 Thread Roger Quadros
On 02/05/2013 07:54 AM, kishon wrote:
 On Monday 04 February 2013 09:28 PM, Roger Quadros wrote:
 Add 2 flags, needs_vcc and needs_reset to platform data.
 If the flag is set and the regulator couldn't be found
 then we bail out with -EPROBE_DEFER.

 For device tree boot we depend on presensce of vcc-supply/
 reset-supply properties to decide if we should bail out
 with -EPROBE_DEFER or just continue in case the regulator
 can't be found.

 This is required for proper functionality in cases where the
 regulator is needed but is probed later than the PHY device.

 Signed-off-by: Roger Quadros rog...@ti.com
 ---
   drivers/usb/otg/nop-usb-xceiv.c   |8 
   include/linux/usb/nop-usb-xceiv.h |4 
   2 files changed, 12 insertions(+), 0 deletions(-)

 diff --git a/drivers/usb/otg/nop-usb-xceiv.c 
 b/drivers/usb/otg/nop-usb-xceiv.c
 index adbb7ab..7860e7569 100644
 --- a/drivers/usb/otg/nop-usb-xceiv.c
 +++ b/drivers/usb/otg/nop-usb-xceiv.c
 @@ -147,6 +147,10 @@ static void nop_xeiv_get_dt_pdata(struct device *dev,

   if (!of_property_read_u32(node, clock-frequency, clk_rate))
   pdata-clk_rate = clk_rate;
 +if (of_property_read_bool(node, vcc-supply))
 +pdata-needs_vcc = true;
 This can be written as..
 pdata-needs_vcc = of_property_read_bool(node, vcc-supply);

OK.

 
 +if (of_property_read_bool(node, reset-supply))
 +pdata-needs_reset = true;
 same here..
   }

   static int nop_usb_xceiv_probe(struct platform_device *pdev)
 @@ -205,12 +209,16 @@ static int nop_usb_xceiv_probe(struct platform_device 
 *pdev)
   if (IS_ERR(nop-vcc)) {
   dev_dbg(pdev-dev, Error getting vcc regulator: %ld\n,
   PTR_ERR(nop-vcc));
 +if (pdata-needs_vcc)
 +return -EPROBE_DEFER;
   }

   nop-reset = devm_regulator_get(pdev-dev, reset);
   if (IS_ERR(nop-reset)) {
   dev_dbg(pdev-dev, Error getting reset regulator: %ld\n,
   PTR_ERR(nop-reset));
 +if (pdata-needs_reset)
 +return -EPROBE_DEFER;
   }

   nop-dev= pdev-dev;
 diff --git a/include/linux/usb/nop-usb-xceiv.h 
 b/include/linux/usb/nop-usb-xceiv.h
 index 3265b61..148d351 100644
 --- a/include/linux/usb/nop-usb-xceiv.h
 +++ b/include/linux/usb/nop-usb-xceiv.h
 @@ -6,6 +6,10 @@
   struct nop_usb_xceiv_platform_data {
   enum usb_phy_type type;
   unsigned long clk_rate;
 +
 +/* if set fails with -EPROBE_DEFER if can't get regulator */
 +unsigned int needs_vcc:1;
 +unsigned int needs_reset:1;
 
 how about u8 here?

Not sure. Bitfields are usually defined as unsigned int.

cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 04/13] mfd: omap-usb-tll: Add device tree support

2013-02-05 Thread Roger Quadros
On 02/05/2013 08:04 AM, kishon wrote:
 On Monday 04 February 2013 09:28 PM, Roger Quadros wrote:
 Enable this driver to probe in device tree boot.

 CC: Samuel Ortiz sa...@linux.intel.com
 Signed-off-by: Roger Quadros rog...@ti.com
 ---
   .../devicetree/bindings/mfd/omap-usb-tll.txt   |   17 +
   drivers/mfd/omap-usb-tll.c |9 +
   2 files changed, 26 insertions(+), 0 deletions(-)
   create mode 100644 Documentation/devicetree/bindings/mfd/omap-usb-tll.txt

 diff --git a/Documentation/devicetree/bindings/mfd/omap-usb-tll.txt 
 b/Documentation/devicetree/bindings/mfd/omap-usb-tll.txt
 new file mode 100644
 index 000..835cf4f
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/mfd/omap-usb-tll.txt
 @@ -0,0 +1,17 @@
 +OMAP HS USB Host TLL (Transceiver-Less Interface)
 +
 +Required properties:
 +
 +- compatible : should be ti,usbhs-tll
 +- reg : should contain one register range i.e. start and length
 +- interrupts : should contain the TLL module's interrupt
 +- ti,hwmod : must contain usb_tll_hs
 +
 +Example:
 +
 +usbhstll: usbhstll@0x4a062000 {
 The node name shouldn't have 0x. This comment applies to all your patches 
 adding device tree support.

OK, will fix.

cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 09/13] mfd: omap-usb-host: Add device tree support and binding information

2013-02-05 Thread Roger Quadros
On 02/05/2013 08:16 AM, kishon wrote:
 On Monday 04 February 2013 09:28 PM, Roger Quadros wrote:
 Allows the OMAP HS USB host controller to be specified
 via device tree.

 CC: Samuel Ortiz sa...@linux.intel.com
 Signed-off-by: Roger Quadros rog...@ti.com
 ---
   .../devicetree/bindings/mfd/omap-usb-host.txt  |   68 
   drivers/mfd/omap-usb-host.c|   83 
 ++--
   2 files changed, 145 insertions(+), 6 deletions(-)
   create mode 100644 Documentation/devicetree/bindings/mfd/omap-usb-host.txt

 diff --git a/Documentation/devicetree/bindings/mfd/omap-usb-host.txt 
 b/Documentation/devicetree/bindings/mfd/omap-usb-host.txt
 new file mode 100644
 index 000..2196893
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/mfd/omap-usb-host.txt
 @@ -0,0 +1,68 @@
 +OMAP HS USB Host
 +
 +Required properties:
 +
 +- compatible: should be ti,usbhs-host
 +- reg: should contain one register range i.e. start and length
 +- ti,hwmods: must contain usb_host_hs
 +
 +Optional properties:
 +
 +- nports: number of USB ports. Usually this is automatically detected
 +  from the IP's revision register but can be overridden by specifying
 +  this property.
 +
 +- portN_mode: Integer specifying the port mode for port N, where N can be
 +  from 1 to nports. The port mode must be as per enum usbhs_omap_port_mode
 +  in include/linux/platform_data/usb-omap.h
 +  If the port mode is not specified, that port is treated as unused.
 +
 +- single_ulpi_bypass: Must be present if the controller contains a single
 +  ULPI bypass control bit. e.g. OMAP3 silicon = ES2.1
 +
 +Required properties if child node exists:
 +
 +- #address-cells: Must be 1
 +- #size-cells: Must be 1
 +- ranges: must be present
 +
 +Properties for children:
 +
 +The OMAP HS USB Host subsystem contains EHCI and OHCI controllers.
 +See Documentation/devicetree/bindings/usb/omap-ehci.txt and
 +omap3-ohci.txt
 +
 +Example for OMAP4:
 +
 +usbhshost: usbhshost@0x4a064000 {
 +compatible = ti,usbhs-host;
 +reg = 0x4a064000 0x800;
 +ti,hwmods = usb_host_hs;
 +#address-cells = 1;
 +#size-cells = 1;
 +ranges;
 +
 +usbhsohci: ohci@0x4a064800 {
 +compatible = ti,omap3-ohci, usb-ohci;
 +reg = 0x4a064800 0x400;
 +interrupt-parent = gic;
 +interrupts = 0 76 0x4;
 +};
 +
 +usbhsehci: ehci@0x4a064c00 {
 +compatible = ti,omap-ehci, usb-ehci;
 +reg = 0x4a064c00 0x400;
 +interrupt-parent = gic;
 +interrupts = 0 77 0x4;
 +};
 +};
 +
 +usbhshost {
 +port1_mode = 1; /* OMAP_EHCI_PORT_MODE_PHY */
 +port2_mode = 2; /* OMAP_EHCI_PORT_MODE_TLL */
 +port3_mode = 1; /* OMAP_EHCI_PORT_MODE_PHY */
 +};
 +
 +usbhsehci {
 +phy = hsusb1_phy 0 hsusb3_phy;
 +};
 diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
 index f8ed08e..0f67856 100644
 --- a/drivers/mfd/omap-usb-host.c
 +++ b/drivers/mfd/omap-usb-host.c
 @@ -1,8 +1,9 @@
   /**
* omap-usb-host.c - The USBHS core driver for OMAP EHCI  OHCI
*
 - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com
 + * Copyright (C) 2011-2013 Texas Instruments Incorporated - 
 http://www.ti.com
* Author: Keshava Munegowda keshava_mgo...@ti.com
 + * Author: Roger Quadros rog...@ti.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  of
 @@ -27,6 +28,8 @@
   #include linux/platform_device.h
   #include linux/platform_data/usb-omap.h
   #include linux/pm_runtime.h
 +#include linux/of.h
 +#include linux/of_platform.h

   #include omap-usb.h

 @@ -464,6 +467,37 @@ static void omap_usbhs_init(struct device *dev)
   pm_runtime_put_sync(dev);
   }

 +static int usbhs_omap_get_dt_pdata(struct device_node *node,
 +struct usbhs_omap_platform_data *pdata)
 +{
 +int ret, i;
 +
 +ret = of_property_read_u32(node, nports, pdata-nports);
 +if (ret)
 +pdata-nports = 0;
 +
 +/* get port modes */
 +for (i = 0; i  OMAP3_HS_USB_PORTS; i++) {
 +char prop[11];
 +
 +snprintf(prop, sizeof(prop), port%d_mode, i + 1);
 +ret = of_property_read_u32(node, prop, pdata-port_mode[i]);
 +if (ret)
 +pdata-port_mode[i] = OMAP_USBHS_PORT_MODE_UNUSED;
 +}
 +
 +/* get flags */
 +pdata-single_ulpi_bypass = of_property_read_bool(node,
 +single_ulpi_bypass);
 +return 0;
 +}
 +
 +static struct of_device_id usbhs_child_match_table[] __initdata = {
 +{ .compatible = ti,omap-ehci, },
 +{ .compatible = ti,omap-ohci, },
 +{ }
 +};
 +
   /**
* usbhs_omap_probe - initialize TI-based HCDs
*
 @@ -479,6 +513,21 @@ static int usbhs_omap_probe(struct platform_device 
 *pdev)
   inti;
   boolneed_logic_fck;

 +if (dev-of_node) {
 +/* For DT boot we populate platform data from OF node

Re: [PATCH 10/13] ARM: dts: OMAP4: Add HS USB Host IP nodes

2013-02-05 Thread Roger Quadros
On 02/05/2013 08:24 AM, kishon wrote:
 On Monday 04 February 2013 09:28 PM, Roger Quadros wrote:
 Adds device nodes for HS USB Host module, TLL module,
 OHCI and EHCI controllers.

 Signed-off-by: Roger Quadros rog...@ti.com
 ---
   arch/arm/boot/dts/omap4.dtsi |   30 ++
   1 files changed, 30 insertions(+), 0 deletions(-)

 diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
 index 739bb79..3429280 100644
 --- a/arch/arm/boot/dts/omap4.dtsi
 +++ b/arch/arm/boot/dts/omap4.dtsi
 @@ -529,5 +529,35 @@
   ti,hwmods = timer11;
   ti,timer-pwm;
   };
 +
 +usbhstll: usbhstll@0x4a062000 {
 +compatible = ti,usbhs-tll;
 +reg = 0x4a062000 0x1000;
 +interrupts = 0 78 0x4;
 +ti,hwmods = usb_tll_hs;
 +};
 +
 +usbhshost: usbhshost@0x4a064000 {
 +compatible = ti,usbhs-host;
 +reg = 0x4a064000 0x800;
 +ti,hwmods = usb_host_hs;
 +#address-cells = 1;
 +#size-cells = 1;
 +ranges;
 +
 +usbhsohci: ohci@0x4a064800 {
 +compatible = ti,omap3-ohci, usb-ohci;
 +reg = 0x4a064800 0x400;
 +interrupt-parent = gic;
 
 Just curious.. Were you facing issues if you are not having interrupt-parent 
 here? It's also missing in your dt node usbhstll.

Yes I was. Interrupt-parent is not there in any of the children which are at 
the same level as usbhstll.

cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 10/13] ARM: dts: OMAP4: Add HS USB Host IP nodes

2013-02-05 Thread Roger Quadros
On 02/05/2013 09:41 AM, Felipe Balbi wrote:
 On Mon, Feb 04, 2013 at 05:58:57PM +0200, Roger Quadros wrote:
 Adds device nodes for HS USB Host module, TLL module,
 OHCI and EHCI controllers.

 Signed-off-by: Roger Quadros rog...@ti.com
 ---
  arch/arm/boot/dts/omap4.dtsi |   30 ++
  1 files changed, 30 insertions(+), 0 deletions(-)

 diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
 index 739bb79..3429280 100644
 --- a/arch/arm/boot/dts/omap4.dtsi
 +++ b/arch/arm/boot/dts/omap4.dtsi
 @@ -529,5 +529,35 @@
  ti,hwmods = timer11;
  ti,timer-pwm;
  };
 +
 +usbhstll: usbhstll@0x4a062000 {
 +compatible = ti,usbhs-tll;
 +reg = 0x4a062000 0x1000;
 +interrupts = 0 78 0x4;
 +ti,hwmods = usb_tll_hs;
 +};
 +
 +usbhshost: usbhshost@0x4a064000 {
 +compatible = ti,usbhs-host;
 +reg = 0x4a064000 0x800;
 +ti,hwmods = usb_host_hs;
 +#address-cells = 1;
 +#size-cells = 1;
 +ranges;
 +
 +usbhsohci: ohci@0x4a064800 {
 
 usbhsohci is a bit misleading :-)
 
 How about we stick to ohci and ehci for these nodes ? :-)
 
Was just thinking of a unique label that will point to the OHCI/EHCI
controller in the HS USB subsystem. We need the label to provide
PHY information in the board DT.

If we are sure we won't have another OHCI/EHCI controller then I can
just use ehci/ohci.

cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


how to specify an OMAP clock in device tree?

2013-02-05 Thread Roger Quadros
Hi Rajendra,

On 02/04/2013 05:58 PM, Roger Quadros wrote:
 Provide the RESET and Power regulators for the USB PHY,
 the USB Host port mode and the PHY device.
 
 Also provide pin multiplexer information for the USB host
 pins.
 
 Signed-off-by: Roger Quadros rog...@ti.com
 ---
  arch/arm/boot/dts/omap4-panda.dts |   55 
 +
  1 files changed, 55 insertions(+), 0 deletions(-)
 
 diff --git a/arch/arm/boot/dts/omap4-panda.dts 
 b/arch/arm/boot/dts/omap4-panda.dts
 index 4122efe..fe2d3d4 100644
 --- a/arch/arm/boot/dts/omap4-panda.dts
 +++ b/arch/arm/boot/dts/omap4-panda.dts
 @@ -57,6 +57,35 @@
   AFML, Line In,
   AFMR, Line In;
   };
 +
 + /* HS USB Port 1 RESET */
 + hsusb1_reset: hsusb1_reset_reg {
 + compatible = regulator-fixed;
 + regulator-name = hsusb1_reset;
 + regulator-min-microvolt = 330;
 + regulator-max-microvolt = 330;
 + gpio = gpio2 30 0;   /* gpio_62 */
 + startup-delay-us = 7;
 + enable-active-high;
 + };
 +
 + /* HS USB Port 1 Power */
 + hsusb1_power: hsusb1_power_reg {
 + compatible = regulator-fixed;
 + regulator-name = hsusb1_vbus;
 + regulator-min-microvolt = 330;
 + regulator-max-microvolt = 330;
 + gpio = gpio1 1 0;/* gpio_1 */
 + startup-delay-us = 7;
 + enable-active-high;
 + };
 +
 + /* HS USB Host PHY on PORT 1 */
 + hsusb1_phy: hsusb1_phy {
 + compatible = usb-nop-xceiv;
 + reset-supply = hsusb1_reset;
 + vcc-supply = hsusb1_power;
 + };

This is the patch I was discussing with you about before.

Let me explain the problem again.

The Pandaboard has a USB PHY whose reference clock is provided by
FREF_CLK3 pin which is a clock generated by the OMAP.
The PHY driver expects a reference to this clock in the PHY device node.
See the above node hsusb1_phy. we would need something like
hsusb1_phy {
...
clocks = fref_clk3;
clock-names = main_clk;
...
};

Currently on OMAP, there is no way to provide a phandle to this clock.

Is it practical to provide device tree based implementation of at least
the externally accessible OMAP clocks?

cheers,
-roger

  };
  
  omap4_pmx_core {
 @@ -67,6 +96,7 @@
   mcbsp1_pins
   dss_hdmi_pins
   tpd12s015_pins
 + hsusbb1_pins
   ;
  
   twl6040_pins: pinmux_twl6040_pins {
 @@ -110,6 +140,23 @@
   0x58 0x10b  /* hdmi_hpd.gpio_63 INPUT PULLDOWN | 
 MODE3 */
   ;
   };


___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 02/13] USB: phy: nop: Defer probe if device needs VCC/RESET

2013-02-05 Thread Roger Quadros
On 02/05/2013 11:09 AM, Felipe Balbi wrote:
 On Tue, Feb 05, 2013 at 10:44:05AM +0200, Roger Quadros wrote:
 diff --git a/include/linux/usb/nop-usb-xceiv.h 
 b/include/linux/usb/nop-usb-xceiv.h
 index 3265b61..148d351 100644
 --- a/include/linux/usb/nop-usb-xceiv.h
 +++ b/include/linux/usb/nop-usb-xceiv.h
 @@ -6,6 +6,10 @@
   struct nop_usb_xceiv_platform_data {
   enum usb_phy_type type;
   unsigned long clk_rate;
 +
 +/* if set fails with -EPROBE_DEFER if can't get regulator */
 +unsigned int needs_vcc:1;
 +unsigned int needs_reset:1;

 how about u8 here?

 Not sure. Bitfields are usually defined as unsigned int.
 
 IIRC the benefit is that compiler can try to optimize those flags. I
 mean, if you have 32 1-bit flags, compiler will combine those in a
 single u32. Someone correct me if I'm wrong.
 

Yes you are right. Kishon was asking me to use u8 instead of unsigned int, which
I don't think is necessary. AFAIK, it is a norm to use unsigned int when 
defining
a bitfield. Compilers are known to behave funny with bitfields. I don't mind
using bool for each.

cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 09/13] mfd: omap-usb-host: Add device tree support and binding information

2013-02-05 Thread Roger Quadros
On 02/05/2013 08:16 AM, kishon wrote:
 On Monday 04 February 2013 09:28 PM, Roger Quadros wrote:
 Allows the OMAP HS USB host controller to be specified
 via device tree.

 CC: Samuel Ortiz sa...@linux.intel.com
 Signed-off-by: Roger Quadros rog...@ti.com
 ---
   .../devicetree/bindings/mfd/omap-usb-host.txt  |   68 
   drivers/mfd/omap-usb-host.c|   83 
 ++--
   2 files changed, 145 insertions(+), 6 deletions(-)
   create mode 100644 Documentation/devicetree/bindings/mfd/omap-usb-host.txt

 diff --git a/Documentation/devicetree/bindings/mfd/omap-usb-host.txt 
 b/Documentation/devicetree/bindings/mfd/omap-usb-host.txt
 new file mode 100644
 index 000..2196893
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/mfd/omap-usb-host.txt
 @@ -0,0 +1,68 @@
 +OMAP HS USB Host
 +
 +Required properties:
 +
 +- compatible: should be ti,usbhs-host
 +- reg: should contain one register range i.e. start and length
 +- ti,hwmods: must contain usb_host_hs
 +
 +Optional properties:
 +
 +- nports: number of USB ports. Usually this is automatically detected
 +  from the IP's revision register but can be overridden by specifying
 +  this property.
 +
 +- portN_mode: Integer specifying the port mode for port N, where N can be
 +  from 1 to nports. The port mode must be as per enum usbhs_omap_port_mode
 +  in include/linux/platform_data/usb-omap.h
 +  If the port mode is not specified, that port is treated as unused.
 +
 +- single_ulpi_bypass: Must be present if the controller contains a single
 +  ULPI bypass control bit. e.g. OMAP3 silicon = ES2.1
 +
 +Required properties if child node exists:
 +
 +- #address-cells: Must be 1
 +- #size-cells: Must be 1
 +- ranges: must be present
 +
 +Properties for children:
 +
 +The OMAP HS USB Host subsystem contains EHCI and OHCI controllers.
 +See Documentation/devicetree/bindings/usb/omap-ehci.txt and
 +omap3-ohci.txt
 +
 +Example for OMAP4:
 +
 +usbhshost: usbhshost@0x4a064000 {
 +compatible = ti,usbhs-host;
 +reg = 0x4a064000 0x800;
 +ti,hwmods = usb_host_hs;
 +#address-cells = 1;
 +#size-cells = 1;
 +ranges;
 +
 +usbhsohci: ohci@0x4a064800 {
 +compatible = ti,omap3-ohci, usb-ohci;
 +reg = 0x4a064800 0x400;
 +interrupt-parent = gic;
 +interrupts = 0 76 0x4;
 +};
 +
 +usbhsehci: ehci@0x4a064c00 {
 +compatible = ti,omap-ehci, usb-ehci;
 +reg = 0x4a064c00 0x400;
 +interrupt-parent = gic;
 +interrupts = 0 77 0x4;
 +};
 +};
 +
 +usbhshost {
 +port1_mode = 1; /* OMAP_EHCI_PORT_MODE_PHY */
 +port2_mode = 2; /* OMAP_EHCI_PORT_MODE_TLL */
 +port3_mode = 1; /* OMAP_EHCI_PORT_MODE_PHY */
 +};
 +
 +usbhsehci {
 +phy = hsusb1_phy 0 hsusb3_phy;
 +};
 diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
 index f8ed08e..0f67856 100644
 --- a/drivers/mfd/omap-usb-host.c
 +++ b/drivers/mfd/omap-usb-host.c
 @@ -1,8 +1,9 @@
   /**
* omap-usb-host.c - The USBHS core driver for OMAP EHCI  OHCI
*
 - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com
 + * Copyright (C) 2011-2013 Texas Instruments Incorporated - 
 http://www.ti.com
* Author: Keshava Munegowda keshava_mgo...@ti.com
 + * Author: Roger Quadros rog...@ti.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  of
 @@ -27,6 +28,8 @@
   #include linux/platform_device.h
   #include linux/platform_data/usb-omap.h
   #include linux/pm_runtime.h
 +#include linux/of.h
 +#include linux/of_platform.h

   #include omap-usb.h

 @@ -464,6 +467,37 @@ static void omap_usbhs_init(struct device *dev)
   pm_runtime_put_sync(dev);
   }

 +static int usbhs_omap_get_dt_pdata(struct device_node *node,
 +struct usbhs_omap_platform_data *pdata)
 +{
 +int ret, i;
 +
 +ret = of_property_read_u32(node, nports, pdata-nports);
 +if (ret)
 +pdata-nports = 0;
 +
 +/* get port modes */
 +for (i = 0; i  OMAP3_HS_USB_PORTS; i++) {
 +char prop[11];
 +
 +snprintf(prop, sizeof(prop), port%d_mode, i + 1);
 +ret = of_property_read_u32(node, prop, pdata-port_mode[i]);
 +if (ret)
 +pdata-port_mode[i] = OMAP_USBHS_PORT_MODE_UNUSED;
 +}
 +
 +/* get flags */
 +pdata-single_ulpi_bypass = of_property_read_bool(node,
 +single_ulpi_bypass);
 +return 0;
 +}
 +
 +static struct of_device_id usbhs_child_match_table[] __initdata = {
 +{ .compatible = ti,omap-ehci, },
 +{ .compatible = ti,omap-ohci, },
 +{ }
 +};
 +
   /**
* usbhs_omap_probe - initialize TI-based HCDs
*
 @@ -479,6 +513,21 @@ static int usbhs_omap_probe(struct platform_device 
 *pdev)
   inti;
   boolneed_logic_fck;

 +if (dev-of_node) {
 +/* For DT boot we populate platform data from OF node

Re: [PATCH 00/13] Device tree support for OMAP HS USB Host

2013-02-05 Thread Roger Quadros
On 02/05/2013 01:25 PM, Rajendra Nayak wrote:
 On Monday 04 February 2013 09:28 PM, Roger Quadros wrote:
 This patchset adds device tree support for OMAP's High Speed USB Host
 subsystem. Board adaptation for Panda and Beagleboard is also provided.

 Tested on Beagleboard.

 Will only work with Panda if we provide a reference to the PHY clock
 
 But there is no reference provided even for Beagle. Does it work because
 the default clk speed is 192Mhz?

On beagle board the PHY is connected differently, i.e. as the clock receptor.
The PHY clock comes directly from the USB_CLK pin.

On Panda the PHY is the clock provider to the USB_CLK pin. For that it needs
a reference clock at the REFCLK pin which comes from FREF_CLK3.

 
 generator in the device tree in PATCH 11. I do not know how to do that
 as there is no way to provide a phandle to any of the OMAP generated clocks
 in the device tree. Suggestions welcome:).
 

cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 09/13] mfd: omap-usb-host: Add device tree support and binding information

2013-02-05 Thread Roger Quadros
On 02/05/2013 02:11 PM, kishon wrote:
 Hi,
 
 On Tuesday 05 February 2013 04:28 PM, Roger Quadros wrote:
 On 02/05/2013 08:16 AM, kishon wrote:
 On Monday 04 February 2013 09:28 PM, Roger Quadros wrote:
 Allows the OMAP HS USB host controller to be specified
 via device tree.

 CC: Samuel Ortiz sa...@linux.intel.com
 Signed-off-by: Roger Quadros rog...@ti.com
 ---
.../devicetree/bindings/mfd/omap-usb-host.txt  |   68 
 
drivers/mfd/omap-usb-host.c|   83 
 ++--
2 files changed, 145 insertions(+), 6 deletions(-)
create mode 100644 
 Documentation/devicetree/bindings/mfd/omap-usb-host.txt

 diff --git a/Documentation/devicetree/bindings/mfd/omap-usb-host.txt 
 b/Documentation/devicetree/bindings/mfd/omap-usb-host.txt
 new file mode 100644
 index 000..2196893
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/mfd/omap-usb-host.txt
 @@ -0,0 +1,68 @@
 +OMAP HS USB Host
 +
 +Required properties:
 +
 +- compatible: should be ti,usbhs-host
 +- reg: should contain one register range i.e. start and length
 +- ti,hwmods: must contain usb_host_hs
 +
 +Optional properties:
 +
 +- nports: number of USB ports. Usually this is automatically detected
 +  from the IP's revision register but can be overridden by specifying
 +  this property.
 +
 +- portN_mode: Integer specifying the port mode for port N, where N can be
 +  from 1 to nports. The port mode must be as per enum usbhs_omap_port_mode
 +  in include/linux/platform_data/usb-omap.h
 +  If the port mode is not specified, that port is treated as unused.
 +
 +- single_ulpi_bypass: Must be present if the controller contains a single
 +  ULPI bypass control bit. e.g. OMAP3 silicon = ES2.1
 +
 +Required properties if child node exists:
 +
 +- #address-cells: Must be 1
 +- #size-cells: Must be 1
 +- ranges: must be present
 +
 +Properties for children:
 +
 +The OMAP HS USB Host subsystem contains EHCI and OHCI controllers.
 +See Documentation/devicetree/bindings/usb/omap-ehci.txt and
 +omap3-ohci.txt
 +
 +Example for OMAP4:
 +
 +usbhshost: usbhshost@0x4a064000 {
 +compatible = ti,usbhs-host;
 +reg = 0x4a064000 0x800;
 +ti,hwmods = usb_host_hs;
 +#address-cells = 1;
 +#size-cells = 1;
 +ranges;
 +
 +usbhsohci: ohci@0x4a064800 {
 +compatible = ti,omap3-ohci, usb-ohci;
 +reg = 0x4a064800 0x400;
 +interrupt-parent = gic;
 +interrupts = 0 76 0x4;
 +};
 +
 +usbhsehci: ehci@0x4a064c00 {
 +compatible = ti,omap-ehci, usb-ehci;
 +reg = 0x4a064c00 0x400;
 +interrupt-parent = gic;
 +interrupts = 0 77 0x4;
 +};
 +};
 +
 +usbhshost {
 +port1_mode = 1; /* OMAP_EHCI_PORT_MODE_PHY */
 +port2_mode = 2; /* OMAP_EHCI_PORT_MODE_TLL */
 +port3_mode = 1; /* OMAP_EHCI_PORT_MODE_PHY */
 +};
 +
 +usbhsehci {
 +phy = hsusb1_phy 0 hsusb3_phy;
 +};
 diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
 index f8ed08e..0f67856 100644
 --- a/drivers/mfd/omap-usb-host.c
 +++ b/drivers/mfd/omap-usb-host.c
 @@ -1,8 +1,9 @@
/**
 * omap-usb-host.c - The USBHS core driver for OMAP EHCI  OHCI
 *
 - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com
 + * Copyright (C) 2011-2013 Texas Instruments Incorporated - 
 http://www.ti.com
 * Author: Keshava Munegowda keshava_mgo...@ti.com
 + * Author: Roger Quadros rog...@ti.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  of
 @@ -27,6 +28,8 @@
#include linux/platform_device.h
#include linux/platform_data/usb-omap.h
#include linux/pm_runtime.h
 +#include linux/of.h
 +#include linux/of_platform.h

#include omap-usb.h

 @@ -464,6 +467,37 @@ static void omap_usbhs_init(struct device *dev)
pm_runtime_put_sync(dev);
}

 +static int usbhs_omap_get_dt_pdata(struct device_node *node,
 +struct usbhs_omap_platform_data *pdata)
 +{
 +int ret, i;
 +
 +ret = of_property_read_u32(node, nports, pdata-nports);
 +if (ret)
 +pdata-nports = 0;
 +
 +/* get port modes */
 +for (i = 0; i  OMAP3_HS_USB_PORTS; i++) {
 +char prop[11];
 +
 +snprintf(prop, sizeof(prop), port%d_mode, i + 1);
 +ret = of_property_read_u32(node, prop, pdata-port_mode[i]);
 +if (ret)
 +pdata-port_mode[i] = OMAP_USBHS_PORT_MODE_UNUSED;
 +}
 +
 +/* get flags */
 +pdata-single_ulpi_bypass = of_property_read_bool(node,
 +single_ulpi_bypass);
 +return 0;
 +}
 +
 +static struct of_device_id usbhs_child_match_table[] __initdata = {
 +{ .compatible = ti,omap-ehci, },
 +{ .compatible = ti,omap-ohci, },
 +{ }
 +};
 +
/**
 * usbhs_omap_probe - initialize TI-based HCDs
 *
 @@ -479,6 +513,21 @@ static int usbhs_omap_probe(struct platform_device 
 *pdev)
inti

Re: [PATCH 08/13] USB: ehci-omap: Add device tree support and binding information

2013-02-05 Thread Roger Quadros
On 02/05/2013 02:33 PM, Mark Rutland wrote:
 On Mon, Feb 04, 2013 at 03:58:55PM +, Roger Quadros wrote:
 Allows the OMAP EHCI controller to be specified via device tree.

 Signed-off-by: Roger Quadros rog...@ti.com
 ---
  .../devicetree/bindings/usb/omap-ehci.txt  |   34 ++
  drivers/usb/host/ehci-omap.c   |   36 
 +++-
  2 files changed, 69 insertions(+), 1 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/usb/omap-ehci.txt

 diff --git a/Documentation/devicetree/bindings/usb/omap-ehci.txt 
 b/Documentation/devicetree/bindings/usb/omap-ehci.txt
 new file mode 100644
 index 000..90e6e3a
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/usb/omap-ehci.txt
 @@ -0,0 +1,34 @@
 +OMAP HS USB EHCI controller
 +
 +This device is usually the child of the omap-usb-host
 +Documentation/devicetree/bindings/mfd/omap-usb-host.txt
 +
 +Required properties:
 +
 +- compatible: should be ti,omap-ehci
 +- reg: should contain one register range i.e. start and length
 +- interrupt-parent: phandle to the interrupt controller
 +- interrupts: description of the interrupt line
 +
 +Optional properties:
 +
 +- phy: list of phandles to PHY nodes.
 +  This property is required if at least one of the ports are in
 +  PHY mode i.e. OMAP_EHCI_PORT_MODE_PHY
 
 Any reason for not calling this phys, given it's a list?


No good reason. phys seems more appropriate. Thanks.

cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: how to specify an OMAP clock in device tree?

2013-02-05 Thread Roger Quadros
On 02/05/2013 01:15 PM, Rajendra Nayak wrote:
 On Tuesday 05 February 2013 03:04 PM, Roger Quadros wrote:
 Hi Rajendra,

 On 02/04/2013 05:58 PM, Roger Quadros wrote:
 Provide the RESET and Power regulators for the USB PHY,
 the USB Host port mode and the PHY device.

 Also provide pin multiplexer information for the USB host
 pins.

 Signed-off-by: Roger Quadros rog...@ti.com
 ---
   arch/arm/boot/dts/omap4-panda.dts |   55 
 +
   1 files changed, 55 insertions(+), 0 deletions(-)

 diff --git a/arch/arm/boot/dts/omap4-panda.dts 
 b/arch/arm/boot/dts/omap4-panda.dts
 index 4122efe..fe2d3d4 100644
 --- a/arch/arm/boot/dts/omap4-panda.dts
 +++ b/arch/arm/boot/dts/omap4-panda.dts
 @@ -57,6 +57,35 @@
   AFML, Line In,
   AFMR, Line In;
   };
 +
 +/* HS USB Port 1 RESET */
 +hsusb1_reset: hsusb1_reset_reg {
 +compatible = regulator-fixed;
 +regulator-name = hsusb1_reset;
 +regulator-min-microvolt = 330;
 +regulator-max-microvolt = 330;
 +gpio = gpio2 30 0;/* gpio_62 */
 +startup-delay-us = 7;
 +enable-active-high;
 +};
 +
 +/* HS USB Port 1 Power */
 +hsusb1_power: hsusb1_power_reg {
 +compatible = regulator-fixed;
 +regulator-name = hsusb1_vbus;
 +regulator-min-microvolt = 330;
 +regulator-max-microvolt = 330;
 +gpio = gpio1 1 0;/* gpio_1 */
 +startup-delay-us = 7;
 +enable-active-high;
 +};
 +
 +/* HS USB Host PHY on PORT 1 */
 +hsusb1_phy: hsusb1_phy {
 +compatible = usb-nop-xceiv;
 +reset-supply = hsusb1_reset;
 +vcc-supply = hsusb1_power;
 +};

 This is the patch I was discussing with you about before.

 Let me explain the problem again.

 The Pandaboard has a USB PHY whose reference clock is provided by
 FREF_CLK3 pin which is a clock generated by the OMAP.
 The PHY driver expects a reference to this clock in the PHY device node.
 
 Well, the driver just does a clk_get(dev, main_clk); and clk_get() is
 then able to either pick the reference from the PHY dt node or from a
 clkdev entry.
 
 The problem here seems to be that you are not able to add a clkdev entry
 because the device name wouldn't be fixed, since you have a node in
 the form of 'node: node {'. All other onchip OMAP devices don't have
 this issue because they have an entry in the form of 'node: node@addr'
 and hence have a fixed device name and hence can add a clkdev entry for
 the clocks they want to control.
 
 I don't know if there is any good way to define the DT node for the
 on board PHY in such a way that the device name is always fixed, in
 which case you can then add a clkdev entry for 'dev, main_clk' mapping
 to the onchip clock that provides the clock, but if there is one, then
 that should fix your problem.

Fixing the device name doesn't really solve the problem.
Not all OMAP boards will use the same clock for the external device.
So you can't provide this information in some common clock data file.

The data has to come from a board specific location, which in the DT boot
case is the board's dts file.

I think all we need to do is register a clock provider using 
of_clk_add_provider()
and provide a clk_src_get() hook that can get the right clock.

usage e.g.

/* provider */
clks: omapclocks {
compatible = ti,omapclocks;
#clock-cells = 1;
};

/* consumer */
hsusb1_phy: hsusb1_phy {
compatible = usb-nop-xceiv;
clocks = clks auxclk3_ck;  /* FREF_CLK3 */
clock-names = main-clk;
};

The only problem I see is that the argument to the clks phandle
cannot be a string. It needs to be u32.

In that case we need to map all clocks into a u32 index.

If we can do that only for auxclks, my problem is solved for panda.

The usage e.g then changes to

/* provider */
aux_clks: omap_aux_clocks {
compatible = ti,omap_aux_clocks;
#clock-cells = 1;
};

/* consumer */
hsusb1_phy: hsusb1_phy {
compatible = usb-nop-xceiv;
clocks = aux_clks 3; /* FREF_CLK3 */
clock-names = main-clk;
};

Does this idea sound reasonable?

regards,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: how to specify an OMAP clock in device tree?

2013-02-05 Thread Roger Quadros
On 02/05/2013 04:13 PM, Rajendra Nayak wrote:
 On Tuesday 05 February 2013 07:16 PM, Roger Quadros wrote:
 Fixing the device name doesn't really solve the problem.
 Not all OMAP boards will use the same clock for the external device.
 
 Are you saying different OMAP boards will use different Internal clocks?
 Or different OMAP boards will use a single Internal clock or an
 external one.
 
All I was saying is that one board can use for example auxclk1 whereas another
one can use auxclk3, both generated by OMAP for the same PHY configuration.

cheers,
-roger

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: how to specify an OMAP clock in device tree?

2013-02-05 Thread Roger Quadros
On 02/05/2013 04:21 PM, Rajendra Nayak wrote:
 On Tuesday 05 February 2013 07:48 PM, Roger Quadros wrote:
 On 02/05/2013 04:13 PM, Rajendra Nayak wrote:
 On Tuesday 05 February 2013 07:16 PM, Roger Quadros wrote:
 Fixing the device name doesn't really solve the problem.
 Not all OMAP boards will use the same clock for the external device.

 Are you saying different OMAP boards will use different Internal clocks?
 Or different OMAP boards will use a single Internal clock or an
 external one.

 All I was saying is that one board can use for example auxclk1 whereas 
 another
 one can use auxclk3, both generated by OMAP for the same PHY configuration.
 
 Ok, so lets keep DT aside for a while. How would something like this
 work in a non-DT world? Would the driver then be able to do a
 clk_get(dev, main_clk); and get say auxclk1 on one board and
 auxclk3 on another?
 

Yes, all you need to do is specify an alias to the clock in the board file.

e.g. in board 1 file
clk_add_alias(main_clk, phy.1, auxclk1_ck, NULL);

in board 2 file
clk_add_alias(main_clk, phy.1, auxclk3_ck, NULL);

cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 09/13] mfd: omap-usb-host: Add device tree support and binding information

2013-02-05 Thread Roger Quadros
On 02/05/2013 04:20 PM, Mark Rutland wrote:
 Hi,
 
 I have a few comments on the binding and the way it's parsed.
 
 On Mon, Feb 04, 2013 at 03:58:56PM +, Roger Quadros wrote:
 Allows the OMAP HS USB host controller to be specified
 via device tree.

 CC: Samuel Ortiz sa...@linux.intel.com
 Signed-off-by: Roger Quadros rog...@ti.com
 ---
  .../devicetree/bindings/mfd/omap-usb-host.txt  |   68 
  drivers/mfd/omap-usb-host.c|   83 
 ++--
  2 files changed, 145 insertions(+), 6 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/mfd/omap-usb-host.txt

 diff --git a/Documentation/devicetree/bindings/mfd/omap-usb-host.txt 
 b/Documentation/devicetree/bindings/mfd/omap-usb-host.txt
 new file mode 100644
 index 000..2196893
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/mfd/omap-usb-host.txt
 @@ -0,0 +1,68 @@
 +OMAP HS USB Host
 +
 +Required properties:
 +
 +- compatible: should be ti,usbhs-host
 +- reg: should contain one register range i.e. start and length
 +- ti,hwmods: must contain usb_host_hs
 +
 +Optional properties:
 +
 +- nports: number of USB ports. Usually this is automatically detected
 +  from the IP's revision register but can be overridden by specifying
 +  this property.
 
 It would be nice if this were num-ports, as atmel-usb is already using that,
 and it's clear that it's a number of ports rather than some other meaning of
 'n'.
 
 From a quick grep of binding documents, out of nTHING(s), nr-THINGs, and
 num-THINGs, num-THINGs seems to be the most common. It would be nice if new
 bindings could standardise this.

Agreed.
 
 +
 +- portN_mode: Integer specifying the port mode for port N, where N can be
 +  from 1 to nports. The port mode must be as per enum usbhs_omap_port_mode
 +  in include/linux/platform_data/usb-omap.h
 +  If the port mode is not specified, that port is treated as unused.
 
 I'm against devicetree bindings refering to Linux internals. It makes a poorly
 documented ABI that someone might change in future without realising the
 implications, and it makes it stupidly difficult to read a dts.
 
 Everything required should be specified in the binding document (or another
 linked binding document). It might be better to describe this with a string
 property that gets mapped by your dt parsing code to whatever internal
 representation you need. That way it's far easier for a human to verify the 
 dts
 is correct, and you know by construction that the parsed value is something 
 you
 can handle in the driver.

As string makes it self documenting, I'll convert it to a string and update the
binding document.

 
 It would be nicer is you used '-' rather than '_' for consistency with
 devicetree bindings in general.

OK.

 
 +
 +- single_ulpi_bypass: Must be present if the controller contains a single
 +  ULPI bypass control bit. e.g. OMAP3 silicon = ES2.1
 
 Again it would be nicer to have '-' rather than '_' here. It might be worth
 prefixing this ti,.

Is prefixing with ti really required? how does it better?

 
 +
 +Required properties if child node exists:
 +
 +- #address-cells: Must be 1
 +- #size-cells: Must be 1
 +- ranges: must be present
 +
 +Properties for children:
 +
 +The OMAP HS USB Host subsystem contains EHCI and OHCI controllers.
 +See Documentation/devicetree/bindings/usb/omap-ehci.txt and
 +omap3-ohci.txt
 +
 +Example for OMAP4:
 +
 +usbhshost: usbhshost@0x4a064000 {
 +compatible = ti,usbhs-host;
 +reg = 0x4a064000 0x800;
 +ti,hwmods = usb_host_hs;
 +#address-cells = 1;
 +#size-cells = 1;
 +ranges;
 +
 +usbhsohci: ohci@0x4a064800 {
 +compatible = ti,omap3-ohci, usb-ohci;
 +reg = 0x4a064800 0x400;
 +interrupt-parent = gic;
 +interrupts = 0 76 0x4;
 +};
 +
 +usbhsehci: ehci@0x4a064c00 {
 +compatible = ti,omap-ehci, usb-ehci;
 +reg = 0x4a064c00 0x400;
 +interrupt-parent = gic;
 +interrupts = 0 77 0x4;
 +};
 +};
 +
 +usbhshost {
 +port1_mode = 1; /* OMAP_EHCI_PORT_MODE_PHY */
 +port2_mode = 2; /* OMAP_EHCI_PORT_MODE_TLL */
 +port3_mode = 1; /* OMAP_EHCI_PORT_MODE_PHY */
 
 With a string property, these values would be self-documenting.
 
 +};
 +
 +usbhsehci {
 +phy = hsusb1_phy 0 hsusb3_phy;
 +};
 diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
 index f8ed08e..0f67856 100644
 --- a/drivers/mfd/omap-usb-host.c
 +++ b/drivers/mfd/omap-usb-host.c
 @@ -1,8 +1,9 @@
  /**
   * omap-usb-host.c - The USBHS core driver for OMAP EHCI  OHCI
   *
 - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com
 + * Copyright (C) 2011-2013 Texas Instruments Incorporated - 
 http://www.ti.com
   * Author: Keshava Munegowda keshava_mgo...@ti.com
 + * Author: Roger Quadros rog...@ti.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU General Public

Re: how to specify an OMAP clock in device tree?

2013-02-05 Thread Roger Quadros
On 02/05/2013 04:36 PM, Rajendra Nayak wrote:
 On Tuesday 05 February 2013 07:59 PM, Roger Quadros wrote:
 On 02/05/2013 04:21 PM, Rajendra Nayak wrote:
 On Tuesday 05 February 2013 07:48 PM, Roger Quadros wrote:
 On 02/05/2013 04:13 PM, Rajendra Nayak wrote:
 On Tuesday 05 February 2013 07:16 PM, Roger Quadros wrote:
 Fixing the device name doesn't really solve the problem.
 Not all OMAP boards will use the same clock for the external device.

 Are you saying different OMAP boards will use different Internal clocks?
 Or different OMAP boards will use a single Internal clock or an
 external one.

 All I was saying is that one board can use for example auxclk1 whereas 
 another
 one can use auxclk3, both generated by OMAP for the same PHY configuration.

 Ok, so lets keep DT aside for a while. How would something like this
 work in a non-DT world? Would the driver then be able to do a
 clk_get(dev, main_clk); and get say auxclk1 on one board and
 auxclk3 on another?


 Yes, all you need to do is specify an alias to the clock in the board file.
 
 Can we then create a special board specific node for panda and do
 similar things from DT?
 See a similar discussion below on how to handle the gpio_request()
 we had as part of board files
 http://www.spinics.net/lists/linux-omap/msg85248.html

Doesn't look very elegant to me, but I wouldn't mind if there is no better 
option.
Even then, we can't rely on the device name as its index can change based on 
where it is
located in the dts file. e.g. in the beginning it may be named phy.8, and if a 
device
node is added before it, it will get changed to phy.9

 

 e.g. in board 1 file
 clk_add_alias(main_clk, phy.1, auxclk1_ck, NULL);

 in board 2 file
 clk_add_alias(main_clk, phy.1, auxclk3_ck, NULL);


cheers,
-roger

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 09/13] mfd: omap-usb-host: Add device tree support and binding information

2013-02-06 Thread Roger Quadros
On 02/05/2013 06:11 PM, Mark Rutland wrote:
 [...]
 
 +
 +- single_ulpi_bypass: Must be present if the controller contains a single
 +  ULPI bypass control bit. e.g. OMAP3 silicon = ES2.1

 Again it would be nicer to have '-' rather than '_' here. It might be worth
 prefixing this ti,.

 Is prefixing with ti really required? how does it better?
 
 I thought single-ulpi-bypass sounded rather generic, but it probably is
 specific enough as-is. I don't know enough about USB hardware to have strong
 feelings either way.
 

Yes, it is specific to the TI silicon. I'll leave it as it is then.

cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: how to specify an OMAP clock in device tree?

2013-02-06 Thread Roger Quadros
On 02/06/2013 12:21 PM, Rajendra Nayak wrote:
 On Tuesday 05 February 2013 08:22 PM, Roger Quadros wrote:
 Doesn't look very elegant to me, but I wouldn't mind if there is no better 
 option.
 Even then, we can't rely on the device name as its index can change based on 
 where it is
 
 Well, thats what I said in the first mail, that *if* you are able to
 fix the device name, *then* we could use clkdev the way its used in
 non-DT case. But then you came back saying 'Fixing the device name
 doesn't really solve the problem.' :)

It does, yes, but depending on fixed device names is not so great for DT, is it?
Doesn't solve the problem in the right sense :)

 
 located in the dts file. e.g. in the beginning it may be named phy.8, and if 
 a device
 node is added before it, it will get changed to phy.9
 
 If you provide a phandle to the PHY node in the board node, for which
 you need to add the clk alias, you can always extract the device (using
 of_find_device_by_node() ) and hence its name, so it doesn't matter if
 its phy.8 or phy.9.

Right, I'll come up with something on these lines.

Thanks for the suggestions :).

cheers,
-roger

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 1/2] ARM: OMAP2+: Allow clock alias provision from device tree

2013-02-11 Thread Roger Quadros
Currently on OMAP, it is not possible to specify a clock consumer
to any of the OMAP generated clocks using the device tree. This can pose
a problem for external devices that run off an OMAP clock as we
can't reliably provide a reference to the clock in the device tree.

This patch allows device trees to provide a node that contains the
clock identifier, clock alias and the device phandle. The board
initialization code then creates a clock alias to this clock id,
and associates it with the device whose phandle was supplied.

Discussion
http://www.spinics.net/lists/linux-omap/msg86241.html

CC: Russell King li...@arm.linux.org.uk
CC: Rajendra Nayak rna...@ti.com
CC: Santosh Shilimkar santosh.shilim...@ti.com

Signed-off-by: Roger Quadros rog...@ti.com
---
 .../devicetree/bindings/clock/ti-clock-alias.txt   |   26 
 arch/arm/mach-omap2/board-generic.c|   67 
 2 files changed, 93 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/ti-clock-alias.txt

diff --git a/Documentation/devicetree/bindings/clock/ti-clock-alias.txt 
b/Documentation/devicetree/bindings/clock/ti-clock-alias.txt
new file mode 100644
index 000..87ef4c3
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/ti-clock-alias.txt
@@ -0,0 +1,26 @@
+* Clock alias provision for TI OMAP2+ boards
+
+This binding allows the board's device tree file to specify a clock name,
+device phandle and clock alias so that that clock can be associated
+to the device with the alias.
+
+This is required in cases where an external device is clocked by an
+OMAP generated clock and needs to be assocated to it.
+
+NOTE: The node's name should be clock_alias
+
+Required properties
+- clock-name: The clock identifier string. Should be one of the
+  clock ids defined in OMAP common clock data.
+- clock-alias: A string specifying the alias that must be created to the clock.
+- device: A phandle to the device this clock should be associated to.
+
+e.g. On the OMAP4 Panda board, the USB PHY device is clocked by the
+FREF_CLK3 (auxclk3_ck) from the OMAP. The PHY driver expexts the clock to
+be named main_clk. This binding can be provided like so
+
+clock_alias {
+   clock-name = auxclk3_ck;
+   clock-alias = main_clk;
+   device = hsusb1_phy;
+};
diff --git a/arch/arm/mach-omap2/board-generic.c 
b/arch/arm/mach-omap2/board-generic.c
index 53cb380b..a4b8813 100644
--- a/arch/arm/mach-omap2/board-generic.c
+++ b/arch/arm/mach-omap2/board-generic.c
@@ -15,6 +15,9 @@
 #include linux/of_irq.h
 #include linux/of_platform.h
 #include linux/irqdomain.h
+#include linux/clk.h
+#include linux/string.h
+#include linux/slab.h
 
 #include asm/hardware/gic.h
 #include asm/mach/arch.h
@@ -36,12 +39,76 @@ static struct of_device_id omap_dt_match_table[] __initdata 
= {
{ }
 };
 
+static int __init omap_create_clk_alias(struct device_node *np)
+{
+   int ret = 0;
+   const char *s, *alias;
+   char *clk_id;
+   struct device_node *dev_np;
+   struct platform_device *pdev;
+
+   of_property_read_string(np, clock-name, s);
+   if (!s) {
+   pr_err(%s: couldn't find clock-name property in node %s\n,
+   __func__, np-name);
+   return -ENODEV;
+   }
+
+   clk_id = kstrdup(s, GFP_KERNEL);
+   if (!clk_id)
+   return -ENOMEM;
+
+   dev_np = of_parse_phandle(np, device, 0);
+   if (!dev_np) {
+   pr_err(%s: couldn't find device phandle for \'%s\'\n,
+   __func__, clk_id);
+   ret = -ENODEV;
+   goto exit;
+   }
+
+   pdev = of_find_device_by_node(dev_np);
+   if (!pdev) {
+   pr_err(%s: couldn't find device for clock \'%s\'\n,
+   __func__, clk_id);
+   ret = -ENODEV;
+   goto exit;
+   }
+
+   ret = of_property_read_string(np, clock-alias, alias);
+   if (ret) {
+   pr_err(%s: couldn't find alias for clock \'%s\'\n,
+   __func__, clk_id);
+   ret = -ENODEV;
+   goto exit;
+   }
+
+   ret = clk_add_alias(alias, dev_name(pdev-dev), clk_id, NULL);
+   if (ret) {
+   pr_err(%s: couldn't add alias \'%s\' to clock \'%s\'\n,
+   __func__, alias, clk_id);
+   ret = -ENODEV;
+   goto exit;
+   }
+
+exit:
+   kfree(clk_id);
+   return ret;
+}
+
 static void __init omap_generic_init(void)
 {
+   struct device_node *np;
+
omap_sdrc_init(NULL, NULL);
 
of_platform_populate(NULL, omap_dt_match_table, NULL, NULL);
 
+   /* create clock aliases based on 'clock_alias' nodes */
+   for_each_node_by_name(np, clock_alias) {
+   omap_create_clk_alias(np);
+   of_node_put(np);
+   }
+
/*
 * HACK: call display setup code

[PATCH 2/2] ARM: dts: omap4-panda: Add clock alias for USB PHY

2013-02-11 Thread Roger Quadros
On Panda, the USB Host PHY is clocked by FREF3_CLK (auxclk3_ck) pin
of the OMAP. Provide this information in the device tree.

CC: Russell King li...@arm.linux.org.uk
CC: Rajendra Nayak rna...@ti.com
CC: Santosh Shilimkar santosh.shilim...@ti.com

Signed-off-by: Roger Quadros rog...@ti.com
---
 arch/arm/boot/dts/omap4-panda.dts |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/omap4-panda.dts 
b/arch/arm/boot/dts/omap4-panda.dts
index d6e59c7..a7d66cc 100644
--- a/arch/arm/boot/dts/omap4-panda.dts
+++ b/arch/arm/boot/dts/omap4-panda.dts
@@ -86,6 +86,13 @@
reset-supply = hsusb1_reset;
vcc-supply = hsusb1_power;
};
+
+   /* hsusb1_phy is clocked by FREF_CLK3 i.e. auxclk3 */
+   clock_alias {
+   clock-name = auxclk3_ck;
+   clock-alias = main_clk;
+   device = hsusb1_phy;
+   };
 };
 
 omap4_pmx_core {
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 1/2] ARM: OMAP2+: Allow clock alias provision from device tree

2013-02-11 Thread Roger Quadros
On 02/11/2013 06:07 PM, Sascha Hauer wrote:
 On Mon, Feb 11, 2013 at 05:44:23PM +0200, Roger Quadros wrote:
 Currently on OMAP, it is not possible to specify a clock consumer
 to any of the OMAP generated clocks using the device tree. This can pose
 a problem for external devices that run off an OMAP clock as we
 can't reliably provide a reference to the clock in the device tree.
 
 There is an established way of providing clocks in the devicetree using
 the clocks/clock-names properties. Wouldn't it be better using this
 for OMAP aswell?
 
I agree with you, but I'm not sure when this migration will be done.
Rajendra/Santosh might know better.

regards,
-roger

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 01/13] usb: phy: nop: Add device tree support and binding information

2013-03-08 Thread Roger Quadros
On 03/08/2013 12:46 PM, Marc Kleine-Budde wrote:
 On 02/04/2013 04:58 PM, Roger Quadros wrote:
 The PHY clock, clock rate, VCC regulator and RESET regulator
 can now be provided via device tree.

 Signed-off-by: Roger Quadros rog...@ti.com
 ---
  .../devicetree/bindings/usb/usb-nop-xceiv.txt  |   34 
 
  drivers/usb/otg/nop-usb-xceiv.c|   31 ++
  2 files changed, 65 insertions(+), 0 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt

 diff --git a/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt 
 b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt
 new file mode 100644
 index 000..d7e2726
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt
 @@ -0,0 +1,34 @@
 +USB NOP PHY
 +
 +Required properties:
 +- compatible: should be usb-nop-xceiv
 +
 +Optional properties:
 +- clocks: phandle to the PHY clock. Use as per Documentation/devicetree
 +  /bindings/clock/clock-bindings.txt
 +  This property is required if clock-frequency is specified.
 +
 +- clock-names: Should be main_clk
 +
 +- clock-frequency: the clock frequency (in Hz) that the PHY clock must
 +  be configured to.
 +
 +- vcc-supply: phandle to the regulator that provides RESET to the PHY.
 +
 +- reset-supply: phandle to the regulator that provides power to the PHY.
 +
 +Example:
 +
 +hsusb1_phy {
 +compatible = usb-nop-xceiv;
 +clock-frequency = 1920;
 
 Why do you hardcode the clock frequency here? You should use
 clk_get_rate() to get the frequency from the clock tree.

That would work only if the clock was programmed to the correct frequency
by someone.

e.g. In the OMAP case nobody programs the auxiliary clock on Panda which clocks
the USB PHY.

The usb-nop-xceiv device driver must program the clock rate using 
clk_set_rate(),
but it needs to know what frequency it must program it to. Different boards/PHYs
might use a different clock frequency. The 'clock-frequency' property
is used to pass on this information to the driver.

cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 01/13] usb: phy: nop: Add device tree support and binding information

2013-03-11 Thread Roger Quadros
On 03/08/2013 05:45 PM, Marc Kleine-Budde wrote:
 On 03/08/2013 11:46 AM, Marc Kleine-Budde wrote:
 On 02/04/2013 04:58 PM, Roger Quadros wrote:
 The PHY clock, clock rate, VCC regulator and RESET regulator
 can now be provided via device tree.

 Signed-off-by: Roger Quadros rog...@ti.com
 ---
  .../devicetree/bindings/usb/usb-nop-xceiv.txt  |   34 
 
  drivers/usb/otg/nop-usb-xceiv.c|   31 
 ++
  2 files changed, 65 insertions(+), 0 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt

 diff --git a/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt 
 b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt
 new file mode 100644
 index 000..d7e2726
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt
 @@ -0,0 +1,34 @@
 +USB NOP PHY
 +
 +Required properties:
 +- compatible: should be usb-nop-xceiv
 +
 +Optional properties:
 +- clocks: phandle to the PHY clock. Use as per Documentation/devicetree
 +  /bindings/clock/clock-bindings.txt
 +  This property is required if clock-frequency is specified.
 +
 +- clock-names: Should be main_clk
 +
 +- clock-frequency: the clock frequency (in Hz) that the PHY clock must
 +  be configured to.
 +
 +- vcc-supply: phandle to the regulator that provides RESET to the PHY.
 +
 +- reset-supply: phandle to the regulator that provides power to the PHY.
 +
 +Example:
 +
 +   hsusb1_phy {
 +   compatible = usb-nop-xceiv;
 +   clock-frequency = 1920;

 Why do you hardcode the clock frequency here? You should use
 clk_get_rate() to get the frequency from the clock tree.
 
 What about declaring a fixed-clock node in the device tree? Then it
 should be possible to keep the driver free of any omap specific code.
 

The current implementation is not OMAP specific and is not limited to a
fixed frequency clock. The PHY driver is using standard clock APIs to set
the clock rate 'only' if the 'clock-frequency' property is present in the
device tree node.

What is the benefit of declaring it as a fixed-clock?
FYI. The clock may not necessarily be a fixed frequency clock and someone
needs to program the rate.

cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 01/13] usb: phy: nop: Add device tree support and binding information

2013-03-12 Thread Roger Quadros
On 03/11/2013 05:52 PM, Marc Kleine-Budde wrote:
 On 02/05/2013 08:26 AM, Felipe Balbi wrote:
 Hi,

 On Mon, Feb 04, 2013 at 05:58:48PM +0200, Roger Quadros wrote:
 The PHY clock, clock rate, VCC regulator and RESET regulator
 can now be provided via device tree.

 Signed-off-by: Roger Quadros rog...@ti.com
 ---
  .../devicetree/bindings/usb/usb-nop-xceiv.txt  |   34 
 
  drivers/usb/otg/nop-usb-xceiv.c|   31 
 ++
  2 files changed, 65 insertions(+), 0 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt

 diff --git a/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt 
 b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt
 new file mode 100644
 index 000..d7e2726
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt
 @@ -0,0 +1,34 @@
 +USB NOP PHY
 +
 +Required properties:
 +- compatible: should be usb-nop-xceiv
 +
 +Optional properties:
 +- clocks: phandle to the PHY clock. Use as per Documentation/devicetree
 +  /bindings/clock/clock-bindings.txt
 +  This property is required if clock-frequency is specified.
 +
 +- clock-names: Should be main_clk
 +
 +- clock-frequency: the clock frequency (in Hz) that the PHY clock must
 +  be configured to.
 +
 +- vcc-supply: phandle to the regulator that provides RESET to the PHY.
 +
 +- reset-supply: phandle to the regulator that provides power to the PHY.
 +
 +Example:
 +
 +   hsusb1_phy {
 +   compatible = usb-nop-xceiv;
 +   clock-frequency = 1920;
 +   clocks = osc 0;
 +   clock-names = main_clk;
 +   vcc-supply = hsusb1_vcc_regulator;
 +   reset-supply = hsusb1_reset_regulator;
 +   };
 +
 +hsusb1_phy is a NOP USB PHY device that gets its clock from an oscillator
 +and expects that clock to be configured to 19.2MHz by the NOP PHY driver.
 +hsusb1_vcc_regulator provides power to the PHY and hsusb1_reset_regulator
 +controls RESET.
 diff --git a/drivers/usb/otg/nop-usb-xceiv.c 
 b/drivers/usb/otg/nop-usb-xceiv.c
 index ac027a1..adbb7ab 100644
 --- a/drivers/usb/otg/nop-usb-xceiv.c
 +++ b/drivers/usb/otg/nop-usb-xceiv.c
 @@ -34,6 +34,7 @@
  #include linux/slab.h
  #include linux/clk.h
  #include linux/regulator/consumer.h
 +#include linux/of.h
  
  struct nop_usb_xceiv {
 struct usb_phy  phy;
 @@ -138,8 +139,19 @@ static int nop_set_host(struct usb_otg *otg, struct 
 usb_bus *host)
 return 0;
  }
  
 +static void nop_xeiv_get_dt_pdata(struct device *dev,

 asking to remove, but xeiv != xceiv :-)

 +   struct nop_usb_xceiv_platform_data *pdata)
 +{
 +   struct device_node *node = dev-of_node;
 +   u32 clk_rate;
 +
 +   if (!of_property_read_u32(node, clock-frequency, clk_rate))
 +   pdata-clk_rate = clk_rate;
 +}
 +
  static int nop_usb_xceiv_probe(struct platform_device *pdev)
  {
 +   struct device *dev = pdev-dev;
 struct nop_usb_xceiv_platform_data *pdata = pdev-dev.platform_data;
 struct nop_usb_xceiv*nop;
 enum usb_phy_type   type = USB_PHY_TYPE_USB2;
 @@ -153,6 +165,17 @@ static int nop_usb_xceiv_probe(struct platform_device 
 *pdev)
 if (!nop-phy.otg)
 return -ENOMEM;
  
 +   if (dev-of_node) {
 +   pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
 +   if (!pdata) {
 +   dev_err(dev, Memory allocation failure\n);
 +   return -ENOMEM;
 +   }
 +   nop_xeiv_get_dt_pdata(dev, pdata);

 actually, I would prefer to not create pdata at all. I mean, ideally
 pdata would be used to initialize fields in your own structure, so first
 move clk_rate to your own private structure, copy pdata's clk_rate value
 to that, then you don't need this hackery when using DT.
 
 As far as I can see, clk_rate is never used, but in the probe function.
 Why should it be saved into the private data structure at all?
 
Yes you are right. I'll fix it up.
Thanks.

cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 02/13] USB: phy: nop: Defer probe if device needs VCC/RESET

2013-03-12 Thread Roger Quadros
On 03/11/2013 05:58 PM, Marc Kleine-Budde wrote:
 On 02/05/2013 10:43 AM, Roger Quadros wrote:
 On 02/05/2013 11:09 AM, Felipe Balbi wrote:
 On Tue, Feb 05, 2013 at 10:44:05AM +0200, Roger Quadros wrote:
 diff --git a/include/linux/usb/nop-usb-xceiv.h 
 b/include/linux/usb/nop-usb-xceiv.h
 index 3265b61..148d351 100644
 --- a/include/linux/usb/nop-usb-xceiv.h
 +++ b/include/linux/usb/nop-usb-xceiv.h
 @@ -6,6 +6,10 @@
   struct nop_usb_xceiv_platform_data {
   enum usb_phy_type type;
   unsigned long clk_rate;
 +
 +/* if set fails with -EPROBE_DEFER if can't get regulator */
 +unsigned int needs_vcc:1;
 +unsigned int needs_reset:1;

 how about u8 here?

 Not sure. Bitfields are usually defined as unsigned int.

 IIRC the benefit is that compiler can try to optimize those flags. I
 mean, if you have 32 1-bit flags, compiler will combine those in a
 single u32. Someone correct me if I'm wrong.


 Yes you are right. Kishon was asking me to use u8 instead of unsigned int, 
 which
 I don't think is necessary. AFAIK, it is a norm to use unsigned int when 
 defining
 a bitfield. Compilers are known to behave funny with bitfields. I don't mind
 using bool for each.
 
 In the current version (rogerq/v3.8-usbhost17-dt) of this patch you've
 put both needs_* into the private data struct and the pdata, but it's
 only used inside the probe function.
 

Good catch! Will fix.

cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 0/6] mfd: omap-usb-host: Device tree support for 3.10

2013-03-12 Thread Roger Quadros
Hi Samuel,

These patches implement device tree support for the OMAP High Speed
USB Host subsystem. The corresponding EHCI  SoC patches will be sent
separately and this set has no build dependencies with them.

Patch 3 is acutally a bug fix which should go into 3.9-rc. I've sent
it separately to you before.

The following changes since commit f6161aa153581da4a3867a2d1a7caf4be19b6ec9:

  Linux 3.9-rc2 (2013-03-10 16:54:19 -0700)

are available in the git repository at:
  git://github.com/rogerq/linux.git usbhost-mfd-next

Roger Quadros (6):
  mfd: omap-usb-host: update nports in platform_data
  mfd: omap-usb-host: Remove PHY reset handling code
  mfd: omap-usb-host: Actually update hostconfig
  mfd: omap-usb-tll: move configuration code to omap_tll_init()
  mfd: omap-usb-tll: Add device tree support and binding information
  mfd: omap-usb-host: Add device tree support and binding information

 .../devicetree/bindings/mfd/omap-usb-host.txt  |   80 
 .../devicetree/bindings/mfd/omap-usb-tll.txt   |   17 ++
 drivers/mfd/omap-usb-host.c|  206 ++-
 drivers/mfd/omap-usb-tll.c |  214 ++--
 drivers/mfd/omap-usb.h |5 +-
 5 files changed, 365 insertions(+), 157 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/omap-usb-host.txt
 create mode 100644 Documentation/devicetree/bindings/mfd/omap-usb-tll.txt

--
cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 1/6] mfd: omap-usb-host: update nports in platform_data

2013-03-12 Thread Roger Quadros
EHCI driver would need to know the number of ports available
on the platform. We set the nports parameter of platform_data
based on IP version if it was not already provided.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Samuel Ortiz sa...@linux.intel.com
---
 drivers/mfd/omap-usb-host.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 6b5edf6..0874352 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -575,6 +575,7 @@ static int usbhs_omap_probe(struct platform_device *pdev)
 omap-usbhs_rev, omap-nports);
break;
}
+   pdata-nports = omap-nports;
}
 
i = sizeof(struct clk *) * omap-nports;
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 2/6] mfd: omap-usb-host: Remove PHY reset handling code

2013-03-12 Thread Roger Quadros
PHY reset GPIO handling will be done in the PHY driver

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Samuel Ortiz sa...@linux.intel.com
---
 drivers/mfd/omap-usb-host.c |   47 ---
 1 files changed, 0 insertions(+), 47 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 0874352..502a779 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -430,24 +430,10 @@ static unsigned omap_usbhs_rev2_hostconfig(struct 
usbhs_hcd_omap *omap,
 static void omap_usbhs_init(struct device *dev)
 {
struct usbhs_hcd_omap   *omap = dev_get_drvdata(dev);
-   struct usbhs_omap_platform_data *pdata = omap-pdata;
unsignedreg;
 
dev_dbg(dev, starting TI HSUSB Controller\n);
 
-   if (pdata-phy_reset) {
-   if (gpio_is_valid(pdata-reset_gpio_port[0]))
-   gpio_request_one(pdata-reset_gpio_port[0],
-GPIOF_OUT_INIT_LOW, USB1 PHY reset);
-
-   if (gpio_is_valid(pdata-reset_gpio_port[1]))
-   gpio_request_one(pdata-reset_gpio_port[1],
-GPIOF_OUT_INIT_LOW, USB2 PHY reset);
-
-   /* Hold the PHY in RESET for enough time till DIR is high */
-   udelay(10);
-   }
-
pm_runtime_get_sync(dev);
 
reg = usbhs_read(omap-uhh_base, OMAP_UHH_HOSTCONFIG);
@@ -476,37 +462,8 @@ static void omap_usbhs_init(struct device *dev)
dev_dbg(dev, UHH setup done, uhh_hostconfig=%x\n, reg);
 
pm_runtime_put_sync(dev);
-   if (pdata-phy_reset) {
-   /* Hold the PHY in RESET for enough time till
-* PHY is settled and ready
-*/
-   udelay(10);
-
-   if (gpio_is_valid(pdata-reset_gpio_port[0]))
-   gpio_set_value_cansleep
-   (pdata-reset_gpio_port[0], 1);
-
-   if (gpio_is_valid(pdata-reset_gpio_port[1]))
-   gpio_set_value_cansleep
-   (pdata-reset_gpio_port[1], 1);
-   }
-}
-
-static void omap_usbhs_deinit(struct device *dev)
-{
-   struct usbhs_hcd_omap   *omap = dev_get_drvdata(dev);
-   struct usbhs_omap_platform_data *pdata = omap-pdata;
-
-   if (pdata-phy_reset) {
-   if (gpio_is_valid(pdata-reset_gpio_port[0]))
-   gpio_free(pdata-reset_gpio_port[0]);
-
-   if (gpio_is_valid(pdata-reset_gpio_port[1]))
-   gpio_free(pdata-reset_gpio_port[1]);
-   }
 }
 
-
 /**
  * usbhs_omap_probe - initialize TI-based HCDs
  *
@@ -710,8 +667,6 @@ static int usbhs_omap_probe(struct platform_device *pdev)
return 0;
 
 err_alloc:
-   omap_usbhs_deinit(pdev-dev);
-
for (i = 0; i  omap-nports; i++) {
if (!IS_ERR(omap-utmi_clk[i]))
clk_put(omap-utmi_clk[i]);
@@ -756,8 +711,6 @@ static int usbhs_omap_remove(struct platform_device *pdev)
struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev);
int i;
 
-   omap_usbhs_deinit(pdev-dev);
-
for (i = 0; i  omap-nports; i++) {
if (!IS_ERR(omap-utmi_clk[i]))
clk_put(omap-utmi_clk[i]);
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 3/6] mfd: omap-usb-host: Actually update hostconfig

2013-03-12 Thread Roger Quadros
The helper functions omap_usbhs_rev1_hostconfig()
and omap_usbhs_rev2_hostconfig() don't write into
the hostconfig register. Make sure that we write
the return value into the hostconfig register.

Signed-off-by: Roger Quadros rog...@ti.com
---
 drivers/mfd/omap-usb-host.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 502a779..c3efe64 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -446,15 +446,15 @@ static void omap_usbhs_init(struct device *dev)
 
switch (omap-usbhs_rev) {
case OMAP_USBHS_REV1:
-   omap_usbhs_rev1_hostconfig(omap, reg);
+   reg = omap_usbhs_rev1_hostconfig(omap, reg);
break;
 
case OMAP_USBHS_REV2:
-   omap_usbhs_rev2_hostconfig(omap, reg);
+   reg = omap_usbhs_rev2_hostconfig(omap, reg);
break;
 
default:/* newer revisions */
-   omap_usbhs_rev2_hostconfig(omap, reg);
+   reg = omap_usbhs_rev2_hostconfig(omap, reg);
break;
}
 
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 4/6] mfd: omap-usb-tll: move configuration code to omap_tll_init()

2013-03-12 Thread Roger Quadros
This is because we want to get rid of platform_data usage from probe().
The only information we need is PORT_MODE, and this can be supplied
to us by the user (i.e. omap-usb-host.c).

We also move channel clock management from runtime PM handlers into
omap_tll_enable/disable().

Signed-off-by: Roger Quadros rog...@ti.com
---
 drivers/mfd/omap-usb-host.c |7 +-
 drivers/mfd/omap-usb-tll.c  |  204 +--
 drivers/mfd/omap-usb.h  |5 +-
 3 files changed, 107 insertions(+), 109 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index c3efe64..138ee98 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -278,7 +278,7 @@ static int usbhs_runtime_resume(struct device *dev)
 
dev_dbg(dev, usbhs_runtime_resume\n);
 
-   omap_tll_enable();
+   omap_tll_enable(pdata);
 
if (!IS_ERR(omap-ehci_logic_fck))
clk_enable(omap-ehci_logic_fck);
@@ -353,7 +353,7 @@ static int usbhs_runtime_suspend(struct device *dev)
if (!IS_ERR(omap-ehci_logic_fck))
clk_disable(omap-ehci_logic_fck);
 
-   omap_tll_disable();
+   omap_tll_disable(pdata);
 
return 0;
 }
@@ -499,6 +499,9 @@ static int usbhs_omap_probe(struct platform_device *pdev)
 
omap-pdata = pdata;
 
+   /* Initialize the TLL subsystem */
+   omap_tll_init(pdata);
+
pm_runtime_enable(dev);
 
platform_set_drvdata(pdev, omap);
diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index 0aef1a7..f7d2568 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -1,8 +1,9 @@
 /**
  * omap-usb-tll.c - The USB TLL driver for OMAP EHCI  OHCI
  *
- * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com
+ * Copyright (C) 2012-2013 Texas Instruments Incorporated - http://www.ti.com
  * Author: Keshava Munegowda keshava_mgo...@ti.com
+ * Author: Roger Quadros rog...@ti.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  of
@@ -105,8 +106,8 @@
 
 struct usbtll_omap {
int nch;/* num. of channels */
-   struct usbhs_omap_platform_data *pdata;
struct clk  **ch_clk;
+   void __iomem*base;
 };
 
 /*-*/
@@ -210,14 +211,10 @@ static unsigned ohci_omap3_fslsmode(enum 
usbhs_omap_port_mode mode)
 static int usbtll_omap_probe(struct platform_device *pdev)
 {
struct device   *dev =  pdev-dev;
-   struct usbhs_omap_platform_data *pdata = dev-platform_data;
-   void __iomem*base;
struct resource *res;
struct usbtll_omap  *tll;
-   unsignedreg;
int ret = 0;
int i, ver;
-   bool needs_tll;
 
dev_dbg(dev, starting TI HSUSB TLL Controller\n);
 
@@ -227,16 +224,9 @@ static int usbtll_omap_probe(struct platform_device *pdev)
return -ENOMEM;
}
 
-   if (!pdata) {
-   dev_err(dev, Platform data missing\n);
-   return -ENODEV;
-   }
-
-   tll-pdata = pdata;
-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   base = devm_request_and_ioremap(dev, res);
-   if (!base) {
+   tll-base = devm_request_and_ioremap(dev, res);
+   if (!tll-base) {
ret = -EADDRNOTAVAIL;
dev_err(dev, Resource request/ioremap failed:%d\n, ret);
return ret;
@@ -246,7 +236,7 @@ static int usbtll_omap_probe(struct platform_device *pdev)
pm_runtime_enable(dev);
pm_runtime_get_sync(dev);
 
-   ver =  usbtll_read(base, OMAP_USBTLL_REVISION);
+   ver =  usbtll_read(tll-base, OMAP_USBTLL_REVISION);
switch (ver) {
case OMAP_USBTLL_REV1:
case OMAP_USBTLL_REV4:
@@ -283,11 +273,77 @@ static int usbtll_omap_probe(struct platform_device *pdev)
dev_dbg(dev, can't get clock : %s\n, clkname);
}
 
+   pm_runtime_put_sync(dev);
+   /* only after this can omap_tll_enable/disable work */
+   spin_lock(tll_lock);
+   tll_dev = dev;
+   spin_unlock(tll_lock);
+
+   return 0;
+
+err_clk_alloc:
+   pm_runtime_put_sync(dev);
+   pm_runtime_disable(dev);
+
+   return ret;
+}
+
+/**
+ * usbtll_omap_remove - shutdown processing for UHH  TLL HCDs
+ * @pdev: USB Host Controller being removed
+ *
+ * Reverses the effect of usbtll_omap_probe().
+ */
+static int usbtll_omap_remove(struct platform_device *pdev)
+{
+   struct usbtll_omap *tll = platform_get_drvdata(pdev);
+   int i

[PATCH 5/6] mfd: omap-usb-tll: Add device tree support and binding information

2013-03-12 Thread Roger Quadros
Allows the OMAP USB TLL module to be specified via device tree.

Signed-off-by: Roger Quadros rog...@ti.com
---
 .../devicetree/bindings/mfd/omap-usb-tll.txt   |   17 +
 drivers/mfd/omap-usb-tll.c |   10 ++
 2 files changed, 27 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/omap-usb-tll.txt

diff --git a/Documentation/devicetree/bindings/mfd/omap-usb-tll.txt 
b/Documentation/devicetree/bindings/mfd/omap-usb-tll.txt
new file mode 100644
index 000..62fe697
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/omap-usb-tll.txt
@@ -0,0 +1,17 @@
+OMAP HS USB Host TLL (Transceiver-Less Interface)
+
+Required properties:
+
+- compatible : should be ti,usbhs-tll
+- reg : should contain one register range i.e. start and length
+- interrupts : should contain the TLL module's interrupt
+- ti,hwmod : must contain usb_tll_hs
+
+Example:
+
+   usbhstll: usbhstll@4a062000 {
+   compatible = ti,usbhs-tll;
+   reg = 0x4a062000 0x1000;
+   interrupts = 78;
+   ti,hwmods = usb_tll_hs;
+ };
diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index f7d2568..8f4d5a1 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -28,6 +28,7 @@
 #include linux/err.h
 #include linux/pm_runtime.h
 #include linux/platform_data/usb-omap.h
+#include linux/of.h
 
 #define USBTLL_DRIVER_NAME usbhs_tll
 
@@ -311,10 +312,18 @@ static int usbtll_omap_remove(struct platform_device 
*pdev)
return 0;
 }
 
+static const struct of_device_id usbtll_omap_dt_ids[] = {
+   { .compatible = ti,usbhs-tll },
+   { }
+};
+
+MODULE_DEVICE_TABLE(of, usbtll_omap_dt_ids);
+
 static struct platform_driver usbtll_omap_driver = {
.driver = {
.name   = (char *)usbtll_driver_name,
.owner  = THIS_MODULE,
+   .of_match_table = of_match_ptr(usbtll_omap_dt_ids),
},
.probe  = usbtll_omap_probe,
.remove = usbtll_omap_remove,
@@ -467,6 +476,7 @@ int omap_tll_disable(struct usbhs_omap_platform_data *pdata)
 EXPORT_SYMBOL_GPL(omap_tll_disable);
 
 MODULE_AUTHOR(Keshava Munegowda keshava_mgo...@ti.com);
+MODULE_AUTHOR(Roger Quadros rog...@ti.com);
 MODULE_ALIAS(platform: USBHS_DRIVER_NAME);
 MODULE_LICENSE(GPL v2);
 MODULE_DESCRIPTION(usb tll driver for TI OMAP EHCI and OHCI controllers);
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 6/6] mfd: omap-usb-host: Add device tree support and binding information

2013-03-12 Thread Roger Quadros
Allows the OMAP HS USB host controller to be specified
via device tree.

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Mark Rutland mark.rutl...@arm.com
---
 .../devicetree/bindings/mfd/omap-usb-host.txt  |   80 ++
 drivers/mfd/omap-usb-host.c|  161 +++-
 2 files changed, 235 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/omap-usb-host.txt

diff --git a/Documentation/devicetree/bindings/mfd/omap-usb-host.txt 
b/Documentation/devicetree/bindings/mfd/omap-usb-host.txt
new file mode 100644
index 000..b381fa6
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/omap-usb-host.txt
@@ -0,0 +1,80 @@
+OMAP HS USB Host
+
+Required properties:
+
+- compatible: should be ti,usbhs-host
+- reg: should contain one register range i.e. start and length
+- ti,hwmods: must contain usb_host_hs
+
+Optional properties:
+
+- num-ports: number of USB ports. Usually this is automatically detected
+  from the IP's revision register but can be overridden by specifying
+  this property. A maximum of 3 ports are supported at the moment.
+
+- portN-mode: String specifying the port mode for port N, where N can be
+  from 1 to 3. If the port mode is not specified, that port is treated
+  as unused. When specified, it must be one of the following.
+   ehci-phy,
+ehci-tll,
+ehci-hsic,
+ohci-phy-6pin-datse0,
+ohci-phy-6pin-dpdm,
+ohci-phy-3pin-datse0,
+ohci-phy-4pin-dpdm,
+ohci-tll-6pin-datse0,
+ohci-tll-6pin-dpdm,
+ohci-tll-3pin-datse0,
+ohci-tll-4pin-dpdm,
+ohci-tll-2pin-datse0,
+ohci-tll-2pin-dpdm,
+
+- single-ulpi-bypass: Must be present if the controller contains a single
+  ULPI bypass control bit. e.g. OMAP3 silicon = ES2.1
+
+Required properties if child node exists:
+
+- #address-cells: Must be 1
+- #size-cells: Must be 1
+- ranges: must be present
+
+Properties for children:
+
+The OMAP HS USB Host subsystem contains EHCI and OHCI controllers.
+See Documentation/devicetree/bindings/usb/omap-ehci.txt and
+omap3-ohci.txt
+
+Example for OMAP4:
+
+usbhshost: usbhshost@4a064000 {
+   compatible = ti,usbhs-host;
+   reg = 0x4a064000 0x800;
+   ti,hwmods = usb_host_hs;
+   #address-cells = 1;
+   #size-cells = 1;
+   ranges;
+
+   usbhsohci: ohci@4a064800 {
+   compatible = ti,ohci-omap3, usb-ohci;
+   reg = 0x4a064800 0x400;
+   interrupt-parent = gic;
+   interrupts = 0 76 0x4;
+   };
+
+   usbhsehci: ehci@4a064c00 {
+   compatible = ti,ehci-omap, usb-ehci;
+   reg = 0x4a064c00 0x400;
+   interrupt-parent = gic;
+   interrupts = 0 77 0x4;
+   };
+};
+
+usbhshost {
+   port1-mode = ehci-phy;
+   port2-mode = ehci-tll;
+   port3-mode = ehci-phy;
+};
+
+usbhsehci {
+   phys = hsusb1_phy 0 hsusb3_phy;
+};
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 138ee98..d3b6e94 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -1,8 +1,9 @@
 /**
  * omap-usb-host.c - The USBHS core driver for OMAP EHCI  OHCI
  *
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com
+ * Copyright (C) 2011-2013 Texas Instruments Incorporated - http://www.ti.com
  * Author: Keshava Munegowda keshava_mgo...@ti.com
+ * Author: Roger Quadros rog...@ti.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  of
@@ -27,6 +28,8 @@
 #include linux/platform_device.h
 #include linux/platform_data/usb-omap.h
 #include linux/pm_runtime.h
+#include linux/of.h
+#include linux/of_platform.h
 
 #include omap-usb.h
 
@@ -137,6 +140,49 @@ static inline u8 usbhs_readb(void __iomem *base, u8 reg)
 
 /*-*/
 
+/**
+ * Map 'enum usbhs_omap_port_mode' found in linux/platform_data/usb-omap.h
+ * to the device tree binding portN-mode found in
+ * 'Documentation/devicetree/bindings/mfd/omap-usb-host.txt'
+ */
+static const char * const port_modes[] = {
+   [OMAP_USBHS_PORT_MODE_UNUSED]   = ,
+   [OMAP_EHCI_PORT_MODE_PHY]   = ehci-phy,
+   [OMAP_EHCI_PORT_MODE_TLL]   = ehci-tll,
+   [OMAP_EHCI_PORT_MODE_HSIC]  = ehci-hsic,
+   [OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0]   = ohci-phy-6pin-datse0,
+   [OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM] = ohci-phy-6pin-dpdm,
+   [OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0]   = ohci-phy-3pin-datse0,
+   [OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM] = ohci-phy-4pin-dpdm,
+   [OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0]   = ohci-tll-6pin-datse0,
+   [OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM] = ohci-tll-6pin-dpdm,
+   [OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0]   = ohci-tll-3pin-datse0,
+   [OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM] = ohci-tll-4pin

[PATCH 00/12] USB: ehci-omap: Device tree support for 3.10

2013-03-12 Thread Roger Quadros
Hi Greg,

These patches implement device tree support for the OMAP's
EHCI host controller. The corresponding MFD/SoC patches will be sent
separately and this set has no dependeny with them.

NOTE: Last 2 patches are new and still need and Ack from Alan Stern.
Please accept this set after he has acked them. Thanks.

cheers,
-roger

The following changes since commit f6161aa153581da4a3867a2d1a7caf4be19b6ec9:

  Linux 3.9-rc2 (2013-03-10 16:54:19 -0700)

are available in the git repository at:
  git://github.com/rogerq/linux.git usbhost-usb-next

Alan Stern (1):
  USB: EHCI: split ehci-omap out to a separate driver

Roger Quadros (11):
  USB: ehci-omap: Use devm_ioremap_resource()
  USB: ehci-omap: Use PHY APIs to get the PHY device and put it out of
suspend
  USB: ehci-omap: Remove PHY reset handling code
  USB: ehci-omap: Remove PHY regulator handling code
  USB: ehci-omap: Select NOP USB transceiver driver
  USB: ehci-omap: Get platform resources by index rather than by name
  USB: ohci-omap3: Get platform resources by index rather than by name
  USB: ohci-omap3: Add device tree support and binding information
  USB: ehci-omap: Add device tree support and binding information
  USB: ehci-omap: Try to get PHY even if not in PHY mode
  USB: ehci-omap: Fix detection in HSIC mode

 .../devicetree/bindings/usb/ehci-omap.txt  |   32 ++
 .../devicetree/bindings/usb/ohci-omap3.txt |   15 +
 drivers/usb/host/Kconfig   |3 +-
 drivers/usb/host/Makefile  |1 +
 drivers/usb/host/ehci-hcd.c|6 +-
 drivers/usb/host/ehci-omap.c   |  312 +---
 drivers/usb/host/ohci-omap3.c  |   24 ++-
 7 files changed, 214 insertions(+), 179 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/ehci-omap.txt
 create mode 100644 Documentation/devicetree/bindings/usb/ohci-omap3.txt

-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 01/12] USB: EHCI: split ehci-omap out to a separate driver

2013-03-12 Thread Roger Quadros
From: Alan Stern st...@rowland.harvard.edu

This patch (as1645) converts ehci-omap over to the new ehci-hcd is a
library approach, so that it can coexist peacefully with other EHCI
platform drivers and can make use of the private area allocated at
the end of struct ehci_hcd.

Signed-off-by: Alan Stern st...@rowland.harvard.edu
---
 drivers/usb/host/Kconfig |2 +-
 drivers/usb/host/Makefile|1 +
 drivers/usb/host/ehci-hcd.c  |6 +---
 drivers/usb/host/ehci-omap.c |   76 +++---
 4 files changed, 37 insertions(+), 48 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index c59a112..62f4e9a 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -155,7 +155,7 @@ config USB_EHCI_MXC
  Variation of ARC USB block used in some Freescale chips.
 
 config USB_EHCI_HCD_OMAP
-   bool EHCI support for OMAP3 and later chips
+   tristate EHCI support for OMAP3 and later chips
depends on USB_EHCI_HCD  ARCH_OMAP
default y
---help---
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 001fbff..56de410 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_USB_EHCI_HCD)+= ehci-hcd.o
 obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o
 obj-$(CONFIG_USB_EHCI_HCD_PLATFORM)+= ehci-platform.o
 obj-$(CONFIG_USB_EHCI_MXC) += ehci-mxc.o
+obj-$(CONFIG_USB_EHCI_HCD_OMAP)+= ehci-omap.o
 
 obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o
 obj-$(CONFIG_USB_ISP116X_HCD)  += isp116x-hcd.o
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index b416a3f..303b022 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1252,11 +1252,6 @@ MODULE_LICENSE (GPL);
 #define PLATFORM_DRIVERehci_hcd_sh_driver
 #endif
 
-#ifdef CONFIG_USB_EHCI_HCD_OMAP
-#include ehci-omap.c
-#definePLATFORM_DRIVER ehci_hcd_omap_driver
-#endif
-
 #ifdef CONFIG_PPC_PS3
 #include ehci-ps3.c
 #definePS3_SYSTEM_BUS_DRIVER   ps3_ehci_driver
@@ -1346,6 +1341,7 @@ MODULE_LICENSE (GPL);
!IS_ENABLED(CONFIG_USB_EHCI_HCD_PLATFORM)  \
!IS_ENABLED(CONFIG_USB_CHIPIDEA_HOST)  \
!IS_ENABLED(CONFIG_USB_EHCI_MXC)  \
+   !IS_ENABLED(CONFIG_USB_EHCI_HCD_OMAP)  \
!defined(PLATFORM_DRIVER)  \
!defined(PS3_SYSTEM_BUS_DRIVER)  \
!defined(OF_PLATFORM_DRIVER)  \
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 0555ee4..fa66757 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -36,6 +36,9 @@
  * - convert to use hwmod and runtime PM
  */
 
+#include linux/kernel.h
+#include linux/module.h
+#include linux/io.h
 #include linux/platform_device.h
 #include linux/slab.h
 #include linux/usb/ulpi.h
@@ -43,6 +46,10 @@
 #include linux/pm_runtime.h
 #include linux/gpio.h
 #include linux/clk.h
+#include linux/usb.h
+#include linux/usb/hcd.h
+
+#include ehci.h
 
 #include linux/platform_data/usb-omap.h
 
@@ -57,9 +64,11 @@
 #defineEHCI_INSNREG05_ULPI_EXTREGADD_SHIFT 8
 #defineEHCI_INSNREG05_ULPI_WRDATA_SHIFT0
 
-/*-*/
+#define DRIVER_DESC OMAP-EHCI Host Controller driver
 
-static const struct hc_driver ehci_omap_hc_driver;
+static const char hcd_name[] = ehci-omap;
+
+/*-*/
 
 
 static inline void ehci_write(void __iomem *base, u32 reg, u32 val)
@@ -166,6 +175,12 @@ static void disable_put_regulator(
 /* configure so an HC device and id are always provided */
 /* always called with process context; sleeping is OK */
 
+static struct hc_driver __read_mostly ehci_omap_hc_driver;
+
+static const struct ehci_driver_overrides ehci_omap_overrides __initdata = {
+   .reset =omap_ehci_init,
+};
+
 /**
  * ehci_hcd_omap_probe - initialize TI-based HCDs
  *
@@ -315,56 +330,33 @@ static struct platform_driver ehci_hcd_omap_driver = {
/*.suspend  = ehci_hcd_omap_suspend, */
/*.resume   = ehci_hcd_omap_resume, */
.driver = {
-   .name   = ehci-omap,
+   .name   = hcd_name,
}
 };
 
 /*-*/
 
-static const struct hc_driver ehci_omap_hc_driver = {
-   .description= hcd_name,
-   .product_desc   = OMAP-EHCI Host Controller,
-   .hcd_priv_size  = sizeof(struct ehci_hcd),
-
-   /*
-* generic hardware linkage
-*/
-   .irq= ehci_irq,
-   .flags  = HCD_MEMORY | HCD_USB2,
-
-   /*
-* basic lifecycle operations
-*/
-   .reset  = omap_ehci_init,
-   .start  = ehci_run,
-   .stop  

[PATCH 04/12] USB: ehci-omap: Remove PHY reset handling code

2013-03-12 Thread Roger Quadros
Reset GPIO handling for the PHY must be done in the PHY
driver. We use the PHY helpers instead to reset the PHY.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Alan Stern st...@rowland.harvard.edu
---
 drivers/usb/host/ehci-omap.c |   72 ++
 1 files changed, 10 insertions(+), 62 deletions(-)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 6b8b7e5..0bbfdc1 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -86,79 +86,27 @@ static inline u32 ehci_read(void __iomem *base, u32 reg)
return __raw_readl(base + reg);
 }
 
-
-static void omap_ehci_soft_phy_reset(struct usb_hcd *hcd, u8 port)
-{
-   unsigned long timeout = jiffies + msecs_to_jiffies(1000);
-   unsigned reg = 0;
-
-   reg = ULPI_FUNC_CTRL_RESET
-   /* FUNCTION_CTRL_SET register */
-   | (ULPI_SET(ULPI_FUNC_CTRL)  EHCI_INSNREG05_ULPI_REGADD_SHIFT)
-   /* Write */
-   | (2  EHCI_INSNREG05_ULPI_OPSEL_SHIFT)
-   /* PORTn */
-   | ((port + 1)  EHCI_INSNREG05_ULPI_PORTSEL_SHIFT)
-   /* start ULPI access*/
-   | (1  EHCI_INSNREG05_ULPI_CONTROL_SHIFT);
-
-   ehci_write(hcd-regs, EHCI_INSNREG05_ULPI, reg);
-
-   /* Wait for ULPI access completion */
-   while ((ehci_read(hcd-regs, EHCI_INSNREG05_ULPI)
-(1  EHCI_INSNREG05_ULPI_CONTROL_SHIFT))) {
-   cpu_relax();
-
-   if (time_after(jiffies, timeout)) {
-   dev_dbg(hcd-self.controller,
-   phy reset operation timed out\n);
-   break;
-   }
-   }
-}
-
 static int omap_ehci_init(struct usb_hcd *hcd)
 {
-   struct ehci_hcd *ehci = hcd_to_ehci(hcd);
-   int rc;
-   struct usbhs_omap_platform_data *pdata;
-
-   pdata = hcd-self.controller-platform_data;
+   struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+   struct omap_hcd *omap = (struct omap_hcd *)ehci-priv;
+   int rc, i;
 
/* Hold PHYs in reset while initializing EHCI controller */
-   if (pdata-phy_reset) {
-   if (gpio_is_valid(pdata-reset_gpio_port[0]))
-   gpio_set_value_cansleep(pdata-reset_gpio_port[0], 0);
-
-   if (gpio_is_valid(pdata-reset_gpio_port[1]))
-   gpio_set_value_cansleep(pdata-reset_gpio_port[1], 0);
-
-   /* Hold the PHY in RESET for enough time till DIR is high */
-   udelay(10);
+   for (i = 0; i  omap-nports; i++) {
+   if (omap-phy[i])
+   usb_phy_shutdown(omap-phy[i]);
}
 
-   /* Soft reset the PHY using PHY reset command over ULPI */
-   if (pdata-port_mode[0] == OMAP_EHCI_PORT_MODE_PHY)
-   omap_ehci_soft_phy_reset(hcd, 0);
-   if (pdata-port_mode[1] == OMAP_EHCI_PORT_MODE_PHY)
-   omap_ehci_soft_phy_reset(hcd, 1);
-
/* we know this is the memory we want, no need to ioremap again */
ehci-caps = hcd-regs;
 
rc = ehci_setup(hcd);
 
-   if (pdata-phy_reset) {
-   /* Hold the PHY in RESET for enough time till
-* PHY is settled and ready
-*/
-   udelay(10);
-
-   if (gpio_is_valid(pdata-reset_gpio_port[0]))
-   gpio_set_value_cansleep(pdata-reset_gpio_port[0], 1);
-
-   if (gpio_is_valid(pdata-reset_gpio_port[1]))
-   gpio_set_value_cansleep(pdata-reset_gpio_port[1], 1);
+   /* Bring PHYs out of reset */
+   for (i = 0; i  omap-nports; i++) {
+   if (omap-phy[i])
+   usb_phy_init(omap-phy[i]);
}
 
return rc;
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 06/12] USB: ehci-omap: Select NOP USB transceiver driver

2013-03-12 Thread Roger Quadros
In PHY mode we need to have the nop-usb-xceiv transceiver
driver to operate, so select it in Kconfig.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Alan Stern st...@rowland.harvard.edu
---
 drivers/usb/host/Kconfig |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 62f4e9a..2f68221 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -157,6 +157,7 @@ config USB_EHCI_MXC
 config USB_EHCI_HCD_OMAP
tristate EHCI support for OMAP3 and later chips
depends on USB_EHCI_HCD  ARCH_OMAP
+   select NOP_USB_XCEIV
default y
---help---
  Enables support for the on-chip EHCI controller on
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 07/12] USB: ehci-omap: Get platform resources by index rather than by name

2013-03-12 Thread Roger Quadros
Since there is only one resource per type we don't really need
to use resource name to obtain it. This also also makes it easier
for device tree adaptation.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Alan Stern st...@rowland.harvard.edu
---
 drivers/usb/host/ehci-omap.c |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 57fe985..7d05cce 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -148,14 +148,13 @@ static int ehci_hcd_omap_probe(struct platform_device 
*pdev)
return -ENODEV;
}
 
-   irq = platform_get_irq_byname(pdev, ehci-irq);
+   irq = platform_get_irq(pdev, 0);
if (irq  0) {
dev_err(dev, EHCI irq failed\n);
return -ENODEV;
}
 
-   res =  platform_get_resource_byname(pdev,
-   IORESOURCE_MEM, ehci);
+   res =  platform_get_resource(pdev, IORESOURCE_MEM, 0);
regs = devm_ioremap_resource(dev, res);
if (IS_ERR(regs))
return PTR_ERR(regs);
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 09/12] USB: ohci-omap3: Add device tree support and binding information

2013-03-12 Thread Roger Quadros
Allows the OHCI controller found in OMAP3 and later chips to
be specified via device tree.

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Mark Rutland mark.rutl...@arm.com
Acked-by: Alan Stern st...@rowland.harvard.edu
---
 .../devicetree/bindings/usb/ohci-omap3.txt |   15 +++
 drivers/usb/host/ohci-omap3.c  |   19 +++
 2 files changed, 34 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/ohci-omap3.txt

diff --git a/Documentation/devicetree/bindings/usb/ohci-omap3.txt 
b/Documentation/devicetree/bindings/usb/ohci-omap3.txt
new file mode 100644
index 000..14ab428
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ohci-omap3.txt
@@ -0,0 +1,15 @@
+OMAP HS USB OHCI controller (OMAP3 and later)
+
+Required properties:
+
+- compatible: should be ti,ohci-omap3
+- reg: should contain one register range i.e. start and length
+- interrupts: description of the interrupt line
+
+Example for OMAP4:
+
+usbhsohci: ohci@4a064800 {
+   compatible = ti,ohci-omap3, usb-ohci;
+   reg = 0x4a064800 0x400;
+   interrupts = 0 76 0x4;
+};
diff --git a/drivers/usb/host/ohci-omap3.c b/drivers/usb/host/ohci-omap3.c
index 5ed28c5..ddfc314 100644
--- a/drivers/usb/host/ohci-omap3.c
+++ b/drivers/usb/host/ohci-omap3.c
@@ -31,6 +31,8 @@
 
 #include linux/platform_device.h
 #include linux/pm_runtime.h
+#include linux/of.h
+#include linux/dma-mapping.h
 
 /*-*/
 
@@ -112,6 +114,8 @@ static const struct hc_driver ohci_omap3_hc_driver = {
 
 /*-*/
 
+static u64 omap_ohci_dma_mask = DMA_BIT_MASK(32);
+
 /*
  * configure so an HC device and id are always provided
  * always called with process context; sleeping is OK
@@ -159,6 +163,13 @@ static int ohci_hcd_omap3_probe(struct platform_device 
*pdev)
return -ENOMEM;
}
 
+   /*
+* Right now device-tree probed devices don't get dma_mask set.
+* Since shared usb code relies on it, set it here for now.
+* Once we have dma capability bindings this can go away.
+*/
+   if (!pdev-dev.dma_mask)
+   pdev-dev.dma_mask = omap_ohci_dma_mask;
 
hcd = usb_create_hcd(ohci_omap3_hc_driver, dev,
dev_name(dev));
@@ -228,12 +239,20 @@ static void ohci_hcd_omap3_shutdown(struct 
platform_device *pdev)
hcd-driver-shutdown(hcd);
 }
 
+static const struct of_device_id omap_ohci_dt_ids[] = {
+   { .compatible = ti,ohci-omap3 },
+   { }
+};
+
+MODULE_DEVICE_TABLE(of, omap_ohci_dt_ids);
+
 static struct platform_driver ohci_hcd_omap3_driver = {
.probe  = ohci_hcd_omap3_probe,
.remove = ohci_hcd_omap3_remove,
.shutdown   = ohci_hcd_omap3_shutdown,
.driver = {
.name   = ohci-omap3,
+   .of_match_table = of_match_ptr(omap_ohci_dt_ids),
},
 };
 
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 10/12] USB: ehci-omap: Add device tree support and binding information

2013-03-12 Thread Roger Quadros
Allows the OMAP EHCI controller to be specified via device tree.

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Mark Rutland mark.rutl...@arm.com
Acked-by: Alan Stern st...@rowland.harvard.edu
---
 .../devicetree/bindings/usb/ehci-omap.txt  |   32 +
 drivers/usb/host/ehci-omap.c   |   37 +++-
 2 files changed, 68 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/ehci-omap.txt

diff --git a/Documentation/devicetree/bindings/usb/ehci-omap.txt 
b/Documentation/devicetree/bindings/usb/ehci-omap.txt
new file mode 100644
index 000..485a9a1
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ehci-omap.txt
@@ -0,0 +1,32 @@
+OMAP HS USB EHCI controller
+
+This device is usually the child of the omap-usb-host
+Documentation/devicetree/bindings/mfd/omap-usb-host.txt
+
+Required properties:
+
+- compatible: should be ti,ehci-omap
+- reg: should contain one register range i.e. start and length
+- interrupts: description of the interrupt line
+
+Optional properties:
+
+- phys: list of phandles to PHY nodes.
+  This property is required if at least one of the ports are in
+  PHY mode i.e. OMAP_EHCI_PORT_MODE_PHY
+
+To specify the port mode, see
+Documentation/devicetree/bindings/mfd/omap-usb-host.txt
+
+Example for OMAP4:
+
+usbhsehci: ehci@4a064c00 {
+   compatible = ti,ehci-omap, usb-ehci;
+   reg = 0x4a064c00 0x400;
+   interrupts = 0 77 0x4;
+};
+
+usbhsehci {
+   phys = hsusb1_phy 0 hsusb3_phy;
+};
+
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 7d05cce..45cd01e 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -48,6 +48,8 @@
 #include linux/clk.h
 #include linux/usb.h
 #include linux/usb/hcd.h
+#include linux/of.h
+#include linux/dma-mapping.h
 
 #include ehci.h
 
@@ -121,6 +123,8 @@ static const struct ehci_driver_overrides 
ehci_omap_overrides __initdata = {
.extra_priv_size = sizeof(struct omap_hcd),
 };
 
+static u64 omap_ehci_dma_mask = DMA_BIT_MASK(32);
+
 /**
  * ehci_hcd_omap_probe - initialize TI-based HCDs
  *
@@ -148,6 +152,17 @@ static int ehci_hcd_omap_probe(struct platform_device 
*pdev)
return -ENODEV;
}
 
+   /* For DT boot, get platform data from parent. i.e. usbhshost */
+   if (dev-of_node) {
+   pdata = dev-parent-platform_data;
+   dev-platform_data = pdata;
+   }
+
+   if (!pdata) {
+   dev_err(dev, Missing platform data\n);
+   return -ENODEV;
+   }
+
irq = platform_get_irq(pdev, 0);
if (irq  0) {
dev_err(dev, EHCI irq failed\n);
@@ -159,6 +174,14 @@ static int ehci_hcd_omap_probe(struct platform_device 
*pdev)
if (IS_ERR(regs))
return PTR_ERR(regs);
 
+   /*
+* Right now device-tree probed devices don't get dma_mask set.
+* Since shared usb code relies on it, set it here for now.
+* Once we have dma capability bindings this can go away.
+*/
+   if (!pdev-dev.dma_mask)
+   pdev-dev.dma_mask = omap_ehci_dma_mask;
+
hcd = usb_create_hcd(ehci_omap_hc_driver, dev,
dev_name(dev));
if (!hcd) {
@@ -183,7 +206,10 @@ static int ehci_hcd_omap_probe(struct platform_device 
*pdev)
continue;
 
/* get the PHY device */
-   phy = devm_usb_get_phy_dev(dev, i);
+   if (dev-of_node)
+   phy = devm_usb_get_phy_by_phandle(dev, phys, i);
+   else
+   phy = devm_usb_get_phy_dev(dev, i);
if (IS_ERR(phy) || !phy) {
ret = IS_ERR(phy) ? PTR_ERR(phy) : -ENODEV;
dev_err(dev, Can't get PHY device for port %d: %d\n,
@@ -273,6 +299,13 @@ static void ehci_hcd_omap_shutdown(struct platform_device 
*pdev)
hcd-driver-shutdown(hcd);
 }
 
+static const struct of_device_id omap_ehci_dt_ids[] = {
+   { .compatible = ti,ehci-omap },
+   { }
+};
+
+MODULE_DEVICE_TABLE(of, omap_ehci_dt_ids);
+
 static struct platform_driver ehci_hcd_omap_driver = {
.probe  = ehci_hcd_omap_probe,
.remove = ehci_hcd_omap_remove,
@@ -281,6 +314,7 @@ static struct platform_driver ehci_hcd_omap_driver = {
/*.resume   = ehci_hcd_omap_resume, */
.driver = {
.name   = hcd_name,
+   .of_match_table = of_match_ptr(omap_ehci_dt_ids),
}
 };
 
@@ -307,6 +341,7 @@ module_exit(ehci_omap_cleanup);
 MODULE_ALIAS(platform:ehci-omap);
 MODULE_AUTHOR(Texas Instruments, Inc.);
 MODULE_AUTHOR(Felipe Balbi felipe.ba...@nokia.com);
+MODULE_AUTHOR(Roger Quadros rog...@ti.com);
 
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE(GPL);
-- 
1.7.4.1

___
devicetree-discuss mailing

Re: [PATCH 12/12] USB: ehci-omap: Fix detection in HSIC mode

2013-03-12 Thread Roger Quadros
On 03/12/2013 12:51 PM, kishon wrote:
 Hi,
 
 On Tuesday 12 March 2013 04:14 PM, Roger Quadros wrote:
 The HSIC devices need to be kept in reset while the EHCI controller
 is being initialized and only brought out of reset after the
 initialization is complete, else HSIC devices will not be detected.

 Signed-off-by: Roger Quadros rog...@ti.com
 CC: Alan Stern st...@rowland.harvard.edu
 ---
   drivers/usb/host/ehci-omap.c |   28 +++-
   1 files changed, 11 insertions(+), 17 deletions(-)

 diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
 index 1ba1df8..52a2d46 100644
 --- a/drivers/usb/host/ehci-omap.c
 +++ b/drivers/usb/host/ehci-omap.c
 @@ -50,6 +50,7 @@
   #include linux/usb/hcd.h
   #include linux/of.h
   #include linux/dma-mapping.h
 +#include linux/delay.h
 
 not needed here I guess.

Right. will remove.


   #include ehci.h

 @@ -90,26 +91,13 @@ static inline u32 ehci_read(void __iomem *base, u32 reg)
   static int omap_ehci_init(struct usb_hcd *hcd)
   {
   struct ehci_hcd*ehci = hcd_to_ehci(hcd);
 -struct omap_hcd*omap = (struct omap_hcd *)ehci-priv;
 -int rc, i;
 -
 -/* Hold PHYs in reset while initializing EHCI controller */
 -for (i = 0; i  omap-nports; i++) {
 -if (omap-phy[i])
 -usb_phy_shutdown(omap-phy[i]);
 -}
 +int rc;

   /* we know this is the memory we want, no need to ioremap again */
   ehci-caps = hcd-regs;

   rc = ehci_setup(hcd);

 -/* Bring PHYs out of reset */
 -for (i = 0; i  omap-nports; i++) {
 -if (omap-phy[i])
 -usb_phy_init(omap-phy[i]);
 -}
 -
   return rc;
   }

 @@ -219,9 +207,6 @@ static int ehci_hcd_omap_probe(struct platform_device 
 *pdev)
   }

   omap-phy[i] = phy;
 -usb_phy_init(omap-phy[i]);
 -/* bring PHY out of suspend */
 -usb_phy_set_suspend(omap-phy[i], 0);
   }

   pm_runtime_enable(dev);
 @@ -245,6 +230,15 @@ static int ehci_hcd_omap_probe(struct platform_device 
 *pdev)
   goto err_pm_runtime;
   }

 +/* Bring PHYs out of reset */
 +for (i = 0; i  omap-nports; i++) {
 +if (!omap-phy[i])
 +continue;
 +
 +usb_phy_init(omap-phy[i]);
 +/* bring PHY out of suspend */
 +usb_phy_set_suspend(omap-phy[i], 0);
 +}
 
 But isn't HSIC supposed to be PHYless devices. Maybe a comment explaining it 
 might be helpful.
 

Yes HSIC is PHYless but they do have reset line between the chips.
I'll put a comment.

cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH v2 12/12] USB: ehci-omap: Fix detection in HSIC mode

2013-03-12 Thread Roger Quadros
The HSIC devices need to be kept in reset while the EHCI controller
is being initialized and only brought out of reset after the
initialization is complete, else HSIC devices will not be detected.

Also remove outdated TODO list from header.

Signed-off-by: Roger Quadros rog...@ti.com
CC: Alan Stern st...@rowland.harvard.edu
---
 drivers/usb/host/ehci-omap.c |   38 +++---
 1 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 1ba1df8..dc2de47 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -29,12 +29,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  *
- * TODO (last updated Feb 27, 2010):
- * - add kernel-doc
- * - enable AUTOIDLE
- * - add suspend/resume
- * - add HSIC and TLL support
- * - convert to use hwmod and runtime PM
  */
 
 #include linux/kernel.h
@@ -90,26 +84,13 @@ static inline u32 ehci_read(void __iomem *base, u32 reg)
 static int omap_ehci_init(struct usb_hcd *hcd)
 {
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
-   struct omap_hcd *omap = (struct omap_hcd *)ehci-priv;
-   int rc, i;
-
-   /* Hold PHYs in reset while initializing EHCI controller */
-   for (i = 0; i  omap-nports; i++) {
-   if (omap-phy[i])
-   usb_phy_shutdown(omap-phy[i]);
-   }
+   int rc;
 
/* we know this is the memory we want, no need to ioremap again */
ehci-caps = hcd-regs;
 
rc = ehci_setup(hcd);
 
-   /* Bring PHYs out of reset */
-   for (i = 0; i  omap-nports; i++) {
-   if (omap-phy[i])
-   usb_phy_init(omap-phy[i]);
-   }
-
return rc;
 }
 
@@ -219,9 +200,6 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
}
 
omap-phy[i] = phy;
-   usb_phy_init(omap-phy[i]);
-   /* bring PHY out of suspend */
-   usb_phy_set_suspend(omap-phy[i], 0);
}
 
pm_runtime_enable(dev);
@@ -245,6 +223,20 @@ static int ehci_hcd_omap_probe(struct platform_device 
*pdev)
goto err_pm_runtime;
}
 
+   /*
+* Bring PHYs out of reset.
+* Even though HSIC mode is a PHY-less mode, the reset
+* line exists between the chips and can be modelled
+* as a PHY device for reset control.
+*/
+   for (i = 0; i  omap-nports; i++) {
+   if (!omap-phy[i])
+   continue;
+
+   usb_phy_init(omap-phy[i]);
+   /* bring PHY out of suspend */
+   usb_phy_set_suspend(omap-phy[i], 0);
+   }
 
return 0;
 
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 0/8] USB: PHY: nop: Device tree support for 3.10

2013-03-12 Thread Roger Quadros
Hi Felipe,

These patches add device tree support as well as PHY resource handling
(i.e. clock, reset, power) for the NOP transceiver driver.

Please add these patches before your patches that move/rename the
drivers/usb/otg/nop-usb-xceiv.c file.

NOTE: The first patch that changes platform header must be common between
you and Tony's OMAP tree. Maybe you guys can share an immutable branch?

cheers,
-roger

The following changes since commit f6161aa153581da4a3867a2d1a7caf4be19b6ec9:

  Linux 3.9-rc2 (2013-03-10 16:54:19 -0700)

are available in the git repository at:
  git://github.com/rogerq/linux.git usbhost-phy-next

Roger Quadros (8):
  usb: phy: nop: Add some parameters to platform data
  usb: phy: nop: use devm_kzalloc()
  usb: phy: nop: Manage PHY clock
  usb: phy: nop: Handle power supply regulator for the PHY
  usb: phy: nop: Handle RESET for the PHY
  usb: phy: nop: use new PHY API to register PHY
  usb: phy: nop: Add device tree support and binding information
  USB: phy: nop: Defer probe if device needs VCC/RESET

 .../devicetree/bindings/usb/usb-nop-xceiv.txt  |   34 +
 drivers/usb/otg/nop-usb-xceiv.c|  143 +--
 include/linux/usb/nop-usb-xceiv.h  |5 +
 3 files changed, 167 insertions(+), 15 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt

-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 1/8] usb: phy: nop: Add some parameters to platform data

2013-03-12 Thread Roger Quadros
Add clk_rate parameter to platform data. If supplied, the
NOP phy driver will program the clock to that rate during probe.

Also add 2 flags, needs_vcc and needs_reset.
If the flag is set and the regulator couldn't be found
then the driver will bail out with -EPROBE_DEFER.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 include/linux/usb/nop-usb-xceiv.h |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/include/linux/usb/nop-usb-xceiv.h 
b/include/linux/usb/nop-usb-xceiv.h
index 28884c7..148d351 100644
--- a/include/linux/usb/nop-usb-xceiv.h
+++ b/include/linux/usb/nop-usb-xceiv.h
@@ -5,6 +5,11 @@
 
 struct nop_usb_xceiv_platform_data {
enum usb_phy_type type;
+   unsigned long clk_rate;
+
+   /* if set fails with -EPROBE_DEFER if can't get regulator */
+   unsigned int needs_vcc:1;
+   unsigned int needs_reset:1;
 };
 
 #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE)  
defined(MODULE))
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 2/8] usb: phy: nop: use devm_kzalloc()

2013-03-12 Thread Roger Quadros
Use resource managed kzalloc.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/usb/otg/nop-usb-xceiv.c |   17 +
 1 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
index a3ce24b..af52870 100644
--- a/drivers/usb/otg/nop-usb-xceiv.c
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -100,15 +100,14 @@ static int nop_usb_xceiv_probe(struct platform_device 
*pdev)
enum usb_phy_type   type = USB_PHY_TYPE_USB2;
int err;
 
-   nop = kzalloc(sizeof *nop, GFP_KERNEL);
+   nop = devm_kzalloc(pdev-dev, sizeof(*nop), GFP_KERNEL);
if (!nop)
return -ENOMEM;
 
-   nop-phy.otg = kzalloc(sizeof *nop-phy.otg, GFP_KERNEL);
-   if (!nop-phy.otg) {
-   kfree(nop);
+   nop-phy.otg = devm_kzalloc(pdev-dev, sizeof(*nop-phy.otg),
+   GFP_KERNEL);
+   if (!nop-phy.otg)
return -ENOMEM;
-   }
 
if (pdata)
type = pdata-type;
@@ -127,7 +126,7 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
if (err) {
dev_err(pdev-dev, can't register transceiver, err: %d\n,
err);
-   goto exit;
+   return err;
}
 
platform_set_drvdata(pdev, nop);
@@ -135,10 +134,6 @@ static int nop_usb_xceiv_probe(struct platform_device 
*pdev)
ATOMIC_INIT_NOTIFIER_HEAD(nop-phy.notifier);
 
return 0;
-exit:
-   kfree(nop-phy.otg);
-   kfree(nop);
-   return err;
 }
 
 static int nop_usb_xceiv_remove(struct platform_device *pdev)
@@ -148,8 +143,6 @@ static int nop_usb_xceiv_remove(struct platform_device 
*pdev)
usb_remove_phy(nop-phy);
 
platform_set_drvdata(pdev, NULL);
-   kfree(nop-phy.otg);
-   kfree(nop);
 
return 0;
 }
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 3/8] usb: phy: nop: Manage PHY clock

2013-03-12 Thread Roger Quadros
If the PHY has a clock associated to it then manage the clock.
We just enable the clock in .init() and disable it in .shutdown().

Add clk_rate parameter in platform data and configure the
clock rate during probe if supplied.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/usb/otg/nop-usb-xceiv.c |   54 ++-
 1 files changed, 53 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
index af52870..17c174f 100644
--- a/drivers/usb/otg/nop-usb-xceiv.c
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -32,10 +32,12 @@
 #include linux/usb/otg.h
 #include linux/usb/nop-usb-xceiv.h
 #include linux/slab.h
+#include linux/clk.h
 
 struct nop_usb_xceiv {
struct usb_phy  phy;
struct device   *dev;
+   struct clk  *clk;
 };
 
 static struct platform_device *pd;
@@ -64,6 +66,24 @@ static int nop_set_suspend(struct usb_phy *x, int suspend)
return 0;
 }
 
+static int nop_init(struct usb_phy *phy)
+{
+   struct nop_usb_xceiv *nop = dev_get_drvdata(phy-dev);
+
+   if (!IS_ERR(nop-clk))
+   clk_enable(nop-clk);
+
+   return 0;
+}
+
+static void nop_shutdown(struct usb_phy *phy)
+{
+   struct nop_usb_xceiv *nop = dev_get_drvdata(phy-dev);
+
+   if (!IS_ERR(nop-clk))
+   clk_disable(nop-clk);
+}
+
 static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
 {
if (!otg)
@@ -112,10 +132,34 @@ static int nop_usb_xceiv_probe(struct platform_device 
*pdev)
if (pdata)
type = pdata-type;
 
+   nop-clk = devm_clk_get(pdev-dev, main_clk);
+   if (IS_ERR(nop-clk)) {
+   dev_dbg(pdev-dev, Can't get phy clock: %ld\n,
+   PTR_ERR(nop-clk));
+   }
+
+   if (!IS_ERR(nop-clk)  pdata  pdata-clk_rate) {
+   err = clk_set_rate(nop-clk, pdata-clk_rate);
+   if (err) {
+   dev_err(pdev-dev, Error setting clock rate\n);
+   return err;
+   }
+   }
+
+   if (!IS_ERR(nop-clk)) {
+   err = clk_prepare(nop-clk);
+   if (err) {
+   dev_err(pdev-dev, Error preparing clock\n);
+   return err;
+   }
+   }
+
nop-dev= pdev-dev;
nop-phy.dev= nop-dev;
nop-phy.label  = nop-xceiv;
nop-phy.set_suspend= nop_set_suspend;
+   nop-phy.init   = nop_init;
+   nop-phy.shutdown   = nop_shutdown;
nop-phy.state  = OTG_STATE_UNDEFINED;
 
nop-phy.otg-phy   = nop-phy;
@@ -126,7 +170,7 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
if (err) {
dev_err(pdev-dev, can't register transceiver, err: %d\n,
err);
-   return err;
+   goto err_add;
}
 
platform_set_drvdata(pdev, nop);
@@ -134,12 +178,20 @@ static int nop_usb_xceiv_probe(struct platform_device 
*pdev)
ATOMIC_INIT_NOTIFIER_HEAD(nop-phy.notifier);
 
return 0;
+
+err_add:
+   if (!IS_ERR(nop-clk))
+   clk_unprepare(nop-clk);
+   return err;
 }
 
 static int nop_usb_xceiv_remove(struct platform_device *pdev)
 {
struct nop_usb_xceiv *nop = platform_get_drvdata(pdev);
 
+   if (!IS_ERR(nop-clk))
+   clk_unprepare(nop-clk);
+
usb_remove_phy(nop-phy);
 
platform_set_drvdata(pdev, NULL);
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 4/8] usb: phy: nop: Handle power supply regulator for the PHY

2013-03-12 Thread Roger Quadros
We use vcc as the supply name for the PHY's power supply.
The power supply will be enabled during .init() and disabled
during .shutdown()

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/usb/otg/nop-usb-xceiv.c |   18 ++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
index 17c174f..fbdcfef 100644
--- a/drivers/usb/otg/nop-usb-xceiv.c
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -33,11 +33,13 @@
 #include linux/usb/nop-usb-xceiv.h
 #include linux/slab.h
 #include linux/clk.h
+#include linux/regulator/consumer.h
 
 struct nop_usb_xceiv {
struct usb_phy  phy;
struct device   *dev;
struct clk  *clk;
+   struct regulator*vcc;
 };
 
 static struct platform_device *pd;
@@ -70,6 +72,11 @@ static int nop_init(struct usb_phy *phy)
 {
struct nop_usb_xceiv *nop = dev_get_drvdata(phy-dev);
 
+   if (!IS_ERR(nop-vcc)) {
+   if (regulator_enable(nop-vcc))
+   dev_err(phy-dev, Failed to enable power\n);
+   }
+
if (!IS_ERR(nop-clk))
clk_enable(nop-clk);
 
@@ -82,6 +89,11 @@ static void nop_shutdown(struct usb_phy *phy)
 
if (!IS_ERR(nop-clk))
clk_disable(nop-clk);
+
+   if (!IS_ERR(nop-vcc)) {
+   if (regulator_disable(nop-vcc))
+   dev_err(phy-dev, Failed to disable power\n);
+   }
 }
 
 static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
@@ -154,6 +166,12 @@ static int nop_usb_xceiv_probe(struct platform_device 
*pdev)
}
}
 
+   nop-vcc = devm_regulator_get(pdev-dev, vcc);
+   if (IS_ERR(nop-vcc)) {
+   dev_dbg(pdev-dev, Error getting vcc regulator: %ld\n,
+   PTR_ERR(nop-vcc));
+   }
+
nop-dev= pdev-dev;
nop-phy.dev= nop-dev;
nop-phy.label  = nop-xceiv;
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 7/8] usb: phy: nop: Add device tree support and binding information

2013-03-12 Thread Roger Quadros
The PHY clock, clock rate, VCC regulator and RESET regulator
can now be provided via device tree.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 .../devicetree/bindings/usb/usb-nop-xceiv.txt  |   34 +++
 drivers/usb/otg/nop-usb-xceiv.c|   35 +++
 2 files changed, 61 insertions(+), 8 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt

diff --git a/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt 
b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt
new file mode 100644
index 000..d7e2726
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt
@@ -0,0 +1,34 @@
+USB NOP PHY
+
+Required properties:
+- compatible: should be usb-nop-xceiv
+
+Optional properties:
+- clocks: phandle to the PHY clock. Use as per Documentation/devicetree
+  /bindings/clock/clock-bindings.txt
+  This property is required if clock-frequency is specified.
+
+- clock-names: Should be main_clk
+
+- clock-frequency: the clock frequency (in Hz) that the PHY clock must
+  be configured to.
+
+- vcc-supply: phandle to the regulator that provides RESET to the PHY.
+
+- reset-supply: phandle to the regulator that provides power to the PHY.
+
+Example:
+
+   hsusb1_phy {
+   compatible = usb-nop-xceiv;
+   clock-frequency = 1920;
+   clocks = osc 0;
+   clock-names = main_clk;
+   vcc-supply = hsusb1_vcc_regulator;
+   reset-supply = hsusb1_reset_regulator;
+   };
+
+hsusb1_phy is a NOP USB PHY device that gets its clock from an oscillator
+and expects that clock to be configured to 19.2MHz by the NOP PHY driver.
+hsusb1_vcc_regulator provides power to the PHY and hsusb1_reset_regulator
+controls RESET.
diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
index fe7a460..b26b1c2 100644
--- a/drivers/usb/otg/nop-usb-xceiv.c
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -34,13 +34,14 @@
 #include linux/slab.h
 #include linux/clk.h
 #include linux/regulator/consumer.h
+#include linux/of.h
 
 struct nop_usb_xceiv {
-   struct usb_phy  phy;
-   struct device   *dev;
-   struct clk  *clk;
-   struct regulator*vcc;
-   struct regulator*reset;
+   struct usb_phy phy;
+   struct device *dev;
+   struct clk *clk;
+   struct regulator *vcc;
+   struct regulator *reset;
 };
 
 static struct platform_device *pd;
@@ -140,10 +141,12 @@ static int nop_set_host(struct usb_otg *otg, struct 
usb_bus *host)
 
 static int nop_usb_xceiv_probe(struct platform_device *pdev)
 {
+   struct device *dev = pdev-dev;
struct nop_usb_xceiv_platform_data *pdata = pdev-dev.platform_data;
struct nop_usb_xceiv*nop;
enum usb_phy_type   type = USB_PHY_TYPE_USB2;
int err;
+   u32 clk_rate = 0;
 
nop = devm_kzalloc(pdev-dev, sizeof(*nop), GFP_KERNEL);
if (!nop)
@@ -154,8 +157,16 @@ static int nop_usb_xceiv_probe(struct platform_device 
*pdev)
if (!nop-phy.otg)
return -ENOMEM;
 
-   if (pdata)
+   if (dev-of_node) {
+   struct device_node *node = dev-of_node;
+
+   if (of_property_read_u32(node, clock-frequency, clk_rate))
+   clk_rate = 0;
+
+   } else if (pdata) {
type = pdata-type;
+   clk_rate = pdata-clk_rate;
+   }
 
nop-clk = devm_clk_get(pdev-dev, main_clk);
if (IS_ERR(nop-clk)) {
@@ -163,8 +174,8 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
PTR_ERR(nop-clk));
}
 
-   if (!IS_ERR(nop-clk)  pdata  pdata-clk_rate) {
-   err = clk_set_rate(nop-clk, pdata-clk_rate);
+   if (!IS_ERR(nop-clk)  clk_rate) {
+   err = clk_set_rate(nop-clk, clk_rate);
if (err) {
dev_err(pdev-dev, Error setting clock rate\n);
return err;
@@ -237,12 +248,20 @@ static int nop_usb_xceiv_remove(struct platform_device 
*pdev)
return 0;
 }
 
+static const struct of_device_id nop_xceiv_dt_ids[] = {
+   { .compatible = usb-nop-xceiv },
+   { }
+};
+
+MODULE_DEVICE_TABLE(of, nop_xceiv_dt_ids);
+
 static struct platform_driver nop_usb_xceiv_driver = {
.probe  = nop_usb_xceiv_probe,
.remove = nop_usb_xceiv_remove,
.driver = {
.name   = nop_usb_xceiv,
.owner  = THIS_MODULE,
+   .of_match_table = of_match_ptr(nop_xceiv_dt_ids),
},
 };
 
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 8/8] USB: phy: nop: Defer probe if device needs VCC/RESET

2013-03-12 Thread Roger Quadros
Add 2 flags, needs_vcc and needs_reset to platform data.
If the flag is set and the regulator couldn't be found
then we bail out with -EPROBE_DEFER.

For device tree boot we depend on presensce of vcc-supply/
reset-supply properties to decide if we should bail out
with -EPROBE_DEFER or just continue in case the regulator
can't be found.

This is required for proper functionality in cases where the
regulator is needed but is probed later than the PHY device.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/usb/otg/nop-usb-xceiv.c |   11 +++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
index b26b1c2..2b10cc9 100644
--- a/drivers/usb/otg/nop-usb-xceiv.c
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -147,6 +147,8 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
enum usb_phy_type   type = USB_PHY_TYPE_USB2;
int err;
u32 clk_rate = 0;
+   bool needs_vcc = false;
+   bool needs_reset = false;
 
nop = devm_kzalloc(pdev-dev, sizeof(*nop), GFP_KERNEL);
if (!nop)
@@ -163,9 +165,14 @@ static int nop_usb_xceiv_probe(struct platform_device 
*pdev)
if (of_property_read_u32(node, clock-frequency, clk_rate))
clk_rate = 0;
 
+   needs_vcc = of_property_read_bool(node, vcc-supply);
+   needs_reset = of_property_read_bool(node, reset-supply);
+
} else if (pdata) {
type = pdata-type;
clk_rate = pdata-clk_rate;
+   needs_vcc = pdata-needs_vcc;
+   needs_reset = pdata-needs_reset;
}
 
nop-clk = devm_clk_get(pdev-dev, main_clk);
@@ -194,12 +201,16 @@ static int nop_usb_xceiv_probe(struct platform_device 
*pdev)
if (IS_ERR(nop-vcc)) {
dev_dbg(pdev-dev, Error getting vcc regulator: %ld\n,
PTR_ERR(nop-vcc));
+   if (needs_vcc)
+   return -EPROBE_DEFER;
}
 
nop-reset = devm_regulator_get(pdev-dev, reset);
if (IS_ERR(nop-reset)) {
dev_dbg(pdev-dev, Error getting reset regulator: %ld\n,
PTR_ERR(nop-reset));
+   if (needs_reset)
+   return -EPROBE_DEFER;
}
 
nop-dev= pdev-dev;
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 00/24] ARM: OMAP2+: Adapt to ehci-omap changes for 3.10

2013-03-12 Thread Roger Quadros
Hi Tony,

These patches provide the SoC side code required to support
the changes in the OMAP USB Host drivers done in [1], [2]  [3].

Device tree support is added for Beagleboard and Panda.

NOTE: The first patch needs to be shared between the
OMAP tree and Felipe's USB tree.

[1] MFD side changes to omap-usb-host and omap-usb-tll
  https://lkml.org/lkml/2013/3/12/179
[2] USB EHCI side changes to ehci-omap 
  http://www.mail-archive.com/linux-omap@vger.kernel.org/msg86265.html
[3] USB PHY driver changes
  http://www.mail-archive.com/linux-omap@vger.kernel.org/msg86293.html

The following changes since commit f6161aa153581da4a3867a2d1a7caf4be19b6ec9:

  Linux 3.9-rc2 (2013-03-10 16:54:19 -0700)

are available in the git repository at:
  git://github.com/rogerq/linux.git usbhost-arm-next

Roger Quadros (24):
  usb: phy: nop: Add some parameters to platform data
  ARM: OMAP2+: omap4panda: Provide USB Host's PHY platform data
  ARM: OMAP2+: omap4panda: Adapt to ehci-omap changes
  ARM: OMAP3: Beagle: Adapt to ehci-omap changes
  ARM: OMAP3: 3430SDP: Adapt to ehci-omap changes
  ARM: OMAP3: 3630SDP: Adapt to ehci-omap changes
  ARM: OMAP: AM3517crane: Adapt to ehci-omap changes
  ARM: OMAP: AM3517evm: Adapt to ehci-omap changes
  ARM: OMAP3: cm-t35: Adapt to ehci-omap changes
  ARM: OMAP3: cm-t3517: Adapt to ehci-omap changes
  ARM: OMAP: devkit8000: Adapt to ehci-omap changes
  ARM: OMAP3: igep0020: Adapt to ehci-omap changes
  ARM: OMAP3: omap3evm: Adapt to ehci-omap changes
  ARM: OMAP3: omap3pandora: Adapt to ehci-omap changes
  ARM: OMAP3: omap3stalker: Adapt to ehci-omap changes
  ARM: OMAP3: omap3touchbook: Adapt to ehci-omap changes
  ARM: OMAP3: overo: Adapt to ehci-omap changes
  ARM: OMAP: zoom: Adapt to ehci-omap changes
  ARM: dts: OMAP4: Add HS USB Host IP nodes
  ARM: dts: omap4-panda: Add USB Host support
  ARM: dts: OMAP3: Add HS USB Host IP nodes
  ARM: dts: omap3-beagle: Add USB Host support
  ARM: OMAP2+: Allow clock alias provision from device tree
  ARM: dts: omap4-panda: Add clock alias for USB PHY

 .../devicetree/bindings/clock/ti-clock-alias.txt   |   26 
 arch/arm/boot/dts/omap3-beagle.dts |   71 +++
 arch/arm/boot/dts/omap3.dtsi   |   31 +
 arch/arm/boot/dts/omap4-panda.dts  |   63 ++
 arch/arm/boot/dts/omap4.dtsi   |   30 +
 arch/arm/mach-omap2/board-3430sdp.c|   97 +++-
 arch/arm/mach-omap2/board-3630sdp.c|  100 +++-
 arch/arm/mach-omap2/board-am3517crane.c|   95 +--
 arch/arm/mach-omap2/board-am3517evm.c  |   66 ++-
 arch/arm/mach-omap2/board-cm-t35.c |   95 ++-
 arch/arm/mach-omap2/board-cm-t3517.c   |   97 +++-
 arch/arm/mach-omap2/board-devkit8000.c |   20 ++--
 arch/arm/mach-omap2/board-generic.c|   67 +++
 arch/arm/mach-omap2/board-igep0020.c   |  112 ---
 arch/arm/mach-omap2/board-omap3beagle.c|   93 +--
 arch/arm/mach-omap2/board-omap3evm.c   |   62 --
 arch/arm/mach-omap2/board-omap3pandora.c   |   52 +++--
 arch/arm/mach-omap2/board-omap3stalker.c   |   52 +++-
 arch/arm/mach-omap2/board-omap3touchbook.c |   62 +-
 arch/arm/mach-omap2/board-omap4panda.c |  122 ++--
 arch/arm/mach-omap2/board-overo.c  |   54 -
 arch/arm/mach-omap2/board-zoom.c   |   56 -
 include/linux/usb/nop-usb-xceiv.h  |5 +
 23 files changed, 1377 insertions(+), 151 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/ti-clock-alias.txt

--
cheers,
-roger 

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 01/24] usb: phy: nop: Add some parameters to platform data

2013-03-12 Thread Roger Quadros
Add clk_rate parameter to platform data. If supplied, the
NOP phy driver will program the clock to that rate during probe.

Also add 2 flags, needs_vcc and needs_reset.
If the flag is set and the regulator couldn't be found
then the driver will bail out with -EPROBE_DEFER.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 include/linux/usb/nop-usb-xceiv.h |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/include/linux/usb/nop-usb-xceiv.h 
b/include/linux/usb/nop-usb-xceiv.h
index 28884c7..148d351 100644
--- a/include/linux/usb/nop-usb-xceiv.h
+++ b/include/linux/usb/nop-usb-xceiv.h
@@ -5,6 +5,11 @@
 
 struct nop_usb_xceiv_platform_data {
enum usb_phy_type type;
+   unsigned long clk_rate;
+
+   /* if set fails with -EPROBE_DEFER if can't get regulator */
+   unsigned int needs_vcc:1;
+   unsigned int needs_reset:1;
 };
 
 #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE)  
defined(MODULE))
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 02/24] ARM: OMAP2+: omap4panda: Provide USB Host's PHY platform data

2013-03-12 Thread Roger Quadros
Add platform device and data for 'nop-usb-xceiv'. This will be used
as PHY for HS USB port 1, so provide binding information for it.

Get rid of managing the PHY clock as it will be done by the PHY driver.
For that to work we create a clock alias that links the PHY clock name
to the PHY device name.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 arch/arm/mach-omap2/board-omap4panda.c |   34 ++-
 1 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap4panda.c 
b/arch/arm/mach-omap2/board-omap4panda.c
index b02c2f0..feffde6 100644
--- a/arch/arm/mach-omap2/board-omap4panda.c
+++ b/arch/arm/mach-omap2/board-omap4panda.c
@@ -31,6 +31,7 @@
 #include linux/ti_wilink_st.h
 #include linux/usb/musb.h
 #include linux/usb/phy.h
+#include linux/usb/nop-usb-xceiv.h
 #include linux/wl12xx.h
 #include linux/irqchip/arm-gic.h
 #include linux/platform_data/omap-abe-twl6040.h
@@ -132,12 +133,27 @@ static struct platform_device btwilink_device = {
.id = -1,
 };
 
+/* PHY device on HS USB Port 1 i.e. nop_usb_xceiv.1 */
+static struct nop_usb_xceiv_platform_data hsusb1_phy_data = {
+   /* FREF_CLK3 provides the 19.2 MHz reference clock to the PHY */
+   .clk_rate = 1920,
+};
+
+static struct platform_device hsusb1_phy_device = {
+   .name   = nop_usb_xceiv,
+   .id = 1,
+   .dev= {
+   .platform_data = hsusb1_phy_data,
+   },
+};
+
 static struct platform_device *panda_devices[] __initdata = {
leds_gpio,
wl1271_device,
panda_abe_audio,
panda_hdmi_audio_codec,
btwilink_device,
+   hsusb1_phy_device,
 };
 
 static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
@@ -158,16 +174,6 @@ static struct gpio panda_ehci_gpios[] __initdata = {
 static void __init omap4_ehci_init(void)
 {
int ret;
-   struct clk *phy_ref_clk;
-
-   /* FREF_CLK3 provides the 19.2 MHz reference clock to the PHY */
-   phy_ref_clk = clk_get(NULL, auxclk3_ck);
-   if (IS_ERR(phy_ref_clk)) {
-   pr_err(Cannot request auxclk3\n);
-   return;
-   }
-   clk_set_rate(phy_ref_clk, 1920);
-   clk_prepare_enable(phy_ref_clk);
 
/* disable the power to the usb hub prior to init and reset phy+hub */
ret = gpio_request_array(panda_ehci_gpios,
@@ -181,6 +187,14 @@ static void __init omap4_ehci_init(void)
gpio_export(GPIO_HUB_NRESET, 0);
gpio_set_value(GPIO_HUB_NRESET, 1);
 
+   /* FREF_CLK3 provides the 19.2 MHz reference clock to the PHY */
+   ret = clk_add_alias(main_clk, nop_usb_xceiv.1, auxclk3_ck, NULL);
+   if (ret)
+   pr_err(Failed to add main_clk alias to auxclk3_ck\n);
+
+   /* PHY on HS USB Port 1 i.e. index 0 */
+   usb_bind_phy(ehci-omap.0, 0, nop_usb_xceiv.1);
+
usbhs_init(usbhs_bdata);
 
/* enable power to hub */
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 03/24] ARM: OMAP2+: omap4panda: Adapt to ehci-omap changes

2013-03-12 Thread Roger Quadros
Model RESET and Power for HS USB Port 1 as GPIO fixed regulators
and link them to the 'nop-usb-xceiv' PHY by making them as reset
and vcc supplies.

The RESET and Power will then be managed by the PHY driver.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 arch/arm/mach-omap2/board-omap4panda.c |   92 +++-
 1 files changed, 66 insertions(+), 26 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap4panda.c 
b/arch/arm/mach-omap2/board-omap4panda.c
index feffde6..3f34db3 100644
--- a/arch/arm/mach-omap2/board-omap4panda.c
+++ b/arch/arm/mach-omap2/board-omap4panda.c
@@ -147,6 +147,70 @@ static struct platform_device hsusb1_phy_device = {
},
 };
 
+/* Regulator for USB HUB/PHY reset */
+static struct regulator_consumer_supply hsusb1_reset_supplies[] = {
+/* Link PHY device to reset supply so it gets used in the PHY driver */
+   REGULATOR_SUPPLY(reset, nop_usb_xceiv.1),
+};
+
+static struct regulator_init_data hsusb1_reset_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies  = hsusb1_reset_supplies,
+   .num_consumer_supplies  = ARRAY_SIZE(hsusb1_reset_supplies),
+};
+
+static struct fixed_voltage_config hsusb1_reset_config = {
+   .supply_name= hsusb1_reset,
+   .microvolts = 330,
+   .gpio = GPIO_HUB_NRESET,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,   /* keep in RESET */
+   .init_data = hsusb1_reset_data,
+};
+
+static struct platform_device hsusb1_reset_device = {
+   .name   = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb1_reset_config,
+   },
+};
+
+/* Regulator for USB HUB supply */
+static struct regulator_consumer_supply hsusb1_power_supplies[] = {
+/* Link PHY device to USB HUB supply so it gets enabled in the PHY driver */
+   REGULATOR_SUPPLY(vcc, nop_usb_xceiv.1),
+};
+
+static struct regulator_init_data hsusb1_power_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies  = hsusb1_power_supplies,
+   .num_consumer_supplies  = ARRAY_SIZE(hsusb1_power_supplies),
+};
+
+static struct fixed_voltage_config hsusb1_power_config = {
+   .supply_name= hsusb1_vbus,
+   .microvolts = 330,
+   .gpio = GPIO_HUB_POWER,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,
+   .init_data = hsusb1_power_data,
+};
+
+static struct platform_device hsusb1_power_device = {
+   .name   = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb1_power_config,
+   },
+};
+
 static struct platform_device *panda_devices[] __initdata = {
leds_gpio,
wl1271_device,
@@ -154,39 +218,18 @@ static struct platform_device *panda_devices[] __initdata 
= {
panda_hdmi_audio_codec,
btwilink_device,
hsusb1_phy_device,
+   hsusb1_power_device,
+   hsusb1_reset_device,
 };
 
 static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
-   .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
-   .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
-   .phy_reset  = false,
-   .reset_gpio_port[0]  = -EINVAL,
-   .reset_gpio_port[1]  = -EINVAL,
-   .reset_gpio_port[2]  = -EINVAL
-};
-
-static struct gpio panda_ehci_gpios[] __initdata = {
-   { GPIO_HUB_POWER,   GPIOF_OUT_INIT_LOW,  hub_power  },
-   { GPIO_HUB_NRESET,  GPIOF_OUT_INIT_LOW,  hub_nreset },
 };
 
 static void __init omap4_ehci_init(void)
 {
int ret;
 
-   /* disable the power to the usb hub prior to init and reset phy+hub */
-   ret = gpio_request_array(panda_ehci_gpios,
-ARRAY_SIZE(panda_ehci_gpios));
-   if (ret) {
-   pr_err(Unable to initialize EHCI power/reset\n);
-   return;
-   }
-
-   gpio_export(GPIO_HUB_POWER, 0);
-   gpio_export(GPIO_HUB_NRESET, 0);
-   gpio_set_value(GPIO_HUB_NRESET, 1);
-
/* FREF_CLK3 provides the 19.2 MHz reference clock to the PHY */
ret = clk_add_alias(main_clk, nop_usb_xceiv.1, auxclk3_ck, NULL);
if (ret)
@@ -196,9 +239,6 @@ static void __init omap4_ehci_init(void)
usb_bind_phy(ehci-omap.0, 0, nop_usb_xceiv.1);
 
usbhs_init(usbhs_bdata);
-
-   /* enable power to hub */
-   gpio_set_value(GPIO_HUB_POWER, 1);
 }
 
 static struct omap_musb_board_data musb_board_data = {
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 04/24] ARM: OMAP3: Beagle: Adapt to ehci-omap changes

2013-03-12 Thread Roger Quadros
Add platform device for 'nop-usb-xceiv'. This will be used as a
PHY for HS USB Port 2, so provide binding information for it.

Model RESET and Power for HS USB Port 2 as GPIO fixed regulators
and link them to the 'nop-usb-xceiv' PHY.

NOTE: Register the PHY device only after the power regulator has
been registered else power won't be enabled for the Host port.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 arch/arm/mach-omap2/board-omap3beagle.c |   93 +++---
 1 files changed, 83 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3beagle.c 
b/arch/arm/mach-omap2/board-omap3beagle.c
index c3558f9..a3d5e13 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -35,7 +35,9 @@
 #include linux/usb/phy.h
 
 #include linux/regulator/machine.h
+#include linux/regulator/fixed.h
 #include linux/i2c/twl.h
+#include linux/usb/phy.h
 
 #include asm/mach-types.h
 #include asm/mach/arch.h
@@ -277,6 +279,76 @@ static struct regulator_consumer_supply 
beagle_vsim_supply[] = {
 
 static struct gpio_led gpio_leds[];
 
+/* PHY device on HS USB Port 2 i.e. nop_usb_xceiv.2 */
+static struct platform_device hsusb2_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 2,
+};
+
+/* Regulator for HS USB Port 2 PHY reset */
+static struct regulator_consumer_supply hsusb2_reset_supplies[] = {
+   /* Link PHY device to reset supply so it gets used in the PHY driver */
+   REGULATOR_SUPPLY(reset, nop_usb_xceiv.2),
+};
+
+static struct regulator_init_data hsusb2_reset_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies = hsusb2_reset_supplies,
+   .num_consumer_supplies = ARRAY_SIZE(hsusb2_reset_supplies),
+};
+
+static struct fixed_voltage_config hsusb2_reset_config = {
+   .supply_name = hsusb2_reset,
+   .microvolts = 330,
+   .gpio = 147,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,   /* keep in RESET */
+   .init_data = hsusb2_reset_data,
+};
+
+static struct platform_device hsusb2_reset_device = {
+   .name = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb2_reset_config,
+   },
+};
+
+/* Regulator for HS USB Port 2 supply */
+static struct regulator_consumer_supply hsusb2_power_supplies[] = {
+/* Link PHY device to power supply so it gets enabled in the PHY driver */
+   REGULATOR_SUPPLY(vcc, nop_usb_xceiv.2),
+};
+
+static struct regulator_init_data hsusb2_power_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies = hsusb2_power_supplies,
+   .num_consumer_supplies = ARRAY_SIZE(hsusb2_power_supplies),
+};
+
+static struct fixed_voltage_config hsusb2_power_config = {
+   .supply_name = hsusb2_vbus,
+   .microvolts = 500,
+   .gpio = -1, /* set at runtime in beagle_twl_gpio_setup */
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 0,   /* updated in omap3_beagle_init_rev() */
+   .enabled_at_boot = 0,
+   .init_data = hsusb2_power_data,
+};
+
+static struct platform_device hsusb2_power_device = {
+   .name = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb2_power_config,
+   },
+};
+
 static int beagle_twl_gpio_setup(struct device *dev,
unsigned gpio, unsigned ngpio)
 {
@@ -318,8 +390,12 @@ static int beagle_twl_gpio_setup(struct device *dev,
}
dvi_panel.power_down_gpio = beagle_config.dvi_pd_gpio;
 
-   gpio_request_one(gpio + TWL4030_GPIO_MAX, beagle_config.usb_pwr_level,
-   nEN_USB_PWR);
+   /* TWL4030_GPIO_MAX controls HS USB Port 2 power */
+   hsusb2_power_config.gpio = gpio + TWL4030_GPIO_MAX;
+   hsusb2_power_config.enable_high = beagle_config.usb_pwr_level;
+
+   platform_device_register(hsusb2_power_device);
+   platform_device_register(hsusb2_phy_device);
 
return 0;
 }
@@ -450,18 +526,11 @@ static struct platform_device *omap3_beagle_devices[] 
__initdata = {
keys_gpio,
madc_hwmon,
leds_pwm,
+   hsusb2_reset_device,
 };
 
 static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
-
-   .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
-   .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
-
-   .phy_reset  = true,
-   .reset_gpio_port[0]  = -EINVAL,
-   .reset_gpio_port[1]  = 147,
-   .reset_gpio_port[2]  = -EINVAL
 };
 
 #ifdef CONFIG_OMAP_MUX
@@ -543,7 +612,11 @@ static void __init omap3_beagle_init(void)
 
usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb);
usb_musb_init(NULL);
+
+   /* PHY on HSUSB Port 2 i.e. index 1 */
+   usb_bind_phy

[PATCH 06/24] ARM: OMAP3: 3630SDP: Adapt to ehci-omap changes

2013-03-12 Thread Roger Quadros
Add 2 platform devices for 'nop-usb-xceiv'. These will be used
as PHYs for HS USB ports 1 and 2 so provide binding information
for them.

Model RESET for HS USB Ports 1 and 2 as GPIO fixed regulators and
link them to the 2 PHYs we just created.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 arch/arm/mach-omap2/board-3630sdp.c |  100 --
 1 files changed, 94 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/board-3630sdp.c 
b/arch/arm/mach-omap2/board-3630sdp.c
index 67447bd..d528101 100644
--- a/arch/arm/mach-omap2/board-3630sdp.c
+++ b/arch/arm/mach-omap2/board-3630sdp.c
@@ -12,6 +12,9 @@
 #include linux/input.h
 #include linux/gpio.h
 #include linux/mtd/nand.h
+#include linux/regulator/machine.h
+#include linux/regulator/fixed.h
+#include linux/usb/phy.h
 
 #include asm/mach-types.h
 #include asm/mach/arch.h
@@ -53,16 +56,86 @@ static void enable_board_wakeup_source(void)
OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
 }
 
+/* PHY device on HS USB Port 1 i.e. nop_usb_xceiv.1 */
+static struct platform_device hsusb1_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 1,
+};
+
+/* Regulator for HS USB Port 1 PHY reset */
+static struct regulator_consumer_supply hsusb1_reset_supplies[] = {
+   /* Link PHY device to reset supply so it gets used in the PHY driver */
+   REGULATOR_SUPPLY(reset, nop_usb_xceiv.1),
+};
+
+static struct regulator_init_data hsusb1_reset_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies = hsusb1_reset_supplies,
+   .num_consumer_supplies = ARRAY_SIZE(hsusb1_reset_supplies),
+};
+
+static struct fixed_voltage_config hsusb1_reset_config = {
+   .supply_name = hsusb1_reset,
+   .microvolts = 330,
+   .gpio = 126,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,   /* keep in RESET */
+   .init_data = hsusb1_reset_data,
+};
+
+static struct platform_device hsusb1_reset_device = {
+   .name = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb1_reset_config,
+   },
+};
+
+/* PHY device on HS USB Port 2 i.e. nop_usb_xceiv.2 */
+static struct platform_device hsusb2_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 2,
+};
+
+/* Regulator for HS USB Port 2 PHY reset */
+static struct regulator_consumer_supply hsusb2_reset_supplies[] = {
+   /* Link PHY device to reset supply so it gets used in the PHY driver */
+   REGULATOR_SUPPLY(reset, nop_usb_xceiv.2),
+};
+
+static struct regulator_init_data hsusb2_reset_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies = hsusb2_reset_supplies,
+   .num_consumer_supplies = ARRAY_SIZE(hsusb2_reset_supplies),
+};
+
+static struct fixed_voltage_config hsusb2_reset_config = {
+   .supply_name = hsusb2_reset,
+   .microvolts = 330,
+   .gpio = 61,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,   /* keep in RESET */
+   .init_data = hsusb2_reset_data,
+};
+
+static struct platform_device hsusb2_reset_device = {
+   .name = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb2_reset_config,
+   },
+};
+
 static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 
.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
-   .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
-
-   .phy_reset  = true,
-   .reset_gpio_port[0]  = 126,
-   .reset_gpio_port[1]  = 61,
-   .reset_gpio_port[2]  = -EINVAL
 };
 
 #ifdef CONFIG_OMAP_MUX
@@ -189,6 +262,13 @@ static struct flash_partitions sdp_flash_partitions[] = {
},
 };
 
+static struct platform_device *sdp3630_devices[] __initdata = {
+   hsusb1_phy_device,
+   hsusb1_reset_device,
+   hsusb2_phy_device,
+   hsusb2_reset_device,
+};
+
 static void __init omap_sdp_init(void)
 {
omap3_mux_init(board_mux, OMAP_PACKAGE_CBP);
@@ -199,6 +279,14 @@ static void __init omap_sdp_init(void)
board_smc91x_init();
board_flash_init(sdp_flash_partitions, chip_sel_sdp, NAND_BUSWIDTH_16);
enable_board_wakeup_source();
+
+   platform_add_devices(sdp3630_devices, ARRAY_SIZE(sdp3630_devices));
+
+   /* PHY on HSUSB Port 1 i.e. index 0 */
+   usb_bind_phy(ehci-omap.0, 0, nop_usb_xceiv.1);
+   /* PHY on HSUSB Port 2 i.e. index 1 */
+   usb_bind_phy(ehci-omap.0, 1, nop_usb_xceiv.2);
+
usbhs_init(usbhs_bdata);
 }
 
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 05/24] ARM: OMAP3: 3430SDP: Adapt to ehci-omap changes

2013-03-12 Thread Roger Quadros
Add 2 platform devices for 'nop-usb-xceiv'. These will be used
as PHYs for HS USB ports 1 and 2 so provide binding information
for them.

Model RESET for HS USB Ports 1 and 2 as GPIO fixed regulators and
link them to the 2 PHYs we just created.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 arch/arm/mach-omap2/board-3430sdp.c |   97 --
 1 files changed, 91 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/board-3430sdp.c 
b/arch/arm/mach-omap2/board-3430sdp.c
index ce812de..7e3c88a 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -21,6 +21,8 @@
 #include linux/spi/spi.h
 #include linux/i2c/twl.h
 #include linux/regulator/machine.h
+#include linux/regulator/fixed.h
+#include linux/usb/phy.h
 #include linux/io.h
 #include linux/gpio.h
 #include linux/mmc/host.h
@@ -445,16 +447,86 @@ static void enable_board_wakeup_source(void)
OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
 }
 
+/* PHY device on HS USB Port 1 i.e. nop_usb_xceiv.1 */
+static struct platform_device hsusb1_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 1,
+};
+
+/* Regulator for HS USB Port 1 PHY reset */
+static struct regulator_consumer_supply hsusb1_reset_supplies[] = {
+   /* Link PHY device to reset supply so it gets used in the PHY driver */
+   REGULATOR_SUPPLY(reset, nop_usb_xceiv.1),
+};
+
+static struct regulator_init_data hsusb1_reset_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies = hsusb1_reset_supplies,
+   .num_consumer_supplies = ARRAY_SIZE(hsusb1_reset_supplies),
+};
+
+static struct fixed_voltage_config hsusb1_reset_config = {
+   .supply_name = hsusb1_reset,
+   .microvolts = 330,
+   .gpio = 57,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,   /* keep in RESET */
+   .init_data = hsusb1_reset_data,
+};
+
+static struct platform_device hsusb1_reset_device = {
+   .name = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb1_reset_config,
+   },
+};
+
+/* PHY device on HS USB Port 2 i.e. nop_usb_xceiv.2 */
+static struct platform_device hsusb2_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 2,
+};
+
+/* Regulator for HS USB Port 2 PHY reset */
+static struct regulator_consumer_supply hsusb2_reset_supplies[] = {
+   /* Link PHY device to reset supply so it gets used in the PHY driver */
+   REGULATOR_SUPPLY(reset, nop_usb_xceiv.2),
+};
+
+static struct regulator_init_data hsusb2_reset_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies = hsusb2_reset_supplies,
+   .num_consumer_supplies = ARRAY_SIZE(hsusb2_reset_supplies),
+};
+
+static struct fixed_voltage_config hsusb2_reset_config = {
+   .supply_name = hsusb2_reset,
+   .microvolts = 330,
+   .gpio = 61,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,   /* keep in RESET */
+   .init_data = hsusb2_reset_data,
+};
+
+static struct platform_device hsusb2_reset_device = {
+   .name = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb2_reset_config,
+   },
+};
+
 static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 
.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
-   .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
-
-   .phy_reset  = true,
-   .reset_gpio_port[0]  = 57,
-   .reset_gpio_port[1]  = 61,
-   .reset_gpio_port[2]  = -EINVAL
 };
 
 #ifdef CONFIG_OMAP_MUX
@@ -585,6 +657,13 @@ static struct flash_partitions sdp_flash_partitions[] = {
},
 };
 
+static struct platform_device *sdp3430_devices[] __initdata = {
+   hsusb1_phy_device,
+   hsusb1_reset_device,
+   hsusb2_phy_device,
+   hsusb2_reset_device,
+};
+
 static void __init omap_3430sdp_init(void)
 {
int gpio_pendown;
@@ -606,6 +685,12 @@ static void __init omap_3430sdp_init(void)
board_flash_init(sdp_flash_partitions, chip_sel_3430, 0);
sdp3430_display_init();
enable_board_wakeup_source();
+
+   platform_add_devices(sdp3430_devices, ARRAY_SIZE(sdp3430_devices));
+   /* PHY on HSUSB Port 1 i.e. index 0 */
+   usb_bind_phy(ehci-omap.0, 0, nop_usb_xceiv.1);
+   /* PHY on HSUSB Port 2 i.e. index 1 */
+   usb_bind_phy(ehci-omap.0, 1, nop_usb_xceiv.2);
usbhs_init(usbhs_bdata);
 }
 
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 07/24] ARM: OMAP: AM3517crane: Adapt to ehci-omap changes

2013-03-12 Thread Roger Quadros
Add platform device for 'nop-usb-xceiv'. This will be used as a
PHY for HS USB Port 1, so provide binding information for it.

Model RESET and Power for HS USB Port 1 as GPIO fixed regulators
and link them to the 'nop-usb-xceiv' PHY.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 arch/arm/mach-omap2/board-am3517crane.c |   95 +++
 1 files changed, 83 insertions(+), 12 deletions(-)

diff --git a/arch/arm/mach-omap2/board-am3517crane.c 
b/arch/arm/mach-omap2/board-am3517crane.c
index 7d3358b..6dd6c1d 100644
--- a/arch/arm/mach-omap2/board-am3517crane.c
+++ b/arch/arm/mach-omap2/board-am3517crane.c
@@ -24,6 +24,9 @@
 #include linux/mtd/mtd.h
 #include linux/mtd/nand.h
 #include linux/mtd/partitions.h
+#include linux/regulator/machine.h
+#include linux/regulator/fixed.h
+#include linux/usb/phy.h
 
 #include asm/mach-types.h
 #include asm/mach/arch.h
@@ -47,15 +50,84 @@ static struct omap_board_mux board_mux[] __initdata = {
 };
 #endif
 
+/* PHY device on HS USB Port 1 i.e. nop_usb_xceiv.1 */
+static struct platform_device hsusb1_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 1,
+};
+
+/* Regulator for HS USB Port 1 PHY reset */
+static struct regulator_consumer_supply hsusb1_reset_supplies[] = {
+   /* Link PHY device to reset supply so it gets used in the PHY driver */
+   REGULATOR_SUPPLY(reset, nop_usb_xceiv.1),
+};
+
+static struct regulator_init_data hsusb1_reset_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies = hsusb1_reset_supplies,
+   .num_consumer_supplies = ARRAY_SIZE(hsusb1_reset_supplies),
+};
+
+static struct fixed_voltage_config hsusb1_reset_config = {
+   .supply_name = hsusb1_reset,
+   .microvolts = 330,
+   .gpio = GPIO_USB_NRESET,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,   /* keep in RESET */
+   .init_data = hsusb1_reset_data,
+};
+
+static struct platform_device hsusb1_reset_device = {
+   .name = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb1_reset_config,
+   },
+};
+
+/* Regulator for HS USB Port 1 supply */
+static struct regulator_consumer_supply hsusb1_power_supplies[] = {
+/* Link PHY device to power supply so it gets enabled in the PHY driver */
+   REGULATOR_SUPPLY(vcc, nop_usb_xceiv.1),
+};
+
+static struct regulator_init_data hsusb1_power_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies = hsusb1_power_supplies,
+   .num_consumer_supplies  = ARRAY_SIZE(hsusb1_power_supplies),
+};
+
+static struct fixed_voltage_config hsusb1_power_config = {
+   .supply_name = hsusb1_vbus,
+   .microvolts = 500,
+   .gpio = GPIO_USB_POWER,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,
+   .init_data = hsusb1_power_data,
+};
+
+static struct platform_device hsusb1_power_device = {
+   .name = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb1_power_config,
+   },
+};
+
 static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
-   .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
-   .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
+};
 
-   .phy_reset  = true,
-   .reset_gpio_port[0]  = GPIO_USB_NRESET,
-   .reset_gpio_port[1]  = -EINVAL,
-   .reset_gpio_port[2]  = -EINVAL
+static struct platform_device *am3517_crane_devices[] __initdata = {
+   hsusb1_phy_device,
+   hsusb1_reset_device,
+   hsusb1_power_device,
 };
 
 static struct mtd_partition crane_nand_partitions[] = {
@@ -131,12 +203,11 @@ static void __init am3517_crane_init(void)
return;
}
 
-   ret = gpio_request_one(GPIO_USB_POWER, GPIOF_OUT_INIT_HIGH,
-  usb_ehci_enable);
-   if (ret  0) {
-   pr_err(Can not request GPIO %d\n, GPIO_USB_POWER);
-   return;
-   }
+   platform_add_devices(am3517_crane_devices,
+   ARRAY_SIZE(am3517_crane_devices));
+
+   /* PHY on HSUSB Port 1 i.e. index 0 */
+   usb_bind_phy(ehci-omap.0, 0, nop_usb_xceiv.1);
 
usbhs_init(usbhs_bdata);
am35xx_emac_init(AM35XX_DEFAULT_MDIO_FREQUENCY, 1);
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 08/24] ARM: OMAP: AM3517evm: Adapt to ehci-omap changes

2013-03-12 Thread Roger Quadros
Add 2 platform devices for 'nop-usb-xceiv'. These will be used as a
PHY for HS USB Port 1 and 2, so provide binding information for them.

Model RESET for HS USB Port 1 as GPIO fixed regulator and link it
to the 'nop-usb-xceiv' PHY on port 1.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 arch/arm/mach-omap2/board-am3517evm.c |   66 ++---
 1 files changed, 60 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/board-am3517evm.c 
b/arch/arm/mach-omap2/board-am3517evm.c
index 9fb8590..36c00fb 100644
--- a/arch/arm/mach-omap2/board-am3517evm.c
+++ b/arch/arm/mach-omap2/board-am3517evm.c
@@ -25,6 +25,9 @@
 #include linux/can/platform/ti_hecc.h
 #include linux/davinci_emac.h
 #include linux/mmc/host.h
+#include linux/regulator/machine.h
+#include linux/regulator/fixed.h
+#include linux/usb/phy.h
 #include linux/usb/musb.h
 #include linux/platform_data/gpio-omap.h
 
@@ -274,6 +277,50 @@ static __init void am3517_evm_mcbsp1_init(void)
omap_ctrl_writel(devconf0, OMAP2_CONTROL_DEVCONF0);
 }
 
+/* PHY device on HS USB Port 1 i.e. nop_usb_xceiv.1 */
+static struct platform_device hsusb1_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 1,
+};
+
+/* Regulator for HS USB Port 1 PHY reset */
+static struct regulator_consumer_supply hsusb1_reset_supplies[] = {
+   /* Link PHY device to reset supply so it gets used in the PHY driver */
+   REGULATOR_SUPPLY(reset, nop_usb_xceiv.1),
+};
+
+static struct regulator_init_data hsusb1_reset_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies = hsusb1_reset_supplies,
+   .num_consumer_supplies = ARRAY_SIZE(hsusb1_reset_supplies),
+};
+
+static struct fixed_voltage_config hsusb1_reset_config = {
+   .supply_name = hsusb1_reset,
+   .microvolts = 330,
+   .gpio = 57,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,   /* keep in RESET */
+   .init_data = hsusb1_reset_data,
+};
+
+static struct platform_device hsusb1_reset_device = {
+   .name = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb1_reset_config,
+   },
+};
+
+/* PHY device on HS USB Port 2 i.e. nop_usb_xceiv.2 */
+static struct platform_device hsusb2_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 2,
+};
+
 static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
 #if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \
@@ -282,12 +329,6 @@ static struct usbhs_omap_platform_data usbhs_bdata 
__initdata = {
 #else
.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
 #endif
-   .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
-
-   .phy_reset  = true,
-   .reset_gpio_port[0]  = 57,
-   .reset_gpio_port[1]  = -EINVAL,
-   .reset_gpio_port[2]  = -EINVAL
 };
 
 #ifdef CONFIG_OMAP_MUX
@@ -349,6 +390,11 @@ static struct omap2_hsmmc_info mmc[] = {
{}  /* Terminator */
 };
 
+static struct platform_device *am3517evm_devices[] __initdata = {
+   hsusb1_phy_device,
+   hsusb1_reset_device,
+   hsusb2_phy_device,
+};
 
 static void __init am3517_evm_init(void)
 {
@@ -361,6 +407,14 @@ static void __init am3517_evm_init(void)
 
/* Configure GPIO for EHCI port */
omap_mux_init_gpio(57, OMAP_PIN_OUTPUT);
+
+   platform_add_devices(am3517evm_devices, ARRAY_SIZE(am3517evm_devices));
+
+   /* PHY on HSUSB Port 1 i.e. index 0 */
+   usb_bind_phy(ehci-omap.0, 0, nop_usb_xceiv.1);
+   /* PHY on HSUSB Port 2 i.e. index 1 */
+   usb_bind_phy(ehci-omap.0, 1, nop_usb_xceiv.2);
+
usbhs_init(usbhs_bdata);
am3517_evm_hecc_init(am3517_evm_hecc_pdata);
/* DSS */
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 09/24] ARM: OMAP3: cm-t35: Adapt to ehci-omap changes

2013-03-12 Thread Roger Quadros
Add 2 platform devices for 'nop-usb-xceiv'. These will be used
as PHYs for HS USB ports 1 and 2 so provide binding information
for them.

Model RESET for HS USB Ports 1 and 2 as GPIO fixed regulators and
link them to the 2 PHYs we just created.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 arch/arm/mach-omap2/board-cm-t35.c |   95 ++--
 1 files changed, 90 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-omap2/board-cm-t35.c 
b/arch/arm/mach-omap2/board-cm-t35.c
index af2bb21..155ab13 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -29,6 +29,7 @@
 #include linux/i2c/twl.h
 #include linux/regulator/fixed.h
 #include linux/regulator/machine.h
+#include linux/usb/phy.h
 #include linux/mmc/host.h
 #include linux/usb/phy.h
 
@@ -419,15 +420,92 @@ static struct omap2_hsmmc_info mmc[] = {
{}  /* Terminator */
 };
 
+/* PHY device on HS USB Port 1 i.e. nop_usb_xceiv.1 */
+static struct platform_device hsusb1_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 1,
+};
+
+/* Regulator for HS USB Port 1 PHY reset */
+static struct regulator_consumer_supply hsusb1_reset_supplies[] = {
+   /* Link PHY device to reset supply so it gets used in the PHY driver */
+   REGULATOR_SUPPLY(reset, nop_usb_xceiv.1),
+};
+
+static struct regulator_init_data hsusb1_reset_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies = hsusb1_reset_supplies,
+   .num_consumer_supplies = ARRAY_SIZE(hsusb1_reset_supplies),
+};
+
+static struct fixed_voltage_config hsusb1_reset_config = {
+   .supply_name = hsusb1_reset,
+   .microvolts = 330,
+   .gpio = OMAP_MAX_GPIO_LINES + 6,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,   /* keep in RESET */
+   .init_data = hsusb1_reset_data,
+};
+
+static struct platform_device hsusb1_reset_device = {
+   .name = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb1_reset_config,
+   },
+};
+
+/* PHY device on HS USB Port 2 i.e. nop_usb_xceiv.2 */
+static struct platform_device hsusb2_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 2,
+};
+
+/* Regulator for HS USB Port 2 PHY reset */
+static struct regulator_consumer_supply hsusb2_reset_supplies[] = {
+   /* Link PHY device to reset supply so it gets used in the PHY driver */
+   REGULATOR_SUPPLY(reset, nop_usb_xceiv.2),
+};
+
+static struct regulator_init_data hsusb2_reset_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies = hsusb2_reset_supplies,
+   .num_consumer_supplies = ARRAY_SIZE(hsusb2_reset_supplies),
+};
+
+static struct fixed_voltage_config hsusb2_reset_config = {
+   .supply_name = hsusb2_reset,
+   .microvolts = 330,
+   .gpio = OMAP_MAX_GPIO_LINES + 7,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,   /* keep in RESET */
+   .init_data = hsusb2_reset_data,
+};
+
+static struct platform_device hsusb2_reset_device = {
+   .name = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb2_reset_config,
+   },
+};
+
 static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
-   .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
+};
 
-   .phy_reset  = true,
-   .reset_gpio_port[0]  = OMAP_MAX_GPIO_LINES + 6,
-   .reset_gpio_port[1]  = OMAP_MAX_GPIO_LINES + 7,
-   .reset_gpio_port[2]  = -EINVAL
+static struct platform_device *usbhs_devices[] = {
+   hsusb1_phy_device,
+   hsusb1_reset_device,
+   hsusb2_phy_device,
+   hsusb2_reset_device,
 };
 
 static void  __init cm_t35_init_usbh(void)
@@ -444,6 +522,13 @@ static void  __init cm_t35_init_usbh(void)
msleep(1);
}
 
+   platform_add_devices(usbhs_devices, ARRAY_SIZE(usbhs_devices));
+
+   /* PHY on HSUSB Port 1 i.e. index 0 */
+   usb_bind_phy(ehci-omap.0, 0, nop_usb_xceiv.1);
+   /* PHY on HSUSB Port 2 i.e. index 1 */
+   usb_bind_phy(ehci-omap.0, 1, nop_usb_xceiv.2);
+
usbhs_init(usbhs_bdata);
 }
 
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 10/24] ARM: OMAP3: cm-t3517: Adapt to ehci-omap changes

2013-03-12 Thread Roger Quadros
Add 2 platform devices for 'nop-usb-xceiv'. These will be used
as PHYs for HS USB ports 1 and 2 so provide binding information
for them.

Model RESET for HS USB Ports 1 and 2 as GPIO fixed regulators and
link them to the 2 PHYs we just created.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 arch/arm/mach-omap2/board-cm-t3517.c |   97 --
 1 files changed, 92 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-omap2/board-cm-t3517.c 
b/arch/arm/mach-omap2/board-cm-t3517.c
index a66da80..de470c8 100644
--- a/arch/arm/mach-omap2/board-cm-t3517.c
+++ b/arch/arm/mach-omap2/board-cm-t3517.c
@@ -34,6 +34,9 @@
 #include linux/mtd/partitions.h
 #include linux/mmc/host.h
 #include linux/can/platform/ti_hecc.h
+#include linux/regulator/machine.h
+#include linux/regulator/fixed.h
+#include linux/usb/phy.h
 
 #include asm/mach-types.h
 #include asm/mach/arch.h
@@ -188,15 +191,92 @@ static inline void cm_t3517_init_rtc(void) {}
 #define HSUSB2_RESET_GPIO  (147)
 #define USB_HUB_RESET_GPIO (152)
 
+/* PHY device on HS USB Port 1 i.e. nop_usb_xceiv.1 */
+static struct platform_device hsusb1_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 1,
+};
+
+/* Regulator for HS USB Port 1 PHY reset */
+static struct regulator_consumer_supply hsusb1_reset_supplies[] = {
+   /* Link PHY device to reset supply so it gets used in the PHY driver */
+   REGULATOR_SUPPLY(reset, nop_usb_xceiv.1),
+};
+
+static struct regulator_init_data hsusb1_reset_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies = hsusb1_reset_supplies,
+   .num_consumer_supplies = ARRAY_SIZE(hsusb1_reset_supplies),
+};
+
+static struct fixed_voltage_config hsusb1_reset_config = {
+   .supply_name = hsusb1_reset,
+   .microvolts = 330,
+   .gpio = HSUSB1_RESET_GPIO,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,   /* keep in RESET */
+   .init_data = hsusb1_reset_data,
+};
+
+static struct platform_device hsusb1_reset_device = {
+   .name = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb1_reset_config,
+   },
+};
+
+/* PHY device on HS USB Port 2 i.e. nop_usb_xceiv.2 */
+static struct platform_device hsusb2_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 2,
+};
+
+/* Regulator for HS USB Port 2 PHY reset */
+static struct regulator_consumer_supply hsusb2_reset_supplies[] = {
+   /* Link PHY device to reset supply so it gets used in the PHY driver */
+   REGULATOR_SUPPLY(reset, nop_usb_xceiv.2),
+};
+
+static struct regulator_init_data hsusb2_reset_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies = hsusb2_reset_supplies,
+   .num_consumer_supplies = ARRAY_SIZE(hsusb2_reset_supplies),
+};
+
+static struct fixed_voltage_config hsusb2_reset_config = {
+   .supply_name = hsusb2_reset,
+   .microvolts = 330,
+   .gpio = HSUSB2_RESET_GPIO,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,   /* keep in RESET */
+   .init_data = hsusb2_reset_data,
+};
+
+static struct platform_device hsusb2_reset_device = {
+   .name = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb2_reset_config,
+   },
+};
+
 static struct usbhs_omap_platform_data cm_t3517_ehci_pdata __initdata = {
.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
-   .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
+};
 
-   .phy_reset  = true,
-   .reset_gpio_port[0]  = HSUSB1_RESET_GPIO,
-   .reset_gpio_port[1]  = HSUSB2_RESET_GPIO,
-   .reset_gpio_port[2]  = -EINVAL,
+static struct platform_device *usbhs_devices[] = {
+   hsusb1_phy_device,
+   hsusb1_reset_device,
+   hsusb2_phy_device,
+   hsusb2_reset_device,
 };
 
 static int __init cm_t3517_init_usbh(void)
@@ -213,6 +293,13 @@ static int __init cm_t3517_init_usbh(void)
msleep(1);
}
 
+   platform_add_devices(usbhs_devices, ARRAY_SIZE(usbhs_devices));
+
+   /* PHY on HSUSB Port 1 i.e. index 0 */
+   usb_bind_phy(ehci-omap.0, 0, nop_usb_xceiv.1);
+   /* PHY on HSUSB Port 2 i.e. index 1 */
+   usb_bind_phy(ehci-omap.0, 1, nop_usb_xceiv.2);
+
usbhs_init(cm_t3517_ehci_pdata);
 
return 0;
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 11/24] ARM: OMAP: devkit8000: Adapt to ehci-omap changes

2013-03-12 Thread Roger Quadros
Add platform device for 'nop-usb-xceiv'. This will be used as a
PHY for HS USB Port 1, so provide binding information for it.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 arch/arm/mach-omap2/board-devkit8000.c |   20 
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-omap2/board-devkit8000.c 
b/arch/arm/mach-omap2/board-devkit8000.c
index 53056c3..922ca91 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -33,6 +33,7 @@
 
 #include linux/regulator/machine.h
 #include linux/i2c/twl.h
+#include linux/usb/phy.h
 #include id.h
 #include asm/mach-types.h
 #include asm/mach/arch.h
@@ -430,22 +431,21 @@ static void __init omap_dm9000_init(void)
eth_addr[5] = (odi.id_0  0x00ff);
 }
 
+/* PHY device on HS USB Port 1 i.e. nop_usb_xceiv.1 */
+static struct platform_device hsusb1_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 1,
+};
+
 static struct platform_device *devkit8000_devices[] __initdata = {
leds_gpio,
keys_gpio,
omap_dm9000_dev,
+   hsusb1_phy_device,
 };
 
 static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
-
.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
-   .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
-   .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
-
-   .phy_reset  = true,
-   .reset_gpio_port[0]  = -EINVAL,
-   .reset_gpio_port[1]  = -EINVAL,
-   .reset_gpio_port[2]  = -EINVAL
 };
 
 #ifdef CONFIG_OMAP_MUX
@@ -625,6 +625,10 @@ static void __init devkit8000_init(void)
 
usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb);
usb_musb_init(NULL);
+
+   /* PHY on HSUSB Port 1 i.e. index 0 */
+   usb_bind_phy(ehci-omap.0, 0, nop_usb_xceiv.1);
+
usbhs_init(usbhs_bdata);
board_nand_init(devkit8000_nand_partitions,
ARRAY_SIZE(devkit8000_nand_partitions), NAND_CS,
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 12/24] ARM: OMAP3: igep0020: Adapt to ehci-omap changes

2013-03-12 Thread Roger Quadros
Add 2 platform devices for 'nop-usb-xceiv'. These will be used
as PHYs for HS USB ports 1 and 2 so provide binding information
for them.

Model RESET for HS USB Ports 1 and 2 as GPIO fixed regulators and
link them to the 2 PHYs we just created.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 arch/arm/mach-omap2/board-igep0020.c |  112 +
 1 files changed, 98 insertions(+), 14 deletions(-)

diff --git a/arch/arm/mach-omap2/board-igep0020.c 
b/arch/arm/mach-omap2/board-igep0020.c
index bf92678..c4730c6 100644
--- a/arch/arm/mach-omap2/board-igep0020.c
+++ b/arch/arm/mach-omap2/board-igep0020.c
@@ -22,6 +22,7 @@
 
 #include linux/regulator/machine.h
 #include linux/regulator/fixed.h
+#include linux/usb/phy.h
 #include linux/i2c/twl.h
 #include linux/mmc/host.h
 
@@ -527,26 +528,98 @@ static void __init igep_i2c_init(void)
omap3_pmic_init(twl4030, igep_twldata);
 }
 
+/* PHY device on HS USB Port 1 i.e. nop_usb_xceiv.1 */
+static struct platform_device hsusb1_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 1,
+};
+
+/* Regulator for HS USB Port 1 PHY reset */
+static struct regulator_consumer_supply hsusb1_reset_supplies[] = {
+   /* Link PHY device to reset supply so it gets used in the PHY driver */
+   REGULATOR_SUPPLY(reset, nop_usb_xceiv.1),
+};
+
+static struct regulator_init_data hsusb1_reset_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies = hsusb1_reset_supplies,
+   .num_consumer_supplies = ARRAY_SIZE(hsusb1_reset_supplies),
+};
+
+static struct fixed_voltage_config hsusb1_reset_config = {
+   .supply_name = hsusb1_reset,
+   .microvolts = 330,
+   .gpio = IGEP2_GPIO_USBH_NRESET,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,   /* keep in RESET */
+   .init_data = hsusb1_reset_data,
+};
+
+static struct platform_device hsusb1_reset_device = {
+   .name = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb1_reset_config,
+   },
+};
+
+/* PHY device on HS USB Port 2 i.e. nop_usb_xceiv.2 */
+static struct platform_device hsusb2_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 2,
+};
+
+/* Regulator for HS USB Port 2 PHY reset */
+static struct regulator_consumer_supply hsusb2_reset_supplies[] = {
+   /* Link PHY device to reset supply so it gets used in the PHY driver */
+   REGULATOR_SUPPLY(reset, nop_usb_xceiv.2),
+};
+
+static struct regulator_init_data hsusb2_reset_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies = hsusb2_reset_supplies,
+   .num_consumer_supplies = ARRAY_SIZE(hsusb2_reset_supplies),
+};
+
+static struct fixed_voltage_config hsusb2_reset_config = {
+   .supply_name = hsusb2_reset,
+   .microvolts = 330,
+   .gpio = IGEP3_GPIO_USBH_NRESET,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,   /* keep in RESET */
+   .init_data = hsusb2_reset_data,
+};
+
+static struct platform_device hsusb2_reset_device = {
+   .name = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb2_reset_config,
+   },
+};
+
+static struct platform_device *igep2_devices[] __initdata = {
+   hsusb1_phy_device,
+   hsusb1_reset_device,
+};
+
+static struct platform_device *igep3_devices[] __initdata = {
+   hsusb2_phy_device,
+   hsusb2_reset_device,
+};
+
 static struct usbhs_omap_platform_data igep2_usbhs_bdata __initdata = {
.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
-   .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
-   .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
-
-   .phy_reset = true,
-   .reset_gpio_port[0] = IGEP2_GPIO_USBH_NRESET,
-   .reset_gpio_port[1] = -EINVAL,
-   .reset_gpio_port[2] = -EINVAL,
 };
 
 static struct usbhs_omap_platform_data igep3_usbhs_bdata __initdata = {
-   .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
-   .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
-
-   .phy_reset = true,
-   .reset_gpio_port[0] = -EINVAL,
-   .reset_gpio_port[1] = IGEP3_GPIO_USBH_NRESET,
-   .reset_gpio_port[2] = -EINVAL,
 };
 
 #ifdef CONFIG_OMAP_MUX
@@ -642,8 +715,19 @@ static void __init igep_init(void)
if (machine_is_igep0020()) {
omap_display_init(igep2_dss_data);
igep2_init_smsc911x();
+
+   platform_add_devices(igep2_devices, ARRAY_SIZE(igep2_devices));
+
+   /* PHY on HSUSB Port 1 i.e. index 0 */
+   usb_bind_phy(ehci-omap.0, 0, nop_usb_xceiv.1);
+
usbhs_init(igep2_usbhs_bdata);
} else {
+   platform_add_devices

[PATCH 13/24] ARM: OMAP3: omap3evm: Adapt to ehci-omap changes

2013-03-12 Thread Roger Quadros
Add platform device for 'nop-usb-xceiv'. This will be used as a
PHY for HS USB Port 2, so provide binding information for it.

Model RESET for HS USB Port 2 as GPIO fixed regulator and link
it to the 'nop-usb-xceiv' PHY.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 arch/arm/mach-omap2/board-omap3evm.c |   62 --
 1 files changed, 51 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3evm.c 
b/arch/arm/mach-omap2/board-omap3evm.c
index 48789e0..5da465e 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -34,6 +34,7 @@
 #include linux/usb/otg.h
 #include linux/usb/musb.h
 #include linux/usb/nop-usb-xceiv.h
+#include linux/usb/phy.h
 #include linux/smsc911x.h
 
 #include linux/wl12xx.h
@@ -539,17 +540,51 @@ static int __init omap3_evm_i2c_init(void)
return 0;
 }
 
-static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
+/* PHY device on HS USB Port 2 i.e. nop_usb_xceiv.2 */
+static struct platform_device hsusb2_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 2,
+};
 
-   .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
-   .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
-   .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
+/* Regulator for HS USB Port 2 PHY reset */
+static struct regulator_consumer_supply hsusb2_reset_supplies[] = {
+   /* Link PHY device to reset supply so it gets used in the PHY driver */
+   REGULATOR_SUPPLY(reset, nop_usb_xceiv.2),
+};
 
-   .phy_reset  = true,
-   /* PHY reset GPIO will be runtime programmed based on EVM version */
-   .reset_gpio_port[0]  = -EINVAL,
-   .reset_gpio_port[1]  = -EINVAL,
-   .reset_gpio_port[2]  = -EINVAL
+static struct regulator_init_data hsusb2_reset_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies = hsusb2_reset_supplies,
+   .num_consumer_supplies = ARRAY_SIZE(hsusb2_reset_supplies),
+};
+
+static struct fixed_voltage_config hsusb2_reset_config = {
+   .supply_name = hsusb2_reset,
+   .microvolts = 330,
+   .gpio = -1, /* set at runtime */
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,   /* keep in RESET */
+   .init_data = hsusb2_reset_data,
+};
+
+static struct platform_device hsusb2_reset_device = {
+   .name = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb2_reset_config,
+   },
+};
+
+static struct platform_device *omap3evm_devices[] __initdata = {
+   hsusb2_phy_device,
+   hsusb2_reset_device,
+};
+
+static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
+   .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
 };
 
 #ifdef CONFIG_OMAP_MUX
@@ -725,7 +760,7 @@ static void __init omap3_evm_init(void)
 
/* setup EHCI phy reset config */
omap_mux_init_gpio(21, OMAP_PIN_INPUT_PULLUP);
-   usbhs_bdata.reset_gpio_port[1] = 21;
+   hsusb2_reset_config.gpio = 21;
 
/* EVM REV = E can supply 500mA with EXTVBUS programming */
musb_board_data.power = 500;
@@ -733,10 +768,15 @@ static void __init omap3_evm_init(void)
} else {
/* setup EHCI phy reset on MDC */
omap_mux_init_gpio(135, OMAP_PIN_OUTPUT);
-   usbhs_bdata.reset_gpio_port[1] = 135;
+   hsusb2_reset_config.gpio = 135;
}
usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb);
usb_musb_init(musb_board_data);
+
+   platform_add_devices(omap3evm_devices, ARRAY_SIZE(omap3evm_devices));
+   /* PHY on HSUSB Port 2 i.e. index 1 */
+   usb_bind_phy(ehci-omap.0, 1, nop_usb_xceiv.2);
+
usbhs_init(usbhs_bdata);
board_nand_init(omap3evm_nand_partitions,
ARRAY_SIZE(omap3evm_nand_partitions), NAND_CS,
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 14/24] ARM: OMAP3: omap3pandora: Adapt to ehci-omap changes

2013-03-12 Thread Roger Quadros
Add platform device for 'nop-usb-xceiv'. This will be used as a
PHY for HS USB Port 2, so provide binding information for it.

Model RESET for HS USB Port 2 as GPIO fixed regulator and link
it to the 'nop-usb-xceiv' PHY.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 arch/arm/mach-omap2/board-omap3pandora.c |   52 +
 1 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3pandora.c 
b/arch/arm/mach-omap2/board-omap3pandora.c
index 2bba362..85e5685 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -23,6 +23,8 @@
 
 #include linux/spi/spi.h
 #include linux/regulator/machine.h
+#include linux/regulator/fixed.h
+#include linux/usb/phy.h
 #include linux/i2c/twl.h
 #include linux/wl12xx.h
 #include linux/mtd/partitions.h
@@ -561,23 +563,55 @@ fail:
printk(KERN_ERR wl1251 board initialisation failed\n);
 }
 
+/* PHY device on HS USB Port 2 i.e. nop_usb_xceiv.2 */
+static struct platform_device hsusb2_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 2,
+};
+
+/* Regulator for HS USB Port 2 PHY reset */
+static struct regulator_consumer_supply hsusb2_reset_supplies[] = {
+   /* Link PHY device to reset supply so it gets used in the PHY driver */
+   REGULATOR_SUPPLY(reset, nop_usb_xceiv.2),
+};
+
+static struct regulator_init_data hsusb2_reset_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies = hsusb2_reset_supplies,
+   .num_consumer_supplies = ARRAY_SIZE(hsusb2_reset_supplies),
+};
+
+static struct fixed_voltage_config hsusb2_reset_config = {
+   .supply_name = hsusb2_reset,
+   .microvolts = 330,
+   .gpio = 16,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,   /* keep in RESET */
+   .init_data = hsusb2_reset_data,
+};
+
+static struct platform_device hsusb2_reset_device = {
+   .name = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb2_reset_config,
+   },
+};
+
 static struct platform_device *omap3pandora_devices[] __initdata = {
pandora_leds_gpio,
pandora_keys_gpio,
pandora_vwlan_device,
pandora_backlight,
+   hsusb2_phy_device,
+   hsusb2_reset_device,
 };
 
 static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
-
-   .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
-   .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
-
-   .phy_reset  = true,
-   .reset_gpio_port[0]  = -EINVAL,
-   .reset_gpio_port[1]  = 16,
-   .reset_gpio_port[2]  = -EINVAL
 };
 
 #ifdef CONFIG_OMAP_MUX
@@ -601,6 +635,8 @@ static void __init omap3pandora_init(void)
spi_register_board_info(omap3pandora_spi_board_info,
ARRAY_SIZE(omap3pandora_spi_board_info));
omap_ads7846_init(1, OMAP3_PANDORA_TS_GPIO, 0, NULL);
+   /* PHY on HSUSB Port 2 i.e. index 1 */
+   usb_bind_phy(ehci-omap.0, 1, nop_usb_xceiv.2);
usbhs_init(usbhs_bdata);
usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb);
usb_musb_init(NULL);
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 15/24] ARM: OMAP3: omap3stalker: Adapt to ehci-omap changes

2013-03-12 Thread Roger Quadros
Add platform device for 'nop-usb-xceiv'. This will be used as a
PHY for HS USB Port 2, so provide binding information for it.

Model RESET for HS USB Port 2 as GPIO fixed regulator and link
it to the 'nop-usb-xceiv' PHY.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 arch/arm/mach-omap2/board-omap3stalker.c |   52 ++
 1 files changed, 45 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3stalker.c 
b/arch/arm/mach-omap2/board-omap3stalker.c
index 95c10b3..e38c0bd 100644
--- a/arch/arm/mach-omap2/board-omap3stalker.c
+++ b/arch/arm/mach-omap2/board-omap3stalker.c
@@ -26,6 +26,7 @@
 
 #include linux/regulator/fixed.h
 #include linux/regulator/machine.h
+#include linux/usb/phy.h
 #include linux/i2c/twl.h
 #include linux/mmc/host.h
 #include linux/input/matrix_keypad.h
@@ -358,19 +359,52 @@ static int __init omap3_stalker_i2c_init(void)
 
 #define OMAP3_STALKER_TS_GPIO  175
 
+/* PHY device on HS USB Port 2 i.e. nop_usb_xceiv.2 */
+static struct platform_device hsusb2_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 2,
+};
+
+/* Regulator for HS USB Port 2 PHY reset */
+static struct regulator_consumer_supply hsusb2_reset_supplies[] = {
+   /* Link PHY device to reset supply so it gets used in the PHY driver */
+   REGULATOR_SUPPLY(reset, nop_usb_xceiv.2),
+};
+
+static struct regulator_init_data hsusb2_reset_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies = hsusb2_reset_supplies,
+   .num_consumer_supplies = ARRAY_SIZE(hsusb2_reset_supplies),
+};
+
+static struct fixed_voltage_config hsusb2_reset_config = {
+   .supply_name = hsusb2_reset,
+   .microvolts = 330,
+   .gpio = 21,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,   /* keep in RESET */
+   .init_data = hsusb2_reset_data,
+};
+
+static struct platform_device hsusb2_reset_device = {
+   .name = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb2_reset_config,
+   },
+};
+
 static struct platform_device *omap3_stalker_devices[] __initdata = {
keys_gpio,
+   hsusb2_phy_device,
+   hsusb2_reset_device,
 };
 
 static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
-   .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
-   .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
-
-   .phy_reset = true,
-   .reset_gpio_port[0] = -EINVAL,
-   .reset_gpio_port[1] = 21,
-   .reset_gpio_port[2] = -EINVAL,
 };
 
 #ifdef CONFIG_OMAP_MUX
@@ -407,6 +441,10 @@ static void __init omap3_stalker_init(void)
omap_sdrc_init(mt46h32m32lf6_sdrc_params, NULL);
usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb);
usb_musb_init(NULL);
+
+   /* PHY on HSUSB Port 2 i.e. index 1 */
+   usb_bind_phy(ehci-omap.0, 1, nop_usb_xceiv.2);
+
usbhs_init(usbhs_bdata);
omap_ads7846_init(1, OMAP3_STALKER_TS_GPIO, 310, NULL);
 
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 16/24] ARM: OMAP3: omap3touchbook: Adapt to ehci-omap changes

2013-03-12 Thread Roger Quadros
Add 2 platform devices for 'nop-usb-xceiv'. These will be used as a
PHY for HS USB Ports 1 and 2, so provide binding information for them.

Model RESET for HS USB Port 2 as GPIO fixed regulator and link it
to the respective 'nop-usb-xceiv' PHY.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 arch/arm/mach-omap2/board-omap3touchbook.c |   62 ---
 1 files changed, 55 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c 
b/arch/arm/mach-omap2/board-omap3touchbook.c
index bcd44fb..6bdde83 100644
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -36,6 +36,8 @@
 #include linux/spi/ads7846.h
 
 #include linux/regulator/machine.h
+#include linux/regulator/fixed.h
+#include linux/usb/phy.h
 #include linux/i2c/twl.h
 
 #include asm/mach-types.h
@@ -305,21 +307,61 @@ static struct omap_board_mux board_mux[] __initdata = {
 };
 #endif
 
+/* PHY device on HS USB Port 1 i.e. nop_usb_xceiv.1 */
+static struct platform_device hsusb1_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 1,
+};
+
+/* PHY device on HS USB Port 2 i.e. nop_usb_xceiv.2 */
+static struct platform_device hsusb2_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 2,
+};
+
+/* Regulator for HS USB Port 2 PHY reset */
+static struct regulator_consumer_supply hsusb2_reset_supplies[] = {
+   /* Link PHY device to reset supply so it gets used in the PHY driver */
+   REGULATOR_SUPPLY(reset, nop_usb_xceiv.2),
+};
+
+static struct regulator_init_data hsusb2_reset_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies = hsusb2_reset_supplies,
+   .num_consumer_supplies = ARRAY_SIZE(hsusb2_reset_supplies),
+};
+
+static struct fixed_voltage_config hsusb2_reset_config = {
+   .supply_name = hsusb2_reset,
+   .microvolts = 330,
+   .gpio = 147,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,   /* keep in RESET */
+   .init_data = hsusb2_reset_data,
+};
+
+static struct platform_device hsusb2_reset_device = {
+   .name = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb2_reset_config,
+   },
+};
+
 static struct platform_device *omap3_touchbook_devices[] __initdata = {
leds_gpio,
keys_gpio,
+   hsusb1_phy_device,
+   hsusb2_phy_device,
+   hsusb2_reset_device,
 };
 
 static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
-
.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
-   .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
-
-   .phy_reset  = true,
-   .reset_gpio_port[0]  = -EINVAL,
-   .reset_gpio_port[1]  = 147,
-   .reset_gpio_port[2]  = -EINVAL
 };
 
 static void omap3_touchbook_poweroff(void)
@@ -368,6 +410,12 @@ static void __init omap3_touchbook_init(void)
omap_ads7846_init(4, OMAP3_TS_GPIO, 310, ads7846_pdata);
usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb);
usb_musb_init(NULL);
+
+   /* PHY on HSUSB Port 1 i.e. index 0 */
+   usb_bind_phy(ehci-omap.0, 0, nop_usb_xceiv.1);
+   /* PHY on HSUSB Port 2 i.e. index 1 */
+   usb_bind_phy(ehci-omap.0, 1, nop_usb_xceiv.2);
+
usbhs_init(usbhs_bdata);
board_nand_init(omap3touchbook_nand_partitions,
ARRAY_SIZE(omap3touchbook_nand_partitions), NAND_CS,
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 17/24] ARM: OMAP3: overo: Adapt to ehci-omap changes

2013-03-12 Thread Roger Quadros
Add platform device for 'nop-usb-xceiv'. This will be used as a
PHY for HS USB Port 2, so provide binding information for it.

Model RESET for HS USB Port 2 as GPIO fixed regulator and link
it to the 'nop-usb-xceiv' PHY.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 arch/arm/mach-omap2/board-overo.c |   54 
 1 files changed, 48 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/board-overo.c 
b/arch/arm/mach-omap2/board-overo.c
index 86bab51..5f93ba0 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -31,6 +31,7 @@
 #include linux/regulator/machine.h
 #include linux/regulator/fixed.h
 #include linux/spi/spi.h
+#include linux/usb/phy.h
 
 #include linux/mtd/mtd.h
 #include linux/mtd/nand.h
@@ -458,14 +459,51 @@ static int __init overo_spi_init(void)
return 0;
 }
 
+/* PHY device on HS USB Port 2 i.e. nop_usb_xceiv.2 */
+static struct platform_device hsusb2_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 2,
+};
+
+/* Regulator for HS USB Port 2 PHY reset */
+static struct regulator_consumer_supply hsusb2_reset_supplies[] = {
+   /* Link PHY device to reset supply so it gets used in the PHY driver */
+   REGULATOR_SUPPLY(reset, nop_usb_xceiv.2),
+};
+
+static struct regulator_init_data hsusb2_reset_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies = hsusb2_reset_supplies,
+   .num_consumer_supplies = ARRAY_SIZE(hsusb2_reset_supplies),
+};
+
+static struct fixed_voltage_config hsusb2_reset_config = {
+   .supply_name = hsusb2_reset,
+   .microvolts = 330,
+   .gpio = OVERO_GPIO_USBH_NRESET,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,   /* keep in RESET */
+   .init_data = hsusb2_reset_data,
+};
+
+static struct platform_device hsusb2_reset_device = {
+   .name = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb2_reset_config,
+   },
+};
+
+static struct platform_device *overo_devices[] __initdata = {
+   hsusb2_phy_device,
+   hsusb2_reset_device,
+};
+
 static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
-   .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
-   .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
-   .phy_reset  = true,
-   .reset_gpio_port[0]  = -EINVAL,
-   .reset_gpio_port[1]  = OVERO_GPIO_USBH_NRESET,
-   .reset_gpio_port[2]  = -EINVAL
 };
 
 #ifdef CONFIG_OMAP_MUX
@@ -502,6 +540,10 @@ static void __init overo_init(void)
ARRAY_SIZE(overo_nand_partitions), NAND_CS, 0, NULL);
usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb);
usb_musb_init(NULL);
+
+   platform_add_devices(overo_devices, ARRAY_SIZE(overo_devices));
+   /* PHY on HSUSB Port 2 i.e. index 1 */
+   usb_bind_phy(ehci-omap.0, 1, nop_usb_xceiv.2);
usbhs_init(usbhs_bdata);
overo_spi_init();
overo_init_smsc911x();
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 18/24] ARM: OMAP: zoom: Adapt to ehci-omap changes

2013-03-12 Thread Roger Quadros
Add platform device for 'nop-usb-xceiv'. This will be used as a
PHY for HS USB Port 2, so provide binding information for it.

Model RESET for HS USB Port 2 as GPIO fixed regulator and link
it to the 'nop-usb-xceiv' PHY.

Signed-off-by: Roger Quadros rog...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 arch/arm/mach-omap2/board-zoom.c |   56 +
 1 files changed, 50 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/board-zoom.c b/arch/arm/mach-omap2/board-zoom.c
index 5e4d4c9..5c5deaa 100644
--- a/arch/arm/mach-omap2/board-zoom.c
+++ b/arch/arm/mach-omap2/board-zoom.c
@@ -17,6 +17,9 @@
 #include linux/gpio.h
 #include linux/i2c/twl.h
 #include linux/mtd/nand.h
+#include linux/regulator/machine.h
+#include linux/regulator/fixed.h
+#include linux/usb/phy.h
 
 #include asm/mach-types.h
 #include asm/mach/arch.h
@@ -92,14 +95,51 @@ static struct mtd_partition zoom_nand_partitions[] = {
},
 };
 
+/* PHY device on HS USB Port 2 i.e. nop_usb_xceiv.2 */
+static struct platform_device hsusb2_phy_device = {
+   .name = nop_usb_xceiv,
+   .id = 2,
+};
+
+/* Regulator for HS USB Port 2 PHY reset */
+static struct regulator_consumer_supply hsusb2_reset_supplies[] = {
+   /* Link PHY device to reset supply so it gets used in the PHY driver */
+   REGULATOR_SUPPLY(reset, nop_usb_xceiv.2),
+};
+
+static struct regulator_init_data hsusb2_reset_data = {
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .consumer_supplies = hsusb2_reset_supplies,
+   .num_consumer_supplies = ARRAY_SIZE(hsusb2_reset_supplies),
+};
+
+static struct fixed_voltage_config hsusb2_reset_config = {
+   .supply_name = hsusb2_reset,
+   .microvolts = 330,
+   .gpio = ZOOM3_EHCI_RESET_GPIO,
+   .startup_delay = 7, /* 70msec */
+   .enable_high = 1,
+   .enabled_at_boot = 0,   /* keep in RESET */
+   .init_data = hsusb2_reset_data,
+};
+
+static struct platform_device hsusb2_reset_device = {
+   .name = reg-fixed-voltage,
+   .id = PLATFORM_DEVID_AUTO,
+   .dev = {
+   .platform_data = hsusb2_reset_config,
+   },
+};
+
+static struct platform_device *zoom3_devices[] __initdata = {
+   hsusb2_phy_device,
+   hsusb2_reset_device,
+};
+
 static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
-   .port_mode[0]   = OMAP_USBHS_PORT_MODE_UNUSED,
.port_mode[1]   = OMAP_EHCI_PORT_MODE_PHY,
-   .port_mode[2]   = OMAP_USBHS_PORT_MODE_UNUSED,
-   .phy_reset  = true,
-   .reset_gpio_port[0] = -EINVAL,
-   .reset_gpio_port[1] = ZOOM3_EHCI_RESET_GPIO,
-   .reset_gpio_port[2] = -EINVAL,
 };
 
 static void __init omap_zoom_init(void)
@@ -109,6 +149,10 @@ static void __init omap_zoom_init(void)
} else if (machine_is_omap_zoom3()) {
omap3_mux_init(board_mux, OMAP_PACKAGE_CBP);
omap_mux_init_gpio(ZOOM3_EHCI_RESET_GPIO, OMAP_PIN_OUTPUT);
+
+   platform_add_devices(zoom3_devices, ARRAY_SIZE(zoom3_devices));
+   /* PHY on HSUSB Port 2 i.e. index 1 */
+   usb_bind_phy(ehci-omap.0, 1, nop_usb_xceiv.2);
usbhs_init(usbhs_bdata);
}
 
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 19/24] ARM: dts: OMAP4: Add HS USB Host IP nodes

2013-03-12 Thread Roger Quadros
Adds device nodes for HS USB Host module, TLL module,
OHCI and EHCI controllers.

Signed-off-by: Roger Quadros rog...@ti.com
---
 arch/arm/boot/dts/omap4.dtsi |   30 ++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 739bb79..b7db1a2 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -529,5 +529,35 @@
ti,hwmods = timer11;
ti,timer-pwm;
};
+
+   usbhstll: usbhstll@4a062000 {
+   compatible = ti,usbhs-tll;
+   reg = 0x4a062000 0x1000;
+   interrupts = 0 78 0x4;
+   ti,hwmods = usb_tll_hs;
+   };
+
+   usbhshost: usbhshost@4a064000 {
+   compatible = ti,usbhs-host;
+   reg = 0x4a064000 0x800;
+   ti,hwmods = usb_host_hs;
+   #address-cells = 1;
+   #size-cells = 1;
+   ranges;
+
+   usbhsohci: ohci@4a064800 {
+   compatible = ti,ohci-omap3, usb-ohci;
+   reg = 0x4a064800 0x400;
+   interrupt-parent = gic;
+   interrupts = 0 76 0x4;
+   };
+
+   usbhsehci: ehci@4a064c00 {
+   compatible = ti,ehci-omap, usb-ehci;
+   reg = 0x4a064c00 0x400;
+   interrupt-parent = gic;
+   interrupts = 0 77 0x4;
+   };
+   };
};
 };
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 20/24] ARM: dts: omap4-panda: Add USB Host support

2013-03-12 Thread Roger Quadros
Provide the RESET and Power regulators for the USB PHY,
the USB Host port mode and the PHY device.

Also provide pin multiplexer information for the USB host
pins.

Signed-off-by: Roger Quadros rog...@ti.com
---
 arch/arm/boot/dts/omap4-panda.dts |   56 +
 1 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/omap4-panda.dts 
b/arch/arm/boot/dts/omap4-panda.dts
index 4122efe..cfc7683 100644
--- a/arch/arm/boot/dts/omap4-panda.dts
+++ b/arch/arm/boot/dts/omap4-panda.dts
@@ -57,6 +57,36 @@
AFML, Line In,
AFMR, Line In;
};
+
+   /* HS USB Port 1 RESET */
+   hsusb1_reset: hsusb1_reset_reg {
+   compatible = regulator-fixed;
+   regulator-name = hsusb1_reset;
+   regulator-min-microvolt = 330;
+   regulator-max-microvolt = 330;
+   gpio = gpio2 30 0;   /* gpio_62 */
+   startup-delay-us = 7;
+   enable-active-high;
+   };
+
+   /* HS USB Port 1 Power */
+   hsusb1_power: hsusb1_power_reg {
+   compatible = regulator-fixed;
+   regulator-name = hsusb1_vbus;
+   regulator-min-microvolt = 330;
+   regulator-max-microvolt = 330;
+   gpio = gpio1 1 0;/* gpio_1 */
+   startup-delay-us = 7;
+   enable-active-high;
+   };
+
+   /* HS USB Host PHY on PORT 1 */
+   hsusb1_phy: hsusb1_phy {
+   compatible = usb-nop-xceiv;
+   reset-supply = hsusb1_reset;
+   vcc-supply = hsusb1_power;
+   clock-frequency = 1920;
+   };
 };
 
 omap4_pmx_core {
@@ -67,6 +97,7 @@
mcbsp1_pins
dss_hdmi_pins
tpd12s015_pins
+   hsusbb1_pins
;
 
twl6040_pins: pinmux_twl6040_pins {
@@ -110,6 +141,23 @@
0x58 0x10b  /* hdmi_hpd.gpio_63 INPUT PULLDOWN | 
MODE3 */
;
};
+
+   hsusbb1_pins: pinmux_hsusbb1_pins {
+   pinctrl-single,pins = 
+   0x82 0x10C  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_clk INPUT | PULLDOWN */
+   0x84 0x4/* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_stp OUTPUT */
+   0x86 0x104  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dir INPUT | PULLDOWN */
+   0x88 0x104  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_nxt INPUT | PULLDOWN */
+   0x8a 0x104  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat0 INPUT | PULLDOWN */
+   0x8c 0x104  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat1 INPUT | PULLDOWN */
+   0x8e 0x104  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat2 INPUT | PULLDOWN */
+   0x90 0x104  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat3 INPUT | PULLDOWN */
+   0x92 0x104  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat4 INPUT | PULLDOWN */
+   0x94 0x104  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat5 INPUT | PULLDOWN */
+   0x96 0x104  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat6 INPUT | PULLDOWN */
+   0x98 0x104  /* 
USBB1_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat7 INPUT | PULLDOWN */
+   ;
+   };
 };
 
 i2c1 {
@@ -206,3 +254,11 @@
 twl_usb_comparator {
usb-supply = vusb;
 };
+
+usbhshost {
+   port1-mode = ehci-phy;
+};
+
+usbhsehci {
+   phys = hsusb1_phy;
+};
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 21/24] ARM: dts: OMAP3: Add HS USB Host IP nodes

2013-03-12 Thread Roger Quadros
Adds device nodes for HS USB Host module, TLL module,
OHCI and EHCI controllers.

Signed-off-by: Roger Quadros rog...@ti.com
---
 arch/arm/boot/dts/omap3.dtsi |   31 +++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 1acc261..a14f74b 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -397,5 +397,36 @@
ti,timer-alwon;
ti,timer-secure;
};
+
+   usbhstll: usbhstll@48062000 {
+   compatible = ti,usbhs-tll;
+   reg = 0x48062000 0x1000;
+   interrupts = 78;
+   ti,hwmods = usb_tll_hs;
+   };
+
+   usbhshost: usbhshost@48064000 {
+   compatible = ti,usbhs-host;
+   reg = 0x48064000 0x400;
+   ti,hwmods = usb_host_hs;
+   #address-cells = 1;
+   #size-cells = 1;
+   ranges;
+
+   usbhsohci: ohci@48064400 {
+   compatible = ti,ohci-omap3, usb-ohci;
+   reg = 0x48064400 0x400;
+   interrupt-parent = intc;
+   interrupts = 76;
+   };
+
+   usbhsehci: ehci@48064800 {
+   compatible = ti,ehci-omap, usb-ehci;
+   reg = 0x48064800 0x400;
+   interrupt-parent = intc;
+   interrupts = 77;
+   };
+   };
+
};
 };
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 22/24] ARM: dts: omap3-beagle: Add USB Host support

2013-03-12 Thread Roger Quadros
Provide RESET and Power regulators for the USB PHY,
the USB Host port mode and the PHY device.

Also provide pin multiplexer information for USB host
pins.

Signed-off-by: Roger Quadros rog...@ti.com
---
 arch/arm/boot/dts/omap3-beagle.dts |   71 
 1 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/omap3-beagle.dts 
b/arch/arm/boot/dts/omap3-beagle.dts
index f624dc8..02d23f1 100644
--- a/arch/arm/boot/dts/omap3-beagle.dts
+++ b/arch/arm/boot/dts/omap3-beagle.dts
@@ -38,6 +38,57 @@
};
};
 
+   /* HS USB Port 2 RESET */
+   hsusb2_reset: hsusb2_reset_reg {
+   compatible = regulator-fixed;
+   regulator-name = hsusb2_reset;
+   regulator-min-microvolt = 330;
+   regulator-max-microvolt = 330;
+   gpio = gpio5 19 0;   /* gpio_147 */
+   startup-delay-us = 7;
+   enable-active-high;
+   };
+
+   /* HS USB Port 2 Power */
+   hsusb2_power: hsusb2_power_reg {
+   compatible = regulator-fixed;
+   regulator-name = hsusb2_vbus;
+   regulator-min-microvolt = 330;
+   regulator-max-microvolt = 330;
+   gpio = twl_gpio 18 0;/* GPIO LEDA */
+   startup-delay-us = 7;
+   };
+
+   /* HS USB Host PHY on PORT 2 */
+   hsusb2_phy: hsusb2_phy {
+   compatible = usb-nop-xceiv;
+   reset-supply = hsusb2_reset;
+   vcc-supply = hsusb2_power;
+   };
+};
+
+omap3_pmx_core {
+   pinctrl-names = default;
+   pinctrl-0 = 
+   hsusbb2_pins
+   ;
+
+   hsusbb2_pins: pinmux_hsusbb2_pins {
+   pinctrl-single,pins = 
+   0x5c0 0x3  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_clk OUTPUT */
+   0x5c2 0x3  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_stp OUTPUT */
+   0x5c4 0x10b  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dir INPUT | PULLDOWN */
+   0x5c6 0x10b  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_nxt INPUT | PULLDOWN */
+   0x5c8 0x10b  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat0 INPUT | PULLDOWN */
+   0x5cA 0x10b  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat1 INPUT | PULLDOWN */
+   0x1a4 0x10b  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat2 INPUT | PULLDOWN */
+   0x1a6 0x10b  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat3 INPUT | PULLDOWN */
+   0x1a8 0x10b  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat4 INPUT | PULLDOWN */
+   0x1aa 0x10b  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat5 INPUT | PULLDOWN */
+   0x1ac 0x10b  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat6 INPUT | PULLDOWN */
+   0x1ae 0x10b  /* 
USBB2_ULPITLL_CLK_MUXMODE.usbb1_ulpiphy_dat7 INPUT | PULLDOWN */
+   ;
+   };
 };
 
 i2c1 {
@@ -65,3 +116,23 @@
 mmc3 {
status = disabled;
 };
+
+usbhshost {
+   port2-mode = ehci-phy;
+};
+
+usbhsehci {
+   phys = 0 hsusb2_phy;
+};
+
+twl_gpio {
+   ti,use-leds;
+   /* pullups: BIT(1) */
+   ti,pullups = 0x02;
+   /*
+* pulldowns:
+* BIT(2), BIT(6), BIT(7), BIT(8), BIT(13)
+* BIT(15), BIT(16), BIT(17)
+*/
+   ti,pulldowns = 0x03a1c4;
+};
-- 
1.7.4.1

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH 23/24] ARM: OMAP2+: Allow clock alias provision from device tree

2013-03-12 Thread Roger Quadros
Currently on OMAP, it is not possible to specify a clock consumer
to any of the OMAP generated clocks using the device tree. This can pose
a problem for external devices that run off an OMAP clock as we
can't reliably provide a reference to the clock in the device tree.

This patch allows device trees to provide a node that contains the
clock identifier, clock alias and the device phandle. The board
initialization code then creates a clock alias to this clock id,
and associates it with the device whose phandle was supplied.

Discussion
http://www.spinics.net/lists/linux-omap/msg86241.html

CC: Russell King li...@arm.linux.org.uk
CC: Rajendra Nayak rna...@ti.com
CC: Santosh Shilimkar santosh.shilim...@ti.com

Signed-off-by: Roger Quadros rog...@ti.com
---
 .../devicetree/bindings/clock/ti-clock-alias.txt   |   26 
 arch/arm/mach-omap2/board-generic.c|   67 
 2 files changed, 93 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/ti-clock-alias.txt

diff --git a/Documentation/devicetree/bindings/clock/ti-clock-alias.txt 
b/Documentation/devicetree/bindings/clock/ti-clock-alias.txt
new file mode 100644
index 000..87ef4c3
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/ti-clock-alias.txt
@@ -0,0 +1,26 @@
+* Clock alias provision for TI OMAP2+ boards
+
+This binding allows the board's device tree file to specify a clock name,
+device phandle and clock alias so that that clock can be associated
+to the device with the alias.
+
+This is required in cases where an external device is clocked by an
+OMAP generated clock and needs to be assocated to it.
+
+NOTE: The node's name should be clock_alias
+
+Required properties
+- clock-name: The clock identifier string. Should be one of the
+  clock ids defined in OMAP common clock data.
+- clock-alias: A string specifying the alias that must be created to the clock.
+- device: A phandle to the device this clock should be associated to.
+
+e.g. On the OMAP4 Panda board, the USB PHY device is clocked by the
+FREF_CLK3 (auxclk3_ck) from the OMAP. The PHY driver expexts the clock to
+be named main_clk. This binding can be provided like so
+
+clock_alias {
+   clock-name = auxclk3_ck;
+   clock-alias = main_clk;
+   device = hsusb1_phy;
+};
diff --git a/arch/arm/mach-omap2/board-generic.c 
b/arch/arm/mach-omap2/board-generic.c
index 0274ff7..2fc48f9 100644
--- a/arch/arm/mach-omap2/board-generic.c
+++ b/arch/arm/mach-omap2/board-generic.c
@@ -15,6 +15,9 @@
 #include linux/of_irq.h
 #include linux/of_platform.h
 #include linux/irqdomain.h
+#include linux/clk.h
+#include linux/string.h
+#include linux/slab.h
 
 #include asm/mach/arch.h
 
@@ -35,12 +38,76 @@ static struct of_device_id omap_dt_match_table[] __initdata 
= {
{ }
 };
 
+static int __init omap_create_clk_alias(struct device_node *np)
+{
+   int ret = 0;
+   const char *s, *alias;
+   char *clk_id;
+   struct device_node *dev_np;
+   struct platform_device *pdev;
+
+   of_property_read_string(np, clock-name, s);
+   if (!s) {
+   pr_err(%s: couldn't find clock-name property in node %s\n,
+   __func__, np-name);
+   return -ENODEV;
+   }
+
+   clk_id = kstrdup(s, GFP_KERNEL);
+   if (!clk_id)
+   return -ENOMEM;
+
+   dev_np = of_parse_phandle(np, device, 0);
+   if (!dev_np) {
+   pr_err(%s: couldn't find device phandle for \'%s\'\n,
+   __func__, clk_id);
+   ret = -ENODEV;
+   goto exit;
+   }
+
+   pdev = of_find_device_by_node(dev_np);
+   if (!pdev) {
+   pr_err(%s: couldn't find device for clock \'%s\'\n,
+   __func__, clk_id);
+   ret = -ENODEV;
+   goto exit;
+   }
+
+   ret = of_property_read_string(np, clock-alias, alias);
+   if (ret) {
+   pr_err(%s: couldn't find alias for clock \'%s\'\n,
+   __func__, clk_id);
+   ret = -ENODEV;
+   goto exit;
+   }
+
+   ret = clk_add_alias(alias, dev_name(pdev-dev), clk_id, NULL);
+   if (ret) {
+   pr_err(%s: couldn't add alias \'%s\' to clock \'%s\'\n,
+   __func__, alias, clk_id);
+   ret = -ENODEV;
+   goto exit;
+   }
+
+exit:
+   kfree(clk_id);
+   return ret;
+}
+
 static void __init omap_generic_init(void)
 {
+   struct device_node *np;
+
omap_sdrc_init(NULL, NULL);
 
of_platform_populate(NULL, omap_dt_match_table, NULL, NULL);
 
+   /* create clock aliases based on 'clock_alias' nodes */
+   for_each_node_by_name(np, clock_alias) {
+   omap_create_clk_alias(np);
+   of_node_put(np);
+   }
+
/*
 * HACK: call display setup code for selected boards to enable omapdss

Re: [PATCH 23/24] ARM: OMAP2+: Allow clock alias provision from device tree

2013-03-12 Thread Roger Quadros
Hi Benoit,

On 03/12/2013 03:17 PM, Benoit Cousson wrote:
 Hi Roger,
 
 On 03/12/2013 12:43 PM, Roger Quadros wrote:
 Currently on OMAP, it is not possible to specify a clock consumer
 to any of the OMAP generated clocks using the device tree. This can pose
 a problem for external devices that run off an OMAP clock as we
 can't reliably provide a reference to the clock in the device tree.
 
 I'm really confused by that statement... Why cannot you use the current
 clock binding definition?
 
 The point is that we should avoid defining temporary custom bindings.
 Especially when a generic one already exist.
 
 I know you already discussed that on the list, but I cannot really find
 the rational in the previous thread.
 
 Here is a quote from the original Subject: Re: how to specify an OMAP
 clock in device tree? thread.
 
 /* provider */
 clks: omapclocks {
 compatible = ti,omapclocks;
 #clock-cells = 1;
 };

 /* consumer */
 hsusb1_phy: hsusb1_phy {
  compatible = usb-nop-xceiv;
  clocks = clks auxclk3_ck;  /* FREF_CLK3 */
  clock-names = main-clk;
 };

 The only problem I see is that the argument to the clks phandle
 cannot be a string. It needs to be u32.

 In that case we need to map all clocks into a u32 index.

 If we can do that only for auxclks, my problem is solved for panda.
 
 phandle is u32 as always, but you should not care about that.
 What you care about is the clock node referenced by the phandle, not the
 phandle itself.
 
 What is missing right now is a proper of_clk_add_provider call to
 declare a generic OMAP clock provider and thus allow OMAP clocks to be
 used with DT.
 
 The AUXCLOCKs are managed by the SCRM which is outside the PRCM, so you
 should be able to add a clock providers dedicated to the SCRM clocks only.

Okay, I will convert at least the SCRM clocks to be provided by device tree.

Tony,

Please drop this patch and patch 24. The rest should be fine.
Just that Panda EHCI won't work till we have the PHY clock correctly
provided.

cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 1/8] usb: phy: nop: Add some parameters to platform data

2013-03-12 Thread Roger Quadros
On 03/12/2013 01:54 PM, Marc Kleine-Budde wrote:
 On 03/12/2013 12:24 PM, Roger Quadros wrote:
 Add clk_rate parameter to platform data. If supplied, the
 NOP phy driver will program the clock to that rate during probe.

 Also add 2 flags, needs_vcc and needs_reset.
 If the flag is set and the regulator couldn't be found
 then the driver will bail out with -EPROBE_DEFER.
 
 Is there a platform which fills out pdata.needs_vcc and
 pdata.needs_reset? IMHO it makes no sense to add features for the non DT
 case, if there isn't any user for it.


There can be a user in the non DT case as well. Consider the following example:
The power regulator that supplies VCC to the PHY device sits over the I2C bus.
The NOP transceiver driver is built into the kernel but the regulator driver
is built as a module.

During boot, the NOP transceiver driver's probe is called before the regulator 
can
be probed. So regulator_get() will fail and if the platform doesn't set the
needs_vcc flag, the driver will continue as normal and the PHY device won't 
work.

I know that beagleboard can benefit from this. The current workaround is to
register the regulator before we register the PHY in the board file. With the
needs_vcc flag, we don't need to have that limitation.

cheers,
-roger
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


  1   2   3   >