video: fbdev: mxc: add HX8363 mipi panel driver support

Add driver support for Truly HX8363 mipi panel.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
This commit is contained in:
Fancy Fang 2019-08-20 15:08:36 +08:00 committed by Dong Aisheng
parent d89f676e5e
commit 8508b3b54f
4 changed files with 391 additions and 0 deletions

View File

@ -46,3 +46,8 @@ config FB_MXC_ADV7535
depends on FB_MXC_MIPI_DSI_NORTHWEST
help
Driver support for the ADV7535 DSI-to-HDMI module
config FB_MXC_TRULY_PANEL_TFT3P5581E
tristate "TRULY Panel TFT3P5581E"
depends on FB_MXC_DISP_FRAMEWORK
depends on FB_MXC_MIPI_DSI_NORTHWEST

View File

@ -2,3 +2,4 @@ obj-$(CONFIG_FB_MXC_DISP_FRAMEWORK) += mxc_dispdrv.o
obj-$(CONFIG_FB_MXC_MIPI_DSI_NORTHWEST) += mipi_dsi_northwest.o
obj-$(CONFIG_FB_MXC_EDID) += mxc_edid.o
obj-$(CONFIG_FB_MXC_ADV7535) += adv7535.o
obj-$(CONFIG_FB_MXC_TRULY_PANEL_TFT3P5581E) += mxcfb_hx8363_wvga.o

View File

@ -0,0 +1,220 @@
/*
* Copyright (C) 2016 Freescale Semiconductor, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <linux/types.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/err.h>
#include <linux/clk.h>
#include <linux/console.h>
#include <linux/io.h>
#include <linux/bitops.h>
#include <linux/spinlock.h>
#include <linux/mipi_dsi.h>
#include <linux/mxcfb.h>
#include <linux/backlight.h>
#include <video/mipi_display.h>
#include "mipi_dsi.h"
#define HX8363_TWO_DATA_LANE (0x2)
#define HX8363_MAX_DPHY_CLK (800)
#define HX8363_CMD_GETHXID (0xF4)
#define HX8363_CMD_GETHXID_LEN (0x4)
#define HX8363_ID (0x84)
#define HX8363_ID_MASK (0xFF)
#define CHECK_RETCODE(ret) \
do { \
if (ret < 0) { \
dev_err(&mipi_dsi->pdev->dev, \
"%s ERR: ret:%d, line:%d.\n", \
__func__, ret, __LINE__); \
return ret; \
} \
} while (0)
static void parse_variadic(int n, u8 *buf, ...)
{
int i = 0;
va_list args;
if (unlikely(!n)) return;
va_start(args, buf);
for (i = 0; i < n; i++)
buf[i + 1] = (u8)va_arg(args, int);
va_end(args);
}
#define TC358763_DCS_write_1A_nP(n, addr, ...) { \
int err; \
\
buf[0] = addr; \
parse_variadic(n, buf, ##__VA_ARGS__); \
\
if (n >= 2) \
err = mipi_dsi->mipi_dsi_pkt_write(mipi_dsi, \
MIPI_DSI_DCS_LONG_WRITE, (u32*)buf, n + 1); \
else if (n == 1) \
err = mipi_dsi->mipi_dsi_pkt_write(mipi_dsi, \
MIPI_DSI_DCS_SHORT_WRITE_PARAM, (u32*)buf, 0); \
else if (n == 0) \
{ \
buf[1] = 0; \
err = mipi_dsi->mipi_dsi_pkt_write(mipi_dsi, \
MIPI_DSI_DCS_SHORT_WRITE, (u32*)buf, 0); \
} \
CHECK_RETCODE(err); \
}
#define TC358763_DCS_write_1A_0P(addr) \
TC358763_DCS_write_1A_nP(0, addr)
#define TC358763_DCS_write_1A_1P(addr, ...) \
TC358763_DCS_write_1A_nP(1, addr, __VA_ARGS__)
#define TC358763_DCS_write_1A_2P(addr, ...) \
TC358763_DCS_write_1A_nP(2, addr, __VA_ARGS__)
#define TC358763_DCS_write_1A_3P(addr, ...) \
TC358763_DCS_write_1A_nP(3, addr, __VA_ARGS__)
#define TC358763_DCS_write_1A_5P(addr, ...) \
TC358763_DCS_write_1A_nP(5, addr, __VA_ARGS__)
#define TC358763_DCS_write_1A_6P(addr, ...) \
TC358763_DCS_write_1A_nP(6, addr, __VA_ARGS__)
#define TC358763_DCS_write_1A_7P(addr, ...) \
TC358763_DCS_write_1A_nP(7, addr, __VA_ARGS__)
#define TC358763_DCS_write_1A_12P(addr, ...) \
TC358763_DCS_write_1A_nP(12, addr, __VA_ARGS__)
#define TC358763_DCS_write_1A_13P(addr, ...) \
TC358763_DCS_write_1A_nP(13, addr, __VA_ARGS__)
#define TC358763_DCS_write_1A_14P(addr, ...) \
TC358763_DCS_write_1A_nP(14, addr, __VA_ARGS__)
#define TC358763_DCS_write_1A_19P(addr, ...) \
TC358763_DCS_write_1A_nP(19, addr, __VA_ARGS__)
#define TC358763_DCS_write_1A_34P(addr, ...) \
TC358763_DCS_write_1A_nP(34, addr, __VA_ARGS__)
#define TC358763_DCS_write_1A_127P(addr, ...) \
TC358763_DCS_write_1A_nP(127, addr, __VA_ARGS__)
static int hx8363bl_brightness;
#define ACTIVE_HIGH_NAME "TRUULY-WVGA-SYNC-HIGH"
#define ACTIVE_LOW_NAME "TRUULY-WVGA-SYNC-LOW"
static struct fb_videomode truly_lcd_modedb[] = {
{
ACTIVE_HIGH_NAME, 50, 480, 854, 41042,
40, 60,
3, 3,
8, 4,
0x0,
FB_VMODE_NONINTERLACED,
0,
}, {
ACTIVE_LOW_NAME, 50, 480, 854, 41042,
40, 60,
3, 3,
8, 4,
FB_SYNC_OE_LOW_ACT,
FB_VMODE_NONINTERLACED,
0,
},
};
static struct mipi_lcd_config lcd_config = {
.virtual_ch = 0x0,
.data_lane_num = HX8363_TWO_DATA_LANE,
.max_phy_clk = HX8363_MAX_DPHY_CLK,
.dpi_fmt = MIPI_RGB888,
};
void mipid_hx8363_get_lcd_videomode(struct fb_videomode **mode, int *size,
struct mipi_lcd_config **data)
{
*mode = &truly_lcd_modedb[0];
*size = ARRAY_SIZE(truly_lcd_modedb);
*data = &lcd_config;
}
int mipid_hx8363_lcd_setup(struct mipi_dsi_info *mipi_dsi)
{
u8 buf[DSI_CMD_BUF_MAXSIZE];
dev_dbg(&mipi_dsi->pdev->dev, "MIPI DSI LCD HX8363 setup.\n");
TC358763_DCS_write_1A_3P(0xB9,0xFF,0x83,0x63);/* SET password */
TC358763_DCS_write_1A_19P(0xB1,0x01,0x00,0x44,0x08,0x01,0x10,0x10,0x36,
0x3E,0x1A,0x1A,0x40,0x12,0x00,0xE6,0xE6,0xE6,0xE6,0xE6);/* Set Power */
TC358763_DCS_write_1A_2P(0xB2,0x08,0x03);/* Set DISP */
TC358763_DCS_write_1A_7P(0xB4,0x02,0x18,0x9C,0x08,0x18,0x04,0x6C);
TC358763_DCS_write_1A_1P(0xB6,0x00);/* Set VCOM */
TC358763_DCS_write_1A_1P(0xCC,0x0B);/* Set Panel */
TC358763_DCS_write_1A_34P(0xE0,0x0E,0x15,0x19,0x30,0x31,0x3F,0x27,0x3C,0x88,0x8F,0xD1,0xD5,0xD7,0x16,0x16,
0x0C,0x1E,0x0E,0x15,0x19,0x30,0x31,0x3F,0x27,0x3C,0x88,0x8F,
0xD1,0xD5,0xD7,0x16,0x16,0x0C,0x1E);
mdelay(5);
TC358763_DCS_write_1A_1P(0x3A,0x77);/* 24bit */
TC358763_DCS_write_1A_14P(0xBA,0x11,0x00,0x56,0xC6,0x10,0x89,0xFF,0x0F,0x32,0x6E,0x04,0x07,0x9A,0x92);
TC358763_DCS_write_1A_0P(0x21);
TC358763_DCS_write_1A_0P(0x11);
msleep(10);
TC358763_DCS_write_1A_0P(0x29);
msleep(120);
return 0;
}
static int mipid_bl_update_status(struct backlight_device *bl)
{
return 0;
}
static int mipid_bl_get_brightness(struct backlight_device *bl)
{
return hx8363bl_brightness;
}
static int mipi_bl_check_fb(struct backlight_device *bl, struct fb_info *fbi)
{
return 0;
}
static const struct backlight_ops mipid_lcd_bl_ops = {
.update_status = mipid_bl_update_status,
.get_brightness = mipid_bl_get_brightness,
.check_fb = mipi_bl_check_fb,
};

165
include/linux/mipi_dsi.h Normal file
View File

@ -0,0 +1,165 @@
/*
* Copyright (C) 2011-2015 Freescale Semiconductor, Inc. All Rights Reserved.
*/
/*
* The code contained herein is licensed under the GNU General Public
* License. You may obtain a copy of the GNU General Public License
* Version 2 or later at the following locations:
*
* http://www.opensource.org/licenses/gpl-license.html
* http://www.gnu.org/copyleft/gpl.html
*/
#ifndef __INCLUDE_MIPI_DSI_H
#define __INCLUDE_MIPI_DSI_H
#define MIPI_DSI_VERSION (0x000)
#define MIPI_DSI_PWR_UP (0x004)
#define MIPI_DSI_CLKMGR_CFG (0x008)
#define MIPI_DSI_DPI_CFG (0x00c)
#define MIPI_DSI_DBI_CFG (0x010)
#define MIPI_DSI_DBIS_CMDSIZE (0x014)
#define MIPI_DSI_PCKHDL_CFG (0x018)
#define MIPI_DSI_VID_MODE_CFG (0x01c)
#define MIPI_DSI_VID_PKT_CFG (0x020)
#define MIPI_DSI_CMD_MODE_CFG (0x024)
#define MIPI_DSI_TMR_LINE_CFG (0x028)
#define MIPI_DSI_VTIMING_CFG (0x02c)
#define MIPI_DSI_PHY_TMR_CFG (0x030)
#define MIPI_DSI_GEN_HDR (0x034)
#define MIPI_DSI_GEN_PLD_DATA (0x038)
#define MIPI_DSI_CMD_PKT_STATUS (0x03c)
#define MIPI_DSI_TO_CNT_CFG (0x040)
#define MIPI_DSI_ERROR_ST0 (0x044)
#define MIPI_DSI_ERROR_ST1 (0x048)
#define MIPI_DSI_ERROR_MSK0 (0x04c)
#define MIPI_DSI_ERROR_MSK1 (0x050)
#define MIPI_DSI_PHY_RSTZ (0x054)
#define MIPI_DSI_PHY_IF_CFG (0x058)
#define MIPI_DSI_PHY_IF_CTRL (0x05c)
#define MIPI_DSI_PHY_STATUS (0x060)
#define MIPI_DSI_PHY_TST_CTRL0 (0x064)
#define MIPI_DSI_PHY_TST_CTRL1 (0x068)
#define DSI_PWRUP_RESET (0x0 << 0)
#define DSI_PWRUP_POWERUP (0x1 << 0)
#define DSI_DPI_CFG_VID_SHIFT (0)
#define DSI_DPI_CFG_VID_MASK (0x3)
#define DSI_DPI_CFG_COLORCODE_SHIFT (2)
#define DSI_DPI_CFG_COLORCODE_MASK (0x7)
#define DSI_DPI_CFG_DATAEN_ACT_LOW (0x1 << 5)
#define DSI_DPI_CFG_DATAEN_ACT_HIGH (0x0 << 5)
#define DSI_DPI_CFG_VSYNC_ACT_LOW (0x1 << 6)
#define DSI_DPI_CFG_VSYNC_ACT_HIGH (0x0 << 6)
#define DSI_DPI_CFG_HSYNC_ACT_LOW (0x1 << 7)
#define DSI_DPI_CFG_HSYNC_ACT_HIGH (0x0 << 7)
#define DSI_DPI_CFG_SHUTD_ACT_LOW (0x1 << 8)
#define DSI_DPI_CFG_SHUTD_ACT_HIGH (0x0 << 8)
#define DSI_DPI_CFG_COLORMODE_ACT_LOW (0x1 << 9)
#define DSI_DPI_CFG_COLORMODE_ACT_HIGH (0x0 << 9)
#define DSI_DPI_CFG_EN18LOOSELY (0x1 << 10)
#define DSI_PCKHDL_CFG_EN_EOTP_TX (0x1 << 0)
#define DSI_PCKHDL_CFG_EN_EOTP_RX (0x1 << 1)
#define DSI_PCKHDL_CFG_EN_BTA (0x1 << 2)
#define DSI_PCKHDL_CFG_EN_ECC_RX (0x1 << 3)
#define DSI_PCKHDL_CFG_EN_CRC_RX (0x1 << 4)
#define DSI_PCKHDL_CFG_GEN_VID_RX_MASK (0x3)
#define DSI_PCKHDL_CFG_GEN_VID_RX_SHIFT (5)
#define DSI_VID_MODE_CFG_EN (0x1 << 0)
#define DSI_VID_MODE_CFG_EN_BURSTMODE (0x3 << 1)
#define DSI_VID_MODE_CFG_TYPE_MASK (0x3)
#define DSI_VID_MODE_CFG_TYPE_SHIFT (1)
#define DSI_VID_MODE_CFG_EN_LP_VSA (0x1 << 3)
#define DSI_VID_MODE_CFG_EN_LP_VBP (0x1 << 4)
#define DSI_VID_MODE_CFG_EN_LP_VFP (0x1 << 5)
#define DSI_VID_MODE_CFG_EN_LP_VACT (0x1 << 6)
#define DSI_VID_MODE_CFG_EN_LP_HBP (0x1 << 7)
#define DSI_VID_MODE_CFG_EN_LP_HFP (0x1 << 8)
#define DSI_VID_MODE_CFG_EN_MULTI_PKT (0x1 << 9)
#define DSI_VID_MODE_CFG_EN_NULL_PKT (0x1 << 10)
#define DSI_VID_MODE_CFG_EN_FRAME_ACK (0x1 << 11)
#define DSI_VID_MODE_CFG_EN_LP_MODE (DSI_VID_MODE_CFG_EN_LP_VSA | \
DSI_VID_MODE_CFG_EN_LP_VBP | \
DSI_VID_MODE_CFG_EN_LP_VFP | \
DSI_VID_MODE_CFG_EN_LP_HFP | \
DSI_VID_MODE_CFG_EN_LP_HBP | \
DSI_VID_MODE_CFG_EN_LP_VACT)
#define DSI_VID_PKT_CFG_VID_PKT_SZ_MASK (0x7ff)
#define DSI_VID_PKT_CFG_VID_PKT_SZ_SHIFT (0)
#define DSI_VID_PKT_CFG_NUM_CHUNKS_MASK (0x3ff)
#define DSI_VID_PKT_CFG_NUM_CHUNKS_SHIFT (11)
#define DSI_VID_PKT_CFG_NULL_PKT_SZ_MASK (0x3ff)
#define DSI_VID_PKT_CFG_NULL_PKT_SZ_SHIFT (21)
#define MIPI_DSI_CMD_MODE_CFG_EN_LOWPOWER (0x1FFF)
#define MIPI_DSI_CMD_MODE_CFG_EN_CMD_MODE (0x1 << 0)
#define DSI_TME_LINE_CFG_HSA_TIME_MASK (0x1ff)
#define DSI_TME_LINE_CFG_HSA_TIME_SHIFT (0)
#define DSI_TME_LINE_CFG_HBP_TIME_MASK (0x1ff)
#define DSI_TME_LINE_CFG_HBP_TIME_SHIFT (9)
#define DSI_TME_LINE_CFG_HLINE_TIME_MASK (0x3fff)
#define DSI_TME_LINE_CFG_HLINE_TIME_SHIFT (18)
#define DSI_VTIMING_CFG_VSA_LINES_MASK (0xf)
#define DSI_VTIMING_CFG_VSA_LINES_SHIFT (0)
#define DSI_VTIMING_CFG_VBP_LINES_MASK (0x3f)
#define DSI_VTIMING_CFG_VBP_LINES_SHIFT (4)
#define DSI_VTIMING_CFG_VFP_LINES_MASK (0x3f)
#define DSI_VTIMING_CFG_VFP_LINES_SHIFT (10)
#define DSI_VTIMING_CFG_V_ACT_LINES_MASK (0x7ff)
#define DSI_VTIMING_CFG_V_ACT_LINES_SHIFT (16)
#define DSI_PHY_TMR_CFG_BTA_TIME_MASK (0xfff)
#define DSI_PHY_TMR_CFG_BTA_TIME_SHIFT (0)
#define DSI_PHY_TMR_CFG_LP2HS_TIME_MASK (0xff)
#define DSI_PHY_TMR_CFG_LP2HS_TIME_SHIFT (12)
#define DSI_PHY_TMR_CFG_HS2LP_TIME_MASK (0xff)
#define DSI_PHY_TMR_CFG_HS2LP_TIME_SHIFT (20)
#define DSI_PHY_IF_CFG_N_LANES_MASK (0x3)
#define DSI_PHY_IF_CFG_N_LANES_SHIFT (0)
#define DSI_PHY_IF_CFG_WAIT_TIME_MASK (0xff)
#define DSI_PHY_IF_CFG_WAIT_TIME_SHIFT (2)
#define DSI_PHY_RSTZ_EN_CLK (0x1 << 2)
#define DSI_PHY_RSTZ_DISABLE_RST (0x1 << 1)
#define DSI_PHY_RSTZ_DISABLE_SHUTDOWN (0x1 << 0)
#define DSI_PHY_RSTZ_RST (0x0)
#define DSI_PHY_STATUS_LOCK (0x1 << 0)
#define DSI_PHY_STATUS_STOPSTATE_CLK_LANE (0x1 << 2)
#define DSI_GEN_HDR_TYPE_MASK (0xff)
#define DSI_GEN_HDR_TYPE_SHIFT (0)
#define DSI_GEN_HDR_DATA_MASK (0xffff)
#define DSI_GEN_HDR_DATA_SHIFT (8)
#define DSI_CMD_PKT_STATUS_GEN_CMD_EMPTY (0x1 << 0)
#define DSI_CMD_PKT_STATUS_GEN_CMD_FULL (0x1 << 1)
#define DSI_CMD_PKT_STATUS_GEN_PLD_W_EMPTY (0x1 << 2)
#define DSI_CMD_PKT_STATUS_GEN_PLD_W_FULL (0x1 << 3)
#define DSI_CMD_PKT_STATUS_GEN_PLD_R_EMPTY (0x1 << 4)
#define DSI_CMD_PKT_STATUS_GEN_RD_CMD_BUSY (0x1 << 6)
#define DSI_ERROR_MSK0_ALL_MASK (0x1fffff)
#define DSI_ERROR_MSK1_ALL_MASK (0x3ffff)
#define DSI_PHY_IF_CTRL_RESET (0x0)
#define DSI_PHY_IF_CTRL_TX_REQ_CLK_HS (0x1 << 0)
#define DSI_PHY_IF_CTRL_TX_REQ_CLK_ULPS (0x1 << 1)
#define DSI_PHY_IF_CTRL_TX_EXIT_CLK_ULPS (0x1 << 2)
#define DSI_PHY_IF_CTRL_TX_REQ_DATA_ULPS (0x1 << 3)
#define DSI_PHY_IF_CTRL_TX_EXIT_DATA_ULPS (0x1 << 4)
#define DSI_PHY_IF_CTRL_TX_TRIG_MASK (0xF)
#define DSI_PHY_IF_CTRL_TX_TRIG_SHIFT (5)
#define DSI_PHY_CLK_INIT_COMMAND (0x44)
#define DSI_GEN_PLD_DATA_BUF_SIZE (0x4)
#endif