* [PATCH v3 0/4] ARM: OMAP2+: Adapt to ehci-omap changes for 3.10
@ 2013-03-18 12:51 Roger Quadros
2013-03-18 12:51 ` [PATCH v3 1/4] usb: phy: nop: Add some parameters to platform data Roger Quadros
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Roger Quadros @ 2013-03-18 12:51 UTC (permalink / raw)
To: linux-arm-kernel
Hi Tony,
I've revised the patches based on your comments. For now I've just
adapted Panda and Beagleboard.
If this looks OK then I can adapt the other boards as well.
cheers,
-roger
Roger Quadros (4):
usb: phy: nop: Add some parameters to platform data
ARM: OMAP2+: omap-usb-host: Add usbhs_init_phys()
ARM: OMAP2+: omap4panda: Adapt to ehci-omap changes
ARM: OMAP3: Beagle: Adapt to ehci-omap changes
arch/arm/mach-omap2/board-omap3beagle.c | 32 ++++--
arch/arm/mach-omap2/board-omap4panda.c | 55 ++++------
arch/arm/mach-omap2/usb-host.c | 177 ++++++++++++++++++++++++++++++-
arch/arm/mach-omap2/usb.h | 9 ++
include/linux/usb/nop-usb-xceiv.h | 5 +
5 files changed, 232 insertions(+), 46 deletions(-)
--
1.7.4.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/4] usb: phy: nop: Add some parameters to platform data
2013-03-18 12:51 [PATCH v3 0/4] ARM: OMAP2+: Adapt to ehci-omap changes for 3.10 Roger Quadros
@ 2013-03-18 12:51 ` Roger Quadros
2013-03-18 12:51 ` [PATCH v3 2/4] ARM: OMAP2+: omap-usb-host: Add usbhs_init_phys() Roger Quadros
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Roger Quadros @ 2013-03-18 12:51 UTC (permalink / raw)
To: linux-arm-kernel
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 <rogerq@ti.com>
Acked-by: Felipe Balbi <balbi@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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 2/4] ARM: OMAP2+: omap-usb-host: Add usbhs_init_phys()
2013-03-18 12:51 [PATCH v3 0/4] ARM: OMAP2+: Adapt to ehci-omap changes for 3.10 Roger Quadros
2013-03-18 12:51 ` [PATCH v3 1/4] usb: phy: nop: Add some parameters to platform data Roger Quadros
@ 2013-03-18 12:51 ` Roger Quadros
2013-03-18 12:51 ` [PATCH v3 3/4] ARM: OMAP2+: omap4panda: Adapt to ehci-omap changes Roger Quadros
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Roger Quadros @ 2013-03-18 12:51 UTC (permalink / raw)
To: linux-arm-kernel
This helper allows board support code to add the PHY's
VCC and RESET regulators which are GPIO controlled as well
as the NOP PHY device.
Signed-off-by: Roger Quadros <rogerq@ti.com>
---
arch/arm/mach-omap2/usb-host.c | 177 +++++++++++++++++++++++++++++++++++++++-
arch/arm/mach-omap2/usb.h | 9 ++
2 files changed, 184 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-omap2/usb-host.c b/arch/arm/mach-omap2/usb-host.c
index 5706bdc..49a2c3f 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 <asm/io.h>
+#include <linux/regulator/machine.h>
+#include <linux/regulator/fixed.h>
+#include <linux/string.h>
+#include <linux/io.h>
+#include <linux/gpio.h>
+#include <linux/usb/phy.h>
#include "soc.h"
#include "omap_device.h"
@@ -526,3 +530,172 @@ void __init usbhs_init(struct usbhs_omap_platform_data *pdata)
}
#endif
+
+/* 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,
+};
+
+static const char *reset_supply = "reset";
+static const char *vcc_supply = "vcc";
+static const char *nop_name = "nop_usb_xceiv"; /* NOP PHY driver */
+
+int usbhs_init_phys(struct usbhs_phy_data *phy, int num_phys)
+{
+ struct regulator_consumer_supply *supplies;
+ struct regulator_init_data *reg_data;
+ struct fixed_voltage_config *config;
+ char *supply_name;
+ int i, len;
+ struct platform_device *pdev;
+ char *phy_id;
+
+ /* the phy_id will be something like "nop_usb_xceiv.1" */
+ len = strlen(nop_name) + 3; /* 3 -> ".1" and NULL terminator */
+
+ for (i = 0; i < num_phys; i++) {
+
+ if (!phy->port) {
+ pr_err("%s: Invalid port 0. Must start from 1\n",
+ __func__);
+ continue;
+ }
+
+ /* do we need a NOP PHY device ? */
+ if (!gpio_is_valid(phy->reset_gpio) &&
+ !gpio_is_valid(phy->vcc_gpio))
+ continue;
+
+ /* create a NOP PHY device */
+ pdev = kzalloc(sizeof(*pdev), GFP_KERNEL);
+ if (!pdev)
+ return -ENOMEM;
+
+ pdev->id = phy->port;
+ pdev->name = nop_name;
+ pdev->dev.platform_data = phy->platform_data;
+
+ phy_id = kmalloc(len, GFP_KERNEL);
+ if (!phy_id)
+ return -ENOMEM;
+
+ scnprintf(phy_id, len, "nop_usb_xceiv.%d\n",
+ pdev->id);
+
+ if (platform_device_register(pdev)) {
+ pr_err("%s: Failed to register device %s\n",
+ __func__, phy_id);
+ continue;
+ }
+
+ usb_bind_phy("ehci-omap.0", phy->port - 1, phy_id);
+
+ /* Do we need RESET regulator ? */
+ 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_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(13, GFP_KERNEL);
+ if (!supply_name)
+ return -ENOMEM;
+
+ scnprintf(supply_name, 13, "hsusb%d_reset", phy->port);
+ 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:
+ /* Do we need VCC regulator? */
+ 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_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(13, GFP_KERNEL);
+ if (!supply_name)
+ return -ENOMEM;
+
+ scnprintf(supply_name, 13, "hsusb%d_vcc", phy->port);
+ 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;
+}
diff --git a/arch/arm/mach-omap2/usb.h b/arch/arm/mach-omap2/usb.h
index 3319f5c..e7261eb 100644
--- a/arch/arm/mach-omap2/usb.h
+++ b/arch/arm/mach-omap2/usb.h
@@ -53,8 +53,17 @@
#define USBPHY_OTGSESSEND_EN (1 << 20)
#define USBPHY_DATA_POLARITY (1 << 23)
+struct usbhs_phy_data {
+ int port; /* 1 indexed port number */
+ int reset_gpio;
+ int vcc_gpio;
+ bool vcc_polarity; /* 1 active high, 0 active low */
+ void *platform_data;
+};
+
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, int num_phys);
extern void am35x_musb_reset(void);
extern void am35x_musb_phy_power(u8 on);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 3/4] ARM: OMAP2+: omap4panda: Adapt to ehci-omap changes
2013-03-18 12:51 [PATCH v3 0/4] ARM: OMAP2+: Adapt to ehci-omap changes for 3.10 Roger Quadros
2013-03-18 12:51 ` [PATCH v3 1/4] usb: phy: nop: Add some parameters to platform data Roger Quadros
2013-03-18 12:51 ` [PATCH v3 2/4] ARM: OMAP2+: omap-usb-host: Add usbhs_init_phys() Roger Quadros
@ 2013-03-18 12:51 ` Roger Quadros
2013-03-18 12:51 ` [PATCH v3 4/4] ARM: OMAP3: Beagle: " Roger Quadros
2013-03-18 16:41 ` [PATCH v3 0/4] ARM: OMAP2+: Adapt to ehci-omap changes for 3.10 Tony Lindgren
4 siblings, 0 replies; 6+ messages in thread
From: Roger Quadros @ 2013-03-18 12:51 UTC (permalink / raw)
To: linux-arm-kernel
Use usbhs_init_phys() to register the PHY's VCC and RESET
regulators and the NOP PHY device.
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 <rogerq@ti.com>
---
arch/arm/mach-omap2/board-omap4panda.c | 55 ++++++++++++-------------------
1 files changed, 21 insertions(+), 34 deletions(-)
diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c
index b02c2f0..a71ad34 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,6 +133,22 @@ 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 = 19200000,
+};
+
+static struct usbhs_phy_data phy_data[] __initdata = {
+ {
+ .port = 1,
+ .reset_gpio = GPIO_HUB_NRESET,
+ .vcc_gpio = GPIO_HUB_POWER,
+ .vcc_polarity = 1,
+ .platform_data = &hsusb1_phy_data,
+ },
+};
+
static struct platform_device *panda_devices[] __initdata = {
&leds_gpio,
&wl1271_device,
@@ -142,49 +159,19 @@ static struct platform_device *panda_devices[] __initdata = {
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;
- 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, 19200000);
- 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,
- 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);
+ 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");
+ usbhs_init_phys(phy_data, ARRAY_SIZE(phy_data));
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 4/4] ARM: OMAP3: Beagle: Adapt to ehci-omap changes
2013-03-18 12:51 [PATCH v3 0/4] ARM: OMAP2+: Adapt to ehci-omap changes for 3.10 Roger Quadros
` (2 preceding siblings ...)
2013-03-18 12:51 ` [PATCH v3 3/4] ARM: OMAP2+: omap4panda: Adapt to ehci-omap changes Roger Quadros
@ 2013-03-18 12:51 ` Roger Quadros
2013-03-18 16:41 ` [PATCH v3 0/4] ARM: OMAP2+: Adapt to ehci-omap changes for 3.10 Tony Lindgren
4 siblings, 0 replies; 6+ messages in thread
From: Roger Quadros @ 2013-03-18 12:51 UTC (permalink / raw)
To: linux-arm-kernel
Use usbhs_init_phys() to register the PHY's VCC and RESET
regulators and the NOP PHY device.
Signed-off-by: Roger Quadros <rogerq@ti.com>
---
arch/arm/mach-omap2/board-omap3beagle.c | 32 +++++++++++++++++++++---------
1 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index c3558f9..5382215 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -33,6 +33,7 @@
#include <linux/mtd/nand.h>
#include <linux/mmc/host.h>
#include <linux/usb/phy.h>
+#include <linux/usb/nop-usb-xceiv.h>
#include <linux/regulator/machine.h>
#include <linux/i2c/twl.h>
@@ -277,6 +278,21 @@ static struct regulator_consumer_supply beagle_vsim_supply[] = {
static struct gpio_led gpio_leds[];
+/* PHY's VCC regulator might be added later, so flag that we need it */
+static struct nop_usb_xceiv_platform_data hsusb2_phy_data = {
+ .needs_vcc = true,
+};
+
+static struct usbhs_phy_data phy_data[] = {
+ {
+ .port = 2,
+ .reset_gpio = 147,
+ .vcc_gpio = -1, /* updated in beagle_twl_gpio_setup */
+ .vcc_polarity = 1, /* updated in beagle_twl_gpio_setup */
+ .platform_data = &hsusb2_phy_data,
+ },
+};
+
static int beagle_twl_gpio_setup(struct device *dev,
unsigned gpio, unsigned ngpio)
{
@@ -318,9 +334,11 @@ 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 i.e. LED_GPO controls HS USB Port 2 power */
+ phy_data[0].vcc_gpio = gpio + TWL4030_GPIO_MAX;
+ phy_data[0].vcc_polarity = beagle_config.usb_pwr_level;
+ usbhs_init_phys(phy_data, ARRAY_SIZE(phy_data));
return 0;
}
@@ -453,15 +471,7 @@ static struct platform_device *omap3_beagle_devices[] __initdata = {
};
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 +553,9 @@ static void __init omap3_beagle_init(void)
usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
usb_musb_init(NULL);
+
usbhs_init(&usbhs_bdata);
+
board_nand_init(omap3beagle_nand_partitions,
ARRAY_SIZE(omap3beagle_nand_partitions), NAND_CS,
NAND_BUSWIDTH_16, NULL);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 0/4] ARM: OMAP2+: Adapt to ehci-omap changes for 3.10
2013-03-18 12:51 [PATCH v3 0/4] ARM: OMAP2+: Adapt to ehci-omap changes for 3.10 Roger Quadros
` (3 preceding siblings ...)
2013-03-18 12:51 ` [PATCH v3 4/4] ARM: OMAP3: Beagle: " Roger Quadros
@ 2013-03-18 16:41 ` Tony Lindgren
4 siblings, 0 replies; 6+ messages in thread
From: Tony Lindgren @ 2013-03-18 16:41 UTC (permalink / raw)
To: linux-arm-kernel
* Roger Quadros <rogerq@ti.com> [130318 05:55]:
> Hi Tony,
>
> I've revised the patches based on your comments. For now I've just
> adapted Panda and Beagleboard.
> If this looks OK then I can adapt the other boards as well.
Thanks yes looks good to me now.
Regards,
Tony
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-03-18 16:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-18 12:51 [PATCH v3 0/4] ARM: OMAP2+: Adapt to ehci-omap changes for 3.10 Roger Quadros
2013-03-18 12:51 ` [PATCH v3 1/4] usb: phy: nop: Add some parameters to platform data Roger Quadros
2013-03-18 12:51 ` [PATCH v3 2/4] ARM: OMAP2+: omap-usb-host: Add usbhs_init_phys() Roger Quadros
2013-03-18 12:51 ` [PATCH v3 3/4] ARM: OMAP2+: omap4panda: Adapt to ehci-omap changes Roger Quadros
2013-03-18 12:51 ` [PATCH v3 4/4] ARM: OMAP3: Beagle: " Roger Quadros
2013-03-18 16:41 ` [PATCH v3 0/4] ARM: OMAP2+: Adapt to ehci-omap changes for 3.10 Tony Lindgren
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).