via82c505.c 1.9 KB

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