xref: /openbmc/u-boot/drivers/usb/host/ehci-pci.c (revision 4cbd2928)
1 /*-
2  * Copyright (c) 2007-2008, Juniper Networks, Inc.
3  * All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation version 2 of
8  * the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18  * MA 02111-1307 USA
19  */
20 
21 #include <common.h>
22 #include <errno.h>
23 #include <pci.h>
24 #include <usb.h>
25 
26 #include "ehci.h"
27 
28 #ifdef CONFIG_PCI_EHCI_DEVICE
29 static struct pci_device_id ehci_pci_ids[] = {
30 	/* Please add supported PCI EHCI controller ids here */
31 	{0x1033, 0x00E0},	/* NEC */
32 	{0x10B9, 0x5239},	/* ULI1575 PCI EHCI module ids */
33 	{0x12D8, 0x400F},	/* Pericom */
34 	{0, 0}
35 };
36 #else
37 #endif
38 
39 /*
40  * Create the appropriate control structures to manage
41  * a new EHCI host controller.
42  */
43 int ehci_hcd_init(int index, enum usb_init_type init,
44 		struct ehci_hccr **ret_hccr, struct ehci_hcor **ret_hcor)
45 {
46 	pci_dev_t pdev;
47 	uint32_t cmd;
48 	struct ehci_hccr *hccr;
49 	struct ehci_hcor *hcor;
50 
51 #ifdef CONFIG_PCI_EHCI_DEVICE
52 	pdev = pci_find_devices(ehci_pci_ids, CONFIG_PCI_EHCI_DEVICE);
53 #else
54 	pdev = pci_find_class(PCI_CLASS_SERIAL_USB_EHCI, index);
55 #endif
56 	if (pdev < 0) {
57 		printf("EHCI host controller not found\n");
58 		return -1;
59 	}
60 
61 	hccr = (struct ehci_hccr *)pci_map_bar(pdev,
62 			PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
63 	hcor = (struct ehci_hcor *)((uint32_t) hccr +
64 			HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
65 
66 	debug("EHCI-PCI init hccr 0x%x and hcor 0x%x hc_length %d\n",
67 			(uint32_t)hccr, (uint32_t)hcor,
68 			(uint32_t)HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
69 
70 	*ret_hccr = hccr;
71 	*ret_hcor = hcor;
72 
73 	/* enable busmaster */
74 	pci_read_config_dword(pdev, PCI_COMMAND, &cmd);
75 	cmd |= PCI_COMMAND_MASTER;
76 	pci_write_config_dword(pdev, PCI_COMMAND, cmd);
77 	return 0;
78 }
79 
80 /*
81  * Destroy the appropriate control structures corresponding
82  * the the EHCI host controller.
83  */
84 int ehci_hcd_stop(int index)
85 {
86 	return 0;
87 }
88