via82c505.c 1.9 KB

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