USB: musb-new: omap2430: Prep driver for Peripheral support.
Subsystems (3)
PATCH v2 1/2 USB: musb-new: omap2430: Prep driver for Peripheral support.
The omap2430 driver only currently supports host only. In preparation for supporting peripheral mode, this patch makes the driver support only the host by creating a ofdata_to_platdata function host/peripheral agnostic with a host helper version.
---
V2: No Changes
drivers/usb/musb-new/omap2430.c +32 -34
@@ -137,6 +137,12 @@ const struct musb_platform_ops omap2430_ops = { #if CONFIG_IS_ENABLED(DM_USB) +static const struct udevice_id omap2430_musb_ids[] = { + { .compatible = "ti,omap3-musb" }, + { .compatible = "ti,omap4-musb" }, + { } +}; + struct omap2430_musb_platdata { void *base; void *ctrl_mod_base;
@@ -190,20 +196,6 @@ static int omap2430_musb_ofdata_to_platdata(struct udevice *dev)return -ENOENT ; } -#if 0 /* In a perfect world, mode would be set to OTG, mode 3 from DT */ - platdata->plat.mode =fdtdec_get_int (fdt, node, -"mode" ,-1 ); -if (platdata->plat.mode <0 ) { -pr_err ("MUSB mode DT entry missing\n" ); -return -ENOENT ; - } -#else /* MUSB_OTG, it doesn't work */ -#ifdef CONFIG_USB_MUSB_HOST /* Host seems to be the only option that works */ - platdata->plat.mode =MUSB_HOST ; -#else /* For that matter, MUSB_PERIPHERAL doesn't either */ - platdata->plat.mode =MUSB_PERIPHERAL ; -#endif -#endif platdata->otg_board_data.dev = dev; platdata->plat.config = &platdata->musb_config; platdata->plat.platform_ops = &omap2430_ops;
@@ -211,11 +203,10 @@ static int omap2430_musb_ofdata_to_platdata(struct udevice *dev)return 0 ; } +#ifdef CONFIG_USB_MUSB_HOST static int omap2430_musb_probe (struct udevice *dev) { -#ifdef CONFIG_USB_MUSB_HOST struct musb_host_data *host =dev_get_priv (dev); -#endif struct omap2430_musb_platdata *platdata =dev_get_platdata (dev);struct usb_bus_priv *priv =dev_get_uclass_priv (dev);struct omap_musb_board_data *otg_board_data;
@@ -226,7 +217,6 @@ static int omap2430_musb_probe(struct udevice *dev) otg_board_data = &platdata->otg_board_data; -#ifdef CONFIG_USB_MUSB_HOST host->host =musb_init_controller (&platdata->plat, (struct device *)otg_board_data, platdata->base);
@@ -235,11 +225,7 @@ static int omap2430_musb_probe(struct udevice *dev) } ret =musb_lowlevel_init (host); -#else - ret =musb_register (&platdata->plat, - (struct device *)otg_board_data, - platdata->base); -#endif +return ret; }
@@ -252,28 +238,40 @@ static int omap2430_musb_remove(struct udevice *dev)return 0 ; } -static const struct udevice_id omap2430_musb_ids[] = { - { .compatible ="ti,omap3-musb" }, - { .compatible ="ti,omap4-musb" }, - { } -}; +#if CONFIG_IS_ENABLED (OF_CONTROL ) +static int omap2430_musb_host_ofdata_to_platdata (struct udevice *dev) +{ +struct ti_musb_platdata *platdata =dev_get_platdata (dev); +const void *fdt = gd->fdt_blob; +int node =dev_of_offset (dev); +int ret; + + ret =omap2430_musb_ofdata_to_platdata (dev); +if (ret) { +pr_err ("platdata dt parse error\n" ); +return ret; + } + + platdata->plat.mode =MUSB_HOST ; + +return 0 ; +} +#endif U_BOOT_DRIVER (omap2430_musb) = { .name ="omap2430-musb" , -#ifdef CONFIG_USB_MUSB_HOST .id =UCLASS_USB , -#else - .id =UCLASS_USB_GADGET_GENERIC , -#endif .of_match = omap2430_musb_ids, - .ofdata_to_platdata = omap2430_musb_ofdata_to_platdata, +#if CONFIG_IS_ENABLED(OF_CONTROL) + .ofdata_to_platdata = omap2430_musb_host_ofdata_to_platdata, +#endif .probe = omap2430_musb_probe, .remove = omap2430_musb_remove, -#ifdef CONFIG_USB_MUSB_HOST .ops = &musb_usb_ops, -#endif .platdata_auto_alloc_size =sizeof (struct omap2430_musb_platdata ), .priv_auto_alloc_size =sizeof (struct musb_host_data ), }; +#endif +#endif /* CONFIG_IS_ENABLED(DM_USB) */
Signature · 1 line
2.17.1
PATCH v2 2/2 USB: musb-new: omap2430: Add hooks for Peripheral support.
Borrowing from the updates to ti-musb.c, this glue layer checks to see if the MUSB controller is gadget or host. Going under the assumpution there is only one MUSB controller, this only builds either the host probe or the gadget probe based on the device tree added by -u-boot.dtsi. OTG would be preferred, but it doesn't appear to be working yet.
---
V2: Support MISC device to read device tree to determine host or peripheral mode.
arch/arm/dts/logicpd-torpedo-37xx-devkit-u-boot.dtsi +3 -0
@@ -20,3 +20,6 @@ status = "disabled"; }; +&usb_otg_hs { + dr_mode = "host"; +};
configs/omap3_logic_defconfig +1 -1
@@ -21,7 +21,6 @@ CONFIG_SYS_PROMPT="OMAP Logic # " CONFIG_CMD_SPL=y CONFIG_CMD_SPL_NAND_OFS=0x240000 CONFIG_CMD_SPL_WRITE_SIZE=0x20000 -# CONFIG_CMD_EEPROM is not set # CONFIG_CMD_FLASH is not set CONFIG_CMD_NAND=y CONFIG_CMD_NAND_LOCK_UNLOCK=y
@@ -37,6 +36,7 @@ CONFIG_ENV_IS_IN_NAND=y CONFIG_SPL_DM=y CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_DM_I2C=y +CONFIG_MISC=y CONFIG_DM_MMC=y CONFIG_MMC_OMAP_HS=y CONFIG_MMC_OMAP36XX_PINS=y
drivers/usb/musb-new/omap2430.c +126 -9
165 lines not on this page · raw message
Signature · 1 line
2.17.1