pc873xx.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #include <linux/ioport.h>
  2. #include <asm/io.h>
  3. #include "pc873xx.h"
  4. static unsigned pc873xx_probelist[] = {0x398, 0x26e, 0};
  5. static char *pc873xx_names[] = {
  6. "PC87303", "PC87306", "PC87312", "PC87332", "PC87334"
  7. };
  8. static unsigned int base, model;
  9. unsigned int __init pc873xx_get_base()
  10. {
  11. return base;
  12. }
  13. char *__init pc873xx_get_model()
  14. {
  15. return pc873xx_names[model];
  16. }
  17. static unsigned char __init pc873xx_read(unsigned int base, int reg)
  18. {
  19. outb(reg, base);
  20. return inb(base + 1);
  21. }
  22. static void __init pc873xx_write(unsigned int base, int reg, unsigned char data)
  23. {
  24. unsigned long flags;
  25. local_irq_save(flags);
  26. outb(reg, base);
  27. outb(data, base + 1);
  28. outb(data, base + 1); /* Must be written twice */
  29. local_irq_restore(flags);
  30. }
  31. int __init pc873xx_probe(void)
  32. {
  33. int val, index = 0;
  34. while ((base = pc873xx_probelist[index++])) {
  35. if (request_region(base, 2, "Super IO PC873xx") == NULL)
  36. continue;
  37. val = pc873xx_read(base, REG_SID);
  38. if ((val & 0xf0) == 0x10) {
  39. model = PC87332;
  40. break;
  41. } else if ((val & 0xf8) == 0x70) {
  42. model = PC87306;
  43. break;
  44. } else if ((val & 0xf8) == 0x50) {
  45. model = PC87334;
  46. break;
  47. } else if ((val & 0xf8) == 0x40) {
  48. model = PC87303;
  49. break;
  50. }
  51. release_region(base, 2);
  52. }
  53. return (base == 0) ? -1 : 1;
  54. }
  55. void __init pc873xx_enable_epp19(void)
  56. {
  57. unsigned char data;
  58. printk(KERN_INFO "PC873xx enabling EPP v1.9\n");
  59. data = pc873xx_read(base, REG_PCR);
  60. pc873xx_write(base, REG_PCR, (data & 0xFC) | 0x02);
  61. }
  62. void __init pc873xx_enable_ide(void)
  63. {
  64. unsigned char data;
  65. printk(KERN_INFO "PC873xx enabling IDE interrupt\n");
  66. data = pc873xx_read(base, REG_FER);
  67. pc873xx_write(base, REG_FER, data | 0x40);
  68. }