via82c505.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #include <linux/kernel.h>
  2. #include <linux/pci.h>
  3. #include <linux/interrupt.h>
  4. #include <linux/mm.h>
  5. #include <linux/init.h>
  6. #include <linux/ioport.h>
  7. #include <linux/io.h>
  8. #include <asm/system.h>
  9. #include <asm/mach/pci.h>
  10. #define MAX_SLOTS 7
  11. #define CONFIG_CMD(bus, devfn, where) (0x80000000 | (bus->number << 16) | (devfn << 8) | (where & ~3))
  12. static int
  13. via82c505_read_config(struct pci_bus *bus, unsigned int devfn, int where,
  14. int size, u32 *value)
  15. {
  16. outl(CONFIG_CMD(bus,devfn,where),0xCF8);
  17. switch (size) {
  18. case 1:
  19. *value=inb(0xCFC + (where&3));
  20. break;
  21. case 2:
  22. *value=inw(0xCFC + (where&2));
  23. break;
  24. case 4:
  25. *value=inl(0xCFC);
  26. break;
  27. }
  28. return PCIBIOS_SUCCESSFUL;
  29. }
  30. static int
  31. via82c505_write_config(struct pci_bus *bus, unsigned int devfn, int where,
  32. int size, u32 value)
  33. {
  34. outl(CONFIG_CMD(bus,devfn,where),0xCF8);
  35. switch (size) {
  36. case 1:
  37. outb(value, 0xCFC + (where&3));
  38. break;
  39. case 2:
  40. outw(value, 0xCFC + (where&2));
  41. break;
  42. case 4:
  43. outl(value, 0xCFC);
  44. break;
  45. }
  46. return PCIBIOS_SUCCESSFUL;
  47. }
  48. static struct pci_ops via82c505_ops = {
  49. .read = via82c505_read_config,
  50. .write = via82c505_write_config,
  51. };
  52. void __init via82c505_preinit(void)
  53. {
  54. printk(KERN_DEBUG "PCI: VIA 82c505\n");
  55. if (!request_region(0xA8,2,"via config")) {
  56. printk(KERN_WARNING"VIA 82c505: Unable to request region 0xA8\n");
  57. return;
  58. }
  59. if (!request_region(0xCF8,8,"pci config")) {
  60. printk(KERN_WARNING"VIA 82c505: Unable to request region 0xCF8\n");
  61. release_region(0xA8, 2);
  62. return;
  63. }
  64. /* Enable compatible Mode */
  65. outb(0x96,0xA8);
  66. outb(0x18,0xA9);
  67. outb(0x93,0xA8);
  68. outb(0xd0,0xA9);
  69. }
  70. int __init via82c505_setup(int nr, struct pci_sys_data *sys)
  71. {
  72. return (nr == 0);
  73. }
  74. struct pci_bus * __init via82c505_scan_bus(int nr, struct pci_sys_data *sysdata)
  75. {
  76. if (nr == 0)
  77. return pci_scan_bus(0, &via82c505_ops, sysdata);
  78. return NULL;
  79. }