via82c505.c 1.9 KB

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