10 #include <linux/kernel.h>
11 #include <linux/module.h>
12 #include <linux/pci.h>
26 pci_read_config_dword(pdev, reg, &rval);
27 rval = (rval &
mask) ^ xor;
28 pci_write_config_dword(pdev, reg, rval);
40 ~0x000000FF, 0x0000003F);
42 pci_read_config_dword(pdev, 0x48, &val);
53 ~0x00F00000, 0x00100000);
55 ~0x08000000, 0x08000000);
59 ~0x00000F00, 0x00000200);
61 ~0x00060000, 0x00040000);
77 for (nr = chip->
slots; nr; ++slot, --nr) {
79 if (handler_func && handler_func(slot))
88 static void cb710_release_slot(
struct device *
dev)
90 #ifdef CONFIG_CB710_DEBUG_ASSUMPTIONS
92 struct cb710_chip *chip = cb710_slot_to_chip(slot);
102 int nr = chip->
slots;
107 "register: %s.%d; slot %d; mask %d; IO offset: 0x%02X\n",
108 name, chip->
platform_id, nr, slot_mask, io_offset);
118 slot->
pdev.dev.parent = &chip->
pdev->dev;
119 slot->
pdev.dev.release = cb710_release_slot;
123 #ifdef CONFIG_CB710_DEBUG_ASSUMPTIONS
142 static void cb710_unregister_slot(
struct cb710_chip *chip,
145 int nr = chip->
slots - 1;
164 struct cb710_chip *chip = cb710_slot_to_chip(slot);
169 spin_unlock_irqrestore(&chip->
irq_lock, flags);
177 struct cb710_chip *chip = pci_get_drvdata(pdev);
187 static int cb710_resume(
struct pci_dev *pdev)
189 struct cb710_chip *chip = pci_get_drvdata(pdev);
198 return devm_request_irq(&pdev->
dev, pdev->
irq,
199 cb710_irq_handler,
IRQF_SHARED, KBUILD_MODNAME, chip);
213 err = cb710_pci_configure(pdev);
218 pci_read_config_dword(pdev, 0x48, &val);
219 if (!(val & 0x80000000)) {
220 pci_write_config_dword(pdev, 0x48, val|0x71000000);
221 pci_read_config_dword(pdev, 0x48, &val);
224 dev_dbg(&pdev->
dev,
"PCI config[0x48] = 0x%08X\n", val);
225 if (!(val & 0x70000000))
227 val = (val >> 28) & 7;
252 pci_set_drvdata(pdev, chip);
254 err = devm_request_irq(&pdev->
dev, pdev->
irq,
255 cb710_irq_handler,
IRQF_SHARED, KBUILD_MODNAME, chip);
265 spin_unlock_irqrestore(&cb710_ida_lock, flags);
267 if (err && err != -
EAGAIN)
275 if (val & CB710_SLOT_MMC) {
276 err = cb710_register_slot(chip,
277 CB710_SLOT_MMC, 0x00,
"cb710-mmc");
282 if (val & CB710_SLOT_MS) {
283 err = cb710_register_slot(chip,
284 CB710_SLOT_MS, 0x40,
"cb710-ms");
289 if (val & CB710_SLOT_SM) {
290 err = cb710_register_slot(chip,
291 CB710_SLOT_SM, 0x60,
"cb710-sm");
298 cb710_unregister_slot(chip, CB710_SLOT_MS);
300 cb710_unregister_slot(chip, CB710_SLOT_MMC);
302 #ifdef CONFIG_CB710_DEBUG_ASSUMPTIONS
310 struct cb710_chip *chip = pci_get_drvdata(pdev);
313 cb710_unregister_slot(chip, CB710_SLOT_SM);
314 cb710_unregister_slot(chip, CB710_SLOT_MS);
315 cb710_unregister_slot(chip, CB710_SLOT_MMC);
316 #ifdef CONFIG_CB710_DEBUG_ASSUMPTIONS
322 spin_unlock_irqrestore(&cb710_ida_lock, flags);
332 .name = KBUILD_MODNAME,
333 .id_table = cb710_pci_tbl,
334 .probe = cb710_probe,
337 .suspend = cb710_suspend,
338 .resume = cb710_resume,
342 static int __init cb710_init_module(
void)
344 return pci_register_driver(&cb710_driver);
347 static void __exit cb710_cleanup_module(
void)