From abf500d9d01d5ed2b8dcb12565598ec379a22522 Mon Sep 17 00:00:00 2001 From: xjh Date: Tue, 17 Jun 2014 17:01:11 +0800 Subject: [PATCH] MIPI: 1. cmd length up to 1kB long; 2. sync to uboot MIPI --- drivers/video/rockchip/screen/lcd_mipi.c | 62 +++++++++++++----- .../rockchip/transmitter/rk32_mipi_dsi.c | 64 ++++++++++++++----- .../rockchip/transmitter/rk32_mipi_dsi.h | 10 ++- 3 files changed, 103 insertions(+), 33 deletions(-) diff --git a/drivers/video/rockchip/screen/lcd_mipi.c b/drivers/video/rockchip/screen/lcd_mipi.c index c0813a8d7d6a..67d9094aa88d 100755 --- a/drivers/video/rockchip/screen/lcd_mipi.c +++ b/drivers/video/rockchip/screen/lcd_mipi.c @@ -28,9 +28,7 @@ #include #include #include -#include -#include -#include +#include #include #include "../transmitter/mipi_dsi.h" #endif @@ -43,6 +41,7 @@ #define MIPI_SCREEN_DBG(x...) #endif #ifdef CONFIG_RK_3288_DSI_UBOOT +DECLARE_GLOBAL_DATA_PTR; #define msleep(a) udelay(a * 1000) #define printk(x...) //printf(x) #endif @@ -70,6 +69,7 @@ static void rk_mipi_screen_pwr_disable(struct mipi_screen *screen) static void rk_mipi_screen_pwr_enable(struct mipi_screen *screen) { + if(screen->lcd_en_gpio != INVALID_GPIO){ gpio_direction_output(screen->lcd_en_gpio, !screen->lcd_en_atv_val); msleep(screen->lcd_en_delay); @@ -91,10 +91,26 @@ static void rk_mipi_screen_pwr_enable(struct mipi_screen *screen) static void rk_mipi_screen_cmd_init(struct mipi_screen *screen) { - u8 len, i, cmds[25] = {0}; + u8 len, i; + u8 *cmds; struct list_head *screen_pos; struct mipi_dcs_cmd_ctr_list *dcs_cmd; - +#ifdef CONFIG_RK_3288_DSI_UBOOT + cmds = calloc(1,0x400); + if(!cmds) { + printf("request cmds fail!\n"); + return; + } +#endif + +#ifdef CONFIG_LCD_MIPI + cmds = kmalloc(0x400, GFP_KERNEL); + if(!cmds) { + printk("request cmds fail!\n"); + return ; + } +#endif + list_for_each(screen_pos, &screen->cmdlist_head){ dcs_cmd = list_entry(screen_pos, struct mipi_dcs_cmd_ctr_list, list); @@ -151,13 +167,20 @@ static void rk_mipi_screen_cmd_init(struct mipi_screen *screen) else MIPI_SCREEN_DBG("cmd type err.\n"); } + +#ifdef CONFIG_RK_3288_DSI_UBOOT + free(cmds); +#endif +#ifdef CONFIG_LCD_MIPI + kfree(cmds); +#endif + } int rk_mipi_screen(void) { u8 dcs[16] = {0}, rk_dsi_num; rk_dsi_num = gmipi_screen->mipi_dsi_num; - if(gmipi_screen->screen_init == 0){ dsi_enable_hs_clk(0,1); @@ -539,19 +562,21 @@ int rk_mipi_get_dsi_clk(void) EXPORT_SYMBOL(rk_mipi_get_dsi_clk); #endif #ifdef CONFIG_RK_3288_DSI_UBOOT +#ifdef CONFIG_OF_LIBFDT static int rk_mipi_screen_init_dt(struct mipi_screen *screen) { struct mipi_dcs_cmd_ctr_list *dcs_cmd; - u32 i,cmds[20],length; + u32 i,cmds[20]; + int length; int err; int node; - void *blob; + const void *blob; struct fdt_gpio_state gpio_val; int noffset; INIT_LIST_HEAD(&screen->cmdlist_head); - blob = getenv_hex("fdtaddr", 0); + blob = gd->fdt_blob;//getenv_hex("fdtaddr", 0); node = fdtdec_next_compatible(blob, 0, COMPAT_ROCKCHIP_MIPI_INIT); if(node < 0){ MIPI_SCREEN_DBG("Can not get node of COMPAT_ROCKCHIP_MIPI_INIT\n"); @@ -686,7 +711,7 @@ static int rk_mipi_screen_init_dt(struct mipi_screen *screen) MIPI_SCREEN_DBG("dcs_cmd.type=%02x\n",dcs_cmd->dcs_cmd.type); dcs_cmd->dcs_cmd.dsi_id = fdtdec_get_int(blob, noffset, "rockchip,dsi_id", -1); MIPI_SCREEN_DBG("dcs_cmd.dsi_id=%02x\n",dcs_cmd->dcs_cmd.dsi_id); - err = fdt_getprop(blob, noffset, "rockchip,cmd", &length); + fdt_getprop(blob, noffset, "rockchip,cmd", &length); dcs_cmd->dcs_cmd.cmd_len = length / sizeof(u32) ; err = fdtdec_get_int_array(blob, noffset, "rockchip,cmd", cmds, dcs_cmd->dcs_cmd.cmd_len); MIPI_SCREEN_DBG("length=%d,cmd_len = %d err = %d\n",length,dcs_cmd->dcs_cmd.cmd_len,err); @@ -703,6 +728,7 @@ static int rk_mipi_screen_init_dt(struct mipi_screen *screen) return 0; } +#endif /* CONFIG_OF_LIBFDT */ int rk_mipi_screen_probe(void) { @@ -712,18 +738,20 @@ int rk_mipi_screen_probe(void) printf("request struct screen fail!\n"); return -ENOMEM; } - ret = rk_mipi_screen_init_dt(gmipi_screen); - if(ret < 0){ - printf(" rk_mipi_screen_init_dt fail!\n"); - return -1; - } - +#ifdef CONFIG_OF_LIBFDT + ret = rk_mipi_screen_init_dt(gmipi_screen); + if(ret < 0){ + printf(" rk_mipi_screen_init_dt fail!\n"); + return -1; + } +#endif /* CONFIG_OF_LIBFDT */ + // MIPI_SCREEN_DBG("---rk_mipi_screen_probe--end\n"); return 0; } -#endif +#endif /* CONFIG_RK_3288_DSI_UBOOT */ #ifdef CONFIG_LCD_MIPI static int __init rk_mipi_screen_probe(struct platform_device *pdev) { diff --git a/drivers/video/rockchip/transmitter/rk32_mipi_dsi.c b/drivers/video/rockchip/transmitter/rk32_mipi_dsi.c index 8024a9eb15ef..1b654a4eb5c4 100755 --- a/drivers/video/rockchip/transmitter/rk32_mipi_dsi.c +++ b/drivers/video/rockchip/transmitter/rk32_mipi_dsi.c @@ -39,6 +39,7 @@ #include #include #include +#include #else #include #include @@ -90,7 +91,7 @@ * */ -#define RK_MIPI_DSI_VERSION_AND_TIME "rockchip mipi_dsi v1.0 2014-05-16" +#define RK_MIPI_DSI_VERSION_AND_TIME "rockchip mipi_dsi v1.1 2014-06-17" static struct dsi *dsi0; static struct dsi *dsi1; @@ -103,6 +104,9 @@ static int rk32_mipi_dsi_is_enable(void *arg, u32 enable); int rk_mipi_screen_standby(u8 enable); #ifdef CONFIG_RK_3288_DSI_UBOOT +DECLARE_GLOBAL_DATA_PTR; +extern int rk_mipi_screen_probe(void); +extern void writel_relaxed(uint32 val, uint32 addr); #define msleep(a) udelay(a * 1000) /* dsihost0: @@ -124,6 +128,7 @@ int rk32_mipi_dsi_clk_enable(struct dsi *dsi) else val = (1 << 21); writel(val, RK3288_CRU_PHYS + 0x1a0); /*pclk*/ + return 0; } int rk32_mipi_dsi_clk_disable(struct dsi *dsi) { @@ -135,7 +140,9 @@ int rk32_mipi_dsi_clk_disable(struct dsi *dsi) writel(val, RK3288_CRU_PHYS + 0x1a0); /*pclk*/ val = 0x80008000;//bit31~bit16 - writel(val, RK3288_CRU_PHYS + 0x174); /*24M*/} + writel(val, RK3288_CRU_PHYS + 0x174); /*24M*/ + return 0; +} #endif static int rk32_dsi_read_reg(struct dsi *dsi, u16 reg, u32 *pval) @@ -751,17 +758,28 @@ static int rk32_mipi_dsi_is_active(void *arg) static int rk32_mipi_dsi_send_packet(void *arg, unsigned char cmds[], u32 length) { struct dsi *dsi = arg; - unsigned char regs[25] = {0}; + unsigned char *regs; u32 type, liTmp = 0, i = 0, j = 0, data = 0; if(rk32_dsi_get_bits(dsi, gen_cmd_full) == 1) { MIPI_TRACE("gen_cmd_full\n"); return -1; } - - for(i = 0; i < length; i++){ - regs[i] = cmds[i]; +#ifdef CONFIG_MIPI_DSI_LINUX + regs = kmalloc(0x400, GFP_KERNEL); + if(!regs) { + printk("request regs fail!\n"); + return -ENOMEM; } +#endif +#ifdef CONFIG_RK_3288_DSI_UBOOT + regs = calloc(1, 0x400); + if(!regs) { + printf("request regs fail!\n"); + return -ENOMEM; + } +#endif + memcpy(regs,cmds,length); liTmp = length - 2; type = regs[1]; @@ -889,7 +907,12 @@ static int rk32_mipi_dsi_send_packet(void *arg, unsigned char cmds[], u32 length udelay(10); } udelay(10); - +#ifdef CONFIG_MIPI_DSI_LINUX + kfree(regs); +#endif +#ifdef CONFIG_RK_3288_DSI_UBOOT + free(regs); +#endif return 0; } @@ -1291,6 +1314,7 @@ int rk32_dsi_sync(void) dsi_is_enable(0, 1); if (rk_mipi_get_dsi_num() ==2) dsi_is_enable(1, 1); + return 0; } #endif @@ -1336,6 +1360,7 @@ static int rk32_dsi_enable(void) return 0; } +#ifdef CONFIG_MIPI_DSI_LINUX static int rk32_dsi_disable(void) { MIPI_DBG("rk32_dsi_disable-------\n"); @@ -1348,7 +1373,6 @@ static int rk32_dsi_disable(void) return 0; } -#ifdef CONFIG_MIPI_DSI_LINUX static struct rk_fb_trsm_ops trsm_dsi_ops = { .enable = rk32_dsi_enable, @@ -1386,27 +1410,36 @@ static void rk32_init_phy_mode(int lcdc_id) } } #ifdef CONFIG_RK_3288_DSI_UBOOT +#ifdef CONFIG_OF_LIBFDT int rk_dsi_host_parse_dt(const void *blob, struct dsi *dsi) { int node; - void *handle; - int length; node = fdtdec_next_compatible(blob, 0, COMPAT_ROCKCHIP_DSIHOST); + if(node<0) { + printf("mipi dts get node failed, node = %d.\n", node); + return -1; + } + do{ if(fdtdec_get_int(blob, node, "rockchip,prop", -1) != dsi->dsi_id){ node = fdtdec_next_compatible(blob, node, COMPAT_ROCKCHIP_DSIHOST); + if(node<0) { + printf("mipi dts get node failed, node = %d.\n", node); + return -1; + } }else{ break; } }while(1); //fdtdec_get_addr_size(blob,node,"reg",&length); - dsi->host.membase = fdtdec_get_int(blob, node, "reg", -1); + dsi->host.membase = (void __iomem *)fdtdec_get_int(blob, node, "reg", -1); //fdt_getprop(blob, node, "reg", &length); - MIPI_DBG("dsi->host.membase 0x%08x, length %d\n",dsi->host.membase,length); + MIPI_DBG("dsi->host.membase 0x%08lx.\n",(unsigned long)dsi->host.membase); return 0; } +#endif /* #ifdef CONFIG_OF_LIBFDT */ int rk32_mipi_enable(vidinfo_t *vid) { @@ -1427,8 +1460,9 @@ int rk32_mipi_enable(vidinfo_t *vid) } dsi->dsi_id = id; - rk_dsi_host_parse_dt(getenv_hex("fdtaddr", 0),dsi); - +#ifdef CONFIG_OF_LIBFDT + rk_dsi_host_parse_dt(gd->fdt_blob,dsi); +#endif /* #ifdef CONFIG_OF_LIBFDT */ screen = calloc(1, sizeof(struct rk_screen)); if(!screen) { MIPI_DBG("request struct rk_screen fail!\n"); @@ -1522,6 +1556,7 @@ int rk32_mipi_enable(vidinfo_t *vid) } #endif +#ifdef CONFIG_MIPI_DSI_LINUX int rk32_mipi_power_down_DDR(void) { dsi_is_enable(0, 0); @@ -1544,7 +1579,6 @@ int rk32_mipi_power_up_DDR(void) } EXPORT_SYMBOL(rk32_mipi_power_up_DDR); -#ifdef CONFIG_MIPI_DSI_LINUX static int rk32_mipi_dsi_probe(struct platform_device *pdev) { int ret = 0; diff --git a/drivers/video/rockchip/transmitter/rk32_mipi_dsi.h b/drivers/video/rockchip/transmitter/rk32_mipi_dsi.h index 9c9c789014b7..3ec578cf0a76 100755 --- a/drivers/video/rockchip/transmitter/rk32_mipi_dsi.h +++ b/drivers/video/rockchip/transmitter/rk32_mipi_dsi.h @@ -4,7 +4,15 @@ drivers/video/rockchip/transmitter/rk32_mipi_dsi.h #ifndef RK32_MIPI_DSI_H #define RK32_MIPI_DSI_H -#ifndef CONFIG_RK_3288_DSI_UBOOT + +#ifdef CONFIG_RK_3288_DSI_UBOOT +#include +#define RK_GRF_VIRT RKIO_GRF_PHYS +#define RK3288_CRU_PHYS RKIO_CRU_PHYS + +#define RK3288_GRF_SOC_CON6 GRF_SOC_CON6 +#define RK3288_GRF_SOC_CON14 GRF_SOC_CON14 +#else #include #endif #define MIPI_DSI_HOST_OFFSET 0x1000 -- 2.34.1