marubun_pcmcia.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  27. #define CONFIG_PCMCIA
  28. #endif
  29. #if (CONFIG_COMMANDS & CFG_CMD_IDE)
  30. #define CONFIG_PCMCIA
  31. #endif
  32. #if defined(CONFIG_PCMCIA) \
  33. && (defined(CONFIG_MARUBUN_PCCARD))
  34. /* MR-SHPC-01 register */
  35. #define MRSHPC_MODE (CFG_MARUBUN_MRSHPC + 4)
  36. #define MRSHPC_OPTION (CFG_MARUBUN_MRSHPC + 6)
  37. #define MRSHPC_CSR (CFG_MARUBUN_MRSHPC + 8)
  38. #define MRSHPC_ISR (CFG_MARUBUN_MRSHPC + 10)
  39. #define MRSHPC_ICR (CFG_MARUBUN_MRSHPC + 12)
  40. #define MRSHPC_CPWCR (CFG_MARUBUN_MRSHPC + 14)
  41. #define MRSHPC_MW0CR1 (CFG_MARUBUN_MRSHPC + 16)
  42. #define MRSHPC_MW1CR1 (CFG_MARUBUN_MRSHPC + 18)
  43. #define MRSHPC_IOWCR1 (CFG_MARUBUN_MRSHPC + 20)
  44. #define MRSHPC_MW0CR2 (CFG_MARUBUN_MRSHPC + 22)
  45. #define MRSHPC_MW1CR2 (CFG_MARUBUN_MRSHPC + 24)
  46. #define MRSHPC_IOWCR2 (CFG_MARUBUN_MRSHPC + 26)
  47. #define MRSHPC_CDCR (CFG_MARUBUN_MRSHPC + 28)
  48. #define MRSHPC_PCIC_INFO (CFG_MARUBUN_MRSHPC + 30)
  49. int pcmcia_on (void)
  50. {
  51. printf("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
  52. /* Init */
  53. outw( 0x0000 , MRSHPC_MODE );
  54. if ((inw(MRSHPC_CSR) & 0x000c) == 0){ /* if card detect is true */
  55. if ((inw(MRSHPC_CSR) & 0x0080) == 0){
  56. outw(0x0674 ,MRSHPC_CPWCR); /* Card Vcc is 3.3v? */
  57. }else{
  58. outw(0x0678 ,MRSHPC_CPWCR); /* Card Vcc is 5V */
  59. }
  60. udelay( 100000 ); /* wait for power on */
  61. }else{
  62. return 1;
  63. }
  64. /*
  65. * PC-Card window open
  66. * flag == COMMON/ATTRIBUTE/IO
  67. */
  68. /* common window open */
  69. outw(0x8a84,MRSHPC_MW0CR1); /* window 0xb8400000 */
  70. if ((inw(MRSHPC_CSR) & 0x4000) != 0)
  71. outw(0x0b00,MRSHPC_MW0CR2); /* common mode & bus width 16bit SWAP = 1 */
  72. else
  73. outw(0x0300,MRSHPC_MW0CR2); /* common mode & bus width 16bit SWAP = 0 */
  74. /* attribute window open */
  75. outw(0x8a85,MRSHPC_MW1CR1); /* window 0xb8500000 */
  76. if ((inw(MRSHPC_CSR) & 0x4000) != 0)
  77. outw(0x0a00,MRSHPC_MW1CR2); /* attribute mode & bus width 16bit SWAP = 1 */
  78. else
  79. outw(0x0200,MRSHPC_MW1CR2); /* attribute mode & bus width 16bit SWAP = 0 */
  80. /* I/O window open */
  81. outw(0x8a86,MRSHPC_IOWCR1); /* I/O window 0xb8600000 */
  82. outw(0x0008,MRSHPC_CDCR); /* I/O card mode */
  83. if ((inw(MRSHPC_CSR) & 0x4000) != 0)
  84. outw(0x0a00,MRSHPC_IOWCR2); /* bus width 16bit SWAP = 1 */
  85. else
  86. outw(0x0200,MRSHPC_IOWCR2); /* bus width 16bit SWAP = 0 */
  87. outw(0x0000,MRSHPC_ISR);
  88. outw(0x2000,MRSHPC_ICR);
  89. outb(0x00,(CFG_MARUBUN_MW2 + 0x206));
  90. outb(0x42,(CFG_MARUBUN_MW2 + 0x200));
  91. return 0;
  92. }
  93. int pcmcia_off (void)
  94. {
  95. printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
  96. return 0;
  97. }
  98. #endif /* CONFIG_MARUBUN_PCCARD */