rk30: refactor code
author黄涛 <huangtao@rock-chips.com>
Wed, 22 Feb 2012 08:06:07 +0000 (16:06 +0800)
committer黄涛 <huangtao@rock-chips.com>
Wed, 22 Feb 2012 08:06:07 +0000 (16:06 +0800)
arch/arm/mach-rk30/board-rk30-sdk.c
arch/arm/mach-rk30/devices.c
arch/arm/plat-rk/include/plat/board.h

index 7e7307175e7e6f34b02b6df310b72fd864ceedf2..80add14938513fa3033ded363dcd28fb1bffdf59 100755 (executable)
@@ -245,7 +245,7 @@ static int rk29_backlight_pwm_resume(void)
        return 0;
 }
 
-struct rk29_bl_info rk29_bl_info = {
+static struct rk29_bl_info rk29_bl_info = {
     .pwm_id   = PWM_ID,
     .bl_ref   = PWM_EFFECT_VALUE,
     .io_init   = rk29_backlight_io_init,
@@ -255,7 +255,7 @@ struct rk29_bl_info rk29_bl_info = {
 };
 
 
-struct platform_device rk29_device_backlight = {
+static struct platform_device rk29_device_backlight = {
        .name   = "rk29_backlight",
        .id     = -1,
         .dev    = {
@@ -293,8 +293,7 @@ static struct mma8452_platform_data mma8452_info = {
 #endif
 
 #ifdef CONFIG_FB_ROCKCHIP
-/* rk30 fb resource */
- static struct resource resource_fb[] = {
+static struct resource resource_fb[] = {
        [0] = {
                .name  = "fb0 buf",
                .start = 0,
@@ -303,8 +302,7 @@ static struct mma8452_platform_data mma8452_info = {
        },
 };
 
-/*platform_device*/
-struct platform_device device_fb = {
+static struct platform_device device_fb = {
        .name             = "rk-fb",
        .id               = -1,
        .num_resources    = ARRAY_SIZE(resource_fb),
@@ -312,7 +310,6 @@ struct platform_device device_fb = {
 };
 #endif
 
-extern struct platform_device rk30_device_lcdc;
 static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_BACKLIGHT_RK29_BL
        &rk29_device_backlight,
@@ -320,10 +317,6 @@ static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_FB_ROCKCHIP
        &device_fb,
 #endif
-#ifdef CONFIG_LCDC_RK30
-       &rk30_device_lcdc,
-#endif
-
 };
 
 // i2c
@@ -391,8 +384,10 @@ static void __init machine_rk30_board_init(void)
 
 static void __init rk30_reserve(void)
 {
+#ifdef CONFIG_FB_ROCKCHIP
        resource_fb[0].start = board_mem_reserve_add("fb0",RK30_FB0_MEM_SIZE);
-       resource_fb[0].end      = resource_fb[0].start + RK30_FB0_MEM_SIZE - 1;
+       resource_fb[0].end = resource_fb[0].start + RK30_FB0_MEM_SIZE - 1;
+#endif
        board_mem_reserved();
 }
 
index 538020fda41a93576cd25b12a1e287dd344bd28c..460463fcf694e808b8b3af4208e9f687aca03418 100755 (executable)
@@ -495,40 +495,12 @@ static void __init rk30_init_i2c(void)
 }
 //end of i2c
 
+#if defined(CONFIG_SPIM0_RK29) || defined(CONFIG_SPIM1_RK29)
 /*****************************************************************************************
  * spi devices
  * author: cmc@rock-chips.com
  *****************************************************************************************/
 #define SPI_CHIPSELECT_NUM 2
-static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
-       {
-               .name = "spi0 cs0",
-               .cs_gpio = RK30_PIN1_PA4,
-               .cs_iomux_name = GPIO1A4_UART1SIN_SPI0CSN0_NAME,
-               .cs_iomux_mode = GPIO1A_SPI0_CSN0,
-       },
-       {
-               .name = "spi0 cs1",
-               .cs_gpio = RK30_PIN4_PB7,
-               .cs_iomux_name = GPIO4B7_SPI0CSN1_NAME,//if no iomux,set it NULL
-               .cs_iomux_mode = GPIO4B_SPI0_CSN1,
-       }
-};
-
-static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
-       {
-               .name = "spi1 cs0",
-               .cs_gpio = RK30_PIN2_PC4,
-               .cs_iomux_name = GPIO2C4_LCDC1DATA20_SPI1CSN0_HSADCDATA1_NAME,
-               .cs_iomux_mode = GPIO2C_SPI1_CSN0,
-       },
-       {
-               .name = "spi1 cs1",
-               .cs_gpio = RK30_PIN2_PC7,
-               .cs_iomux_name = GPIO2C7_LCDC1DATA23_SPI1CSN1_HSADCDATA4_NAME,//if no iomux,set it NULL
-               .cs_iomux_mode = GPIO2C_SPI1_CSN1,
-       }
-};
 
 static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
 {
@@ -561,31 +533,36 @@ static int spi_io_resume_leakage_bug(void)
 #endif
        return 0;
 }
+#endif
 
-struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
-       .num_chipselect = SPI_CHIPSELECT_NUM,
-       .chipselect_gpios = rk29xx_spi0_cs_gpios,
-       .io_init = spi_io_init,
-       .io_deinit = spi_io_deinit,
-       .io_fix_leakage_bug = spi_io_fix_leakage_bug,
-       .io_resume_leakage_bug = spi_io_resume_leakage_bug,
+/*
+ * rk29xx spi master device
+ */
+#ifdef CONFIG_SPIM0_RK29
+static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
+       {
+               .name = "spi0 cs0",
+               .cs_gpio = RK30_PIN1_PA4,
+               .cs_iomux_name = GPIO1A4_UART1SIN_SPI0CSN0_NAME,
+               .cs_iomux_mode = GPIO1A_SPI0_CSN0,
+       },
+       {
+               .name = "spi0 cs1",
+               .cs_gpio = RK30_PIN4_PB7,
+               .cs_iomux_name = GPIO4B7_SPI0CSN1_NAME,//if no iomux,set it NULL
+               .cs_iomux_mode = GPIO4B_SPI0_CSN1,
+       }
 };
 
-struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
+static struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
        .num_chipselect = SPI_CHIPSELECT_NUM,
-       .chipselect_gpios = rk29xx_spi1_cs_gpios,
+       .chipselect_gpios = rk29xx_spi0_cs_gpios,
        .io_init = spi_io_init,
        .io_deinit = spi_io_deinit,
        .io_fix_leakage_bug = spi_io_fix_leakage_bug,
        .io_resume_leakage_bug = spi_io_resume_leakage_bug,
 };
 
-
-
-/*
- * rk29xx spi master device
- */
-#ifdef CONFIG_SPIM0_RK29
 static struct resource rk29_spi0_resources[] = {
        {
                .start  = IRQ_SPI0,
@@ -623,6 +600,30 @@ struct platform_device rk29xx_device_spi0m = {
 #endif
 
 #ifdef CONFIG_SPIM1_RK29
+static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
+       {
+               .name = "spi1 cs0",
+               .cs_gpio = RK30_PIN2_PC4,
+               .cs_iomux_name = GPIO2C4_LCDC1DATA20_SPI1CSN0_HSADCDATA1_NAME,
+               .cs_iomux_mode = GPIO2C_SPI1_CSN0,
+       },
+       {
+               .name = "spi1 cs1",
+               .cs_gpio = RK30_PIN2_PC7,
+               .cs_iomux_name = GPIO2C7_LCDC1DATA23_SPI1CSN1_HSADCDATA4_NAME,//if no iomux,set it NULL
+               .cs_iomux_mode = GPIO2C_SPI1_CSN1,
+       }
+};
+
+static struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
+       .num_chipselect = SPI_CHIPSELECT_NUM,
+       .chipselect_gpios = rk29xx_spi1_cs_gpios,
+       .io_init = spi_io_init,
+       .io_deinit = spi_io_deinit,
+       .io_fix_leakage_bug = spi_io_fix_leakage_bug,
+       .io_resume_leakage_bug = spi_io_resume_leakage_bug,
+};
+
 static struct resource rk29_spi1_resources[] = {
        {
                .start  = IRQ_SPI1,
@@ -669,7 +670,6 @@ static void __init rk30_init_spim(void)
 #endif
 }
 
-
 #ifdef CONFIG_MTD_NAND_RK29XX
 static struct resource resources_nand[] = {
        {
@@ -687,6 +687,7 @@ static struct platform_device device_nand = {
 };
 #endif
 
+#ifdef CONFIG_LCDC_RK30
 static struct resource resource_lcdc[] = {
        [0] = {
                .name  = "lcdc0 reg",
@@ -714,14 +715,13 @@ static struct resource resource_lcdc[] = {
        },
 };
 
-/*platform_device*/
-struct platform_device rk30_device_lcdc = {
+static struct platform_device device_lcdc = {
        .name             = "rk30-lcdc",
        .id               = 4,
        .num_resources    = ARRAY_SIZE(resource_lcdc),
        .resource         = resource_lcdc,
 };
-
+#endif
 
 #ifdef CONFIG_KEYS_RK29
 extern struct rk29_keys_platform_data rk29_keys_pdata;
@@ -745,6 +745,9 @@ static int __init rk30_init_devices(void)
 #endif
 #ifdef CONFIG_KEYS_RK29
        platform_device_register(&device_keys);
+#endif
+#ifdef CONFIG_LCDC_RK30
+       platform_device_register(&device_lcdc);
 #endif
         return 0;
 }
index 7a3b62e8cc169932d1c07f14a4b279813d579855..932c6fdcd5ee1a46b5d25b696e9ff81eece9bd41 100644 (file)
@@ -62,7 +62,7 @@ struct rk29_fb_info {
        u32 fb_id;
        u32 mcu_fmk_pin;
        struct rk29lcd_info *lcd_info;
-       int (*io_init)(struct rk_fb_setting_info *fb_setting);
+       int (*io_init)(struct rk29_fb_setting_info *fb_setting);
        int (*io_deinit)(void);
        int (*io_enable)(void);
        int (*io_disable)(void);