ms_port.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #ifndef _H_MS_PORT_COMMON
  2. #define _H_MS_PORT_COMMON
  3. #include <asm/types.h>
  4. #include <asm/io.h>
  5. #include <mach/am_regs.h>
  6. #include <mach/card_io.h>
  7. //Following I/O configurations are just for default case if no any known PCB defined
  8. #define MS_IO_EXTERNAL
  9. //Port operation for MS BUS
  10. //write it as such form that could be replaced by function later if needed
  11. extern int i_GPIO_timer;
  12. extern void (*ms_mspro_power_register) (int power_on);
  13. extern int (*ms_mspro_ins_register) (void);
  14. extern int (*ms_mspro_wp_register) (void);
  15. extern void (*ms_mspro_io_release_register) (void);
  16. extern void sd_sdio_enable(SDIO_Pad_Type_t io_pad_type);
  17. extern void sd_gpio_enable(SDIO_Pad_Type_t io_pad_type);
  18. #ifdef MS_IO_EXTERNAL
  19. extern unsigned MS_BS_OUTPUT_EN_REG;
  20. extern unsigned MS_BS_OUTPUT_EN_MASK;
  21. extern unsigned MS_BS_OUTPUT_REG;
  22. extern unsigned MS_BS_OUTPUT_MASK;
  23. extern unsigned MS_CLK_OUTPUT_EN_REG;
  24. extern unsigned MS_CLK_OUTPUT_EN_MASK;
  25. extern unsigned MS_CLK_OUTPUT_REG;
  26. extern unsigned MS_CLK_OUTPUT_MASK;
  27. extern unsigned MS_DAT_OUTPUT_EN_REG;
  28. extern unsigned MS_DAT0_OUTPUT_EN_MASK;
  29. extern unsigned MS_DAT0_3_OUTPUT_EN_MASK;
  30. extern unsigned MS_DAT_INPUT_REG;
  31. extern unsigned MS_DAT_OUTPUT_REG;
  32. extern unsigned MS_DAT0_INPUT_MASK;
  33. extern unsigned MS_DAT0_OUTPUT_MASK;
  34. extern unsigned MS_DAT0_3_INPUT_MASK;
  35. extern unsigned MS_DAT0_3_OUTPUT_MASK;
  36. extern unsigned MS_DAT_INPUT_OFFSET;
  37. extern unsigned MS_DAT_OUTPUT_OFFSET;
  38. extern unsigned MS_INS_OUTPUT_EN_REG;
  39. extern unsigned MS_INS_OUTPUT_EN_MASK;
  40. extern unsigned MS_INS_INPUT_REG;
  41. extern unsigned MS_INS_INPUT_MASK;
  42. extern unsigned MS_PWR_OUTPUT_EN_REG;
  43. extern unsigned MS_PWR_OUTPUT_EN_MASK;
  44. extern unsigned MS_PWR_OUTPUT_REG;
  45. extern unsigned MS_PWR_OUTPUT_MASK;
  46. extern unsigned MS_PWR_EN_LEVEL;
  47. extern unsigned MS_WORK_MODE;
  48. //extern void (*ms_mspro_power_register)(int power_on);
  49. //extern int (*ms_mspro_ins_register)(void);
  50. //extern void (*ms_mspro_io_release_register)(void);
  51. #define MS_MSPRO_POWER_CONTROL
  52. // void ms_sdio_enable(void);
  53. // void ms_gpio_enable(void);
  54. #define ms_sdio_enable sd_sdio_enable
  55. #define ms_gpio_enable sd_gpio_enable
  56. #else //MS_IO_EXTERNAL
  57. #define MS_BS_OUTPUT_EN_REG CARD_GPIO_ENABLE
  58. #define MS_BS_OUTPUT_EN_MASK PREG_IO_19_MASK
  59. #define MS_BS_OUTPUT_REG CARD_GPIO_OUTPUT
  60. #define MS_BS_OUTPUT_MASK PREG_IO_19_MASK
  61. #define MS_CLK_OUTPUT_EN_REG CARD_GPIO_ENABLE
  62. #define MS_CLK_OUTPUT_EN_MASK PREG_IO_18_MASK
  63. #define MS_CLK_OUTPUT_REG CARD_GPIO_OUTPUT
  64. #define MS_CLK_OUTPUT_MASK PREG_IO_18_MASK
  65. #define MS_DAT_OUTPUT_EN_REG CARD_GPIO_ENABLE
  66. #define MS_DAT0_OUTPUT_EN_MASK PREG_IO_13_MASK
  67. #define MS_DAT0_3_OUTPUT_EN_MASK PREG_IO_13_16_MASK
  68. #define MS_DAT_INPUT_REG CARD_GPIO_INPUT
  69. #define MS_DAT_OUTPUT_REG CARD_GPIO_OUTPUT
  70. #define MS_DAT0_INPUT_MASK PREG_IO_13_MASK
  71. #define MS_DAT0_OUTPUT_MASK PREG_IO_13_MASK
  72. #define MS_DAT0_3_INPUT_MASK PREG_IO_13_16_MASK
  73. #define MS_DAT0_3_OUTPUT_MASK PREG_IO_13_16_MASK
  74. #define MS_DAT_INPUT_OFFSET 13
  75. #define MS_DAT_OUTPUT_OFFSET 13
  76. #define MS_INS_OUTPUT_EN_REG CARD_GPIO_ENABLE
  77. #define MS_INS_OUTPUT_EN_MASK PREG_IO_20_MASK
  78. #define MS_INS_INPUT_REG CARD_GPIO_INPUT
  79. #define MS_INS_INPUT_MASK PREG_IO_20_MASK
  80. #define MS_PWR_OUTPUT_EN_REG CARD_GPIO_ENABLE
  81. #define MS_PWR_OUTPUT_EN_MASK PREG_IO_23_MASK
  82. #define MS_PWR_OUTPUT_REG CARD_GPIO_OUTPUT
  83. #define MS_PWR_OUTPUT_MASK PREG_IO_23_MASK
  84. #define MS_PWR_EN_LEVEL 0
  85. #define MS_WORK_MODE CARD_HW_MODE
  86. #define MS_MSPRO_POWER_CONTROL
  87. #define ms_sdio_enable() {SET_CBUS_REG_MASK(CARD_PIN_MUX_0, (0x3F<<23));SET_CBUS_REG_MASK(SDIO_MULT_CONFIG, (0));}
  88. #define ms_gpio_enable() {CLEAR_CBUS_REG_MASK(CARD_PIN_MUX_0, (0x3F<<23));CLEAR_CBUS_REG_MASK(SDIO_MULT_CONFIG, (0));}
  89. #endif //MS_IO_EXTERNAL
  90. #define ms_set_bs_output() {(*(volatile unsigned *)MS_BS_OUTPUT_EN_REG) &= ~MS_BS_OUTPUT_EN_MASK;}
  91. #define ms_set_bs_high() {(*(volatile unsigned *)MS_BS_OUTPUT_REG) |= MS_BS_OUTPUT_MASK;}
  92. #define ms_set_bs_low() {(*(volatile unsigned *)MS_BS_OUTPUT_REG) &= ~MS_BS_OUTPUT_MASK;}
  93. #define ms_set_bs_state(number) {if(number&0x01){ms_set_bs_high()}else{ms_set_bs_low()}}
  94. #define ms_set_clk_output() {(*(volatile unsigned *)MS_CLK_OUTPUT_EN_REG) &= ~MS_CLK_OUTPUT_EN_MASK;}
  95. #define ms_set_clk_high() {(*(volatile unsigned *)MS_CLK_OUTPUT_REG) |= MS_CLK_OUTPUT_MASK;}
  96. #define ms_set_clk_low() {(*(volatile unsigned *)MS_CLK_OUTPUT_REG) &= ~MS_CLK_OUTPUT_MASK;}
  97. #define ms_set_dat0_input() {(*(volatile unsigned *)MS_DAT_OUTPUT_EN_REG) |= MS_DAT0_OUTPUT_EN_MASK; for(i_GPIO_timer=0;i_GPIO_timer<15;i_GPIO_timer++);}
  98. #define ms_set_dat0_output() {(*(volatile unsigned *)MS_DAT_OUTPUT_EN_REG) &= ~MS_DAT0_OUTPUT_EN_MASK;}
  99. #define ms_set_dat0_value(data) {if(data){*(volatile unsigned *)MS_DAT_OUTPUT_REG |= MS_DAT0_OUTPUT_MASK;}else{*(volatile unsigned *)MS_DAT_OUTPUT_REG &= ~MS_DAT0_OUTPUT_MASK;}}
  100. #define ms_get_dat0_value() (((*(volatile unsigned *)MS_DAT_INPUT_REG) & MS_DAT0_INPUT_MASK)?1:0)
  101. #define ms_set_dat0_3_input() {(*(volatile unsigned *)MS_DAT_OUTPUT_EN_REG) |= MS_DAT0_3_OUTPUT_EN_MASK; for(i_GPIO_timer=0;i_GPIO_timer<15;i_GPIO_timer++);}
  102. #define ms_set_dat0_3_output() {(*(volatile unsigned *)MS_DAT_OUTPUT_EN_REG) &= ~MS_DAT0_3_OUTPUT_EN_MASK;}
  103. #define ms_set_dat0_3_value(data) {(*(volatile unsigned *)MS_DAT_OUTPUT_REG) = (((*(volatile unsigned *)MS_DAT_OUTPUT_REG) & (~MS_DAT0_3_OUTPUT_MASK)) | (data << MS_DAT_OUTPUT_OFFSET));}
  104. #define ms_get_dat0_3_value() (((*(volatile unsigned *)MS_DAT_INPUT_REG) & MS_DAT0_3_INPUT_MASK) >> MS_DAT_INPUT_OFFSET)
  105. #define ms_set_ins_input() {(*(volatile unsigned *)MS_INS_OUTPUT_EN_REG) |= MS_INS_OUTPUT_EN_MASK; for(i_GPIO_timer=0;i_GPIO_timer<15;i_GPIO_timer++); }
  106. #define ms_get_ins_value() ((*(volatile unsigned *)MS_INS_INPUT_REG & MS_INS_INPUT_MASK)?1:0)
  107. #define MS_MSPRO_POWER_CONTROL
  108. #ifdef MS_MSPRO_POWER_CONTROL
  109. #define ms_set_enable() {(*(volatile unsigned *)MS_PWR_OUTPUT_EN_REG) &= ~MS_PWR_OUTPUT_EN_MASK; if(MS_PWR_EN_LEVEL){*(volatile unsigned *)MS_PWR_OUTPUT_REG |= MS_PWR_OUTPUT_MASK;} else {*(volatile unsigned *)MS_PWR_OUTPUT_REG &= ~MS_PWR_OUTPUT_MASK;}}
  110. #define ms_set_disable() {(*(volatile unsigned *)MS_PWR_OUTPUT_EN_REG) &= ~MS_PWR_OUTPUT_EN_MASK; if(MS_PWR_EN_LEVEL){*(volatile unsigned *)MS_PWR_OUTPUT_REG &= ~MS_PWR_OUTPUT_MASK;} else {*(volatile unsigned *)MS_PWR_OUTPUT_REG |= MS_PWR_OUTPUT_MASK;}}
  111. #endif /* */
  112. #endif //_H_MS_PORT_COMMON