/** * usbhs_omap_remove - shutdown processing for UHH & TLL HCDs * @pdev: USB Host Controller being removed * * Reverses the effect of usbhs_omap_probe(). */ static int __devexit usbhs_omap_remove(struct platform_device *pdev) { struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev); omap_usbhs_deinit(&pdev->dev); iounmap(omap->uhh_base); clk_put(omap->usb_host_hs_hsic480m_p2_clk); clk_put(omap->usb_host_hs_hsic60m_p2_clk); clk_put(omap->usb_host_hs_hsic480m_p1_clk); clk_put(omap->usb_host_hs_hsic60m_p1_clk); clk_put(omap->init_60m_fclk); clk_put(omap->usbhost_p2_fck); clk_put(omap->usbhost_p1_fck); clk_put(omap->xclk60mhsp2_ck); clk_put(omap->utmi_p2_fck); clk_put(omap->xclk60mhsp1_ck); clk_put(omap->utmi_p1_fck); clk_put(omap->ehci_logic_fck); if (cpu_is_omap54xx()) { clk_put(omap->usbhost_p3_fck); clk_put(omap->usb_host_hs_hsic480m_p3_clk); clk_put(omap->usb_host_hs_hsic60m_p3_clk); } pm_runtime_disable(&pdev->dev); kfree(omap); return 0; }
/** * usbhs_omap_remove - shutdown processing for UHH & TLL HCDs * @pdev: USB Host Controller being removed * * Reverses the effect of usbhs_omap_probe(). */ static int __devexit usbhs_omap_remove(struct platform_device *pdev) { struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev); omap_usbhs_deinit(&pdev->dev); iounmap(omap->tll_base); iounmap(omap->uhh_base); clk_put(omap->init_60m_fclk); clk_put(omap->usbtll_p2_fck); clk_put(omap->usbhost_p2_fck); clk_put(omap->usbtll_p1_fck); clk_put(omap->usbhost_p1_fck); clk_put(omap->xclk60mhsp2_ck); clk_put(omap->utmi_p2_fck); clk_put(omap->xclk60mhsp1_ck); clk_put(omap->utmi_p1_fck); pm_runtime_disable(&pdev->dev); kfree(omap); return 0; }
/** * usbhs_omap_probe - initialize TI-based HCDs * * Allocates basic resources for this USB host controller. */ static int __devinit usbhs_omap_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct usbhs_omap_platform_data *pdata = dev->platform_data; struct usbhs_hcd_omap *omap; struct resource *res; int ret = 0; int i; if (!pdata) { dev_err(dev, "Missing platform data\n"); ret = -ENOMEM; goto end_probe; } omap = kzalloc(sizeof(*omap), GFP_KERNEL); if (!omap) { dev_err(dev, "Memory allocation failed\n"); ret = -ENOMEM; goto end_probe; } spin_lock_init(&omap->lock); for (i = 0; i < OMAP3_HS_USB_PORTS; i++) omap->platdata.port_mode[i] = pdata->port_mode[i]; omap->platdata.ehci_data = pdata->ehci_data; omap->platdata.ohci_data = pdata->ohci_data; pm_runtime_enable(dev); for (i = 0; i < OMAP3_HS_USB_PORTS; i++) if (is_ehci_phy_mode(i) || is_ehci_tll_mode(i) || is_ehci_hsic_mode(i)) { omap->ehci_logic_fck = clk_get(dev, "ehci_logic_fck"); if (IS_ERR(omap->ehci_logic_fck)) { ret = PTR_ERR(omap->ehci_logic_fck); dev_warn(dev, "ehci_logic_fck failed:%d\n", ret); } break; } omap->utmi_p1_fck = clk_get(dev, "utmi_p1_gfclk"); if (IS_ERR(omap->utmi_p1_fck)) { ret = PTR_ERR(omap->utmi_p1_fck); dev_err(dev, "utmi_p1_gfclk failed error:%d\n", ret); goto err_end; } omap->xclk60mhsp1_ck = clk_get(dev, "xclk60mhsp1"); if (IS_ERR(omap->xclk60mhsp1_ck)) { ret = PTR_ERR(omap->xclk60mhsp1_ck); dev_err(dev, "xclk60mhsp1_ck failed error:%d\n", ret); goto err_utmi_p1_fck; } omap->utmi_p2_fck = clk_get(dev, "utmi_p2_gfclk"); if (IS_ERR(omap->utmi_p2_fck)) { ret = PTR_ERR(omap->utmi_p2_fck); dev_err(dev, "utmi_p2_gfclk failed error:%d\n", ret); goto err_xclk60mhsp1_ck; } omap->xclk60mhsp2_ck = clk_get(dev, "xclk60mhsp2"); if (IS_ERR(omap->xclk60mhsp2_ck)) { ret = PTR_ERR(omap->xclk60mhsp2_ck); dev_err(dev, "xclk60mhsp2_ck failed error:%d\n", ret); goto err_utmi_p2_fck; } omap->usbhost_p1_fck = clk_get(dev, "usb_host_hs_utmi_p1_clk"); if (IS_ERR(omap->usbhost_p1_fck)) { ret = PTR_ERR(omap->usbhost_p1_fck); dev_err(dev, "usbhost_p1_fck failed error:%d\n", ret); goto err_xclk60mhsp2_ck; } omap->usbhost_p2_fck = clk_get(dev, "usb_host_hs_utmi_p2_clk"); if (IS_ERR(omap->usbhost_p2_fck)) { ret = PTR_ERR(omap->usbhost_p2_fck); dev_err(dev, "usbhost_p2_fck failed error:%d\n", ret); goto err_usbhost_p1_fck; } if (cpu_is_omap54xx()) { omap->usbhost_p3_fck = clk_get(dev, "usb_host_hs_utmi_p3_clk"); if (IS_ERR(omap->usbhost_p3_fck)) { ret = PTR_ERR(omap->usbhost_p3_fck); dev_err(dev, "usbhost_p3_fck failed error:%d\n", ret); goto err_usbhost_p2_fck; } } if (cpu_is_omap54xx()) omap->init_60m_fclk = clk_get(dev, "l3init_60m_fclk"); else omap->init_60m_fclk = clk_get(dev, "init_60m_fclk"); if (IS_ERR(omap->init_60m_fclk)) { ret = PTR_ERR(omap->init_60m_fclk); dev_err(dev, "init_60m_fclk failed error:%d\n", ret); goto err_usbhost_p2_fck; } omap->usb_host_hs_hsic60m_p1_clk = clk_get(dev, "usb_host_hs_hsic60m_p1_clk"); if (IS_ERR(omap->usb_host_hs_hsic60m_p1_clk)) { ret = PTR_ERR(omap->usb_host_hs_hsic60m_p1_clk); dev_err(dev, "Unable to get usb_host_hs_hsic60m_p1_clk\n"); goto err_init_60m_fclk; } omap->usb_host_hs_hsic480m_p1_clk = clk_get(dev, "usb_host_hs_hsic480m_p1_clk"); if (IS_ERR(omap->usb_host_hs_hsic480m_p1_clk)) { ret = PTR_ERR(omap->usb_host_hs_hsic480m_p1_clk); dev_err(dev, "Unable to get usb_host_hs_hsic480m_p1_clk\n"); goto err_usb_host_hs_hsic60m_p1_clk; } omap->usb_host_hs_hsic60m_p2_clk = clk_get(dev, "usb_host_hs_hsic60m_p2_clk"); if (IS_ERR(omap->usb_host_hs_hsic60m_p2_clk)) { ret = PTR_ERR(omap->usb_host_hs_hsic60m_p2_clk); dev_err(dev, "Unable to get usb_host_hs_hsic60m_p2_clk\n"); goto err_usb_host_hs_hsic480m_p1_clk; } omap->usb_host_hs_hsic480m_p2_clk = clk_get(dev, "usb_host_hs_hsic480m_p2_clk"); if (IS_ERR(omap->usb_host_hs_hsic480m_p2_clk)) { ret = PTR_ERR(omap->usb_host_hs_hsic480m_p2_clk); dev_err(dev, "Unable to get usb_host_hs_hsic480m_p2_clk\n"); goto err_usb_host_hs_hsic60m_p2_clk; } if (cpu_is_omap54xx()) { omap->usb_host_hs_hsic60m_p3_clk = clk_get(dev, "usb_host_hs_hsic60m_p3_clk"); if (IS_ERR(omap->usb_host_hs_hsic60m_p3_clk)) { ret = PTR_ERR(omap->usb_host_hs_hsic60m_p3_clk); dev_err(dev, "Unable to get usb_host_hs_hsic60m_p3_clk\n"); goto err_usb_host_hs_hsic480m_p2_clk; } omap->usb_host_hs_hsic480m_p3_clk = clk_get(dev, "usb_host_hs_hsic480m_p3_clk"); if (IS_ERR(omap->usb_host_hs_hsic480m_p3_clk)) { ret = PTR_ERR(omap->usb_host_hs_hsic480m_p3_clk); dev_err(dev, "Unable to get usb_host_hs_hsic480m_p3_clk\n"); goto err_usb_host_hs_hsic60m_p3_clk; } } if (is_ehci_phy_mode(pdata->port_mode[0])) { /* for OMAP3 , the clk set paretn fails */ ret = clk_set_parent(omap->utmi_p1_fck, omap->xclk60mhsp1_ck); if (ret != 0) dev_err(dev, "xclk60mhsp1_ck set parent" "failed error:%d\n", ret); } else if (is_ehci_tll_mode(pdata->port_mode[0])) { ret = clk_set_parent(omap->utmi_p1_fck, omap->init_60m_fclk); if (ret != 0) dev_err(dev, "init_60m_fclk set parent" "failed error:%d\n", ret); } if (is_ehci_phy_mode(pdata->port_mode[1])) { ret = clk_set_parent(omap->utmi_p2_fck, omap->xclk60mhsp2_ck); if (ret != 0) dev_err(dev, "xclk60mhsp2_ck set parent" "failed error:%d\n", ret); } else if (is_ehci_tll_mode(pdata->port_mode[1])) { ret = clk_set_parent(omap->utmi_p2_fck, omap->init_60m_fclk); if (ret != 0) dev_err(dev, "init_60m_fclk set parent" "failed error:%d\n", ret); } res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "uhh"); if (!res) { dev_err(dev, "UHH EHCI get resource failed\n"); ret = -ENODEV; goto err_usb_host_hs_hsic480m_p3_clk; } omap->uhh_base = ioremap(res->start, resource_size(res)); if (!omap->uhh_base) { dev_err(dev, "UHH ioremap failed\n"); ret = -ENOMEM; goto err_usb_host_hs_hsic480m_p3_clk; } platform_set_drvdata(pdev, omap); omap_usbhs_init(dev); ret = omap_usbhs_alloc_children(pdev); if (ret) { dev_err(dev, "omap_usbhs_alloc_children failed\n"); goto err_alloc; } goto end_probe; err_alloc: omap_usbhs_deinit(&pdev->dev); iounmap(omap->uhh_base); err_usb_host_hs_hsic480m_p3_clk: clk_put(omap->usb_host_hs_hsic480m_p3_clk); err_usb_host_hs_hsic60m_p3_clk: clk_put(omap->usb_host_hs_hsic60m_p3_clk); err_usb_host_hs_hsic480m_p2_clk: clk_put(omap->usb_host_hs_hsic480m_p2_clk); err_usb_host_hs_hsic60m_p2_clk: clk_put(omap->usb_host_hs_hsic60m_p2_clk); err_usb_host_hs_hsic480m_p1_clk: clk_put(omap->usb_host_hs_hsic480m_p1_clk); err_usb_host_hs_hsic60m_p1_clk: clk_put(omap->usb_host_hs_hsic60m_p1_clk); err_init_60m_fclk: clk_put(omap->init_60m_fclk); err_usbhost_p2_fck: clk_put(omap->usbhost_p2_fck); err_usbhost_p1_fck: clk_put(omap->usbhost_p1_fck); err_xclk60mhsp2_ck: clk_put(omap->xclk60mhsp2_ck); err_utmi_p2_fck: clk_put(omap->utmi_p2_fck); err_xclk60mhsp1_ck: clk_put(omap->xclk60mhsp1_ck); err_utmi_p1_fck: clk_put(omap->utmi_p1_fck); err_end: clk_put(omap->ehci_logic_fck); pm_runtime_disable(dev); kfree(omap); end_probe: return ret; }