1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2014 Freescale Semiconductor, Inc.
6 * FSL DCU Framebuffer driver
11 #include <fsl_dcu_fb.h>
14 #include "../common/diu_ch7301.h"
15 #include "ls1021aqds_qixis.h"
17 DECLARE_GLOBAL_DATA_PTR;
19 static int select_i2c_ch_pca9547(u8 ch, int bus_num)
25 ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_PRI,
28 printf("%s: Cannot find udev for a bus %d\n", __func__,
32 ret = dm_i2c_write(dev, 0, &ch, 1);
34 ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1);
37 puts("PCA: failed to select proper channel\n");
44 unsigned int dcu_set_pixel_clock(unsigned int pixclock)
46 unsigned long long div;
48 div = (unsigned long long)(gd->bus_clk / 1000);
49 div *= (unsigned long long)pixclock;
50 do_div(div, 1000000000);
55 int platform_dcu_init(struct fb_info *fbinfo,
59 struct fb_videomode *dcu_fb_videomode)
62 unsigned int pixel_format;
66 /* Mux I2C3+I2C4 as HSYNC+VSYNC */
70 /* QIXIS device mount on I2C1 bus*/
71 ret = i2c_get_chip_for_busnum(0, CONFIG_SYS_I2C_QIXIS_ADDR,
74 printf("%s: Cannot find udev for a bus %d\n", __func__,
78 ret = dm_i2c_read(dev, QIXIS_DCU_BRDCFG5, &ch, 1);
80 printf("Error: failed to read I2C @%02x\n",
81 CONFIG_SYS_I2C_QIXIS_ADDR);
86 ret = dm_i2c_write(dev, QIXIS_DCU_BRDCFG5, &ch, 1);
89 ret = i2c_read(CONFIG_SYS_I2C_QIXIS_ADDR, QIXIS_DCU_BRDCFG5,
92 printf("Error: failed to read I2C @%02x\n",
93 CONFIG_SYS_I2C_QIXIS_ADDR);
98 ret = i2c_write(CONFIG_SYS_I2C_QIXIS_ADDR, QIXIS_DCU_BRDCFG5,
102 printf("Error: failed to write I2C @%02x\n",
103 CONFIG_SYS_I2C_QIXIS_ADDR);
107 if (strncmp(port, "hdmi", 4) == 0) {
108 unsigned long pixval;
112 pixval = 1000000000 / dcu_fb_videomode->pixclock;
115 #ifndef CONFIG_DM_I2C
116 i2c_set_bus_num(CONFIG_SYS_I2C_DVI_BUS_NUM);
118 select_i2c_ch_pca9547(I2C_MUX_CH_CH7301,
119 CONFIG_SYS_I2C_DVI_BUS_NUM);
120 diu_set_dvi_encoder(pixval);
121 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT,
122 CONFIG_SYS_I2C_DVI_BUS_NUM);
127 printf("DCU: Switching to %s monitor @ %ux%u\n", name, xres, yres);
130 fsl_dcu_init(fbinfo, xres, yres, pixel_format);