#include <fdtdec.h>
#include <errno.h>
#include <asm/io.h>
-#include <asm/arch/clock.h>
-#include <asm/arch/reg.h>
-#include <asm/arch/gpio.h>
+#include <asm/arch/rkplat.h>
#include <lcd.h>
#include "../transmitter/mipi_dsi.h"
#endif
#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
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);
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);
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);
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");
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);
return 0;
}
+#endif /* CONFIG_OF_LIBFDT */
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)
{
#include <fdtdec.h>
#include <linux/fb.h>
#include <linux/rk_screen.h>
+#include <malloc.h>
#else
#include <linux/kernel.h>
#include <linux/init.h>
*
*/
-#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;
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:
else
val = (1 << 21);
writel(val, RK3288_CRU_PHYS + 0x1a0); /*pclk*/
+ return 0;
}
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)
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];
udelay(10);
}
udelay(10);
-
+#ifdef CONFIG_MIPI_DSI_LINUX
+ kfree(regs);
+#endif
+#ifdef CONFIG_RK_3288_DSI_UBOOT
+ free(regs);
+#endif
return 0;
}
dsi_is_enable(0, 1);
if (rk_mipi_get_dsi_num() ==2)
dsi_is_enable(1, 1);
+ return 0;
}
#endif
return 0;
}
+#ifdef CONFIG_MIPI_DSI_LINUX
static int rk32_dsi_disable(void)
{
MIPI_DBG("rk32_dsi_disable-------\n");
return 0;
}
-#ifdef CONFIG_MIPI_DSI_LINUX
static struct rk_fb_trsm_ops trsm_dsi_ops =
{
.enable = rk32_dsi_enable,
}
}
#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)
{
}
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");
}
#endif
+#ifdef CONFIG_MIPI_DSI_LINUX
int rk32_mipi_power_down_DDR(void)
{
dsi_is_enable(0, 0);
}
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;