Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 1 | /* |
| 2 | * SAMSUNG EXYNOS USB HOST OHCI Controller |
| 3 | * |
| 4 | * Copyright (C) 2011 Samsung Electronics Co.Ltd |
| 5 | * Author: Jingoo Han <jg1.han@samsung.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the |
| 9 | * Free Software Foundation; either version 2 of the License, or (at your |
| 10 | * option) any later version. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #include <linux/clk.h> |
Manjunath Goudar | 50a97e0 | 2013-09-21 16:38:38 +0530 | [diff] [blame] | 15 | #include <linux/dma-mapping.h> |
| 16 | #include <linux/io.h> |
| 17 | #include <linux/kernel.h> |
| 18 | #include <linux/module.h> |
Vivek Gautam | d513893 | 2012-07-16 11:25:36 +0530 | [diff] [blame] | 19 | #include <linux/of.h> |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 20 | #include <linux/platform_device.h> |
Vivek Gautam | 7d28e54 | 2014-05-05 10:32:57 +0530 | [diff] [blame] | 21 | #include <linux/phy/phy.h> |
Vivek Gautam | ed993bf | 2013-01-22 18:30:43 +0530 | [diff] [blame] | 22 | #include <linux/usb/phy.h> |
Vivek Gautam | b506eeb | 2013-01-22 18:30:40 +0530 | [diff] [blame] | 23 | #include <linux/usb/samsung_usb_phy.h> |
Manjunath Goudar | 50a97e0 | 2013-09-21 16:38:38 +0530 | [diff] [blame] | 24 | #include <linux/usb.h> |
| 25 | #include <linux/usb/hcd.h> |
| 26 | #include <linux/usb/otg.h> |
| 27 | |
| 28 | #include "ohci.h" |
| 29 | |
| 30 | #define DRIVER_DESC "OHCI EXYNOS driver" |
| 31 | |
| 32 | static const char hcd_name[] = "ohci-exynos"; |
| 33 | static struct hc_driver __read_mostly exynos_ohci_hc_driver; |
| 34 | |
| 35 | #define to_exynos_ohci(hcd) (struct exynos_ohci_hcd *)(hcd_to_ohci(hcd)->priv) |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 36 | |
Vivek Gautam | 7d28e54 | 2014-05-05 10:32:57 +0530 | [diff] [blame] | 37 | #define PHY_NUMBER 3 |
| 38 | |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 39 | struct exynos_ohci_hcd { |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 40 | struct clk *clk; |
Vivek Gautam | ed993bf | 2013-01-22 18:30:43 +0530 | [diff] [blame] | 41 | struct usb_phy *phy; |
| 42 | struct usb_otg *otg; |
Vivek Gautam | 7d28e54 | 2014-05-05 10:32:57 +0530 | [diff] [blame] | 43 | struct phy *phy_g[PHY_NUMBER]; |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 44 | }; |
| 45 | |
Vivek Gautam | 7d28e54 | 2014-05-05 10:32:57 +0530 | [diff] [blame] | 46 | static int exynos_ohci_get_phy(struct device *dev, |
| 47 | struct exynos_ohci_hcd *exynos_ohci) |
| 48 | { |
| 49 | struct device_node *child; |
| 50 | struct phy *phy; |
| 51 | int phy_number; |
| 52 | int ret = 0; |
| 53 | |
| 54 | exynos_ohci->phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); |
| 55 | if (IS_ERR(exynos_ohci->phy)) { |
| 56 | ret = PTR_ERR(exynos_ohci->phy); |
| 57 | if (ret != -ENXIO && ret != -ENODEV) { |
| 58 | dev_err(dev, "no usb2 phy configured\n"); |
| 59 | return ret; |
| 60 | } |
| 61 | dev_dbg(dev, "Failed to get usb2 phy\n"); |
| 62 | } else { |
| 63 | exynos_ohci->otg = exynos_ohci->phy->otg; |
| 64 | } |
| 65 | |
| 66 | /* |
| 67 | * Getting generic phy: |
| 68 | * We are keeping both types of phys as a part of transiting OHCI |
| 69 | * to generic phy framework, so as to maintain backward compatibilty |
| 70 | * with old DTB. |
| 71 | * If there are existing devices using DTB files built from them, |
| 72 | * to remove the support for old bindings in this driver, |
| 73 | * we need to make sure that such devices have their DTBs |
| 74 | * updated to ones built from new DTS. |
| 75 | */ |
| 76 | for_each_available_child_of_node(dev->of_node, child) { |
| 77 | ret = of_property_read_u32(child, "reg", &phy_number); |
| 78 | if (ret) { |
| 79 | dev_err(dev, "Failed to parse device tree\n"); |
| 80 | of_node_put(child); |
| 81 | return ret; |
| 82 | } |
| 83 | |
| 84 | if (phy_number >= PHY_NUMBER) { |
| 85 | dev_err(dev, "Invalid number of PHYs\n"); |
| 86 | of_node_put(child); |
| 87 | return -EINVAL; |
| 88 | } |
| 89 | |
Sachin Kamat | 473e92e | 2014-06-06 14:13:44 +0530 | [diff] [blame] | 90 | phy = devm_of_phy_get(dev, child, NULL); |
Vivek Gautam | 7d28e54 | 2014-05-05 10:32:57 +0530 | [diff] [blame] | 91 | of_node_put(child); |
| 92 | if (IS_ERR(phy)) { |
| 93 | ret = PTR_ERR(phy); |
| 94 | if (ret != -ENOSYS && ret != -ENODEV) { |
| 95 | dev_err(dev, "no usb2 phy configured\n"); |
| 96 | return ret; |
| 97 | } |
| 98 | dev_dbg(dev, "Failed to get usb2 phy\n"); |
| 99 | } |
| 100 | exynos_ohci->phy_g[phy_number] = phy; |
| 101 | } |
| 102 | |
| 103 | return ret; |
| 104 | } |
| 105 | |
| 106 | static int exynos_ohci_phy_enable(struct device *dev) |
Vivek Gautam | ed993bf | 2013-01-22 18:30:43 +0530 | [diff] [blame] | 107 | { |
Vivek Gautam | 54969ed | 2014-05-05 10:33:42 +0530 | [diff] [blame] | 108 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
Manjunath Goudar | 50a97e0 | 2013-09-21 16:38:38 +0530 | [diff] [blame] | 109 | struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd); |
Vivek Gautam | 7d28e54 | 2014-05-05 10:32:57 +0530 | [diff] [blame] | 110 | int i; |
| 111 | int ret = 0; |
Vivek Gautam | ed993bf | 2013-01-22 18:30:43 +0530 | [diff] [blame] | 112 | |
Vivek Gautam | 7d28e54 | 2014-05-05 10:32:57 +0530 | [diff] [blame] | 113 | if (!IS_ERR(exynos_ohci->phy)) |
| 114 | return usb_phy_init(exynos_ohci->phy); |
| 115 | |
| 116 | for (i = 0; ret == 0 && i < PHY_NUMBER; i++) |
| 117 | if (!IS_ERR(exynos_ohci->phy_g[i])) |
| 118 | ret = phy_power_on(exynos_ohci->phy_g[i]); |
| 119 | if (ret) |
| 120 | for (i--; i >= 0; i--) |
| 121 | if (!IS_ERR(exynos_ohci->phy_g[i])) |
| 122 | phy_power_off(exynos_ohci->phy_g[i]); |
| 123 | |
| 124 | return ret; |
Vivek Gautam | ed993bf | 2013-01-22 18:30:43 +0530 | [diff] [blame] | 125 | } |
| 126 | |
Vivek Gautam | 54969ed | 2014-05-05 10:33:42 +0530 | [diff] [blame] | 127 | static void exynos_ohci_phy_disable(struct device *dev) |
Vivek Gautam | ed993bf | 2013-01-22 18:30:43 +0530 | [diff] [blame] | 128 | { |
Vivek Gautam | 54969ed | 2014-05-05 10:33:42 +0530 | [diff] [blame] | 129 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
Manjunath Goudar | 50a97e0 | 2013-09-21 16:38:38 +0530 | [diff] [blame] | 130 | struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd); |
Vivek Gautam | 7d28e54 | 2014-05-05 10:32:57 +0530 | [diff] [blame] | 131 | int i; |
Vivek Gautam | ed993bf | 2013-01-22 18:30:43 +0530 | [diff] [blame] | 132 | |
Vivek Gautam | 7d28e54 | 2014-05-05 10:32:57 +0530 | [diff] [blame] | 133 | if (!IS_ERR(exynos_ohci->phy)) { |
Vivek Gautam | ed993bf | 2013-01-22 18:30:43 +0530 | [diff] [blame] | 134 | usb_phy_shutdown(exynos_ohci->phy); |
Vivek Gautam | 7d28e54 | 2014-05-05 10:32:57 +0530 | [diff] [blame] | 135 | return; |
| 136 | } |
| 137 | |
| 138 | for (i = 0; i < PHY_NUMBER; i++) |
| 139 | if (!IS_ERR(exynos_ohci->phy_g[i])) |
| 140 | phy_power_off(exynos_ohci->phy_g[i]); |
Vivek Gautam | ed993bf | 2013-01-22 18:30:43 +0530 | [diff] [blame] | 141 | } |
| 142 | |
Bill Pemberton | 41ac7b3 | 2012-11-19 13:21:48 -0500 | [diff] [blame] | 143 | static int exynos_ohci_probe(struct platform_device *pdev) |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 144 | { |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 145 | struct exynos_ohci_hcd *exynos_ohci; |
| 146 | struct usb_hcd *hcd; |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 147 | struct resource *res; |
| 148 | int irq; |
| 149 | int err; |
| 150 | |
Vivek Gautam | d513893 | 2012-07-16 11:25:36 +0530 | [diff] [blame] | 151 | /* |
| 152 | * Right now device-tree probed devices don't get dma_mask set. |
| 153 | * Since shared usb code relies on it, set it here for now. |
| 154 | * Once we move to full device tree support this will vanish off. |
| 155 | */ |
Russell King | e1fd734 | 2013-06-27 12:36:37 +0100 | [diff] [blame] | 156 | err = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); |
Russell King | 22d9d8e | 2013-06-10 16:28:49 +0100 | [diff] [blame] | 157 | if (err) |
| 158 | return err; |
Vivek Gautam | d513893 | 2012-07-16 11:25:36 +0530 | [diff] [blame] | 159 | |
Manjunath Goudar | 50a97e0 | 2013-09-21 16:38:38 +0530 | [diff] [blame] | 160 | hcd = usb_create_hcd(&exynos_ohci_hc_driver, |
| 161 | &pdev->dev, dev_name(&pdev->dev)); |
| 162 | if (!hcd) { |
| 163 | dev_err(&pdev->dev, "Unable to create HCD\n"); |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 164 | return -ENOMEM; |
Manjunath Goudar | 50a97e0 | 2013-09-21 16:38:38 +0530 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | exynos_ohci = to_exynos_ohci(hcd); |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 168 | |
Thomas Abraham | 2871782 | 2013-04-11 17:12:30 +0530 | [diff] [blame] | 169 | if (of_device_is_compatible(pdev->dev.of_node, |
| 170 | "samsung,exynos5440-ohci")) |
| 171 | goto skip_phy; |
| 172 | |
Vivek Gautam | 7d28e54 | 2014-05-05 10:32:57 +0530 | [diff] [blame] | 173 | err = exynos_ohci_get_phy(&pdev->dev, exynos_ohci); |
| 174 | if (err) |
| 175 | goto fail_clk; |
Vivek Gautam | ed993bf | 2013-01-22 18:30:43 +0530 | [diff] [blame] | 176 | |
Thomas Abraham | 2871782 | 2013-04-11 17:12:30 +0530 | [diff] [blame] | 177 | skip_phy: |
Jingoo Han | 60d80ad | 2012-10-04 16:11:50 +0900 | [diff] [blame] | 178 | exynos_ohci->clk = devm_clk_get(&pdev->dev, "usbhost"); |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 179 | |
| 180 | if (IS_ERR(exynos_ohci->clk)) { |
| 181 | dev_err(&pdev->dev, "Failed to get usbhost clock\n"); |
| 182 | err = PTR_ERR(exynos_ohci->clk); |
| 183 | goto fail_clk; |
| 184 | } |
| 185 | |
Thomas Abraham | c05c946 | 2012-10-03 08:41:37 +0900 | [diff] [blame] | 186 | err = clk_prepare_enable(exynos_ohci->clk); |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 187 | if (err) |
Jingoo Han | 60d80ad | 2012-10-04 16:11:50 +0900 | [diff] [blame] | 188 | goto fail_clk; |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 189 | |
| 190 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 191 | if (!res) { |
| 192 | dev_err(&pdev->dev, "Failed to get I/O memory\n"); |
| 193 | err = -ENXIO; |
| 194 | goto fail_io; |
| 195 | } |
| 196 | |
| 197 | hcd->rsrc_start = res->start; |
| 198 | hcd->rsrc_len = resource_size(res); |
Vivek Gautam | bae00c1 | 2014-05-10 17:30:10 +0530 | [diff] [blame] | 199 | hcd->regs = devm_ioremap_resource(&pdev->dev, res); |
| 200 | if (IS_ERR(hcd->regs)) { |
| 201 | err = PTR_ERR(hcd->regs); |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 202 | goto fail_io; |
| 203 | } |
| 204 | |
| 205 | irq = platform_get_irq(pdev, 0); |
| 206 | if (!irq) { |
| 207 | dev_err(&pdev->dev, "Failed to get IRQ\n"); |
| 208 | err = -ENODEV; |
Jingoo Han | 390a0a7 | 2012-06-28 16:30:30 +0900 | [diff] [blame] | 209 | goto fail_io; |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 210 | } |
| 211 | |
Vivek Gautam | ed993bf | 2013-01-22 18:30:43 +0530 | [diff] [blame] | 212 | if (exynos_ohci->otg) |
Manjunath Goudar | 50a97e0 | 2013-09-21 16:38:38 +0530 | [diff] [blame] | 213 | exynos_ohci->otg->set_host(exynos_ohci->otg, &hcd->self); |
Vivek Gautam | ed993bf | 2013-01-22 18:30:43 +0530 | [diff] [blame] | 214 | |
Manjunath Goudar | 50a97e0 | 2013-09-21 16:38:38 +0530 | [diff] [blame] | 215 | platform_set_drvdata(pdev, hcd); |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 216 | |
Vivek Gautam | 7d28e54 | 2014-05-05 10:32:57 +0530 | [diff] [blame] | 217 | err = exynos_ohci_phy_enable(&pdev->dev); |
| 218 | if (err) { |
| 219 | dev_err(&pdev->dev, "Failed to enable USB phy\n"); |
| 220 | goto fail_io; |
| 221 | } |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 222 | |
| 223 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); |
| 224 | if (err) { |
| 225 | dev_err(&pdev->dev, "Failed to add USB HCD\n"); |
Vivek Gautam | ed993bf | 2013-01-22 18:30:43 +0530 | [diff] [blame] | 226 | goto fail_add_hcd; |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 227 | } |
Peter Chen | 3c9740a | 2013-11-05 10:46:02 +0800 | [diff] [blame] | 228 | device_wakeup_enable(hcd->self.controller); |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 229 | return 0; |
| 230 | |
Vivek Gautam | ed993bf | 2013-01-22 18:30:43 +0530 | [diff] [blame] | 231 | fail_add_hcd: |
Vivek Gautam | 54969ed | 2014-05-05 10:33:42 +0530 | [diff] [blame] | 232 | exynos_ohci_phy_disable(&pdev->dev); |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 233 | fail_io: |
Thomas Abraham | c05c946 | 2012-10-03 08:41:37 +0900 | [diff] [blame] | 234 | clk_disable_unprepare(exynos_ohci->clk); |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 235 | fail_clk: |
| 236 | usb_put_hcd(hcd); |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 237 | return err; |
| 238 | } |
| 239 | |
Bill Pemberton | fb4e98a | 2012-11-19 13:26:20 -0500 | [diff] [blame] | 240 | static int exynos_ohci_remove(struct platform_device *pdev) |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 241 | { |
Manjunath Goudar | 50a97e0 | 2013-09-21 16:38:38 +0530 | [diff] [blame] | 242 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
| 243 | struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd); |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 244 | |
| 245 | usb_remove_hcd(hcd); |
| 246 | |
Vivek Gautam | ed993bf | 2013-01-22 18:30:43 +0530 | [diff] [blame] | 247 | if (exynos_ohci->otg) |
Manjunath Goudar | 50a97e0 | 2013-09-21 16:38:38 +0530 | [diff] [blame] | 248 | exynos_ohci->otg->set_host(exynos_ohci->otg, &hcd->self); |
Vivek Gautam | ed993bf | 2013-01-22 18:30:43 +0530 | [diff] [blame] | 249 | |
Vivek Gautam | 54969ed | 2014-05-05 10:33:42 +0530 | [diff] [blame] | 250 | exynos_ohci_phy_disable(&pdev->dev); |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 251 | |
Thomas Abraham | c05c946 | 2012-10-03 08:41:37 +0900 | [diff] [blame] | 252 | clk_disable_unprepare(exynos_ohci->clk); |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 253 | |
| 254 | usb_put_hcd(hcd); |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 255 | |
| 256 | return 0; |
| 257 | } |
| 258 | |
| 259 | static void exynos_ohci_shutdown(struct platform_device *pdev) |
| 260 | { |
Manjunath Goudar | 50a97e0 | 2013-09-21 16:38:38 +0530 | [diff] [blame] | 261 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 262 | |
| 263 | if (hcd->driver->shutdown) |
| 264 | hcd->driver->shutdown(hcd); |
| 265 | } |
| 266 | |
| 267 | #ifdef CONFIG_PM |
| 268 | static int exynos_ohci_suspend(struct device *dev) |
| 269 | { |
Manjunath Goudar | 50a97e0 | 2013-09-21 16:38:38 +0530 | [diff] [blame] | 270 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
| 271 | struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd); |
Majunath Goudar | 14982e3 | 2013-11-13 17:40:20 +0530 | [diff] [blame] | 272 | bool do_wakeup = device_may_wakeup(dev); |
Majunath Goudar | 14982e3 | 2013-11-13 17:40:20 +0530 | [diff] [blame] | 273 | int rc = ohci_suspend(hcd, do_wakeup); |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 274 | |
Majunath Goudar | 14982e3 | 2013-11-13 17:40:20 +0530 | [diff] [blame] | 275 | if (rc) |
| 276 | return rc; |
| 277 | |
Vivek Gautam | ed993bf | 2013-01-22 18:30:43 +0530 | [diff] [blame] | 278 | if (exynos_ohci->otg) |
Manjunath Goudar | 50a97e0 | 2013-09-21 16:38:38 +0530 | [diff] [blame] | 279 | exynos_ohci->otg->set_host(exynos_ohci->otg, &hcd->self); |
Vivek Gautam | ed993bf | 2013-01-22 18:30:43 +0530 | [diff] [blame] | 280 | |
Vivek Gautam | 54969ed | 2014-05-05 10:33:42 +0530 | [diff] [blame] | 281 | exynos_ohci_phy_disable(dev); |
Jingoo Han | e864abe | 2012-06-28 16:49:42 +0900 | [diff] [blame] | 282 | |
Thomas Abraham | c05c946 | 2012-10-03 08:41:37 +0900 | [diff] [blame] | 283 | clk_disable_unprepare(exynos_ohci->clk); |
Jingoo Han | e864abe | 2012-06-28 16:49:42 +0900 | [diff] [blame] | 284 | |
Majunath Goudar | 14982e3 | 2013-11-13 17:40:20 +0530 | [diff] [blame] | 285 | return 0; |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | static int exynos_ohci_resume(struct device *dev) |
| 289 | { |
Manjunath Goudar | 50a97e0 | 2013-09-21 16:38:38 +0530 | [diff] [blame] | 290 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
| 291 | struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd); |
Vivek Gautam | 7d28e54 | 2014-05-05 10:32:57 +0530 | [diff] [blame] | 292 | int ret; |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 293 | |
Thomas Abraham | c05c946 | 2012-10-03 08:41:37 +0900 | [diff] [blame] | 294 | clk_prepare_enable(exynos_ohci->clk); |
Jingoo Han | e864abe | 2012-06-28 16:49:42 +0900 | [diff] [blame] | 295 | |
Vivek Gautam | ed993bf | 2013-01-22 18:30:43 +0530 | [diff] [blame] | 296 | if (exynos_ohci->otg) |
Manjunath Goudar | 50a97e0 | 2013-09-21 16:38:38 +0530 | [diff] [blame] | 297 | exynos_ohci->otg->set_host(exynos_ohci->otg, &hcd->self); |
Vivek Gautam | ed993bf | 2013-01-22 18:30:43 +0530 | [diff] [blame] | 298 | |
Vivek Gautam | 7d28e54 | 2014-05-05 10:32:57 +0530 | [diff] [blame] | 299 | ret = exynos_ohci_phy_enable(dev); |
| 300 | if (ret) { |
| 301 | dev_err(dev, "Failed to enable USB phy\n"); |
| 302 | clk_disable_unprepare(exynos_ohci->clk); |
| 303 | return ret; |
| 304 | } |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 305 | |
Florian Fainelli | cfa49b4 | 2012-10-08 15:11:29 +0200 | [diff] [blame] | 306 | ohci_resume(hcd, false); |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 307 | |
| 308 | return 0; |
| 309 | } |
| 310 | #else |
| 311 | #define exynos_ohci_suspend NULL |
| 312 | #define exynos_ohci_resume NULL |
| 313 | #endif |
| 314 | |
Manjunath Goudar | 50a97e0 | 2013-09-21 16:38:38 +0530 | [diff] [blame] | 315 | static const struct ohci_driver_overrides exynos_overrides __initconst = { |
| 316 | .extra_priv_size = sizeof(struct exynos_ohci_hcd), |
| 317 | }; |
| 318 | |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 319 | static const struct dev_pm_ops exynos_ohci_pm_ops = { |
| 320 | .suspend = exynos_ohci_suspend, |
| 321 | .resume = exynos_ohci_resume, |
| 322 | }; |
| 323 | |
Vivek Gautam | d513893 | 2012-07-16 11:25:36 +0530 | [diff] [blame] | 324 | #ifdef CONFIG_OF |
| 325 | static const struct of_device_id exynos_ohci_match[] = { |
Vivek Gautam | 6e24777 | 2013-01-24 19:15:29 +0530 | [diff] [blame] | 326 | { .compatible = "samsung,exynos4210-ohci" }, |
Thomas Abraham | 2871782 | 2013-04-11 17:12:30 +0530 | [diff] [blame] | 327 | { .compatible = "samsung,exynos5440-ohci" }, |
Vivek Gautam | d513893 | 2012-07-16 11:25:36 +0530 | [diff] [blame] | 328 | {}, |
| 329 | }; |
| 330 | MODULE_DEVICE_TABLE(of, exynos_ohci_match); |
| 331 | #endif |
| 332 | |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 333 | static struct platform_driver exynos_ohci_driver = { |
| 334 | .probe = exynos_ohci_probe, |
Bill Pemberton | 7690417 | 2012-11-19 13:21:08 -0500 | [diff] [blame] | 335 | .remove = exynos_ohci_remove, |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 336 | .shutdown = exynos_ohci_shutdown, |
| 337 | .driver = { |
| 338 | .name = "exynos-ohci", |
| 339 | .owner = THIS_MODULE, |
| 340 | .pm = &exynos_ohci_pm_ops, |
Vivek Gautam | d513893 | 2012-07-16 11:25:36 +0530 | [diff] [blame] | 341 | .of_match_table = of_match_ptr(exynos_ohci_match), |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 342 | } |
| 343 | }; |
Manjunath Goudar | 50a97e0 | 2013-09-21 16:38:38 +0530 | [diff] [blame] | 344 | static int __init ohci_exynos_init(void) |
| 345 | { |
| 346 | if (usb_disabled()) |
| 347 | return -ENODEV; |
| 348 | |
| 349 | pr_info("%s: " DRIVER_DESC "\n", hcd_name); |
| 350 | ohci_init_driver(&exynos_ohci_hc_driver, &exynos_overrides); |
| 351 | return platform_driver_register(&exynos_ohci_driver); |
| 352 | } |
| 353 | module_init(ohci_exynos_init); |
| 354 | |
| 355 | static void __exit ohci_exynos_cleanup(void) |
| 356 | { |
| 357 | platform_driver_unregister(&exynos_ohci_driver); |
| 358 | } |
| 359 | module_exit(ohci_exynos_cleanup); |
Jingoo Han | 6219424 | 2011-12-23 11:20:54 +0900 | [diff] [blame] | 360 | |
| 361 | MODULE_ALIAS("platform:exynos-ohci"); |
| 362 | MODULE_AUTHOR("Jingoo Han <jg1.han@samsung.com>"); |
Manjunath Goudar | 50a97e0 | 2013-09-21 16:38:38 +0530 | [diff] [blame] | 363 | MODULE_LICENSE("GPL v2"); |