marubun_pcmcia.c 2.8 KB

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