Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 1 | /* |
| 2 | * SAMSUNG S5P USB HOST EHCI Controller |
| 3 | * |
| 4 | * Copyright (C) 2011 Samsung Electronics Co.Ltd |
| 5 | * Author: Jingoo Han <jg1.han@samsung.com> |
| 6 | * Author: Joonyoung Shim <jy0922.shim@samsung.com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License as published by the |
| 10 | * Free Software Foundation; either version 2 of the License, or (at your |
| 11 | * option) any later version. |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | #include <linux/clk.h> |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 16 | #include <linux/dma-mapping.h> |
| 17 | #include <linux/io.h> |
| 18 | #include <linux/kernel.h> |
| 19 | #include <linux/module.h> |
Vivek Gautam | 2c026e2 | 2012-07-16 11:25:37 +0530 | [diff] [blame] | 20 | #include <linux/of.h> |
Vivek Gautam | fd81d59 | 2012-07-17 10:10:50 +0530 | [diff] [blame] | 21 | #include <linux/of_gpio.h> |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 22 | #include <linux/platform_device.h> |
Arnd Bergmann | 436d42c | 2012-08-24 15:22:12 +0200 | [diff] [blame] | 23 | #include <linux/platform_data/usb-ehci-s5p.h> |
Vivek Gautam | d233c19 | 2013-01-22 18:30:42 +0530 | [diff] [blame] | 24 | #include <linux/usb/phy.h> |
Vivek Gautam | b506eeb | 2013-01-22 18:30:40 +0530 | [diff] [blame] | 25 | #include <linux/usb/samsung_usb_phy.h> |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 26 | #include <plat/usb-phy.h> |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 27 | #include <linux/usb.h> |
| 28 | #include <linux/usb/hcd.h> |
| 29 | #include <linux/usb/otg.h> |
| 30 | |
| 31 | #include "ehci.h" |
| 32 | |
| 33 | #define DRIVER_DESC "EHCI s5p driver" |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 34 | |
Jingoo Han | 88555a6 | 2012-03-05 10:40:14 +0900 | [diff] [blame] | 35 | #define EHCI_INSNREG00(base) (base + 0x90) |
| 36 | #define EHCI_INSNREG00_ENA_INCR16 (0x1 << 25) |
| 37 | #define EHCI_INSNREG00_ENA_INCR8 (0x1 << 24) |
| 38 | #define EHCI_INSNREG00_ENA_INCR4 (0x1 << 23) |
| 39 | #define EHCI_INSNREG00_ENA_INCRX_ALIGN (0x1 << 22) |
| 40 | #define EHCI_INSNREG00_ENABLE_DMA_BURST \ |
| 41 | (EHCI_INSNREG00_ENA_INCR16 | EHCI_INSNREG00_ENA_INCR8 | \ |
| 42 | EHCI_INSNREG00_ENA_INCR4 | EHCI_INSNREG00_ENA_INCRX_ALIGN) |
| 43 | |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 44 | static const char hcd_name[] = "ehci-s5p"; |
| 45 | static struct hc_driver __read_mostly s5p_ehci_hc_driver; |
| 46 | |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 47 | struct s5p_ehci_hcd { |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 48 | struct clk *clk; |
Vivek Gautam | d233c19 | 2013-01-22 18:30:42 +0530 | [diff] [blame] | 49 | struct usb_phy *phy; |
| 50 | struct usb_otg *otg; |
| 51 | struct s5p_ehci_platdata *pdata; |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 52 | }; |
| 53 | |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 54 | #define to_s5p_ehci(hcd) (struct s5p_ehci_hcd *)(hcd_to_ehci(hcd)->priv) |
Vivek Gautam | d233c19 | 2013-01-22 18:30:42 +0530 | [diff] [blame] | 55 | |
Vivek Gautam | fd81d59 | 2012-07-17 10:10:50 +0530 | [diff] [blame] | 56 | static void s5p_setup_vbus_gpio(struct platform_device *pdev) |
| 57 | { |
Doug Anderson | 3f3b55b | 2013-03-14 20:15:37 -0700 | [diff] [blame] | 58 | struct device *dev = &pdev->dev; |
Vivek Gautam | fd81d59 | 2012-07-17 10:10:50 +0530 | [diff] [blame] | 59 | int err; |
| 60 | int gpio; |
| 61 | |
Doug Anderson | 3f3b55b | 2013-03-14 20:15:37 -0700 | [diff] [blame] | 62 | if (!dev->of_node) |
Vivek Gautam | fd81d59 | 2012-07-17 10:10:50 +0530 | [diff] [blame] | 63 | return; |
| 64 | |
Doug Anderson | 3f3b55b | 2013-03-14 20:15:37 -0700 | [diff] [blame] | 65 | gpio = of_get_named_gpio(dev->of_node, "samsung,vbus-gpio", 0); |
Vivek Gautam | fd81d59 | 2012-07-17 10:10:50 +0530 | [diff] [blame] | 66 | if (!gpio_is_valid(gpio)) |
| 67 | return; |
| 68 | |
Doug Anderson | 3f3b55b | 2013-03-14 20:15:37 -0700 | [diff] [blame] | 69 | err = devm_gpio_request_one(dev, gpio, GPIOF_OUT_INIT_HIGH, |
| 70 | "ehci_vbus_gpio"); |
Vivek Gautam | fd81d59 | 2012-07-17 10:10:50 +0530 | [diff] [blame] | 71 | if (err) |
Doug Anderson | 3f3b55b | 2013-03-14 20:15:37 -0700 | [diff] [blame] | 72 | dev_err(dev, "can't request ehci vbus gpio %d", gpio); |
Vivek Gautam | fd81d59 | 2012-07-17 10:10:50 +0530 | [diff] [blame] | 73 | } |
| 74 | |
Vivek Gautam | 2c026e2 | 2012-07-16 11:25:37 +0530 | [diff] [blame] | 75 | static u64 ehci_s5p_dma_mask = DMA_BIT_MASK(32); |
| 76 | |
Bill Pemberton | 41ac7b3 | 2012-11-19 13:21:48 -0500 | [diff] [blame] | 77 | static int s5p_ehci_probe(struct platform_device *pdev) |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 78 | { |
Vivek Gautam | d233c19 | 2013-01-22 18:30:42 +0530 | [diff] [blame] | 79 | struct s5p_ehci_platdata *pdata = pdev->dev.platform_data; |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 80 | struct s5p_ehci_hcd *s5p_ehci; |
| 81 | struct usb_hcd *hcd; |
| 82 | struct ehci_hcd *ehci; |
| 83 | struct resource *res; |
Vivek Gautam | d233c19 | 2013-01-22 18:30:42 +0530 | [diff] [blame] | 84 | struct usb_phy *phy; |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 85 | int irq; |
| 86 | int err; |
| 87 | |
Vivek Gautam | 2c026e2 | 2012-07-16 11:25:37 +0530 | [diff] [blame] | 88 | /* |
| 89 | * Right now device-tree probed devices don't get dma_mask set. |
| 90 | * Since shared usb code relies on it, set it here for now. |
| 91 | * Once we move to full device tree support this will vanish off. |
| 92 | */ |
| 93 | if (!pdev->dev.dma_mask) |
| 94 | pdev->dev.dma_mask = &ehci_s5p_dma_mask; |
| 95 | if (!pdev->dev.coherent_dma_mask) |
| 96 | pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); |
| 97 | |
Vivek Gautam | fd81d59 | 2012-07-17 10:10:50 +0530 | [diff] [blame] | 98 | s5p_setup_vbus_gpio(pdev); |
| 99 | |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 100 | hcd = usb_create_hcd(&s5p_ehci_hc_driver, |
| 101 | &pdev->dev, dev_name(&pdev->dev)); |
| 102 | if (!hcd) { |
| 103 | dev_err(&pdev->dev, "Unable to create HCD\n"); |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 104 | return -ENOMEM; |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 105 | } |
| 106 | s5p_ehci = to_s5p_ehci(hcd); |
Vivek Gautam | d233c19 | 2013-01-22 18:30:42 +0530 | [diff] [blame] | 107 | phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); |
Felipe Balbi | a16283e | 2013-03-15 11:04:15 +0200 | [diff] [blame] | 108 | if (IS_ERR(phy)) { |
Vivek Gautam | d233c19 | 2013-01-22 18:30:42 +0530 | [diff] [blame] | 109 | /* Fallback to pdata */ |
| 110 | if (!pdata) { |
| 111 | dev_warn(&pdev->dev, "no platform data or transceiver defined\n"); |
| 112 | return -EPROBE_DEFER; |
| 113 | } else { |
| 114 | s5p_ehci->pdata = pdata; |
| 115 | } |
| 116 | } else { |
| 117 | s5p_ehci->phy = phy; |
| 118 | s5p_ehci->otg = phy->otg; |
| 119 | } |
| 120 | |
Julia Lawall | 63fd0ae | 2012-07-30 16:43:44 +0200 | [diff] [blame] | 121 | s5p_ehci->clk = devm_clk_get(&pdev->dev, "usbhost"); |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 122 | |
| 123 | if (IS_ERR(s5p_ehci->clk)) { |
| 124 | dev_err(&pdev->dev, "Failed to get usbhost clock\n"); |
| 125 | err = PTR_ERR(s5p_ehci->clk); |
| 126 | goto fail_clk; |
| 127 | } |
| 128 | |
Thomas Abraham | e1deb56 | 2012-10-03 08:40:42 +0900 | [diff] [blame] | 129 | err = clk_prepare_enable(s5p_ehci->clk); |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 130 | if (err) |
Julia Lawall | 63fd0ae | 2012-07-30 16:43:44 +0200 | [diff] [blame] | 131 | goto fail_clk; |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 132 | |
| 133 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 134 | if (!res) { |
| 135 | dev_err(&pdev->dev, "Failed to get I/O memory\n"); |
| 136 | err = -ENXIO; |
| 137 | goto fail_io; |
| 138 | } |
| 139 | |
| 140 | hcd->rsrc_start = res->start; |
| 141 | hcd->rsrc_len = resource_size(res); |
Jingoo Han | 9cb0756 | 2012-06-28 16:29:46 +0900 | [diff] [blame] | 142 | hcd->regs = devm_ioremap(&pdev->dev, res->start, hcd->rsrc_len); |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 143 | if (!hcd->regs) { |
| 144 | dev_err(&pdev->dev, "Failed to remap I/O memory\n"); |
| 145 | err = -ENOMEM; |
| 146 | goto fail_io; |
| 147 | } |
| 148 | |
| 149 | irq = platform_get_irq(pdev, 0); |
| 150 | if (!irq) { |
| 151 | dev_err(&pdev->dev, "Failed to get IRQ\n"); |
| 152 | err = -ENODEV; |
Jingoo Han | 9cb0756 | 2012-06-28 16:29:46 +0900 | [diff] [blame] | 153 | goto fail_io; |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 154 | } |
| 155 | |
Vivek Gautam | d233c19 | 2013-01-22 18:30:42 +0530 | [diff] [blame] | 156 | if (s5p_ehci->otg) |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 157 | s5p_ehci->otg->set_host(s5p_ehci->otg, &hcd->self); |
Vivek Gautam | d233c19 | 2013-01-22 18:30:42 +0530 | [diff] [blame] | 158 | |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 159 | if (s5p_ehci->phy) |
| 160 | usb_phy_init(s5p_ehci->phy); |
| 161 | else if (s5p_ehci->pdata->phy_init) |
| 162 | s5p_ehci->pdata->phy_init(pdev, USB_PHY_TYPE_HOST); |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 163 | |
| 164 | ehci = hcd_to_ehci(hcd); |
| 165 | ehci->caps = hcd->regs; |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 166 | |
Jingoo Han | 88555a6 | 2012-03-05 10:40:14 +0900 | [diff] [blame] | 167 | /* DMA burst Enable */ |
| 168 | writel(EHCI_INSNREG00_ENABLE_DMA_BURST, EHCI_INSNREG00(hcd->regs)); |
| 169 | |
Yong Zhang | b5dd18d | 2011-09-07 16:10:52 +0800 | [diff] [blame] | 170 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 171 | if (err) { |
| 172 | dev_err(&pdev->dev, "Failed to add USB HCD\n"); |
Vivek Gautam | d233c19 | 2013-01-22 18:30:42 +0530 | [diff] [blame] | 173 | goto fail_add_hcd; |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 174 | } |
| 175 | |
Vivek Gautam | bbcd85a | 2013-04-09 18:42:11 +0530 | [diff] [blame^] | 176 | platform_set_drvdata(pdev, hcd); |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 177 | |
| 178 | return 0; |
| 179 | |
Vivek Gautam | d233c19 | 2013-01-22 18:30:42 +0530 | [diff] [blame] | 180 | fail_add_hcd: |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 181 | if (s5p_ehci->phy) |
| 182 | usb_phy_shutdown(s5p_ehci->phy); |
| 183 | else if (s5p_ehci->pdata->phy_exit) |
| 184 | s5p_ehci->pdata->phy_exit(pdev, USB_PHY_TYPE_HOST); |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 185 | fail_io: |
Thomas Abraham | e1deb56 | 2012-10-03 08:40:42 +0900 | [diff] [blame] | 186 | clk_disable_unprepare(s5p_ehci->clk); |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 187 | fail_clk: |
| 188 | usb_put_hcd(hcd); |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 189 | return err; |
| 190 | } |
| 191 | |
Bill Pemberton | fb4e98a | 2012-11-19 13:26:20 -0500 | [diff] [blame] | 192 | static int s5p_ehci_remove(struct platform_device *pdev) |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 193 | { |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 194 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
| 195 | struct s5p_ehci_hcd *s5p_ehci = to_s5p_ehci(hcd); |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 196 | |
| 197 | usb_remove_hcd(hcd); |
| 198 | |
Vivek Gautam | d233c19 | 2013-01-22 18:30:42 +0530 | [diff] [blame] | 199 | if (s5p_ehci->otg) |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 200 | s5p_ehci->otg->set_host(s5p_ehci->otg, &hcd->self); |
Vivek Gautam | d233c19 | 2013-01-22 18:30:42 +0530 | [diff] [blame] | 201 | |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 202 | if (s5p_ehci->phy) |
| 203 | usb_phy_shutdown(s5p_ehci->phy); |
| 204 | else if (s5p_ehci->pdata->phy_exit) |
| 205 | s5p_ehci->pdata->phy_exit(pdev, USB_PHY_TYPE_HOST); |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 206 | |
Thomas Abraham | e1deb56 | 2012-10-03 08:40:42 +0900 | [diff] [blame] | 207 | clk_disable_unprepare(s5p_ehci->clk); |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 208 | |
| 209 | usb_put_hcd(hcd); |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 210 | |
| 211 | return 0; |
| 212 | } |
| 213 | |
| 214 | static void s5p_ehci_shutdown(struct platform_device *pdev) |
| 215 | { |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 216 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 217 | |
| 218 | if (hcd->driver->shutdown) |
| 219 | hcd->driver->shutdown(hcd); |
| 220 | } |
| 221 | |
Jingoo Han | 1acb30e | 2011-05-20 20:48:33 +0900 | [diff] [blame] | 222 | #ifdef CONFIG_PM |
| 223 | static int s5p_ehci_suspend(struct device *dev) |
| 224 | { |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 225 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
| 226 | struct s5p_ehci_hcd *s5p_ehci = to_s5p_ehci(hcd); |
| 227 | struct platform_device *pdev = to_platform_device(dev); |
| 228 | |
Alan Stern | c5cf921 | 2012-06-28 11:19:02 -0400 | [diff] [blame] | 229 | bool do_wakeup = device_may_wakeup(dev); |
Alan Stern | c5cf921 | 2012-06-28 11:19:02 -0400 | [diff] [blame] | 230 | int rc; |
Jingoo Han | 1acb30e | 2011-05-20 20:48:33 +0900 | [diff] [blame] | 231 | |
Alan Stern | c5cf921 | 2012-06-28 11:19:02 -0400 | [diff] [blame] | 232 | rc = ehci_suspend(hcd, do_wakeup); |
Jingoo Han | 1acb30e | 2011-05-20 20:48:33 +0900 | [diff] [blame] | 233 | |
Vivek Gautam | d233c19 | 2013-01-22 18:30:42 +0530 | [diff] [blame] | 234 | if (s5p_ehci->otg) |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 235 | s5p_ehci->otg->set_host(s5p_ehci->otg, &hcd->self); |
Vivek Gautam | d233c19 | 2013-01-22 18:30:42 +0530 | [diff] [blame] | 236 | |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 237 | if (s5p_ehci->phy) |
| 238 | usb_phy_shutdown(s5p_ehci->phy); |
| 239 | else if (s5p_ehci->pdata->phy_exit) |
| 240 | s5p_ehci->pdata->phy_exit(pdev, USB_PHY_TYPE_HOST); |
Jingoo Han | 1acb30e | 2011-05-20 20:48:33 +0900 | [diff] [blame] | 241 | |
Thomas Abraham | e1deb56 | 2012-10-03 08:40:42 +0900 | [diff] [blame] | 242 | clk_disable_unprepare(s5p_ehci->clk); |
Jingoo Han | 8b4fc8c | 2012-04-13 11:06:36 +0900 | [diff] [blame] | 243 | |
Jingoo Han | 1acb30e | 2011-05-20 20:48:33 +0900 | [diff] [blame] | 244 | return rc; |
| 245 | } |
| 246 | |
| 247 | static int s5p_ehci_resume(struct device *dev) |
| 248 | { |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 249 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
| 250 | struct s5p_ehci_hcd *s5p_ehci = to_s5p_ehci(hcd); |
| 251 | struct platform_device *pdev = to_platform_device(dev); |
Jingoo Han | 1acb30e | 2011-05-20 20:48:33 +0900 | [diff] [blame] | 252 | |
Thomas Abraham | e1deb56 | 2012-10-03 08:40:42 +0900 | [diff] [blame] | 253 | clk_prepare_enable(s5p_ehci->clk); |
Jingoo Han | 8b4fc8c | 2012-04-13 11:06:36 +0900 | [diff] [blame] | 254 | |
Vivek Gautam | d233c19 | 2013-01-22 18:30:42 +0530 | [diff] [blame] | 255 | if (s5p_ehci->otg) |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 256 | s5p_ehci->otg->set_host(s5p_ehci->otg, &hcd->self); |
Vivek Gautam | d233c19 | 2013-01-22 18:30:42 +0530 | [diff] [blame] | 257 | |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 258 | if (s5p_ehci->phy) |
| 259 | usb_phy_init(s5p_ehci->phy); |
| 260 | else if (s5p_ehci->pdata->phy_init) |
| 261 | s5p_ehci->pdata->phy_init(pdev, USB_PHY_TYPE_HOST); |
Jingoo Han | 1acb30e | 2011-05-20 20:48:33 +0900 | [diff] [blame] | 262 | |
Jingoo Han | 88555a6 | 2012-03-05 10:40:14 +0900 | [diff] [blame] | 263 | /* DMA burst Enable */ |
| 264 | writel(EHCI_INSNREG00_ENABLE_DMA_BURST, EHCI_INSNREG00(hcd->regs)); |
| 265 | |
Alan Stern | c5cf921 | 2012-06-28 11:19:02 -0400 | [diff] [blame] | 266 | ehci_resume(hcd, false); |
Jingoo Han | 1acb30e | 2011-05-20 20:48:33 +0900 | [diff] [blame] | 267 | return 0; |
| 268 | } |
| 269 | #else |
| 270 | #define s5p_ehci_suspend NULL |
| 271 | #define s5p_ehci_resume NULL |
| 272 | #endif |
| 273 | |
| 274 | static const struct dev_pm_ops s5p_ehci_pm_ops = { |
| 275 | .suspend = s5p_ehci_suspend, |
| 276 | .resume = s5p_ehci_resume, |
| 277 | }; |
| 278 | |
Vivek Gautam | 2c026e2 | 2012-07-16 11:25:37 +0530 | [diff] [blame] | 279 | #ifdef CONFIG_OF |
| 280 | static const struct of_device_id exynos_ehci_match[] = { |
Vivek Gautam | 6e24777 | 2013-01-24 19:15:29 +0530 | [diff] [blame] | 281 | { .compatible = "samsung,exynos4210-ehci" }, |
Vivek Gautam | 2c026e2 | 2012-07-16 11:25:37 +0530 | [diff] [blame] | 282 | {}, |
| 283 | }; |
| 284 | MODULE_DEVICE_TABLE(of, exynos_ehci_match); |
| 285 | #endif |
| 286 | |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 287 | static struct platform_driver s5p_ehci_driver = { |
| 288 | .probe = s5p_ehci_probe, |
Bill Pemberton | 7690417 | 2012-11-19 13:21:08 -0500 | [diff] [blame] | 289 | .remove = s5p_ehci_remove, |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 290 | .shutdown = s5p_ehci_shutdown, |
| 291 | .driver = { |
| 292 | .name = "s5p-ehci", |
| 293 | .owner = THIS_MODULE, |
Jingoo Han | 1acb30e | 2011-05-20 20:48:33 +0900 | [diff] [blame] | 294 | .pm = &s5p_ehci_pm_ops, |
Vivek Gautam | 2c026e2 | 2012-07-16 11:25:37 +0530 | [diff] [blame] | 295 | .of_match_table = of_match_ptr(exynos_ehci_match), |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 296 | } |
| 297 | }; |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 298 | static const struct ehci_driver_overrides s5p_overrides __initdata = { |
| 299 | .extra_priv_size = sizeof(struct s5p_ehci_hcd), |
| 300 | }; |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 301 | |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 302 | static int __init ehci_s5p_init(void) |
| 303 | { |
| 304 | if (usb_disabled()) |
| 305 | return -ENODEV; |
| 306 | |
| 307 | pr_info("%s: " DRIVER_DESC "\n", hcd_name); |
| 308 | ehci_init_driver(&s5p_ehci_hc_driver, &s5p_overrides); |
| 309 | return platform_driver_register(&s5p_ehci_driver); |
| 310 | } |
| 311 | module_init(ehci_s5p_init); |
| 312 | |
| 313 | static void __exit ehci_s5p_cleanup(void) |
| 314 | { |
| 315 | platform_driver_unregister(&s5p_ehci_driver); |
| 316 | } |
| 317 | module_exit(ehci_s5p_cleanup); |
| 318 | |
| 319 | MODULE_DESCRIPTION(DRIVER_DESC); |
Joonyoung Shim | 1bcc5aa | 2011-04-08 14:08:50 +0900 | [diff] [blame] | 320 | MODULE_ALIAS("platform:s5p-ehci"); |
Manjunath Goudar | 7edb3da | 2013-04-02 18:24:01 +0200 | [diff] [blame] | 321 | MODULE_AUTHOR("Jingoo Han"); |
| 322 | MODULE_AUTHOR("Joonyoung Shim"); |
| 323 | MODULE_LICENSE("GPL v2"); |