aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoungJun Cho <yj44.cho@samsung.com>2014-07-17 05:01:23 -0400
committerInki Dae <daeinki@gmail.com>2014-08-03 03:52:16 -0400
commit9a3204156b75c435559dd6e0fe4b236184751600 (patch)
tree524259dddf652c34b11e30be46c996bdbd894bcf
parent88dc66ccf5380eeb1be5b24cc2b2f8b35a166417 (diff)
drm/exynos: dsi: add driver data to support Exynos5410/5420/5440 SoCs
The offset of register DSIM_PLLTMR_REG in Exynos5410 / 5420 / 5440 SoCs is different from the one in Exynos4 SoCs. In case of Exynos5410 / 5420 / 5440 SoCs, there is no frequency band bit in DSIM_PLLCTRL_REG, and it uses DSIM_PHYCTRL_REG and DSIM_PHYTIMING*_REG instead. So this patch adds driver data to distinguish it. Signed-off-by: YoungJun Cho <yj44.cho@samsung.com> Acked-by: Inki Dae <inki.dae@samsung.com> Acked-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Inki Dae <inki.dae@samsung.com>
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_dsi.c157
1 files changed, 135 insertions, 22 deletions
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
index a19107af1c3b..5e78d4534d1c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
@@ -18,6 +18,7 @@
18#include <linux/clk.h> 18#include <linux/clk.h>
19#include <linux/gpio/consumer.h> 19#include <linux/gpio/consumer.h>
20#include <linux/irq.h> 20#include <linux/irq.h>
21#include <linux/of_device.h>
21#include <linux/of_gpio.h> 22#include <linux/of_gpio.h>
22#include <linux/phy/phy.h> 23#include <linux/phy/phy.h>
23#include <linux/regulator/consumer.h> 24#include <linux/regulator/consumer.h>
@@ -57,9 +58,12 @@
57 58
58/* FIFO memory AC characteristic register */ 59/* FIFO memory AC characteristic register */
59#define DSIM_PLLCTRL_REG 0x4c /* PLL control register */ 60#define DSIM_PLLCTRL_REG 0x4c /* PLL control register */
60#define DSIM_PLLTMR_REG 0x50 /* PLL timer register */
61#define DSIM_PHYACCHR_REG 0x54 /* D-PHY AC characteristic register */ 61#define DSIM_PHYACCHR_REG 0x54 /* D-PHY AC characteristic register */
62#define DSIM_PHYACCHR1_REG 0x58 /* D-PHY AC characteristic register1 */ 62#define DSIM_PHYACCHR1_REG 0x58 /* D-PHY AC characteristic register1 */
63#define DSIM_PHYCTRL_REG 0x5c
64#define DSIM_PHYTIMING_REG 0x64
65#define DSIM_PHYTIMING1_REG 0x68
66#define DSIM_PHYTIMING2_REG 0x6c
63 67
64/* DSIM_STATUS */ 68/* DSIM_STATUS */
65#define DSIM_STOP_STATE_DAT(x) (((x) & 0xf) << 0) 69#define DSIM_STOP_STATE_DAT(x) (((x) & 0xf) << 0)
@@ -203,6 +207,24 @@
203#define DSIM_PLL_M(x) ((x) << 4) 207#define DSIM_PLL_M(x) ((x) << 4)
204#define DSIM_PLL_S(x) ((x) << 1) 208#define DSIM_PLL_S(x) ((x) << 1)
205 209
210/* DSIM_PHYCTRL */
211#define DSIM_PHYCTRL_ULPS_EXIT(x) (((x) & 0x1ff) << 0)
212
213/* DSIM_PHYTIMING */
214#define DSIM_PHYTIMING_LPX(x) ((x) << 8)
215#define DSIM_PHYTIMING_HS_EXIT(x) ((x) << 0)
216
217/* DSIM_PHYTIMING1 */
218#define DSIM_PHYTIMING1_CLK_PREPARE(x) ((x) << 24)
219#define DSIM_PHYTIMING1_CLK_ZERO(x) ((x) << 16)
220#define DSIM_PHYTIMING1_CLK_POST(x) ((x) << 8)
221#define DSIM_PHYTIMING1_CLK_TRAIL(x) ((x) << 0)
222
223/* DSIM_PHYTIMING2 */
224#define DSIM_PHYTIMING2_HS_PREPARE(x) ((x) << 16)
225#define DSIM_PHYTIMING2_HS_ZERO(x) ((x) << 8)
226#define DSIM_PHYTIMING2_HS_TRAIL(x) ((x) << 0)
227
206#define DSI_MAX_BUS_WIDTH 4 228#define DSI_MAX_BUS_WIDTH 4
207#define DSI_NUM_VIRTUAL_CHANNELS 4 229#define DSI_NUM_VIRTUAL_CHANNELS 4
208#define DSI_TX_FIFO_SIZE 2048 230#define DSI_TX_FIFO_SIZE 2048
@@ -236,6 +258,12 @@ struct exynos_dsi_transfer {
236#define DSIM_STATE_INITIALIZED BIT(1) 258#define DSIM_STATE_INITIALIZED BIT(1)
237#define DSIM_STATE_CMD_LPM BIT(2) 259#define DSIM_STATE_CMD_LPM BIT(2)
238 260
261struct exynos_dsi_driver_data {
262 unsigned int plltmr_reg;
263
264 unsigned int has_freqband:1;
265};
266
239struct exynos_dsi { 267struct exynos_dsi {
240 struct mipi_dsi_host dsi_host; 268 struct mipi_dsi_host dsi_host;
241 struct drm_connector connector; 269 struct drm_connector connector;
@@ -266,11 +294,39 @@ struct exynos_dsi {
266 294
267 spinlock_t transfer_lock; /* protects transfer_list */ 295 spinlock_t transfer_lock; /* protects transfer_list */
268 struct list_head transfer_list; 296 struct list_head transfer_list;
297
298 struct exynos_dsi_driver_data *driver_data;
269}; 299};
270 300
271#define host_to_dsi(host) container_of(host, struct exynos_dsi, dsi_host) 301#define host_to_dsi(host) container_of(host, struct exynos_dsi, dsi_host)
272#define connector_to_dsi(c) container_of(c, struct exynos_dsi, connector) 302#define connector_to_dsi(c) container_of(c, struct exynos_dsi, connector)
273 303
304static struct exynos_dsi_driver_data exynos4_dsi_driver_data = {
305 .plltmr_reg = 0x50,
306 .has_freqband = 1,
307};
308
309static struct exynos_dsi_driver_data exynos5_dsi_driver_data = {
310 .plltmr_reg = 0x58,
311};
312
313static struct of_device_id exynos_dsi_of_match[] = {
314 { .compatible = "samsung,exynos4210-mipi-dsi",
315 .data = &exynos4_dsi_driver_data },
316 { .compatible = "samsung,exynos5410-mipi-dsi",
317 .data = &exynos5_dsi_driver_data },
318 { }
319};
320
321static inline struct exynos_dsi_driver_data *exynos_dsi_get_driver_data(
322 struct platform_device *pdev)
323{
324 const struct of_device_id *of_id =
325 of_match_device(exynos_dsi_of_match, &pdev->dev);
326
327 return (struct exynos_dsi_driver_data *)of_id->data;
328}
329
274static void exynos_dsi_wait_for_reset(struct exynos_dsi *dsi) 330static void exynos_dsi_wait_for_reset(struct exynos_dsi *dsi)
275{ 331{
276 if (wait_for_completion_timeout(&dsi->completed, msecs_to_jiffies(300))) 332 if (wait_for_completion_timeout(&dsi->completed, msecs_to_jiffies(300)))
@@ -344,14 +400,9 @@ static unsigned long exynos_dsi_pll_find_pms(struct exynos_dsi *dsi,
344static unsigned long exynos_dsi_set_pll(struct exynos_dsi *dsi, 400static unsigned long exynos_dsi_set_pll(struct exynos_dsi *dsi,
345 unsigned long freq) 401 unsigned long freq)
346{ 402{
347 static const unsigned long freq_bands[] = { 403 struct exynos_dsi_driver_data *driver_data = dsi->driver_data;
348 100 * MHZ, 120 * MHZ, 160 * MHZ, 200 * MHZ,
349 270 * MHZ, 320 * MHZ, 390 * MHZ, 450 * MHZ,
350 510 * MHZ, 560 * MHZ, 640 * MHZ, 690 * MHZ,
351 770 * MHZ, 870 * MHZ, 950 * MHZ,
352 };
353 unsigned long fin, fout; 404 unsigned long fin, fout;
354 int timeout, band; 405 int timeout;
355 u8 p, s; 406 u8 p, s;
356 u16 m; 407 u16 m;
357 u32 reg; 408 u32 reg;
@@ -372,18 +423,30 @@ static unsigned long exynos_dsi_set_pll(struct exynos_dsi *dsi,
372 "failed to find PLL PMS for requested frequency\n"); 423 "failed to find PLL PMS for requested frequency\n");
373 return -EFAULT; 424 return -EFAULT;
374 } 425 }
426 dev_dbg(dsi->dev, "PLL freq %lu, (p %d, m %d, s %d)\n", fout, p, m, s);
375 427
376 for (band = 0; band < ARRAY_SIZE(freq_bands); ++band) 428 writel(500, dsi->reg_base + driver_data->plltmr_reg);
377 if (fout < freq_bands[band]) 429
378 break; 430 reg = DSIM_PLL_EN | DSIM_PLL_P(p) | DSIM_PLL_M(m) | DSIM_PLL_S(s);
431
432 if (driver_data->has_freqband) {
433 static const unsigned long freq_bands[] = {
434 100 * MHZ, 120 * MHZ, 160 * MHZ, 200 * MHZ,
435 270 * MHZ, 320 * MHZ, 390 * MHZ, 450 * MHZ,
436 510 * MHZ, 560 * MHZ, 640 * MHZ, 690 * MHZ,
437 770 * MHZ, 870 * MHZ, 950 * MHZ,
438 };
439 int band;
379 440
380 dev_dbg(dsi->dev, "PLL freq %lu, (p %d, m %d, s %d), band %d\n", fout, 441 for (band = 0; band < ARRAY_SIZE(freq_bands); ++band)
381 p, m, s, band); 442 if (fout < freq_bands[band])
443 break;
382 444
383 writel(500, dsi->reg_base + DSIM_PLLTMR_REG); 445 dev_dbg(dsi->dev, "band %d\n", band);
446
447 reg |= DSIM_FREQ_BAND(band);
448 }
384 449
385 reg = DSIM_FREQ_BAND(band) | DSIM_PLL_EN
386 | DSIM_PLL_P(p) | DSIM_PLL_M(m) | DSIM_PLL_S(s);
387 writel(reg, dsi->reg_base + DSIM_PLLCTRL_REG); 450 writel(reg, dsi->reg_base + DSIM_PLLCTRL_REG);
388 451
389 timeout = 1000; 452 timeout = 1000;
@@ -437,6 +500,59 @@ static int exynos_dsi_enable_clock(struct exynos_dsi *dsi)
437 return 0; 500 return 0;
438} 501}
439 502
503static void exynos_dsi_set_phy_ctrl(struct exynos_dsi *dsi)
504{
505 struct exynos_dsi_driver_data *driver_data = dsi->driver_data;
506 u32 reg;
507
508 if (driver_data->has_freqband)
509 return;
510
511 /* B D-PHY: D-PHY Master & Slave Analog Block control */
512 reg = DSIM_PHYCTRL_ULPS_EXIT(0x0af);
513 writel(reg, dsi->reg_base + DSIM_PHYCTRL_REG);
514
515 /*
516 * T LPX: Transmitted length of any Low-Power state period
517 * T HS-EXIT: Time that the transmitter drives LP-11 following a HS
518 * burst
519 */
520 reg = DSIM_PHYTIMING_LPX(0x06) | DSIM_PHYTIMING_HS_EXIT(0x0b);
521 writel(reg, dsi->reg_base + DSIM_PHYTIMING_REG);
522
523 /*
524 * T CLK-PREPARE: Time that the transmitter drives the Clock Lane LP-00
525 * Line state immediately before the HS-0 Line state starting the
526 * HS transmission
527 * T CLK-ZERO: Time that the transmitter drives the HS-0 state prior to
528 * transmitting the Clock.
529 * T CLK_POST: Time that the transmitter continues to send HS clock
530 * after the last associated Data Lane has transitioned to LP Mode
531 * Interval is defined as the period from the end of T HS-TRAIL to
532 * the beginning of T CLK-TRAIL
533 * T CLK-TRAIL: Time that the transmitter drives the HS-0 state after
534 * the last payload clock bit of a HS transmission burst
535 */
536 reg = DSIM_PHYTIMING1_CLK_PREPARE(0x07) |
537 DSIM_PHYTIMING1_CLK_ZERO(0x27) |
538 DSIM_PHYTIMING1_CLK_POST(0x0d) |
539 DSIM_PHYTIMING1_CLK_TRAIL(0x08);
540 writel(reg, dsi->reg_base + DSIM_PHYTIMING1_REG);
541
542 /*
543 * T HS-PREPARE: Time that the transmitter drives the Data Lane LP-00
544 * Line state immediately before the HS-0 Line state starting the
545 * HS transmission
546 * T HS-ZERO: Time that the transmitter drives the HS-0 state prior to
547 * transmitting the Sync sequence.
548 * T HS-TRAIL: Time that the transmitter drives the flipped differential
549 * state after last payload data bit of a HS transmission burst
550 */
551 reg = DSIM_PHYTIMING2_HS_PREPARE(0x09) | DSIM_PHYTIMING2_HS_ZERO(0x0d) |
552 DSIM_PHYTIMING2_HS_TRAIL(0x0b);
553 writel(reg, dsi->reg_base + DSIM_PHYTIMING2_REG);
554}
555
440static void exynos_dsi_disable_clock(struct exynos_dsi *dsi) 556static void exynos_dsi_disable_clock(struct exynos_dsi *dsi)
441{ 557{
442 u32 reg; 558 u32 reg;
@@ -987,10 +1103,11 @@ static void exynos_dsi_disable_irq(struct exynos_dsi *dsi)
987 1103
988static int exynos_dsi_init(struct exynos_dsi *dsi) 1104static int exynos_dsi_init(struct exynos_dsi *dsi)
989{ 1105{
990 exynos_dsi_enable_clock(dsi);
991 exynos_dsi_reset(dsi); 1106 exynos_dsi_reset(dsi);
992 exynos_dsi_enable_irq(dsi); 1107 exynos_dsi_enable_irq(dsi);
1108 exynos_dsi_enable_clock(dsi);
993 exynos_dsi_wait_for_reset(dsi); 1109 exynos_dsi_wait_for_reset(dsi);
1110 exynos_dsi_set_phy_ctrl(dsi);
994 exynos_dsi_init_link(dsi); 1111 exynos_dsi_init_link(dsi);
995 1112
996 return 0; 1113 return 0;
@@ -1547,6 +1664,7 @@ static int exynos_dsi_probe(struct platform_device *pdev)
1547 dsi->dsi_host.dev = &pdev->dev; 1664 dsi->dsi_host.dev = &pdev->dev;
1548 1665
1549 dsi->dev = &pdev->dev; 1666 dsi->dev = &pdev->dev;
1667 dsi->driver_data = exynos_dsi_get_driver_data(pdev);
1550 1668
1551 ret = exynos_dsi_parse_dt(dsi); 1669 ret = exynos_dsi_parse_dt(dsi);
1552 if (ret) 1670 if (ret)
@@ -1629,11 +1747,6 @@ static int exynos_dsi_remove(struct platform_device *pdev)
1629 return 0; 1747 return 0;
1630} 1748}
1631 1749
1632static struct of_device_id exynos_dsi_of_match[] = {
1633 { .compatible = "samsung,exynos4210-mipi-dsi" },
1634 { }
1635};
1636
1637struct platform_driver dsi_driver = { 1750struct platform_driver dsi_driver = {
1638 .probe = exynos_dsi_probe, 1751 .probe = exynos_dsi_probe,
1639 .remove = exynos_dsi_remove, 1752 .remove = exynos_dsi_remove,