xref: /openbmc/u-boot/drivers/video/ssd2828.h (revision e8f80a5a)
1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */
2b8329acfSSiarhei Siamashka /*
3b8329acfSSiarhei Siamashka  * (C) 2015 Siarhei Siamashka <siarhei.siamashka@gmail.com>
4b8329acfSSiarhei Siamashka  */
5b8329acfSSiarhei Siamashka 
6b8329acfSSiarhei Siamashka /*
7b8329acfSSiarhei Siamashka  * Support for the SSD2828 bridge chip, which can take pixel data coming
8b8329acfSSiarhei Siamashka  * from a parallel LCD interface and translate it on the flight into MIPI DSI
9b8329acfSSiarhei Siamashka  * interface for driving a MIPI compatible TFT display.
10b8329acfSSiarhei Siamashka  *
11b8329acfSSiarhei Siamashka  * Implemented as a utility function. To be used from display drivers, which are
12b8329acfSSiarhei Siamashka  * responsible for driving parallel LCD hardware in front of the video pipeline.
13b8329acfSSiarhei Siamashka  */
14b8329acfSSiarhei Siamashka 
15b8329acfSSiarhei Siamashka #ifndef _SSD2828_H
16b8329acfSSiarhei Siamashka #define _SSD2828_H
17b8329acfSSiarhei Siamashka 
18b8329acfSSiarhei Siamashka struct ctfb_res_modes;
19b8329acfSSiarhei Siamashka 
20b8329acfSSiarhei Siamashka struct ssd2828_config {
21b8329acfSSiarhei Siamashka 	/*********************************************************************/
22b8329acfSSiarhei Siamashka 	/* SSD2828 configuration                                             */
23b8329acfSSiarhei Siamashka 	/*********************************************************************/
24b8329acfSSiarhei Siamashka 
25b8329acfSSiarhei Siamashka 	/*
26b8329acfSSiarhei Siamashka 	 * The pins, which are used for SPI communication. This is only used
27b8329acfSSiarhei Siamashka 	 * for configuring SSD2828, so the performance is irrelevant (only
28b8329acfSSiarhei Siamashka 	 * around a hundred of bytes is moved). Also these can be any arbitrary
29b8329acfSSiarhei Siamashka 	 * GPIO pins (not necessarily the pins having hardware SPI function).
30b8329acfSSiarhei Siamashka 	 * Moreover, the 'sdo' pin may be even not wired up in some devices.
31b8329acfSSiarhei Siamashka 	 *
32b8329acfSSiarhei Siamashka 	 * These configuration variables need to be set as pin numbers for
33b8329acfSSiarhei Siamashka 	 * the standard u-boot GPIO interface (gpio_get_value/gpio_set_value
34b8329acfSSiarhei Siamashka 	 * functions). Note that -1 value can be used for the pins, which are
35b8329acfSSiarhei Siamashka 	 * not really wired up.
36b8329acfSSiarhei Siamashka 	 */
37b8329acfSSiarhei Siamashka 	int csx_pin;
38b8329acfSSiarhei Siamashka 	int sck_pin;
39b8329acfSSiarhei Siamashka 	int sdi_pin;
40b8329acfSSiarhei Siamashka 	int sdo_pin;
41b8329acfSSiarhei Siamashka 	/* SSD2828 reset pin (shared with LCD panel reset) */
42b8329acfSSiarhei Siamashka 	int reset_pin;
43b8329acfSSiarhei Siamashka 
44b8329acfSSiarhei Siamashka 	/*
45b8329acfSSiarhei Siamashka 	 * The SSD2828 has its own dedicated clock source 'tx_clk' (connected
46b8329acfSSiarhei Siamashka 	 * to TX_CLK_XIO/TX_CLK_XIN pins), which is necessary at least for
47b8329acfSSiarhei Siamashka 	 * clocking SPI after reset. The exact clock speed is not strictly,
48b8329acfSSiarhei Siamashka 	 * defined, but the datasheet says that it must be somewhere in the
49dddccd69SSiarhei Siamashka 	 * 8MHz - 30MHz range (see "TX_CLK Timing" section). It can be also
50dddccd69SSiarhei Siamashka 	 * used as a reference clock for PLL. If the exact clock frequency
51dddccd69SSiarhei Siamashka 	 * is known, then it can be specified here. If it is unknown, or the
52dddccd69SSiarhei Siamashka 	 * information is not trustworthy, then it can be set to 0.
53dddccd69SSiarhei Siamashka 	 *
54dddccd69SSiarhei Siamashka 	 * If unsure, set to 0.
55b8329acfSSiarhei Siamashka 	 */
56b8329acfSSiarhei Siamashka 	int ssd2828_tx_clk_khz;
57b8329acfSSiarhei Siamashka 
58b8329acfSSiarhei Siamashka 	/*
59b8329acfSSiarhei Siamashka 	 * This is not a property of the used LCD panel, but more like a
60b8329acfSSiarhei Siamashka 	 * property of the SSD2828 wiring. See the "SSD2828QN4 RGB data
61b8329acfSSiarhei Siamashka 	 * arrangement" table in the datasheet. The SSD2828 pins are arranged
62b8329acfSSiarhei Siamashka 	 * in such a way that 18bpp and 24bpp configurations are completely
63b8329acfSSiarhei Siamashka 	 * incompatible with each other.
64b8329acfSSiarhei Siamashka 	 *
65b8329acfSSiarhei Siamashka 	 * Depending on the color depth, this must be set to 16, 18 or 24.
66b8329acfSSiarhei Siamashka 	 */
67b8329acfSSiarhei Siamashka 	int ssd2828_color_depth;
68b8329acfSSiarhei Siamashka 
69b8329acfSSiarhei Siamashka 	/*********************************************************************/
70b8329acfSSiarhei Siamashka 	/* LCD panel configuration                                           */
71b8329acfSSiarhei Siamashka 	/*********************************************************************/
72b8329acfSSiarhei Siamashka 
73b8329acfSSiarhei Siamashka 	/*
74b8329acfSSiarhei Siamashka 	 * The number of lanes in the MIPI DSI interface. May vary from 1 to 4.
75b8329acfSSiarhei Siamashka 	 *
76b8329acfSSiarhei Siamashka 	 * This information can be found in the LCD panel datasheet.
77b8329acfSSiarhei Siamashka 	 */
78b8329acfSSiarhei Siamashka 	int mipi_dsi_number_of_data_lanes;
79b8329acfSSiarhei Siamashka 
80b8329acfSSiarhei Siamashka 	/*
81b8329acfSSiarhei Siamashka 	 * Data transfer bit rate per lane. Please note that it is expected
82b8329acfSSiarhei Siamashka 	 * to be higher than the pixel clock rate of the used video mode when
83b8329acfSSiarhei Siamashka 	 * multiplied by the number of lanes. This is perfectly normal because
84b8329acfSSiarhei Siamashka 	 * MIPI DSI handles data transfers in periodic bursts, and uses the
85b8329acfSSiarhei Siamashka 	 * idle time between bursts for sending configuration information and
86b8329acfSSiarhei Siamashka 	 * commands. Or just for saving power.
87b8329acfSSiarhei Siamashka 	 *
88b8329acfSSiarhei Siamashka 	 * The necessary Mbps/lane information can be found in the LCD panel
89b8329acfSSiarhei Siamashka 	 * datasheet. Note that the transfer rate can't be always set precisely
90b8329acfSSiarhei Siamashka 	 * and it may be rounded *up* (introducing no more than 10Mbps error).
91b8329acfSSiarhei Siamashka 	 */
92b8329acfSSiarhei Siamashka 	int mipi_dsi_bitrate_per_data_lane_mbps;
93b8329acfSSiarhei Siamashka 
94b8329acfSSiarhei Siamashka 	/*
95b8329acfSSiarhei Siamashka 	 * Setting this to 1 enforces packing of 18bpp pixel data in 24bpp
96b8329acfSSiarhei Siamashka 	 * envelope when sending it over the MIPI DSI link.
97b8329acfSSiarhei Siamashka 	 *
98b8329acfSSiarhei Siamashka 	 * If unsure, set to 0.
99b8329acfSSiarhei Siamashka 	 */
100b8329acfSSiarhei Siamashka 	int mipi_dsi_loosely_packed_pixel_format;
101b8329acfSSiarhei Siamashka 
102b8329acfSSiarhei Siamashka 	/*
103b8329acfSSiarhei Siamashka 	 * According to the "Example for system sleep in and out" section in
104b8329acfSSiarhei Siamashka 	 * the SSD2828 datasheet, some LCD panel specific delays are necessary
105b8329acfSSiarhei Siamashka 	 * after MIPI DCS commands EXIT_SLEEP_MODE and SET_DISPLAY_ON.
106b8329acfSSiarhei Siamashka 	 *
107b8329acfSSiarhei Siamashka 	 * For example, Allwinner uses 100 milliseconds delay after
108b8329acfSSiarhei Siamashka 	 * EXIT_SLEEP_MODE and 200 milliseconds delay after SET_DISPLAY_ON.
109b8329acfSSiarhei Siamashka 	 */
110b8329acfSSiarhei Siamashka 	int mipi_dsi_delay_after_exit_sleep_mode_ms;
111b8329acfSSiarhei Siamashka 	int mipi_dsi_delay_after_set_display_on_ms;
112b8329acfSSiarhei Siamashka };
113b8329acfSSiarhei Siamashka 
114b8329acfSSiarhei Siamashka /*
115b8329acfSSiarhei Siamashka  * Initialize the SSD2828 chip. It needs the 'ssd2828_config' structure
116b8329acfSSiarhei Siamashka  * and also the video mode timings.
117b8329acfSSiarhei Siamashka  *
118b8329acfSSiarhei Siamashka  * The right place to insert this function call is after the parallel LCD
119b8329acfSSiarhei Siamashka  * interface is initialized and before turning on the backlight. This is
120b8329acfSSiarhei Siamashka  * advised in the "Example for system sleep in and out" section of the
121dddccd69SSiarhei Siamashka  * SSD2828 datasheet. And also SS2828 may use 'pclk' as the clock source
122dddccd69SSiarhei Siamashka  * for PLL, which means that the input signal must be already there.
123b8329acfSSiarhei Siamashka  */
124b8329acfSSiarhei Siamashka int ssd2828_init(const struct ssd2828_config *cfg,
125b8329acfSSiarhei Siamashka 		 const struct ctfb_res_modes *mode);
126b8329acfSSiarhei Siamashka 
127b8329acfSSiarhei Siamashka #endif
128