ehci-ps3.c revision b18ffd49e86102a9ed0a1cc83fdafe3891e844e5
1ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand/*
2ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand *  PS3 EHCI Host Controller driver
3ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand *
4ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand *  Copyright (C) 2006 Sony Computer Entertainment Inc.
5ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand *  Copyright 2006 Sony Corp.
6ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand *
7ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand *  This program is free software; you can redistribute it and/or modify
8ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand *  it under the terms of the GNU General Public License as published by
9ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand *  the Free Software Foundation; version 2 of the License.
10ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand *
11ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand *  This program is distributed in the hope that it will be useful,
12ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand *  GNU General Public License for more details.
15ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand *
16ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand *  You should have received a copy of the GNU General Public License
17ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand *  along with this program; if not, write to the Free Software
18ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand */
20ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
217a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand#include <asm/firmware.h>
22ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand#include <asm/ps3.h>
23ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
24ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levandstatic int ps3_ehci_hc_reset(struct usb_hcd *hcd)
25ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand{
26ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	int result;
27ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	struct ehci_hcd *ehci = hcd_to_ehci(hcd);
28ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
29ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	ehci->big_endian_mmio = 1;
30ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
31ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	ehci->caps = hcd->regs;
32ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	ehci->regs = hcd->regs + HC_LENGTH(ehci_readl(ehci,
33ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		&ehci->caps->hc_capbase));
34ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
35ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	dbg_hcs_params(ehci, "reset");
36ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	dbg_hcc_params(ehci, "reset");
37ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
38ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
39ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
40ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	result = ehci_halt(ehci);
41ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
42ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	if (result)
43ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		return result;
44ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
45ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	result = ehci_init(hcd);
46ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
47ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	if (result)
48ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		return result;
49ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
50af1c51fcb2aea23ec2dfe73b7d66515d1622e689Marcelo Tosatti	ehci_reset(ehci);
51ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
52ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	return result;
53ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand}
54ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
55ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levandstatic const struct hc_driver ps3_ehci_hc_driver = {
56ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	.description		= hcd_name,
57ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	.product_desc		= "PS3 EHCI Host Controller",
58ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	.hcd_priv_size		= sizeof(struct ehci_hcd),
59ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	.irq			= ehci_irq,
60ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	.flags			= HCD_MEMORY | HCD_USB2,
61ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	.reset			= ps3_ehci_hc_reset,
62ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	.start			= ehci_run,
63ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	.stop			= ehci_stop,
64ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	.shutdown		= ehci_shutdown,
65ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	.urb_enqueue		= ehci_urb_enqueue,
66ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	.urb_dequeue		= ehci_urb_dequeue,
67ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	.endpoint_disable	= ehci_endpoint_disable,
68b18ffd49e86102a9ed0a1cc83fdafe3891e844e5Alan Stern	.endpoint_reset		= ehci_endpoint_reset,
69ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	.get_frame_number	= ehci_get_frame,
70ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	.hub_status_data	= ehci_hub_status_data,
71ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	.hub_control		= ehci_hub_control,
72ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand#if defined(CONFIG_PM)
73ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	.bus_suspend		= ehci_bus_suspend,
74ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	.bus_resume		= ehci_bus_resume,
75ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand#endif
7690da096ee46b682011b7d549e52b81cf9742e60bBalaji Rao	.relinquish_port	= ehci_relinquish_port,
773a31155cfff0935e4b178f3dca733d2d60d2eb8dAlan Stern	.port_handed_over	= ehci_port_handed_over,
78ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand};
79ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
807a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levandstatic int ps3_ehci_probe(struct ps3_system_bus_device *dev)
81ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand{
82ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	int result;
83ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	struct usb_hcd *hcd;
84ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	unsigned int virq;
85284901a90a9e0b812ca3f5f852cbbfb60d10249dYang Hongyang	static u64 dummy_mask = DMA_BIT_MASK(32);
86ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
87ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	if (usb_disabled()) {
88ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		result = -ENODEV;
89ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		goto fail_start;
90ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	}
91ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
927a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	result = ps3_open_hv_device(dev);
937a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand
947a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	if (result) {
957a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand		dev_dbg(&dev->core, "%s:%d: ps3_open_hv_device failed\n",
967a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand			__func__, __LINE__);
977a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand		goto fail_open;
987a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	}
997a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand
1007a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	result = ps3_dma_region_create(dev->d_region);
1017a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand
1027a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	if (result) {
1037a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand		dev_dbg(&dev->core, "%s:%d: ps3_dma_region_create failed: "
1047a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand			"(%d)\n", __func__, __LINE__, result);
1057a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand		BUG_ON("check region type");
1067a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand		goto fail_dma_region;
1077a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	}
1087a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand
109ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	result = ps3_mmio_region_create(dev->m_region);
110ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
111ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	if (result) {
112ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		dev_dbg(&dev->core, "%s:%d: ps3_map_mmio_region failed\n",
113ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand			__func__, __LINE__);
114ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		result = -EPERM;
1157a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand		goto fail_mmio_region;
116ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	}
117ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
118ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	dev_dbg(&dev->core, "%s:%d: mmio mapped_addr %lxh\n", __func__,
119ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		__LINE__, dev->m_region->lpar_addr);
120ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
121dc4f60c25ae71e8278dcf909486e4aa34de7eecbGeoff Levand	result = ps3_io_irq_setup(PS3_BINDING_CPU_ANY, dev->interrupt_id, &virq);
122ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
123ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	if (result) {
124ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		dev_dbg(&dev->core, "%s:%d: ps3_construct_io_irq(%d) failed.\n",
125ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand			__func__, __LINE__, virq);
126ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		result = -EPERM;
127ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		goto fail_irq;
128ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	}
129ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
130ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	dev->core.dma_mask = &dummy_mask; /* FIXME: for improper usb code */
131ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
1327071a3ce0ca058ad2a9e3e8c33f30fb0bce62005Kay Sievers	hcd = usb_create_hcd(&ps3_ehci_hc_driver, &dev->core, dev_name(&dev->core));
133ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
134ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	if (!hcd) {
135ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		dev_dbg(&dev->core, "%s:%d: usb_create_hcd failed\n", __func__,
136ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand			__LINE__);
137ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		result = -ENOMEM;
138ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		goto fail_create_hcd;
139ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	}
140ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
141ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	hcd->rsrc_start = dev->m_region->lpar_addr;
142ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	hcd->rsrc_len = dev->m_region->len;
1437a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand
1447a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name))
1457a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand		dev_dbg(&dev->core, "%s:%d: request_mem_region failed\n",
1467a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand			__func__, __LINE__);
1477a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand
148ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	hcd->regs = ioremap(dev->m_region->lpar_addr, dev->m_region->len);
149ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
150ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	if (!hcd->regs) {
151ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		dev_dbg(&dev->core, "%s:%d: ioremap failed\n", __func__,
152ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand			__LINE__);
153ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		result = -EPERM;
154ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		goto fail_ioremap;
155ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	}
156ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
157ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	dev_dbg(&dev->core, "%s:%d: hcd->rsrc_start %lxh\n", __func__, __LINE__,
158ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		(unsigned long)hcd->rsrc_start);
159ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	dev_dbg(&dev->core, "%s:%d: hcd->rsrc_len   %lxh\n", __func__, __LINE__,
160ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		(unsigned long)hcd->rsrc_len);
161ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	dev_dbg(&dev->core, "%s:%d: hcd->regs       %lxh\n", __func__, __LINE__,
162ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		(unsigned long)hcd->regs);
163ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	dev_dbg(&dev->core, "%s:%d: virq            %lu\n", __func__, __LINE__,
164ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		(unsigned long)virq);
165ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
166ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	ps3_system_bus_set_driver_data(dev, hcd);
167ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
168ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	result = usb_add_hcd(hcd, virq, IRQF_DISABLED);
169ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
170ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	if (result) {
171ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		dev_dbg(&dev->core, "%s:%d: usb_add_hcd failed (%d)\n",
172ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand			__func__, __LINE__, result);
173ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		goto fail_add_hcd;
174ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	}
175ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
176ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	return result;
177ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
178ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levandfail_add_hcd:
179ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	iounmap(hcd->regs);
180ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levandfail_ioremap:
1817a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
182ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	usb_put_hcd(hcd);
183ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levandfail_create_hcd:
184dc4f60c25ae71e8278dcf909486e4aa34de7eecbGeoff Levand	ps3_io_irq_destroy(virq);
185ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levandfail_irq:
186ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	ps3_free_mmio_region(dev->m_region);
1877a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levandfail_mmio_region:
1887a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	ps3_dma_region_free(dev->d_region);
1897a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levandfail_dma_region:
1907a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	ps3_close_hv_device(dev);
1917a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levandfail_open:
192ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levandfail_start:
193ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	return result;
194ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand}
195ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
1967a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levandstatic int ps3_ehci_remove(struct ps3_system_bus_device *dev)
197ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand{
1987a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	unsigned int tmp;
199ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	struct usb_hcd *hcd =
200ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand		(struct usb_hcd *)ps3_system_bus_get_driver_data(dev);
201ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
2027a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	BUG_ON(!hcd);
2037a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand
2047a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	dev_dbg(&dev->core, "%s:%d: regs %p\n", __func__, __LINE__, hcd->regs);
2057a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	dev_dbg(&dev->core, "%s:%d: irq %u\n", __func__, __LINE__, hcd->irq);
2067a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand
2077a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	tmp = hcd->irq;
2087a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand
209ddcb01ff9bf49c4dbbb058423559f7bc90b89374Geoff Levand	ehci_shutdown(hcd);
2107a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	usb_remove_hcd(hcd);
2117a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand
212ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	ps3_system_bus_set_driver_data(dev, NULL);
213ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
2147a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	BUG_ON(!hcd->regs);
2157a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	iounmap(hcd->regs);
2167a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand
2177a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
2187a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	usb_put_hcd(hcd);
2197a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand
2207a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	ps3_io_irq_destroy(tmp);
2217a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	ps3_free_mmio_region(dev->m_region);
2227a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand
2237a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	ps3_dma_region_free(dev->d_region);
2247a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	ps3_close_hv_device(dev);
2257a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand
226ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	return 0;
227ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand}
228ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
2297a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levandstatic int ps3_ehci_driver_register(struct ps3_system_bus_driver *drv)
2307a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand{
2317a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	return firmware_has_feature(FW_FEATURE_PS3_LV1)
2327a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand		? ps3_system_bus_driver_register(drv)
2337a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand		: 0;
2347a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand}
2357a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand
2367a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levandstatic void ps3_ehci_driver_unregister(struct ps3_system_bus_driver *drv)
2377a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand{
2387a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	if (firmware_has_feature(FW_FEATURE_PS3_LV1))
2397a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand		ps3_system_bus_driver_unregister(drv);
2407a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand}
2417a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand
2427a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff LevandMODULE_ALIAS(PS3_MODULE_ALIAS_EHCI);
243ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand
2447a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levandstatic struct ps3_system_bus_driver ps3_ehci_driver = {
2457a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	.core.name = "ps3-ehci-driver",
2467a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	.core.owner = THIS_MODULE,
247ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand	.match_id = PS3_MATCH_ID_EHCI,
2487a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	.probe = ps3_ehci_probe,
2497a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	.remove = ps3_ehci_remove,
2507a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand	.shutdown = ps3_ehci_remove,
251ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand};
252