pcmcia.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. ** asm-m68k/pcmcia.c -- Amiga Linux PCMCIA support
  3. ** most information was found by disassembling card.resource
  4. ** I'm still looking for an official doc !
  5. **
  6. ** Copyright 1997 by Alain Malek
  7. **
  8. ** This file is subject to the terms and conditions of the GNU General Public
  9. ** License. See the file COPYING in the main directory of this archive
  10. ** for more details.
  11. **
  12. ** Created: 12/10/97 by Alain Malek
  13. */
  14. #include <linux/types.h>
  15. #include <linux/jiffies.h>
  16. #include <linux/timer.h>
  17. #include <linux/module.h>
  18. #include <asm/amigayle.h>
  19. #include <asm/amipcmcia.h>
  20. /* gayle config byte for program voltage and access speed */
  21. static unsigned char cfg_byte = GAYLE_CFG_0V|GAYLE_CFG_150NS;
  22. void pcmcia_reset(void)
  23. {
  24. unsigned long reset_start_time = jiffies;
  25. unsigned char b;
  26. gayle_reset = 0x00;
  27. while (time_before(jiffies, reset_start_time + 1*HZ/100));
  28. b = gayle_reset;
  29. }
  30. EXPORT_SYMBOL(pcmcia_reset);
  31. /* copy a tuple, including tuple header. return nb bytes copied */
  32. /* be careful as this may trigger a GAYLE_IRQ_WR interrupt ! */
  33. int pcmcia_copy_tuple(unsigned char tuple_id, void *tuple, int max_len)
  34. {
  35. unsigned char id, *dest;
  36. int cnt, pos, len;
  37. dest = tuple;
  38. pos = 0;
  39. id = gayle_attribute[pos];
  40. while((id != CISTPL_END) && (pos < 0x10000)) {
  41. len = (int)gayle_attribute[pos+2] + 2;
  42. if (id == tuple_id) {
  43. len = (len > max_len)?max_len:len;
  44. for (cnt = 0; cnt < len; cnt++) {
  45. *dest++ = gayle_attribute[pos+(cnt<<1)];
  46. }
  47. return len;
  48. }
  49. pos += len<<1;
  50. id = gayle_attribute[pos];
  51. }
  52. return 0;
  53. }
  54. EXPORT_SYMBOL(pcmcia_copy_tuple);
  55. void pcmcia_program_voltage(int voltage)
  56. {
  57. unsigned char v;
  58. switch (voltage) {
  59. case PCMCIA_0V:
  60. v = GAYLE_CFG_0V;
  61. break;
  62. case PCMCIA_5V:
  63. v = GAYLE_CFG_5V;
  64. break;
  65. case PCMCIA_12V:
  66. v = GAYLE_CFG_12V;
  67. break;
  68. default:
  69. v = GAYLE_CFG_0V;
  70. }
  71. cfg_byte = (cfg_byte & 0xfc) | v;
  72. gayle.config = cfg_byte;
  73. }
  74. EXPORT_SYMBOL(pcmcia_program_voltage);
  75. void pcmcia_access_speed(int speed)
  76. {
  77. unsigned char s;
  78. if (speed <= PCMCIA_SPEED_100NS)
  79. s = GAYLE_CFG_100NS;
  80. else if (speed <= PCMCIA_SPEED_150NS)
  81. s = GAYLE_CFG_150NS;
  82. else if (speed <= PCMCIA_SPEED_250NS)
  83. s = GAYLE_CFG_250NS;
  84. else
  85. s = GAYLE_CFG_720NS;
  86. cfg_byte = (cfg_byte & 0xf3) | s;
  87. gayle.config = cfg_byte;
  88. }
  89. EXPORT_SYMBOL(pcmcia_access_speed);
  90. void pcmcia_write_enable(void)
  91. {
  92. gayle.cardstatus = GAYLE_CS_WR|GAYLE_CS_DA;
  93. }
  94. EXPORT_SYMBOL(pcmcia_write_enable);
  95. void pcmcia_write_disable(void)
  96. {
  97. gayle.cardstatus = 0;
  98. }
  99. EXPORT_SYMBOL(pcmcia_write_disable);