君正T40添加lcd驱动

最近需要调试一个lcd驱动,在原先的驱动上面适配好了,为了分离出来好给后续单个适配,从新添加多一个驱动

君正T40添加一个lcd驱动
步骤:
1.添加驱动源文件
os/kernel/drivers/video/fbdev/ingenic/fb_v12/displays/panel-st7102-xiaomi.c

/*
 * Copyright (c) 2012 Ingenic Semiconductor Co., Ltd.
 *              http://www.ingenic.com/
 *
 *  dorado board lcd setup routines.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#include <linux/init.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/mm.h>
#include <linux/console.h>
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/pwm_backlight.h>
#include <linux/lcd.h>
#include <linux/of_gpio.h>
#include <soc/gpio.h>
#include <linux/fb.h>
#include <linux/backlight.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/cdev.h>
#include <linux/device.h>
#include <linux/ide.h>
#include <linux/irq.h>
#include <linux/errno.h>
#include <linux/ioctl.h>

#include "../ingenicfb.h"
#include "../jz_dsim.h"
#include "../jz_mipi_dsi/jz_mipi_dsih_hal.h"

#define ST7102_SUPPORT_LANE_2_FPS_60 0
#define ST7102_SUPPORT_LANE_2_FPS_30 1
#if defined(CONFIG_FB_ESD_CHECK_MODE)
#define ST7102_TE_IRQ_USE	1
#else
#define ST7102_TE_IRQ_USE	0
#endif
#define JZ_LCD_FPS_MAX  ST7102_SUPPORT_LANE_2_FPS_60

static struct dsi_cmd_packet st7102_xiaomi_cmd_list[] = {
   
   

#if 0
{
   
   0x39, 0x06, 0x00, {
   
   0xFF,0x77,0x01,0x00,0x00,0x13}},
{
   
   0x39, 0x02, 0x00, {
   
   0xEF,0x08}},
{
   
   0x39, 0x06, 0x00, {
   
   0xFF,0x77,0x01,0x00,0x00,0x10}},
{
   
   0x39, 0x03, 0x00, {
   
   0xC0,0x63,0x00}},
{
   
   0x39, 0x03, 0x00, {
   
   0xC1,0x09,0x02}},
{
   
   0x39, 0x03, 0x00, {
   
   0xC2,0x20,0x02}},
{
   
   0x39, 0x02, 0x00, {
   
   0xCC,0x18}},
{
   
   0x39, 0x11, 0x00, {
   
   0xB0,0x40,0x0E,0x51,0x0F,0x11,0x07,0x00,0x09,0x06,0x1E,0x04,0x12,0x11,0x64,0x29,0xDF}},
{
   
   0x39, 0x11, 0x00, {
   
   0xB1,0x40,0x07,0x4C,0x0A,0x0E,0x04,0x00,0x08,0x09,0x1D,0x01,0x0E,0x0C,0x6A,0x34,0xDF}},
{
   
   0x39, 0x06, 0x00, {
   
   0xFF,0x77,0x01,0x00,0x00,0x11}},
{
   
   0x39, 0x02, 0x00, {
   
   0xB0,0x30}},
{
   
   0x39, 0x02, 0x00, {
   
   0xB1,0x48}},
{
   
   0x39, 0x02, 0x00, {
   
   0xB2,0x80}},
{
   
   0x39, 0x02, 0x00, {
   
   0xB3,0x80}},
{
   
   0x39, 0x02, 0x00, {
   
   0xB5,0x4F}},
{
   
   0x39, 0x02, 0x00, {
   
   0xB7,0x85}},
{
   
   0x39, 0x02, 0x00, {
   
   0xB8,0x23}},
{
   
   0x39, 0x03, 0x00, {
   
   0xB9,0x22,0x13}},
{
   
   0x39, 0x02, 0x00, {
   
   0xBB,0x03}},
{
   
   0x39, 0x02, 0x00, {
   
   0xBC,0x10}},
{
   
   0x39, 0x02, 0x00, {
   
   0xC0,0x89}},
{
   
   0x39, 0x02, 0x00, {
   
   0xC1,0x78}},
{
   
   0x39, 0x02, 0x00, {
   
   0xC2,0x78}},
{
   
   0x39, 0x02, 0x00, {
   
   0xD0,0x88}},
{
   
   0x39, 0x04, 0x00, {
   
   0xE0,0x00,0x00,0x02}},
{
   
   0x39, 0x0C, 0x00, {
   
   0xE1,0x04,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x10,0x10}},
{
   
   0x39, 0x0E, 0x00, {
   
   0xE2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
{
   
   0x39, 0x05, 0x00, {
   
   0xE3,0x00,0x00,0x33,0x00}},
{
   
   0x39, 0x03, 0x00, {
   
   0xE4,0x22,0x00}},
{
   
   0x39, 0x11, 0x00, {
   
   0xE5,0x03,0x34,0xAF,0xB3,0x05,0x34,0xAF,0xB3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
{
   
   0x39, 0x05, 0x00, {
   
   0xE6,0x00,0x00,0x33,0x00}},
{
   
   0x39, 0x03, 0x00, {
   
   0xE7,0x22,0x00}},
{
   
   0x39, 0x11, 0x00, {
   
   0xE8,0x04,0x34,0xAF,0xB3,0x06,0x34,0xAF,0xB3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
{
   
   0x39, 0x08, 0x00, {
   
   0xEB,0x02,0x00,0x40,0x40,0x00,0x00,0x00}},
{
   
   0x39, 0x03, 0x00, {
   
   0xEC,0x00,0x00}},
{
   
   0x39, 0x11, 0x00, {
   
   0xED,0xFA,0x45,0x0B,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xB0,0x54,0xAF}},
{
   
   0x39, 0x07, 0x00, {
   
   0xEF,0x08,0x08,0x08,0x45,0x3F,0x54}},
{
   
   0x39, 0x06, 0x00, {
   
   0xFF,0x77,0x01,0x00,0x00,0x13}},
{
   
   0x39, 0x03, 0x00, {
   
   0xE6,0x16,0x7c}},
{
   
   0x39, 0x03, 0x00, {
   
   0xe8,0x00,0x0E}},
{
   
   0x39, 0x06, 0x00, {
   
   0xFF,0x77,0x01,0x00,0x00,0x00}},
{
   
   0x15, 0x11, 0x00, {
   
    0x00 }}, 	//Sleep out
{
   
   0x99, 120, 0x00, {
   
   0x00}},
{
   
   0x39, 0x06, 0x00, {
   
   0xFF,0x77,0x01,0x00,0x00,0x13}},
{
   
   0x39, 0x03, 0x00, {
   
   0xe8,0x00,0x0C}},
{
   
   0x99, 10, 0x00, {
   
   0x00}},
{
   
   0x39, 0x03, 0x00, {
   
   0xe8,0x00,0x00}},
{
   
   0x39, 0x06, 0x00, {
   
   0xFF,0x77,0x01,0x00,0x00,0x00}},
{
   
   0x39, 0x02, 0x00, {
   
   0x35,0x00}},
{
   
   0x39, 0x06, 0x00, {
   
   0xFF,0x77,0x01,0x00,0x00,0x00}},
{
   
   0x15, 0x29, 0x00, {
   
    0x00}},  	// Display On
{
   
   0x99, 20, 0x00, {
   
   0x00}},		//delay 50ms
{
   
   0x39, 0x06, 0x00, {
   
   0xFF,0x77,0x01,0x00,0x00,0x10}},
{
   
   0x39, 0x02, 0x00, {
   
   0xE5,0x00}},
#else


//{0x99, 50, 0x00, {0x00}},  //sleep 5ms

{
   
   0x05, 0x10, 0x00 },
{
   
   0x05, 0x28, 0x00 },

{
   
   0x29, 0x04, 0x00, {
   
    0x99, 0x71, 0x02, 0xa2, } },
{
   
   0x29, 0x04, 0x00, {
   
    0x99, 0x71, 0x02, 0xa3, } },
{
   
   0x29, 0x04, 0x00, {
   
    0x99, 0x71, 0x02, 0xa4, } },

{
   
   0x39, 0x02, 0x00, {
   
    0x78, 0x21, } },
{
   
   0x39, 0x02, 0x00, {
   
    0x79, 0xCF, } },
//2lane
//{0x39, 0x02, 0x00, { 0xA4, 0x31, } },

{
   
   0x39, 0x08, 0x00, {
   
    0xB0, 0x22, 0x57, 0x1E, 0x61, 0x2F, 0x57, 0x61, } },

{
   
   0x39, 0x03, 0x00, {
   
    0xB7, 0x64, 0x64, } },

{
   
   0x39, 0x03, 0x00, {
   
    0xBF, 0x6e, 0x6e, } },
{
   
   0x29, 0x26, 0x00, {
   
    0xC8, 0x00, 0x00, 0x13, 0x23, 0x3E, 0x00, 0x6A, 0x03, 0xB0, 0x06, 0x11, 0x0F, 0x07, 0x85, 0x03, 0x21, 0xD5, 0x01, 0x18, 0x00, 0x22, 0x56, 0x0F, 0x98, 0x0A, 0x32, 0xF8, 0x0D, 0x48, 0x0F, 0xF3, 0x80, 0x0F, 0xAC, 0xC1, 0x03, 0xC4, } },

{
   
   0x29, 0x26, 0x00, {
   
    0xC9, 0x00, 0x00, 0x13, 0x23, 0x3E, 0x00, 0x6A, 0x03, 0xB0, 0x06, 0x11, 0x0F, 0x07, 0x85, 0x03, 0x21, 0xD5, 0x01, 0x18, 0x00, 0x22, 0x56, 0x0F, 0x98, 0x0A, 0x32, 0xF8, 0x0D, 0x48, 0x0F, 0xF3, 0x80, 0x0F, 0xAC, 0xC1, 0x03, 0xC4, } },

{
   
   0x39, 0x07, 0x00, {
   
    0xD7, 0x10, 0x0C, 0x77, 0x19, 0xE0, 0xE0, } },
{
   
   0x39, 0x21, 0x00, {
   
    0xA3, 0x40, 0x03, 0x80, 0xCF, 0x44, 0x00, 0x00, 0x00, 0x00, 0x04, 0x6F, 0x6F, 0x00, 0x1A, 0x00, 0x45, 0x05, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x02, 0x20, 0x52, 0x00, 0x05, 0x00, 0x00, 0xFF, } },
{
   
   0x39, 0x2D, 0x00, {
   
    0xA6, 0x02, 0x00, 0x24, 0x55, 0x35, 0x00, 0x38, 0x00, 0x5E, 0x5E, 0x00, 0x24, 0x55,0x36, 0x00, 0x37, 0x00, 0x5E, 0x5E, 0x02, 0xAC, 0x51, 0x3A, 0x00, 0x00, 0x00, 0x5E, 0x5E, 0x00, 0xAC, 0x11, 0x00, 0x00, 0x00, 0x00, 0x5E, 0x5E, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, } },

{
   
   0x39, 0x31, 0x00, {
   
    0xA7, 0x19, 0x19, 0x00, 0x64, 0x40, 0x07, 0x16, 0x40, 0x00, 0x04, 0x03, 0x5E, 0x5E, 0x00, 0x64, 0x40, 0x25, 0x34, 0x00, 0x00, 0x02, 0x01, 0x5E, 0x5E, 0x00, 0x64, 0x40, 0x4B, 0x5A, 0x00, 0x00, 0x02, 0x01, 0x5E, 0x5E, 0x00, 0x24, 0x40, 0x69, 0x78, 0x00, 0x00, 0x00, 0x00, 0x5E, 0x5E, 0x00, 0x44, } },

{
   
   0x39, 0x26, 0x00, {
   
    0xAC, 0x08, 0x0A, 0x11, 0x00, 0x13, 0x03, 0x1B,0x18, 0x06, 0x1A, 0x19, 0x1B, 0x1B,0x1B, 0x18, 0x1B, 0x09,0x0B, 0x10, 0x02, 0x12, 0x01, 0x1B, 0x18, 0x06, 0x1A, 0x19, 0x1B, 0x1B, 0x1B, 0x18, 0x1B, 0xFF, 0x67, 0xFF, 0x67, 0x00, } },
{
   
   0x39, 0x08, 0x00, {
   
    0xAD, 0xCC, 0x40, 0x46, 0x11, 0x04, 0x6F, 0x6F, } },
{
   
   0x39, 0x0F, 0x00, {
   
    0xE8, 0x30, 0x07, 0x00, 0x7A, 0x7A, 0x9C, 0x00, 0xE2, 0x04, 0x00, 0x00, 0x00, 0x00, 0xEF, } },
{
   
   0x29, 0x03, 0x00, {
   
    0x75, 0x03, 0x04, } },
{
   
   0x39, 0x22, 0x00, {
   
    0xE7, 0x8B, 0x3C, 0x00, 0x0C, 0xF0, 0x5D, 0x00, 0x5D, 0x00, 0x5D, 0x00, 0x5D, 0x00, 0xFF, 0x00, 0x08, 0x7B, 0x00, 0x00, 0xC8, 0x6A, 0x5A, 0x08, 0x1A, 0x3C, 0x00, 0x91, 0x01, 0xCC, 0x01, 0x7F, 0xF0, 0x22, } },
{
   
   0x39, 0x0A, 0x00, {
   
    0xE9, 0x4C, 0x7F, 0x08, 0x07, 0x1A, 0x7A, 0x22, 0x1A, 0x33, } },

{
   
   0x05, 0x11, 0x00 }, 	//Sleep out
{
   
   0x99, 120, 0x00, {
   
   0x00}},		//delay 250ms

{
   
   0x05, 0x29, 0x00 },  	// Display On

{
   
   0x29, 0x02, 0x00, {
   
    0x35, 0x00, } },
//{0x39, 0x02, 0x00, { 0xB5, 0x85, } },
#endif
};

struct board_gpio {
   
   
	short gpio;
	short active_level;
};

struct panel_dev {
   
   
	/* ingenic frame buffer */
	struct device *dev;
	struct lcd_panel *panel;

	/* common lcd framework */
	struct lcd_device *lcd;
	struct backlight_device *backlight;
	int power;

	struct regulator *vcc;
	struct board_gpio vdd_en;
	struct board_gpio bl;
	struct board_gpio rst;
	struct board_gpio oled;
	struct board_gpio lcd_pwm;

	struct mipi_dsim_lcd_device *dsim_dev;
};

struct panel_dev *panel;

#define lcd_to_master(a)     (a->dsim_dev->master)
#define lcd_to_master_ops(a) ((lcd_to_master(a))->master_ops)

#define DEV_NAME "gpio_irq"
#define GPIO_LCD_TE GPIO_PC(24)
struct gpio_irq_st
{
   
   
    int gpio;
    unsigned int irq_num; //中断号
    unsigned char value;  //键值
};
// static int te_reset_flag = 0;
static int sg_suspend_flag = 1;
static int sg_init_ignore_cnt = 0;
static volatile unsigned long long lcd_te_irq_ts = 0;
static struct gpio_irq_st gpio_data = {
   
   GPIO_LCD_TE, 0, 0};

struct st7102_xiaomi {
   
   
	struct device *dev;
	unsigned int power;
	unsigned int id;

	struct lcd_device *ld;
	struct backlight_device *bd;

	struct mipi_dsim_lcd_device *dsim_dev;
};

struct fb_videomode jzfb_st7102_xiaomi_videomode[] = {
   
   
	//[0] 4lane 60fps
	{
   
   
		.name = "st7102_xiaomi",
		.refresh = 30,//现在不支持60fps
		.xres = 480,
		.yres = 960,
		.pixclock = KHZ2PICOS(56000),  //60

		.left_margin = 40,
		.right_margin = 80,
		.hsync_len = 2,//2

		.upper_margin = 10,
		.lower_margin = 215,//215
		.vsync_len = 2,

		.sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
		.vmode = FB_VMODE_NONINTERLACED,
		.flag = 0
	},

	{
   
   
		.name = "st7102_xiaomi",
		.refresh = 30,
		.xres = 480,
		.yres = 960,
		.pixclock = KHZ2PICOS(56000),  //60//56000
		.left_margin = 40,
		.right_margin = 80,
		.hsync_len = 2,//2

		.upper_margin = 10,
		.lower_margin = 215,
		.vsync_len = 2,

		.sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
		.vmode = FB_VMODE_NONINTERLACED,
		.flag = 0
	},

};

struct jzdsi_data jzdsi_pdata = {
   
   
	.modes = &jzfb_st7102_xiaomi_videomode[JZ_LCD_FPS_MAX],
#ifdef CONFIG_MIPI_2LANE
	.video_config.no_of_lanes = 2,
#endif
#ifdef CONFIG_MIPI_4LANE
	.video_config.no_of_lanes = 4,
#endif
	.video_config.virtual_channel = 0,
	.video_config.color_coding = COLOR_CODE_24BIT,
#if 0
	.video_config.video_mode = VIDEO_NON_BURST_WITH_SYNC_PULSES,
	// .video_config.video_mode = VIDEO_NON_BURST_WITH_SYNC_EVENTS,
#else
	.video_config.video_mode = VIDEO_BURST_WITH_SYNC_PULSES,
#endif
	.video_config.receive_ack_packets = 0,	/* enable receiving of ack packets */
	/*loosely: R0R1R2R3R4R5__G0G1G2G3G4G5G6__B0B1B2B3B4B5B6,
	 * not loosely: R0R1R2R3R4R5G0G1G2G3G4G5B0B1B2B3B4B5*/
	.video_config.is_18_loosely = 0,
	.video_config.data_en_polarity = 1,

	.dsi_config.max_lanes = 4,//4
	.dsi_config.max_hs_to_lp_cycles = 100,
	.dsi_config.max_lp_to_hs_cycles = 40,
	.dsi_config.max_bta_cycles = 4095,
	.dsi_config.color_mode_polarity = 1,
	.dsi_config.shut_down_polarity = 1,
	.dsi_config.max_bps = 460,//460
	//	.max_bps = 650,  // 650 Mbps
	.bpp_info = 24,

};

struct tft_config st7102_xiaomi_cfg = {
   
   
	.pix_clk_inv = 0,
	.de_dl = 0,
	.sync_dl = 0,
	.color_even = TFT_LCD_COLOR_EVEN_RGB,
	.color_odd = TFT_LCD_COLOR_ODD_RGB,
	.mode = TFT_LCD_MODE_PARALLEL_888,
};

struct lcd_panel lcd_panel = {
   
   
	.num_modes = 1,
	.modes = &jzfb_st7102_xiaomi_videomode[JZ_LCD_FPS_MAX],
	.dsi_pdata = &jzdsi_pdata,
	//.smart_config = &smart_cfg,
	.tft_config = &st7102_xiaomi_cfg,

	.lcd_type = LCD_TYPE_TFT ,
	.width = 480,
	.height = 960,
	//.bpp = 24,

	//.pixclk_falling_edge = 0,
	//.data_enable_active_low = 0,

};

/**************************************************************************************************/
#ifdef CONFIG_BACKLIGHT_PWM

static struct platform_pwm_backlight_data backlight_data = {
   
   
	.pwm_id		= 0,
	.max_brightness	= 255,
	.dft_brightness	= 100,
	.pwm_period_ns	= 30000,
};

struct platform_device backlight_device = {
   
   
	.name		= "pwm-backlight",
	.dev		= {
   
   
		.platform_data	= &backlight_data,
	},
};

#endif

#define POWER_IS_ON(pwr)    ((pwr) <= FB_BLANK_NORMAL)
static int panel_set_power(struct lcd_device *lcd, int power)
{
   
   
	return 0;
}

static int panel_get_power(struct lcd_device *lcd)
{
   
   
	struct panel_dev *panel = lcd_get_data
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值