1 /***************************************************************************************************
2 * arch/arm/palt-rk/rk-sdmmc-ops.c
4 * Copyright (C) 2013 ROCKCHIP, Inc.
6 * Description: define the gpio for SDMMC module on various platforms
9 * E-mail: xbw@rock-chips.com
12 * ver1.0 Unified function interface for new imoux-API, created at 2013-01-15
13 * ver1.1 add drive strength control and the setting of IO-voltage, created at 2013-01-29
15 **************************************************************************************************/
17 //use the new iomux-API
18 #if 1//defined(CONFIG_ARCH_RK3066B)||defined(CONFIG_ARCH_RK3168)||defined(CONFIG_ARCH_RK3188)
19 #define SDMMC_USE_NEW_IOMUX_API 1
21 #define SDMMC_USE_NEW_IOMUX_API 0
25 #if defined(CONFIG_ARCH_RK3066B)||defined(CONFIG_ARCH_RK3168)||defined(CONFIG_ARCH_RK3188)
26 #define SDMMC_SET_IO_VOLTAGE 1
28 #define SDMMC_SET_IO_VOLTAGE 0
31 #if SDMMC_SET_IO_VOLTAGE
33 #define SDMMC0_DRIVER_STRENGTH_2MA (0x00 << 6)
34 #define SDMMC0_DRIVER_STRENGTH_4MA (0x01 << 6)
35 #define SDMMC0_DRIVER_STRENGTH_8MA (0x02 << 6)
36 #define SDMMC0_DRIVER_STRENGTH_12MA (0x03 << 6)
37 #define SDMMC0_DRIVER_STRENGTH_MASK (0x03 << 22)
40 #define SDMMC1_DRIVER_STRENGTH_2MA (0x00 << 2)
41 #define SDMMC1_DRIVER_STRENGTH_4MA (0x01 << 2)
42 #define SDMMC1_DRIVER_STRENGTH_8MA (0x02 << 2)
43 #define SDMMC1_DRIVER_STRENGTH_12MA (0x03 << 2)
44 #define SDMMC1_DRIVER_STRENGTH_MASK (0x03 << 18)
47 #define SDMMC0_IO_VOLTAGE_33 (0x00 << 12)
48 #define SDMMC0_IO_VOLTAGE_18 (0x01 << 12)
49 #define SDMMC0_IO_VOLTAGE_MASK (0x01 << 28)
51 #define SDMMC1_IO_VOLTAGE_33 (0x00 << 8)
52 #define SDMMC1_IO_VOLTAGE_18 (0x01 << 8)
53 #define SDMMC1_IO_VOLTAGE_MASK (0x01 << 24)
55 #define SDMMC_write_grf_reg(addr, val) __raw_writel(val, addr+RK30_GRF_BASE)
56 #define SDMMC_read_grf_reg(addr) __raw_readl(addr+RK30_GRF_BASE)
57 #define SDMMC_mask_grf_reg(addr, msk, val) write_grf_reg(addr,(val)|((~(msk))&read_grf_reg(addr)))
59 #define SDMMC_write_grf_reg(addr, val)
60 #define SDMMC_read_grf_reg(addr)
61 #define SDMMC_mask_grf_reg(addr, msk, val)
64 int rk31sdk_wifi_voltage_select(void)
69 voltage = rk31sdk_get_sdio_wifi_voltage();
73 else if(voltage <= 2000)
82 #if defined(CONFIG_ARCH_RK3066B) || defined(CONFIG_ARCH_RK3188)
84 * define the gpio for sdmmc0
86 static struct rksdmmc_gpio_board rksdmmc0_gpio_init = {
92 .name = "mmc0_clkout",
150 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
151 .io = RK29SDK_SD_CARD_PWR_EN,
152 .enable = RK29SDK_SD_CARD_PWR_EN_LEVEL,
153 #ifdef RK29SDK_SD_CARD_PWR_EN_PIN_NAME
155 .name = RK29SDK_SD_CARD_PWR_EN_PIN_NAME,
156 #ifdef RK29SDK_SD_CARD_PWR_EN_IOMUX_FGPIO
157 .fgpio = RK29SDK_SD_CARD_PWR_EN_IOMUX_FGPIO,
159 #ifdef RK29SDK_SD_CARD_PWR_EN_IOMUX_FMUX
160 .fmux = RK29SDK_SD_CARD_PWR_EN_IOMUX_FMUX,
171 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
172 .io = RK29SDK_SD_CARD_DETECT_N,
173 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
174 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
176 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
177 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
178 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
180 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
181 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
195 * define the gpio for sdmmc1
197 static struct rksdmmc_gpio_board rksdmmc1_gpio_init = {
203 .name = "mmc1_clkout",
259 // ---end -#if defined(CONFIG_ARCH_RK3066B)
261 #elif defined(CONFIG_ARCH_RK2928)
263 * define the gpio for sdmmc0
265 static struct rksdmmc_gpio_board rksdmmc0_gpio_init = {
268 .io = RK2928_PIN1_PC0,
271 #if !(!!SDMMC_USE_NEW_IOMUX_API)
272 .name = GPIO1C0_MMC0_CLKOUT_NAME,
273 .fgpio = GPIO1C_GPIO1C0,
274 .fmux = GPIO1C_MMC0_CLKOUT,
280 .io = RK2928_PIN1_PC7,
283 #if !(!!SDMMC_USE_NEW_IOMUX_API)
284 .name = GPIO1B7_MMC0_CMD_NAME,
285 .fgpio = GPIO1B_GPIO1B7,
286 .fmux = GPIO1B_MMC0_CMD,
292 .io = RK2928_PIN1_PC2,
295 #if !(!!SDMMC_USE_NEW_IOMUX_API)
296 .name = GPIO1C2_MMC0_D0_NAME,
297 .fgpio = GPIO1C_GPIO1C2,
298 .fmux = GPIO1C_MMC0_D0,
304 .io = RK2928_PIN1_PC3,
307 #if !(!!SDMMC_USE_NEW_IOMUX_API)
308 .name = GPIO1C3_MMC0_D1_NAME,
309 .fgpio = GPIO1C_GPIO1C3,
310 .fmux = GPIO1C_MMC0_D1,
316 .io = RK2928_PIN1_PC4,
319 #if !(!!SDMMC_USE_NEW_IOMUX_API)
320 .name = GPIO1C4_MMC0_D2_NAME,
321 .fgpio = GPIO1C_GPIO1C4,
322 .fmux = GPIO1C_MMC0_D2,
328 .io = RK2928_PIN1_PC5,
331 #if !(!!SDMMC_USE_NEW_IOMUX_API)
332 .name = GPIO1C5_MMC0_D3_NAME,
333 .fgpio = GPIO1C_GPIO1C5,
334 .fmux = GPIO1C_MMC0_D3,
341 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
342 .io = RK29SDK_SD_CARD_PWR_EN,
343 .enable = RK29SDK_SD_CARD_PWR_EN_LEVEL,
344 #ifdef RK29SDK_SD_CARD_PWR_EN_PIN_NAME
346 .name = RK29SDK_SD_CARD_PWR_EN_PIN_NAME,
347 #ifdef RK29SDK_SD_CARD_PWR_EN_IOMUX_FGPIO
348 .fgpio = RK29SDK_SD_CARD_PWR_EN_IOMUX_FGPIO,
350 #ifdef RK29SDK_SD_CARD_PWR_EN_IOMUX_FMUX
351 .fmux = RK29SDK_SD_CARD_PWR_EN_IOMUX_FMUX,
362 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
363 .io = RK29SDK_SD_CARD_DETECT_N,
364 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
365 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
367 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
368 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
369 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
371 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
372 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
385 * define the gpio for sdmmc1
387 static struct rksdmmc_gpio_board rksdmmc1_gpio_init = {
390 .io = RK2928_PIN0_PB1,
393 #if !(!!SDMMC_USE_NEW_IOMUX_API)
394 .name = GPIO0B1_MMC1_CLKOUT_NAME,
395 .fgpio = GPIO0B_GPIO0B1,
396 .fmux = GPIO0B_MMC1_CLKOUT,
402 .io = RK2928_PIN0_PB0,
405 #if !(!!SDMMC_USE_NEW_IOMUX_API)
406 .name = GPIO0B0_MMC1_CMD_NAME,
407 .fgpio = GPIO0B_GPIO0B0,
408 .fmux = GPIO0B_MMC1_CMD,
414 .io = RK2928_PIN0_PB3,
417 #if !(!!SDMMC_USE_NEW_IOMUX_API)
418 .name = GPIO0B3_MMC1_D0_NAME,
419 .fgpio = GPIO0B_GPIO0B3,
420 .fmux = GPIO0B_MMC1_D0,
426 .io = RK2928_PIN0_PB4,
429 #if !(!!SDMMC_USE_NEW_IOMUX_API)
430 .name = GPIO0B4_MMC1_D1_NAME,
431 .fgpio = GPIO0B_GPIO0B4,
432 .fmux = GPIO0B_MMC1_D1,
438 .io = RK2928_PIN0_PB5,
441 #if !(!!SDMMC_USE_NEW_IOMUX_API)
442 .name = GPIO0B5_MMC1_D2_NAME,
443 .fgpio = GPIO0B_GPIO0B5,
444 .fmux = GPIO0B_MMC1_D2,
450 .io = RK2928_PIN0_PB6,
453 #if !(!!SDMMC_USE_NEW_IOMUX_API)
454 .name = GPIO0B6_MMC1_D3_NAME,
455 .fgpio = GPIO0B_GPIO0B6,
456 .fmux = GPIO0B_MMC1_D3,
463 // ---end -#if defined(CONFIG_ARCH_RK2928)
464 #elif defined(CONFIG_ARCH_RK3026)
466 * define the gpio for sdmmc0
468 static struct rksdmmc_gpio_board rksdmmc0_gpio_init = {
532 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
533 .io = RK29SDK_SD_CARD_PWR_EN,
534 .enable = RK29SDK_SD_CARD_PWR_EN_LEVEL,
535 #ifdef RK29SDK_SD_CARD_PWR_EN_PIN_NAME
537 .name = RK29SDK_SD_CARD_PWR_EN_PIN_NAME,
538 #ifdef RK29SDK_SD_CARD_PWR_EN_IOMUX_FGPIO
539 .fgpio = RK29SDK_SD_CARD_PWR_EN_IOMUX_FGPIO,
541 #ifdef RK29SDK_SD_CARD_PWR_EN_IOMUX_FMUX
542 .fmux = RK29SDK_SD_CARD_PWR_EN_IOMUX_FMUX,
553 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
554 .io = RK29SDK_SD_CARD_DETECT_N,
555 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
556 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
558 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
559 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
560 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
562 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
563 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
576 * define the gpio for sdmmc1
578 static struct rksdmmc_gpio_board rksdmmc1_gpio_init = {
642 // ---end -#if defined(CONFIG_ARCH_RK3026)
644 #else //default for RK30,RK3066 SDK
646 * define the gpio for sdmmc0
648 struct rksdmmc_gpio_board rksdmmc0_gpio_init = {
654 #if !(!!SDMMC_USE_NEW_IOMUX_API)
655 .name = GPIO3B0_SDMMC0CLKOUT_NAME,
656 .fgpio = GPIO3B_GPIO3B0,
657 .fmux = GPIO3B_SDMMC0_CLKOUT,
666 #if !(!!SDMMC_USE_NEW_IOMUX_API)
667 .name = GPIO3B1_SDMMC0CMD_NAME,
668 .fgpio = GPIO3B_GPIO3B1,
669 .fmux = GPIO3B_SDMMC0_CMD,
678 #if !(!!SDMMC_USE_NEW_IOMUX_API)
679 .name = GPIO3B2_SDMMC0DATA0_NAME,
680 .fgpio = GPIO3B_GPIO3B2,
681 .fmux = GPIO3B_SDMMC0_DATA0,
690 #if !(!!SDMMC_USE_NEW_IOMUX_API)
691 .name = GPIO3B3_SDMMC0DATA1_NAME,
692 .fgpio = GPIO3B_GPIO3B3,
693 .fmux = GPIO3B_SDMMC0_DATA1,
702 #if !(!!SDMMC_USE_NEW_IOMUX_API)
703 .name = GPIO3B4_SDMMC0DATA2_NAME,
704 .fgpio = GPIO3B_GPIO3B4,
705 .fmux = GPIO3B_SDMMC0_DATA2,
714 #if !(!!SDMMC_USE_NEW_IOMUX_API)
715 .name = GPIO3B5_SDMMC0DATA3_NAME,
716 .fgpio = GPIO3B_GPIO3B5,
717 .fmux = GPIO3B_SDMMC0_DATA3,
723 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
724 .io = RK29SDK_SD_CARD_PWR_EN,
725 .enable = RK29SDK_SD_CARD_PWR_EN_LEVEL,
726 #ifdef RK29SDK_SD_CARD_PWR_EN_PIN_NAME
728 .name = RK29SDK_SD_CARD_PWR_EN_PIN_NAME,
729 #ifdef RK29SDK_SD_CARD_PWR_EN_IOMUX_FGPIO
730 .fgpio = RK29SDK_SD_CARD_PWR_EN_IOMUX_FGPIO,
732 #ifdef RK29SDK_SD_CARD_PWR_EN_IOMUX_FMUX
733 .fmux = RK29SDK_SD_CARD_PWR_EN_IOMUX_FMUX,
744 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)
745 .io = RK29SDK_SD_CARD_DETECT_N,
746 .enable = RK29SDK_SD_CARD_INSERT_LEVEL,
747 #ifdef RK29SDK_SD_CARD_DETECT_PIN_NAME
749 .name = RK29SDK_SD_CARD_DETECT_PIN_NAME,
750 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO
751 .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO,
753 #ifdef RK29SDK_SD_CARD_DETECT_IOMUX_FMUX
754 .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX,
767 * define the gpio for sdmmc1
769 static struct rksdmmc_gpio_board rksdmmc1_gpio_init = {
775 #if !(!!SDMMC_USE_NEW_IOMUX_API)
776 .name = GPIO3C5_SDMMC1CLKOUT_NAME,
777 .fgpio = GPIO3C_GPIO3C5,
778 .fmux = GPIO3B_SDMMC0_CLKOUT,
787 #if !(!!SDMMC_USE_NEW_IOMUX_API)
788 .name = GPIO3C0_SMMC1CMD_NAME,
789 .fgpio = GPIO3C_GPIO3C0,
790 .fmux = GPIO3B_SDMMC0_CMD,
799 #if !(!!SDMMC_USE_NEW_IOMUX_API)
800 .name = GPIO3C1_SDMMC1DATA0_NAME,
801 .fgpio = GPIO3C_GPIO3C1,
802 .fmux = GPIO3B_SDMMC0_DATA0,
811 #if !(!!SDMMC_USE_NEW_IOMUX_API)
812 .name = GPIO3C2_SDMMC1DATA1_NAME,
813 .fgpio = GPIO3C_GPIO3C2,
814 .fmux = GPIO3B_SDMMC0_DATA1,
823 #if !(!!SDMMC_USE_NEW_IOMUX_API)
824 .name = GPIO3C3_SDMMC1DATA2_NAME,
825 .fgpio = GPIO3C_GPIO3C3,
826 .fmux = GPIO3B_SDMMC0_DATA2,
835 #if !(!!SDMMC_USE_NEW_IOMUX_API)
836 .name = GPIO3C4_SDMMC1DATA3_NAME,
837 .fgpio = GPIO3C_GPIO3C4,
838 .fmux = GPIO3B_SDMMC0_DATA3,
843 // ---end -defualt rk30sdk,rk3066sdk
849 //1.Part 3: The various operations of the SDMMC-SDIO module
850 /*************************************************************************
851 * define the varaious operations for SDMMC module
852 * Generally only the author of SDMMC module will modify this section.
853 *************************************************************************/
854 #if !defined(CONFIG_SDMMC_RK29_OLD)
855 //static void rk29_sdmmc_gpio_open(int device_id, int on)
856 void rk29_sdmmc_gpio_open(int device_id, int on)
862 #ifdef CONFIG_SDMMC0_RK29
865 gpio_direction_output(rksdmmc0_gpio_init.clk_gpio.io, GPIO_HIGH);//set mmc0-clk to high
866 gpio_direction_output(rksdmmc0_gpio_init.cmd_gpio.io, GPIO_HIGH);// set mmc0-cmd to high.
867 gpio_direction_output(rksdmmc0_gpio_init.data0_gpio.io,GPIO_HIGH);//set mmc0-data0 to high.
868 gpio_direction_output(rksdmmc0_gpio_init.data1_gpio.io,GPIO_HIGH);//set mmc0-data1 to high.
869 gpio_direction_output(rksdmmc0_gpio_init.data2_gpio.io,GPIO_HIGH);//set mmc0-data2 to high.
870 gpio_direction_output(rksdmmc0_gpio_init.data3_gpio.io,GPIO_HIGH);//set mmc0-data3 to high.
876 #if !(!!SDMMC_USE_NEW_IOMUX_API)
877 rk30_mux_api_set(rksdmmc0_gpio_init.clk_gpio.iomux.name, rksdmmc0_gpio_init.clk_gpio.iomux.fgpio);
879 gpio_request(rksdmmc0_gpio_init.clk_gpio.io, "mmc0-clk");
880 gpio_direction_output(rksdmmc0_gpio_init.clk_gpio.io,GPIO_LOW);//set mmc0-clk to low.
882 #if !(!!SDMMC_USE_NEW_IOMUX_API)
883 rk30_mux_api_set(rksdmmc0_gpio_init.cmd_gpio.iomux.name, rksdmmc0_gpio_init.cmd_gpio.iomux.fgpio);
885 gpio_request(rksdmmc0_gpio_init.cmd_gpio.io, "mmc0-cmd");
886 gpio_direction_output(rksdmmc0_gpio_init.cmd_gpio.io,GPIO_LOW);//set mmc0-cmd to low.
888 #if !(!!SDMMC_USE_NEW_IOMUX_API)
889 rk30_mux_api_set(rksdmmc0_gpio_init.data0_gpio.iomux.name, rksdmmc0_gpio_init.data0_gpio.iomux.fgpio);
891 gpio_request(rksdmmc0_gpio_init.data0_gpio.io, "mmc0-data0");
892 gpio_direction_output(rksdmmc0_gpio_init.data0_gpio.io,GPIO_LOW);//set mmc0-data0 to low.
894 #if !(!!SDMMC_USE_NEW_IOMUX_API)
895 rk30_mux_api_set(rksdmmc0_gpio_init.data1_gpio.iomux.name, rksdmmc0_gpio_init.data1_gpio.iomux.fgpio);
897 gpio_request(rksdmmc0_gpio_init.data1_gpio.io, "mmc0-data1");
898 gpio_direction_output(rksdmmc0_gpio_init.data1_gpio.io,GPIO_LOW);//set mmc0-data1 to low.
900 #if !(!!SDMMC_USE_NEW_IOMUX_API)
901 rk30_mux_api_set(rksdmmc0_gpio_init.data2_gpio.iomux.name, rksdmmc0_gpio_init.data2_gpio.iomux.fgpio);
903 gpio_request(rksdmmc0_gpio_init.data2_gpio.io, "mmc0-data2");
904 gpio_direction_output(rksdmmc0_gpio_init.data2_gpio.io,GPIO_LOW);//set mmc0-data2 to low.
906 #if !(!!SDMMC_USE_NEW_IOMUX_API)
907 rk30_mux_api_set(rksdmmc0_gpio_init.data3_gpio.iomux.name, rksdmmc0_gpio_init.data3_gpio.iomux.fgpio);
909 gpio_request(rksdmmc0_gpio_init.data3_gpio.io, "mmc0-data3");
910 gpio_direction_output(rksdmmc0_gpio_init.data3_gpio.io,GPIO_LOW);//set mmc0-data3 to low.
920 #ifdef CONFIG_SDMMC1_RK29
923 gpio_direction_output(rksdmmc1_gpio_init.clk_gpio.io,GPIO_HIGH);//set mmc1-clk to high
924 gpio_direction_output(rksdmmc1_gpio_init.cmd_gpio.io,GPIO_HIGH);//set mmc1-cmd to high.
925 gpio_direction_output(rksdmmc1_gpio_init.data0_gpio.io,GPIO_HIGH);//set mmc1-data0 to high.
926 gpio_direction_output(rksdmmc1_gpio_init.data1_gpio.io,GPIO_HIGH);//set mmc1-data1 to high.
927 gpio_direction_output(rksdmmc1_gpio_init.data2_gpio.io,GPIO_HIGH);//set mmc1-data2 to high.
928 gpio_direction_output(rksdmmc1_gpio_init.data3_gpio.io,GPIO_HIGH);//set mmc1-data3 to high.
933 #if !(!!SDMMC_USE_NEW_IOMUX_API)
934 rk30_mux_api_set(rksdmmc1_gpio_init.clk_gpio.iomux.name, rksdmmc1_gpio_init.clk_gpio.iomux.fgpio);
936 gpio_request(rksdmmc1_gpio_init.clk_gpio.io, "mmc1-clk");
937 gpio_direction_output(rksdmmc1_gpio_init.clk_gpio.io,GPIO_LOW);//set mmc1-clk to low.
939 #if !(!!SDMMC_USE_NEW_IOMUX_API)
940 rk30_mux_api_set(rksdmmc1_gpio_init.cmd_gpio.iomux.name, rksdmmc1_gpio_init.cmd_gpio.iomux.fgpio);
942 gpio_request(rksdmmc1_gpio_init.cmd_gpio.io, "mmc1-cmd");
943 gpio_direction_output(rksdmmc1_gpio_init.cmd_gpio.io,GPIO_LOW);//set mmc1-cmd to low.
945 #if !(!!SDMMC_USE_NEW_IOMUX_API)
946 rk30_mux_api_set(rksdmmc1_gpio_init.data0_gpio.iomux.name, rksdmmc1_gpio_init.data0_gpio.iomux.fgpio);
948 gpio_request(rksdmmc1_gpio_init.data0_gpio.io, "mmc1-data0");
949 gpio_direction_output(rksdmmc1_gpio_init.data0_gpio.io,GPIO_LOW);//set mmc1-data0 to low.
951 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) || defined(CONFIG_MT5931) || defined(CONFIG_MT5931_MT6622)
952 #if !(!!SDMMC_USE_NEW_IOMUX_API)
953 rk29_mux_api_set(rksdmmc1_gpio_init.data1_gpio.iomux.name, rksdmmc1_gpio_init.data1_gpio.iomux.fgpio);
955 gpio_request(rksdmmc1_gpio_init.data1_gpio.io, "mmc1-data1");
956 gpio_direction_output(rksdmmc1_gpio_init.data1_gpio.io,GPIO_LOW);//set mmc1-data1 to low.
958 #if !(!!SDMMC_USE_NEW_IOMUX_API)
959 rk29_mux_api_set(rksdmmc1_gpio_init.data2_gpio.iomux.name, rksdmmc1_gpio_init.data2_gpio.iomux.fgpio);
961 gpio_request(rksdmmc1_gpio_init.data2_gpio.io, "mmc1-data2");
962 gpio_direction_output(rksdmmc1_gpio_init.data2_gpio.io,GPIO_LOW);//set mmc1-data2 to low.
964 #if !(!!SDMMC_USE_NEW_IOMUX_API)
965 rk29_mux_api_set(rksdmmc1_gpio_init.data3_gpio.iomux.name, rksdmmc1_gpio_init.data3_gpio.iomux.fgpio);
967 gpio_request(rksdmmc1_gpio_init.data3_gpio.io, "mmc1-data3");
968 gpio_direction_output(rksdmmc1_gpio_init.data3_gpio.io,GPIO_LOW);//set mmc1-data3 to low.
984 static void rk29_sdmmc_set_iomux_mmc0(unsigned int bus_width)
989 case 1://SDMMC_CTYPE_4BIT:
991 #if SDMMC_USE_NEW_IOMUX_API
992 iomux_set(rksdmmc0_gpio_init.data1_gpio.iomux.fmux);
993 iomux_set(rksdmmc0_gpio_init.data2_gpio.iomux.fmux);
994 iomux_set(rksdmmc0_gpio_init.data3_gpio.iomux.fmux);
996 rk30_mux_api_set(rksdmmc0_gpio_init.data1_gpio.iomux.name, rksdmmc0_gpio_init.data1_gpio.iomux.fmux);
997 rk30_mux_api_set(rksdmmc0_gpio_init.data2_gpio.iomux.name, rksdmmc0_gpio_init.data2_gpio.iomux.fmux);
998 rk30_mux_api_set(rksdmmc0_gpio_init.data3_gpio.iomux.name, rksdmmc0_gpio_init.data3_gpio.iomux.fmux);
1003 case 0x10000://SDMMC_CTYPE_8BIT:
1005 case 0xFFFF: //gpio_reset
1007 #if (!!SDMMC_USE_NEW_IOMUX_API) && !defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
1008 iomux_set(MMC0_DETN);
1011 #if !(!!SDMMC_USE_NEW_IOMUX_API)
1012 rk30_mux_api_set(rksdmmc0_gpio_init.power_en_gpio.iomux.name, rksdmmc0_gpio_init.power_en_gpio.iomux.fgpio);
1014 gpio_request(rksdmmc0_gpio_init.power_en_gpio.io,"sdmmc-power");
1015 gpio_direction_output(rksdmmc0_gpio_init.power_en_gpio.io, !(rksdmmc0_gpio_init.power_en_gpio.enable)); //power-off
1017 #if 0 //replace the power control into rk29_sdmmc_set_ios(); modifyed by xbw at 2012-08-12
1018 rk29_sdmmc_gpio_open(0, 0);
1020 gpio_direction_output(rksdmmc0_gpio_init.power_en_gpio.io, rksdmmc0_gpio_init.power_en_gpio.enable); //power-on
1022 rk29_sdmmc_gpio_open(0, 1);
1027 default: //case 0://SDMMC_CTYPE_1BIT:
1029 #if SDMMC_USE_NEW_IOMUX_API
1030 iomux_set(rksdmmc0_gpio_init.cmd_gpio.iomux.fmux);
1031 iomux_set(rksdmmc0_gpio_init.clk_gpio.iomux.fmux);
1032 iomux_set(rksdmmc0_gpio_init.data0_gpio.iomux.fmux);
1034 rk30_mux_api_set(rksdmmc0_gpio_init.cmd_gpio.iomux.name, rksdmmc0_gpio_init.cmd_gpio.iomux.fmux);
1035 rk30_mux_api_set(rksdmmc0_gpio_init.clk_gpio.iomux.name, rksdmmc0_gpio_init.clk_gpio.iomux.fmux);
1036 rk30_mux_api_set(rksdmmc0_gpio_init.data0_gpio.iomux.name, rksdmmc0_gpio_init.data0_gpio.iomux.fmux);
1039 //IO voltage(vccio);
1040 #ifdef RK31SDK_SET_SDMMC0_PIN_VOLTAGE
1041 if(rk31sdk_get_sdmmc0_pin_io_voltage() > 2700)
1042 SDMMC_write_grf_reg(GRF_IO_CON4, (SDMMC0_IO_VOLTAGE_MASK |SDMMC0_IO_VOLTAGE_33)); //set SDMMC0 pin to 3.3v
1044 SDMMC_write_grf_reg(GRF_IO_CON4, (SDMMC0_IO_VOLTAGE_MASK |SDMMC0_IO_VOLTAGE_18));//set SDMMC0 pin to 1.8v
1046 //default set the voltage of SDMMC0 to 3.3V
1047 SDMMC_write_grf_reg(GRF_IO_CON4, (SDMMC0_IO_VOLTAGE_MASK |SDMMC0_IO_VOLTAGE_33));
1050 //sdmmc drive strength control
1051 SDMMC_write_grf_reg(GRF_IO_CON2, (SDMMC0_DRIVER_STRENGTH_MASK |SDMMC0_DRIVER_STRENGTH_8MA));
1053 #if !(!!SDMMC_USE_NEW_IOMUX_API)
1054 rk30_mux_api_set(rksdmmc0_gpio_init.data1_gpio.iomux.name, rksdmmc0_gpio_init.data1_gpio.iomux.fgpio);
1056 gpio_request(rksdmmc0_gpio_init.data1_gpio.io, "mmc0-data1");
1057 gpio_direction_output(rksdmmc0_gpio_init.data1_gpio.io,GPIO_HIGH);//set mmc0-data1 to high.
1059 #if !(!!SDMMC_USE_NEW_IOMUX_API)
1060 rk30_mux_api_set(rksdmmc0_gpio_init.data2_gpio.iomux.name, rksdmmc0_gpio_init.data2_gpio.iomux.fgpio);
1062 gpio_request(rksdmmc0_gpio_init.data2_gpio.io, "mmc0-data2");
1063 gpio_direction_output(rksdmmc0_gpio_init.data2_gpio.io,GPIO_HIGH);//set mmc0-data2 to high.
1065 #if !(!!SDMMC_USE_NEW_IOMUX_API)
1066 rk30_mux_api_set(rksdmmc0_gpio_init.data3_gpio.iomux.name, rksdmmc0_gpio_init.data3_gpio.iomux.fgpio);
1068 gpio_request(rksdmmc0_gpio_init.data3_gpio.io, "mmc0-data3");
1069 gpio_direction_output(rksdmmc0_gpio_init.data3_gpio.io,GPIO_HIGH);//set mmc0-data3 to high.
1075 static void rk29_sdmmc_set_iomux_mmc1(unsigned int bus_width)
1077 #if SDMMC_USE_NEW_IOMUX_API
1078 iomux_set(rksdmmc1_gpio_init.cmd_gpio.iomux.fmux);
1079 iomux_set(rksdmmc1_gpio_init.clk_gpio.iomux.fmux);
1080 iomux_set(rksdmmc1_gpio_init.data0_gpio.iomux.fmux);
1081 iomux_set(rksdmmc1_gpio_init.data1_gpio.iomux.fmux);
1082 iomux_set(rksdmmc1_gpio_init.data2_gpio.iomux.fmux);
1083 iomux_set(rksdmmc1_gpio_init.data3_gpio.iomux.fmux);
1085 rk30_mux_api_set(rksdmmc1_gpio_init.cmd_gpio.iomux.name, rksdmmc1_gpio_init.cmd_gpio.iomux.fmux);
1086 rk30_mux_api_set(rksdmmc1_gpio_init.clk_gpio.iomux.name, rksdmmc1_gpio_init.clk_gpio.iomux.fmux);
1087 rk30_mux_api_set(rksdmmc1_gpio_init.data0_gpio.iomux.name, rksdmmc1_gpio_init.data0_gpio.iomux.fmux);
1088 rk30_mux_api_set(rksdmmc1_gpio_init.data1_gpio.iomux.name, rksdmmc1_gpio_init.data1_gpio.iomux.fmux);
1089 rk30_mux_api_set(rksdmmc1_gpio_init.data2_gpio.iomux.name, rksdmmc1_gpio_init.data2_gpio.iomux.fmux);
1090 rk30_mux_api_set(rksdmmc1_gpio_init.data3_gpio.iomux.name, rksdmmc1_gpio_init.data3_gpio.iomux.fmux);
1093 //IO voltage(vcc-ap0)
1094 if(rk31sdk_wifi_voltage_select())
1095 SDMMC_write_grf_reg(GRF_IO_CON4, (SDMMC1_IO_VOLTAGE_MASK|SDMMC1_IO_VOLTAGE_18));
1097 SDMMC_write_grf_reg(GRF_IO_CON4, (SDMMC1_IO_VOLTAGE_MASK|SDMMC1_IO_VOLTAGE_33));
1099 //sdmmc1 drive strength control
1100 SDMMC_write_grf_reg(GRF_IO_CON3, (SDMMC1_DRIVER_STRENGTH_MASK|SDMMC1_DRIVER_STRENGTH_12MA));
1104 static void rk29_sdmmc_set_iomux_mmc2(unsigned int bus_width)
1109 static void rk29_sdmmc_set_iomux(int device_id, unsigned int bus_width)
1114 #ifdef CONFIG_SDMMC0_RK29
1115 rk29_sdmmc_set_iomux_mmc0(bus_width);
1119 #ifdef CONFIG_SDMMC1_RK29
1120 rk29_sdmmc_set_iomux_mmc1(bus_width);
1124 rk29_sdmmc_set_iomux_mmc2(bus_width);