Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Feng Li | 39e112d | 2016-11-03 14:15:17 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2016 Freescale Semiconductor, Inc. |
| 4 | * |
| 5 | * FSL DCU Framebuffer driver |
Feng Li | 39e112d | 2016-11-03 14:15:17 +0800 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <fsl_dcu_fb.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 10 | #include <asm/global_data.h> |
Feng Li | 39e112d | 2016-11-03 14:15:17 +0800 | [diff] [blame] | 11 | #include "div64.h" |
| 12 | #include "../common/dcu_sii9022a.h" |
| 13 | |
| 14 | DECLARE_GLOBAL_DATA_PTR; |
| 15 | |
| 16 | unsigned int dcu_set_pixel_clock(unsigned int pixclock) |
| 17 | { |
| 18 | unsigned long long div; |
| 19 | |
| 20 | div = (unsigned long long)(gd->bus_clk / 1000); |
| 21 | div *= (unsigned long long)pixclock; |
| 22 | do_div(div, 1000000000); |
| 23 | |
| 24 | return div; |
| 25 | } |
| 26 | |
Igor Opaniuk | 9a0270f | 2019-06-10 14:47:49 +0300 | [diff] [blame] | 27 | int platform_dcu_init(struct fb_info *fbinfo, |
| 28 | unsigned int xres, unsigned int yres, |
| 29 | const char *port, |
| 30 | struct fb_videomode *dcu_fb_videomode) |
Feng Li | 39e112d | 2016-11-03 14:15:17 +0800 | [diff] [blame] | 31 | { |
| 32 | const char *name; |
| 33 | unsigned int pixel_format; |
| 34 | |
| 35 | if (strncmp(port, "twr_lcd", 4) == 0) { |
| 36 | name = "TWR_LCD_RGB card"; |
| 37 | } else { |
| 38 | name = "HDMI"; |
| 39 | dcu_set_dvi_encoder(dcu_fb_videomode); |
| 40 | } |
| 41 | |
| 42 | printf("DCU: Switching to %s monitor @ %ux%u\n", name, xres, yres); |
| 43 | |
| 44 | pixel_format = 32; |
Igor Opaniuk | 9a0270f | 2019-06-10 14:47:49 +0300 | [diff] [blame] | 45 | fsl_dcu_init(fbinfo, xres, yres, pixel_format); |
Feng Li | 39e112d | 2016-11-03 14:15:17 +0800 | [diff] [blame] | 46 | |
| 47 | return 0; |
| 48 | } |