USB: Modify EHCI & OHCI clk and gpio.
authorwlf <wulf@rock-chips.com>
Thu, 20 Mar 2014 01:57:04 +0000 (09:57 +0800)
committerwlf <wulf@rock-chips.com>
Thu, 20 Mar 2014 01:57:04 +0000 (09:57 +0800)
arch/arm/boot/dts/rk3288.dtsi
drivers/usb/dwc_otg_310/usbdev_rk30.c
drivers/usb/dwc_otg_310/usbdev_rk32.c

index e7e0af21ac6dbb397a3ad4bed6ceda73f3783618..e05e50b7fd9d0a27fdf1375b64d65bb31e0a32dc 100755 (executable)
                /*clock-names = "clk_usbphy1", "hclk_usb1";*/
        };
 
-       usb2: usb@ff520000 {
-               compatible = "rockchip,rk3288_rk_ohci_host";
-               reg = <0xff520000 0x20000>;
-               interrupts = <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>;
+       usb2: usb@ff500000 {
+               compatible = "rockchip,rk3288_usbhs_host";
+               reg = <0xff500000 0x40000>;
                /*clocks = <&clk_gates13 6>, <&clk_gates7 7>;*/
                /*clock-names = "clk_usbphy2", "hclk_usb2";*/
-       };
+               #address-cells = <1>;
+               #size-cells = <1>;
+               ranges;
 
-       usb3: usb@ff500000 {
-               compatible = "rockchip,rk3288_rk_ehci_host";
-               reg = <0xff500000 0x20000>;
-               interrupts = <GIC_SPI 24 IRQ_TYPE_LEVEL_HIGH>;
-               /*clocks = <&clk_gates13 6>, <&clk_gates7 7>;*/
-               /*clock-names = "clk_usbphy3", "hclk_usb3";*/
+               ehci: ehci@ff500000 {
+                       compatible = "rockchip,rk3288_rk_ehci_host";
+                       reg = <0xff500000 0x20000>;
+                       interrupt-parent = <&gic>;
+                       interrupts = <GIC_SPI 24 IRQ_TYPE_LEVEL_HIGH>;
+               };
+
+               ohci: ohci@ff520000 {
+                       compatible = "rockchip,rk3288_rk_ohci_host";
+                       reg = <0xff520000 0x20000>;
+                       interrupt-parent = <&gic>;
+                       interrupts = <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>;
+               };
        };
 
        hsic: hsic@ff5c0000 {
index f4913a0af9fe4605f11891c9749e62f5a35150c1..6fb727f8a56329e53eb75600f948caf8e1e0b429 100755 (executable)
@@ -21,7 +21,9 @@ static void usb20otg_hw_init(void)
 
        /* other haredware init,include:
         * DRV_VBUS GPIO init */
-       gpio_direction_output(control_usb->otg_gpios->gpio, 0);
+       if(gpio_get_value(control_usb->otg_gpios->gpio)){
+               gpio_set_value(control_usb->otg_gpios->gpio, 0);
+       }
 }
 
 static void usb20otg_phy_suspend(void* pdata, int suspend)
@@ -166,8 +168,9 @@ static void usb20host_hw_init(void)
 
        /* other haredware init,include:
         * DRV_VBUS GPIO init */
-       gpio_direction_output(control_usb->host_gpios->gpio, 1);
-
+       if(!gpio_get_value(control_usb->host_gpios->gpio)){
+               gpio_set_value(control_usb->host_gpios->gpio, 1);
+       }
 }
 
 static void usb20host_phy_suspend(void* pdata, int suspend)
@@ -540,7 +543,13 @@ static int dwc_otg_control_usb_probe(struct platform_device *pdev)
                goto err2;
        }
 
+       /* init host gpio */
        control_usb->host_gpios = devm_kzalloc(&pdev->dev, sizeof(struct gpio), GFP_KERNEL);
+       if(!control_usb->host_gpios){
+               dev_err(&pdev->dev, "unable to alloc memory for host_gpios\n");
+               ret =  -ENOMEM;
+               goto err2;
+       }
 
        gpio =  of_get_named_gpio(np, "gpios", 0);
        if(!gpio_is_valid(gpio)){
@@ -548,7 +557,9 @@ static int dwc_otg_control_usb_probe(struct platform_device *pdev)
                ret = -EINVAL;
                goto err2;
        }
+
        control_usb->host_gpios->gpio = gpio;
+
        err = devm_gpio_request(&pdev->dev, gpio, "host_drv_gpio");
        if (err) {
                dev_err(&pdev->dev,
@@ -557,8 +568,15 @@ static int dwc_otg_control_usb_probe(struct platform_device *pdev)
                ret = err;
                goto err2;
        }
+       gpio_direction_output(control_usb->host_gpios->gpio, 1);
 
+       /* init otg gpio */
        control_usb->otg_gpios = devm_kzalloc(&pdev->dev, sizeof(struct gpio), GFP_KERNEL);
+       if(!control_usb->otg_gpios){
+               dev_err(&pdev->dev, "unable to alloc memory for otg_gpios\n");
+               ret =  -ENOMEM;
+               goto err2;
+       }
 
        gpio =  of_get_named_gpio(np, "gpios", 1);
        if(!gpio_is_valid(gpio)){
@@ -575,6 +593,8 @@ static int dwc_otg_control_usb_probe(struct platform_device *pdev)
                ret = err;
                goto err2;
        }
+       gpio_direction_output(control_usb->otg_gpios->gpio, 0);
+
        ret = otg_irq_detect_init(pdev);
        if (ret < 0)
                goto err2;
index 9656992148796f6eebe1affd9c73294e73d46493..103bbfa59f0cc1e75c1af8176cd2a814e94ab104 100755 (executable)
@@ -19,8 +19,9 @@ static void usb20otg_hw_init(void)
 
        /* other haredware init,include:
         * DRV_VBUS GPIO init */
-//     gpio_direction_output(control_usb->otg_gpios->gpio, 0);
-
+       /*if(gpio_get_value(control_usb->otg_gpios->gpio)){
+               gpio_set_value(control_usb->otg_gpios->gpio, 0);
+       }*/
 }
 
 static void usb20otg_phy_suspend(void* pdata, int suspend)
@@ -166,7 +167,9 @@ static void usb20host_hw_init(void)
 
        /* other haredware init,include:
         * DRV_VBUS GPIO init */
-//     gpio_direction_output(control_usb->host_gpios->gpio, 1);
+       /*if(!gpio_get_value(control_usb->host_gpios->gpio)){
+               gpio_set_value(control_usb->host_gpios->gpio, 1);
+       }*/
 }
 
 static void usb20host_phy_suspend(void* pdata, int suspend)
@@ -387,17 +390,54 @@ struct rkehci_platform_data rkhsic_pdata_rk3288 = {
 #ifdef CONFIG_USB_EHCI_RK
 static void rk_ehci_hw_init(void)
 {
+       /* usb phy config init */
 
+       /* DRV_VBUS GPIO init */
+       /*if(!gpio_get_value(control_usb->host_gpios->gpio)){
+               gpio_set_value(control_usb->host_gpios->gpio, 1);
+       }*/
 }
 
 static void rk_ehci_clock_init(void* pdata)
 {
+/*
+       struct rkehci_platform_data *usbpdata=pdata;
+       struct clk* ahbclk,*phyclk;
+
+       ahbclk = of_clk_get_by_name(of_get_parent(usbpdata->dev.of_node), "hclk_usb2");
+       if (IS_ERR(ahbclk)) {
+               dev_err(usbpdata->dev, "Failed to get hclk_usb2\n");
+               return;
+       }
+
+       phyclk = of_clk_get_by_name(of_get_parent(usbpdata->dev.of_node), "clk_usbphy2");
+       if (IS_ERR(phyclk)) {
+               dev_err(usbpdata->dev, "Failed to get clk_usbphy2\n");
+               return;
+       }
 
+       usbpdata->phyclk = phyclk;
+       usbpdata->ahbclk = ahbclk;
+*/
 }
 
 static void rk_ehci_clock_enable(void* pdata, int enable)
 {
+/*
+       struct rkehci_platform_data *usbpdata=pdata;
 
+       if(enable == usbpdata->clk_status)
+               return;
+       if(enable){
+               clk_prepare_enable(usbpdata->ahbclk);
+               clk_prepare_enable(usbpdata->phyclk);
+               usbpdata->clk_status = 1;
+       }else{
+               clk_disable_unprepare(usbpdata->ahbclk);
+               clk_disable_unprepare(usbpdata->phyclk);
+               usbpdata->clk_status = 0;
+       }
+*/
 }
 
 static void rk_ehci_soft_reset(void)
@@ -419,14 +459,54 @@ struct rkehci_platform_data rkehci_pdata_rk3288 = {
 #ifdef CONFIG_USB_OHCI_HCD_RK
 static void rk_ohci_hw_init(void)
 {
+       /* usb phy config init */
+
+       /* DRV_VBUS GPIO init */
+       /*if(!gpio_get_value(control_usb->host_gpios->gpio)){
+               gpio_set_value(control_usb->host_gpios->gpio, 1);
+       }*/
 }
 
 static void rk_ohci_clock_init(void* pdata)
 {
+/*
+       struct rkehci_platform_data *usbpdata=pdata;
+       struct clk* ahbclk,*phyclk;
+
+       ahbclk = of_clk_get_by_name(of_get_parent(usbpdata->dev.of_node), "hclk_usb2");
+       if (IS_ERR(ahbclk)) {
+               dev_err(usbpdata->dev, "Failed to get hclk_usb2\n");
+               return;
+       }
+
+       phyclk = of_clk_get_by_name(of_get_parent(usbpdata->dev.of_node), "clk_usbphy2");
+       if (IS_ERR(phyclk)) {
+               dev_err(usbpdata->dev, "Failed to get clk_usbphy2\n");
+               return;
+       }
+
+       usbpdata->phyclk = phyclk;
+       usbpdata->ahbclk = ahbclk;
+*/
 }
 
 static void rk_ohci_clock_enable(void* pdata, int enable)
 {
+/*
+       struct rkehci_platform_data *usbpdata=pdata;
+
+       if(enable == usbpdata->clk_status)
+               return;
+       if(enable){
+               clk_prepare_enable(usbpdata->ahbclk);
+               clk_prepare_enable(usbpdata->phyclk);
+               usbpdata->clk_status = 1;
+       }else{
+               clk_disable_unprepare(usbpdata->ahbclk);
+               clk_disable_unprepare(usbpdata->phyclk);
+               usbpdata->clk_status = 0;
+       }
+*/
 }
 
 static void rk_ohci_soft_reset(void)
@@ -767,6 +847,11 @@ static int dwc_otg_control_usb_probe(struct platform_device *pdev)
        }
 /*
        control_usb->host_gpios = devm_kzalloc(&pdev->dev, sizeof(struct gpio), GFP_KERNEL);
+       if(!control_usb->host_gpios){
+               dev_err(&pdev->dev, "unable to alloc memory for host_gpios\n");
+               ret =  -ENOMEM;
+               goto err2;
+       }
 
        gpio =  of_get_named_gpio(np, "gpios", 0);
        if(!gpio_is_valid(gpio)){
@@ -783,8 +868,14 @@ static int dwc_otg_control_usb_probe(struct platform_device *pdev)
                ret = err;
                goto err2;
        }
+       gpio_direction_output(control_usb->host_gpios->gpio, 1);
 
        control_usb->otg_gpios = devm_kzalloc(&pdev->dev, sizeof(struct gpio), GFP_KERNEL);
+       if(!control_usb->otg_gpios){
+               dev_err(&pdev->dev, "unable to alloc memory for otg_gpios\n");
+               ret =  -ENOMEM;
+               goto err2;
+       }
 
        gpio =  of_get_named_gpio(np, "gpios", 1);
        if(!gpio_is_valid(gpio)){
@@ -801,6 +892,7 @@ static int dwc_otg_control_usb_probe(struct platform_device *pdev)
                ret = err;
                goto err2;
        }
+       gpio_direction_output(control_usb->otg_gpios->gpio, 0);
 */
 /* disable for debug
        ret = otg_irq_detect_init(pdev);