rk31: add i2s/codec/pwm/backlight support
authorhxy <hxy@rock-chips.com>
Thu, 26 Jul 2012 08:56:35 +0000 (16:56 +0800)
committerhxy <hxy@rock-chips.com>
Thu, 26 Jul 2012 08:57:06 +0000 (16:57 +0800)
arch/arm/mach-rk30/board-rk31-fpga.c
arch/arm/mach-rk30/include/mach/io.h
drivers/video/backlight/Kconfig
drivers/video/backlight/rk29_backlight.c
sound/soc/rk29/Kconfig
sound/soc/rk29/Makefile
sound/soc/rk29/rk29_rk1000codec.c

index 3b4a517678fcfcd47c31fef2221e67aabc37e423..abd4303591aa94de2ca0fa0452d7bd4694892887 100644 (file)
@@ -148,6 +148,18 @@ static struct platform_device device_fb = {
 //i2c
 #ifdef CONFIG_I2C0_RK30
 static struct i2c_board_info __initdata i2c0_info[] = {
+#if defined (CONFIG_SND_SOC_RK1000)
+        {
+                .type          = "rk1000_i2c_codec",
+                .addr          = 0x60,
+                .flags         = 0,
+        },
+        {
+                .type          = "rk1000_control",
+                .addr          = 0x40,
+                .flags         = 0,
+        },
+#endif
 };
 #endif
 #ifdef CONFIG_I2C1_RK30
@@ -191,10 +203,73 @@ static void __init rk30_i2c_register_board_info(void)
 static struct spi_board_info board_spi_devices[] = {
 };
 
+/***********************************************************
+*      rk30  backlight
+************************************************************/
+#ifdef CONFIG_BACKLIGHT_RK29_BL
+#define PWM_ID            1
+#define PWM_MUX_NAME      GPIO0A3_PWM0_NAME
+#define PWM_MUX_MODE      GPIO0A_PWM0
+#define PWM_MUX_MODE_GPIO GPIO0A_GPIO0A3
+#define PWM_GPIO         RK30_PIN0_PA3
+#define PWM_EFFECT_VALUE  1
+
+#define LCD_DISP_ON_PIN
+
+#ifdef  LCD_DISP_ON_PIN
+
+#define BL_EN_PIN         RK30_PIN6_PB3
+#define BL_EN_VALUE       GPIO_HIGH
+#endif
+static int rk29_backlight_io_init(void)
+{
+       int ret = 0;
+       return ret;
+}
+
+static int rk29_backlight_io_deinit(void)
+{
+       int ret = 0;
+       return ret;
+}
+
+static int rk29_backlight_pwm_suspend(void)
+{
+       int ret = 0;
+       return ret;
+}
+
+static int rk29_backlight_pwm_resume(void)
+{
+       return 0;
+}
+
+static struct rk29_bl_info rk29_bl_info = {
+       .pwm_id = PWM_ID,
+       .bl_ref = PWM_EFFECT_VALUE,
+       .io_init = rk29_backlight_io_init,
+       .io_deinit = rk29_backlight_io_deinit,
+       .pwm_suspend = rk29_backlight_pwm_suspend,
+       .pwm_resume = rk29_backlight_pwm_resume,
+};
+
+static struct platform_device rk29_device_backlight = {
+       .name   = "rk29_backlight",
+       .id     = -1,
+       .dev    = {
+               .platform_data  = &rk29_bl_info,
+       }
+};
+
+#endif
+
 static struct platform_device *devices[] __initdata = {
 #if defined(CONFIG_FB_ROCKCHIP)
        &device_fb,
 #endif
+#ifdef CONFIG_BACKLIGHT_RK29_BL
+       &rk29_device_backlight,
+#endif
 };
 /**************************************************************************************************
  * SDMMC devices,  include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
@@ -384,6 +459,11 @@ static struct clk xin24m = {
        .rate           = 24000000,
 };
 
+static struct clk xin12m = {
+       .name           = "xin12m",
+       .rate           = 12000000,
+};
+
 #define CLK(dev, con, ck) \
        { \
                .dev_id = dev, \
@@ -413,10 +493,26 @@ static struct clk_lookup clks[] = {
        CLK("rk_serial.2", "uart", &xin24m),
        CLK("rk_serial.2", "pclk_uart", &xin24m),
 
-        CLK("rk29_i2s.0", "i2s_div", &xin24m),
-       CLK("rk29_i2s.0", "i2s_frac_div", &xin24m),
-       CLK("rk29_i2s.0", "i2s", &xin24m),
-       CLK("rk29_i2s.0", "hclk_i2s", &xin24m),
+  CLK("rk29_i2s.1", "i2s_div", &xin24m),
+       CLK("rk29_i2s.1", "i2s_frac_div", &xin24m),
+       CLK("rk29_i2s.1", "i2s", &xin12m),
+       CLK("rk29_i2s.1", "hclk_i2s", &xin24m),
+       
+       CLK("rk29_sdmmc.0","mmc",&xin24m),
+       CLK("rk29_sdmmc.0","hclk_mmc",&xin24m),
+       CLK("rk29_sdmmc.1","mmc",&xin24m),
+       CLK("rk29_sdmmc.1","hclk_mmc",&xin24m),
+       
+       CLK(NULL,"pd_lcdc0",&xin24m),
+       CLK(NULL,"hclk_lcdc0",&xin24m),
+       CLK(NULL,"aclk_lcdc0",&xin24m),
+       CLK(NULL,"dclk_lcdc0",&xin24m),
+       CLK(NULL,"pd_lcdc1",&xin24m),
+       CLK(NULL,"hclk_lcdc1",&xin24m),
+       CLK(NULL,"aclk_lcdc1",&xin24m),
+       CLK(NULL,"dclk_lcdc1",&xin24m),
+       
+       CLK(NULL,"pwm01",&xin24m),
 };
 
 static void __init rk30_clock_init(void)
@@ -451,7 +547,10 @@ EXPORT_SYMBOL(clk_disable);
 
 unsigned long clk_get_rate(struct clk *clk)
 {
-       return 24000000;
+  if(clk)
+               return clk->rate;       
+       else
+               return 24000000;
 }
 EXPORT_SYMBOL(clk_get_rate);
 
index e4a9c7210e2193d744cfc978676f1e16b4951988..99cbdf4b13ad7d2f0639aef3c756bd7bf26fa00c 100755 (executable)
@@ -52,7 +52,7 @@
 #define RK30_IPP_SIZE           SZ_16K
 #define RK30_RGA_PHYS           0x10114000
 #define RK30_RGA_SIZE           SZ_8K
-#ifdef CONFIG_ARCH_RK30
+#if defined(CONFIG_ARCH_RK30) || defined(CONFIG_ARCH_RK31)
 #define RK30_HDMI_PHYS          0x10116000
 #define RK30_HDMI_SIZE          SZ_8K
 #define RK30_I2S0_8CH_PHYS      0x10118000
index 81056931d8c6c6b1abc1745b84ec6dcbd1b2657d..4e7324b875885a5f81e832c65306b92e11175b4e 100755 (executable)
@@ -299,7 +299,7 @@ config BACKLIGHT_RK2818_BL
          
 config BACKLIGHT_RK29_BL
         bool "rk backlight driver"
-       depends on BACKLIGHT_CLASS_DEVICE && (ARCH_RK29 || ARCH_RK30)
+       depends on BACKLIGHT_CLASS_DEVICE && (ARCH_RK29 || ARCH_RK30 || ARCH_RK31)
        default y
        help
          rk29 backlight support.         
index a60a0245797c41d9a7052cca4ca6ce85052c1631..f8c251de5e8bbe6977015ecc91a1f116fa98fb5e 100755 (executable)
@@ -38,7 +38,7 @@
 #define DBG(x...)
 #endif
 
-#if defined(CONFIG_ARCH_RK30)
+#if defined(CONFIG_ARCH_RK30) || defined(CONFIG_ARCH_RK31) 
 #define write_pwm_reg(id, addr, val)        __raw_writel(val, addr+(RK30_PWM01_BASE+(id>>1)*0x20000)+id*0x10)
 #define read_pwm_reg(id, addr)              __raw_readl(addr+(RK30_PWM01_BASE+(id>>1)*0x20000+id*0x10))
 #elif defined(CONFIG_ARCH_RK29)
@@ -170,6 +170,7 @@ static int rk29_backlight_probe(struct platform_device *pdev)
        unsigned long pwm_clk_rate;
        struct backlight_properties props;
 
+
        if (rk29_bl) {
                printk(KERN_CRIT "%s: backlight device register has existed \n",
                                __func__);
@@ -186,6 +187,7 @@ static int rk29_backlight_probe(struct platform_device *pdev)
                rk29_bl_info->io_init();
        }
 
+
        memset(&props, 0, sizeof(struct backlight_properties));
        props.type = BACKLIGHT_RAW;
        props.max_brightness = BL_STEP;
@@ -196,9 +198,10 @@ static int rk29_backlight_probe(struct platform_device *pdev)
                return -ENODEV;         
        }
 
+
 #if defined(CONFIG_ARCH_RK29)
        pwm_clk = clk_get(NULL, "pwm");
-#elif defined(CONFIG_ARCH_RK30)
+#elif defined(CONFIG_ARCH_RK30) || defined(CONFIG_ARCH_RK31)
        if (id == 0 || id == 1)
                pwm_clk = clk_get(NULL, "pwm01");
        else if (id == 2 || id == 3)
index c95b1d03768f08d7a008475b672af7988330e0a9..1596ca660a73691b6515b22ba42170589c4697ec 100755 (executable)
@@ -1,5 +1,5 @@
 config SND_RK29_SOC
-       tristate "SoC Audio for the rockchip RK29/RK30 System-on-Chip"
+       tristate "SoC Audio for the rockchip RK29/RK30/RK31 System-on-Chip"
        depends on PLAT_RK && SND_SOC
        help
          Say Y or M if you want to add support for codecs attached to
@@ -12,7 +12,7 @@ config SND_RK29_SOC_I2S
 config SND_RK29_SOC_I2S_8CH
         bool "Soc RK29 I2S 8 Channel support(I2S0)"
         default y
-       depends on SND_RK29_SOC_I2S
+       depends on SND_RK29_SOC_I2S && !ARCH_RK31
        help
                 This supports the use of the 8 Channel I2S interface on rk29 processors.
 
index 1f962229128277de5d7fcc1e024b85074eda1b13..cce9283a31d70fa132cf31f07e8cff0468de9f3b 100755 (executable)
@@ -9,6 +9,9 @@ endif
 ifdef CONFIG_ARCH_RK2928
 snd-soc-rockchip-i2s-objs := rk30_i2s.o
 endif
+ifdef CONFIG_ARCH_RK31
+snd-soc-rockchip-i2s-objs := rk30_i2s.o
+endif
 snd-soc-rockchip-spdif-objs := rk29_spdif.o
 
 obj-$(CONFIG_SND_RK29_SOC) += snd-soc-rockchip.o
index b5457b9868030e880990bbd516eca01bcbccd118..a65bfba54617af1c235dd331401e68ef644ad9e6 100755 (executable)
@@ -85,7 +85,11 @@ static struct snd_soc_dai_link rk29_dai[] = {
          .platform_name = "rockchip-audio",
          .codec_name = "RK1000_CODEC.0-0060",
          .codec_dai_name = "rk1000_codec",
-         .cpu_dai_name = "rk29_i2s.1",
+#if defined(CONFIG_SND_RK29_SOC_I2S_8CH)        
+          .cpu_dai_name = "rk29_i2s.0",
+#elif defined(CONFIG_SND_RK29_SOC_I2S_2CH)
+          .cpu_dai_name = "rk29_i2s.1",
+#endif
          .init = rk29_rk1000_codec_init,
          .ops = &rk29_ops,
        }