Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 2 | /* |
Hannes Schmelzer | 2d9a3cd | 2018-01-09 19:01:32 +0100 | [diff] [blame] | 3 | * Copyright (C) 2013-2018 Hannes Schmelzer <oe5hpm@oevsv.at> |
| 4 | * B&R Industrial Automation GmbH - http://www.br-automation.com |
Dario Binacchi | 017b469 | 2020-02-22 14:05:45 +0100 | [diff] [blame] | 5 | * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 6 | * |
| 7 | * minimal framebuffer driver for TI's AM335x SoC to be compatible with |
| 8 | * Wolfgang Denk's LCD-Framework (CONFIG_LCD, common/lcd.c) |
| 9 | * |
Martin Pietryka | 8664c22 | 2016-04-27 21:39:15 +0200 | [diff] [blame] | 10 | * - supporting 16/24/32bit RGB/TFT raster Mode (not using palette) |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 11 | * - sets up LCD controller as in 'am335x_lcdpanel' struct given |
| 12 | * - starts output DMA from gd->fb_base buffer |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 13 | */ |
| 14 | #include <common.h> |
Dario Binacchi | 763e736 | 2020-05-03 21:27:48 +0200 | [diff] [blame] | 15 | #include <lcd.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 16 | #include <log.h> |
Dario Binacchi | 763e736 | 2020-05-03 21:27:48 +0200 | [diff] [blame] | 17 | #include <asm/arch/clock.h> |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 18 | #include <asm/arch/hardware.h> |
Hannes Schmelzer | 6e1e428 | 2018-01-09 19:01:34 +0100 | [diff] [blame] | 19 | #include <asm/arch/omap.h> |
Hannes Schmelzer | 6e1e428 | 2018-01-09 19:01:34 +0100 | [diff] [blame] | 20 | #include <asm/arch/sys_proto.h> |
Dario Binacchi | 763e736 | 2020-05-03 21:27:48 +0200 | [diff] [blame] | 21 | #include <asm/io.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 22 | #include <linux/delay.h> |
Dario Binacchi | 5a4ed09 | 2020-02-22 14:05:44 +0100 | [diff] [blame] | 23 | #include <linux/err.h> |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 24 | #include "am335x-fb.h" |
| 25 | |
Hannes Schmelzer | 6e1e428 | 2018-01-09 19:01:34 +0100 | [diff] [blame] | 26 | #define LCDC_FMAX 200000000 |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 27 | |
| 28 | /* LCD Control Register */ |
Dario Binacchi | 5a4ed09 | 2020-02-22 14:05:44 +0100 | [diff] [blame] | 29 | #define LCDC_CTRL_CLK_DIVISOR_MASK GENMASK(15, 8) |
Dario Binacchi | 33dfa79 | 2020-02-22 14:05:41 +0100 | [diff] [blame] | 30 | #define LCDC_CTRL_RASTER_MODE BIT(0) |
| 31 | #define LCDC_CTRL_CLK_DIVISOR(x) (((x) & GENMASK(7, 0)) << 8) |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 32 | /* LCD Clock Enable Register */ |
Dario Binacchi | 33dfa79 | 2020-02-22 14:05:41 +0100 | [diff] [blame] | 33 | #define LCDC_CLKC_ENABLE_CORECLKEN BIT(0) |
| 34 | #define LCDC_CLKC_ENABLE_LIDDCLKEN BIT(1) |
| 35 | #define LCDC_CLKC_ENABLE_DMACLKEN BIT(2) |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 36 | /* LCD DMA Control Register */ |
Dario Binacchi | 33dfa79 | 2020-02-22 14:05:41 +0100 | [diff] [blame] | 37 | #define LCDC_DMA_CTRL_BURST_SIZE(x) (((x) & GENMASK(2, 0)) << 4) |
| 38 | #define LCDC_DMA_CTRL_BURST_1 0x0 |
| 39 | #define LCDC_DMA_CTRL_BURST_2 0x1 |
| 40 | #define LCDC_DMA_CTRL_BURST_4 0x2 |
| 41 | #define LCDC_DMA_CTRL_BURST_8 0x3 |
| 42 | #define LCDC_DMA_CTRL_BURST_16 0x4 |
Dario Binacchi | 017b469 | 2020-02-22 14:05:45 +0100 | [diff] [blame] | 43 | #define LCDC_DMA_CTRL_FIFO_TH(x) (((x) & GENMASK(2, 0)) << 8) |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 44 | /* LCD Timing_0 Register */ |
Dario Binacchi | bd0b969 | 2020-02-22 14:05:48 +0100 | [diff] [blame] | 45 | #define LCDC_RASTER_TIMING_0_HORMSB(x) ((((x) - 1) & BIT(10)) >> 7) |
Dario Binacchi | 33dfa79 | 2020-02-22 14:05:41 +0100 | [diff] [blame] | 46 | #define LCDC_RASTER_TIMING_0_HORLSB(x) (((((x) >> 4) - 1) & GENMASK(5, 0)) << 4) |
| 47 | #define LCDC_RASTER_TIMING_0_HSWLSB(x) ((((x) - 1) & GENMASK(5, 0)) << 10) |
| 48 | #define LCDC_RASTER_TIMING_0_HFPLSB(x) ((((x) - 1) & GENMASK(7, 0)) << 16) |
| 49 | #define LCDC_RASTER_TIMING_0_HBPLSB(x) ((((x) - 1) & GENMASK(7, 0)) << 24) |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 50 | /* LCD Timing_1 Register */ |
Dario Binacchi | 33dfa79 | 2020-02-22 14:05:41 +0100 | [diff] [blame] | 51 | #define LCDC_RASTER_TIMING_1_VERLSB(x) (((x) - 1) & GENMASK(9, 0)) |
| 52 | #define LCDC_RASTER_TIMING_1_VSW(x) ((((x) - 1) & GENMASK(5, 0)) << 10) |
| 53 | #define LCDC_RASTER_TIMING_1_VFP(x) (((x) & GENMASK(7, 0)) << 16) |
| 54 | #define LCDC_RASTER_TIMING_1_VBP(x) (((x) & GENMASK(7, 0)) << 24) |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 55 | /* LCD Timing_2 Register */ |
Dario Binacchi | 33dfa79 | 2020-02-22 14:05:41 +0100 | [diff] [blame] | 56 | #define LCDC_RASTER_TIMING_2_HFPMSB(x) ((((x) - 1) & GENMASK(9, 8)) >> 8) |
| 57 | #define LCDC_RASTER_TIMING_2_HBPMSB(x) ((((x) - 1) & GENMASK(9, 8)) >> 4) |
Dario Binacchi | 017b469 | 2020-02-22 14:05:45 +0100 | [diff] [blame] | 58 | #define LCDC_RASTER_TIMING_2_ACB(x) (((x) & GENMASK(7, 0)) << 8) |
| 59 | #define LCDC_RASTER_TIMING_2_ACBI(x) (((x) & GENMASK(3, 0)) << 16) |
| 60 | #define LCDC_RASTER_TIMING_2_VSYNC_INVERT BIT(20) |
| 61 | #define LCDC_RASTER_TIMING_2_HSYNC_INVERT BIT(21) |
| 62 | #define LCDC_RASTER_TIMING_2_PXCLK_INVERT BIT(22) |
| 63 | #define LCDC_RASTER_TIMING_2_DE_INVERT BIT(23) |
| 64 | #define LCDC_RASTER_TIMING_2_HSVS_RISEFALL BIT(24) |
| 65 | #define LCDC_RASTER_TIMING_2_HSVS_CONTROL BIT(25) |
Dario Binacchi | 33dfa79 | 2020-02-22 14:05:41 +0100 | [diff] [blame] | 66 | #define LCDC_RASTER_TIMING_2_VERMSB(x) ((((x) - 1) & BIT(10)) << 16) |
| 67 | #define LCDC_RASTER_TIMING_2_HSWMSB(x) ((((x) - 1) & GENMASK(9, 6)) << 21) |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 68 | /* LCD Raster Ctrl Register */ |
Dario Binacchi | 33dfa79 | 2020-02-22 14:05:41 +0100 | [diff] [blame] | 69 | #define LCDC_RASTER_CTRL_ENABLE BIT(0) |
| 70 | #define LCDC_RASTER_CTRL_TFT_MODE BIT(7) |
Dario Binacchi | 017b469 | 2020-02-22 14:05:45 +0100 | [diff] [blame] | 71 | #define LCDC_RASTER_CTRL_DATA_ORDER BIT(8) |
| 72 | #define LCDC_RASTER_CTRL_REQDLY(x) (((x) & GENMASK(7, 0)) << 12) |
Dario Binacchi | 33dfa79 | 2020-02-22 14:05:41 +0100 | [diff] [blame] | 73 | #define LCDC_RASTER_CTRL_PALMODE_RAWDATA (0x02 << 20) |
Dario Binacchi | 017b469 | 2020-02-22 14:05:45 +0100 | [diff] [blame] | 74 | #define LCDC_RASTER_CTRL_TFT_ALT_ENABLE BIT(23) |
Dario Binacchi | 33dfa79 | 2020-02-22 14:05:41 +0100 | [diff] [blame] | 75 | #define LCDC_RASTER_CTRL_TFT_24BPP_MODE BIT(25) |
| 76 | #define LCDC_RASTER_CTRL_TFT_24BPP_UNPACK BIT(26) |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 77 | |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 78 | struct am335x_lcdhw { |
| 79 | unsigned int pid; /* 0x00 */ |
| 80 | unsigned int ctrl; /* 0x04 */ |
| 81 | unsigned int gap0; /* 0x08 */ |
| 82 | unsigned int lidd_ctrl; /* 0x0C */ |
| 83 | unsigned int lidd_cs0_conf; /* 0x10 */ |
| 84 | unsigned int lidd_cs0_addr; /* 0x14 */ |
| 85 | unsigned int lidd_cs0_data; /* 0x18 */ |
| 86 | unsigned int lidd_cs1_conf; /* 0x1C */ |
| 87 | unsigned int lidd_cs1_addr; /* 0x20 */ |
| 88 | unsigned int lidd_cs1_data; /* 0x24 */ |
| 89 | unsigned int raster_ctrl; /* 0x28 */ |
| 90 | unsigned int raster_timing0; /* 0x2C */ |
| 91 | unsigned int raster_timing1; /* 0x30 */ |
| 92 | unsigned int raster_timing2; /* 0x34 */ |
| 93 | unsigned int raster_subpanel; /* 0x38 */ |
| 94 | unsigned int raster_subpanel2; /* 0x3C */ |
| 95 | unsigned int lcddma_ctrl; /* 0x40 */ |
| 96 | unsigned int lcddma_fb0_base; /* 0x44 */ |
| 97 | unsigned int lcddma_fb0_ceiling; /* 0x48 */ |
| 98 | unsigned int lcddma_fb1_base; /* 0x4C */ |
| 99 | unsigned int lcddma_fb1_ceiling; /* 0x50 */ |
| 100 | unsigned int sysconfig; /* 0x54 */ |
| 101 | unsigned int irqstatus_raw; /* 0x58 */ |
| 102 | unsigned int irqstatus; /* 0x5C */ |
| 103 | unsigned int irqenable_set; /* 0x60 */ |
| 104 | unsigned int irqenable_clear; /* 0x64 */ |
| 105 | unsigned int gap1; /* 0x68 */ |
| 106 | unsigned int clkc_enable; /* 0x6C */ |
| 107 | unsigned int clkc_reset; /* 0x70 */ |
| 108 | }; |
| 109 | |
Dario Binacchi | 0dc4819 | 2020-12-30 00:16:29 +0100 | [diff] [blame] | 110 | DECLARE_GLOBAL_DATA_PTR; |
| 111 | |
Dario Binacchi | 0dc4819 | 2020-12-30 00:16:29 +0100 | [diff] [blame] | 112 | #if !defined(LCD_CNTL_BASE) |
| 113 | #error "hw-base address of LCD-Controller (LCD_CNTL_BASE) not defined!" |
| 114 | #endif |
| 115 | |
| 116 | /* Macro definitions */ |
| 117 | #define FBSIZE(x) (((x)->hactive * (x)->vactive * (x)->bpp) >> 3) |
| 118 | |
| 119 | #define LCDC_RASTER_TIMING_2_INVMASK(x) ((x) & GENMASK(25, 20)) |
| 120 | |
| 121 | static struct am335x_lcdhw *lcdhw = (void *)LCD_CNTL_BASE; |
| 122 | |
| 123 | int lcd_get_size(int *line_length) |
| 124 | { |
| 125 | *line_length = (panel_info.vl_col * NBITS(panel_info.vl_bpix)) / 8; |
| 126 | return *line_length * panel_info.vl_row + 0x20; |
| 127 | } |
| 128 | |
Dario Binacchi | 5a4ed09 | 2020-02-22 14:05:44 +0100 | [diff] [blame] | 129 | struct dpll_data { |
| 130 | unsigned long rounded_rate; |
| 131 | u16 rounded_m; |
| 132 | u8 rounded_n; |
| 133 | u8 rounded_div; |
| 134 | }; |
| 135 | |
Dario Binacchi | 5a4ed09 | 2020-02-22 14:05:44 +0100 | [diff] [blame] | 136 | /** |
| 137 | * am335x_dpll_round_rate() - Round a target rate for an OMAP DPLL |
| 138 | * |
| 139 | * @dpll_data: struct dpll_data pointer for the DPLL |
| 140 | * @rate: New DPLL clock rate |
| 141 | * @return rounded rate and the computed m, n and div values in the dpll_data |
| 142 | * structure, or -ve error code. |
| 143 | */ |
| 144 | static ulong am335x_dpll_round_rate(struct dpll_data *dd, ulong rate) |
| 145 | { |
| 146 | unsigned int m, n, d; |
| 147 | unsigned long rounded_rate; |
| 148 | int err, err_r; |
| 149 | |
| 150 | dd->rounded_rate = -EFAULT; |
| 151 | err = rate; |
| 152 | err_r = err; |
| 153 | |
| 154 | for (d = 2; err && d < 255; d++) { |
| 155 | for (m = 2; m < 2047; m++) { |
| 156 | if ((V_OSCK * m) < (rate * d)) |
| 157 | continue; |
| 158 | |
| 159 | n = (V_OSCK * m) / (rate * d); |
| 160 | if (n > 127) |
| 161 | break; |
| 162 | |
| 163 | if (((V_OSCK * m) / n) > LCDC_FMAX) |
| 164 | break; |
| 165 | |
| 166 | rounded_rate = (V_OSCK * m) / n / d; |
| 167 | err = abs(rounded_rate - rate); |
| 168 | if (err < err_r) { |
| 169 | err_r = err; |
| 170 | dd->rounded_rate = rounded_rate; |
| 171 | dd->rounded_m = m; |
| 172 | dd->rounded_n = n; |
| 173 | dd->rounded_div = d; |
| 174 | if (err == 0) |
| 175 | break; |
| 176 | } |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | debug("DPLL display: best error %d Hz (M %d, N %d, DIV %d)\n", |
| 181 | err_r, dd->rounded_m, dd->rounded_n, dd->rounded_div); |
| 182 | |
| 183 | return dd->rounded_rate; |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * am335x_fb_set_pixel_clk_rate() - Set pixel clock rate. |
| 188 | * |
| 189 | * @am335x_lcdhw: Base address of the LCD controller registers. |
| 190 | * @rate: New clock rate in Hz. |
| 191 | * @return new rate, or -ve error code. |
| 192 | */ |
| 193 | static ulong am335x_fb_set_pixel_clk_rate(struct am335x_lcdhw *regs, ulong rate) |
| 194 | { |
| 195 | struct dpll_params dpll_disp = { 1, 0, 1, -1, -1, -1, -1 }; |
| 196 | struct dpll_data dd; |
| 197 | ulong round_rate; |
| 198 | u32 reg; |
| 199 | |
| 200 | round_rate = am335x_dpll_round_rate(&dd, rate); |
| 201 | if (IS_ERR_VALUE(round_rate)) |
| 202 | return round_rate; |
| 203 | |
| 204 | dpll_disp.m = dd.rounded_m; |
| 205 | dpll_disp.n = dd.rounded_n; |
| 206 | do_setup_dpll(&dpll_disp_regs, &dpll_disp); |
| 207 | |
| 208 | reg = readl(®s->ctrl) & ~LCDC_CTRL_CLK_DIVISOR_MASK; |
| 209 | reg |= LCDC_CTRL_CLK_DIVISOR(dd.rounded_div); |
| 210 | writel(reg, ®s->ctrl); |
| 211 | return round_rate; |
| 212 | } |
| 213 | |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 214 | int am335xfb_init(struct am335x_lcdpanel *panel) |
| 215 | { |
Martin Pietryka | 8664c22 | 2016-04-27 21:39:15 +0200 | [diff] [blame] | 216 | u32 raster_ctrl = 0; |
Hannes Schmelzer | 6e1e428 | 2018-01-09 19:01:34 +0100 | [diff] [blame] | 217 | struct cm_dpll *const cmdpll = (struct cm_dpll *)CM_DPLL; |
Dario Binacchi | 5a4ed09 | 2020-02-22 14:05:44 +0100 | [diff] [blame] | 218 | ulong rate; |
| 219 | u32 reg; |
Hannes Schmelzer | 6e1e428 | 2018-01-09 19:01:34 +0100 | [diff] [blame] | 220 | |
Hannes Schmelzer | a301aa4 | 2018-01-09 19:01:33 +0100 | [diff] [blame] | 221 | if (gd->fb_base == 0) { |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 222 | printf("ERROR: no valid fb_base stored in GLOBAL_DATA_PTR!\n"); |
| 223 | return -1; |
| 224 | } |
Hannes Schmelzer | a301aa4 | 2018-01-09 19:01:33 +0100 | [diff] [blame] | 225 | if (panel == NULL) { |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 226 | printf("ERROR: missing ptr to am335x_lcdpanel!\n"); |
| 227 | return -1; |
| 228 | } |
| 229 | |
Martin Pietryka | 8664c22 | 2016-04-27 21:39:15 +0200 | [diff] [blame] | 230 | /* We can already set the bits for the raster_ctrl in this check */ |
| 231 | switch (panel->bpp) { |
| 232 | case 16: |
| 233 | break; |
| 234 | case 32: |
Dario Binacchi | 33dfa79 | 2020-02-22 14:05:41 +0100 | [diff] [blame] | 235 | raster_ctrl |= LCDC_RASTER_CTRL_TFT_24BPP_UNPACK; |
Martin Pietryka | 8664c22 | 2016-04-27 21:39:15 +0200 | [diff] [blame] | 236 | /* fallthrough */ |
| 237 | case 24: |
Dario Binacchi | 33dfa79 | 2020-02-22 14:05:41 +0100 | [diff] [blame] | 238 | raster_ctrl |= LCDC_RASTER_CTRL_TFT_24BPP_MODE; |
Martin Pietryka | 8664c22 | 2016-04-27 21:39:15 +0200 | [diff] [blame] | 239 | break; |
| 240 | default: |
Masahiro Yamada | 81e1042 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 241 | pr_err("am335x-fb: invalid bpp value: %d\n", panel->bpp); |
Martin Pietryka | 8664c22 | 2016-04-27 21:39:15 +0200 | [diff] [blame] | 242 | return -1; |
| 243 | } |
| 244 | |
Hannes Schmelzer | 6e1e428 | 2018-01-09 19:01:34 +0100 | [diff] [blame] | 245 | /* check given clock-frequency */ |
| 246 | if (panel->pxl_clk > (LCDC_FMAX / 2)) { |
| 247 | pr_err("am335x-fb: requested pxl-clk: %d not supported!\n", |
| 248 | panel->pxl_clk); |
| 249 | return -1; |
| 250 | } |
| 251 | |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 252 | debug("setting up LCD-Controller for %dx%dx%d (hfp=%d,hbp=%d,hsw=%d / ", |
| 253 | panel->hactive, panel->vactive, panel->bpp, |
| 254 | panel->hfp, panel->hbp, panel->hsw); |
Hannes Schmelzer | 6e1e428 | 2018-01-09 19:01:34 +0100 | [diff] [blame] | 255 | debug("vfp=%d,vbp=%d,vsw=%d / clk=%d)\n", |
| 256 | panel->vfp, panel->vfp, panel->vsw, panel->pxl_clk); |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 257 | debug("using frambuffer at 0x%08x with size %d.\n", |
| 258 | (unsigned int)gd->fb_base, FBSIZE(panel)); |
| 259 | |
Dario Binacchi | 5a4ed09 | 2020-02-22 14:05:44 +0100 | [diff] [blame] | 260 | rate = am335x_fb_set_pixel_clk_rate(lcdhw, panel->pxl_clk); |
| 261 | if (IS_ERR_VALUE(rate)) |
| 262 | return rate; |
Hannes Schmelzer | 6e1e428 | 2018-01-09 19:01:34 +0100 | [diff] [blame] | 263 | |
| 264 | /* clock source for LCDC from dispPLL M2 */ |
| 265 | writel(0x0, &cmdpll->clklcdcpixelclk); |
| 266 | |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 267 | /* palette default entry */ |
| 268 | memset((void *)gd->fb_base, 0, 0x20); |
| 269 | *(unsigned int *)gd->fb_base = 0x4000; |
Martin Pietryka | 3707a68 | 2016-04-27 21:39:16 +0200 | [diff] [blame] | 270 | /* point fb behind palette */ |
| 271 | gd->fb_base += 0x20; |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 272 | |
Hannes Petermaier | 169aa70 | 2015-02-03 13:22:23 +0100 | [diff] [blame] | 273 | /* turn ON display through powercontrol function if accessible */ |
Hannes Schmelzer | a301aa4 | 2018-01-09 19:01:33 +0100 | [diff] [blame] | 274 | if (panel->panel_power_ctrl != NULL) |
Hannes Petermaier | 169aa70 | 2015-02-03 13:22:23 +0100 | [diff] [blame] | 275 | panel->panel_power_ctrl(1); |
| 276 | |
| 277 | debug("am335x-fb: wait for stable power ...\n"); |
| 278 | mdelay(panel->pup_delay); |
Dario Binacchi | 33dfa79 | 2020-02-22 14:05:41 +0100 | [diff] [blame] | 279 | lcdhw->clkc_enable = LCDC_CLKC_ENABLE_CORECLKEN | |
| 280 | LCDC_CLKC_ENABLE_LIDDCLKEN | LCDC_CLKC_ENABLE_DMACLKEN; |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 281 | lcdhw->raster_ctrl = 0; |
Dario Binacchi | 5a4ed09 | 2020-02-22 14:05:44 +0100 | [diff] [blame] | 282 | |
| 283 | reg = lcdhw->ctrl & LCDC_CTRL_CLK_DIVISOR_MASK; |
| 284 | reg |= LCDC_CTRL_RASTER_MODE; |
| 285 | lcdhw->ctrl = reg; |
| 286 | |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 287 | lcdhw->lcddma_fb0_base = gd->fb_base; |
Martin Pietryka | 3707a68 | 2016-04-27 21:39:16 +0200 | [diff] [blame] | 288 | lcdhw->lcddma_fb0_ceiling = gd->fb_base + FBSIZE(panel); |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 289 | lcdhw->lcddma_fb1_base = gd->fb_base; |
Martin Pietryka | 3707a68 | 2016-04-27 21:39:16 +0200 | [diff] [blame] | 290 | lcdhw->lcddma_fb1_ceiling = gd->fb_base + FBSIZE(panel); |
Dario Binacchi | 33dfa79 | 2020-02-22 14:05:41 +0100 | [diff] [blame] | 291 | lcdhw->lcddma_ctrl = LCDC_DMA_CTRL_BURST_SIZE(LCDC_DMA_CTRL_BURST_16); |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 292 | |
Dario Binacchi | 33dfa79 | 2020-02-22 14:05:41 +0100 | [diff] [blame] | 293 | lcdhw->raster_timing0 = LCDC_RASTER_TIMING_0_HORLSB(panel->hactive) | |
| 294 | LCDC_RASTER_TIMING_0_HORMSB(panel->hactive) | |
| 295 | LCDC_RASTER_TIMING_0_HFPLSB(panel->hfp) | |
| 296 | LCDC_RASTER_TIMING_0_HBPLSB(panel->hbp) | |
| 297 | LCDC_RASTER_TIMING_0_HSWLSB(panel->hsw); |
| 298 | lcdhw->raster_timing1 = LCDC_RASTER_TIMING_1_VBP(panel->vbp) | |
| 299 | LCDC_RASTER_TIMING_1_VFP(panel->vfp) | |
| 300 | LCDC_RASTER_TIMING_1_VSW(panel->vsw) | |
| 301 | LCDC_RASTER_TIMING_1_VERLSB(panel->vactive); |
| 302 | lcdhw->raster_timing2 = LCDC_RASTER_TIMING_2_HSWMSB(panel->hsw) | |
| 303 | LCDC_RASTER_TIMING_2_VERMSB(panel->vactive) | |
| 304 | LCDC_RASTER_TIMING_2_INVMASK(panel->pol) | |
| 305 | LCDC_RASTER_TIMING_2_HBPMSB(panel->hbp) | |
| 306 | LCDC_RASTER_TIMING_2_HFPMSB(panel->hfp) | |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 307 | 0x0000FF00; /* clk cycles for ac-bias */ |
Martin Pietryka | 8664c22 | 2016-04-27 21:39:15 +0200 | [diff] [blame] | 308 | lcdhw->raster_ctrl = raster_ctrl | |
Dario Binacchi | 33dfa79 | 2020-02-22 14:05:41 +0100 | [diff] [blame] | 309 | LCDC_RASTER_CTRL_PALMODE_RAWDATA | |
| 310 | LCDC_RASTER_CTRL_TFT_MODE | |
| 311 | LCDC_RASTER_CTRL_ENABLE; |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 312 | |
Hannes Petermaier | 169aa70 | 2015-02-03 13:22:23 +0100 | [diff] [blame] | 313 | debug("am335x-fb: waiting picture to be stable.\n."); |
| 314 | mdelay(panel->pon_delay); |
Hannes Petermaier | f04e999 | 2014-03-06 14:39:06 +0100 | [diff] [blame] | 315 | |
Dario Binacchi | 017b469 | 2020-02-22 14:05:45 +0100 | [diff] [blame] | 316 | return 0; |
| 317 | } |