sd_pad.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. #include <mach/card_io.h>
  2. #include <linux/cardreader/card_block.h>
  3. #include <linux/cardreader/cardreader.h>
  4. static unsigned sd_backup_input_val = 0;
  5. static unsigned sd_backup_output_val = 0;
  6. static unsigned SD_BAKUP_INPUT_REG = (unsigned)&sd_backup_input_val;
  7. static unsigned SD_BAKUP_OUTPUT_REG = (unsigned)&sd_backup_output_val;
  8. unsigned SD_CMD_OUTPUT_EN_REG;
  9. unsigned SD_CMD_OUTPUT_EN_MASK;
  10. unsigned SD_CMD_INPUT_REG;
  11. unsigned SD_CMD_INPUT_MASK;
  12. unsigned SD_CMD_OUTPUT_REG;
  13. unsigned SD_CMD_OUTPUT_MASK;
  14. unsigned SD_CLK_OUTPUT_EN_REG;
  15. unsigned SD_CLK_OUTPUT_EN_MASK;
  16. unsigned SD_CLK_OUTPUT_REG;
  17. unsigned SD_CLK_OUTPUT_MASK;
  18. unsigned SD_DAT_OUTPUT_EN_REG;
  19. unsigned SD_DAT0_OUTPUT_EN_MASK;
  20. unsigned SD_DAT0_3_OUTPUT_EN_MASK;
  21. unsigned SD_DAT_INPUT_REG;
  22. unsigned SD_DAT_OUTPUT_REG;
  23. unsigned SD_DAT0_INPUT_MASK;
  24. unsigned SD_DAT0_OUTPUT_MASK;
  25. unsigned SD_DAT0_3_INPUT_MASK;
  26. unsigned SD_DAT0_3_OUTPUT_MASK;
  27. unsigned SD_DAT_INPUT_OFFSET;
  28. unsigned SD_DAT_OUTPUT_OFFSET;
  29. unsigned SD_INS_OUTPUT_EN_REG;
  30. unsigned SD_INS_OUTPUT_EN_MASK;
  31. unsigned SD_INS_INPUT_REG;
  32. unsigned SD_INS_INPUT_MASK;
  33. unsigned SD_WP_OUTPUT_EN_REG;
  34. unsigned SD_WP_OUTPUT_EN_MASK;
  35. unsigned SD_WP_INPUT_REG;
  36. unsigned SD_WP_INPUT_MASK;
  37. unsigned SD_PWR_OUTPUT_EN_REG;
  38. unsigned SD_PWR_OUTPUT_EN_MASK;
  39. unsigned SD_PWR_OUTPUT_REG;
  40. unsigned SD_PWR_OUTPUT_MASK;
  41. unsigned SD_PWR_EN_LEVEL;
  42. unsigned SD_WORK_MODE;
  43. extern int using_sdxc_controller;
  44. void sd_io_init(struct memory_card *card)
  45. {
  46. struct aml_card_info *aml_card_info = card->card_plat_info;
  47. SD_WORK_MODE = aml_card_info->work_mode;
  48. if ((aml_card_info->io_pad_type == SDXC_CARD_0_5) ||
  49. (aml_card_info->io_pad_type == SDXC_BOOT_0_11) ||
  50. (aml_card_info->io_pad_type == SDXC_GPIOX_0_9))
  51. using_sdxc_controller = 1;
  52. switch (aml_card_info->io_pad_type) {
  53. case SDIO_A_GPIOX_0_3:
  54. SD_CMD_OUTPUT_EN_REG = EGPIO_GPIOX_ENABLE;
  55. SD_CMD_OUTPUT_EN_MASK = PREG_IO_9_MASK;
  56. SD_CMD_INPUT_REG = EGPIO_GPIOX_INPUT;
  57. SD_CMD_INPUT_MASK = PREG_IO_9_MASK;
  58. SD_CMD_OUTPUT_REG = EGPIO_GPIOX_OUTPUT;
  59. SD_CMD_OUTPUT_MASK = PREG_IO_9_MASK;
  60. SD_CLK_OUTPUT_EN_REG = EGPIO_GPIOX_ENABLE;
  61. SD_CLK_OUTPUT_EN_MASK = PREG_IO_8_MASK;
  62. SD_CLK_OUTPUT_REG = EGPIO_GPIOX_OUTPUT;
  63. SD_CLK_OUTPUT_MASK = PREG_IO_8_MASK;
  64. SD_DAT_OUTPUT_EN_REG = EGPIO_GPIOX_ENABLE;
  65. SD_DAT0_OUTPUT_EN_MASK = PREG_IO_0_MASK;
  66. SD_DAT0_3_OUTPUT_EN_MASK = PREG_IO_0_3_MASK;
  67. SD_DAT_INPUT_REG = EGPIO_GPIOX_INPUT;
  68. SD_DAT_OUTPUT_REG = EGPIO_GPIOX_OUTPUT;
  69. SD_DAT0_INPUT_MASK = PREG_IO_0_MASK;
  70. SD_DAT0_OUTPUT_MASK = PREG_IO_0_MASK;
  71. SD_DAT0_3_INPUT_MASK = PREG_IO_0_3_MASK;
  72. SD_DAT0_3_OUTPUT_MASK = PREG_IO_0_3_MASK;
  73. SD_DAT_INPUT_OFFSET = 0;
  74. SD_DAT_OUTPUT_OFFSET = 0;
  75. break;
  76. case SDIO_B_CARD_0_5:
  77. SD_CMD_OUTPUT_EN_REG = CARD_GPIO_ENABLE;
  78. SD_CMD_OUTPUT_EN_MASK = PREG_IO_28_MASK;
  79. SD_CMD_INPUT_REG = CARD_GPIO_INPUT;
  80. SD_CMD_INPUT_MASK = PREG_IO_28_MASK;
  81. SD_CMD_OUTPUT_REG = CARD_GPIO_OUTPUT;
  82. SD_CMD_OUTPUT_MASK = PREG_IO_28_MASK;
  83. SD_CLK_OUTPUT_EN_REG = CARD_GPIO_ENABLE;
  84. SD_CLK_OUTPUT_EN_MASK = PREG_IO_27_MASK;
  85. SD_CLK_OUTPUT_REG = CARD_GPIO_OUTPUT;
  86. SD_CLK_OUTPUT_MASK = PREG_IO_27_MASK;
  87. SD_DAT_OUTPUT_EN_REG = CARD_GPIO_ENABLE;
  88. SD_DAT0_OUTPUT_EN_MASK = PREG_IO_23_MASK;
  89. SD_DAT0_3_OUTPUT_EN_MASK = PREG_IO_23_26_MASK;
  90. SD_DAT_INPUT_REG = CARD_GPIO_INPUT;
  91. SD_DAT_OUTPUT_REG = CARD_GPIO_OUTPUT;
  92. SD_DAT0_INPUT_MASK = PREG_IO_23_MASK;
  93. SD_DAT0_OUTPUT_MASK = PREG_IO_23_MASK;
  94. SD_DAT0_3_INPUT_MASK = PREG_IO_23_26_MASK;
  95. SD_DAT0_3_OUTPUT_MASK = PREG_IO_23_26_MASK;
  96. SD_DAT_INPUT_OFFSET = 23;
  97. SD_DAT_OUTPUT_OFFSET = 23;
  98. break;
  99. case SDIO_C_BOOT_0_3:
  100. SD_CMD_OUTPUT_EN_REG = BOOT_GPIO_ENABLE;
  101. SD_CMD_OUTPUT_EN_MASK = PREG_IO_10_MASK;
  102. SD_CMD_INPUT_REG = BOOT_GPIO_INPUT;
  103. SD_CMD_INPUT_MASK = PREG_IO_10_MASK;
  104. SD_CMD_OUTPUT_REG = BOOT_GPIO_OUTPUT;
  105. SD_CMD_OUTPUT_MASK = PREG_IO_10_MASK;
  106. SD_CLK_OUTPUT_EN_REG = BOOT_GPIO_ENABLE;
  107. SD_CLK_OUTPUT_EN_MASK = PREG_IO_11_MASK;
  108. SD_CLK_OUTPUT_REG = BOOT_GPIO_OUTPUT;
  109. SD_CLK_OUTPUT_MASK = PREG_IO_11_MASK;
  110. SD_DAT_OUTPUT_EN_REG = BOOT_GPIO_ENABLE;
  111. SD_DAT0_OUTPUT_EN_MASK = PREG_IO_0_MASK;
  112. SD_DAT0_3_OUTPUT_EN_MASK = PREG_IO_0_3_MASK;
  113. SD_DAT_INPUT_REG = BOOT_GPIO_INPUT;
  114. SD_DAT_OUTPUT_REG = BOOT_GPIO_OUTPUT;
  115. SD_DAT0_INPUT_MASK = PREG_IO_0_MASK;
  116. SD_DAT0_OUTPUT_MASK = PREG_IO_0_MASK;
  117. SD_DAT0_3_INPUT_MASK = PREG_IO_0_3_MASK;
  118. SD_DAT0_3_OUTPUT_MASK = PREG_IO_0_3_MASK;
  119. SD_DAT_INPUT_OFFSET = 0;
  120. SD_DAT_OUTPUT_OFFSET = 0;
  121. break;
  122. #define SDHC_B_ENABLE CBUS_REG_ADDR(0x201b)
  123. #define SDHC_B_OUTPUT CBUS_REG_ADDR(0x201c)
  124. #define SDHC_B_INPUT CBUS_REG_ADDR(0x201d)
  125. case SDHC_CARD_0_5: //SDHC-B
  126. SD_CMD_OUTPUT_EN_REG = SDHC_B_ENABLE;
  127. SD_CMD_OUTPUT_EN_MASK = PREG_IO_28_MASK;
  128. SD_CMD_OUTPUT_REG = SDHC_B_OUTPUT;
  129. SD_CMD_OUTPUT_MASK = PREG_IO_28_MASK;
  130. SD_CMD_INPUT_REG = SDHC_B_INPUT;
  131. SD_CMD_INPUT_MASK = PREG_IO_28_MASK;
  132. SD_CLK_OUTPUT_EN_REG = SDHC_B_ENABLE;
  133. SD_CLK_OUTPUT_EN_MASK = PREG_IO_27_MASK;
  134. SD_CLK_OUTPUT_REG = SDHC_B_OUTPUT;
  135. SD_CLK_OUTPUT_MASK = PREG_IO_27_MASK;
  136. SD_DAT_OUTPUT_EN_REG = SDHC_B_ENABLE;
  137. SD_DAT0_OUTPUT_EN_MASK = PREG_IO_23_MASK;
  138. SD_DAT0_3_OUTPUT_EN_MASK = PREG_IO_23_26_MASK;
  139. SD_DAT_OUTPUT_REG = SDHC_B_OUTPUT;
  140. SD_DAT0_OUTPUT_MASK = PREG_IO_23_MASK;
  141. SD_DAT0_3_OUTPUT_MASK = PREG_IO_23_26_MASK;
  142. SD_DAT_OUTPUT_OFFSET = 23;
  143. SD_DAT_INPUT_REG = SDHC_B_INPUT;
  144. SD_DAT0_INPUT_MASK = PREG_IO_23_MASK;
  145. SD_DAT0_3_INPUT_MASK = PREG_IO_23_26_MASK;
  146. SD_DAT_INPUT_OFFSET = 23;
  147. break;
  148. #define SDHC_C_ENABLE CBUS_REG_ADDR(0x2015)
  149. #define SDHC_C_OUTPUT CBUS_REG_ADDR(0x2016)
  150. #define SDHC_C_INPUT CBUS_REG_ADDR(0x2017)
  151. case SDHC_BOOT_0_11: //SDHC-C
  152. SD_CMD_OUTPUT_EN_REG = SDHC_C_ENABLE;
  153. SD_CMD_OUTPUT_EN_MASK = PREG_IO_10_MASK;
  154. SD_CMD_OUTPUT_REG = SDHC_C_OUTPUT;
  155. SD_CMD_OUTPUT_MASK = PREG_IO_10_MASK;
  156. SD_CMD_INPUT_REG = SDHC_C_INPUT;
  157. SD_CMD_INPUT_MASK = PREG_IO_10_MASK;
  158. SD_CLK_OUTPUT_EN_REG = SDHC_C_ENABLE;
  159. SD_CLK_OUTPUT_EN_MASK = PREG_IO_11_MASK;
  160. SD_CLK_OUTPUT_REG = SDHC_C_OUTPUT;
  161. SD_CLK_OUTPUT_MASK = PREG_IO_11_MASK;
  162. SD_DAT_OUTPUT_EN_REG = SDHC_C_ENABLE;
  163. SD_DAT0_OUTPUT_EN_MASK = PREG_IO_0_MASK;
  164. SD_DAT0_3_OUTPUT_EN_MASK = PREG_IO_0_3_MASK;
  165. SD_DAT_OUTPUT_REG = SDHC_C_OUTPUT;
  166. SD_DAT0_OUTPUT_MASK = PREG_IO_0_MASK;
  167. SD_DAT0_3_OUTPUT_MASK = PREG_IO_0_3_MASK;
  168. SD_DAT_OUTPUT_OFFSET = 0;
  169. SD_DAT_INPUT_REG = SDHC_C_INPUT;
  170. SD_DAT0_INPUT_MASK = PREG_IO_0_MASK;
  171. SD_DAT0_3_INPUT_MASK = PREG_IO_0_3_MASK;
  172. SD_DAT_INPUT_OFFSET = 0;
  173. break;
  174. #define SDHC_A_ENABLE CBUS_REG_ADDR(0x2018)
  175. #define SDHC_A_OUTPUT CBUS_REG_ADDR(0x2019)
  176. #define SDHC_A_INPUT CBUS_REG_ADDR(0x201a)
  177. case SDHC_GPIOX_0_9: //SDHC-A
  178. SD_CMD_OUTPUT_EN_REG = SDHC_A_ENABLE;
  179. SD_CMD_OUTPUT_EN_MASK = PREG_IO_9_MASK;
  180. SD_CMD_OUTPUT_REG = SDHC_A_OUTPUT;
  181. SD_CMD_OUTPUT_MASK = PREG_IO_9_MASK;
  182. SD_CMD_INPUT_REG = SDHC_A_INPUT;
  183. SD_CMD_INPUT_MASK = PREG_IO_9_MASK;
  184. SD_CLK_OUTPUT_EN_REG = SDHC_A_ENABLE;
  185. SD_CLK_OUTPUT_EN_MASK = PREG_IO_8_MASK;
  186. SD_CLK_OUTPUT_REG = SDHC_A_OUTPUT;
  187. SD_CLK_OUTPUT_MASK = PREG_IO_8_MASK;
  188. SD_DAT_OUTPUT_EN_REG = SDHC_A_ENABLE;
  189. SD_DAT0_OUTPUT_EN_MASK = PREG_IO_0_MASK;
  190. SD_DAT0_3_OUTPUT_EN_MASK = PREG_IO_0_3_MASK;
  191. SD_DAT_OUTPUT_REG = SDHC_A_OUTPUT;
  192. SD_DAT0_OUTPUT_MASK = PREG_IO_0_MASK;
  193. SD_DAT0_3_OUTPUT_MASK = PREG_IO_0_3_MASK;
  194. SD_DAT_OUTPUT_OFFSET = 0;
  195. SD_DAT_INPUT_REG = SDHC_A_INPUT;
  196. SD_DAT0_INPUT_MASK = PREG_IO_0_MASK;
  197. SD_DAT0_3_INPUT_MASK = PREG_IO_0_3_MASK;
  198. SD_DAT_INPUT_OFFSET = 0;
  199. break;
  200. #define SDXC_B_ENABLE CBUS_REG_ADDR(0x201b)
  201. #define SDXC_B_OUTPUT CBUS_REG_ADDR(0x201c)
  202. #define SDXC_B_INPUT CBUS_REG_ADDR(0x201d)
  203. case SDXC_CARD_0_5: //SDXC-B
  204. SD_CMD_OUTPUT_EN_REG = SDXC_B_ENABLE;
  205. SD_CMD_OUTPUT_EN_MASK = PREG_IO_28_MASK;
  206. SD_CMD_OUTPUT_REG = SDXC_B_OUTPUT;
  207. SD_CMD_OUTPUT_MASK = PREG_IO_28_MASK;
  208. SD_CMD_INPUT_REG = SDXC_B_INPUT;
  209. SD_CMD_INPUT_MASK = PREG_IO_28_MASK;
  210. SD_CLK_OUTPUT_EN_REG = SDXC_B_ENABLE;
  211. SD_CLK_OUTPUT_EN_MASK = PREG_IO_27_MASK;
  212. SD_CLK_OUTPUT_REG = SDXC_B_OUTPUT;
  213. SD_CLK_OUTPUT_MASK = PREG_IO_27_MASK;
  214. SD_DAT_OUTPUT_EN_REG = SDXC_B_ENABLE;
  215. SD_DAT0_OUTPUT_EN_MASK = PREG_IO_23_MASK;
  216. SD_DAT0_3_OUTPUT_EN_MASK = PREG_IO_23_26_MASK;
  217. SD_DAT_OUTPUT_REG = SDXC_B_OUTPUT;
  218. SD_DAT0_OUTPUT_MASK = PREG_IO_23_MASK;
  219. SD_DAT0_3_OUTPUT_MASK = PREG_IO_23_26_MASK;
  220. SD_DAT_OUTPUT_OFFSET = 23;
  221. SD_DAT_INPUT_REG = SDXC_B_INPUT;
  222. SD_DAT0_INPUT_MASK = PREG_IO_23_MASK;
  223. SD_DAT0_3_INPUT_MASK = PREG_IO_23_26_MASK;
  224. SD_DAT_INPUT_OFFSET = 23;
  225. break;
  226. #define SDXC_C_ENABLE CBUS_REG_ADDR(0x2015)
  227. #define SDXC_C_OUTPUT CBUS_REG_ADDR(0x2016)
  228. #define SDXC_C_INPUT CBUS_REG_ADDR(0x2017)
  229. case SDXC_BOOT_0_11: //SDXC-C
  230. SD_CMD_OUTPUT_EN_REG = SDXC_C_ENABLE;
  231. SD_CMD_OUTPUT_EN_MASK = PREG_IO_10_MASK;
  232. SD_CMD_OUTPUT_REG = SDXC_C_OUTPUT;
  233. SD_CMD_OUTPUT_MASK = PREG_IO_10_MASK;
  234. SD_CMD_INPUT_REG = SDXC_C_INPUT;
  235. SD_CMD_INPUT_MASK = PREG_IO_10_MASK;
  236. SD_CLK_OUTPUT_EN_REG = SDXC_C_ENABLE;
  237. SD_CLK_OUTPUT_EN_MASK = PREG_IO_11_MASK;
  238. SD_CLK_OUTPUT_REG = SDXC_C_OUTPUT;
  239. SD_CLK_OUTPUT_MASK = PREG_IO_11_MASK;
  240. SD_DAT_OUTPUT_EN_REG = SDXC_C_ENABLE;
  241. SD_DAT0_OUTPUT_EN_MASK = PREG_IO_0_MASK;
  242. SD_DAT0_3_OUTPUT_EN_MASK = PREG_IO_0_3_MASK;
  243. SD_DAT_OUTPUT_REG = SDXC_C_OUTPUT;
  244. SD_DAT0_OUTPUT_MASK = PREG_IO_0_MASK;
  245. SD_DAT0_3_OUTPUT_MASK = PREG_IO_0_3_MASK;
  246. SD_DAT_OUTPUT_OFFSET = 0;
  247. SD_DAT_INPUT_REG = SDXC_C_INPUT;
  248. SD_DAT0_INPUT_MASK = PREG_IO_0_MASK;
  249. SD_DAT0_3_INPUT_MASK = PREG_IO_0_3_MASK;
  250. SD_DAT_INPUT_OFFSET = 0;
  251. break;
  252. #define SDXC_A_ENABLE CBUS_REG_ADDR(0x2018)
  253. #define SDXC_A_OUTPUT CBUS_REG_ADDR(0x2019)
  254. #define SDXC_A_INPUT CBUS_REG_ADDR(0x201a)
  255. case SDXC_GPIOX_0_9: //SDXC-A
  256. SD_CMD_OUTPUT_EN_REG = SDXC_A_ENABLE;
  257. SD_CMD_OUTPUT_EN_MASK = PREG_IO_9_MASK;
  258. SD_CMD_OUTPUT_REG = SDXC_A_OUTPUT;
  259. SD_CMD_OUTPUT_MASK = PREG_IO_9_MASK;
  260. SD_CMD_INPUT_REG = SDXC_A_INPUT;
  261. SD_CMD_INPUT_MASK = PREG_IO_9_MASK;
  262. SD_CLK_OUTPUT_EN_REG = SDXC_A_ENABLE;
  263. SD_CLK_OUTPUT_EN_MASK = PREG_IO_8_MASK;
  264. SD_CLK_OUTPUT_REG = SDXC_A_OUTPUT;
  265. SD_CLK_OUTPUT_MASK = PREG_IO_8_MASK;
  266. SD_DAT_OUTPUT_EN_REG = SDXC_A_ENABLE;
  267. SD_DAT0_OUTPUT_EN_MASK = PREG_IO_0_MASK;
  268. SD_DAT0_3_OUTPUT_EN_MASK = PREG_IO_0_3_MASK;
  269. SD_DAT_OUTPUT_REG = SDXC_A_OUTPUT;
  270. SD_DAT0_OUTPUT_MASK = PREG_IO_0_MASK;
  271. SD_DAT0_3_OUTPUT_MASK = PREG_IO_0_3_MASK;
  272. SD_DAT_OUTPUT_OFFSET = 0;
  273. SD_DAT_INPUT_REG = SDXC_A_INPUT;
  274. SD_DAT0_INPUT_MASK = PREG_IO_0_MASK;
  275. SD_DAT0_3_INPUT_MASK = PREG_IO_0_3_MASK;
  276. SD_DAT_INPUT_OFFSET = 0;
  277. break;
  278. default:
  279. printk("Warning couldn`t find any valid hw io pad!!!\n");
  280. break;
  281. }
  282. if (aml_card_info->card_ins_en_reg) {
  283. SD_INS_OUTPUT_EN_REG = aml_card_info->card_ins_en_reg;
  284. SD_INS_OUTPUT_EN_MASK = aml_card_info->card_ins_en_mask;
  285. SD_INS_INPUT_REG = aml_card_info->card_ins_input_reg;
  286. SD_INS_INPUT_MASK = aml_card_info->card_ins_input_mask;
  287. }
  288. else {
  289. SD_INS_OUTPUT_EN_REG = SD_BAKUP_OUTPUT_REG;
  290. SD_INS_OUTPUT_EN_MASK = 1;
  291. SD_INS_INPUT_REG = SD_BAKUP_INPUT_REG;
  292. SD_INS_INPUT_MASK = SD_WP_INPUT_MASK = 1;
  293. }
  294. if (aml_card_info->card_power_en_reg) {
  295. SD_PWR_OUTPUT_EN_REG = aml_card_info->card_power_en_reg;
  296. SD_PWR_OUTPUT_EN_MASK = aml_card_info->card_power_en_mask;
  297. SD_PWR_OUTPUT_REG = aml_card_info->card_power_output_reg;
  298. SD_PWR_OUTPUT_MASK = aml_card_info->card_power_output_mask;
  299. SD_PWR_EN_LEVEL = aml_card_info->card_power_en_lev;
  300. }
  301. else {
  302. SD_PWR_OUTPUT_EN_REG = SD_BAKUP_OUTPUT_REG;
  303. SD_PWR_OUTPUT_EN_MASK = 1;
  304. SD_PWR_OUTPUT_REG = SD_BAKUP_OUTPUT_REG;
  305. SD_PWR_OUTPUT_MASK = 1;
  306. SD_PWR_EN_LEVEL = 0;
  307. }
  308. if (aml_card_info->card_wp_en_reg) {
  309. SD_WP_OUTPUT_EN_REG = aml_card_info->card_wp_en_reg;
  310. SD_WP_OUTPUT_EN_MASK = aml_card_info->card_wp_en_mask;
  311. SD_WP_INPUT_REG = aml_card_info->card_wp_input_reg;
  312. SD_WP_INPUT_MASK = aml_card_info->card_wp_input_mask;
  313. }
  314. else {
  315. SD_WP_OUTPUT_EN_REG = SD_BAKUP_OUTPUT_REG;
  316. SD_WP_OUTPUT_EN_MASK = 1;
  317. SD_WP_INPUT_REG = SD_BAKUP_INPUT_REG;
  318. SD_WP_INPUT_MASK = 1;
  319. }
  320. return;
  321. }
  322. void sd_sdio_enable(SDIO_Pad_Type_t io_pad_type)
  323. {
  324. switch (io_pad_type) {
  325. case SDIO_A_GPIOX_0_3:
  326. SET_CBUS_REG_MASK(CARD_PIN_MUX_8, (0x3F<<0));
  327. SET_CBUS_REG_MASK(SDIO_MULT_CONFIG, (0));
  328. break;
  329. case SDIO_B_CARD_0_5:
  330. SET_CBUS_REG_MASK(CARD_PIN_MUX_2, (0x3F<<10));
  331. SET_CBUS_REG_MASK(SDIO_MULT_CONFIG, (1));
  332. break;
  333. case SDIO_C_BOOT_0_3:
  334. SET_CBUS_REG_MASK(CARD_PIN_MUX_6, (0x3F<<24));
  335. SET_CBUS_REG_MASK(SDIO_MULT_CONFIG, (2));
  336. break;
  337. case SDHC_CARD_0_5 : //SDHC-B
  338. SET_CBUS_REG_MASK(CARD_PIN_MUX_2, (0x3F<<10));
  339. SET_CBUS_REG_MASK(SDIO_MULT_CONFIG, (1));
  340. break;
  341. case SDHC_BOOT_0_11 : //SDHC-C
  342. SET_CBUS_REG_MASK(CARD_PIN_MUX_6, (0x3F<<24));
  343. SET_CBUS_REG_MASK(SDIO_MULT_CONFIG, (2));
  344. break;
  345. case SDHC_GPIOX_0_9 : //SDHC-A
  346. SET_CBUS_REG_MASK(CARD_PIN_MUX_8, 0x3F);
  347. SET_CBUS_REG_MASK(SDIO_MULT_CONFIG, (0));
  348. break;
  349. case SDXC_CARD_0_5 : //SDXC-B
  350. SET_CBUS_REG_MASK(CARD_PIN_MUX_2, (0xF<<4));
  351. //SET_CBUS_REG_MASK(SDIO_MULT_CONFIG, (1));
  352. break;
  353. case SDXC_BOOT_0_11 : //SDXC-C
  354. SET_CBUS_REG_MASK(CARD_PIN_MUX_4, (0x1F<<26));
  355. //SET_CBUS_REG_MASK(SDIO_MULT_CONFIG, (2));
  356. break;
  357. case SDXC_GPIOX_0_9 : //SDXC-A
  358. SET_CBUS_REG_MASK(CARD_PIN_MUX_5, (0x1F<<10));
  359. //SET_CBUS_REG_MASK(SDIO_MULT_CONFIG, (0));
  360. break;
  361. default :
  362. printk("invalid hw io pad!!!\n");
  363. break;
  364. }
  365. return;
  366. }
  367. void sd_gpio_enable(SDIO_Pad_Type_t io_pad_type)
  368. {
  369. switch (io_pad_type) {
  370. case SDIO_A_GPIOX_0_3:
  371. CLEAR_CBUS_REG_MASK(CARD_PIN_MUX_8, (0x3F<<0));
  372. CLEAR_CBUS_REG_MASK(SDIO_MULT_CONFIG, (0));
  373. break;
  374. case SDIO_B_CARD_0_5:
  375. CLEAR_CBUS_REG_MASK(CARD_PIN_MUX_2, (0x3F<<10));
  376. CLEAR_CBUS_REG_MASK(SDIO_MULT_CONFIG, (1));
  377. break;
  378. case SDIO_C_BOOT_0_3:
  379. CLEAR_CBUS_REG_MASK(CARD_PIN_MUX_6, (0x3F<<24));
  380. CLEAR_CBUS_REG_MASK(SDIO_MULT_CONFIG, (2));
  381. break;
  382. case SDHC_CARD_0_5 : //SDHC-B
  383. CLEAR_CBUS_REG_MASK(CARD_PIN_MUX_2, (0x3F<<10));
  384. CLEAR_CBUS_REG_MASK(SDIO_MULT_CONFIG, (1));
  385. break;
  386. case SDHC_BOOT_0_11 : //SDHC-C
  387. CLEAR_CBUS_REG_MASK(CARD_PIN_MUX_6, (0x3F<<24));
  388. CLEAR_CBUS_REG_MASK(SDIO_MULT_CONFIG, (2));
  389. break;
  390. case SDHC_GPIOX_0_9 : //SDHC-A
  391. CLEAR_CBUS_REG_MASK(CARD_PIN_MUX_8, 0x3F);
  392. CLEAR_CBUS_REG_MASK(SDIO_MULT_CONFIG, (0));
  393. break;
  394. case SDXC_CARD_0_5 : //SDXC-B
  395. CLEAR_CBUS_REG_MASK(CARD_PIN_MUX_2, (0xF<<4));
  396. //CLEAR_CBUS_REG_MASK(SDIO_MULT_CONFIG, (1));
  397. break;
  398. case SDXC_BOOT_0_11 : //SDXC-C
  399. CLEAR_CBUS_REG_MASK(CARD_PIN_MUX_4, (0x1F<<26));
  400. //CLEAR_CBUS_REG_MASK(SDIO_MULT_CONFIG, (2));
  401. break;
  402. case SDXC_GPIOX_0_9 : //SDXC-A
  403. CLEAR_CBUS_REG_MASK(CARD_PIN_MUX_5, (0x1F<<10));
  404. //CLEAR_CBUS_REG_MASK(SDIO_MULT_CONFIG, (0));
  405. break;
  406. default :
  407. printk("invalid hw io pad!!!\n");
  408. break;
  409. }
  410. return;
  411. }
  412. /*set SDIO_MULT_CONFIG 0, SDIO CLK(SDIOA) temp be 50M, unwork on samsung NRX600 wifi*/
  413. void sd_gpio_enable_sdioa(void)
  414. {
  415. CLEAR_CBUS_REG_MASK(CARD_PIN_MUX_8, (0x3F<<0));
  416. }