Message ID | 20121128125955.29569.25431.stgit@build.warmcat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 11/28/2012 02:59 PM, Andy Green wrote: > This adds regulators which are controlled by the OMAP4 PandaBoard (ES)'s > EHCI logical root hub existing. > > The regulators are made a device_asset of the EHCI logical root hub by > passing them through the hsusb -> mfd path. Although the ehci-related > platform_device is created at boot time, it is not instantiated until the > ehci-hcd module is inserted if it is modular. > > Since the regulator is an asset of the ehci-omap.0 device, it's turned on > during successful probe and off when the device is removed. > > Without power control, the ULPI PHY + SMSC9614 on the Panda eats 700-900mW > all the time, which is around the same as the idle power of the SoC and > rest of the board. > > This allows us to start off with it depowered, and only power it if the > ehci-hcd module is inserted. When the module is removed, it's depowered > again. > > Signed-off-by: Andy Green <andy.green@linaro.org> > --- > arch/arm/mach-omap2/board-omap4panda.c | 100 ++++++++++++++++++++++++++------ > arch/arm/mach-omap2/usb-host.c | 1 > arch/arm/plat-omap/include/plat/usb.h | 2 + > drivers/mfd/omap-usb-host.c | 9 ++- > 4 files changed, 89 insertions(+), 23 deletions(-) > > diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c > index bfcd397..52add03 100644 > --- a/arch/arm/mach-omap2/board-omap4panda.c > +++ b/arch/arm/mach-omap2/board-omap4panda.c > @@ -144,6 +144,15 @@ static struct platform_device *panda_devices[] __initdata = { > &btwilink_device, > }; > > +static struct device_asset assets_ehci_omap0[] = { > + { > + .name = "reg-panda-smsc95xx", > + .pre_probe = regulator_asset_default_preprobe, > + .post_remove = regulator_asset_default_postremove, > + }, > + { } > +}; > + > static const struct usbhs_omap_board_data usbhs_bdata __initconst = { > .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY, > .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED, > @@ -151,12 +160,8 @@ static const struct usbhs_omap_board_data usbhs_bdata __initconst = { > .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" }, > + .reset_gpio_port[2] = -EINVAL, > + .assets = assets_ehci_omap0, > }; > > static void __init omap4_ehci_init(void) > @@ -173,23 +178,76 @@ static void __init omap4_ehci_init(void) > 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; > - } > + usbhs_init(&usbhs_bdata); > +} > > - gpio_export(GPIO_HUB_POWER, 0); > - gpio_export(GPIO_HUB_NRESET, 0); > - gpio_set_value(GPIO_HUB_NRESET, 1); > +/* > + * hub_nreset also resets the ULPI PHY and is required after powering SMSC chip > + * ULPI PHY is always powered... need to do reset once for both once > + * hub_power enables a 3.3V regulator for (hub + eth) chip > + * however there's no point having ULPI PHY in use alone > + * since it's only connected to the (hub + eth) chip > + */ > > - usbhs_init(&usbhs_bdata); > +static struct regulator_init_data panda_hub = { > + .constraints = { > + .name = "vhub", > + .valid_ops_mask = REGULATOR_CHANGE_STATUS, > + }, > +}; > > - /* enable power to hub */ > - gpio_set_value(GPIO_HUB_POWER, 1); > -} > +static struct fixed_voltage_config panda_vhub = { > + .supply_name = "vhub", > + .microvolts = 3300000, > + .gpio = GPIO_HUB_POWER, > + .startup_delay = 70000, /* 70msec */ > + .enable_high = 1, > + .enabled_at_boot = 0, > + .init_data = &panda_hub, > +}; > + > +static struct platform_device omap_vhub_device = { > + .name = "reg-fixed-voltage", > + .id = 2, > + .dev = { > + .platform_data = &panda_vhub, > + }, > +}; > + > +static struct regulator_init_data panda_ulpireset = { > + /* > + * idea is that when operating ulpireset, regulator api will make > + * sure that the hub+eth chip is powered, since it's the "parent" > + */ > + .supply_regulator = "vhub", /* we are a child of vhub */ > + .constraints = { > + /* > + * this magic string associates us with ehci-omap.0 root hub > + * when the root hub logical device is up, we will power > + * and reset [ ULPI PHY + [ HUB + ETH ] ] > + */ > + .name = "reg-panda-smsc95xx", > + .valid_ops_mask = REGULATOR_CHANGE_STATUS, > + }, > +}; > + > +static struct fixed_voltage_config panda_vulpireset = { > + .supply_name = "reg-panda-smsc95xx", > + .microvolts = 3300000, > + .gpio = GPIO_HUB_NRESET, > + .startup_delay = 70000, /* 70msec */ > + .enable_high = 1, > + .enabled_at_boot = 0, > + .init_data = &panda_ulpireset, > +}; > + > +static struct platform_device omap_vulpireset_device = { > + .name = "reg-fixed-voltage", > + .id = 3, > + .dev = { > + .platform_data = &panda_vulpireset, > + }, > +}; > > static struct omap_musb_board_data musb_board_data = { > .interface_type = MUSB_INTERFACE_UTMI, > @@ -504,6 +562,8 @@ static void __init omap4_panda_init(void) > omap4_panda_i2c_init(); > platform_add_devices(panda_devices, ARRAY_SIZE(panda_devices)); > platform_device_register(&omap_vwlan_device); > + platform_device_register(&omap_vhub_device); > + platform_device_register(&omap_vulpireset_device); > omap_serial_init(); > omap_sdrc_init(NULL, NULL); > omap4_twl6030_hsmmc_init(mmc); > diff --git a/arch/arm/mach-omap2/usb-host.c b/arch/arm/mach-omap2/usb-host.c > index 98f3287..2a0fdf9 100644 > --- a/arch/arm/mach-omap2/usb-host.c > +++ b/arch/arm/mach-omap2/usb-host.c > @@ -501,6 +501,7 @@ void __init usbhs_init(const struct usbhs_omap_board_data *pdata) > } > ehci_data.phy_reset = pdata->phy_reset; > ohci_data.es2_compatibility = pdata->es2_compatibility; > + ehci_data.assets = pdata->assets; Just wondering if it makes more sense to tie the regulator and clock assets on the Panda to LAN95xx platform device instead of ehci_omap's platform device. The only thing we need to do is add a dummy platform device for the LAN9xx chip and probe it in the smsc9xx driver. The benefit of this is we can choose to power up/down the LAN9xx device by insmod/rmmod smsc0xx driver and still have other OMAP USB ports functional. what do you think? regards, -roger -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 11/28/2012 11:06 PM, the mail apparently from Roger Quadros included: Hi Roger - > On 11/28/2012 02:59 PM, Andy Green wrote: >> This adds regulators which are controlled by the OMAP4 PandaBoard (ES)'s >> EHCI logical root hub existing. >> >> The regulators are made a device_asset of the EHCI logical root hub by >> passing them through the hsusb -> mfd path. Although the ehci-related >> platform_device is created at boot time, it is not instantiated until the >> ehci-hcd module is inserted if it is modular. >> >> Since the regulator is an asset of the ehci-omap.0 device, it's turned on >> during successful probe and off when the device is removed. >> >> Without power control, the ULPI PHY + SMSC9614 on the Panda eats 700-900mW >> all the time, which is around the same as the idle power of the SoC and >> rest of the board. >> >> This allows us to start off with it depowered, and only power it if the >> ehci-hcd module is inserted. When the module is removed, it's depowered >> again. ... >> diff --git a/arch/arm/mach-omap2/usb-host.c b/arch/arm/mach-omap2/usb-host.c >> index 98f3287..2a0fdf9 100644 >> --- a/arch/arm/mach-omap2/usb-host.c >> +++ b/arch/arm/mach-omap2/usb-host.c >> @@ -501,6 +501,7 @@ void __init usbhs_init(const struct usbhs_omap_board_data *pdata) >> } >> ehci_data.phy_reset = pdata->phy_reset; >> ohci_data.es2_compatibility = pdata->es2_compatibility; >> + ehci_data.assets = pdata->assets; > > Just wondering if it makes more sense to tie the regulator and clock > assets on the Panda to LAN95xx platform device instead of ehci_omap's > platform device. > > The only thing we need to do is add a dummy platform device for the > LAN9xx chip and probe it in the smsc9xx driver. > > The benefit of this is we can choose to power up/down the LAN9xx device > by insmod/rmmod smsc0xx driver and still have other OMAP USB ports > functional. > > what do you think? I think it's cool but I am not sure it hangs together. Just to make sure we're on the same page, the "LAN95XX platform device" doesn't exist at the moment, right? With hsusb mfd -> ehci the platform device can be made from boot because the memory-mapped hardware is always there. As soon as the driver appears, it can be probed and made into a real live device and everything is straight. But when the platform_device would represent a usb device, that's not quite the same. AIUI the usb stack only creates the device when it has probed a vid:pid and identified a driver that claims to serve it. If the power for the HUB+ETH was controlled by an asset on the probe for the HUB+ETH device, isn't that never going to happen? The usb stack can't see the vid+pid for smsc95xx device until we give it power (it's connected but off), in this scheme we don't give it power until something ran probe for an smsc95xx device? There's another quirk on Panda that makes trouble too, after enabling power on the HUB+ETH chip, we must reset it. But the same reset signal resets the ULPI PHY too. So if the powering deadlock was solved we would still run into a problem where we caused ULPI errors bringing up the smsc95xx, if ehci+ULPI was already going. It's a violation of the independence of the ULPI and [usb device on other side of ulpi] caused by the Panda design using the same reset signal. That is why the current approach gets power + reset over with once at the time we would anyway want to reset the ULPI PHY. However I think what you're saying about binding to hub power is good. The hub ports are not devices, but it would be possible to bind an asset array to them and make the pre- and post- code functions. But AFAIK neither that, nor the platform_device idea for smsc95xx even get off the ground without a device_path type addressing scheme, because you are targeting from the board file specific logical devices that only exist later after other probes. I think it will be possible to address objections around the "pathiness" by being able to seed the path match with a platform_device pointer (there exists in the board file time a platform_device for ehci-omap.0 ...) and just matching the remainder on a single usb device's name, like "*-1.1-1". -Andy
On Thu, 29 Nov 2012, Andy Green wrote: > However I think what you're saying about binding to hub power is good. > The hub ports are not devices, but it would be possible to bind an asset > array to them and make the pre- and post- code functions. In the 3.6 kernel, hub ports are not devices. In 3.7 they are -- that is, each hub port has its own struct device. > I think it will be possible to address objections around the "pathiness" > by being able to seed the path match with a platform_device pointer > (there exists in the board file time a platform_device for ehci-omap.0 > ...) and just matching the remainder on a single usb device's name, like > "*-1.1-1". Can you think of a way to do this without checking for a match every time a new device is registered? For instance, in this case it would be preferable to do this match only for descendants of ehci-omap.0. To match the port device, the string would have to be something like "*-0:1.0/port2". In fact, if the match were anchored at the end of the string, we wouldn't need the wildcard at all -- at least, not in this case. The string could simply be "-0:1.0/port2". But that's only if the match is restricted to devices below ehci-omap.0. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 11/30/2012 01:57 AM, the mail apparently from Alan Stern included: > On Thu, 29 Nov 2012, Andy Green wrote: > >> However I think what you're saying about binding to hub power is good. >> The hub ports are not devices, but it would be possible to bind an asset >> array to them and make the pre- and post- code functions. > > In the 3.6 kernel, hub ports are not devices. In 3.7 they are -- that > is, each hub port has its own struct device. Right, I should have seen this in hub.c before. It's much better like that. >> I think it will be possible to address objections around the "pathiness" >> by being able to seed the path match with a platform_device pointer >> (there exists in the board file time a platform_device for ehci-omap.0 >> ...) and just matching the remainder on a single usb device's name, like >> "*-1.1-1". > > Can you think of a way to do this without checking for a match every > time a new device is registered? For instance, in this case it would > be preferable to do this match only for descendants of ehci-omap.0. To > match the port device, the string would have to be something like > "*-0:1.0/port2". Yes. How about adding a third callback to struct device_asset, along the lines of int (*pre_child_register)(struct device *child); then, in register_device() we add code that before we get down to it, we walk up the new device's parents calling ->pre_child_register() on any assets the parents may have. In the typical case that's a rapid NOP once per device registration. However... if we had arranged back at boot time that the ehci-omap.0 struct device had an asset with only pre_device_register callback set, we can use that asset's .name for the right-justified child device name we are looking for like "-0:1.0/port2", and its .asset member to point to another asset table the pre_child_register callback will attach to the child device if the name matches. So in the board file: struct device_asset ehci_omap0_smsc_hub_port_assets[] = { /* the smsc regulator and clock assets destined for the hub port */ { } }; /* below is attached to ehci-omap.0 like in try#1 */ struct device_asset ehci_omap0_assets[] = { { .name = "-0:1.0/port2", .asset = ehci_omap0_smsc_hub_port_assets, .pre_child_register = device_asset_attach_to_child, }, { } }; In that way we can project as many stashed asset tables on to dynamically probed devices as we like from the platform_devices at boot time. Only children of the right platform devices do any checking or processing. > In fact, if the match were anchored at the end of the string, we > wouldn't need the wildcard at all -- at least, not in this case. The > string could simply be "-0:1.0/port2". But that's only if the match is > restricted to devices below ehci-omap.0. It's a good idea, it won't get fooled by a hub getting plugged there which has its own port2 either, the -0:1.0 bit will have been elaborated for the subsequent hub "path" and won't match. It may be neater to split out the device_asset callbacks to an ..._ops struct. struct device_asset_ops { int (*pre_probe)(struct device *device, struct device_asset *asset); void (*post_remove)(struct device *device, struct device_asset *asset); int (*pre_child_register)(struct device *child); }; struct device_asset { ... struct device_asset_ops *ops; }; that also lets us export and set one thing to select say regulator "handler", instead of n callbacks that must match. Something else I think mux would be a great target for device_asset support. That way it could become normal for mux function to get set as part of the specific device instantiation, so if you know you have an 8-bit ULPI PHY that will be logically created by the platform_device, you can attach ULPI-mode mux config appropriate for your exact SoC as an asset to the platform_device. When the device is destroyed, balls can go back to safe mode and save power, and if the balls are muxed with other things again the right mux asset can be associated with that so it switches automagically according to what you are doing. That's a lot better than forcing them once at boot which is the current method. Are there any gotchas with that? -Andy
On 11/30/2012 04:58 AM, the mail apparently from Andy Green included: > On 11/30/2012 01:57 AM, the mail apparently from Alan Stern included: >> On Thu, 29 Nov 2012, Andy Green wrote: >> >>> However I think what you're saying about binding to hub power is good. >>> The hub ports are not devices, but it would be possible to bind an asset >>> array to them and make the pre- and post- code functions. >> >> In the 3.6 kernel, hub ports are not devices. In 3.7 they are -- that >> is, each hub port has its own struct device. > > Right, I should have seen this in hub.c before. It's much better like > that. > >>> I think it will be possible to address objections around the "pathiness" >>> by being able to seed the path match with a platform_device pointer >>> (there exists in the board file time a platform_device for ehci-omap.0 >>> ...) and just matching the remainder on a single usb device's name, like >>> "*-1.1-1". >> >> Can you think of a way to do this without checking for a match every >> time a new device is registered? For instance, in this case it would >> be preferable to do this match only for descendants of ehci-omap.0. To >> match the port device, the string would have to be something like >> "*-0:1.0/port2". > > Yes. How about adding a third callback to struct device_asset, along > the lines of > > int (*pre_child_register)(struct device *child); > > then, in register_device() we add code that before we get down to it, we > walk up the new device's parents calling ->pre_child_register() on any > assets the parents may have. In the typical case that's a rapid NOP > once per device registration. > > However... if we had arranged back at boot time that the ehci-omap.0 > struct device had an asset with only pre_device_register callback set, > we can use that asset's .name for the right-justified child device name > we are looking for like "-0:1.0/port2", and its .asset member to point > to another asset table the pre_child_register callback will attach to > the child device if the name matches. So in the board file: > > struct device_asset ehci_omap0_smsc_hub_port_assets[] = { > /* the smsc regulator and clock assets destined for the hub > port */ > { } > }; > > /* below is attached to ehci-omap.0 like in try#1 */ > > struct device_asset ehci_omap0_assets[] = { > { > .name = "-0:1.0/port2", > .asset = ehci_omap0_smsc_hub_port_assets, > .pre_child_register = device_asset_attach_to_child, > }, > { } > }; > > In that way we can project as many stashed asset tables on to > dynamically probed devices as we like from the platform_devices at boot > time. Only children of the right platform devices do any checking or > processing. > >> In fact, if the match were anchored at the end of the string, we >> wouldn't need the wildcard at all -- at least, not in this case. The >> string could simply be "-0:1.0/port2". But that's only if the match is >> restricted to devices below ehci-omap.0. > > It's a good idea, it won't get fooled by a hub getting plugged there > which has its own port2 either, the -0:1.0 bit will have been elaborated > for the subsequent hub "path" and won't match. > > > It may be neater to split out the device_asset callbacks to an ..._ops > struct. > > struct device_asset_ops { > int (*pre_probe)(struct device *device, struct device_asset > *asset); > void (*post_remove)(struct device *device, struct device_asset > *asset); > int (*pre_child_register)(struct device *child); > }; > > struct device_asset { > ... > struct device_asset_ops *ops; > }; > > that also lets us export and set one thing to select say regulator > "handler", instead of n callbacks that must match. I have everything discussed above ready for a try#2, including the descendant matching stuff in separate patches. The code got a lot smaller and better with the _ops struct. The new code can attach the assets to the targeted hub port as discussed (using only "-0:1.0/port1" and only checking ehci-omap.0 descendants at device_add() time), but the hub port device never probes, unless I missed the point it's because it actually never binds to a driver, it's a very unusual standalone logical device. If that's the case I could work around that by doing the probe() asset stuff at device_add() time if there's no driver name on the device, but actually I am not sure that's where we wanted to end up. Now we got so far as to succeed to associate regulator + clock assets to the logical hub port device, isn't it that we want the assets to be enabled and disabled according to hub port power state? In that case it needs to go in the direction of calling device_asset helpers in the hub.c code that handles enable and disable hub port power. Is this sounding like the right way, or something else? -Andy > Something else I think mux would be a great target for device_asset > support. That way it could become normal for mux function to get set as > part of the specific device instantiation, so if you know you have an > 8-bit ULPI PHY that will be logically created by the platform_device, > you can attach ULPI-mode mux config appropriate for your exact SoC as an > asset to the platform_device. > > When the device is destroyed, balls can go back to safe mode and save > power, and if the balls are muxed with other things again the right mux > asset can be associated with that so it switches automagically according > to what you are doing. That's a lot better than forcing them once at > boot which is the current method. Are there any gotchas with that? > > -Andy > -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Fri, 30 Nov 2012, "Andy Green (???)" wrote: > I have everything discussed above ready for a try#2, including the > descendant matching stuff in separate patches. The code got a lot > smaller and better with the _ops struct. > > The new code can attach the assets to the targeted hub port as discussed > (using only "-0:1.0/port1" and only checking ehci-omap.0 descendants at > device_add() time), but the hub port device never probes, unless I > missed the point it's because it actually never binds to a driver, it's > a very unusual standalone logical device. That's right; it gets registered but it never binds. It doesn't need a driver because all the port-related activity is done by the hub driver. > If that's the case I could work around that by doing the probe() asset > stuff at device_add() time if there's no driver name on the device, but > actually I am not sure that's where we wanted to end up. > > Now we got so far as to succeed to associate regulator + clock assets to > the logical hub port device, isn't it that we want the assets to be > enabled and disabled according to hub port power state? In that case it > needs to go in the direction of calling device_asset helpers in the > hub.c code that handles enable and disable hub port power. Is this > sounding like the right way, or something else? I'm not so sure about this. Maybe we're trying to solve too many different kinds of problem at once. The original device asset scheme is fine if all you want to do is turn on the regulator when ehci-omap binds and turn it off when the driver unbinds. But if we want to go farther, maybe the device asset approach isn't the right way. In particular, we would like the regulator to get turned off and on by the port driver as part of its suspend/resume handling. The most straightforward way to do this is to modify the PM code in port.c. This would be specific to USB ports. I toyed around with the idea of a more general-purpose approach using "PM assets" that could hook into various PM callbacks, but it seemed to get too complicated. And besides, it only ended up looking like a way to put something into a PM domain without the driver's knowledge. So maybe something like Ming Lei's suggestion really would be best. We could add code specifically for regulators and clocks to port.c. Trying to write something that can work for all types of devices, not just USB ports, may be over-reaching. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c index bfcd397..52add03 100644 --- a/arch/arm/mach-omap2/board-omap4panda.c +++ b/arch/arm/mach-omap2/board-omap4panda.c @@ -144,6 +144,15 @@ static struct platform_device *panda_devices[] __initdata = { &btwilink_device, }; +static struct device_asset assets_ehci_omap0[] = { + { + .name = "reg-panda-smsc95xx", + .pre_probe = regulator_asset_default_preprobe, + .post_remove = regulator_asset_default_postremove, + }, + { } +}; + static const struct usbhs_omap_board_data usbhs_bdata __initconst = { .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY, .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED, @@ -151,12 +160,8 @@ static const struct usbhs_omap_board_data usbhs_bdata __initconst = { .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" }, + .reset_gpio_port[2] = -EINVAL, + .assets = assets_ehci_omap0, }; static void __init omap4_ehci_init(void) @@ -173,23 +178,76 @@ static void __init omap4_ehci_init(void) 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; - } + usbhs_init(&usbhs_bdata); +} - gpio_export(GPIO_HUB_POWER, 0); - gpio_export(GPIO_HUB_NRESET, 0); - gpio_set_value(GPIO_HUB_NRESET, 1); +/* + * hub_nreset also resets the ULPI PHY and is required after powering SMSC chip + * ULPI PHY is always powered... need to do reset once for both once + * hub_power enables a 3.3V regulator for (hub + eth) chip + * however there's no point having ULPI PHY in use alone + * since it's only connected to the (hub + eth) chip + */ - usbhs_init(&usbhs_bdata); +static struct regulator_init_data panda_hub = { + .constraints = { + .name = "vhub", + .valid_ops_mask = REGULATOR_CHANGE_STATUS, + }, +}; - /* enable power to hub */ - gpio_set_value(GPIO_HUB_POWER, 1); -} +static struct fixed_voltage_config panda_vhub = { + .supply_name = "vhub", + .microvolts = 3300000, + .gpio = GPIO_HUB_POWER, + .startup_delay = 70000, /* 70msec */ + .enable_high = 1, + .enabled_at_boot = 0, + .init_data = &panda_hub, +}; + +static struct platform_device omap_vhub_device = { + .name = "reg-fixed-voltage", + .id = 2, + .dev = { + .platform_data = &panda_vhub, + }, +}; + +static struct regulator_init_data panda_ulpireset = { + /* + * idea is that when operating ulpireset, regulator api will make + * sure that the hub+eth chip is powered, since it's the "parent" + */ + .supply_regulator = "vhub", /* we are a child of vhub */ + .constraints = { + /* + * this magic string associates us with ehci-omap.0 root hub + * when the root hub logical device is up, we will power + * and reset [ ULPI PHY + [ HUB + ETH ] ] + */ + .name = "reg-panda-smsc95xx", + .valid_ops_mask = REGULATOR_CHANGE_STATUS, + }, +}; + +static struct fixed_voltage_config panda_vulpireset = { + .supply_name = "reg-panda-smsc95xx", + .microvolts = 3300000, + .gpio = GPIO_HUB_NRESET, + .startup_delay = 70000, /* 70msec */ + .enable_high = 1, + .enabled_at_boot = 0, + .init_data = &panda_ulpireset, +}; + +static struct platform_device omap_vulpireset_device = { + .name = "reg-fixed-voltage", + .id = 3, + .dev = { + .platform_data = &panda_vulpireset, + }, +}; static struct omap_musb_board_data musb_board_data = { .interface_type = MUSB_INTERFACE_UTMI, @@ -504,6 +562,8 @@ static void __init omap4_panda_init(void) omap4_panda_i2c_init(); platform_add_devices(panda_devices, ARRAY_SIZE(panda_devices)); platform_device_register(&omap_vwlan_device); + platform_device_register(&omap_vhub_device); + platform_device_register(&omap_vulpireset_device); omap_serial_init(); omap_sdrc_init(NULL, NULL); omap4_twl6030_hsmmc_init(mmc); diff --git a/arch/arm/mach-omap2/usb-host.c b/arch/arm/mach-omap2/usb-host.c index 98f3287..2a0fdf9 100644 --- a/arch/arm/mach-omap2/usb-host.c +++ b/arch/arm/mach-omap2/usb-host.c @@ -501,6 +501,7 @@ void __init usbhs_init(const struct usbhs_omap_board_data *pdata) } ehci_data.phy_reset = pdata->phy_reset; ohci_data.es2_compatibility = pdata->es2_compatibility; + ehci_data.assets = pdata->assets; usbhs_data.ehci_data = &ehci_data; usbhs_data.ohci_data = &ohci_data; diff --git a/arch/arm/plat-omap/include/plat/usb.h b/arch/arm/plat-omap/include/plat/usb.h index 70acdee..6f6235e 100644 --- a/arch/arm/plat-omap/include/plat/usb.h +++ b/arch/arm/plat-omap/include/plat/usb.h @@ -36,6 +36,7 @@ struct usbhs_omap_board_data { unsigned es2_compatibility:1; unsigned phy_reset:1; + struct device_asset *assets; }; #ifdef CONFIG_ARCH_OMAP2PLUS @@ -44,6 +45,7 @@ struct ehci_hcd_omap_platform_data { enum usbhs_omap_port_mode port_mode[OMAP3_HS_USB_PORTS]; int reset_gpio_port[OMAP3_HS_USB_PORTS]; unsigned phy_reset:1; + struct device_asset *assets; }; struct ohci_hcd_omap_platform_data { diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c index 23cec57..6d57c9d 100644 --- a/drivers/mfd/omap-usb-host.c +++ b/drivers/mfd/omap-usb-host.c @@ -25,6 +25,7 @@ #include <linux/dma-mapping.h> #include <linux/spinlock.h> #include <linux/gpio.h> +#include <linux/device.h> #include <plat/cpu.h> #include <plat/usb.h> #include <linux/pm_runtime.h> @@ -136,7 +137,8 @@ static inline u8 usbhs_readb(void __iomem *base, u8 reg) static struct platform_device *omap_usbhs_alloc_child(const char *name, struct resource *res, int num_resources, void *pdata, - size_t pdata_size, struct device *dev) + size_t pdata_size, struct device *dev, + struct device_asset *assets) { struct platform_device *child; int ret; @@ -160,6 +162,7 @@ static struct platform_device *omap_usbhs_alloc_child(const char *name, goto err_alloc; } + child->dev.assets = assets; child->dev.dma_mask = &usbhs_dmamask; dma_set_coherent_mask(&child->dev, DMA_BIT_MASK(32)); child->dev.parent = dev; @@ -212,7 +215,7 @@ static int omap_usbhs_alloc_children(struct platform_device *pdev) resources[1] = *res; ehci = omap_usbhs_alloc_child(OMAP_EHCI_DEVICE, resources, 2, ehci_data, - sizeof(*ehci_data), dev); + sizeof(*ehci_data), dev, ehci_data->assets); if (!ehci) { dev_err(dev, "omap_usbhs_alloc_child failed\n"); @@ -237,7 +240,7 @@ static int omap_usbhs_alloc_children(struct platform_device *pdev) resources[1] = *res; ohci = omap_usbhs_alloc_child(OMAP_OHCI_DEVICE, resources, 2, ohci_data, - sizeof(*ohci_data), dev); + sizeof(*ohci_data), dev, NULL); if (!ohci) { dev_err(dev, "omap_usbhs_alloc_child failed\n"); ret = -ENOMEM;
This adds regulators which are controlled by the OMAP4 PandaBoard (ES)'s EHCI logical root hub existing. The regulators are made a device_asset of the EHCI logical root hub by passing them through the hsusb -> mfd path. Although the ehci-related platform_device is created at boot time, it is not instantiated until the ehci-hcd module is inserted if it is modular. Since the regulator is an asset of the ehci-omap.0 device, it's turned on during successful probe and off when the device is removed. Without power control, the ULPI PHY + SMSC9614 on the Panda eats 700-900mW all the time, which is around the same as the idle power of the SoC and rest of the board. This allows us to start off with it depowered, and only power it if the ehci-hcd module is inserted. When the module is removed, it's depowered again. Signed-off-by: Andy Green <andy.green@linaro.org> --- arch/arm/mach-omap2/board-omap4panda.c | 100 ++++++++++++++++++++++++++------ arch/arm/mach-omap2/usb-host.c | 1 arch/arm/plat-omap/include/plat/usb.h | 2 + drivers/mfd/omap-usb-host.c | 9 ++- 4 files changed, 89 insertions(+), 23 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html