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

USB: PS3: USB system-bus rework

USB HCD glue updates to reflect the new PS3 unifed device support.
- Fixed remove() routine.
- Added shutdown() routine.
- Added request_mem_region() call.
- Fixed MODULE_ALIAS().
- Made a proper fix for the hack done to support muti-platform in commit
48fda45120a819ca40cadc50144b55bff1c4c78d.

Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Geoff Levand and committed by
Greg Kroah-Hartman
7a4eb7fd 59c2afa0

+162 -53
+7 -15
drivers/usb/host/ehci-hcd.c
··· 41 41 #include <asm/irq.h> 42 42 #include <asm/system.h> 43 43 #include <asm/unaligned.h> 44 - #ifdef CONFIG_PPC_PS3 45 - #include <asm/firmware.h> 46 - #endif 47 - 48 44 49 45 /*-------------------------------------------------------------------------*/ 50 46 ··· 1008 1012 1009 1013 #ifdef CONFIG_PPC_PS3 1010 1014 #include "ehci-ps3.c" 1011 - #define PS3_SYSTEM_BUS_DRIVER ps3_ehci_sb_driver 1015 + #define PS3_SYSTEM_BUS_DRIVER ps3_ehci_driver 1012 1016 #endif 1013 1017 1014 1018 #ifdef CONFIG_440EPX ··· 1047 1051 #endif 1048 1052 1049 1053 #ifdef PS3_SYSTEM_BUS_DRIVER 1050 - if (firmware_has_feature(FW_FEATURE_PS3_LV1)) { 1051 - retval = ps3_system_bus_driver_register( 1052 - &PS3_SYSTEM_BUS_DRIVER); 1053 - if (retval < 0) { 1054 + retval = ps3_ehci_driver_register(&PS3_SYSTEM_BUS_DRIVER); 1055 + if (retval < 0) { 1054 1056 #ifdef PLATFORM_DRIVER 1055 - platform_driver_unregister(&PLATFORM_DRIVER); 1057 + platform_driver_unregister(&PLATFORM_DRIVER); 1056 1058 #endif 1057 1059 #ifdef PCI_DRIVER 1058 - pci_unregister_driver(&PCI_DRIVER); 1060 + pci_unregister_driver(&PCI_DRIVER); 1059 1061 #endif 1060 - return retval; 1061 - } 1062 + return retval; 1062 1063 } 1063 1064 #endif 1064 1065 ··· 1072 1079 pci_unregister_driver(&PCI_DRIVER); 1073 1080 #endif 1074 1081 #ifdef PS3_SYSTEM_BUS_DRIVER 1075 - if (firmware_has_feature(FW_FEATURE_PS3_LV1)) 1076 - ps3_system_bus_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1082 + ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1077 1083 #endif 1078 1084 } 1079 1085 module_exit(ehci_hcd_cleanup);
+74 -12
drivers/usb/host/ehci-ps3.c
··· 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 21 + #include <asm/firmware.h> 21 22 #include <asm/ps3.h> 22 23 23 24 static int ps3_ehci_hc_reset(struct usb_hcd *hcd) ··· 74 73 #endif 75 74 }; 76 75 77 - static int ps3_ehci_sb_probe(struct ps3_system_bus_device *dev) 76 + static int ps3_ehci_probe(struct ps3_system_bus_device *dev) 78 77 { 79 78 int result; 80 79 struct usb_hcd *hcd; ··· 86 85 goto fail_start; 87 86 } 88 87 88 + result = ps3_open_hv_device(dev); 89 + 90 + if (result) { 91 + dev_dbg(&dev->core, "%s:%d: ps3_open_hv_device failed\n", 92 + __func__, __LINE__); 93 + goto fail_open; 94 + } 95 + 96 + result = ps3_dma_region_create(dev->d_region); 97 + 98 + if (result) { 99 + dev_dbg(&dev->core, "%s:%d: ps3_dma_region_create failed: " 100 + "(%d)\n", __func__, __LINE__, result); 101 + BUG_ON("check region type"); 102 + goto fail_dma_region; 103 + } 104 + 89 105 result = ps3_mmio_region_create(dev->m_region); 90 106 91 107 if (result) { 92 108 dev_dbg(&dev->core, "%s:%d: ps3_map_mmio_region failed\n", 93 109 __func__, __LINE__); 94 110 result = -EPERM; 95 - goto fail_mmio; 111 + goto fail_mmio_region; 96 112 } 97 113 98 114 dev_dbg(&dev->core, "%s:%d: mmio mapped_addr %lxh\n", __func__, ··· 138 120 139 121 hcd->rsrc_start = dev->m_region->lpar_addr; 140 122 hcd->rsrc_len = dev->m_region->len; 123 + 124 + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) 125 + dev_dbg(&dev->core, "%s:%d: request_mem_region failed\n", 126 + __func__, __LINE__); 127 + 141 128 hcd->regs = ioremap(dev->m_region->lpar_addr, dev->m_region->len); 142 129 143 130 if (!hcd->regs) { ··· 176 153 fail_add_hcd: 177 154 iounmap(hcd->regs); 178 155 fail_ioremap: 156 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 179 157 usb_put_hcd(hcd); 180 158 fail_create_hcd: 181 159 ps3_io_irq_destroy(virq); 182 160 fail_irq: 183 161 ps3_free_mmio_region(dev->m_region); 184 - fail_mmio: 162 + fail_mmio_region: 163 + ps3_dma_region_free(dev->d_region); 164 + fail_dma_region: 165 + ps3_close_hv_device(dev); 166 + fail_open: 185 167 fail_start: 186 168 return result; 187 169 } 188 170 189 - static int ps3_ehci_sb_remove(struct ps3_system_bus_device *dev) 171 + static int ps3_ehci_remove(struct ps3_system_bus_device *dev) 190 172 { 173 + unsigned int tmp; 191 174 struct usb_hcd *hcd = 192 175 (struct usb_hcd *)ps3_system_bus_get_driver_data(dev); 193 176 194 - usb_put_hcd(hcd); 177 + BUG_ON(!hcd); 178 + 179 + dev_dbg(&dev->core, "%s:%d: regs %p\n", __func__, __LINE__, hcd->regs); 180 + dev_dbg(&dev->core, "%s:%d: irq %u\n", __func__, __LINE__, hcd->irq); 181 + 182 + tmp = hcd->irq; 183 + 184 + usb_remove_hcd(hcd); 185 + 195 186 ps3_system_bus_set_driver_data(dev, NULL); 187 + 188 + BUG_ON(!hcd->regs); 189 + iounmap(hcd->regs); 190 + 191 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 192 + usb_put_hcd(hcd); 193 + 194 + ps3_io_irq_destroy(tmp); 195 + ps3_free_mmio_region(dev->m_region); 196 + 197 + ps3_dma_region_free(dev->d_region); 198 + ps3_close_hv_device(dev); 196 199 197 200 return 0; 198 201 } 199 202 200 - MODULE_ALIAS("ps3-ehci"); 203 + static int ps3_ehci_driver_register(struct ps3_system_bus_driver *drv) 204 + { 205 + return firmware_has_feature(FW_FEATURE_PS3_LV1) 206 + ? ps3_system_bus_driver_register(drv) 207 + : 0; 208 + } 201 209 202 - static struct ps3_system_bus_driver ps3_ehci_sb_driver = { 210 + static void ps3_ehci_driver_unregister(struct ps3_system_bus_driver *drv) 211 + { 212 + if (firmware_has_feature(FW_FEATURE_PS3_LV1)) 213 + ps3_system_bus_driver_unregister(drv); 214 + } 215 + 216 + MODULE_ALIAS(PS3_MODULE_ALIAS_EHCI); 217 + 218 + static struct ps3_system_bus_driver ps3_ehci_driver = { 219 + .core.name = "ps3-ehci-driver", 220 + .core.owner = THIS_MODULE, 203 221 .match_id = PS3_MATCH_ID_EHCI, 204 - .core = { 205 - .name = "ps3-ehci-driver", 206 - }, 207 - .probe = ps3_ehci_sb_probe, 208 - .remove = ps3_ehci_sb_remove, 222 + .probe = ps3_ehci_probe, 223 + .remove = ps3_ehci_remove, 224 + .shutdown = ps3_ehci_remove, 209 225 };
+6 -14
drivers/usb/host/ohci-hcd.c
··· 42 42 #include <asm/system.h> 43 43 #include <asm/unaligned.h> 44 44 #include <asm/byteorder.h> 45 - #ifdef CONFIG_PPC_PS3 46 - #include <asm/firmware.h> 47 - #endif 48 45 49 46 #include "../core/hcd.h" 50 47 ··· 924 927 925 928 #ifdef CONFIG_PPC_PS3 926 929 #include "ohci-ps3.c" 927 - #define PS3_SYSTEM_BUS_DRIVER ps3_ohci_sb_driver 930 + #define PS3_SYSTEM_BUS_DRIVER ps3_ohci_driver 928 931 #endif 929 932 930 933 #if !defined(PCI_DRIVER) && \ ··· 947 950 sizeof (struct ed), sizeof (struct td)); 948 951 949 952 #ifdef PS3_SYSTEM_BUS_DRIVER 950 - if (firmware_has_feature(FW_FEATURE_PS3_LV1)) { 951 - retval = ps3_system_bus_driver_register( 952 - &PS3_SYSTEM_BUS_DRIVER); 953 - if (retval < 0) 954 - goto error_ps3; 955 - } 953 + retval = ps3_ohci_driver_register(&PS3_SYSTEM_BUS_DRIVER); 954 + if (retval < 0) 955 + goto error_ps3; 956 956 #endif 957 957 958 958 #ifdef PLATFORM_DRIVER ··· 995 1001 error_platform: 996 1002 #endif 997 1003 #ifdef PS3_SYSTEM_BUS_DRIVER 998 - if (firmware_has_feature(FW_FEATURE_PS3_LV1)) 999 - ps3_system_bus_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1004 + ps3_ohci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1000 1005 error_ps3: 1001 1006 #endif 1002 1007 return retval; ··· 1017 1024 platform_driver_unregister(&PLATFORM_DRIVER); 1018 1025 #endif 1019 1026 #ifdef PS3_SYSTEM_BUS_DRIVER 1020 - if (firmware_has_feature(FW_FEATURE_PS3_LV1)) 1021 - ps3_system_bus_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1027 + ps3_ohci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1022 1028 #endif 1023 1029 } 1024 1030 module_exit(ohci_hcd_mod_exit);
+75 -12
drivers/usb/host/ohci-ps3.c
··· 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 21 + #include <asm/firmware.h> 21 22 #include <asm/ps3.h> 22 23 23 24 static int ps3_ohci_hc_reset(struct usb_hcd *hcd) ··· 76 75 #endif 77 76 }; 78 77 79 - static int ps3_ohci_sb_probe(struct ps3_system_bus_device *dev) 78 + static int ps3_ohci_probe(struct ps3_system_bus_device *dev) 80 79 { 81 80 int result; 82 81 struct usb_hcd *hcd; ··· 88 87 goto fail_start; 89 88 } 90 89 90 + result = ps3_open_hv_device(dev); 91 + 92 + if (result) { 93 + dev_dbg(&dev->core, "%s:%d: ps3_open_hv_device failed: %s\n", 94 + __func__, __LINE__, ps3_result(result)); 95 + result = -EPERM; 96 + goto fail_open; 97 + } 98 + 99 + result = ps3_dma_region_create(dev->d_region); 100 + 101 + if (result) { 102 + dev_dbg(&dev->core, "%s:%d: ps3_dma_region_create failed: " 103 + "(%d)\n", __func__, __LINE__, result); 104 + BUG_ON("check region type"); 105 + goto fail_dma_region; 106 + } 107 + 91 108 result = ps3_mmio_region_create(dev->m_region); 92 109 93 110 if (result) { 94 111 dev_dbg(&dev->core, "%s:%d: ps3_map_mmio_region failed\n", 95 112 __func__, __LINE__); 96 113 result = -EPERM; 97 - goto fail_mmio; 114 + goto fail_mmio_region; 98 115 } 99 116 100 117 dev_dbg(&dev->core, "%s:%d: mmio mapped_addr %lxh\n", __func__, ··· 141 122 142 123 hcd->rsrc_start = dev->m_region->lpar_addr; 143 124 hcd->rsrc_len = dev->m_region->len; 125 + 126 + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) 127 + dev_dbg(&dev->core, "%s:%d: request_mem_region failed\n", 128 + __func__, __LINE__); 129 + 144 130 hcd->regs = ioremap(dev->m_region->lpar_addr, dev->m_region->len); 145 131 146 132 if (!hcd->regs) { ··· 179 155 fail_add_hcd: 180 156 iounmap(hcd->regs); 181 157 fail_ioremap: 158 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 182 159 usb_put_hcd(hcd); 183 160 fail_create_hcd: 184 161 ps3_io_irq_destroy(virq); 185 162 fail_irq: 186 163 ps3_free_mmio_region(dev->m_region); 187 - fail_mmio: 164 + fail_mmio_region: 165 + ps3_dma_region_free(dev->d_region); 166 + fail_dma_region: 167 + ps3_close_hv_device(dev); 168 + fail_open: 188 169 fail_start: 189 170 return result; 190 171 } 191 172 192 - static int ps3_ohci_sb_remove (struct ps3_system_bus_device *dev) 173 + static int ps3_ohci_remove (struct ps3_system_bus_device *dev) 193 174 { 175 + unsigned int tmp; 194 176 struct usb_hcd *hcd = 195 177 (struct usb_hcd *)ps3_system_bus_get_driver_data(dev); 196 178 197 - usb_put_hcd(hcd); 179 + BUG_ON(!hcd); 180 + 181 + dev_dbg(&dev->core, "%s:%d: regs %p\n", __func__, __LINE__, hcd->regs); 182 + dev_dbg(&dev->core, "%s:%d: irq %u\n", __func__, __LINE__, hcd->irq); 183 + 184 + tmp = hcd->irq; 185 + 186 + usb_remove_hcd(hcd); 187 + 198 188 ps3_system_bus_set_driver_data(dev, NULL); 189 + 190 + BUG_ON(!hcd->regs); 191 + iounmap(hcd->regs); 192 + 193 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 194 + usb_put_hcd(hcd); 195 + 196 + ps3_io_irq_destroy(tmp); 197 + ps3_free_mmio_region(dev->m_region); 198 + 199 + ps3_dma_region_free(dev->d_region); 200 + ps3_close_hv_device(dev); 199 201 200 202 return 0; 201 203 } 202 204 203 - MODULE_ALIAS("ps3-ohci"); 205 + static int ps3_ohci_driver_register(struct ps3_system_bus_driver *drv) 206 + { 207 + return firmware_has_feature(FW_FEATURE_PS3_LV1) 208 + ? ps3_system_bus_driver_register(drv) 209 + : 0; 210 + } 204 211 205 - static struct ps3_system_bus_driver ps3_ohci_sb_driver = { 212 + static void ps3_ohci_driver_unregister(struct ps3_system_bus_driver *drv) 213 + { 214 + if (firmware_has_feature(FW_FEATURE_PS3_LV1)) 215 + ps3_system_bus_driver_unregister(drv); 216 + } 217 + 218 + MODULE_ALIAS(PS3_MODULE_ALIAS_OHCI); 219 + 220 + static struct ps3_system_bus_driver ps3_ohci_driver = { 221 + .core.name = "ps3-ohci-driver", 222 + .core.owner = THIS_MODULE, 206 223 .match_id = PS3_MATCH_ID_OHCI, 207 - .core = { 208 - .name = "ps3-ohci-driver", 209 - }, 210 - .probe = ps3_ohci_sb_probe, 211 - .remove = ps3_ohci_sb_remove, 224 + .probe = ps3_ohci_probe, 225 + .remove = ps3_ohci_remove, 226 + .shutdown = ps3_ohci_remove, 212 227 };