Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v3.8-rc6 150 lines 3.6 kB view raw
1/* 2 * drivers/usb/host/ehci-vt8500.c 3 * 4 * Copyright (C) 2010 Alexey Charkov <alchark@gmail.com> 5 * 6 * Based on ehci-au1xxx.c 7 * 8 * This software is licensed under the terms of the GNU General Public 9 * License version 2, as published by the Free Software Foundation, and 10 * may be copied, distributed, and modified under those terms. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 */ 18 19#include <linux/of.h> 20#include <linux/platform_device.h> 21 22static const struct hc_driver vt8500_ehci_hc_driver = { 23 .description = hcd_name, 24 .product_desc = "VT8500 EHCI", 25 .hcd_priv_size = sizeof(struct ehci_hcd), 26 27 /* 28 * generic hardware linkage 29 */ 30 .irq = ehci_irq, 31 .flags = HCD_MEMORY | HCD_USB2, 32 33 /* 34 * basic lifecycle operations 35 */ 36 .reset = ehci_setup, 37 .start = ehci_run, 38 .stop = ehci_stop, 39 .shutdown = ehci_shutdown, 40 41 /* 42 * managing i/o requests and associated device resources 43 */ 44 .urb_enqueue = ehci_urb_enqueue, 45 .urb_dequeue = ehci_urb_dequeue, 46 .endpoint_disable = ehci_endpoint_disable, 47 .endpoint_reset = ehci_endpoint_reset, 48 49 /* 50 * scheduling support 51 */ 52 .get_frame_number = ehci_get_frame, 53 54 /* 55 * root hub support 56 */ 57 .hub_status_data = ehci_hub_status_data, 58 .hub_control = ehci_hub_control, 59 .bus_suspend = ehci_bus_suspend, 60 .bus_resume = ehci_bus_resume, 61 .relinquish_port = ehci_relinquish_port, 62 .port_handed_over = ehci_port_handed_over, 63 64 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, 65}; 66 67static u64 vt8500_ehci_dma_mask = DMA_BIT_MASK(32); 68 69static int vt8500_ehci_drv_probe(struct platform_device *pdev) 70{ 71 struct usb_hcd *hcd; 72 struct ehci_hcd *ehci; 73 struct resource *res; 74 int ret; 75 76 if (usb_disabled()) 77 return -ENODEV; 78 79 /* 80 * Right now device-tree probed devices don't get dma_mask set. 81 * Since shared usb code relies on it, set it here for now. 82 * Once we have dma capability bindings this can go away. 83 */ 84 if (!pdev->dev.dma_mask) 85 pdev->dev.dma_mask = &vt8500_ehci_dma_mask; 86 87 if (pdev->resource[1].flags != IORESOURCE_IRQ) { 88 pr_debug("resource[1] is not IORESOURCE_IRQ"); 89 return -ENOMEM; 90 } 91 hcd = usb_create_hcd(&vt8500_ehci_hc_driver, &pdev->dev, "VT8500"); 92 if (!hcd) 93 return -ENOMEM; 94 95 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 96 hcd->rsrc_start = res->start; 97 hcd->rsrc_len = resource_size(res); 98 99 hcd->regs = devm_request_and_ioremap(&pdev->dev, res); 100 if (!hcd->regs) { 101 pr_debug("ioremap failed"); 102 ret = -ENOMEM; 103 goto err1; 104 } 105 106 ehci = hcd_to_ehci(hcd); 107 ehci->caps = hcd->regs; 108 109 ret = usb_add_hcd(hcd, pdev->resource[1].start, 110 IRQF_SHARED); 111 if (ret == 0) { 112 platform_set_drvdata(pdev, hcd); 113 return ret; 114 } 115 116err1: 117 usb_put_hcd(hcd); 118 return ret; 119} 120 121static int vt8500_ehci_drv_remove(struct platform_device *pdev) 122{ 123 struct usb_hcd *hcd = platform_get_drvdata(pdev); 124 125 usb_remove_hcd(hcd); 126 usb_put_hcd(hcd); 127 platform_set_drvdata(pdev, NULL); 128 129 return 0; 130} 131 132static const struct of_device_id vt8500_ehci_ids[] = { 133 { .compatible = "via,vt8500-ehci", }, 134 { .compatible = "wm,prizm-ehci", }, 135 {} 136}; 137 138static struct platform_driver vt8500_ehci_driver = { 139 .probe = vt8500_ehci_drv_probe, 140 .remove = vt8500_ehci_drv_remove, 141 .shutdown = usb_hcd_platform_shutdown, 142 .driver = { 143 .name = "vt8500-ehci", 144 .owner = THIS_MODULE, 145 .of_match_table = of_match_ptr(vt8500_ehci_ids), 146 } 147}; 148 149MODULE_ALIAS("platform:vt8500-ehci"); 150MODULE_DEVICE_TABLE(of, vt8500_ehci_ids);