devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roger Quadros <rogerq@ti.com>
To: Tony Lindgren <tony@atomide.com>
Cc: balbi@ti.com, b-cousson@ti.com, linux-kernel@vger.kernel.org,
	linux-usb@vger.kernel.org, linux-omap@vger.kernel.org,
	devicetree-discuss@lists.ozlabs.org
Subject: Re: [PATCH 00/24] ARM: OMAP2+: Adapt to ehci-omap changes for 3.10
Date: Fri, 15 Mar 2013 11:22:52 +0200	[thread overview]
Message-ID: <5142E86C.90805@ti.com> (raw)
In-Reply-To: <20130314165440.GG26093@atomide.com>

On 03/14/2013 06:54 PM, Tony Lindgren wrote:
> * Roger Quadros <rogerq@ti.com> [130314 08:45]:
>>
>> OK. Let me know how the below patch looks. After that, the board code
>> will look like.
>>
>> static struct usbhs_phy_data phy_data[] = {
>> 	{
>> 		.reset_gpio = 147,
>> 		.vcc_gpio = 148
>> 		.vcc_polarity = 1,
>> 		.phy_id = "nop_usb_xceiv.2",
>> 	},
>> 	{}, /* Terminator */
>> };
>>
>> usbhs_init_phys(phy_data);
> 
> Great, looks good to me.
>  
>> Patch to implement usbhs_init_phys();
>>
>> diff --git a/arch/arm/mach-omap2/usb-host.c b/arch/arm/mach-omap2/usb-host.c
>> index 5706bdc..b9d6bff 100644
>> --- a/arch/arm/mach-omap2/usb-host.c
>> +++ b/arch/arm/mach-omap2/usb-host.c
>> @@ -22,8 +22,12 @@
>>  #include <linux/platform_device.h>
>>  #include <linux/slab.h>
>>  #include <linux/dma-mapping.h>
>> +#include <linux/regulator/machine.h>
>> +#include <linux/regulator/fixed.h>
>> +#include <linux/string.h>
>>  
>>  #include <asm/io.h>
>> +#include <asm/gpio.h>
> 
> Please change these both to linux/io.h and linux/gpio.h.

OK.

>   
>>  #include "soc.h"
>>  #include "omap_device.h"
>> @@ -472,6 +476,141 @@ void __init setup_4430ohci_io_mux(const enum usbhs_omap_port_mode *port_mode)
>>  	}
>>  }
>>  
>> +static const char *reset_supply = "reset";
>> +static const char *vcc_supply = "vcc";
>> +
>> +/* Template for PHY regulators */
>> +static struct regulator_consumer_supply hsusb_reg_supplies[] = {
>> +	{ /* .supply & .dev_name filled later */ },
>> +};
>> +
>> +static struct regulator_init_data hsusb_reg_data = {
>> +	.constraints = {
>> +		.valid_ops_mask = REGULATOR_CHANGE_STATUS,
>> +	},
>> +	.consumer_supplies	= hsusb_reg_supplies,
>> +	.num_consumer_supplies	= ARRAY_SIZE(hsusb_reg_supplies),
>> +};
>> +
>> +static struct fixed_voltage_config hsusb_reg_config = {
>> +	/* .supply_name filled later */
>> +	.microvolts = 3300000,
>> +	.gpio = -1,		/* updated later */
>> +	.startup_delay = 70000, /* 70msec */
>> +	.enable_high = 1,	/* updated later */
>> +	.enabled_at_boot = 0,	/* keep in RESET */
>> +	/* .init_data filled later */
>> +};
>> +
>> +static struct platform_device_info hsusb_reg_pdev_info = {
>> +	.name	= "reg-fixed-voltage",
>> +	.id	= PLATFORM_DEVID_AUTO,
>> +};
>> +
>> +int __init usbhs_init_phys(struct usbhs_phy_data *phy)
>> +{
>> +	struct regulator_consumer_supply *supplies;
>> +	struct regulator_init_data *reg_data;
>> +	struct fixed_voltage_config *config;
>> +	char *supply_name;
>> +	int i;
>> +
>> +
>> +	for (i = 1; i <= OMAP3_HS_USB_PORTS; i++) {
> 
> Maybe pass the number of ports to initialize too to the
> function? Might be more future proof, although it will only
> be needed until we have converted to DT.
> 

OK. I'll add a port index parameter to the usbhs_phy_data structure
to indicate which port the data belongs to and a number of ports
to usbhs_init_phys()

board code can then do

static struct usbhs_phy_data phy_data[] = {
	{
		.port = 1,	/* First USB port */
		.reset_gpio = 147,
		.vcc_gpio = 148
		.vcc_polarity = 1,
		.phy_id = "nop_usb_xceiv.2",
	},
};

usbhs_init_phys(phy_data, ARRAY_SIZE(phy_data));

>> +
>> +		if (!phy->phy_id)	/* Terminator ? */
>> +			break;
>> +
>> +		if (!gpio_is_valid(phy->reset_gpio))
>> +			goto check_vcc;
>> +
>> +		supplies = kmemdup(hsusb_reg_supplies,
>> +			    ARRAY_SIZE(hsusb_reg_supplies) *
>> +			    sizeof(struct regulator_consumer_supply),
>> +			    GFP_KERNEL);
>> +		if (!supplies)
>> +			return -ENOMEM;
>> +
>> +		supplies->supply = reset_supply;
>> +		supplies->dev_name = phy->phy_id;
>> +
>> +		reg_data = kmemdup(&hsusb_reg_data, sizeof(hsusb_reg_data),
>> +							GFP_KERNEL);
>> +		if (!reg_data)
>> +			return -ENOMEM;
>> +
>> +		reg_data->consumer_supplies = supplies;
>> +
>> +		config = kmemdup(&hsusb_reg_config, sizeof(hsusb_reg_config),
>> +							GFP_KERNEL);
>> +		if (!config)
>> +			return -ENOMEM;
>> +
>> +		supply_name = kmalloc(14, GFP_KERNEL);
>> +		if (!supply_name)
>> +			return -ENOMEM;
>> +
>> +		scnprintf(supply_name, 13, "hsusb%d_reset", i);
>> +		config->supply_name = supply_name;
>> +		config->gpio = phy->reset_gpio;
>> +		config->init_data = reg_data;
>> +
>> +		hsusb_reg_pdev_info.data = config;
>> +		hsusb_reg_pdev_info.size_data = sizeof(hsusb_reg_config);
>> +		platform_device_register_full(&hsusb_reg_pdev_info);
>> +
>> +check_vcc:
>> +		if (!gpio_is_valid(phy->vcc_gpio))
>> +			goto next;
>> +
>> +		supplies = kmemdup(hsusb_reg_supplies,
>> +			    ARRAY_SIZE(hsusb_reg_supplies) *
>> +			    sizeof(struct regulator_consumer_supply),
>> +			    GFP_KERNEL);
>> +		if (!supplies)
>> +			return -ENOMEM;
>> +
>> +		supplies->supply = vcc_supply;
>> +		supplies->dev_name = phy->phy_id;
>> +
>> +		reg_data = kmemdup(&hsusb_reg_data, sizeof(hsusb_reg_data),
>> +							GFP_KERNEL);
>> +		if (!reg_data)
>> +			return -ENOMEM;
>> +
>> +		reg_data->consumer_supplies = supplies;
>> +
>> +		config = kmemdup(&hsusb_reg_config, sizeof(hsusb_reg_config),
>> +							GFP_KERNEL);
>> +		if (!config)
>> +			return -ENOMEM;
>> +
>> +		supply_name = kmalloc(14, GFP_KERNEL);
>> +		if (!supply_name)
>> +			return -ENOMEM;
>> +
>> +		scnprintf(supply_name, 13, "hsusb%d_vcc", i);
>> +		config->supply_name = supply_name;
>> +		config->gpio = phy->vcc_gpio;
>> +		config->enable_high = phy->vcc_polarity;
>> +		config->init_data = reg_data;
>> +
>> +		hsusb_reg_pdev_info.data = config;
>> +		hsusb_reg_pdev_info.size_data = sizeof(hsusb_reg_config);
>> +		platform_device_register_full(&hsusb_reg_pdev_info);
>> +
>> +next:
>> +		phy++;
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>>  void __init usbhs_init(struct usbhs_omap_platform_data *pdata)
>>  {
>>  	struct omap_hwmod	*uhh_hwm, *tll_hwm;
>> diff --git a/arch/arm/mach-omap2/usb.h b/arch/arm/mach-omap2/usb.h
>> index 3319f5c..70a8c63 100644
>> --- a/arch/arm/mach-omap2/usb.h
>> +++ b/arch/arm/mach-omap2/usb.h
>> @@ -53,8 +53,16 @@
>>  #define USBPHY_OTGSESSEND_EN	(1 << 20)
>>  #define USBPHY_DATA_POLARITY	(1 << 23)
>>  
>> +struct usbhs_phy_data {
>> +	int reset_gpio;
>> +	int vcc_gpio;
>> +	bool vcc_polarity;	/* 1 active high, 0 active low */
>> +	char *phy_id;
>> +};
>> +
>>  extern void usb_musb_init(struct omap_musb_board_data *board_data);
>>  extern void usbhs_init(struct usbhs_omap_platform_data *pdata);
>> +extern int usbhs_init_phys(struct usbhs_phy_data *phy);
> 
> Maybe need a static inline version when no EHCI is selected?
> 
Yes.

> Otherwise looks good to me, thanks for updating it.
> 

Cool. I'll update all boards and send it to you soon.

cheers,
-roger

      reply	other threads:[~2013-03-15  9:22 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-12 11:43 [PATCH 00/24] ARM: OMAP2+: Adapt to ehci-omap changes for 3.10 Roger Quadros
2013-03-12 11:43 ` [PATCH 01/24] usb: phy: nop: Add some parameters to platform data Roger Quadros
2013-03-12 11:43 ` [PATCH 03/24] ARM: OMAP2+: omap4panda: Adapt to ehci-omap changes Roger Quadros
2013-03-12 11:43 ` [PATCH 06/24] ARM: OMAP3: 3630SDP: " Roger Quadros
2013-03-12 11:43 ` [PATCH 07/24] ARM: OMAP: AM3517crane: " Roger Quadros
     [not found] ` <1363088606-2692-1-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2013-03-12 11:43   ` [PATCH 02/24] ARM: OMAP2+: omap4panda: Provide USB Host's PHY platform data Roger Quadros
2013-03-12 11:43   ` [PATCH 04/24] ARM: OMAP3: Beagle: Adapt to ehci-omap changes Roger Quadros
2013-03-12 11:43   ` [PATCH 05/24] ARM: OMAP3: 3430SDP: " Roger Quadros
2013-03-12 11:43   ` [PATCH 08/24] ARM: OMAP: AM3517evm: " Roger Quadros
2013-03-12 11:43   ` [PATCH 10/24] ARM: OMAP3: cm-t3517: " Roger Quadros
2013-03-12 11:43   ` [PATCH 12/24] ARM: OMAP3: igep0020: " Roger Quadros
2013-03-12 11:43   ` [PATCH 14/24] ARM: OMAP3: omap3pandora: " Roger Quadros
2013-03-12 11:43   ` [PATCH 15/24] ARM: OMAP3: omap3stalker: " Roger Quadros
2013-03-12 11:43 ` [PATCH 09/24] ARM: OMAP3: cm-t35: " Roger Quadros
2013-03-12 11:43 ` [PATCH 11/24] ARM: OMAP: devkit8000: " Roger Quadros
2013-03-12 11:43 ` [PATCH 13/24] ARM: OMAP3: omap3evm: " Roger Quadros
2013-03-12 11:43 ` [PATCH 16/24] ARM: OMAP3: omap3touchbook: " Roger Quadros
2013-03-12 11:43 ` [PATCH 17/24] ARM: OMAP3: overo: " Roger Quadros
2013-03-12 11:43 ` [PATCH 18/24] ARM: OMAP: zoom: " Roger Quadros
2013-03-12 11:43 ` [PATCH 19/24] ARM: dts: OMAP4: Add HS USB Host IP nodes Roger Quadros
2013-03-12 11:43 ` [PATCH 20/24] ARM: dts: omap4-panda: Add USB Host support Roger Quadros
2013-03-12 11:43 ` [PATCH 21/24] ARM: dts: OMAP3: Add HS USB Host IP nodes Roger Quadros
2013-03-12 11:43 ` [PATCH 22/24] ARM: dts: omap3-beagle: Add USB Host support Roger Quadros
2013-03-12 11:43 ` [PATCH 23/24] ARM: OMAP2+: Allow clock alias provision from device tree Roger Quadros
2013-03-12 13:17   ` Benoit Cousson
     [not found]     ` <513F2AEB.8070702-l0cyMroinI0@public.gmane.org>
2013-03-12 14:01       ` Roger Quadros
2013-03-12 11:43 ` [PATCH 24/24] ARM: dts: omap4-panda: Add clock alias for USB PHY Roger Quadros
2013-03-12 16:40 ` [PATCH 00/24] ARM: OMAP2+: Adapt to ehci-omap changes for 3.10 Tony Lindgren
     [not found]   ` <20130312164007.GZ26093-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2013-03-13 13:41     ` Roger Quadros
2013-03-13 16:24       ` Tony Lindgren
2013-03-13 16:36         ` Roger Quadros
2013-03-13 16:57           ` Tony Lindgren
2013-03-14 15:41             ` Roger Quadros
2013-03-14 16:54               ` Tony Lindgren
2013-03-15  9:22                 ` Roger Quadros [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5142E86C.90805@ti.com \
    --to=rogerq@ti.com \
    --cc=b-cousson@ti.com \
    --cc=balbi@ti.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).