York Sun | fd7cbfd | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2008 Freescale Semiconductor, Inc. |
| 3 | * York Sun <yorksun@freescale.com> |
| 4 | * |
| 5 | * FSL DIU Framebuffer driver |
| 6 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 7 | * SPDX-License-Identifier: GPL-2.0+ |
York Sun | fd7cbfd | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <common.h> |
| 11 | #include <command.h> |
| 12 | #include <asm/io.h> |
| 13 | |
Anatolij Gustschin | 43ffc53 | 2010-09-24 01:06:37 +0200 | [diff] [blame] | 14 | #include <fsl_diu_fb.h> |
York Sun | fd7cbfd | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 15 | |
Anatolij Gustschin | 81cad14 | 2010-04-24 19:27:09 +0200 | [diff] [blame] | 16 | DECLARE_GLOBAL_DATA_PTR; |
| 17 | |
York Sun | fd7cbfd | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 18 | void diu_set_pixel_clock(unsigned int pixclock) |
| 19 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 20 | volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
York Sun | fd7cbfd | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 21 | volatile clk512x_t *clk = &immap->clk; |
| 22 | volatile unsigned int *clkdvdr = &clk->scfr[0]; |
| 23 | unsigned long speed_ccb, temp, pixval; |
| 24 | |
| 25 | speed_ccb = get_bus_freq(0) * 4; |
| 26 | temp = 1000000000/pixclock; |
| 27 | temp *= 1000; |
| 28 | pixval = speed_ccb / temp; |
| 29 | debug("DIU pixval = %lu\n", pixval); |
| 30 | |
| 31 | /* Modify PXCLK in GUTS CLKDVDR */ |
Detlev Zundel | 00c2716 | 2010-01-21 17:55:58 +0100 | [diff] [blame] | 32 | debug("DIU: Current value of CLKDVDR = 0x%08x\n", in_be32(clkdvdr)); |
| 33 | temp = in_be32(clkdvdr) & 0xFFFFFF00; |
| 34 | out_be32(clkdvdr, temp | (pixval & 0xFF)); |
| 35 | debug("DIU: Modified value of CLKDVDR = 0x%08x\n", in_be32(clkdvdr)); |
York Sun | fd7cbfd | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 36 | } |
| 37 | |
Timur Tabi | 32f709e | 2011-04-11 14:18:22 -0500 | [diff] [blame] | 38 | int platform_diu_init(unsigned int xres, unsigned int yres, const char *port) |
York Sun | fd7cbfd | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 39 | { |
Timur Tabi | 32f709e | 2011-04-11 14:18:22 -0500 | [diff] [blame] | 40 | unsigned int pixel_format = 0x88883316; |
York Sun | fd7cbfd | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 41 | |
Wolfgang Denk | e384d2e | 2009-05-16 10:47:38 +0200 | [diff] [blame] | 42 | debug("mpc5121_diu_init\n"); |
Timur Tabi | 6d99ce2 | 2011-05-26 09:02:17 -0500 | [diff] [blame] | 43 | return fsl_diu_init(xres, yres, pixel_format, 0); |
York Sun | fd7cbfd | 2008-05-05 10:20:01 -0500 | [diff] [blame] | 44 | } |