aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/firewire')
-rw-r--r--drivers/firewire/fw-ohci.c99
1 files changed, 42 insertions, 57 deletions
diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c
index 312182d6d970..92ff38f82d96 100644
--- a/drivers/firewire/fw-ohci.c
+++ b/drivers/firewire/fw-ohci.c
@@ -2054,17 +2054,9 @@ static const struct fw_card_driver ohci_driver = {
2054 .stop_iso = ohci_stop_iso, 2054 .stop_iso = ohci_stop_iso,
2055}; 2055};
2056 2056
2057static int __devinit
2058pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
2059{
2060 struct fw_ohci *ohci;
2061 u32 bus_options, max_receive, link_speed;
2062 u64 guid;
2063 int err;
2064 size_t size;
2065
2066#ifdef CONFIG_PPC_PMAC 2057#ifdef CONFIG_PPC_PMAC
2067 /* Necessary on some machines if fw-ohci was loaded/ unloaded before */ 2058static void ohci_pmac_on(struct pci_dev *dev)
2059{
2068 if (machine_is(powermac)) { 2060 if (machine_is(powermac)) {
2069 struct device_node *ofn = pci_device_to_OF_node(dev); 2061 struct device_node *ofn = pci_device_to_OF_node(dev);
2070 2062
@@ -2073,8 +2065,35 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
2073 pmac_call_feature(PMAC_FTR_1394_ENABLE, ofn, 0, 1); 2065 pmac_call_feature(PMAC_FTR_1394_ENABLE, ofn, 0, 1);
2074 } 2066 }
2075 } 2067 }
2068}
2069
2070static void ohci_pmac_off(struct pci_dev *dev)
2071{
2072 if (machine_is(powermac)) {
2073 struct device_node *ofn = pci_device_to_OF_node(dev);
2074
2075 if (ofn) {
2076 pmac_call_feature(PMAC_FTR_1394_ENABLE, ofn, 0, 0);
2077 pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, ofn, 0, 0);
2078 }
2079 }
2080}
2081#else
2082#define ohci_pmac_on(dev)
2083#define ohci_pmac_off(dev)
2076#endif /* CONFIG_PPC_PMAC */ 2084#endif /* CONFIG_PPC_PMAC */
2077 2085
2086static int __devinit
2087pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
2088{
2089 struct fw_ohci *ohci;
2090 u32 bus_options, max_receive, link_speed;
2091 u64 guid;
2092 int err;
2093 size_t size;
2094
2095 ohci_pmac_on(dev);
2096
2078 ohci = kzalloc(sizeof(*ohci), GFP_KERNEL); 2097 ohci = kzalloc(sizeof(*ohci), GFP_KERNEL);
2079 if (ohci == NULL) { 2098 if (ohci == NULL) {
2080 fw_error("Could not malloc fw_ohci data.\n"); 2099 fw_error("Could not malloc fw_ohci data.\n");
@@ -2212,75 +2231,41 @@ static void pci_remove(struct pci_dev *dev)
2212 pci_release_region(dev, 0); 2231 pci_release_region(dev, 0);
2213 pci_disable_device(dev); 2232 pci_disable_device(dev);
2214 kfree(&ohci->card); 2233 kfree(&ohci->card);
2215 2234 ohci_pmac_off(dev);
2216#ifdef CONFIG_PPC_PMAC
2217 /* On UniNorth, power down the cable and turn off the chip clock
2218 * to save power on laptops */
2219 if (machine_is(powermac)) {
2220 struct device_node *ofn = pci_device_to_OF_node(dev);
2221
2222 if (ofn) {
2223 pmac_call_feature(PMAC_FTR_1394_ENABLE, ofn, 0, 0);
2224 pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, ofn, 0, 0);
2225 }
2226 }
2227#endif /* CONFIG_PPC_PMAC */
2228 2235
2229 fw_notify("Removed fw-ohci device.\n"); 2236 fw_notify("Removed fw-ohci device.\n");
2230} 2237}
2231 2238
2232#ifdef CONFIG_PM 2239#ifdef CONFIG_PM
2233static int pci_suspend(struct pci_dev *pdev, pm_message_t state) 2240static int pci_suspend(struct pci_dev *dev, pm_message_t state)
2234{ 2241{
2235 struct fw_ohci *ohci = pci_get_drvdata(pdev); 2242 struct fw_ohci *ohci = pci_get_drvdata(dev);
2236 int err; 2243 int err;
2237 2244
2238 software_reset(ohci); 2245 software_reset(ohci);
2239 free_irq(pdev->irq, ohci); 2246 free_irq(dev->irq, ohci);
2240 err = pci_save_state(pdev); 2247 err = pci_save_state(dev);
2241 if (err) { 2248 if (err) {
2242 fw_error("pci_save_state failed\n"); 2249 fw_error("pci_save_state failed\n");
2243 return err; 2250 return err;
2244 } 2251 }
2245 err = pci_set_power_state(pdev, pci_choose_state(pdev, state)); 2252 err = pci_set_power_state(dev, pci_choose_state(dev, state));
2246 if (err) 2253 if (err)
2247 fw_error("pci_set_power_state failed with %d\n", err); 2254 fw_error("pci_set_power_state failed with %d\n", err);
2248 2255 ohci_pmac_off(dev);
2249/* PowerMac suspend code comes last */
2250#ifdef CONFIG_PPC_PMAC
2251 if (machine_is(powermac)) {
2252 struct device_node *ofn = pci_device_to_OF_node(pdev);
2253
2254 if (ofn) {
2255 pmac_call_feature(PMAC_FTR_1394_ENABLE, ofn, 0, 0);
2256 pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, ofn, 0, 0);
2257 }
2258 }
2259#endif /* CONFIG_PPC_PMAC */
2260 2256
2261 return 0; 2257 return 0;
2262} 2258}
2263 2259
2264static int pci_resume(struct pci_dev *pdev) 2260static int pci_resume(struct pci_dev *dev)
2265{ 2261{
2266 struct fw_ohci *ohci = pci_get_drvdata(pdev); 2262 struct fw_ohci *ohci = pci_get_drvdata(dev);
2267 int err; 2263 int err;
2268 2264
2269/* PowerMac resume code comes first */ 2265 ohci_pmac_on(dev);
2270#ifdef CONFIG_PPC_PMAC 2266 pci_set_power_state(dev, PCI_D0);
2271 if (machine_is(powermac)) { 2267 pci_restore_state(dev);
2272 struct device_node *ofn = pci_device_to_OF_node(pdev); 2268 err = pci_enable_device(dev);
2273
2274 if (ofn) {
2275 pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, ofn, 0, 1);
2276 pmac_call_feature(PMAC_FTR_1394_ENABLE, ofn, 0, 1);
2277 }
2278 }
2279#endif /* CONFIG_PPC_PMAC */
2280
2281 pci_set_power_state(pdev, PCI_D0);
2282 pci_restore_state(pdev);
2283 err = pci_enable_device(pdev);
2284 if (err) { 2269 if (err) {
2285 fw_error("pci_enable_device failed\n"); 2270 fw_error("pci_enable_device failed\n");
2286 return err; 2271 return err;