2 * Copyright (C) 2012 Samsung Electronics
4 * Author: InKi Dae <inki.dae@samsung.com>
5 * Author: Donghwa Lee <dh09.lee@samsung.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 #include <linux/err.h>
26 #include <asm/arch/dsim.h>
27 #include <asm/arch/mipi_dsim.h>
28 #include <asm/arch/power.h>
29 #include <asm/arch/cpu.h>
30 #include <asm/arch/clk.h>
32 #include "exynos_mipi_dsi_lowlevel.h"
33 #include "exynos_mipi_dsi_common.h"
35 #define master_to_driver(a) (a->dsim_lcd_drv)
36 #define master_to_device(a) (a->dsim_lcd_dev)
38 static struct exynos_platform_mipi_dsim *dsim_pd;
40 struct mipi_dsim_ddi {
42 struct list_head list;
43 struct mipi_dsim_lcd_device *dsim_lcd_dev;
44 struct mipi_dsim_lcd_driver *dsim_lcd_drv;
47 static LIST_HEAD(dsim_ddi_list);
48 static LIST_HEAD(dsim_lcd_dev_list);
50 int exynos_mipi_dsi_register_lcd_device(struct mipi_dsim_lcd_device *lcd_dev)
52 struct mipi_dsim_ddi *dsim_ddi;
55 debug("mipi_dsim_lcd_device is NULL.\n");
60 debug("dsim_lcd_device name is NULL.\n");
64 dsim_ddi = kzalloc(sizeof(struct mipi_dsim_ddi), GFP_KERNEL);
66 debug("failed to allocate dsim_ddi object.\n");
70 dsim_ddi->dsim_lcd_dev = lcd_dev;
72 list_add_tail(&dsim_ddi->list, &dsim_ddi_list);
78 *exynos_mipi_dsi_find_lcd_device(struct mipi_dsim_lcd_driver *lcd_drv)
80 struct mipi_dsim_ddi *dsim_ddi;
81 struct mipi_dsim_lcd_device *lcd_dev;
83 list_for_each_entry(dsim_ddi, &dsim_ddi_list, list) {
84 lcd_dev = dsim_ddi->dsim_lcd_dev;
88 if (lcd_drv->id >= 0) {
89 if ((strcmp(lcd_drv->name, lcd_dev->name)) == 0 &&
90 lcd_drv->id == lcd_dev->id) {
92 * bus_id would be used to identify
95 dsim_ddi->bus_id = lcd_dev->bus_id;
100 if ((strcmp(lcd_drv->name, lcd_dev->name)) == 0) {
102 * bus_id would be used to identify
105 dsim_ddi->bus_id = lcd_dev->bus_id;
112 list_del(&dsim_ddi_list);
118 int exynos_mipi_dsi_register_lcd_driver(struct mipi_dsim_lcd_driver *lcd_drv)
120 struct mipi_dsim_ddi *dsim_ddi;
123 debug("mipi_dsim_lcd_driver is NULL.\n");
127 if (!lcd_drv->name) {
128 debug("dsim_lcd_driver name is NULL.\n");
132 dsim_ddi = exynos_mipi_dsi_find_lcd_device(lcd_drv);
134 debug("mipi_dsim_ddi object not found.\n");
138 dsim_ddi->dsim_lcd_drv = lcd_drv;
140 debug("registered panel driver(%s) to mipi-dsi driver.\n",
148 *exynos_mipi_dsi_bind_lcd_ddi(struct mipi_dsim_device *dsim,
151 struct mipi_dsim_ddi *dsim_ddi;
152 struct mipi_dsim_lcd_driver *lcd_drv;
153 struct mipi_dsim_lcd_device *lcd_dev;
155 list_for_each_entry(dsim_ddi, &dsim_ddi_list, list) {
156 lcd_drv = dsim_ddi->dsim_lcd_drv;
157 lcd_dev = dsim_ddi->dsim_lcd_dev;
158 if (!lcd_drv || !lcd_dev)
161 debug("lcd_drv->id = %d, lcd_dev->id = %d\n",
162 lcd_drv->id, lcd_dev->id);
164 if ((strcmp(lcd_drv->name, name) == 0)) {
165 lcd_dev->master = dsim;
167 dsim->dsim_lcd_dev = lcd_dev;
168 dsim->dsim_lcd_drv = lcd_drv;
177 /* define MIPI-DSI Master operations. */
178 static struct mipi_dsim_master_ops master_ops = {
179 .cmd_write = exynos_mipi_dsi_wr_data,
180 .get_dsim_frame_done = exynos_mipi_dsi_get_frame_done_status,
181 .clear_dsim_frame_done = exynos_mipi_dsi_clear_frame_done,
184 int exynos_mipi_dsi_init(void)
186 struct mipi_dsim_device *dsim;
187 struct mipi_dsim_config *dsim_config;
188 struct mipi_dsim_ddi *dsim_ddi;
190 dsim = kzalloc(sizeof(struct mipi_dsim_device), GFP_KERNEL);
192 debug("failed to allocate dsim object.\n");
196 /* get mipi_dsim_config. */
197 dsim_config = dsim_pd->dsim_config;
198 if (dsim_config == NULL) {
199 debug("failed to get dsim config data.\n");
204 dsim->dsim_config = dsim_config;
205 dsim->master_ops = &master_ops;
207 /* bind lcd ddi matched with panel name. */
208 dsim_ddi = exynos_mipi_dsi_bind_lcd_ddi(dsim, dsim_pd->lcd_panel_name);
210 debug("mipi_dsim_ddi object not found.\n");
213 if (dsim_pd->lcd_power)
214 dsim_pd->lcd_power();
216 if (dsim_pd->mipi_power)
217 dsim_pd->mipi_power();
219 /* phy_enable(unsigned int dev_index, unsigned int enable) */
220 if (dsim_pd->phy_enable)
221 dsim_pd->phy_enable(0, 1);
225 exynos_mipi_dsi_init_dsim(dsim);
226 exynos_mipi_dsi_init_link(dsim);
227 exynos_mipi_dsi_set_hs_enable(dsim);
229 /* set display timing. */
230 exynos_mipi_dsi_set_display_mode(dsim, dsim->dsim_config);
232 /* initialize mipi-dsi client(lcd panel). */
233 if (dsim_ddi->dsim_lcd_drv && dsim_ddi->dsim_lcd_drv->mipi_panel_init) {
234 dsim_ddi->dsim_lcd_drv->mipi_panel_init(dsim);
235 dsim_ddi->dsim_lcd_drv->mipi_display_on(dsim);
238 debug("mipi-dsi driver(%s mode) has been probed.\n",
239 (dsim_config->e_interface == DSIM_COMMAND) ?
245 void exynos_set_dsim_platform_data(struct exynos_platform_mipi_dsim *pd)
248 debug("pd is NULL\n");