mdss_tc358764_dsi2lvds.c 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696
  1. /* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #include <linux/module.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/of.h>
  15. #include <linux/of_gpio.h>
  16. #include <linux/of_device.h>
  17. #include <linux/gpio.h>
  18. #include <linux/qpnp/pin.h>
  19. #include <linux/delay.h>
  20. #include <linux/slab.h>
  21. #include <linux/leds.h>
  22. #include <linux/pwm.h>
  23. #include <linux/err.h>
  24. #ifdef CONFIG_LCD_CLASS_DEVICE
  25. #include <linux/lcd.h>
  26. #endif
  27. #include "mdss_fb.h"
  28. #include "mdss_dsi.h"
  29. #include "mdss_samsung_dsi_panel_msm8x26.h"
  30. #if defined(CONFIG_MDNIE_TFT_MSM8X26)
  31. #include "mdnie_tft_msm8x26.h"
  32. #endif
  33. #ifdef CONFIG_BACKLIGHT_LP8556
  34. #include "backlight_LP8556.h"
  35. #endif
  36. #define DT_CMD_HDR 6
  37. #if defined(CONFIG_ESD_ERR_FG_RECOVERY)
  38. struct work_struct err_fg_work;
  39. static int err_fg_gpio;
  40. static int esd_count;
  41. static int err_fg_working;
  42. #define ESD_DEBUG 1
  43. #endif
  44. static int lcd_attached;
  45. static int lcd_id;
  46. int get_lcd_attached(void);
  47. extern int system_rev;
  48. void __iomem *virt_mmss_gp0_base;
  49. #define MMSS_GP0_BASE 0xFD8C3420
  50. #define MMSS_GP0_SIZE 0x28
  51. #if defined(CONFIG_TC358764_I2C_CONTROL)
  52. struct i2c_client *lvds_i2c_client;
  53. struct tc35876x_i2c_platform_data {
  54. unsigned int gpio_backlight_en;
  55. u32 en_gpio_flags;
  56. int gpio_sda;
  57. u32 sda_gpio_flags;
  58. int gpio_scl;
  59. u32 scl_gpio_flags;
  60. };
  61. struct tc35876x_i2c_info {
  62. struct i2c_client *client;
  63. struct tc35876x_i2c_platform_data *pdata;
  64. };
  65. static struct tc35876x_i2c_info *i2c_info;
  66. static int tc35876x_i2c_read_reg(u16 reg)
  67. {
  68. u8 tx_data[2], rx_data[4];
  69. int ret, val;
  70. struct i2c_msg msg[2] = {
  71. /* first write slave position to i2c devices */
  72. { i2c_info->client->addr, 0, ARRAY_SIZE(tx_data), tx_data },
  73. /* Second read data from position */
  74. { i2c_info->client->addr, I2C_M_RD, ARRAY_SIZE(rx_data), rx_data}
  75. };
  76. tx_data[0] = (reg >> 8) & 0xff;
  77. tx_data[1] = reg & 0xff;
  78. ret = i2c_transfer(i2c_info->client->adapter, msg, 2);
  79. if (unlikely(ret < 0)) {
  80. pr_err(" [%s] i2c read failed on reg 0x%04x error %d\n",
  81. __func__, reg, ret);
  82. return ret;
  83. }
  84. if (unlikely(ret < ARRAY_SIZE(msg))) {
  85. pr_err("%s: reg 0x%04x msgs %d\n" ,
  86. __func__, reg, ret);
  87. return -EAGAIN;
  88. }
  89. val = (int)rx_data[0] << 24 | ((int)(rx_data[1]) << 16) |
  90. ((int)(rx_data[2]) << 8) | ((int)(rx_data[3]));
  91. return val;
  92. }
  93. static int tc35876x_write_reg(u16 reg, u32 value)
  94. {
  95. int ret;
  96. u8 tx_data[6];
  97. struct i2c_msg msg[] = {
  98. {i2c_info->client->addr, 0, 6, tx_data }
  99. };
  100. /* NOTE: Register address big-endian, data little-endian. */
  101. tx_data[0] = (reg >> 8) & 0xff;
  102. tx_data[1] = reg & 0xff;
  103. tx_data[2] = value & 0xff;
  104. tx_data[3] = (value >> 8) & 0xff;
  105. tx_data[4] = (value >> 16) & 0xff;
  106. tx_data[5] = (value >> 24) & 0xff;
  107. ret = i2c_transfer(i2c_info->client->adapter, msg, ARRAY_SIZE(msg));
  108. if (unlikely(ret < 0)) {
  109. pr_err("%s: i2c write failed reg 0x%04x val 0x%08x error %d\n",
  110. __func__, reg, value, ret);
  111. return ret;
  112. }
  113. if (unlikely(ret < ARRAY_SIZE(msg))) {
  114. pr_err("%s: reg 0x%04x val 0x%08x msgs %d\n",
  115. __func__, reg, value, ret);
  116. return -EAGAIN;
  117. }
  118. return ret;
  119. }
  120. void mdss_i2c_panel_cmds_send(void)
  121. {
  122. int id;
  123. if (get_lcd_attached() == 0)
  124. {
  125. printk("%s: LCD not connected!\n",__func__);
  126. return;
  127. }
  128. id=tc35876x_i2c_read_reg(0x0580);
  129. pr_info("%s: ID :- %X\n",__func__, id);
  130. /**************************************************
  131. TC358764/65XBG DSI Basic Parameters. Following 10 setting should be pefromed in LP mode
  132. **************************************************/
  133. tc35876x_write_reg(0x013C, 0x00030005);
  134. tc35876x_write_reg(0x0114, 0x000000003);
  135. tc35876x_write_reg(0x0164, 0x000000003);
  136. tc35876x_write_reg(0x0168, 0x000000003);
  137. tc35876x_write_reg(0x016C, 0x000000003);
  138. tc35876x_write_reg(0x0170, 0x000000003);
  139. tc35876x_write_reg(0x0134, 0x00000001F);
  140. tc35876x_write_reg(0x0210, 0x00000001F);
  141. tc35876x_write_reg(0x0104, 0x00000001);
  142. tc35876x_write_reg(0x0204, 0x00000001);
  143. /**************************************************
  144. TC358764/65XBG Timing and mode setting
  145. **************************************************/
  146. tc35876x_write_reg(0x450, 0x03F00120);
  147. tc35876x_write_reg(0x454, 0x0032001C);
  148. tc35876x_write_reg(0x458, 0x00320500);
  149. tc35876x_write_reg(0x45C, 0x00040002);
  150. tc35876x_write_reg(0x460, 0x000A0320);
  151. tc35876x_write_reg(0x464, 0x00000001);
  152. tc35876x_write_reg(0x4A0, 0x00448006);
  153. //More than 100us
  154. udelay(200);
  155. tc35876x_write_reg(0x4A0, 0x00048006);
  156. tc35876x_write_reg(0x504, 0x00000004);
  157. /**************************************************
  158. TC358764/65XBG LVDS Color mapping setting
  159. **************************************************/
  160. tc35876x_write_reg(0x480, 0x03020100);
  161. tc35876x_write_reg(0x484, 0x08050704);
  162. tc35876x_write_reg(0x488, 0x0F0E0A09);
  163. tc35876x_write_reg(0x48C, 0x100D0C0B);
  164. tc35876x_write_reg(0x490, 0x12111716);
  165. tc35876x_write_reg(0x494, 0x1B151413);
  166. tc35876x_write_reg(0x498, 0x061A1918);
  167. /**************************************************
  168. TC358764/65XBG LVDS enable
  169. **************************************************/
  170. tc35876x_write_reg(0x49C, 0x00000001);
  171. }
  172. #endif
  173. DEFINE_LED_TRIGGER(bl_led_trigger);
  174. static struct mdss_samsung_driver_data msd;
  175. static char dcs_cmd[2] = {0x54, 0x00}; /* DTYPE_DCS_READ */
  176. static struct dsi_cmd_desc dcs_read_cmd = {
  177. {DTYPE_DCS_READ, 1, 0, 1, 5, sizeof(dcs_cmd)},
  178. dcs_cmd
  179. };
  180. u32 mdss_dsi_dcs_read(struct mdss_dsi_ctrl_pdata *ctrl,
  181. char cmd0, char cmd1)
  182. {
  183. struct dcs_cmd_req cmdreq;
  184. if (get_lcd_attached() == 0)
  185. {
  186. printk("%s: LCD not connected!\n",__func__);
  187. return 0;
  188. }
  189. dcs_cmd[0] = cmd0;
  190. dcs_cmd[1] = cmd1;
  191. memset(&cmdreq, 0, sizeof(cmdreq));
  192. cmdreq.cmds = &dcs_read_cmd;
  193. cmdreq.cmds_cnt = 1;
  194. cmdreq.flags = CMD_REQ_RX | CMD_REQ_COMMIT;
  195. cmdreq.rlen = 1;
  196. cmdreq.cb = NULL; /* call back */
  197. mdss_dsi_cmdlist_put(ctrl, &cmdreq);
  198. /*
  199. * blocked here, until call back called
  200. */
  201. return 0;
  202. }
  203. void mdss_dsi_cmds_send(struct mdss_dsi_ctrl_pdata *ctrl, struct dsi_cmd_desc *cmds, int cnt,int flag)
  204. {
  205. struct dcs_cmd_req cmdreq;
  206. if (get_lcd_attached() == 0)
  207. {
  208. printk("%s: LCD not connected!\n",__func__);
  209. return;
  210. }
  211. memset(&cmdreq, 0, sizeof(cmdreq));
  212. cmdreq.cmds = cmds;
  213. cmdreq.cmds_cnt = cnt;
  214. cmdreq.flags = CMD_REQ_COMMIT | CMD_CLK_CTRL;
  215. cmdreq.rlen = 0;
  216. cmdreq.cb = NULL;
  217. mdss_dsi_cmdlist_put(ctrl, &cmdreq);
  218. }
  219. static void mdss_dsi_panel_cmds_send(struct mdss_dsi_ctrl_pdata *ctrl,
  220. struct dsi_panel_cmds *pcmds)
  221. {
  222. struct dcs_cmd_req cmdreq;
  223. if (get_lcd_attached() == 0)
  224. {
  225. printk("%s: LCD not connected!\n",__func__);
  226. return;
  227. }
  228. memset(&cmdreq, 0, sizeof(cmdreq));
  229. cmdreq.cmds = pcmds->cmds;
  230. cmdreq.cmds_cnt = pcmds->cmd_cnt;
  231. cmdreq.flags = CMD_REQ_COMMIT;
  232. cmdreq.rlen = 0;
  233. cmdreq.cb = NULL;
  234. mdss_dsi_cmdlist_put(ctrl, &cmdreq);
  235. }
  236. unsigned char mdss_dsi_panel_pwm_scaling(int level)
  237. {
  238. unsigned char scaled_level;
  239. if (level >= MAX_BRIGHTNESS_LEVEL)
  240. scaled_level = BL_MAX_BRIGHTNESS_LEVEL;
  241. else if (level >= MID_BRIGHTNESS_LEVEL) {
  242. scaled_level = (level - MID_BRIGHTNESS_LEVEL) *
  243. (BL_MAX_BRIGHTNESS_LEVEL - BL_MID_BRIGHTNESS_LEVEL) / (MAX_BRIGHTNESS_LEVEL-MID_BRIGHTNESS_LEVEL) + BL_MID_BRIGHTNESS_LEVEL;
  244. } else if (level >= DIM_BRIGHTNESS_LEVEL) {
  245. scaled_level = (level - DIM_BRIGHTNESS_LEVEL) *
  246. (BL_MID_BRIGHTNESS_LEVEL - BL_DIM_BRIGHTNESS_LEVEL) / (MID_BRIGHTNESS_LEVEL-DIM_BRIGHTNESS_LEVEL) + BL_DIM_BRIGHTNESS_LEVEL;
  247. } else if (level >= LOW_BRIGHTNESS_LEVEL) {
  248. scaled_level = (level - LOW_BRIGHTNESS_LEVEL) *
  249. (BL_DIM_BRIGHTNESS_LEVEL - BL_LOW_BRIGHTNESS_LEVEL) / (DIM_BRIGHTNESS_LEVEL-LOW_BRIGHTNESS_LEVEL) + BL_LOW_BRIGHTNESS_LEVEL;
  250. } else{
  251. scaled_level = BL_MIN_BRIGHTNESS;
  252. }
  253. pr_info("%s level = [%d]: scaled_level = [%d] \n",__func__,level,scaled_level);
  254. return scaled_level;
  255. }
  256. static char led_pwm1[2] = {0x51, 0x0}; /* DTYPE_DCS_WRITE1 */
  257. static struct dsi_cmd_desc backlight_cmd = {
  258. {DTYPE_DCS_WRITE1, 1, 0, 0, 1, sizeof(led_pwm1)},
  259. led_pwm1
  260. };
  261. static void mdss_dsi_panel_bklt_dcs(struct mdss_dsi_ctrl_pdata *ctrl, int level)
  262. {
  263. struct dcs_cmd_req cmdreq;
  264. if (get_lcd_attached() == 0)
  265. {
  266. printk("%s: LCD not connected!\n",__func__);
  267. return;
  268. }
  269. pr_debug("%s: level=%d\n", __func__, level);
  270. led_pwm1[1] = mdss_dsi_panel_pwm_scaling(level);
  271. memset(&cmdreq, 0, sizeof(cmdreq));
  272. cmdreq.cmds = &backlight_cmd;
  273. cmdreq.cmds_cnt = 1;
  274. cmdreq.flags = CMD_REQ_COMMIT | CMD_CLK_CTRL;
  275. cmdreq.rlen = 0;
  276. cmdreq.cb = NULL;
  277. mdss_dsi_cmdlist_put(ctrl, &cmdreq);
  278. }
  279. void mdss_dsi_tc358764_panel_reset(struct mdss_panel_data *pdata, int enable)
  280. {
  281. struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
  282. struct mdss_panel_info *pinfo = NULL;
  283. int rc=0;
  284. if (pdata == NULL) {
  285. pr_err("%s: Invalid input data\n", __func__);
  286. return;
  287. }
  288. ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  289. panel_data);
  290. if (!gpio_is_valid(ctrl_pdata->disp_en_gpio)) {
  291. pr_debug("%s:%d, reset line not configured\n",
  292. __func__, __LINE__);
  293. }
  294. if (!gpio_is_valid(ctrl_pdata->rst_gpio)) {
  295. pr_debug("%s:%d, reset line not configured\n",
  296. __func__, __LINE__);
  297. return;
  298. }
  299. pr_info("%s:enable = %d\n", __func__, enable);
  300. pinfo = &(ctrl_pdata->panel_data.panel_info);
  301. if (enable) {
  302. mdelay(1);
  303. if (gpio_is_valid(msd.lcd_en_gpio))
  304. gpio_set_value_cansleep(msd.lcd_en_gpio,(1<<1));//PMIC GPIO
  305. mdelay(1);
  306. if (gpio_is_valid(ctrl_pdata->rst_gpio)) {
  307. gpio_tlmm_config(GPIO_CFG(ctrl_pdata->rst_gpio, 0,
  308. GPIO_CFG_OUTPUT,GPIO_CFG_NO_PULL,GPIO_CFG_2MA),
  309. GPIO_CFG_ENABLE);
  310. gpio_set_value((ctrl_pdata->rst_gpio), 1);
  311. mdelay(1);
  312. gpio_set_value((ctrl_pdata->rst_gpio), 0);
  313. mdelay(1);
  314. gpio_set_value((ctrl_pdata->rst_gpio), 1);
  315. mdelay(1);
  316. }
  317. if (gpio_is_valid(ctrl_pdata->mode_gpio)) {
  318. if (pinfo->mode_gpio_state == MODE_GPIO_HIGH)
  319. gpio_set_value((ctrl_pdata->mode_gpio), 1);
  320. else if (pinfo->mode_gpio_state == MODE_GPIO_LOW)
  321. gpio_set_value((ctrl_pdata->mode_gpio), 0);
  322. }
  323. if (gpio_is_valid(msd.bl_ldi_en)) {
  324. rc = gpio_tlmm_config(GPIO_CFG(msd.bl_ldi_en, 0,
  325. GPIO_CFG_INPUT,GPIO_CFG_PULL_DOWN,GPIO_CFG_2MA),
  326. GPIO_CFG_DISABLE);
  327. if (rc)
  328. pr_err("tlmm config bl_ldi_en failed, rc=%d\n",rc);
  329. }
  330. if (ctrl_pdata->ctrl_state & CTRL_STATE_PANEL_INIT) {
  331. pr_debug("%s: Panel Not properly turned OFF\n",
  332. __func__);
  333. ctrl_pdata->ctrl_state &= ~CTRL_STATE_PANEL_INIT;
  334. pr_debug("%s: Reset panel done\n", __func__);
  335. }
  336. } else {
  337. if (gpio_is_valid(ctrl_pdata->rst_gpio)) {
  338. gpio_tlmm_config(GPIO_CFG(ctrl_pdata->rst_gpio, 0,
  339. GPIO_CFG_OUTPUT,GPIO_CFG_PULL_DOWN,GPIO_CFG_2MA),
  340. GPIO_CFG_DISABLE);
  341. gpio_set_value((ctrl_pdata->rst_gpio), 0);
  342. }
  343. if (gpio_is_valid(msd.lcd_en_gpio))
  344. gpio_set_value_cansleep(msd.lcd_en_gpio,0);
  345. #if defined(CONFIG_MACH_MATISSELTE_USC) || defined(CONFIG_MACH_MATISSELTE_OPEN)
  346. if (gpio_is_valid(msd.bl_ldi_en)) {
  347. gpio_tlmm_config(GPIO_CFG(msd.bl_ldi_en, 0,
  348. GPIO_CFG_INPUT,GPIO_CFG_NO_PULL,GPIO_CFG_2MA),
  349. GPIO_CFG_DISABLE);
  350. }
  351. #else
  352. if (gpio_is_valid(msd.bl_ldi_en)) {
  353. gpio_tlmm_config(GPIO_CFG(msd.bl_ldi_en, 0,
  354. GPIO_CFG_INPUT,GPIO_CFG_PULL_DOWN,GPIO_CFG_2MA),
  355. GPIO_CFG_DISABLE);
  356. }
  357. #endif
  358. if (gpio_is_valid(msd.bl_sda)) {
  359. rc = gpio_tlmm_config(GPIO_CFG(msd.bl_sda, 0,
  360. GPIO_CFG_INPUT,GPIO_CFG_NO_PULL,GPIO_CFG_2MA),
  361. GPIO_CFG_DISABLE);
  362. if (rc)
  363. pr_err("tlmm config bl_sda failed, rc=%d\n",rc);
  364. }
  365. if (gpio_is_valid(msd.bl_scl)) {
  366. rc = gpio_tlmm_config(GPIO_CFG(msd.bl_scl, 0,
  367. GPIO_CFG_INPUT,GPIO_CFG_NO_PULL,GPIO_CFG_2MA),
  368. GPIO_CFG_DISABLE);
  369. if (rc)
  370. pr_err("tlmm config bl_scl failed, rc=%d\n",rc);
  371. }
  372. if (gpio_is_valid(ctrl_pdata->disp_en_gpio)) {
  373. gpio_tlmm_config(GPIO_CFG(ctrl_pdata->disp_en_gpio,0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
  374. GPIO_CFG_2MA), GPIO_CFG_DISABLE);
  375. gpio_set_value((ctrl_pdata->disp_en_gpio), 0);
  376. }
  377. mdelay(500);
  378. }
  379. return;
  380. }
  381. static char caset[] = {0x2a, 0x00, 0x00, 0x03, 0x00}; /* DTYPE_DCS_LWRITE */
  382. static char paset[] = {0x2b, 0x00, 0x00, 0x05, 0x00}; /* DTYPE_DCS_LWRITE */
  383. static struct dsi_cmd_desc partial_update_enable_cmd[] = {
  384. {{DTYPE_DCS_LWRITE, 1, 0, 0, 1, sizeof(caset)}, caset},
  385. {{DTYPE_DCS_LWRITE, 1, 0, 0, 1, sizeof(paset)}, paset},
  386. };
  387. static int mdss_dsi_panel_partial_update(struct mdss_panel_data *pdata)
  388. {
  389. struct mipi_panel_info *mipi;
  390. struct mdss_dsi_ctrl_pdata *ctrl = NULL;
  391. struct dcs_cmd_req cmdreq;
  392. int rc = 0;
  393. if (pdata == NULL) {
  394. pr_err("%s: Invalid input data\n", __func__);
  395. return -EINVAL;
  396. }
  397. ctrl = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  398. panel_data);
  399. mipi = &pdata->panel_info.mipi;
  400. pr_debug("%s: ctrl=%pK ndx=%d\n", __func__, ctrl, ctrl->ndx);
  401. caset[1] = (((pdata->panel_info.roi_x) & 0xFF00) >> 8);
  402. caset[2] = (((pdata->panel_info.roi_x) & 0xFF));
  403. caset[3] = (((pdata->panel_info.roi_x - 1 + pdata->panel_info.roi_w)
  404. & 0xFF00) >> 8);
  405. caset[4] = (((pdata->panel_info.roi_x - 1 + pdata->panel_info.roi_w)
  406. & 0xFF));
  407. partial_update_enable_cmd[0].payload = caset;
  408. paset[1] = (((pdata->panel_info.roi_y) & 0xFF00) >> 8);
  409. paset[2] = (((pdata->panel_info.roi_y) & 0xFF));
  410. paset[3] = (((pdata->panel_info.roi_y - 1 + pdata->panel_info.roi_h)
  411. & 0xFF00) >> 8);
  412. paset[4] = (((pdata->panel_info.roi_y - 1 + pdata->panel_info.roi_h)
  413. & 0xFF));
  414. partial_update_enable_cmd[1].payload = paset;
  415. pr_debug("%s: enabling partial update\n", __func__);
  416. memset(&cmdreq, 0, sizeof(cmdreq));
  417. cmdreq.cmds = partial_update_enable_cmd;
  418. cmdreq.cmds_cnt = 2;
  419. cmdreq.flags = CMD_REQ_COMMIT | CMD_CLK_CTRL;
  420. cmdreq.rlen = 0;
  421. cmdreq.cb = NULL;
  422. mdss_dsi_cmdlist_put(ctrl, &cmdreq);
  423. return rc;
  424. }
  425. extern void mdss_dsi_panel_bklt_pwm( int level);
  426. static void mdss_dsi_panel_bl_ctrl(struct mdss_panel_data *pdata,
  427. u32 bl_level)
  428. {
  429. struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
  430. if (pdata == NULL) {
  431. pr_err("%s: Invalid input data\n", __func__);
  432. return;
  433. }
  434. if (get_lcd_attached() == 0)
  435. {
  436. printk("%s: LCD not connected!\n",__func__);
  437. return;
  438. }
  439. ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  440. panel_data);
  441. pr_err("%s:@@@@@@@@@@@@@@@@@@@ bklt_ctrl:%d :bl_level=%d\n", __func__,ctrl_pdata->bklt_ctrl,bl_level);
  442. switch (ctrl_pdata->bklt_ctrl) {
  443. case BL_WLED:
  444. led_trigger_event(bl_led_trigger, bl_level);
  445. break;
  446. case BL_PWM:
  447. bl_level=mdss_dsi_panel_pwm_scaling(bl_level);
  448. mdss_dsi_panel_bklt_pwm(bl_level);
  449. break;
  450. case BL_DCS_CMD:
  451. mdss_dsi_panel_bklt_dcs(ctrl_pdata, bl_level);
  452. break;
  453. default:
  454. pr_err("%s: Unknown bl_ctrl configuration\n",
  455. __func__);
  456. break;
  457. }
  458. }
  459. extern void pwm_backlight_enable(void);
  460. static int mdss_dsi_panel_on(struct mdss_panel_data *pdata)
  461. {
  462. int rc =0;
  463. struct mdss_dsi_ctrl_pdata *ctrl = NULL;
  464. msd.mfd = (struct msm_fb_data_type *)registered_fb[0]->par;
  465. if (pdata == NULL) {
  466. pr_err("%s: Invalid input data\n", __func__);
  467. return -EINVAL;
  468. }
  469. msd.mpd = pdata;
  470. ctrl = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  471. panel_data);
  472. pr_debug("%s: ctrl=%pK ndx=%d\n", __func__, ctrl, ctrl->ndx);
  473. #if !defined(CONFIG_TC358764_I2C_CONTROL)
  474. if (ctrl->on_cmds.cmd_cnt)
  475. mdss_dsi_panel_cmds_send(ctrl, &ctrl->on_cmds);
  476. #else
  477. mdss_i2c_panel_cmds_send();
  478. #endif
  479. msd.mfd->resume_state = MIPI_RESUME_STATE;
  480. #if defined(CONFIG_MDNIE_TFT_MSM8X26)
  481. is_negative_on();
  482. #endif
  483. msleep(300);
  484. if (gpio_is_valid(msd.bl_rst_gpio)) {
  485. gpio_tlmm_config(GPIO_CFG(msd.bl_rst_gpio, 0,
  486. GPIO_CFG_OUTPUT,GPIO_CFG_NO_PULL,GPIO_CFG_2MA),
  487. GPIO_CFG_ENABLE);
  488. gpio_direction_output(msd.bl_rst_gpio, 1);
  489. }
  490. if (gpio_is_valid(msd.bl_sda)) {
  491. rc = gpio_tlmm_config(GPIO_CFG(msd.bl_sda, 0,
  492. GPIO_CFG_INPUT,GPIO_CFG_NO_PULL,GPIO_CFG_2MA),
  493. GPIO_CFG_ENABLE);
  494. if (rc)
  495. pr_err("tlmm config bl_sda failed, rc=%d\n",rc);
  496. }
  497. if (gpio_is_valid(msd.bl_scl)) {
  498. rc = gpio_tlmm_config(GPIO_CFG(msd.bl_scl, 0,
  499. GPIO_CFG_INPUT,GPIO_CFG_NO_PULL,GPIO_CFG_2MA),
  500. GPIO_CFG_ENABLE);
  501. if (rc)
  502. pr_err("tlmm config bl_scl failed, rc=%d\n",rc);
  503. }
  504. mdelay(2);
  505. pwm_backlight_enable();
  506. mdelay(2);
  507. if (gpio_is_valid(msd.bl_ap_pwm)) {
  508. gpio_tlmm_config(GPIO_CFG(msd.bl_ap_pwm,3, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
  509. GPIO_CFG_2MA), GPIO_CFG_ENABLE);
  510. }
  511. #if defined(CONFIG_ESD_ERR_FG_RECOVERY)
  512. enable_irq(err_fg_gpio);
  513. #endif
  514. pr_err("%s:-\n", __func__);
  515. return 0;
  516. }
  517. static int mdss_dsi_panel_off(struct mdss_panel_data *pdata)
  518. {
  519. struct mdss_dsi_ctrl_pdata *ctrl = NULL;
  520. msd.mfd = (struct msm_fb_data_type *)registered_fb[0]->par;
  521. if (pdata == NULL) {
  522. pr_err("%s: Invalid input data\n", __func__);
  523. return -EINVAL;
  524. }
  525. ctrl = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  526. panel_data);
  527. #if defined(CONFIG_ESD_ERR_FG_RECOVERY)
  528. if (!err_fg_working) {
  529. disable_irq_nosync(err_fg_gpio);
  530. cancel_work_sync(&err_fg_work);
  531. }
  532. #endif
  533. pr_debug("%s: ctrl=%pK ndx=%d\n", __func__, ctrl, ctrl->ndx);
  534. if (gpio_is_valid(msd.bl_ap_pwm)) {
  535. gpio_tlmm_config(GPIO_CFG(msd.bl_ap_pwm,0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
  536. GPIO_CFG_2MA), GPIO_CFG_DISABLE);
  537. gpio_set_value(msd.bl_ap_pwm, 0);
  538. }
  539. msleep(10);
  540. if (gpio_is_valid(msd.bl_rst_gpio)) {
  541. gpio_tlmm_config(GPIO_CFG(msd.bl_rst_gpio,0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
  542. GPIO_CFG_2MA), GPIO_CFG_DISABLE);
  543. gpio_set_value(msd.bl_rst_gpio, 0);
  544. }
  545. msleep(190);
  546. if (ctrl->off_cmds.cmd_cnt)
  547. mdss_dsi_panel_cmds_send(ctrl, &ctrl->off_cmds);
  548. msd.mfd->resume_state = MIPI_SUSPEND_STATE;
  549. pr_debug("%s:-\n", __func__);
  550. return 0;
  551. }
  552. static int mdss_dsi_parse_dcs_cmds(struct device_node *np,
  553. struct dsi_panel_cmds *pcmds, char *cmd_key, char *link_key)
  554. {
  555. const char *data;
  556. int blen = 0, len;
  557. char *buf, *bp;
  558. struct dsi_ctrl_hdr *dchdr;
  559. int i, cnt;
  560. data = of_get_property(np, cmd_key, &blen);
  561. if (!data) {
  562. pr_err("%s: failed, key=%s\n", __func__, cmd_key);
  563. return -ENOMEM;
  564. }
  565. buf = kzalloc(sizeof(char) * blen, GFP_KERNEL);
  566. if (!buf)
  567. return -ENOMEM;
  568. memcpy(buf, data, blen);
  569. /* scan dcs commands */
  570. bp = buf;
  571. len = blen;
  572. cnt = 0;
  573. while (len > sizeof(*dchdr)) {
  574. dchdr = (struct dsi_ctrl_hdr *)bp;
  575. dchdr->dlen = ntohs(dchdr->dlen);
  576. if (dchdr->dlen > len) {
  577. pr_err("%s: dtsi cmd=%x error, len=%d",
  578. __func__, dchdr->dtype, dchdr->dlen);
  579. kfree(buf);
  580. return -ENOMEM;
  581. }
  582. bp += sizeof(*dchdr);
  583. len -= sizeof(*dchdr);
  584. bp += dchdr->dlen;
  585. len -= dchdr->dlen;
  586. cnt++;
  587. }
  588. if (len != 0) {
  589. pr_err("%s: dcs_cmd=%x len=%d error!",
  590. __func__, buf[0], blen);
  591. kfree(buf);
  592. return -ENOMEM;
  593. }
  594. pcmds->cmds = kzalloc(cnt * sizeof(struct dsi_cmd_desc),
  595. GFP_KERNEL);
  596. if (!pcmds->cmds){
  597. kfree(buf);
  598. return -ENOMEM;
  599. }
  600. pcmds->cmd_cnt = cnt;
  601. pcmds->buf = buf;
  602. pcmds->blen = blen;
  603. bp = buf;
  604. len = blen;
  605. for (i = 0; i < cnt; i++) {
  606. dchdr = (struct dsi_ctrl_hdr *)bp;
  607. len -= sizeof(*dchdr);
  608. bp += sizeof(*dchdr);
  609. pcmds->cmds[i].dchdr = *dchdr;
  610. pcmds->cmds[i].payload = bp;
  611. bp += dchdr->dlen;
  612. len -= dchdr->dlen;
  613. }
  614. data = of_get_property(np, link_key, NULL);
  615. if (!strncmp(data, "dsi_hs_mode", 11))
  616. pcmds->link_state = DSI_HS_MODE;
  617. else
  618. pcmds->link_state = DSI_LP_MODE;
  619. pr_debug("%s: dcs_cmd=%x len=%d, cmd_cnt=%d link_state=%d\n", __func__,
  620. pcmds->buf[0], pcmds->blen, pcmds->cmd_cnt, pcmds->link_state);
  621. return 0;
  622. }
  623. int mdss_panel_dt_get_dst_fmt(u32 bpp, char mipi_mode, u32 pixel_packing,
  624. char *dst_format)
  625. {
  626. int rc = 0;
  627. switch (bpp) {
  628. case 3:
  629. *dst_format = DSI_CMD_DST_FORMAT_RGB111;
  630. break;
  631. case 8:
  632. *dst_format = DSI_CMD_DST_FORMAT_RGB332;
  633. break;
  634. case 12:
  635. *dst_format = DSI_CMD_DST_FORMAT_RGB444;
  636. break;
  637. case 16:
  638. switch (mipi_mode) {
  639. case DSI_VIDEO_MODE:
  640. *dst_format = DSI_VIDEO_DST_FORMAT_RGB565;
  641. break;
  642. case DSI_CMD_MODE:
  643. *dst_format = DSI_CMD_DST_FORMAT_RGB565;
  644. break;
  645. default:
  646. *dst_format = DSI_VIDEO_DST_FORMAT_RGB565;
  647. break;
  648. }
  649. break;
  650. case 18:
  651. switch (mipi_mode) {
  652. case DSI_VIDEO_MODE:
  653. if (pixel_packing == 0)
  654. *dst_format = DSI_VIDEO_DST_FORMAT_RGB666;
  655. else
  656. *dst_format = DSI_VIDEO_DST_FORMAT_RGB666_LOOSE;
  657. break;
  658. case DSI_CMD_MODE:
  659. *dst_format = DSI_CMD_DST_FORMAT_RGB666;
  660. break;
  661. default:
  662. if (pixel_packing == 0)
  663. *dst_format = DSI_VIDEO_DST_FORMAT_RGB666;
  664. else
  665. *dst_format = DSI_VIDEO_DST_FORMAT_RGB666_LOOSE;
  666. break;
  667. }
  668. break;
  669. case 24:
  670. switch (mipi_mode) {
  671. case DSI_VIDEO_MODE:
  672. *dst_format = DSI_VIDEO_DST_FORMAT_RGB888;
  673. break;
  674. case DSI_CMD_MODE:
  675. *dst_format = DSI_CMD_DST_FORMAT_RGB888;
  676. break;
  677. default:
  678. *dst_format = DSI_VIDEO_DST_FORMAT_RGB888;
  679. break;
  680. }
  681. break;
  682. default:
  683. rc = -EINVAL;
  684. break;
  685. }
  686. return rc;
  687. }
  688. static int mdss_panel_parse_dt_gpio(struct device_node *np,
  689. struct mdss_dsi_ctrl_pdata *ctrl_pdata)
  690. {
  691. int rc = 0;
  692. msd.lcd_en_gpio = of_get_named_gpio(np,
  693. "qcom,lcd-en-gpio", 0);
  694. if (!gpio_is_valid(msd.lcd_en_gpio)) {
  695. pr_err("%s:%d lcd_en_gpio gpio not specified\n",
  696. __func__, __LINE__);
  697. } else {
  698. rc = gpio_request(msd.lcd_en_gpio, "lcd_enable");
  699. if (rc) {
  700. pr_err("request lcd_en_gpio failed, rc=%d\n",
  701. rc);
  702. gpio_free(msd.lcd_en_gpio);
  703. }
  704. }
  705. msd.bl_rst_gpio= of_get_named_gpio(np,
  706. "qcom,bl-rst-gpio", 0);
  707. if (!gpio_is_valid(msd.bl_rst_gpio)) {
  708. pr_err("%s:%d, bl_rst gpio not specified\n",
  709. __func__, __LINE__);
  710. } else {
  711. rc = gpio_request(msd.bl_rst_gpio, "bl_rst");
  712. if (rc) {
  713. pr_err("request bl_rst gpio failed, rc=%d\n",
  714. rc);
  715. gpio_free(msd.bl_rst_gpio);
  716. }else{
  717. rc = gpio_tlmm_config(GPIO_CFG(msd.bl_rst_gpio, 0,
  718. GPIO_CFG_OUTPUT,GPIO_CFG_NO_PULL,GPIO_CFG_2MA),
  719. GPIO_CFG_ENABLE);
  720. if (rc) {
  721. pr_err("request bl_rst failed, rc=%d\n",rc);
  722. }
  723. }
  724. }
  725. msd.bl_ap_pwm= of_get_named_gpio(np,
  726. "qcom,bl-wled", 0);
  727. if (!gpio_is_valid(msd.bl_ap_pwm)) {
  728. pr_err("%s:%d, bl_ap_pwm gpio not specified\n",
  729. __func__, __LINE__);
  730. } else {
  731. rc = gpio_request(msd.bl_ap_pwm, "bl_ap_pwm");
  732. if (rc) {
  733. pr_err("request bl_ap_pwm gpio failed, rc=%d\n",
  734. rc);
  735. gpio_free(msd.bl_ap_pwm);
  736. }else{
  737. rc = gpio_tlmm_config(GPIO_CFG(msd.bl_ap_pwm, 3,
  738. GPIO_CFG_OUTPUT,GPIO_CFG_NO_PULL,GPIO_CFG_2MA),
  739. GPIO_CFG_ENABLE);
  740. if (rc) {
  741. pr_err("request bl_ap_pwm gpio failed, rc=%d\n",rc);
  742. }
  743. }
  744. }
  745. msd.bl_ldi_en = of_get_named_gpio(np,
  746. "qcom,lcd_ldi_int", 0);
  747. if (!gpio_is_valid(msd.bl_ldi_en)) {
  748. pr_err("%s:%d, bl_rst gpio not specified\n",
  749. __func__, __LINE__);
  750. } else {
  751. rc = gpio_request(msd.bl_ldi_en, "bl_ldi_en");
  752. if (rc) {
  753. pr_err("request bl_ldi_en gpio failed, rc=%d\n",
  754. rc);
  755. gpio_free(msd.bl_ldi_en);
  756. } else {
  757. if(system_rev>4)
  758. rc = gpio_tlmm_config(GPIO_CFG(msd.bl_ldi_en, 0,
  759. GPIO_CFG_INPUT,GPIO_CFG_PULL_DOWN,GPIO_CFG_2MA),
  760. GPIO_CFG_DISABLE);
  761. else
  762. rc = gpio_tlmm_config(GPIO_CFG(msd.bl_ldi_en, 0,
  763. GPIO_CFG_INPUT,GPIO_CFG_NO_PULL,GPIO_CFG_2MA),
  764. GPIO_CFG_ENABLE);
  765. if (rc)
  766. pr_err("tlmm config bl_ldi_en failed, rc=%d\n",rc);
  767. }
  768. }
  769. msd.bl_sda = of_get_named_gpio(np,
  770. "qcom,bl-sda-gpio", 0);
  771. if (!gpio_is_valid(msd.bl_sda)) {
  772. pr_err("%s:%d, bl_sda gpio not specified\n",
  773. __func__, __LINE__);
  774. } else {
  775. rc=gpio_tlmm_config(GPIO_CFG(msd.bl_sda, 0,
  776. GPIO_CFG_INPUT,GPIO_CFG_NO_PULL,GPIO_CFG_2MA),
  777. GPIO_CFG_ENABLE);
  778. if (rc)
  779. pr_err("tlmm config bl_sda failed, rc=%d\n",rc);
  780. }
  781. msd.bl_scl = of_get_named_gpio(np,
  782. "qcom,bl-scl-gpio", 0);
  783. if (!gpio_is_valid(msd.bl_scl)) {
  784. pr_err("%s:%d, bl_scl gpio not specified\n",
  785. __func__, __LINE__);
  786. } else {
  787. rc=gpio_tlmm_config(GPIO_CFG(msd.bl_scl, 0,
  788. GPIO_CFG_INPUT,GPIO_CFG_NO_PULL,GPIO_CFG_2MA),
  789. GPIO_CFG_ENABLE);
  790. if (rc)
  791. pr_err("tlmm config bl_scl failed, rc=%d\n",rc);
  792. }
  793. return 0;
  794. }
  795. static int mdss_dsi_parse_fbc_params(struct device_node *np,
  796. struct mdss_panel_info *panel_info)
  797. {
  798. int rc, fbc_enabled = 0;
  799. u32 tmp;
  800. fbc_enabled = of_property_read_bool(np, "qcom,mdss-dsi-fbc-enable");
  801. if (fbc_enabled) {
  802. pr_debug("%s:%d FBC panel enabled.\n", __func__, __LINE__);
  803. panel_info->fbc.enabled = 1;
  804. rc = of_property_read_u32(np, "qcom,mdss-dsi-fbc-bpp", &tmp);
  805. panel_info->fbc.target_bpp = (!rc ? tmp : panel_info->bpp);
  806. rc = of_property_read_u32(np, "qcom,mdss-dsi-fbc-packing",
  807. &tmp);
  808. panel_info->fbc.comp_mode = (!rc ? tmp : 0);
  809. panel_info->fbc.qerr_enable = of_property_read_bool(np,
  810. "qcom,mdss-dsi-fbc-quant-error");
  811. rc = of_property_read_u32(np, "qcom,mdss-dsi-fbc-bias", &tmp);
  812. panel_info->fbc.cd_bias = (!rc ? tmp : 0);
  813. panel_info->fbc.pat_enable = of_property_read_bool(np,
  814. "qcom,mdss-dsi-fbc-pat-mode");
  815. panel_info->fbc.vlc_enable = of_property_read_bool(np,
  816. "qcom,mdss-dsi-fbc-vlc-mode");
  817. panel_info->fbc.bflc_enable = of_property_read_bool(np,
  818. "qcom,mdss-dsi-fbc-bflc-mode");
  819. rc = of_property_read_u32(np, "qcom,mdss-dsi-fbc-h-line-budget",
  820. &tmp);
  821. panel_info->fbc.line_x_budget = (!rc ? tmp : 0);
  822. rc = of_property_read_u32(np, "qcom,mdss-dsi-fbc-budget-ctrl",
  823. &tmp);
  824. panel_info->fbc.block_x_budget = (!rc ? tmp : 0);
  825. rc = of_property_read_u32(np, "qcom,mdss-dsi-fbc-block-budget",
  826. &tmp);
  827. panel_info->fbc.block_budget = (!rc ? tmp : 0);
  828. rc = of_property_read_u32(np,
  829. "qcom,mdss-dsi-fbc-lossless-threshold", &tmp);
  830. panel_info->fbc.lossless_mode_thd = (!rc ? tmp : 0);
  831. rc = of_property_read_u32(np,
  832. "qcom,mdss-dsi-fbc-lossy-threshold", &tmp);
  833. panel_info->fbc.lossy_mode_thd = (!rc ? tmp : 0);
  834. rc = of_property_read_u32(np, "qcom,mdss-dsi-fbc-rgb-threshold",
  835. &tmp);
  836. panel_info->fbc.lossy_rgb_thd = (!rc ? tmp : 0);
  837. rc = of_property_read_u32(np,
  838. "qcom,mdss-dsi-fbc-lossy-mode-idx", &tmp);
  839. panel_info->fbc.lossy_mode_idx = (!rc ? tmp : 0);
  840. } else {
  841. pr_debug("%s:%d Panel does not support FBC.\n",
  842. __func__, __LINE__);
  843. panel_info->fbc.enabled = 0;
  844. panel_info->fbc.target_bpp =
  845. panel_info->bpp;
  846. }
  847. return 0;
  848. }
  849. static int mdss_panel_parse_dt(struct device_node *np,
  850. struct mdss_dsi_ctrl_pdata *ctrl_pdata)
  851. {
  852. u32 tmp;
  853. int rc, i, len;
  854. const char *data;
  855. static const char *pdest;
  856. struct mdss_panel_info *pinfo = &(ctrl_pdata->panel_data.panel_info);
  857. rc = of_property_read_u32(np, "qcom,mdss-dsi-panel-width", &tmp);
  858. if (rc) {
  859. pr_err("%s:%d, panel width not specified\n",
  860. __func__, __LINE__);
  861. return -EINVAL;
  862. }
  863. pinfo->xres = (!rc ? tmp : 640);
  864. rc = of_property_read_u32(np, "qcom,mdss-dsi-panel-height", &tmp);
  865. if (rc) {
  866. pr_err("%s:%d, panel height not specified\n",
  867. __func__, __LINE__);
  868. return -EINVAL;
  869. }
  870. pinfo->yres = (!rc ? tmp : 480);
  871. rc = of_property_read_u32(np,
  872. "qcom,mdss-pan-physical-width-dimension", &tmp);
  873. pinfo->physical_width = (!rc ? tmp : 0);
  874. rc = of_property_read_u32(np,
  875. "qcom,mdss-pan-physical-height-dimension", &tmp);
  876. pinfo->physical_height = (!rc ? tmp : 0);
  877. rc = of_property_read_u32(np, "qcom,mdss-dsi-h-left-border", &tmp);
  878. pinfo->lcdc.xres_pad = (!rc ? tmp : 0);
  879. rc = of_property_read_u32(np, "qcom,mdss-dsi-h-right-border", &tmp);
  880. if (!rc)
  881. pinfo->lcdc.xres_pad += tmp;
  882. rc = of_property_read_u32(np, "qcom,mdss-dsi-v-top-border", &tmp);
  883. pinfo->lcdc.yres_pad = (!rc ? tmp : 0);
  884. rc = of_property_read_u32(np, "qcom,mdss-dsi-v-bottom-border", &tmp);
  885. if (!rc)
  886. pinfo->lcdc.yres_pad += tmp;
  887. rc = of_property_read_u32(np, "qcom,mdss-dsi-bpp", &tmp);
  888. if (rc) {
  889. pr_err("%s:%d, bpp not specified\n", __func__, __LINE__);
  890. return -EINVAL;
  891. }
  892. pinfo->bpp = (!rc ? tmp : 24);
  893. pinfo->mipi.mode = DSI_VIDEO_MODE;
  894. data = of_get_property(np, "qcom,mdss-dsi-panel-type", NULL);
  895. if (data && !strncmp(data, "dsi_cmd_mode", 12))
  896. pinfo->mipi.mode = DSI_CMD_MODE;
  897. rc = of_property_read_u32(np, "qcom,mdss-dsi-pixel-packing", &tmp);
  898. tmp = (!rc ? tmp : 0);
  899. rc = mdss_panel_dt_get_dst_fmt(pinfo->bpp,
  900. pinfo->mipi.mode, tmp,
  901. &(pinfo->mipi.dst_format));
  902. if (rc) {
  903. pr_debug("%s: problem determining dst format. Set Default\n",
  904. __func__);
  905. pinfo->mipi.dst_format =
  906. DSI_VIDEO_DST_FORMAT_RGB888;
  907. }
  908. pdest = of_get_property(np,
  909. "qcom,mdss-dsi-panel-destination", NULL);
  910. if (strlen(pdest) != 9) {
  911. pr_err("%s: Unknown pdest specified\n", __func__);
  912. return -EINVAL;
  913. }
  914. if (!strncmp(pdest, "display_1", 9))
  915. pinfo->pdest = DISPLAY_1;
  916. else if (!strncmp(pdest, "display_2", 9))
  917. pinfo->pdest = DISPLAY_2;
  918. else {
  919. pr_debug("%s: pdest not specified. Set Default\n",
  920. __func__);
  921. pinfo->pdest = DISPLAY_1;
  922. }
  923. rc = of_property_read_u32(np, "qcom,mdss-dsi-h-front-porch", &tmp);
  924. pinfo->lcdc.h_front_porch = (!rc ? tmp : 6);
  925. rc = of_property_read_u32(np, "qcom,mdss-dsi-h-back-porch", &tmp);
  926. pinfo->lcdc.h_back_porch = (!rc ? tmp : 6);
  927. rc = of_property_read_u32(np, "qcom,mdss-dsi-h-pulse-width", &tmp);
  928. pinfo->lcdc.h_pulse_width = (!rc ? tmp : 2);
  929. rc = of_property_read_u32(np, "qcom,mdss-dsi-h-sync-skew", &tmp);
  930. pinfo->lcdc.hsync_skew = (!rc ? tmp : 0);
  931. rc = of_property_read_u32(np, "qcom,mdss-dsi-v-back-porch", &tmp);
  932. pinfo->lcdc.v_back_porch = (!rc ? tmp : 6);
  933. rc = of_property_read_u32(np, "qcom,mdss-dsi-v-front-porch", &tmp);
  934. pinfo->lcdc.v_front_porch = (!rc ? tmp : 6);
  935. rc = of_property_read_u32(np, "qcom,mdss-dsi-v-pulse-width", &tmp);
  936. pinfo->lcdc.v_pulse_width = (!rc ? tmp : 2);
  937. rc = of_property_read_u32(np,
  938. "qcom,mdss-dsi-underflow-color", &tmp);
  939. pinfo->lcdc.underflow_clr = (!rc ? tmp : 0xff);
  940. rc = of_property_read_u32(np,
  941. "qcom,mdss-dsi-border-color", &tmp);
  942. pinfo->lcdc.border_clr = (!rc ? tmp : 0);
  943. pinfo->bklt_ctrl = UNKNOWN_CTRL;
  944. data = of_get_property(np, "qcom,mdss-dsi-bl-pmic-control-type", NULL);
  945. if (data) {
  946. if (!strncmp(data, "bl_ctrl_wled", 12)) {
  947. led_trigger_register_simple("bkl-trigger",
  948. &bl_led_trigger);
  949. pr_debug("%s: SUCCESS-> WLED TRIGGER register\n",
  950. __func__);
  951. ctrl_pdata->bklt_ctrl = BL_WLED;
  952. } else if (!strncmp(data, "bl_ctrl_pwm", 11)) {
  953. ctrl_pdata->bklt_ctrl = BL_PWM;
  954. } else if (!strncmp(data, "bl_ctrl_dcs", 11)) {
  955. ctrl_pdata->bklt_ctrl = BL_DCS_CMD;
  956. }
  957. }
  958. rc = of_property_read_u32(np, "qcom,mdss-brightness-max-level", &tmp);
  959. pinfo->brightness_max = (!rc ? tmp : MDSS_MAX_BL_BRIGHTNESS);
  960. rc = of_property_read_u32(np, "qcom,mdss-dsi-bl-min-level", &tmp);
  961. pinfo->bl_min = (!rc ? tmp : 0);
  962. rc = of_property_read_u32(np, "qcom,mdss-dsi-bl-max-level", &tmp);
  963. pinfo->bl_max = (!rc ? tmp : 255);
  964. ctrl_pdata->bklt_max = pinfo->bl_max;
  965. rc = of_property_read_u32(np, "qcom,mdss-dsi-interleave-mode", &tmp);
  966. pinfo->mipi.interleave_mode = (!rc ? tmp : 0);
  967. pinfo->mipi.vsync_enable = of_property_read_bool(np,
  968. "qcom,mdss-dsi-te-check-enable");
  969. pinfo->mipi.hw_vsync_mode = of_property_read_bool(np,
  970. "qcom,mdss-dsi-te-using-te-pin");
  971. rc = of_property_read_u32(np,
  972. "qcom,mdss-dsi-h-sync-pulse", &tmp);
  973. pinfo->mipi.pulse_mode_hsa_he = (!rc ? tmp : false);
  974. pinfo->mipi.hfp_power_stop = of_property_read_bool(np,
  975. "qcom,mdss-dsi-hfp-power-mode");
  976. pinfo->mipi.hsa_power_stop = of_property_read_bool(np,
  977. "qcom,mdss-dsi-hsa-power-mode");
  978. pinfo->mipi.hbp_power_stop = of_property_read_bool(np,
  979. "qcom,mdss-dsi-hbp-power-mode");
  980. pinfo->mipi.bllp_power_stop = of_property_read_bool(np,
  981. "qcom,mdss-dsi-bllp-power-mode");
  982. pinfo->mipi.eof_bllp_power_stop = of_property_read_bool(
  983. np, "qcom,mdss-dsi-bllp-eof-power-mode");
  984. rc = of_property_read_u32(np,
  985. "qcom,mdss-dsi-traffic-mode", &tmp);
  986. pinfo->mipi.traffic_mode =
  987. (!rc ? tmp : DSI_NON_BURST_SYNCH_PULSE);
  988. rc = of_property_read_u32(np,
  989. "qcom,mdss-dsi-te-dcs-command", &tmp);
  990. pinfo->mipi.insert_dcs_cmd =
  991. (!rc ? tmp : 1);
  992. rc = of_property_read_u32(np,
  993. "qcom,mdss-dsi-te-v-sync-continue-lines", &tmp);
  994. pinfo->mipi.wr_mem_continue =
  995. (!rc ? tmp : 0x3c);
  996. rc = of_property_read_u32(np,
  997. "qcom,mdss-dsi-te-v-sync-rd-ptr-irq-line", &tmp);
  998. pinfo->mipi.wr_mem_start =
  999. (!rc ? tmp : 0x2c);
  1000. rc = of_property_read_u32(np,
  1001. "qcom,mdss-dsi-te-pin-select", &tmp);
  1002. pinfo->mipi.te_sel =
  1003. (!rc ? tmp : 1);
  1004. rc = of_property_read_u32(np, "qcom,mdss-dsi-virtual-channel-id", &tmp);
  1005. pinfo->mipi.vc = (!rc ? tmp : 0);
  1006. rc = of_property_read_u32(np, "qcom,mdss-dsi-color-order", &tmp);
  1007. pinfo->mipi.rgb_swap = (!rc ? tmp : DSI_RGB_SWAP_RGB);
  1008. rc = of_property_read_u32(np, "qcom,mdss-force-clk-lane-hs", &tmp);
  1009. pinfo->mipi.force_clk_lane_hs = (!rc ? tmp : 0);
  1010. pinfo->mipi.data_lane0 = of_property_read_bool(np,
  1011. "qcom,mdss-dsi-lane-0-state");
  1012. pinfo->mipi.data_lane1 = of_property_read_bool(np,
  1013. "qcom,mdss-dsi-lane-1-state");
  1014. pinfo->mipi.data_lane2 = of_property_read_bool(np,
  1015. "qcom,mdss-dsi-lane-2-state");
  1016. pinfo->mipi.data_lane3 = of_property_read_bool(np,
  1017. "qcom,mdss-dsi-lane-3-state");
  1018. rc = of_property_read_u32(np, "qcom,mdss-dsi-lane-map", &tmp);
  1019. pinfo->mipi.dlane_swap = (!rc ? tmp : 0);
  1020. rc = of_property_read_u32(np, "qcom,mdss-dsi-t-clk-pre", &tmp);
  1021. pinfo->mipi.t_clk_pre = (!rc ? tmp : 0x24);
  1022. rc = of_property_read_u32(np, "qcom,mdss-dsi-t-clk-post", &tmp);
  1023. pinfo->mipi.t_clk_post = (!rc ? tmp : 0x03);
  1024. rc = of_property_read_u32(np, "qcom,mdss-dsi-stream", &tmp);
  1025. pinfo->mipi.stream = (!rc ? tmp : 0);
  1026. rc = of_property_read_u32(np, "qcom,mdss-dsi-mdp-trigger", &tmp);
  1027. pinfo->mipi.mdp_trigger =
  1028. (!rc ? tmp : DSI_CMD_TRIGGER_SW);
  1029. if (pinfo->mipi.mdp_trigger > 6) {
  1030. pr_err("%s:%d, Invalid mdp trigger. Forcing to sw trigger",
  1031. __func__, __LINE__);
  1032. pinfo->mipi.mdp_trigger =
  1033. DSI_CMD_TRIGGER_SW;
  1034. }
  1035. rc = of_property_read_u32(np, "qcom,mdss-dsi-dma-trigger", &tmp);
  1036. pinfo->mipi.dma_trigger =
  1037. (!rc ? tmp : DSI_CMD_TRIGGER_SW);
  1038. if (pinfo->mipi.dma_trigger > 6) {
  1039. pr_err("%s:%d, Invalid dma trigger. Forcing to sw trigger",
  1040. __func__, __LINE__);
  1041. pinfo->mipi.dma_trigger =
  1042. DSI_CMD_TRIGGER_SW;
  1043. }
  1044. data = of_get_property(np, "qcom,mdss-dsi-panel-mode-gpio-state", &tmp);
  1045. if (data) {
  1046. if (!strcmp(data, "high"))
  1047. pinfo->mode_gpio_state = MODE_GPIO_HIGH;
  1048. else if (!strcmp(data, "low"))
  1049. pinfo->mode_gpio_state = MODE_GPIO_LOW;
  1050. } else {
  1051. pinfo->mode_gpio_state = MODE_GPIO_NOT_VALID;
  1052. }
  1053. rc = of_property_read_u32(np, "qcom,mdss-dsi-panel-frame-rate", &tmp);
  1054. pinfo->mipi.frame_rate = (!rc ? tmp : 60);
  1055. rc = of_property_read_u32(np, "qcom,mdss-dsi-panel-clock-rate", &tmp);
  1056. pinfo->clk_rate = (!rc ? tmp : 0);
  1057. data = of_get_property(np,
  1058. "qcom,platform-strength-ctrl", &len);
  1059. if ((!data) || (len != 2)) {
  1060. pr_err("%s:%d, Unable to read Phy Strength ctrl settings",
  1061. __func__, __LINE__);
  1062. return -EINVAL;
  1063. }
  1064. pinfo->mipi.dsi_phy_db.strength[0] = data[0];
  1065. pinfo->mipi.dsi_phy_db.strength[1] = data[1];
  1066. data = of_get_property(np,
  1067. "qcom,platform-regulator-settings", &len);
  1068. if ((!data) || (len != 7)) {
  1069. pr_err("%s:%d, Unable to read Phy regulator settings",
  1070. __func__, __LINE__);
  1071. return -EINVAL;
  1072. }
  1073. for (i = 0; i < len; i++) {
  1074. pinfo->mipi.dsi_phy_db.regulator[i]
  1075. = data[i];
  1076. }
  1077. data = of_get_property(np, "qcom,mdss-dsi-panel-timings", &len);
  1078. if ((!data) || (len != 12)) {
  1079. pr_err("%s:%d, Unable to read Phy timing settings",
  1080. __func__, __LINE__);
  1081. goto error;
  1082. }
  1083. for (i = 0; i < len; i++)
  1084. pinfo->mipi.dsi_phy_db.timing[i] = data[i];
  1085. pinfo->mipi.lp11_init = of_property_read_bool(np,
  1086. "qcom,mdss-dsi-lp11-init");
  1087. rc = of_property_read_u32(np, "qcom,mdss-dsi-init-delay-us", &tmp);
  1088. pinfo->mipi.init_delay = (!rc ? tmp : 0);
  1089. mdss_dsi_parse_fbc_params(np, pinfo);
  1090. mdss_dsi_parse_dcs_cmds(np, &ctrl_pdata->on_cmds,
  1091. "qcom,mdss-dsi-on-command", "qcom,mdss-dsi-on-command-state");
  1092. mdss_dsi_parse_dcs_cmds(np, &ctrl_pdata->off_cmds,
  1093. "qcom,mdss-dsi-off-command", "qcom,mdss-dsi-off-command-state");
  1094. return 0;
  1095. error:
  1096. return -EINVAL;
  1097. }
  1098. #if defined(CONFIG_LCD_CLASS_DEVICE)
  1099. static ssize_t mdss_dsi_disp_get_power(struct device *dev,
  1100. struct device_attribute *attr, char *buf)
  1101. {
  1102. pr_info("mipi_samsung_disp_get_power(0)\n");
  1103. return 0;
  1104. }
  1105. static ssize_t mdss_dsi_disp_set_power(struct device *dev,
  1106. struct device_attribute *attr, const char *buf, size_t size)
  1107. {
  1108. unsigned int power;
  1109. if (sscanf(buf, "%u", &power) != 1)
  1110. return -EINVAL;
  1111. pr_info("mipi_samsung_disp_set_power:%d\n",power);
  1112. return size;
  1113. }
  1114. static DEVICE_ATTR(lcd_power, S_IRUGO | S_IWUSR | S_IWGRP,
  1115. mdss_dsi_disp_get_power,
  1116. mdss_dsi_disp_set_power);
  1117. static struct lcd_ops mdss_dsi_disp_props = {
  1118. .get_power = NULL,
  1119. .set_power = NULL,
  1120. };
  1121. static ssize_t mdss_disp_lcdtype_show(struct device *dev,
  1122. struct device_attribute *attr, char *buf)
  1123. {
  1124. char temp[20];
  1125. snprintf(temp, 20, "SMD_LTL101AL06");
  1126. strncat(buf, temp, 20);
  1127. return strnlen(buf, 20);
  1128. }
  1129. static DEVICE_ATTR(lcd_type, S_IRUGO, mdss_disp_lcdtype_show, NULL);
  1130. #endif
  1131. #if defined(CONFIG_ESD_ERR_FG_RECOVERY)
  1132. static irqreturn_t err_fg_irq_handler(int irq, void *handle)
  1133. {
  1134. pr_info("%s : handler start", __func__);
  1135. disable_irq_nosync(err_fg_gpio);
  1136. schedule_work(&err_fg_work);
  1137. pr_info("%s : handler end", __func__);
  1138. return IRQ_HANDLED;
  1139. }
  1140. static void err_fg_work_func(struct work_struct *work)
  1141. {
  1142. int bl_backup;
  1143. struct mdss_panel_data *pdata = msd.mpd;
  1144. struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
  1145. int ret = 0;
  1146. if(msd.mfd == NULL){
  1147. pr_err("%s: mfd not initialized Skip ESD recovery\n", __func__);
  1148. return;
  1149. }
  1150. if(pdata == NULL){
  1151. pr_err("%s: pdata not available... skipping update\n", __func__);
  1152. return;
  1153. }
  1154. bl_backup=msd.mfd->bl_level;
  1155. if( msd.mfd->panel_power_on == false){
  1156. pr_err("%s: Display off Skip ESD recovery\n", __func__);
  1157. return;
  1158. }
  1159. ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  1160. panel_data);
  1161. pr_info("%s : start", __func__);
  1162. err_fg_working = 1;
  1163. ctrl_pdata->panel_reset(pdata, 0);
  1164. mdss_dsi_op_mode_config(DSI_CMD_MODE, pdata);
  1165. if (ctrl_pdata->ctrl_state & CTRL_STATE_PANEL_INIT) {
  1166. ret = ctrl_pdata->off(pdata);
  1167. if (ret) {
  1168. pr_err("%s: Panel OFF failed\n", __func__);
  1169. return;
  1170. }
  1171. ctrl_pdata->ctrl_state &= ~CTRL_STATE_PANEL_INIT;
  1172. }
  1173. msleep(10);
  1174. ctrl_pdata->panel_reset(pdata, 1);
  1175. if (!(ctrl_pdata->ctrl_state & CTRL_STATE_PANEL_INIT)) {
  1176. ret = ctrl_pdata->on(pdata);
  1177. if (ret) {
  1178. pr_err("%s: unable to initialize the panel\n",
  1179. __func__);
  1180. return;
  1181. }
  1182. ctrl_pdata->ctrl_state |= CTRL_STATE_PANEL_INIT;
  1183. }
  1184. esd_count++;
  1185. err_fg_working = 0;
  1186. mdss_dsi_panel_bl_ctrl(pdata, bl_backup);
  1187. pr_info("%s : end", __func__);
  1188. return;
  1189. }
  1190. #ifdef ESD_DEBUG
  1191. static ssize_t mipi_samsung_esd_check_show(struct device *dev,
  1192. struct device_attribute *attr, char *buf)
  1193. {
  1194. int rc;
  1195. rc = snprintf((char *)buf, 20, "esd count:%d \n",esd_count);
  1196. return rc;
  1197. }
  1198. static ssize_t mipi_samsung_esd_check_store(struct device *dev,
  1199. struct device_attribute *attr, const char *buf, size_t size)
  1200. {
  1201. struct msm_fb_data_type *mfd;
  1202. mfd = platform_get_drvdata(msd.msm_pdev);
  1203. err_fg_irq_handler(0, mfd);
  1204. return 1;
  1205. }
  1206. static DEVICE_ATTR(esd_check, S_IRUGO , mipi_samsung_esd_check_show,\
  1207. mipi_samsung_esd_check_store);
  1208. #endif
  1209. #endif
  1210. int get_samsung_lcd_attached(void)
  1211. {
  1212. return lcd_attached;
  1213. }
  1214. EXPORT_SYMBOL(get_samsung_lcd_attached);
  1215. static int __init get_lcd_id_cmdline(char *mode)
  1216. {
  1217. char *pt;
  1218. lcd_id = 0;
  1219. if( mode == NULL ) return 1;
  1220. for( pt = mode; *pt != 0; pt++ )
  1221. {
  1222. lcd_id <<= 4;
  1223. switch(*pt)
  1224. {
  1225. case '0' ... '9' :
  1226. lcd_id += *pt -'0';
  1227. break;
  1228. case 'a' ... 'f' :
  1229. lcd_id += 10 + *pt -'a';
  1230. break;
  1231. case 'A' ... 'F' :
  1232. lcd_id += 10 + *pt -'A';
  1233. break;
  1234. }
  1235. }
  1236. lcd_attached = ((lcd_id&0xFFFFFF)!=0x000000);
  1237. pr_info( "%s: LCD_ID = 0x%X, lcd_attached =%d", __func__,lcd_id, lcd_attached);
  1238. return 0;
  1239. }
  1240. __setup( "lcd_id=0x", get_lcd_id_cmdline );
  1241. int mdss_dsi_panel_init(struct device_node *node,
  1242. struct mdss_dsi_ctrl_pdata *ctrl_pdata,
  1243. bool cmd_cfg_cont_splash)
  1244. {
  1245. int rc = 0;
  1246. static const char *panel_name;
  1247. bool cont_splash_enabled;
  1248. bool partial_update_enabled;
  1249. #if defined(CONFIG_ESD_ERR_FG_RECOVERY)
  1250. int disp_esd_gpio;
  1251. #endif
  1252. #if defined(CONFIG_LCD_CLASS_DEVICE)
  1253. struct lcd_device *lcd_device;
  1254. #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE)
  1255. struct backlight_device *bd = NULL;
  1256. #endif
  1257. #endif
  1258. #if defined(CONFIG_LCD_CLASS_DEVICE)
  1259. struct device_node *np = NULL;
  1260. struct platform_device *pdev = NULL;
  1261. np = of_parse_phandle(node,
  1262. "qcom,mdss-dsi-panel-controller", 0);
  1263. if (!np) {
  1264. pr_err("%s: Dsi controller node not initialized\n", __func__);
  1265. return -EPROBE_DEFER;
  1266. }
  1267. pdev = of_find_device_by_node(np);
  1268. #endif
  1269. printk("%s: LCD attached status: %d !\n",
  1270. __func__, get_samsung_lcd_attached());
  1271. if (!node) {
  1272. pr_err("%s: no panel node\n", __func__);
  1273. return -ENODEV;
  1274. }
  1275. pr_debug("%s:%d\n", __func__, __LINE__);
  1276. panel_name = of_get_property(node, "qcom,mdss-dsi-panel-name", NULL);
  1277. if (!panel_name)
  1278. pr_info("%s:%d, Panel name not specified\n",
  1279. __func__, __LINE__);
  1280. else
  1281. pr_info("%s: Panel Name = %s\n", __func__, panel_name);
  1282. virt_mmss_gp0_base = ioremap(MMSS_GP0_BASE,MMSS_GP0_SIZE);
  1283. if(virt_mmss_gp0_base == NULL) {
  1284. pr_err("%s: I/O remap failed \n", __func__);
  1285. return 0;
  1286. }
  1287. rc = mdss_panel_parse_dt(node, ctrl_pdata);
  1288. if (rc) {
  1289. pr_err("%s:%d panel dt parse failed\n", __func__, __LINE__);
  1290. return rc;
  1291. }
  1292. rc = mdss_panel_parse_dt_gpio(node, ctrl_pdata);
  1293. if (rc) {
  1294. pr_err("%s:%d panel dt gpio parse failed\n", __func__, __LINE__);
  1295. return rc;
  1296. }
  1297. /*if (cmd_cfg_cont_splash)*/
  1298. cont_splash_enabled = of_property_read_bool(node,
  1299. "qcom,cont-splash-enabled");
  1300. /*else
  1301. cont_splash_enabled = false;*/
  1302. if (!cont_splash_enabled) {
  1303. pr_info("%s:%d Continuous splash flag not found.\n",
  1304. __func__, __LINE__);
  1305. ctrl_pdata->panel_data.panel_info.cont_splash_enabled = 0;
  1306. } else {
  1307. pr_info("%s:%d Continuous splash flag enabled.\n",
  1308. __func__, __LINE__);
  1309. ctrl_pdata->panel_data.panel_info.cont_splash_enabled = 1;
  1310. }
  1311. partial_update_enabled = of_property_read_bool(node,
  1312. "qcom,partial-update-enabled");
  1313. if (partial_update_enabled) {
  1314. pr_info("%s:%d Partial update enabled.\n", __func__, __LINE__);
  1315. ctrl_pdata->panel_data.panel_info.partial_update_enabled = 1;
  1316. ctrl_pdata->partial_update_fnc = mdss_dsi_panel_partial_update;
  1317. } else {
  1318. pr_info("%s:%d Partial update disabled.\n", __func__, __LINE__);
  1319. ctrl_pdata->panel_data.panel_info.partial_update_enabled = 0;
  1320. ctrl_pdata->partial_update_fnc = NULL;
  1321. }
  1322. ctrl_pdata->on = mdss_dsi_panel_on;
  1323. ctrl_pdata->off = mdss_dsi_panel_off;
  1324. ctrl_pdata->panel_reset = mdss_dsi_tc358764_panel_reset;
  1325. ctrl_pdata->panel_data.set_backlight = mdss_dsi_panel_bl_ctrl;
  1326. #if defined(CONFIG_LCD_CLASS_DEVICE)
  1327. lcd_device = lcd_device_register("panel", &pdev->dev, NULL,
  1328. &mdss_dsi_disp_props);
  1329. if (IS_ERR(lcd_device)) {
  1330. rc = PTR_ERR(lcd_device);
  1331. printk(KERN_ERR "lcd : failed to register device\n");
  1332. return rc;
  1333. }
  1334. sysfs_remove_file(&lcd_device->dev.kobj,&dev_attr_lcd_power.attr);
  1335. rc = sysfs_create_file(&lcd_device->dev.kobj,&dev_attr_lcd_power.attr);
  1336. if (rc) {
  1337. pr_info("sysfs create fail-%s\n",dev_attr_lcd_power.attr.name);
  1338. }
  1339. rc = sysfs_create_file(&lcd_device->dev.kobj,
  1340. &dev_attr_lcd_type.attr);
  1341. if (rc) {
  1342. pr_info("sysfs create fail-%s\n",
  1343. dev_attr_lcd_type.attr.name);
  1344. }
  1345. #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE)
  1346. bd = backlight_device_register("panel", &lcd_device->dev,
  1347. NULL, NULL, NULL);
  1348. if (IS_ERR(bd)) {
  1349. rc = PTR_ERR(bd);
  1350. pr_info("backlight : failed to register device\n");
  1351. return rc;
  1352. }
  1353. #endif
  1354. #endif
  1355. #if defined(CONFIG_MDNIE_TFT_MSM8X26)
  1356. pr_info("[%s] CONFIG_MDNIE_TFT feature ok ! initclass called!\n",__func__);
  1357. init_mdnie_class();
  1358. mdnie_tft_init(&msd);
  1359. #endif
  1360. #ifdef CONFIG_BACKLIGHT_LP8556
  1361. samsung_bl_init();
  1362. #endif
  1363. #if defined(CONFIG_ESD_ERR_FG_RECOVERY)
  1364. #ifdef ESD_DEBUG
  1365. rc = sysfs_create_file(&lcd_device->dev.kobj,
  1366. &dev_attr_esd_check.attr);
  1367. if (rc) {
  1368. pr_info("sysfs create fail-%s\n",
  1369. dev_attr_esd_check.attr.name);
  1370. }
  1371. #endif
  1372. msd.msm_pdev = pdev;
  1373. INIT_WORK(&err_fg_work, err_fg_work_func);
  1374. disp_esd_gpio =of_get_named_gpio(node,"qcom,oled-esd-gpio", 0);
  1375. err_fg_gpio = gpio_to_irq(disp_esd_gpio);
  1376. rc = gpio_request(disp_esd_gpio, "err_fg");
  1377. if (rc) {
  1378. pr_err("request gpio GPIO_ESD failed, ret=%d\n",rc);
  1379. gpio_free(disp_esd_gpio);
  1380. return rc;
  1381. }
  1382. gpio_tlmm_config(GPIO_CFG(disp_esd_gpio, 0, GPIO_CFG_INPUT,
  1383. GPIO_CFG_NO_PULL, GPIO_CFG_2MA),GPIO_CFG_ENABLE);
  1384. rc = gpio_direction_input(disp_esd_gpio);
  1385. if (unlikely(rc < 0)) {
  1386. pr_err("%s: failed to set gpio %d as input (%d)\n",
  1387. __func__, disp_esd_gpio, rc);
  1388. }
  1389. rc = request_threaded_irq(err_fg_gpio, NULL, err_fg_irq_handler,
  1390. IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "esd_detect", NULL);
  1391. if (rc) {
  1392. pr_err("%s : Failed to request_irq. :ret=%d", __func__, rc);
  1393. }
  1394. disable_irq(err_fg_gpio);
  1395. #endif
  1396. return 0;
  1397. }
  1398. #if defined(CONFIG_TC358764_I2C_CONTROL)
  1399. static int tc35876x_i2c_parse_dt(struct device *dev,
  1400. struct tc35876x_i2c_platform_data *pdata)
  1401. {
  1402. struct device_node *np = dev->of_node;
  1403. /* reset, irq gpio info */
  1404. pdata->gpio_scl = of_get_named_gpio_flags(np, "lvds,scl-gpio",
  1405. 0, &pdata->scl_gpio_flags);
  1406. pdata->gpio_sda = of_get_named_gpio_flags(np, "lvds,sda-gpio",
  1407. 0, &pdata->sda_gpio_flags);
  1408. pr_info("%s gpio_scl : %d , gpio_sda : %d ", __func__, pdata->gpio_scl, pdata->gpio_sda);
  1409. return 0;
  1410. }
  1411. static void tc35876x_i2c_request_gpio(struct tc35876x_i2c_platform_data *pdata)
  1412. {
  1413. gpio_tlmm_config(GPIO_CFG(pdata->gpio_scl, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), 1);
  1414. gpio_tlmm_config(GPIO_CFG(pdata->gpio_sda, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), 1);
  1415. }
  1416. static int __devinit tc35876x_i2c_probe(struct i2c_client *client,
  1417. const struct i2c_device_id *id)
  1418. {
  1419. struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
  1420. struct tc35876x_i2c_platform_data *pdata;
  1421. struct tc35876x_i2c_info *info;
  1422. int error = 0;
  1423. pr_info("%s", __func__);
  1424. if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
  1425. return -EIO;
  1426. if (client->dev.of_node) {
  1427. pdata = devm_kzalloc(&client->dev,
  1428. sizeof(struct tc35876x_i2c_platform_data),
  1429. GFP_KERNEL);
  1430. if (!pdata) {
  1431. dev_info(&client->dev, "Failed to allocate memory\n");
  1432. return -ENOMEM;
  1433. }
  1434. error = tc35876x_i2c_parse_dt(&client->dev, pdata);
  1435. if (error)
  1436. return error;
  1437. } else
  1438. pdata = client->dev.platform_data;
  1439. tc35876x_i2c_request_gpio(pdata);
  1440. i2c_info = info = kzalloc(sizeof(*info), GFP_KERNEL);
  1441. if (!info) {
  1442. dev_info(&client->dev, "%s: fail to memory allocation.\n", __func__);
  1443. return -ENOMEM;
  1444. }
  1445. info->client = client;
  1446. info->pdata = pdata;
  1447. i2c_set_clientdata(client, info);
  1448. return error;
  1449. }
  1450. static int __devexit tc35876x_i2c_remove(struct i2c_client *client)
  1451. {
  1452. return 0;
  1453. }
  1454. static const struct i2c_device_id tc35876x_i2c_id[] = {
  1455. {"lcd-i2c", 0},
  1456. {}
  1457. };
  1458. MODULE_DEVICE_TABLE(i2c, tc35876x_i2c_id);
  1459. static struct of_device_id tc35876x_i2c_match_table[] = {
  1460. { .compatible = "lcd,lvds-i2c",},
  1461. { },
  1462. };
  1463. MODULE_DEVICE_TABLE(of, tc35876x_i2c_id);
  1464. struct i2c_driver tc35876x_i2c_driver = {
  1465. .probe = tc35876x_i2c_probe,
  1466. .remove = tc35876x_i2c_remove,
  1467. .driver = {
  1468. .name = "tc35876x_i2c",
  1469. .owner = THIS_MODULE,
  1470. .of_match_table = tc35876x_i2c_match_table,
  1471. },
  1472. .id_table = tc35876x_i2c_id,
  1473. };
  1474. static int __init tc35876x_i2c_init(void)
  1475. {
  1476. int ret = 0;
  1477. ret = i2c_add_driver(&tc35876x_i2c_driver);
  1478. if (ret) {
  1479. printk(KERN_ERR "tc35876x_i2c_init registration failed. ret= %d\n",
  1480. ret);
  1481. }
  1482. return ret;
  1483. }
  1484. static void __exit tc35876x_i2c_exit(void)
  1485. {
  1486. i2c_del_driver(&tc35876x_i2c_driver);
  1487. }
  1488. module_init(tc35876x_i2c_init);
  1489. module_exit(tc35876x_i2c_exit);
  1490. MODULE_DESCRIPTION("tc35876x i2c driver");
  1491. MODULE_LICENSE("GPL");
  1492. #endif