pcmcia.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. gayle_reset = 0x00;
  26. while (time_before(jiffies, reset_start_time + 1*HZ/100));
  27. READ_ONCE(gayle_reset);
  28. }
  29. EXPORT_SYMBOL(pcmcia_reset);
  30. /* copy a tuple, including tuple header. return nb bytes copied */
  31. /* be careful as this may trigger a GAYLE_IRQ_WR interrupt ! */
  32. int pcmcia_copy_tuple(unsigned char tuple_id, void *tuple, int max_len)
  33. {
  34. unsigned char id, *dest;
  35. int cnt, pos, len;
  36. dest = tuple;
  37. pos = 0;
  38. id = gayle_attribute[pos];
  39. while((id != CISTPL_END) && (pos < 0x10000)) {
  40. len = (int)gayle_attribute[pos+2] + 2;
  41. if (id == tuple_id) {
  42. len = (len > max_len)?max_len:len;
  43. for (cnt = 0; cnt < len; cnt++) {
  44. *dest++ = gayle_attribute[pos+(cnt<<1)];
  45. }
  46. return len;
  47. }
  48. pos += len<<1;
  49. id = gayle_attribute[pos];
  50. }
  51. return 0;
  52. }
  53. EXPORT_SYMBOL(pcmcia_copy_tuple);
  54. void pcmcia_program_voltage(int voltage)
  55. {
  56. unsigned char v;
  57. switch (voltage) {
  58. case PCMCIA_0V:
  59. v = GAYLE_CFG_0V;
  60. break;
  61. case PCMCIA_5V:
  62. v = GAYLE_CFG_5V;
  63. break;
  64. case PCMCIA_12V:
  65. v = GAYLE_CFG_12V;
  66. break;
  67. default:
  68. v = GAYLE_CFG_0V;
  69. }
  70. cfg_byte = (cfg_byte & 0xfc) | v;
  71. gayle.config = cfg_byte;
  72. }
  73. EXPORT_SYMBOL(pcmcia_program_voltage);
  74. void pcmcia_access_speed(int speed)
  75. {
  76. unsigned char s;
  77. if (speed <= PCMCIA_SPEED_100NS)
  78. s = GAYLE_CFG_100NS;
  79. else if (speed <= PCMCIA_SPEED_150NS)
  80. s = GAYLE_CFG_150NS;
  81. else if (speed <= PCMCIA_SPEED_250NS)
  82. s = GAYLE_CFG_250NS;
  83. else
  84. s = GAYLE_CFG_720NS;
  85. cfg_byte = (cfg_byte & 0xf3) | s;
  86. gayle.config = cfg_byte;
  87. }
  88. EXPORT_SYMBOL(pcmcia_access_speed);
  89. void pcmcia_write_enable(void)
  90. {
  91. gayle.cardstatus = GAYLE_CS_WR|GAYLE_CS_DA;
  92. }
  93. EXPORT_SYMBOL(pcmcia_write_enable);
  94. void pcmcia_write_disable(void)
  95. {
  96. gayle.cardstatus = 0;
  97. }
  98. EXPORT_SYMBOL(pcmcia_write_disable);