1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2014 Freescale Semiconductor, Inc.
6 * FSL DCU Framebuffer driver
9 #include <asm/global_data.h>
12 #include <fsl_dcu_fb.h>
14 #include "../common/i2c_mux.h"
16 #include "../common/diu_ch7301.h"
17 #include "ls1021aqds_qixis.h"
19 DECLARE_GLOBAL_DATA_PTR;
21 unsigned int dcu_set_pixel_clock(unsigned int pixclock)
23 unsigned long long div;
25 div = (unsigned long long)(gd->bus_clk / 1000);
26 div *= (unsigned long long)pixclock;
27 do_div(div, 1000000000);
32 int platform_dcu_init(struct fb_info *fbinfo,
36 struct fb_videomode *dcu_fb_videomode)
39 unsigned int pixel_format;
43 /* Mux I2C3+I2C4 as HSYNC+VSYNC */
44 #if CONFIG_IS_ENABLED(DM_I2C)
47 /* QIXIS device mount on I2C1 bus*/
48 ret = i2c_get_chip_for_busnum(0, CONFIG_SYS_I2C_QIXIS_ADDR,
51 printf("%s: Cannot find udev for a bus %d\n", __func__,
55 ret = dm_i2c_read(dev, QIXIS_DCU_BRDCFG5, &ch, 1);
57 printf("Error: failed to read I2C @%02x\n",
58 CONFIG_SYS_I2C_QIXIS_ADDR);
63 ret = dm_i2c_write(dev, QIXIS_DCU_BRDCFG5, &ch, 1);
66 ret = i2c_read(CONFIG_SYS_I2C_QIXIS_ADDR, QIXIS_DCU_BRDCFG5,
69 printf("Error: failed to read I2C @%02x\n",
70 CONFIG_SYS_I2C_QIXIS_ADDR);
75 ret = i2c_write(CONFIG_SYS_I2C_QIXIS_ADDR, QIXIS_DCU_BRDCFG5,
79 printf("Error: failed to write I2C @%02x\n",
80 CONFIG_SYS_I2C_QIXIS_ADDR);
84 if (strncmp(port, "hdmi", 4) == 0) {
89 pixval = 1000000000 / dcu_fb_videomode->pixclock;
92 #if !CONFIG_IS_ENABLED(DM_I2C)
93 i2c_set_bus_num(CONFIG_SYS_I2C_DVI_BUS_NUM);
95 select_i2c_ch_pca9547(I2C_MUX_CH_CH7301,
96 CONFIG_SYS_I2C_DVI_BUS_NUM);
97 diu_set_dvi_encoder(pixval);
98 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT,
99 CONFIG_SYS_I2C_DVI_BUS_NUM);
104 printf("DCU: Switching to %s monitor @ %ux%u\n", name, xres, yres);
107 fsl_dcu_init(fbinfo, xres, yres, pixel_format);