blob: eb4dd758b3b58b0efa8078becf2c1365cca89044 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Peter Senna Tschudin56d96922017-11-06 19:14:11 +00002/*
3 * Copyright 2017 General Electric Company
4 *
5 * Based on board/freescale/mx53loco/mx53loco_video.c:
6 *
7 * Copyright (C) 2012 Freescale Semiconductor, Inc.
8 * Fabio Estevam <fabio.estevam@freescale.com>
Peter Senna Tschudin56d96922017-11-06 19:14:11 +00009 */
10
Ian Ray9e559af2020-01-31 15:07:57 +020011#include <dm.h>
Peter Senna Tschudin56d96922017-11-06 19:14:11 +000012#include <linux/list.h>
Peter Senna Tschudin56d96922017-11-06 19:14:11 +000013#include <asm/arch/iomux-mx53.h>
Ian Ray9e559af2020-01-31 15:07:57 +020014#include <asm/mach-imx/video.h>
Peter Senna Tschudin56d96922017-11-06 19:14:11 +000015#include <linux/fb.h>
16#include <ipu_pixfmt.h>
17#include <asm/arch/crm_regs.h>
18#include <asm/arch/imx-regs.h>
19#include <asm/io.h>
Ian Ray9e559af2020-01-31 15:07:57 +020020#include <panel.h>
Peter Senna Tschudin56d96922017-11-06 19:14:11 +000021
Ian Ray9e559af2020-01-31 15:07:57 +020022static int detect_lcd(struct display_info_t const *dev)
Peter Senna Tschudin56d96922017-11-06 19:14:11 +000023{
Ian Ray9e559af2020-01-31 15:07:57 +020024 return 1;
Peter Senna Tschudin56d96922017-11-06 19:14:11 +000025}
26
27static void lcd_enable(void)
28{
29 struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
30 struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
31
32 /* Set LDB_DI0 as clock source for IPU_DI0 */
33 clrsetbits_le32(&mxc_ccm->cscmr2,
34 MXC_CCM_CSCMR2_DI0_CLK_SEL_MASK,
35 MXC_CCM_CSCMR2_DI0_CLK_SEL(
36 MXC_CCM_CSCMR2_DI0_CLK_SEL_LDB_DI0_CLK));
37
38 /* Turn on IPU LDB DI0 clocks */
39 setbits_le32(&mxc_ccm->CCGR6, MXC_CCM_CCGR6_LDB_DI0(3));
40
41 /* Turn on IPU DI0 clocks */
42 setbits_le32(&mxc_ccm->CCGR6, MXC_CCM_CCGR6_IPU_DI0(3));
43
44 /* Configure LDB */
45 writel(IOMUXC_GPR2_BIT_MAPPING_CH0_SPWG |
46 IOMUXC_GPR2_DATA_WIDTH_CH0_24BIT |
47 IOMUXC_GPR2_LVDS_CH0_MODE_ENABLED_DI0,
48 &iomux->gpr[2]);
Peter Senna Tschudin56d96922017-11-06 19:14:11 +000049}
50
Ian Ray9e559af2020-01-31 15:07:57 +020051static void do_enable_backlight(struct display_info_t const *dev)
Peter Senna Tschudin56d96922017-11-06 19:14:11 +000052{
Ian Ray9e559af2020-01-31 15:07:57 +020053 struct udevice *panel;
54 int ret;
55
Peter Senna Tschudin56d96922017-11-06 19:14:11 +000056 lcd_enable();
Peter Senna Tschudin56d96922017-11-06 19:14:11 +000057
Ian Ray9e559af2020-01-31 15:07:57 +020058 ret = uclass_get_device(UCLASS_PANEL, 0, &panel);
59 if (ret) {
60 printf("Could not find panel: %d\n", ret);
61 return;
62 }
Peter Senna Tschudin56d96922017-11-06 19:14:11 +000063
Ian Ray9e559af2020-01-31 15:07:57 +020064 panel_set_backlight(panel, 100);
65 panel_enable_backlight(panel);
66}
67
68struct display_info_t const displays[] = {
69 {
70 .bus = -1,
71 .addr = -1,
72 .pixfmt = IPU_PIX_FMT_RGB24,
73 .detect = detect_lcd,
74 .enable = do_enable_backlight,
75 .mode = {
76 .name = "NV-SPWGRGB888",
77 .refresh = 60,
78 .xres = 800,
79 .yres = 480,
80 .pixclock = 15384,
81 .left_margin = 16,
82 .right_margin = 210,
83 .upper_margin = 10,
84 .lower_margin = 22,
85 .hsync_len = 30,
86 .vsync_len = 13,
87 .sync = FB_SYNC_EXT,
88 .vmode = FB_VMODE_NONINTERLACED
89 }
90 }
91};
Peter Senna Tschudin56d96922017-11-06 19:14:11 +000092
Ian Ray9e559af2020-01-31 15:07:57 +020093size_t display_count = ARRAY_SIZE(displays);