Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. |
Pavankumar Kondeti | 33f82f3 | 2010-12-07 17:54:03 +0530 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
Pavankumar Kondeti | 33f82f3 | 2010-12-07 17:54:03 +0530 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/platform_device.h> |
Pavankumar Kondeti | 2d0cdcc | 2010-12-07 17:54:05 +0530 | [diff] [blame] | 16 | #include <linux/pm_runtime.h> |
Pavankumar Kondeti | 33f82f3 | 2010-12-07 17:54:03 +0530 | [diff] [blame] | 17 | #include <linux/usb/msm_hsusb_hw.h> |
| 18 | #include <linux/usb/ulpi.h> |
| 19 | |
| 20 | #include "ci13xxx_udc.c" |
| 21 | |
| 22 | #define MSM_USB_BASE (udc->regs) |
| 23 | |
| 24 | static irqreturn_t msm_udc_irq(int irq, void *data) |
| 25 | { |
| 26 | return udc_irq(); |
| 27 | } |
| 28 | |
| 29 | static void ci13xxx_msm_notify_event(struct ci13xxx *udc, unsigned event) |
| 30 | { |
| 31 | struct device *dev = udc->gadget.dev.parent; |
Pavankumar Kondeti | 33f82f3 | 2010-12-07 17:54:03 +0530 | [diff] [blame] | 32 | |
| 33 | switch (event) { |
| 34 | case CI13XXX_CONTROLLER_RESET_EVENT: |
| 35 | dev_dbg(dev, "CI13XXX_CONTROLLER_RESET_EVENT received\n"); |
| 36 | writel(0, USB_AHBBURST); |
| 37 | writel(0, USB_AHBMODE); |
| 38 | break; |
Pavankumar Kondeti | 33f82f3 | 2010-12-07 17:54:03 +0530 | [diff] [blame] | 39 | default: |
| 40 | dev_dbg(dev, "unknown ci13xxx_udc event\n"); |
| 41 | break; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | static struct ci13xxx_udc_driver ci13xxx_msm_udc_driver = { |
| 46 | .name = "ci13xxx_msm", |
| 47 | .flags = CI13XXX_REGS_SHARED | |
| 48 | CI13XXX_REQUIRE_TRANSCEIVER | |
| 49 | CI13XXX_PULLUP_ON_VBUS | |
Vijayavardhan Vennapusa | d450cb0 | 2012-02-25 14:35:26 +0530 | [diff] [blame^] | 50 | CI13XXX_ZERO_ITC | |
| 51 | CI13XXX_IS_OTG, |
Pavankumar Kondeti | 33f82f3 | 2010-12-07 17:54:03 +0530 | [diff] [blame] | 52 | |
| 53 | .notify_event = ci13xxx_msm_notify_event, |
| 54 | }; |
| 55 | |
| 56 | static int ci13xxx_msm_probe(struct platform_device *pdev) |
| 57 | { |
| 58 | struct resource *res; |
| 59 | void __iomem *regs; |
| 60 | int irq; |
| 61 | int ret; |
| 62 | |
| 63 | dev_dbg(&pdev->dev, "ci13xxx_msm_probe\n"); |
| 64 | |
| 65 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 66 | if (!res) { |
| 67 | dev_err(&pdev->dev, "failed to get platform resource mem\n"); |
| 68 | return -ENXIO; |
| 69 | } |
| 70 | |
| 71 | regs = ioremap(res->start, resource_size(res)); |
| 72 | if (!regs) { |
| 73 | dev_err(&pdev->dev, "ioremap failed\n"); |
| 74 | return -ENOMEM; |
| 75 | } |
| 76 | |
| 77 | ret = udc_probe(&ci13xxx_msm_udc_driver, &pdev->dev, regs); |
| 78 | if (ret < 0) { |
| 79 | dev_err(&pdev->dev, "udc_probe failed\n"); |
| 80 | goto iounmap; |
| 81 | } |
| 82 | |
| 83 | irq = platform_get_irq(pdev, 0); |
| 84 | if (irq < 0) { |
| 85 | dev_err(&pdev->dev, "IRQ not found\n"); |
| 86 | ret = -ENXIO; |
| 87 | goto udc_remove; |
| 88 | } |
| 89 | |
| 90 | ret = request_irq(irq, msm_udc_irq, IRQF_SHARED, pdev->name, pdev); |
| 91 | if (ret < 0) { |
| 92 | dev_err(&pdev->dev, "request_irq failed\n"); |
| 93 | goto udc_remove; |
| 94 | } |
| 95 | |
Pavankumar Kondeti | 2d0cdcc | 2010-12-07 17:54:05 +0530 | [diff] [blame] | 96 | pm_runtime_no_callbacks(&pdev->dev); |
| 97 | pm_runtime_enable(&pdev->dev); |
| 98 | |
Pavankumar Kondeti | 33f82f3 | 2010-12-07 17:54:03 +0530 | [diff] [blame] | 99 | return 0; |
| 100 | |
| 101 | udc_remove: |
| 102 | udc_remove(); |
| 103 | iounmap: |
| 104 | iounmap(regs); |
| 105 | |
| 106 | return ret; |
| 107 | } |
| 108 | |
| 109 | static struct platform_driver ci13xxx_msm_driver = { |
| 110 | .probe = ci13xxx_msm_probe, |
| 111 | .driver = { .name = "msm_hsusb", }, |
| 112 | }; |
| 113 | |
| 114 | static int __init ci13xxx_msm_init(void) |
| 115 | { |
| 116 | return platform_driver_register(&ci13xxx_msm_driver); |
| 117 | } |
| 118 | module_init(ci13xxx_msm_init); |