board-rk3108-tb: use new iomux api
author黄涛 <huangtao@rock-chips.com>
Thu, 17 Jan 2013 10:22:34 +0000 (18:22 +0800)
committer黄涛 <huangtao@rock-chips.com>
Thu, 17 Jan 2013 10:22:34 +0000 (18:22 +0800)
arch/arm/mach-rk30/board-rk3108-tb.c

index c8e2b82ccf91777d3700bff230f7cdb6db0ab2f6..3cb50a555decb519f0fa68bb6da479603d47a140 100755 (executable)
@@ -91,10 +91,6 @@ static int goodix_init_platform_hw(void)
 {
        int ret;
        
-       rk30_mux_api_set(GPIO2C0_LCDC1DATA16_SMCADDR0_TRACECLK_NAME, GPIO2C_GPIO2C0);
-       rk30_mux_api_set(GPIO2B4_LCDC1DATA12_SMCDATA12_TRACEDATA12_NAME, GPIO2B_GPIO2B4);
-       printk("%s:0x%x,0x%x\n",__func__,rk30_mux_api_get(GPIO2C0_LCDC1DATA16_SMCADDR0_TRACECLK_NAME),rk30_mux_api_get(GPIO2B4_LCDC1DATA12_SMCDATA12_TRACEDATA12_NAME));
-
        if (TOUCH_PWR_PIN != INVALID_GPIO) {
                ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
                if (ret != 0) {
@@ -140,10 +136,7 @@ static struct spi_board_info board_spi_devices[] = {
 ************************************************************/
 #ifdef CONFIG_BACKLIGHT_RK29_BL
 #define PWM_ID            2
-#define PWM_MUX_NAME      GPIO3D5_PWM2_JTAGTCK_OTGDRVVBUS_NAME
-#define PWM_MUX_MODE      GPIO3D_PWM2
-#define PWM_MUX_MODE_GPIO GPIO3D_GPIO3D5
-#define PWM_GPIO         RK30_PIN3_PD5
+#define PWM_MODE          PWM2
 #define PWM_EFFECT_VALUE  1
 
 #define LCD_DISP_ON_PIN
@@ -155,57 +148,54 @@ static struct spi_board_info board_spi_devices[] = {
 static int rk29_backlight_io_init(void)
 {
        int ret = 0;
-       rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
-#ifdef  LCD_DISP_ON_PIN
-       // rk30_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
 
-       ret = gpio_request(BL_EN_PIN, NULL);
-       if (ret != 0) {
-               gpio_free(BL_EN_PIN);
+       iomux_set(PWM_MODE);
+#ifdef  LCD_DISP_ON_PIN
+       ret = gpio_request(BL_EN_PIN, "bl_en");
+       if (ret == 0) {
+               gpio_direction_output(BL_EN_PIN, BL_EN_VALUE);
        }
-
-       gpio_direction_output(BL_EN_PIN, 0);
-       gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
 #endif
        return ret;
 }
 
 static int rk29_backlight_io_deinit(void)
 {
-       int ret = 0;
+       int ret = 0, pwm_gpio;
 #ifdef  LCD_DISP_ON_PIN
        gpio_free(BL_EN_PIN);
 #endif
-       rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
-       gpio_request(PWM_GPIO, NULL);
-       gpio_direction_output(PWM_GPIO, GPIO_LOW);
+       pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
+       gpio_request(pwm_gpio, "bl_pwm");
+       gpio_direction_output(pwm_gpio, GPIO_LOW);
        return ret;
 }
 
 static int rk29_backlight_pwm_suspend(void)
 {
-       int ret = 0;
-       rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
-       if (gpio_request(PWM_GPIO, NULL)) {
+       int ret, pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
+
+       ret = gpio_request(pwm_gpio, "bl_pwm");
+       if (ret) {
                printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
-               return -1;
+               return ret;
        }
-       gpio_direction_output(PWM_GPIO, GPIO_LOW);
+       gpio_direction_output(pwm_gpio, GPIO_LOW);
 #ifdef  LCD_DISP_ON_PIN
-       gpio_direction_output(BL_EN_PIN, 0);
-       gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
+       gpio_direction_output(BL_EN_PIN, !BL_EN_VALUE);
 #endif
        return ret;
 }
 
 static int rk29_backlight_pwm_resume(void)
 {
-       gpio_free(PWM_GPIO);
-       rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
+       int pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
+
+       gpio_free(pwm_gpio);
+       iomux_set(PWM_MODE);
 #ifdef  LCD_DISP_ON_PIN
        msleep(30);
-       gpio_direction_output(BL_EN_PIN, 1);
-       gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
+       gpio_direction_output(BL_EN_PIN, BL_EN_VALUE);
 #endif
        return 0;
 }
@@ -811,7 +801,7 @@ static struct platform_device device_ion = {
  * SDMMC devices,  include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
 **************************************************************************************************/
 #ifdef CONFIG_SDMMC_RK29
-#include "board-rk3108-tb-sdmmc.c"
+#include "board-rk30-sdk-sdmmc.c"
 
 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
 #define SDMMC0_WRITE_PROTECT_PIN       RK30_PIN3_PB7   //According to your own project to set the value of write-protect-pin.
@@ -845,7 +835,11 @@ static int rk29_sdmmc0_cfg_gpio(void)
 #else
        rk29_sdmmc_set_iomux(0, 0xFFFF);
 
-       rk30_mux_api_set(GPIO3B0_SDMMC0DETECTN_NAME, GPIO3B_SDMMC0DETECTN);
+    #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
+        iomux_set_gpio_mode(iomux_mode_to_gpio(MMC0_DETN));
+    #else
+        iomux_set(MMC0_DETN);
+    #endif     
 
 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
        gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
@@ -1015,9 +1009,8 @@ static struct pwm_platform_data pwm_regulator_info[1] = {
        {
                .pwm_id = 3,
                .pwm_gpio = RK30_PIN3_PD6,
-               .pwm_iomux_name = GPIO3D6_PWM3_JTAGTMS_HOSTDRVVBUS_NAME,
-               .pwm_iomux_pwm = GPIO3D_PWM3,
-               .pwm_iomux_gpio = GPIO3D_GPIO3D6,
+               .pwm_iomux_pwm = PWM3,
+               .pwm_iomux_gpio = GPIO3_D6,
                .pwm_voltage = 1100000,
                .suspend_voltage = 1050000,
                .min_uV = 950000,
@@ -1053,8 +1046,8 @@ static struct rfkill_rk_platform_data rfkill_rk_platdata = {
         .io             = INVALID_GPIO, //RK30_PIN3_PC7,
         .enable         = GPIO_HIGH,
         .iomux          = {
-            .name       = GPIO3C7_SDMMC1WRITEPRT_RMIICRS_NAME,
-            .fgpio      = GPIO3C_GPIO3C7,
+            .name       = "bt_poweron",
+            .fgpio      = GPIO3_C7,
         },
     },
 
@@ -1062,8 +1055,8 @@ static struct rfkill_rk_platform_data rfkill_rk_platdata = {
         .io             = RK30_PIN3_PD1, // set io to INVALID_GPIO for disable it
         .enable         = GPIO_LOW,
         .iomux          = {
-            .name       = GPIO3D1_SDMMC1BACKENDPWR_MIIMDCLK_NAME,
-            .fgpio      = GPIO3D_GPIO3D1,
+            .name       = "bt_reset",
+            .fgpio      = GPIO3_D1,
        },
    }, 
 
@@ -1071,8 +1064,8 @@ static struct rfkill_rk_platform_data rfkill_rk_platdata = {
         .io             = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
         .enable         = GPIO_HIGH,
         .iomux          = {
-            .name       = GPIO3C6_SDMMC1DETECTN_RMIIRXERR_NAME,
-            .fgpio      = GPIO3C_GPIO3C6,
+            .name       = "bt_wake",
+            .fgpio      = GPIO3_C6,
         },
     },
 
@@ -1090,9 +1083,9 @@ static struct rfkill_rk_platform_data rfkill_rk_platdata = {
         .io             = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
         .enable         = GPIO_LOW,
         .iomux          = {
-            .name       = GPIO1A3_UART0RTSN_NAME,
-            .fgpio      = GPIO1A_GPIO1A3,
-            .fmux       = GPIO1A_UART0RTSN,
+            .name       = "bt_rts",
+            .fgpio      = GPIO1_A3,
+            .fmux       = UART0_RTSN,
         },
     },
 };
@@ -1578,12 +1571,12 @@ void __sramfunc rk30_pwm_logic_suspend_voltage(void)
 
 //     int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
        sram_udelay(10000);
-       gpio3d6_iomux = readl_relaxed(GRF_GPIO3D_IOMUX);
+       gpio3d6_iomux = grf_readl(GRF_GPIO3D_IOMUX);
        gpio3d6_do = grf_readl(GRF_GPIO3H_DO);
        gpio3d6_dir = grf_readl(GRF_GPIO3H_DIR);
        gpio3d6_en = grf_readl(GRF_GPIO3H_EN);
 
-       writel_relaxed((1<<28), GRF_GPIO3D_IOMUX);
+       grf_writel((1<<28), GRF_GPIO3D_IOMUX);
        grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DIR);
        grf_writel((1<<30)|(1<<14), GRF_GPIO3H_DO);
        grf_writel((1<<30)|(1<<14), GRF_GPIO3H_EN);
@@ -1592,7 +1585,7 @@ void __sramfunc rk30_pwm_logic_suspend_voltage(void)
 void __sramfunc rk30_pwm_logic_resume_voltage(void)
 {
 #ifdef CONFIG_RK30_PWM_REGULATOR
-       writel_relaxed((1<<28)|gpio3d6_iomux, GRF_GPIO3D_IOMUX);
+       grf_writel((1<<28)|gpio3d6_iomux, GRF_GPIO3D_IOMUX);
        grf_writel((1<<30)|gpio3d6_en, GRF_GPIO3H_EN);
        grf_writel((1<<30)|gpio3d6_dir, GRF_GPIO3H_DIR);
        grf_writel((1<<30)|gpio3d6_do, GRF_GPIO3H_DO);
@@ -1718,8 +1711,7 @@ static void __init machine_rk30_board_init(void)
         gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
 
        //test
-        rk30_mux_api_set(GPIO2A1_LCDC1DATA1_SMCDATA1_TRACEDATA1_NAME, GPIO2A_GPIO2A1);
-        rk30_mux_api_set(GPIO2A2_LCDC1DATA2_SMCDATA2_TRACEDATA2_NAME, GPIO2A_GPIO2A2);
+        iomux_set(GPIO2_A2);
         gpio_request(RK30_PIN2_PA1, NULL);
         gpio_direction_output(RK30_PIN2_PA1, GPIO_HIGH);