]> git.sur5r.net Git - u-boot/blob - drivers/usb/host/ehci-pci.c
usb: Update some EHCI driver licenses to use SPDX
[u-boot] / drivers / usb / host / ehci-pci.c
1 /*-
2  * Copyright (c) 2007-2008, Juniper Networks, Inc.
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier:     GPL-2.0
6  */
7
8 #include <common.h>
9 #include <errno.h>
10 #include <pci.h>
11 #include <usb.h>
12
13 #include "ehci.h"
14
15 #ifdef CONFIG_PCI_EHCI_DEVICE
16 static struct pci_device_id ehci_pci_ids[] = {
17         /* Please add supported PCI EHCI controller ids here */
18         {0x1033, 0x00E0},       /* NEC */
19         {0x10B9, 0x5239},       /* ULI1575 PCI EHCI module ids */
20         {0x12D8, 0x400F},       /* Pericom */
21         {0, 0}
22 };
23 #else
24 #endif
25
26 /*
27  * Create the appropriate control structures to manage
28  * a new EHCI host controller.
29  */
30 int ehci_hcd_init(int index, enum usb_init_type init,
31                 struct ehci_hccr **ret_hccr, struct ehci_hcor **ret_hcor)
32 {
33         pci_dev_t pdev;
34         uint32_t cmd;
35         struct ehci_hccr *hccr;
36         struct ehci_hcor *hcor;
37
38 #ifdef CONFIG_PCI_EHCI_DEVICE
39         pdev = pci_find_devices(ehci_pci_ids, CONFIG_PCI_EHCI_DEVICE);
40 #else
41         pdev = pci_find_class(PCI_CLASS_SERIAL_USB_EHCI, index);
42 #endif
43         if (pdev < 0) {
44                 printf("EHCI host controller not found\n");
45                 return -1;
46         }
47
48         hccr = (struct ehci_hccr *)pci_map_bar(pdev,
49                         PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
50         hcor = (struct ehci_hcor *)((uint32_t) hccr +
51                         HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
52
53         debug("EHCI-PCI init hccr 0x%x and hcor 0x%x hc_length %d\n",
54                         (uint32_t)hccr, (uint32_t)hcor,
55                         (uint32_t)HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
56
57         *ret_hccr = hccr;
58         *ret_hcor = hcor;
59
60         /* enable busmaster */
61         pci_read_config_dword(pdev, PCI_COMMAND, &cmd);
62         cmd |= PCI_COMMAND_MASTER;
63         pci_write_config_dword(pdev, PCI_COMMAND, cmd);
64         return 0;
65 }
66
67 /*
68  * Destroy the appropriate control structures corresponding
69  * the the EHCI host controller.
70  */
71 int ehci_hcd_stop(int index)
72 {
73         return 0;
74 }