[PATCH 5/5] Add information about the new DT device name
Add some information about the new device name to the DT documentation. Signed-off-by: Rolf Peukert --- Documentation/devicetree/bindings/usb/omap-usb.txt | 35 ++ 1 file changed, 35 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt b/Documentation/devicetree/bindings/usb/omap-usb.txt index 38d9bb8..cf98f61 100644 --- a/Documentation/devicetree/bindings/usb/omap-usb.txt +++ b/Documentation/devicetree/bindings/usb/omap-usb.txt @@ -78,3 +78,38 @@ omap_dwc3 { ranges; }; +AM35x MUSB GLUE + - compatible : Should be "ti,am35x-musb" + - ti,hwmods : must be "am35x_otg_hs" + - multipoint : Should be "1" indicating the musb controller supports + multipoint. This is a MUSB configuration-specific setting. + - num-eps : Specifies the number of endpoints. This is also a + MUSB configuration-specific setting. Should be set to "16" + - ram-bits : Specifies the ram address size. Should be set to "12" + - interface-type : Should be set to "1". (The AM35xx SOCs feature an + integrated phy, connected via UTMI+) + - mode : Should be "3" to represent OTG. "1" signifies HOST and "2" + represents PERIPHERAL. + - power : Should be "50". This signifies the controller can supply up to + 100mA when operating in host mode. + +SOC specific device node entry +am35x_otg_hs: am35x_otg_hs@5c04 { + compatible = "ti,am35x-musb"; + ti,hwmods = "am35x_otg_hs"; + clocks = <&hsotgusb_ick_am35xx>, <&hsotgusb_fck_am35xx>; + clock-names = "ick", "fck"; + reg = <0x5c04 0x1000>; + interrupts = <71>; + interrupt-names = "mc"; +}; + +Board specific device node entry +&am35x_otg_hs { + mode = <1>; + interface-type = <1>; + multipoint = <1>; + num-eps = <16>; + ram-bits = <12>; + power = <50>; +}; -- 2.4.10 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/5] Use new MUSB device name in AM3517 device tree.
Use new MUSB device name in AM3517 device tree and add name declarations for interface and function clock, so the am35x drivers clk_get() calls can find them. Signed-off-by: Rolf Peukert --- arch/arm/boot/dts/am3517.dtsi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/am3517.dtsi b/arch/arm/boot/dts/am3517.dtsi index 0b1c07f5..10838b5 100644 --- a/arch/arm/boot/dts/am3517.dtsi +++ b/arch/arm/boot/dts/am3517.dtsi @@ -17,9 +17,11 @@ ocp { am35x_otg_hs: am35x_otg_hs@5c04 { - compatible = "ti,omap3-musb"; + compatible = "ti,am35x-musb"; ti,hwmods = "am35x_otg_hs"; status = "disabled"; + clocks = <&hsotgusb_ick_am35xx>, <&hsotgusb_fck_am35xx>; + clock-names = "ick", "fck"; reg = <0x5c04 0x1000>; interrupts = <71>; interrupt-names = "mc"; -- 2.4.10 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/5] Add device tree support for M-USB on AM35xx SOCs
Add a function that sets up necessary data structures. In older kernels this was done in a board_ file. To support initialization via a DT, this now needs to be included in the probe() function. Also declare a new device 'compatible' name (am35x-musb) to differentiate it from omap3-musb. Signed-off-by: Rolf Peukert --- drivers/usb/musb/am35x.c | 73 1 file changed, 73 insertions(+) diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index c41fe58..3c1477a 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c @@ -462,6 +462,59 @@ static const struct platform_device_info am35x_dev_info = { .dma_mask = DMA_BIT_MASK(32), }; +static struct musb_hdrc_platform_data *am35x_get_config( + struct platform_device *pdev) +{ + struct musb_hdrc_platform_data *pdata; + struct omap_musb_board_data *bdata; + struct musb_hdrc_config *config; + struct device_node *np; + int val, ret; + + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + goto err_out; + + bdata = devm_kzalloc(&pdev->dev, sizeof(*bdata), GFP_KERNEL); + if (!bdata) + goto err_pdata; + + config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL); + if (!config) + goto err_bdata; + + bdata->clear_irq = am35x_musb_clear_irq; + bdata->reset = am35x_musb_reset; + bdata->set_mode = am35x_set_mode; + bdata->set_phy_power = am35x_musb_phy_power; + + pdata->board_data = bdata; + pdata->config = config; + + /* Read settings from device tree */ + np = pdev->dev.of_node; + if (np) { + of_property_read_u32(np, "mode", (u32 *)&pdata->mode); + of_property_read_u32(np, "interface-type", + (u32 *)&bdata->interface_type); + of_property_read_u32(np, "num-eps", (u32 *)&config->num_eps); + of_property_read_u32(np, "ram-bits", (u32 *)&config->ram_bits); + of_property_read_u32(np, "power", (u32 *)&pdata->power); + + ret = of_property_read_u32(np, "multipoint", &val); + if (!ret && val) + config->multipoint = true; + } + return pdata; + +err_bdata: + devm_kfree(&pdev->dev, bdata); +err_pdata: + devm_kfree(&pdev->dev, pdata); +err_out: + return NULL; +} + static int am35x_probe(struct platform_device *pdev) { struct musb_hdrc_platform_data *pdata = dev_get_platdata(&pdev->dev); @@ -479,6 +532,12 @@ static int am35x_probe(struct platform_device *pdev) goto err0; } + if (!pdata) { + pdata = am35x_get_config(pdev); + if (!pdata) + goto err1; + } + phy_clk = clk_get(&pdev->dev, "fck"); if (IS_ERR(phy_clk)) { dev_err(&pdev->dev, "failed to get PHY clock\n"); @@ -548,6 +607,7 @@ err4: clk_put(phy_clk); err3: +err1: kfree(glue); err0: @@ -615,12 +675,25 @@ static int am35x_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(am35x_pm_ops, am35x_suspend, am35x_resume); +#ifdef CONFIG_OF +static const struct of_device_id am35x_id_table[] = { + { + .compatible = "ti,am35x-musb" + }, + {}, +}; +MODULE_DEVICE_TABLE(of, am35x_id_table); +#endif + static struct platform_driver am35x_driver = { .probe = am35x_probe, .remove = am35x_remove, .driver = { .name = "musb-am35x", .pm = &am35x_pm_ops, +#ifdef CONFIG_OF + .of_match_table = of_match_ptr(am35x_id_table), +#endif }, }; -- 2.4.10 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/5] Export am35x helper functions
To be able to call these four helper functions from a M-USB AM35x driver module, their name symbols need to be exported. Signed-off-by: Rolf Peukert --- arch/arm/mach-omap2/omap_phy_internal.c | 4 1 file changed, 4 insertions(+) diff --git a/arch/arm/mach-omap2/omap_phy_internal.c b/arch/arm/mach-omap2/omap_phy_internal.c index 8e90356..648a60f 100644 --- a/arch/arm/mach-omap2/omap_phy_internal.c +++ b/arch/arm/mach-omap2/omap_phy_internal.c @@ -82,6 +82,7 @@ void am35x_musb_reset(void) regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); } +EXPORT_SYMBOL(am35x_musb_reset); void am35x_musb_phy_power(u8 on) { @@ -120,6 +121,7 @@ void am35x_musb_phy_power(u8 on) omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2); } } +EXPORT_SYMBOL(am35x_musb_phy_power); void am35x_musb_clear_irq(void) { @@ -130,6 +132,7 @@ void am35x_musb_clear_irq(void) omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR); regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); } +EXPORT_SYMBOL(am35x_musb_clear_irq); void am35x_set_mode(u8 musb_mode) { @@ -152,3 +155,4 @@ void am35x_set_mode(u8 musb_mode) omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2); } +EXPORT_SYMBOL(am35x_set_mode); -- 2.4.10 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/5] Make am35x helper function declarations accessible
To be able to call these four helper functions from the M-USB AM35xx glue code, their declarations need to be moved to a header file in the kernels include hierarchy. Signed-off-by: Rolf Peukert --- arch/arm/mach-omap2/usb.h | 5 - include/linux/platform_data/usb-omap.h | 5 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-omap2/usb.h b/arch/arm/mach-omap2/usb.h index 3395365..8b0cdf5 100644 --- a/arch/arm/mach-omap2/usb.h +++ b/arch/arm/mach-omap2/usb.h @@ -63,8 +63,3 @@ struct usbhs_phy_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); -extern void am35x_musb_clear_irq(void); -extern void am35x_set_mode(u8 musb_mode); diff --git a/include/linux/platform_data/usb-omap.h b/include/linux/platform_data/usb-omap.h index fa579b4..328e899 100644 --- a/include/linux/platform_data/usb-omap.h +++ b/include/linux/platform_data/usb-omap.h @@ -86,3 +86,8 @@ enum musb_interface { MUSB_INTERFACE_ULPI, MUSB_INTERFACE_UTMI }; + +extern void am35x_musb_reset(void); +extern void am35x_musb_phy_power(u8 on); +extern void am35x_musb_clear_irq(void); +extern void am35x_set_mode(u8 musb_mode); -- 2.4.10 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/5] Device tree support for AM35xx M-USB driver
The M-USB drivers glue code for AM35xx SOCs does not yet support device trees. In legacy kernels, it was left to the respective board_ file to set up some necessary data structures before calling am35x_probe(). To support initialization using a DT, this now needs to be done in am35x.c. These data structures including a set of four pointers to CPU-specific helper functions from the mach-omap2 directory. Unfortunately those functions are only declared locally under arch/arm/mach-omap2/, and they can not easily be moved over to am35x.c. (While they just set a few bits in some system control module registers, they call functions from control.c to access the SCM. These control.c functions are also declared locally in mach-omap2 and not exported, and use some static variables and several other local include files.) So if we want these four functions to be accessible from the driver glue code, their declarations have to be moved to the include/ hierarchy and their names need to be exported. This makes it possible to use the am35x M-USB driver as a kernel module. The patch defines a new device 'compatible' name (am35x-musb) to differentiate it from omap3-musb. It also adds clock name declarations for interface and function clock to the device tree, so the am35x glue code's clk_get() calls can find them. Rolf Peukert (5): Make am35x helper function declarations accessible Export am35x helper functions Add device tree support for M-USB on AM35xx SOCs Use new MUSB device name in AM3517 device tree. Add some information about the new DT device name Documentation/devicetree/bindings/usb/omap-usb.txt | 35 +++ arch/arm/boot/dts/am3517.dtsi | 4 +- arch/arm/mach-omap2/omap_phy_internal.c| 4 ++ arch/arm/mach-omap2/usb.h | 5 -- drivers/usb/musb/am35x.c | 73 ++ include/linux/platform_data/usb-omap.h | 5 ++ 6 files changed, 120 insertions(+), 6 deletions(-) -- 2.4.10 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] ARM: AM35xx: Add M-USB clk device ID
On 13.10.2015 10:15, Tero Kristo wrote: > On 10/12/2015 06:22 PM, Rolf Peukert wrote: >> The glue code in drivers/usb/musb/am35x.c calls clk_get() to get its >> interface and function clocks for the M-USB controller. These calls fail >> in the current kernel. This patch adds clock definitions containing the >> device ID to the list in clk-3xxx.c, so the calls to clk_get() in >> am35x.c can succeed. >> >> Signed-off-by: Rolf Peukert >> >> --- >> drivers/clk/ti/clk-3xxx.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/drivers/clk/ti/clk-3xxx.c b/drivers/clk/ti/clk-3xxx.c >> index 8831e1a..b635deb 100644 >> --- a/drivers/clk/ti/clk-3xxx.c >> +++ b/drivers/clk/ti/clk-3xxx.c >> @@ -507,7 +507,9 @@ static struct ti_dt_clk am35xx_clks[] = { >> DT_CLK("davinci_mdio.0", NULL, "emac_fck"), >> DT_CLK("vpfe-capture", "master", "vpfe_ick"), >> DT_CLK("vpfe-capture", "slave", "vpfe_fck"), >> +DT_CLK("5c04.am35x_otg_hs", "ick", "hsotgusb_ick_am35xx"), >> DT_CLK(NULL, "hsotgusb_ick", "hsotgusb_ick_am35xx"), >> +DT_CLK("5c04.am35x_otg_hs", "fck", "hsotgusb_fck_am35xx"), >> DT_CLK(NULL, "hsotgusb_fck", "hsotgusb_fck_am35xx"), >> DT_CLK(NULL, "hecc_ck", "hecc_ck"), >> DT_CLK(NULL, "uart4_ick", "uart4_ick_am35xx"), >> > > Adding clock aliases should be avoided, isn't there any other way to fix > this issue? Like adding clocks = <&xyz> references under the DT node? > > -Tero > Yes, I just tried adding the lines clocks = <&hsotgusb_ick_am35xx>, <&hsotgusb_fck_am35xx>; clock-names = "ick", "fck"; to am3517.dtsi and this works too. But wouldn't this mean the driver will not work anymore in kernels without DT support? (my first idea was to change the clk_get calls in am35x.c, but Felipe Balbi objected) Best regards, Rolf -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] ARM: AM35xx: Add M-USB clk device ID
The glue code in drivers/usb/musb/am35x.c calls clk_get() to get its interface and function clocks for the M-USB controller. These calls fail in the current kernel. This patch adds clock definitions containing the device ID to the list in clk-3xxx.c, so the calls to clk_get() in am35x.c can succeed. Signed-off-by: Rolf Peukert --- drivers/clk/ti/clk-3xxx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/clk/ti/clk-3xxx.c b/drivers/clk/ti/clk-3xxx.c index 8831e1a..b635deb 100644 --- a/drivers/clk/ti/clk-3xxx.c +++ b/drivers/clk/ti/clk-3xxx.c @@ -507,7 +507,9 @@ static struct ti_dt_clk am35xx_clks[] = { DT_CLK("davinci_mdio.0", NULL, "emac_fck"), DT_CLK("vpfe-capture", "master", "vpfe_ick"), DT_CLK("vpfe-capture", "slave", "vpfe_fck"), + DT_CLK("5c04.am35x_otg_hs", "ick", "hsotgusb_ick_am35xx"), DT_CLK(NULL, "hsotgusb_ick", "hsotgusb_ick_am35xx"), + DT_CLK("5c04.am35x_otg_hs", "fck", "hsotgusb_fck_am35xx"), DT_CLK(NULL, "hsotgusb_fck", "hsotgusb_fck_am35xx"), DT_CLK(NULL, "hecc_ck", "hecc_ck"), DT_CLK(NULL, "uart4_ick", "uart4_ick_am35xx"), -- 2.3.6 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC] AM35xx glue code for M-USB driver
Hi Felipe, On 07.10.2015 18:22, Felipe Balbi wrote: [...] b) The M-USB port on our board is wired as host only. If a device is unplugged, the driver normally goes into some idle state and waits for an ID signal change. But on our board that never happens. >>> >>> did you route ID pin anywhere ? I hope you tied it to ground. >> >> I think so. I'll double-check that. > > cool, thanks. The ID pin was not connected, it's tied to ground now, but still the same behaviour. But I can keep it from entering the musb_try_idle function by deactivating the vbus timeout. This can be done from userspace, so we don't need the additional if-statements in the code. >> [...] + /* Set defaults */ + config->num_eps = 16; + config->ram_bits = 12; + config->multipoint = true; >>> >>> all of these are board-specific. >>> + + bdata->interface_type = MUSB_INTERFACE_UTMI; + bdata->mode = MUSB_OTG; + bdata->power = 500; + bdata->extvbus = 1; >>> >>> so are these. OK, if everything is declared in the device tree, we don't need to set default values here. Regarding the four am35x_... functions from omap_phy_internal.c, it's not easy to move them over to am35x.c. While they just set a few bits in some system control module registers, they call functions from control.c to access the SCM. The control.c functions are not exported either (and use some static variables and also local include files from mach-omap2). >> [...] + phy_clk = clk_get(&pdev->dev, "hsotgusb_fck"); >>> >>> why did you change the clock name ? That shouldn't be necessary. >> >> I did get "failed to get PHY clock" and "failed to get clock" >> messages. > > right, this a bug elsewhere. Drivers shouldn't care about the exact > clock name ;-) > The corresponding clock declaration seems to be in drivers/clk/ti/clk-3xxx.c: DT_CLK(NULL, "hsotgusb_ick", "hsotgusb_ick_am35xx"), DT_CLK(NULL, "hsotgusb_fck", "hsotgusb_fck_am35xx"), When I add two more lines there, DT_CLK("5c04.am35x_otg_hs", "ick", "hsotgusb_ick_am35xx"), DT_CLK("5c04.am35x_otg_hs", "fck", "hsotgusb_fck_am35xx"), the "ick" and "fck" clocks are found. It doesn't work without the address in the device name, and not with just "musb-am35x" either. Still, all other device names in that file look simpler, and I'm wondering if I forgot a proper name declaration somewhere else? Best regards, Rolf -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: AM37x unable to drive output of some gpio lines (works with 2.6.37)
On 09.10.2015 02:54, Ladislav Michl wrote: > Hi there! > > on custom AM37x board running 2.6.37 this was enough to enable gpio 67: > echo 71 > /sys/class/gpio/export > echo out > /sys/class/gpio/gpio71/direction > echo 1 > /sys/class/gpio/gpio71/value > > However, with DT configured linux-4.2 compiled using omap2plus_defconfig > this no longer works. [...] Is some other device driver using these pins? Pins 70 and 71 could be DSS or UART1. Maybe you need to set them to "disabled" in your DT. Best regards, Rolf -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC] AM35xx glue code for M-USB driver
On 07.10.2015 14:15, kbuild test robot wrote: > Hi Rolf, > > [auto build test ERROR on v4.3-rc4 -- if it's inappropriate base, please > ignore] > > config: arm-omap2plus_defconfig (attached as .config) > reproduce: > wget > https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross > -O ~/bin/make.cross > chmod +x ~/bin/make.cross > # save the attached .config to linux build tree > make.cross ARCH=arm > > All errors (new ones prefixed by >>): > >>> ERROR: "am35x_musb_reset" [drivers/usb/musb/am35x.ko] undefined! >>> ERROR: "am35x_set_mode" [drivers/usb/musb/am35x.ko] undefined! >>> ERROR: "am35x_musb_clear_irq" [drivers/usb/musb/am35x.ko] undefined! >>> ERROR: "am35x_musb_phy_power" [drivers/usb/musb/am35x.ko] undefined! Sorry, forgot to test it as a module. Guess I'll have to add some EXPORT_SYMBOL lines. Best regards, Rolf -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC] AM35xx glue code for M-USB driver
Hi Felipe, thank you for your reply. On 07.10.2015 15:59, Felipe Balbi wrote: > > Hi, > > (please sure you also Cc linux-...@vger.kernel.org for MUSB patches) > > Rolf Peukert writes: [...] >> b) The M-USB port on our board is wired as host only. If a device is >> unplugged, the driver normally goes into some idle state and waits for >> an ID signal change. But on our board that never happens. > > did you route ID pin anywhere ? I hope you tied it to ground. I think so. I'll double-check that. [...] >> +/* Set defaults */ >> +config->num_eps = 16; >> +config->ram_bits = 12; >> +config->multipoint = true; > > all of these are board-specific. > >> + >> +bdata->interface_type = MUSB_INTERFACE_UTMI; >> +bdata->mode = MUSB_OTG; >> +bdata->power = 500; >> +bdata->extvbus = 1; > > so are these. The AM3517/05 has an internal phy, so some of these are predetermined. You're right about mode and power. [...] >> +phy_clk = clk_get(&pdev->dev, "hsotgusb_fck"); > > why did you change the clock name ? That shouldn't be necessary. I did get "failed to get PHY clock" and "failed to get clock" messages. I'll do some more testing and see if I can get by with less changes. Best regards, Rolf -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC] AM35xx glue code for M-USB driver
Hi, we're running a 4.x kernel on a board with an AM3505 CPU and would like to use device trees. The AM35xx glue code for the M-USB controller didn't support configuration from a DT yet. I now got it working somehow, but I'm not sure if I'm doing it the correct way. So this post is not meant as a patch submission, but more as a request for comments or help. In the older kernel we were using before (3.2.x), some data structures were set up in the respective board file and then passed to the function am35x_probe(). For the use with DT, I added the function am35x_get_config, which sets up these data structures with default values and then tries to read settings from the DT. The device .compatible declaration is now "ti,am35x-musb", so it's separate from "ti,omap3-musb" (as used in omap2430.c). Now the two things I'm not so sure about: a) We needed to set pointers to machine-specific functions like am35x_musb_clear_irq etc. These functions are implemented in arch/arm/mach-omap2/omap_phy_internal.c, and declared in arch/arm/mach-omap2/usb.h. As this header file can't be included easily from am35x.c, I moved the declarations to include/linux/platform_data/usb-omap.h. I hope that's OK, but would be happy about suggestions. b) The M-USB port on our board is wired as host only. If a device is unplugged, the driver normally goes into some idle state and waits for an ID signal change. But on our board that never happens. So I added two checks for MUSB_OTG mode to support our hardware. Then I noticed similar code was removed from this file three years ago (commit 032ec49f5351e9cb242b1a1c367d14415043ab95), and I don't know if these lines might break something on other hardware. Best regards, Rolf --- Index: linux4/drivers/usb/musb/am35x.c === --- linux4.orig/drivers/usb/musb/am35x.c +++ linux4/drivers/usb/musb/am35x.c @@ -188,6 +188,10 @@ static void am35x_musb_try_idle(struct m { static unsigned long last_timer; + /* do not try if not in OTG mode */ + if (musb->port_mode != MUSB_OTG) + return; + if (timeout == 0) timeout = jiffies + msecs_to_jiffies(3); @@ -323,8 +327,9 @@ eoi: musb_writel(reg_base, USB_END_OF_INTR_REG, 0); } - /* Poll for ID change */ - if (musb->xceiv->otg->state == OTG_STATE_B_IDLE) + /* Poll for ID change (in OTG mode only) */ + if (musb->port_mode == MUSB_OTG && + musb->xceiv->otg->state == OTG_STATE_B_IDLE) mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); spin_unlock_irqrestore(&musb->lock, flags); @@ -458,6 +463,70 @@ static const struct platform_device_info .dma_mask = DMA_BIT_MASK(32), }; +static struct musb_hdrc_platform_data * +am35x_get_config(struct platform_device *pdev) +{ + struct musb_hdrc_platform_data *pdata; + struct omap_musb_board_data *bdata; + struct musb_hdrc_config *config; + struct device_node *np; + int val, ret; + + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + goto err_out; + + bdata = devm_kzalloc(&pdev->dev, sizeof(*bdata), GFP_KERNEL); + if (!bdata) + goto err_pdata; + + config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL); + if (!config) + goto err_bdata; + + /* Set defaults */ + config->num_eps = 16; + config->ram_bits = 12; + config->multipoint = true; + + bdata->interface_type = MUSB_INTERFACE_UTMI; + bdata->mode = MUSB_OTG; + bdata->power = 500; + bdata->extvbus = 1; + bdata->set_phy_power = am35x_musb_phy_power; + bdata->clear_irq = am35x_musb_clear_irq; + bdata->set_mode = am35x_set_mode; + bdata->reset = am35x_musb_reset; + + pdata->mode = MUSB_OTG; + pdata->power = 250; + pdata->board_data = bdata; + pdata->config = config; + + /* Read settings from device tree */ + np = pdev->dev.of_node; + if (np) { + of_property_read_u32(np, "mode", (u32 *)&pdata->mode); + of_property_read_u32(np, "interface-type", + (u32 *)&bdata->interface_type); + of_property_read_u32(np, "num-eps", (u32 *)&config->num_eps); + of_property_read_u32(np, "ram-bits", (u32 *)&config->ram_bits); + of_property_read_u32(np, "power", (u32 *)&pdata->power); + + ret = of_property_read_u32(np, "multipoint", &val); + if (!ret && val) + config->multipoint = true; + } + return pdata; + +err_bdata: + kfree(bdata); +err_pdata: + kfree(pdata); +err_out: + return NULL; +} + static int am35x_probe(struct platform_device *pdev) { struct musb_hdrc_platform_data *pdata = dev_get_platdata(&pdev->dev); @@ -475,14 +544,20 @@ st