marubun_pcmcia.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Marubun MR-SHPC-01 PCMCIA controller device driver
  3. *
  4. * (c) 2007 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  19. * MA 02111-1307 USA
  20. *
  21. */
  22. #include <common.h>
  23. #include <config.h>
  24. #include <pcmcia.h>
  25. #include <asm/io.h>
  26. #undef CONFIG_PCMCIA
  27. #if defined(CONFIG_CMD_PCMCIA)
  28. #define CONFIG_PCMCIA
  29. #endif
  30. #if defined(CONFIG_CMD_IDE)
  31. #define CONFIG_PCMCIA
  32. #endif
  33. #if defined(CONFIG_PCMCIA) \
  34. && (defined(CONFIG_MARUBUN_PCCARD))
  35. /* MR-SHPC-01 register */
  36. #define MRSHPC_MODE (CFG_MARUBUN_MRSHPC + 4)
  37. #define MRSHPC_OPTION (CFG_MARUBUN_MRSHPC + 6)
  38. #define MRSHPC_CSR (CFG_MARUBUN_MRSHPC + 8)
  39. #define MRSHPC_ISR (CFG_MARUBUN_MRSHPC + 10)
  40. #define MRSHPC_ICR (CFG_MARUBUN_MRSHPC + 12)
  41. #define MRSHPC_CPWCR (CFG_MARUBUN_MRSHPC + 14)
  42. #define MRSHPC_MW0CR1 (CFG_MARUBUN_MRSHPC + 16)
  43. #define MRSHPC_MW1CR1 (CFG_MARUBUN_MRSHPC + 18)
  44. #define MRSHPC_IOWCR1 (CFG_MARUBUN_MRSHPC + 20)
  45. #define MRSHPC_MW0CR2 (CFG_MARUBUN_MRSHPC + 22)
  46. #define MRSHPC_MW1CR2 (CFG_MARUBUN_MRSHPC + 24)
  47. #define MRSHPC_IOWCR2 (CFG_MARUBUN_MRSHPC + 26)
  48. #define MRSHPC_CDCR (CFG_MARUBUN_MRSHPC + 28)
  49. #define MRSHPC_PCIC_INFO (CFG_MARUBUN_MRSHPC + 30)
  50. int pcmcia_on (void)
  51. {
  52. printf("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
  53. /* Init */
  54. outw( 0x0000 , MRSHPC_MODE );
  55. if ((inw(MRSHPC_CSR) & 0x000c) == 0){ /* if card detect is true */
  56. if ((inw(MRSHPC_CSR) & 0x0080) == 0){
  57. outw(0x0674 ,MRSHPC_CPWCR); /* Card Vcc is 3.3v? */
  58. }else{
  59. outw(0x0678 ,MRSHPC_CPWCR); /* Card Vcc is 5V */
  60. }
  61. udelay( 100000 ); /* wait for power on */
  62. }else{
  63. return 1;
  64. }
  65. /*
  66. * PC-Card window open
  67. * flag == COMMON/ATTRIBUTE/IO
  68. */
  69. /* common window open */
  70. outw(0x8a84,MRSHPC_MW0CR1); /* window 0xb8400000 */
  71. if ((inw(MRSHPC_CSR) & 0x4000) != 0)
  72. outw(0x0b00,MRSHPC_MW0CR2); /* common mode & bus width 16bit SWAP = 1 */
  73. else
  74. outw(0x0300,MRSHPC_MW0CR2); /* common mode & bus width 16bit SWAP = 0 */
  75. /* attribute window open */
  76. outw(0x8a85,MRSHPC_MW1CR1); /* window 0xb8500000 */
  77. if ((inw(MRSHPC_CSR) & 0x4000) != 0)
  78. outw(0x0a00,MRSHPC_MW1CR2); /* attribute mode & bus width 16bit SWAP = 1 */
  79. else
  80. outw(0x0200,MRSHPC_MW1CR2); /* attribute mode & bus width 16bit SWAP = 0 */
  81. /* I/O window open */
  82. outw(0x8a86,MRSHPC_IOWCR1); /* I/O window 0xb8600000 */
  83. outw(0x0008,MRSHPC_CDCR); /* I/O card mode */
  84. if ((inw(MRSHPC_CSR) & 0x4000) != 0)
  85. outw(0x0a00,MRSHPC_IOWCR2); /* bus width 16bit SWAP = 1 */
  86. else
  87. outw(0x0200,MRSHPC_IOWCR2); /* bus width 16bit SWAP = 0 */
  88. outw(0x0000,MRSHPC_ISR);
  89. outw(0x2000,MRSHPC_ICR);
  90. outb(0x00,(CFG_MARUBUN_MW2 + 0x206));
  91. outb(0x42,(CFG_MARUBUN_MW2 + 0x200));
  92. return 0;
  93. }
  94. int pcmcia_off (void)
  95. {
  96. printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
  97. return 0;
  98. }
  99. #endif /* CONFIG_MARUBUN_PCCARD */