From: Frank Wang Date: Tue, 28 Mar 2017 09:32:36 +0000 (+0800) Subject: usb: dwc_otg_310: add rk3288 usb otg support X-Git-Tag: firefly_0821_release~180 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=eee051ca31f431a8d9b2aa6f790591ae2857b759;p=firefly-linux-kernel-4.4.55.git usb: dwc_otg_310: add rk3288 usb otg support This adds amend usb otg driver to support rk3328-evb board. Change-Id: I152bedb64367ddf9c556e330b31c018f385c3fd7 Signed-off-by: Frank Wang --- diff --git a/drivers/usb/dwc_otg_310/dwc_otg_driver.c b/drivers/usb/dwc_otg_310/dwc_otg_driver.c index b5dc5a5f2cb0..9905a393d6d6 100644 --- a/drivers/usb/dwc_otg_310/dwc_otg_driver.c +++ b/drivers/usb/dwc_otg_310/dwc_otg_driver.c @@ -1621,7 +1621,9 @@ static struct platform_driver dwc_otg_driver = { void rk_usb_power_up(void) { struct dwc_otg_platform_data *pldata_otg; +#ifdef CONFIG_USB20_HOST struct dwc_otg_platform_data *pldata_host; +#endif #ifdef CONFIG_USB_EHCI_RK struct rkehci_platform_data *pldata_ehci; #endif @@ -1677,7 +1679,9 @@ void rk_usb_power_up(void) void rk_usb_power_down(void) { struct dwc_otg_platform_data *pldata_otg; +#ifdef CONFIG_USB20_HOST struct dwc_otg_platform_data *pldata_host; +#endif #ifdef CONFIG_USB_EHCI_RK struct rkehci_platform_data *pldata_ehci; #endif diff --git a/drivers/usb/dwc_otg_310/usbdev_rk32.c b/drivers/usb/dwc_otg_310/usbdev_rk32.c index b494a55c5047..70b4c86ec46f 100644 --- a/drivers/usb/dwc_otg_310/usbdev_rk32.c +++ b/drivers/usb/dwc_otg_310/usbdev_rk32.c @@ -966,17 +966,6 @@ static int usb_grf_ioremap(struct platform_device *pdev) return ret; } -#ifdef CONFIG_OF - -static const struct of_device_id rk_usb_control_id_table[] = { - { - .compatible = "rockchip,rk3288-usb-control", - }, - {}, -}; - -#endif - static int rk_usb_control_probe(struct platform_device *pdev) { int gpio, err; @@ -1012,7 +1001,7 @@ static int rk_usb_control_probe(struct platform_device *pdev) control_usb->host_gpios->gpio = gpio; if (!gpio_is_valid(gpio)) { - dev_err(&pdev->dev, "invalid host gpio%d\n", gpio); + dev_warn(&pdev->dev, "host_drv_gpio is not specified or invalid\n"); } else { err = devm_gpio_request(&pdev->dev, gpio, "host_drv_gpio"); if (err) { @@ -1037,7 +1026,7 @@ static int rk_usb_control_probe(struct platform_device *pdev) control_usb->otg_gpios->gpio = gpio; if (!gpio_is_valid(gpio)) { - dev_err(&pdev->dev, "invalid otg gpio%d\n", gpio); + dev_warn(&pdev->dev, "otg_drv_gpio is not specified or invalid\n"); } else { err = devm_gpio_request(&pdev->dev, gpio, "otg_drv_gpio"); if (err) { @@ -1053,71 +1042,35 @@ out: return ret; } -static int rk_usb_control_remove(struct platform_device *pdev) -{ - return 0; -} - -static struct platform_driver rk_usb_control_driver = { - .probe = rk_usb_control_probe, - .remove = rk_usb_control_remove, - .driver = { - .name = "rk3288-usb-control", - .owner = THIS_MODULE, - .of_match_table = of_match_ptr(rk_usb_control_id_table), - }, -}; - #ifdef CONFIG_OF - static const struct of_device_id dwc_otg_control_usb_id_table[] = { { .compatible = "rockchip,rk3288-dwc-control-usb", }, {}, }; - #endif static int dwc_otg_control_usb_probe(struct platform_device *pdev) { - struct clk *hclk_usb_peri, *phyclk_480m, *phyclk480m_parent; int ret = 0; - if (!control_usb) { - dev_err(&pdev->dev, "unable to alloc memory for control usb\n"); - ret = -ENOMEM; - goto err1; - } - - hclk_usb_peri = devm_clk_get(&pdev->dev, "hclk_usb_peri"); - if (IS_ERR(hclk_usb_peri)) { - dev_err(&pdev->dev, "Failed to get hclk_usb_peri\n"); - ret = -EINVAL; - goto err1; - } - - control_usb->hclk_usb_peri = hclk_usb_peri; - clk_prepare_enable(hclk_usb_peri); - - phyclk480m_parent = devm_clk_get(&pdev->dev, "usbphy2_480m"); - if (IS_ERR(phyclk480m_parent)) { - dev_err(&pdev->dev, "Failed to get usbphy2_480m\n"); - goto err2; - } + ret = rk_usb_control_probe(pdev); + if (ret) + return ret; - phyclk_480m = devm_clk_get(&pdev->dev, "usbphy_480m"); - if (IS_ERR(phyclk_480m)) { - dev_err(&pdev->dev, "Failed to get usbphy_480m\n"); - goto err2; + control_usb->hclk_usb_peri = devm_clk_get(&pdev->dev, "hclk_usb_peri"); + if (IS_ERR(control_usb->hclk_usb_peri)) { + dev_info(&pdev->dev, "no hclk_usb_peri specified\n"); + control_usb->hclk_usb_peri = NULL; } - clk_set_parent(phyclk_480m, phyclk480m_parent); + clk_prepare_enable(control_usb->hclk_usb_peri); ret = usb_grf_ioremap(pdev); if (ret) { dev_err(&pdev->dev, "Failed to ioremap usb grf\n"); - goto err2; + goto err; } #ifdef CONFIG_USB20_OTG if (usb20otg_get_status(USB_STATUS_BVABLID)) @@ -1127,13 +1080,12 @@ static int dwc_otg_control_usb_probe(struct platform_device *pdev) ret = otg_irq_detect_init(pdev); if (ret < 0) - goto err2; + goto err; return 0; -err2: - clk_disable_unprepare(hclk_usb_peri); -err1: +err: + clk_disable_unprepare(control_usb->hclk_usb_peri); return ret; } @@ -1157,12 +1109,6 @@ static int __init dwc_otg_control_usb_init(void) { int retval = 0; - retval = platform_driver_register(&rk_usb_control_driver); - if (retval < 0) { - printk(KERN_ERR "%s retval=%d\n", __func__, retval); - return retval; - } - retval = platform_driver_register(&dwc_otg_control_usb_driver); if (retval < 0) { @@ -1176,7 +1122,6 @@ subsys_initcall(dwc_otg_control_usb_init); static void __exit dwc_otg_control_usb_exit(void) { - platform_driver_unregister(&rk_usb_control_driver); platform_driver_unregister(&dwc_otg_control_usb_driver); }