usb: dwc_otg: optimized grf and clk operation for rk336x board
authorFrank Wang <frank.wang@rock-chips.com>
Wed, 2 Mar 2016 03:24:48 +0000 (11:24 +0800)
committerFrank Wang <frank.wang@rock-chips.com>
Thu, 3 Mar 2016 06:53:55 +0000 (14:53 +0800)
Get grf offset form DT and optimize hclk_usb_peri clock process logic.

Change-Id: I136970c7052e5d621fd10e5d2b90f0fdac620067
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
drivers/usb/dwc_otg_310/usbdev_rk.h [changed mode: 0755->0644]
drivers/usb/dwc_otg_310/usbdev_rk3368.c

old mode 100755 (executable)
new mode 100644 (file)
index c4b0dd7..ad44b85
@@ -130,6 +130,7 @@ struct dwc_otg_control_usb {
        pGRF_SOC_STATUS19_RK3288 grf_soc_status19_rk3288;
        pGRF_SOC_STATUS21_RK3288 grf_soc_status21_rk3288;
 
+       u32 grf_otg_st_offset;
        struct regmap *grf;
        struct gpio *host_gpios;
        struct gpio *otg_gpios;
index ebd2630..6e0cde4 100644 (file)
@@ -131,7 +131,7 @@ static void usb20otg_clock_enable(void *pdata, int enable)
 static int usb20otg_get_status(int id)
 {
        int ret = -1;
-       u32 soc_status15 = uoc_read(0x4bc);
+       u32 soc_status15 = uoc_read(control_usb->grf_otg_st_offset);
 
        switch (id) {
        case USB_STATUS_BVABLID:
@@ -402,6 +402,7 @@ static int dwc_otg_control_usb_probe(struct platform_device *pdev)
        struct clk *hclk_usb_peri;
        struct regmap *grf;
        int gpio, ret = 0;
+       u32 offset;
 
        control_usb = devm_kzalloc(dev, sizeof(*control_usb), GFP_KERNEL);
        if (!control_usb) {
@@ -417,6 +418,14 @@ static int dwc_otg_control_usb_probe(struct platform_device *pdev)
        }
        control_usb->grf = grf;
 
+       /* get the reg offset of GRF_SOC_STATUS for USB2.0 OTG */
+       if (of_property_read_u32(np, "grf-offset", &offset)) {
+               dev_err(&pdev->dev, "missing reg property in node %s\n",
+                       np->name);
+               return -EINVAL;
+       }
+       control_usb->grf_otg_st_offset = offset;
+
        /* Init Vbus-drv GPIOs */
        control_usb->host_gpios =
            devm_kzalloc(&pdev->dev, sizeof(struct gpio), GFP_KERNEL);
@@ -466,8 +475,8 @@ static int dwc_otg_control_usb_probe(struct platform_device *pdev)
        /* Init hclk_usb_peri */
        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");
-               return PTR_ERR(hclk_usb_peri);
+               dev_info(&pdev->dev, "no hclk_usb_peri clk specified\n");
+               hclk_usb_peri = NULL;
        }
        control_usb->hclk_usb_peri = hclk_usb_peri;
        clk_prepare_enable(hclk_usb_peri);