USB: Fix ehci bug and enable host and otg gpios to provide drv_vbus.
authorwlf <wulf@rock-chips.com>
Fri, 21 Mar 2014 08:34:16 +0000 (16:34 +0800)
committerwlf <wulf@rock-chips.com>
Fri, 21 Mar 2014 08:34:16 +0000 (16:34 +0800)
arch/arm/boot/dts/rk3288.dtsi
drivers/usb/dwc_otg_310/usbdev_rk32.c
drivers/usb/host/ehci-rockchip.c

index a3e184698104205acbda3dc33d5ebefa46573bd4..27cc2ec22ba27e2e5a5e0b02bfe4773ea2feae89 100755 (executable)
                interrupt-names = "otg_id", "otg_bvalid",
                           "otg_linestate", "host0_linestate",
                           "host1_linestate";
-               /*gpios = <&gpio0 GPIO_B6 GPIO_ACTIVE_LOW>,*//*HOST_VBUS_DRV*/
-               /*        <&gpio0 GPIO_B4 GPIO_ACTIVE_LOW>;*//*OTG_VBUS_DRV*/
+               gpios = <&gpio0 GPIO_B6 GPIO_ACTIVE_LOW>,/*HOST_VBUS_DRV*/
+                       <&gpio0 GPIO_B4 GPIO_ACTIVE_LOW>;/*OTG_VBUS_DRV*/
                /*clocks = <&clk_gates7 9>;*/
                /*clock-names = "hclk_usb_peri";*/
                rockchip,remote_wakeup;
        };
 
        usb2: usb@ff500000 {
-               compatible = "rockchip,rk3288_usbhs_host";
-               reg = <0xff500000 0x40000>;
+               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_usbphy2", "hclk_usb2";*/
-               #address-cells = <1>;
-               #size-cells = <1>;
-               ranges;
-
-               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>;
-               };
+       usb3: usb@ff520000 {
+               compatible = "rockchip,rk3288_rk_ohci_host";
+               reg = <0xff520000 0x20000>;
+               interrupts = <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>;
+               /*clocks = <&clk_gates13 6>, <&clk_gates7 7>;*/
+               /*clock-names = "clk_usbphy3", "hclk_usb3";*/
        };
 
        hsic: hsic@ff5c0000 {
index 103bbfa59f0cc1e75c1af8176cd2a814e94ab104..faa058a2d29230b8e93d3535a720931dd3e69e28 100755 (executable)
@@ -19,9 +19,9 @@ static void usb20otg_hw_init(void)
 
        /* other haredware init,include:
         * DRV_VBUS GPIO init */
-       /*if(gpio_get_value(control_usb->otg_gpios->gpio)){
+       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)
@@ -130,12 +130,12 @@ static void dwc_otg_uart_mode(void* pdata, int enter_usb_uart_mode)
 #endif
 
 static void usb20otg_power_enable(int enable)
-{      /*
+{
        if(0 == enable){//disable otg_drv power
                gpio_set_value(control_usb->otg_gpios->gpio, 0);
        }else if(1 == enable){//enable otg_drv power
                gpio_set_value(control_usb->otg_gpios->gpio, 1);
-       }*/
+       }
 }
 
 
@@ -167,9 +167,9 @@ static void usb20host_hw_init(void)
 
        /* other haredware init,include:
         * DRV_VBUS GPIO init */
-       /*if(!gpio_get_value(control_usb->host_gpios->gpio)){
+       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)
@@ -265,12 +265,12 @@ static int usb20host_get_status(int id)
 }
 
 static void usb20host_power_enable(int enable)
-{      /*
+{
        if(0 == enable){//disable host_drv power
                //do not disable power in default
        }else if(1 == enable){//enable host_drv power
                gpio_set_value(control_usb->host_gpios->gpio, 1);
-       }*/
+       }
 }
 
 
@@ -393,9 +393,9 @@ static void rk_ehci_hw_init(void)
        /* usb phy config init */
 
        /* DRV_VBUS GPIO init */
-       /*if(!gpio_get_value(control_usb->host_gpios->gpio)){
+       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)
@@ -404,13 +404,13 @@ 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");
+       ahbclk = devm_clk_get(usbpdata->dev, "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");
+       phyclk = devm_clk_get(usbpdata->dev, "clk_usbphy2");
        if (IS_ERR(phyclk)) {
                dev_err(usbpdata->dev, "Failed to get clk_usbphy2\n");
                return;
@@ -462,9 +462,9 @@ static void rk_ohci_hw_init(void)
        /* usb phy config init */
 
        /* DRV_VBUS GPIO init */
-       /*if(!gpio_get_value(control_usb->host_gpios->gpio)){
+       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)
@@ -473,15 +473,15 @@ 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");
+       ahbclk =devm_clk_get(usbpdata->dev, "hclk_usb3");
        if (IS_ERR(ahbclk)) {
-               dev_err(usbpdata->dev, "Failed to get hclk_usb2\n");
+               dev_err(usbpdata->dev, "Failed to get hclk_usb3\n");
                return;
        }
 
-       phyclk = of_clk_get_by_name(of_get_parent(usbpdata->dev.of_node), "clk_usbphy2");
+       phyclk = devm_clk_get(usbpdata->dev, "clk_usbphy3");;
        if (IS_ERR(phyclk)) {
-               dev_err(usbpdata->dev, "Failed to get clk_usbphy2\n");
+               dev_err(usbpdata->dev, "Failed to get clk_usbphy3\n");
                return;
        }
 
@@ -845,7 +845,7 @@ static int dwc_otg_control_usb_probe(struct platform_device *pdev)
                dev_err(&pdev->dev, "Failed to ioremap usb grf\n");
                goto err2;
        }
-/*
+
        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");
@@ -893,7 +893,7 @@ static int dwc_otg_control_usb_probe(struct platform_device *pdev)
                goto err2;
        }
        gpio_direction_output(control_usb->otg_gpios->gpio, 0);
-*/
+
 /* disable for debug
        ret = otg_irq_detect_init(pdev);
        if (ret < 0)
index 91be75a3d5b5d08a15fbec9cd5e6227d697bcb0b..97c66e4bdc1cb3b0cd52bc0765fec887e5bf8948 100755 (executable)
@@ -139,9 +139,9 @@ static ssize_t ehci_power_store( struct device *_dev,
                        pldata->soft_reset();
                        usb_add_hcd(hcd, hcd->irq, IRQF_DISABLED | IRQF_SHARED);
                        ehci_port_power(ehci, 1);
-                       writel_relaxed(0x1d4d ,hcd->regs +0x90);
-                       writel_relaxed(0x4 ,hcd->regs +0xa0);
-                       dsb();
+//                     writel_relaxed(0x1d4d ,hcd->regs +0x90);
+//                     writel_relaxed(0x4 ,hcd->regs +0xa0);
+//                     dsb();
                        break;
                default:
                        break;
@@ -290,9 +290,9 @@ static int ehci_rk_probe(struct platform_device *pdev)
 
        g_ehci = ehci;
        ehci_port_power(ehci, 1);
-       writel_relaxed(0x1d4d ,hcd->regs +0x90);
-       writel_relaxed(0x4 ,hcd->regs +0xa0);
-       dsb();
+//     writel_relaxed(0x1d4d ,hcd->regs +0x90);
+//     writel_relaxed(0x4 ,hcd->regs +0xa0);
+//     dsb();
 
        printk("%s ok\n", __func__);