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 249187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levandstatic void ps3_ehci_setup_insnreg(struct ehci_hcd *ehci) 259187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand{ 269187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand /* PS3 HC internal setup register offsets. */ 279187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand 289187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand enum ps3_ehci_hc_insnreg { 299187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand ps3_ehci_hc_insnreg01 = 0x084, 309187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand ps3_ehci_hc_insnreg02 = 0x088, 319187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand ps3_ehci_hc_insnreg03 = 0x08c, 329187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand }; 339187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand 349187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand /* PS3 EHCI HC errata fix 316 - The PS3 EHCI HC will reset its 359187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand * internal INSNREGXX setup regs back to the chip default values 369187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand * on Host Controller Reset (CMD_RESET) or Light Host Controller 379187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand * Reset (CMD_LRESET). The work-around for this is for the HC 389187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand * driver to re-initialise these regs when ever the HC is reset. 399187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand */ 409187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand 419187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand /* Set burst transfer counts to 256 out, 32 in. */ 429187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand 439187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand writel_be(0x01000020, (void __iomem *)ehci->regs + 449187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand ps3_ehci_hc_insnreg01); 459187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand 469187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand /* Enable burst transfer counts. */ 479187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand 489187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand writel_be(0x00000001, (void __iomem *)ehci->regs + 499187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand ps3_ehci_hc_insnreg03); 509187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand} 519187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand 52ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levandstatic int ps3_ehci_hc_reset(struct usb_hcd *hcd) 53ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand{ 54ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand int result; 55ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand struct ehci_hcd *ehci = hcd_to_ehci(hcd); 56ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 57ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand ehci->big_endian_mmio = 1; 58ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand ehci->caps = hcd->regs; 59ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 601a49e2ac9651df7349867a5cf44e2c83de1046afAlan Stern result = ehci_setup(hcd); 61ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand if (result) 62ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand return result; 63ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 649187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand ps3_ehci_setup_insnreg(ehci); 659187bef2fa395e85d5e22c4792b553d98410ccd6Geoff Levand 66ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand return result; 67ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand} 68ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 69ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levandstatic const struct hc_driver ps3_ehci_hc_driver = { 70ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand .description = hcd_name, 71ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand .product_desc = "PS3 EHCI Host Controller", 72ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand .hcd_priv_size = sizeof(struct ehci_hcd), 73ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand .irq = ehci_irq, 74c04ee4b1136e462722567cf6e76bb35a181574a7Greg Kroah-Hartman .flags = HCD_MEMORY | HCD_USB2 | HCD_BH, 75ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand .reset = ps3_ehci_hc_reset, 76ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand .start = ehci_run, 77ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand .stop = ehci_stop, 78ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand .shutdown = ehci_shutdown, 79ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand .urb_enqueue = ehci_urb_enqueue, 80ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand .urb_dequeue = ehci_urb_dequeue, 81ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand .endpoint_disable = ehci_endpoint_disable, 82b18ffd49e86102a9ed0a1cc83fdafe3891e844e5Alan Stern .endpoint_reset = ehci_endpoint_reset, 83ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand .get_frame_number = ehci_get_frame, 84ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand .hub_status_data = ehci_hub_status_data, 85ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand .hub_control = ehci_hub_control, 86ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand#if defined(CONFIG_PM) 87ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand .bus_suspend = ehci_bus_suspend, 88ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand .bus_resume = ehci_bus_resume, 89ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand#endif 9090da096ee46b682011b7d549e52b81cf9742e60bBalaji Rao .relinquish_port = ehci_relinquish_port, 913a31155cfff0935e4b178f3dca733d2d60d2eb8dAlan Stern .port_handed_over = ehci_port_handed_over, 92914b701280a76f96890ad63eb0fa99bf204b961cAlan Stern 93914b701280a76f96890ad63eb0fa99bf204b961cAlan Stern .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, 94ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand}; 95ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 9641ac7b3ab7fe1d6175839947a877fdf95cbd2211Bill Pembertonstatic int ps3_ehci_probe(struct ps3_system_bus_device *dev) 97ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand{ 98ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand int result; 99ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand struct usb_hcd *hcd; 100ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand unsigned int virq; 101284901a90a9e0b812ca3f5f852cbbfb60d10249dYang Hongyang static u64 dummy_mask = DMA_BIT_MASK(32); 102ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 103ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand if (usb_disabled()) { 104ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand result = -ENODEV; 105ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand goto fail_start; 106ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand } 107ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 1087a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand result = ps3_open_hv_device(dev); 1097a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand 1107a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand if (result) { 1117a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand dev_dbg(&dev->core, "%s:%d: ps3_open_hv_device failed\n", 1127a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand __func__, __LINE__); 1137a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand goto fail_open; 1147a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand } 1157a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand 1167a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand result = ps3_dma_region_create(dev->d_region); 1177a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand 1187a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand if (result) { 1197a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand dev_dbg(&dev->core, "%s:%d: ps3_dma_region_create failed: " 1207a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand "(%d)\n", __func__, __LINE__, result); 1217a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand BUG_ON("check region type"); 1227a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand goto fail_dma_region; 1237a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand } 1247a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand 125ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand result = ps3_mmio_region_create(dev->m_region); 126ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 127ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand if (result) { 128ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand dev_dbg(&dev->core, "%s:%d: ps3_map_mmio_region failed\n", 129ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand __func__, __LINE__); 130ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand result = -EPERM; 1317a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand goto fail_mmio_region; 132ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand } 133ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 134ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand dev_dbg(&dev->core, "%s:%d: mmio mapped_addr %lxh\n", __func__, 135ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand __LINE__, dev->m_region->lpar_addr); 136ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 137dc4f60c25ae71e8278dcf909486e4aa34de7eecbGeoff Levand result = ps3_io_irq_setup(PS3_BINDING_CPU_ANY, dev->interrupt_id, &virq); 138ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 139ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand if (result) { 140ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand dev_dbg(&dev->core, "%s:%d: ps3_construct_io_irq(%d) failed.\n", 141ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand __func__, __LINE__, virq); 142ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand result = -EPERM; 143ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand goto fail_irq; 144ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand } 145ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 146ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand dev->core.dma_mask = &dummy_mask; /* FIXME: for improper usb code */ 147ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 1487071a3ce0ca058ad2a9e3e8c33f30fb0bce62005Kay Sievers hcd = usb_create_hcd(&ps3_ehci_hc_driver, &dev->core, dev_name(&dev->core)); 149ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 150ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand if (!hcd) { 151ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand dev_dbg(&dev->core, "%s:%d: usb_create_hcd failed\n", __func__, 152ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand __LINE__); 153ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand result = -ENOMEM; 154ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand goto fail_create_hcd; 155ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand } 156ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 157ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand hcd->rsrc_start = dev->m_region->lpar_addr; 158ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand hcd->rsrc_len = dev->m_region->len; 1597a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand 1607a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) 1617a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand dev_dbg(&dev->core, "%s:%d: request_mem_region failed\n", 1627a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand __func__, __LINE__); 1637a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand 164ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand hcd->regs = ioremap(dev->m_region->lpar_addr, dev->m_region->len); 165ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 166ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand if (!hcd->regs) { 167ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand dev_dbg(&dev->core, "%s:%d: ioremap failed\n", __func__, 168ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand __LINE__); 169ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand result = -EPERM; 170ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand goto fail_ioremap; 171ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand } 172ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 173ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand dev_dbg(&dev->core, "%s:%d: hcd->rsrc_start %lxh\n", __func__, __LINE__, 174ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand (unsigned long)hcd->rsrc_start); 175ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand dev_dbg(&dev->core, "%s:%d: hcd->rsrc_len %lxh\n", __func__, __LINE__, 176ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand (unsigned long)hcd->rsrc_len); 177ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand dev_dbg(&dev->core, "%s:%d: hcd->regs %lxh\n", __func__, __LINE__, 178ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand (unsigned long)hcd->regs); 179ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand dev_dbg(&dev->core, "%s:%d: virq %lu\n", __func__, __LINE__, 180ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand (unsigned long)virq); 181ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 18203fa68c245cccbcb99035cbabaa13b408ba91ab5Geert Uytterhoeven ps3_system_bus_set_drvdata(dev, hcd); 183ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 184b5dd18d8747010e3f3eb1cc76a49f94291938559Yong Zhang result = usb_add_hcd(hcd, virq, 0); 185ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 186ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand if (result) { 187ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand dev_dbg(&dev->core, "%s:%d: usb_add_hcd failed (%d)\n", 188ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand __func__, __LINE__, result); 189ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand goto fail_add_hcd; 190ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand } 191ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 1923c9740a117d40a74412775b5d3fe2b88a7635a0ePeter Chen device_wakeup_enable(hcd->self.controller); 193ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand return result; 194ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 195ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levandfail_add_hcd: 196ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand iounmap(hcd->regs); 197ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levandfail_ioremap: 1987a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 199ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand usb_put_hcd(hcd); 200ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levandfail_create_hcd: 201dc4f60c25ae71e8278dcf909486e4aa34de7eecbGeoff Levand ps3_io_irq_destroy(virq); 202ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levandfail_irq: 203ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand ps3_free_mmio_region(dev->m_region); 2047a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levandfail_mmio_region: 2057a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand ps3_dma_region_free(dev->d_region); 2067a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levandfail_dma_region: 2077a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand ps3_close_hv_device(dev); 2087a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levandfail_open: 209ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levandfail_start: 210ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand return result; 211ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand} 212ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 2137a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levandstatic int ps3_ehci_remove(struct ps3_system_bus_device *dev) 214ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand{ 2157a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand unsigned int tmp; 21603fa68c245cccbcb99035cbabaa13b408ba91ab5Geert Uytterhoeven struct usb_hcd *hcd = ps3_system_bus_get_drvdata(dev); 217ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 2187a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand BUG_ON(!hcd); 2197a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand 2207a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand dev_dbg(&dev->core, "%s:%d: regs %p\n", __func__, __LINE__, hcd->regs); 2217a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand dev_dbg(&dev->core, "%s:%d: irq %u\n", __func__, __LINE__, hcd->irq); 2227a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand 2237a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand tmp = hcd->irq; 2247a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand 2257a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand usb_remove_hcd(hcd); 2267a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand 22703fa68c245cccbcb99035cbabaa13b408ba91ab5Geert Uytterhoeven ps3_system_bus_set_drvdata(dev, NULL); 228ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 2297a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand BUG_ON(!hcd->regs); 2307a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand iounmap(hcd->regs); 2317a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand 2327a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 2337a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand usb_put_hcd(hcd); 2347a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand 2357a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand ps3_io_irq_destroy(tmp); 2367a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand ps3_free_mmio_region(dev->m_region); 2377a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand 2387a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand ps3_dma_region_free(dev->d_region); 2397a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand ps3_close_hv_device(dev); 2407a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand 241ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand return 0; 242ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand} 243ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 244313485175da221c388f6a8ecf4c30062ba9bea17Geert Uytterhoevenstatic int __init ps3_ehci_driver_register(struct ps3_system_bus_driver *drv) 2457a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand{ 2467a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand return firmware_has_feature(FW_FEATURE_PS3_LV1) 2477a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand ? ps3_system_bus_driver_register(drv) 2487a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand : 0; 2497a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand} 2507a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand 2517a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levandstatic void ps3_ehci_driver_unregister(struct ps3_system_bus_driver *drv) 2527a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand{ 2537a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand if (firmware_has_feature(FW_FEATURE_PS3_LV1)) 2547a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand ps3_system_bus_driver_unregister(drv); 2557a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand} 2567a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand 2577a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff LevandMODULE_ALIAS(PS3_MODULE_ALIAS_EHCI); 258ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand 2597a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levandstatic struct ps3_system_bus_driver ps3_ehci_driver = { 2607a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand .core.name = "ps3-ehci-driver", 2617a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand .core.owner = THIS_MODULE, 262ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand .match_id = PS3_MATCH_ID_EHCI, 2637a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand .probe = ps3_ehci_probe, 2647a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand .remove = ps3_ehci_remove, 2657a4eb7fd50d4df99fc1f623e6d90680d9fca3d82Geoff Levand .shutdown = ps3_ehci_remove, 266ad75a41085d80c8ce5e885962c15779935f8267eGeoff Levand}; 267