marubun_pcmcia.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Marubun MR-SHPC-01 PCMCIA controller device driver
  3. *
  4. * (c) 2007 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <config.h>
  10. #include <pcmcia.h>
  11. #include <asm/io.h>
  12. #undef CONFIG_PCMCIA
  13. #if defined(CONFIG_CMD_PCMCIA)
  14. #define CONFIG_PCMCIA
  15. #endif
  16. #if defined(CONFIG_CMD_IDE)
  17. #define CONFIG_PCMCIA
  18. #endif
  19. #if defined(CONFIG_PCMCIA)
  20. /* MR-SHPC-01 register */
  21. #define MRSHPC_MODE (CONFIG_SYS_MARUBUN_MRSHPC + 4)
  22. #define MRSHPC_OPTION (CONFIG_SYS_MARUBUN_MRSHPC + 6)
  23. #define MRSHPC_CSR (CONFIG_SYS_MARUBUN_MRSHPC + 8)
  24. #define MRSHPC_ISR (CONFIG_SYS_MARUBUN_MRSHPC + 10)
  25. #define MRSHPC_ICR (CONFIG_SYS_MARUBUN_MRSHPC + 12)
  26. #define MRSHPC_CPWCR (CONFIG_SYS_MARUBUN_MRSHPC + 14)
  27. #define MRSHPC_MW0CR1 (CONFIG_SYS_MARUBUN_MRSHPC + 16)
  28. #define MRSHPC_MW1CR1 (CONFIG_SYS_MARUBUN_MRSHPC + 18)
  29. #define MRSHPC_IOWCR1 (CONFIG_SYS_MARUBUN_MRSHPC + 20)
  30. #define MRSHPC_MW0CR2 (CONFIG_SYS_MARUBUN_MRSHPC + 22)
  31. #define MRSHPC_MW1CR2 (CONFIG_SYS_MARUBUN_MRSHPC + 24)
  32. #define MRSHPC_IOWCR2 (CONFIG_SYS_MARUBUN_MRSHPC + 26)
  33. #define MRSHPC_CDCR (CONFIG_SYS_MARUBUN_MRSHPC + 28)
  34. #define MRSHPC_PCIC_INFO (CONFIG_SYS_MARUBUN_MRSHPC + 30)
  35. int pcmcia_on (void)
  36. {
  37. printf("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
  38. /* Init */
  39. outw( 0x0000 , MRSHPC_MODE );
  40. if ((inw(MRSHPC_CSR) & 0x000c) == 0){ /* if card detect is true */
  41. if ((inw(MRSHPC_CSR) & 0x0080) == 0){
  42. outw(0x0674 ,MRSHPC_CPWCR); /* Card Vcc is 3.3v? */
  43. }else{
  44. outw(0x0678 ,MRSHPC_CPWCR); /* Card Vcc is 5V */
  45. }
  46. udelay( 100000 ); /* wait for power on */
  47. }else{
  48. return 1;
  49. }
  50. /*
  51. * PC-Card window open
  52. * flag == COMMON/ATTRIBUTE/IO
  53. */
  54. /* common window open */
  55. outw(0x8a84,MRSHPC_MW0CR1); /* window 0xb8400000 */
  56. if ((inw(MRSHPC_CSR) & 0x4000) != 0)
  57. outw(0x0b00,MRSHPC_MW0CR2); /* common mode & bus width 16bit SWAP = 1 */
  58. else
  59. outw(0x0300,MRSHPC_MW0CR2); /* common mode & bus width 16bit SWAP = 0 */
  60. /* attribute window open */
  61. outw(0x8a85,MRSHPC_MW1CR1); /* window 0xb8500000 */
  62. if ((inw(MRSHPC_CSR) & 0x4000) != 0)
  63. outw(0x0a00,MRSHPC_MW1CR2); /* attribute mode & bus width 16bit SWAP = 1 */
  64. else
  65. outw(0x0200,MRSHPC_MW1CR2); /* attribute mode & bus width 16bit SWAP = 0 */
  66. /* I/O window open */
  67. outw(0x8a86,MRSHPC_IOWCR1); /* I/O window 0xb8600000 */
  68. outw(0x0008,MRSHPC_CDCR); /* I/O card mode */
  69. if ((inw(MRSHPC_CSR) & 0x4000) != 0)
  70. outw(0x0a00,MRSHPC_IOWCR2); /* bus width 16bit SWAP = 1 */
  71. else
  72. outw(0x0200,MRSHPC_IOWCR2); /* bus width 16bit SWAP = 0 */
  73. outw(0x0000,MRSHPC_ISR);
  74. outw(0x2000,MRSHPC_ICR);
  75. outb(0x00,(CONFIG_SYS_MARUBUN_MW2 + 0x206));
  76. outb(0x42,(CONFIG_SYS_MARUBUN_MW2 + 0x200));
  77. return 0;
  78. }
  79. int pcmcia_off (void)
  80. {
  81. printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
  82. return 0;
  83. }
  84. #endif /* CONFIG_PCMCIA */