| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- /* Copyright Statement:
- *
- * This software/firmware and related documentation ("MediaTek Software") are
- * protected under relevant copyright laws. The information contained herein
- * is confidential and proprietary to MediaTek Inc. and/or its licensors.
- * Without the prior written permission of MediaTek inc. and/or its licensors,
- * any reproduction, modification, use or disclosure of MediaTek Software,
- * and information contained herein, in whole or in part, shall be strictly prohibited.
- */
- /* MediaTek Inc. (C) 2015. All rights reserved.
- *
- * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
- * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
- * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
- * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
- * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
- * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- */
- #ifdef BUILD_LK
- #include <platform/mt_gpio.h>
- #include <platform/mt_i2c.h>
- #include <platform/mt_pmic.h>
- #include <string.h>
- #else
- #include <linux/string.h>
- #include <linux/wait.h>
- #include <linux/platform_device.h>
- #include <linux/gpio.h>
- #include <linux/pinctrl/consumer.h>
- #include <linux/of_gpio.h>
- #include <asm-generic/gpio.h>
- #include <linux/kernel.h>
- #include <linux/mm.h>
- #include <linux/mm_types.h>
- #include <linux/module.h>
- #include <linux/types.h>
- #include <linux/slab.h>
- #include <linux/vmalloc.h>
- #ifdef CONFIG_OF
- #include <linux/of.h>
- #include <linux/of_irq.h>
- #include <linux/of_address.h>
- #include <linux/of_device.h>
- #include <linux/regulator/consumer.h>
- #include <linux/clk.h>
- #endif
- #endif
- #include "lcm_drv.h"
- /* --------------------------------------------------------------------------- */
- /* Local Constants */
- /* --------------------------------------------------------------------------- */
- #define FRAME_WIDTH (1920)
- #define FRAME_HEIGHT (1200)
- /* --------------------------------------------------------------------------- */
- /* Local Variables */
- /* --------------------------------------------------------------------------- */
- static LCM_UTIL_FUNCS lcm_util = { 0 };
- #define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
- #define UDELAY(n) (lcm_util.udelay(n))
- #define MDELAY(n) (lcm_util.mdelay(n))
- /* --------------------------------------------------------------------------- */
- /* Local Functions */
- /* --------------------------------------------------------------------------- */
- #define dsi_set_cmdq_V2(cmd, count, ppara, force_update)lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
- #define dsi_set_cmdq(pdata, queue_size, force_update) lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
- #define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
- #define write_regs(addr, pdata, byte_nums) lcm_util.dsi_write_regs(addr, pdata, byte_nums)
- #define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
- #define read_reg_v2(cmd, buffer, buffer_size) lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
- #define LCM_DSI_CMD_MODE 0
- static void lcm_init_power(void)
- {
- }
- static void lcm_suspend_power(void)
- {
- }
- static void lcm_resume_power(void)
- {
- }
- /* --------------------------------------------------------------------------- */
- /* LCM Driver Implementations */
- /* --------------------------------------------------------------------------- */
- static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
- {
- memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
- }
- static void lcm_get_params(LCM_PARAMS *params)
- {
- memset(params, 0, sizeof(LCM_PARAMS));
- params->type = LCM_TYPE_DSI;
- params->width = FRAME_WIDTH;
- params->height = FRAME_HEIGHT;
- #if (LCM_DSI_CMD_MODE)
- params->dsi.mode = CMD_MODE;
- #else
- params->dsi.mode = SYNC_EVENT_VDO_MODE;
- #endif
- params->dsi.LANE_NUM = LCM_FOUR_LANE;
- params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
- params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
- params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
- params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
- params->dsi.packet_size = 256;
- params->dsi.intermediat_buffer_num = 0;
- params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
- params->dsi.word_count = FRAME_WIDTH*3;
- params->dsi.vertical_sync_active = 4;
- params->dsi.vertical_backporch = 20;
- params->dsi.vertical_frontporch = 15;
- params->dsi.vertical_active_line = FRAME_HEIGHT;
- params->dsi.horizontal_sync_active = 40;
- params->dsi.horizontal_backporch = 80;
- params->dsi.horizontal_frontporch = 80;
- params->dsi.horizontal_active_pixel = FRAME_WIDTH;
- params->dsi.PLL_CLOCK = 481;
- params->dsi.null_packet_en = TRUE;
- params->dsi.lane_swap_en = 1;
- params->dsi.lane_swap[MIPITX_PHY_PORT_0][MIPITX_PHY_LANE_CK] = MIPITX_PHY_LANE_CK;
- params->dsi.lane_swap[MIPITX_PHY_PORT_0][MIPITX_PHY_LANE_0] = MIPITX_PHY_LANE_0;
- params->dsi.lane_swap[MIPITX_PHY_PORT_0][MIPITX_PHY_LANE_1] = MIPITX_PHY_LANE_1;
- params->dsi.lane_swap[MIPITX_PHY_PORT_0][MIPITX_PHY_LANE_2] = MIPITX_PHY_LANE_2;
- params->dsi.lane_swap[MIPITX_PHY_PORT_0][MIPITX_PHY_LANE_3] = MIPITX_PHY_LANE_3;
- params->dsi.lane_swap[MIPITX_PHY_PORT_0][MIPITX_PHY_LANE_RX] = MIPITX_PHY_LANE_0;
- }
- static void lcm_init(void)
- {
- #ifdef BUILD_LK
- printf("[LK/LCM] lcm_init() enter\n");
- SET_RESET_PIN(1);
- MDELAY(20);
- SET_RESET_PIN(0);
- MDELAY(20);
- SET_RESET_PIN(1);
- MDELAY(20);
- #else
- pr_debug("[Kernel/LCM] lcm_init() enter\n");
- #endif
- }
- void lcm_suspend(void)
- {
- #ifdef BUILD_LK
- printf("[LK/LCM] lcm_suspend() enter\n");
- SET_RESET_PIN(1);
- MDELAY(10);
- SET_RESET_PIN(0);
- MDELAY(10);
- #else
- pr_debug("[Kernel/LCM] lcm_suspend() enter\n");
- SET_RESET_PIN(1);
- MDELAY(10);
- SET_RESET_PIN(0);
- MDELAY(10);
- #endif
- }
- void lcm_resume(void)
- {
- #ifdef BUILD_LK
- printf("[LK/LCM] lcm_resume() enter\n");
- SET_RESET_PIN(1);
- MDELAY(20);
- SET_RESET_PIN(0);
- MDELAY(20);
- SET_RESET_PIN(1);
- MDELAY(20);
- #else
- pr_debug("[Kernel/LCM] lcm_resume() enter\n");
- SET_RESET_PIN(1);
- MDELAY(20);
- SET_RESET_PIN(0);
- MDELAY(20);
- SET_RESET_PIN(1);
- MDELAY(20);
- #endif
- }
- #if (LCM_DSI_CMD_MODE)
- static void lcm_update(unsigned int x, unsigned int y, unsigned int width, unsigned int height)
- {
- unsigned int x0 = x;
- unsigned int y0 = y;
- unsigned int x1 = x0 + width - 1;
- unsigned int y1 = y0 + height - 1;
- unsigned char x0_MSB = ((x0 >> 8) & 0xFF);
- unsigned char x0_LSB = (x0 & 0xFF);
- unsigned char x1_MSB = ((x1 >> 8) & 0xFF);
- unsigned char x1_LSB = (x1 & 0xFF);
- unsigned char y0_MSB = ((y0 >> 8) & 0xFF);
- unsigned char y0_LSB = (y0 & 0xFF);
- unsigned char y1_MSB = ((y1 >> 8) & 0xFF);
- unsigned char y1_LSB = (y1 & 0xFF);
- unsigned int data_array[16];
- data_array[0] = 0x00053902;
- data_array[1] = (x1_MSB << 24) | (x0_LSB << 16) | (x0_MSB << 8) | 0x2a;
- data_array[2] = (x1_LSB);
- dsi_set_cmdq(data_array, 3, 1);
- data_array[0] = 0x00053902;
- data_array[1] = (y1_MSB << 24) | (y0_LSB << 16) | (y0_MSB << 8) | 0x2b;
- data_array[2] = (y1_LSB);
- dsi_set_cmdq(data_array, 3, 1);
- data_array[0] = 0x00290508;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0] = 0x002c3909;
- dsi_set_cmdq(data_array, 1, 0);
- }
- #endif
- LCM_DRIVER claa101fp01_dsi_vdo_lcm_drv = {
- .name = "CLAA101FP01_DSI_VDO",
- .set_util_funcs = lcm_set_util_funcs,
- .get_params = lcm_get_params,
- .init = lcm_init,
- .suspend = lcm_suspend,
- .resume = lcm_resume,
- .init_power = lcm_init_power,
- .resume_power = lcm_resume_power,
- .suspend_power = lcm_suspend_power,
- #if (LCM_DSI_CMD_MODE)
- .update = lcm_update,
- #endif
- };
|