2 * cardbus.c -- 16-bit PCMCIA core support
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * The initial developer of the original code is David A. Hinds
9 * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
10 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
12 * (C) 1999 David A. Hinds
16 * Cardbus handling has been re-written to be more of a PCI bridge thing,
17 * and the PCI code basically does all the resource handling.
23 #include <linux/kernel.h>
24 #include <linux/module.h>
25 #include <linux/pci.h>
27 #include <pcmcia/ss.h>
30 static void cardbus_config_irq_and_cls(struct pci_bus
*bus
, int irq
)
34 list_for_each_entry(dev
, &bus
->devices
, bus_list
) {
38 * Since there is only one interrupt available to
39 * CardBus devices, all devices downstream of this
40 * device must be using this IRQ.
42 pci_read_config_byte(dev
, PCI_INTERRUPT_PIN
, &irq_pin
);
45 pci_write_config_byte(dev
, PCI_INTERRUPT_LINE
, dev
->irq
);
49 * Some controllers transfer very slowly with 0 CLS.
50 * Configure it. This may fail as CLS configuration
51 * is mandatory only for MWI.
53 pci_set_cacheline_size(dev
);
56 cardbus_config_irq_and_cls(dev
->subordinate
, irq
);
61 * cb_alloc() - add CardBus device
62 * @s: the pcmcia_socket where the CardBus device is located
64 * cb_alloc() allocates the kernel data structures for a Cardbus device
65 * and handles the lowest level PCI device setup issues.
67 int __ref
cb_alloc(struct pcmcia_socket
*s
)
69 struct pci_bus
*bus
= s
->cb_dev
->subordinate
;
71 unsigned int max
, pass
;
73 pci_lock_rescan_remove();
75 s
->functions
= pci_scan_slot(bus
, PCI_DEVFN(0, 0));
76 pci_fixup_cardbus(bus
);
78 max
= bus
->busn_res
.start
;
79 for (pass
= 0; pass
< 2; pass
++)
80 list_for_each_entry(dev
, &bus
->devices
, bus_list
)
81 if (pci_is_bridge(dev
))
82 max
= pci_scan_bridge(bus
, dev
, max
, pass
);
85 * Size all resources below the CardBus controller.
87 pci_bus_size_bridges(bus
);
88 pci_bus_assign_resources(bus
);
89 cardbus_config_irq_and_cls(bus
, s
->pci_irq
);
91 /* socket specific tune function */
93 s
->tune_bridge(s
, bus
);
95 pci_bus_add_devices(bus
);
97 pci_unlock_rescan_remove();
102 * cb_free() - remove CardBus device
103 * @s: the pcmcia_socket where the CardBus device was located
105 * cb_free() handles the lowest level PCI device cleanup.
107 void cb_free(struct pcmcia_socket
*s
)
109 struct pci_dev
*bridge
, *dev
, *tmp
;
116 bus
= bridge
->subordinate
;
120 pci_lock_rescan_remove();
122 list_for_each_entry_safe(dev
, tmp
, &bus
->devices
, bus_list
)
123 pci_stop_and_remove_bus_device(dev
);
125 pci_unlock_rescan_remove();
This page took 0.032569 seconds and 5 git commands to generate.