Lines Matching +full:usb2 +full:- +full:3

1 // SPDX-License-Identifier: GPL-2.0+
3 * Setup platform devices needed by the Freescale multi-port host
4 * and/or dual-role USB controller modules based on the description
17 #include <linux/dma-mapping.h>
21 char *drivers[3]; /* drivers to instantiate for this mode */
28 .drivers = { "fsl-ehci", NULL, NULL, },
33 .drivers = { "fsl-usb2-otg", "fsl-ehci", "fsl-usb2-udc", },
38 .drivers = { "fsl-usb2-udc", NULL, NULL, },
84 const struct resource *res = ofdev->resource; in fsl_usb2_device_register()
85 unsigned int num = ofdev->num_resources; in fsl_usb2_device_register()
90 retval = -ENOMEM; in fsl_usb2_device_register()
94 pdev->dev.parent = &ofdev->dev; in fsl_usb2_device_register()
96 pdev->dev.coherent_dma_mask = ofdev->dev.coherent_dma_mask; in fsl_usb2_device_register()
98 if (!pdev->dev.dma_mask) { in fsl_usb2_device_register()
99 pdev->dev.dma_mask = &ofdev->dev.coherent_dma_mask; in fsl_usb2_device_register()
101 retval = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); in fsl_usb2_device_register()
116 device_set_of_node_from_dev(&pdev->dev, &ofdev->dev); in fsl_usb2_device_register()
138 * returns 3 for usb controller version 2.4 in usb_get_ver_info()
142 if (of_device_is_compatible(np, "fsl-usb2-dr")) { in usb_get_ver_info()
143 if (of_device_is_compatible(np, "fsl-usb2-dr-v1.6")) in usb_get_ver_info()
145 else if (of_device_is_compatible(np, "fsl-usb2-dr-v2.2")) in usb_get_ver_info()
147 else if (of_device_is_compatible(np, "fsl-usb2-dr-v2.4")) in usb_get_ver_info()
149 else if (of_device_is_compatible(np, "fsl-usb2-dr-v2.5")) in usb_get_ver_info()
158 if (of_device_is_compatible(np, "fsl,mpc5121-usb2-dr")) in usb_get_ver_info()
161 if (of_device_is_compatible(np, "fsl-usb2-mph")) { in usb_get_ver_info()
162 if (of_device_is_compatible(np, "fsl-usb2-mph-v1.6")) in usb_get_ver_info()
164 else if (of_device_is_compatible(np, "fsl-usb2-mph-v2.2")) in usb_get_ver_info()
166 else if (of_device_is_compatible(np, "fsl-usb2-mph-v2.4")) in usb_get_ver_info()
168 else if (of_device_is_compatible(np, "fsl-usb2-mph-v2.5")) in usb_get_ver_info()
179 struct device_node *np = ofdev->dev.of_node; in fsl_usb2_mph_dr_of_probe()
189 return -ENODEV; in fsl_usb2_mph_dr_of_probe()
191 match = of_match_device(fsl_usb2_mph_dr_of_match, &ofdev->dev); in fsl_usb2_mph_dr_of_probe()
193 return -ENODEV; in fsl_usb2_mph_dr_of_probe()
196 if (match->data) in fsl_usb2_mph_dr_of_probe()
197 memcpy(pdata, match->data, sizeof(data)); in fsl_usb2_mph_dr_of_probe()
203 if (of_device_is_compatible(np, "fsl-usb2-mph")) { in fsl_usb2_mph_dr_of_probe()
205 pdata->port_enables |= FSL_USB2_PORT0_ENABLED; in fsl_usb2_mph_dr_of_probe()
208 pdata->port_enables |= FSL_USB2_PORT1_ENABLED; in fsl_usb2_mph_dr_of_probe()
210 pdata->operating_mode = FSL_USB2_MPH_HOST; in fsl_usb2_mph_dr_of_probe()
212 pdata->invert_drvvbus = of_property_read_bool(np, "fsl,invert-drvvbus"); in fsl_usb2_mph_dr_of_probe()
213 pdata->invert_pwr_fault = of_property_read_bool(np, "fsl,invert-pwr-fault"); in fsl_usb2_mph_dr_of_probe()
216 pdata->operating_mode = dev_data->op_mode; in fsl_usb2_mph_dr_of_probe()
220 pdata->phy_mode = determine_usb_phy(prop); in fsl_usb2_mph_dr_of_probe()
221 pdata->controller_ver = usb_get_ver_info(np); in fsl_usb2_mph_dr_of_probe()
224 pdata->has_fsl_erratum_a007792 = in fsl_usb2_mph_dr_of_probe()
225 of_property_read_bool(np, "fsl,usb-erratum-a007792"); in fsl_usb2_mph_dr_of_probe()
226 pdata->has_fsl_erratum_a005275 = in fsl_usb2_mph_dr_of_probe()
227 of_property_read_bool(np, "fsl,usb-erratum-a005275"); in fsl_usb2_mph_dr_of_probe()
228 pdata->has_fsl_erratum_a005697 = in fsl_usb2_mph_dr_of_probe()
229 of_property_read_bool(np, "fsl,usb_erratum-a005697"); in fsl_usb2_mph_dr_of_probe()
230 pdata->has_fsl_erratum_a006918 = in fsl_usb2_mph_dr_of_probe()
231 of_property_read_bool(np, "fsl,usb_erratum-a006918"); in fsl_usb2_mph_dr_of_probe()
232 pdata->has_fsl_erratum_14 = in fsl_usb2_mph_dr_of_probe()
233 of_property_read_bool(np, "fsl,usb_erratum-14"); in fsl_usb2_mph_dr_of_probe()
239 pdata->check_phy_clk_valid = in fsl_usb2_mph_dr_of_probe()
240 of_property_read_bool(np, "phy-clk-valid"); in fsl_usb2_mph_dr_of_probe()
242 if (pdata->have_sysif_regs) { in fsl_usb2_mph_dr_of_probe()
243 if (pdata->controller_ver == FSL_USB_VER_NONE) { in fsl_usb2_mph_dr_of_probe()
244 dev_warn(&ofdev->dev, "Could not get controller version\n"); in fsl_usb2_mph_dr_of_probe()
245 return -ENODEV; in fsl_usb2_mph_dr_of_probe()
249 for (i = 0; i < ARRAY_SIZE(dev_data->drivers); i++) { in fsl_usb2_mph_dr_of_probe()
250 if (!dev_data->drivers[i]) in fsl_usb2_mph_dr_of_probe()
253 dev_data->drivers[i], idx); in fsl_usb2_mph_dr_of_probe()
255 dev_err(&ofdev->dev, "Can't register usb device\n"); in fsl_usb2_mph_dr_of_probe()
271 device_for_each_child(&ofdev->dev, NULL, __unregister_subdev); in fsl_usb2_mph_dr_of_remove()
279 #define GC_PPP (1 << 3) /* Inv. Port Power Polarity */
285 #define PHYCTRL_PHYE (1 << 4) /* On-chip UTMI PHY enable */
286 #define PHYCTRL_BSENH (1 << 3) /* Bit Stuff Enable High */
293 struct fsl_usb2_platform_data *pdata = dev_get_platdata(&pdev->dev); in fsl_usb2_mpc5121_init()
297 clk = devm_clk_get(pdev->dev.parent, "ipg"); in fsl_usb2_mpc5121_init()
299 dev_err(&pdev->dev, "failed to get clk\n"); in fsl_usb2_mpc5121_init()
304 dev_err(&pdev->dev, "failed to enable clk\n"); in fsl_usb2_mpc5121_init()
307 pdata->clk = clk; in fsl_usb2_mpc5121_init()
309 if (pdata->phy_mode == FSL_USB2_PHY_UTMI_WIDE) { in fsl_usb2_mpc5121_init()
312 if (pdata->invert_drvvbus) in fsl_usb2_mpc5121_init()
315 if (pdata->invert_pwr_fault) in fsl_usb2_mpc5121_init()
318 out_be32(pdata->regs + ISIPHYCTRL, PHYCTRL_PHYE | PHYCTRL_PXE); in fsl_usb2_mpc5121_init()
319 out_be32(pdata->regs + USBGENCTRL, reg); in fsl_usb2_mpc5121_init()
326 struct fsl_usb2_platform_data *pdata = dev_get_platdata(&pdev->dev); in fsl_usb2_mpc5121_exit()
328 pdata->regs = NULL; in fsl_usb2_mpc5121_exit()
330 if (pdata->clk) in fsl_usb2_mpc5121_exit()
331 clk_disable_unprepare(pdata->clk); in fsl_usb2_mpc5121_exit()
350 { .compatible = "fsl-usb2-mph", .data = &fsl_usb2_mpc8xxx_pd, },
351 { .compatible = "fsl-usb2-dr", .data = &fsl_usb2_mpc8xxx_pd, },
353 { .compatible = "fsl,mpc5121-usb2-dr", .data = &fsl_usb2_mpc5121_pd, },
361 .name = "fsl-usb2-mph-dr",