blob: 4e2c6ebde73c330a483a0ef3fc452d57c6aff828 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Peter Senna Tschudin6b0071c2017-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 Tschudin6b0071c2017-11-06 19:14:11 +00009 */
10
11#include <common.h>
Ian Ray9167c202020-01-31 15:07:57 +020012#include <dm.h>
Peter Senna Tschudin6b0071c2017-11-06 19:14:11 +000013#include <linux/list.h>
Peter Senna Tschudin6b0071c2017-11-06 19:14:11 +000014#include <asm/arch/iomux-mx53.h>
Ian Ray9167c202020-01-31 15:07:57 +020015#include <asm/mach-imx/video.h>
Peter Senna Tschudin6b0071c2017-11-06 19:14:11 +000016#include <linux/fb.h>
17#include <ipu_pixfmt.h>
18#include <asm/arch/crm_regs.h>
19#include <asm/arch/imx-regs.h>
20#include <asm/io.h>
Ian Ray9167c202020-01-31 15:07:57 +020021#include <panel.h>
Peter Senna Tschudin6b0071c2017-11-06 19:14:11 +000022
Ian Ray9167c202020-01-31 15:07:57 +020023static int detect_lcd(struct display_info_t const *dev)
Peter Senna Tschudin6b0071c2017-11-06 19:14:11 +000024{
Ian Ray9167c202020-01-31 15:07:57 +020025 return 1;
Peter Senna Tschudin6b0071c2017-11-06 19:14:11 +000026}
27
28static void lcd_enable(void)
29{
30 struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
31 struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
32
33 /* Set LDB_DI0 as clock source for IPU_DI0 */
34 clrsetbits_le32(&mxc_ccm->cscmr2,
35 MXC_CCM_CSCMR2_DI0_CLK_SEL_MASK,
36 MXC_CCM_CSCMR2_DI0_CLK_SEL(
37 MXC_CCM_CSCMR2_DI0_CLK_SEL_LDB_DI0_CLK));
38
39 /* Turn on IPU LDB DI0 clocks */
40 setbits_le32(&mxc_ccm->CCGR6, MXC_CCM_CCGR6_LDB_DI0(3));
41
42 /* Turn on IPU DI0 clocks */
43 setbits_le32(&mxc_ccm->CCGR6, MXC_CCM_CCGR6_IPU_DI0(3));
44
45 /* Configure LDB */
46 writel(IOMUXC_GPR2_BIT_MAPPING_CH0_SPWG |
47 IOMUXC_GPR2_DATA_WIDTH_CH0_24BIT |
48 IOMUXC_GPR2_LVDS_CH0_MODE_ENABLED_DI0,
49 &iomux->gpr[2]);
Peter Senna Tschudin6b0071c2017-11-06 19:14:11 +000050}
51
Ian Ray9167c202020-01-31 15:07:57 +020052static void do_enable_backlight(struct display_info_t const *dev)
Peter Senna Tschudin6b0071c2017-11-06 19:14:11 +000053{
Ian Ray9167c202020-01-31 15:07:57 +020054 struct udevice *panel;
Peter Senna Tschudin6b0071c2017-11-06 19:14:11 +000055 int ret;
56
Ian Ray9167c202020-01-31 15:07:57 +020057 lcd_enable();
Peter Senna Tschudin6b0071c2017-11-06 19:14:11 +000058
Ian Ray9167c202020-01-31 15:07:57 +020059 ret = uclass_get_device(UCLASS_PANEL, 0, &panel);
60 if (ret) {
61 printf("Could not find panel: %d\n", ret);
62 return;
63 }
64
65 panel_set_backlight(panel, 100);
66 panel_enable_backlight(panel);
Peter Senna Tschudin6b0071c2017-11-06 19:14:11 +000067}
Ian Ray9167c202020-01-31 15:07:57 +020068
69struct display_info_t const displays[] = {
70 {
71 .bus = -1,
72 .addr = -1,
73 .pixfmt = IPU_PIX_FMT_RGB24,
74 .detect = detect_lcd,
75 .enable = do_enable_backlight,
76 .mode = {
77 .name = "NV-SPWGRGB888",
78 .refresh = 60,
79 .xres = 800,
80 .yres = 480,
81 .pixclock = 15384,
82 .left_margin = 16,
83 .right_margin = 210,
84 .upper_margin = 10,
85 .lower_margin = 22,
86 .hsync_len = 30,
87 .vsync_len = 13,
88 .sync = FB_SYNC_EXT,
89 .vmode = FB_VMODE_NONINTERLACED
90 }
91 }
92};
93
94size_t display_count = ARRAY_SIZE(displays);