Ronald G. Minnich | b48605d | 2013-04-09 14:35:35 -0700 | [diff] [blame] | 1 | #include <stdlib.h> |
| 2 | #include <string.h> |
| 3 | #include <stddef.h> |
| 4 | #include <delay.h> |
David Hendricks | 6802dc8 | 2013-02-15 16:18:28 -0800 | [diff] [blame] | 5 | #include <console/console.h> |
| 6 | #include <device/device.h> |
Ronald G. Minnich | b48605d | 2013-04-09 14:35:35 -0700 | [diff] [blame] | 7 | #include <cbmem.h> |
| 8 | #include <cpu/samsung/exynos5250/fimd.h> |
| 9 | #include <cpu/samsung/exynos5-common/s5p-dp-core.h> |
| 10 | #include "chip.h" |
| 11 | #include "cpu.h" |
David Hendricks | 6802dc8 | 2013-02-15 16:18:28 -0800 | [diff] [blame] | 12 | |
David Hendricks | 0f5a3fc | 2013-03-12 20:16:44 -0700 | [diff] [blame] | 13 | #define RAM_BASE_KB (CONFIG_SYS_SDRAM_BASE >> 10) |
| 14 | #define RAM_SIZE_KB (CONFIG_DRAM_SIZE_MB << 10UL) |
David Hendricks | 6802dc8 | 2013-02-15 16:18:28 -0800 | [diff] [blame] | 15 | |
Ronald G. Minnich | b48605d | 2013-04-09 14:35:35 -0700 | [diff] [blame] | 16 | /* we distinguish a display port device from a raw graphics device |
| 17 | * because there are dramatic differences in startup depending on |
| 18 | * graphics usage. To make startup fast and easier to understand and |
| 19 | * debug we explicitly name this common case. The alternate approach, |
| 20 | * involving lots of machine and callbacks, is hard to debug and |
| 21 | * verify. |
| 22 | */ |
| 23 | static void exynos_displayport_init(device_t dev) |
| 24 | { |
| 25 | int ret; |
| 26 | struct cpu_samsung_exynos5250_config *conf = dev->chip_info; |
| 27 | /* put these on the stack. If, at some point, we want to move |
| 28 | * this code to a pre-ram stage, it will be much easier. |
| 29 | */ |
| 30 | vidinfo_t vi; |
| 31 | struct exynos5_fimd_panel panel; |
| 32 | unsigned long int fb_size; |
| 33 | u32 lcdbase; |
| 34 | |
| 35 | printk(BIOS_SPEW, "%s: dev 0x%p, conf 0x%p\n", __func__, dev, conf); |
| 36 | memset(&vi, 0, sizeof(vi)); |
| 37 | memset(&panel, 0, sizeof(panel)); |
| 38 | |
| 39 | panel.is_dp = 1; /* Display I/F is eDP */ |
| 40 | /* while it is true that we did a memset to zero, |
| 41 | * we leave some 'set to zero' entries here to make |
| 42 | * it clear what's going on. Graphics is confusing. |
| 43 | */ |
| 44 | panel.is_mipi = 0; |
| 45 | panel.fixvclk = 0; |
| 46 | panel.ivclk = 0; |
| 47 | panel.clkval_f = conf->clkval_f; |
| 48 | panel.upper_margin = conf->upper_margin; |
| 49 | panel.lower_margin = conf->lower_margin; |
| 50 | panel.vsync = conf->vsync; |
| 51 | panel.left_margin = conf->left_margin; |
| 52 | panel.right_margin = conf->right_margin; |
| 53 | panel.hsync = conf->hsync; |
| 54 | |
| 55 | vi.vl_col = conf->xres; |
| 56 | vi.vl_row = conf->yres; |
| 57 | vi.vl_bpix = conf->bpp; |
| 58 | /* |
| 59 | * The size is a magic number from hardware. Allocate enough for the |
| 60 | * frame buffer and color map. |
| 61 | */ |
| 62 | fb_size = conf->xres * conf->yres * sizeof(unsigned long); |
| 63 | lcdbase = (uintptr_t)cbmem_add(CBMEM_ID_CONSOLE, fb_size + 64*KiB); |
| 64 | printk(BIOS_SPEW, "lcd colormap base is %p\n", (void *)(lcdbase)); |
| 65 | mmio_resource(dev, 0, lcdbase/KiB, 64); |
| 66 | vi.cmap = (void *)lcdbase; |
| 67 | |
| 68 | lcdbase += 64*KiB; |
| 69 | mmio_resource(dev, 1, lcdbase/KiB, fb_size + (KiB-1)/KiB); |
| 70 | printk(BIOS_DEBUG, |
| 71 | "Initializing exynos VGA, base %p\n",(void *)lcdbase); |
| 72 | ret = lcd_ctrl_init(&vi, &panel, (void *)lcdbase); |
| 73 | } |
| 74 | |
David Hendricks | 6802dc8 | 2013-02-15 16:18:28 -0800 | [diff] [blame] | 75 | static void cpu_init(device_t dev) |
| 76 | { |
Ronald G. Minnich | b48605d | 2013-04-09 14:35:35 -0700 | [diff] [blame] | 77 | exynos_displayport_init(dev); |
David Hendricks | 3cc0d1e | 2013-03-26 16:28:21 -0700 | [diff] [blame] | 78 | ram_resource(dev, 0, RAM_BASE_KB, RAM_SIZE_KB); |
David Hendricks | 6802dc8 | 2013-02-15 16:18:28 -0800 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | static void cpu_noop(device_t dev) |
| 82 | { |
| 83 | } |
| 84 | |
| 85 | static struct device_operations cpu_ops = { |
| 86 | .read_resources = cpu_noop, |
| 87 | .set_resources = cpu_noop, |
Ronald G. Minnich | b48605d | 2013-04-09 14:35:35 -0700 | [diff] [blame] | 88 | .enable_resources = cpu_init, |
| 89 | .init = cpu_noop, |
David Hendricks | 6802dc8 | 2013-02-15 16:18:28 -0800 | [diff] [blame] | 90 | .scan_bus = 0, |
| 91 | }; |
| 92 | |
Ronald G. Minnich | b48605d | 2013-04-09 14:35:35 -0700 | [diff] [blame] | 93 | static void enable_exynos5250_dev(device_t dev) |
David Hendricks | 6802dc8 | 2013-02-15 16:18:28 -0800 | [diff] [blame] | 94 | { |
Ronald G. Minnich | b48605d | 2013-04-09 14:35:35 -0700 | [diff] [blame] | 95 | dev->ops = &cpu_ops; |
David Hendricks | 6802dc8 | 2013-02-15 16:18:28 -0800 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | struct chip_operations cpu_samsung_exynos5250_ops = { |
| 99 | CHIP_NAME("CPU Samsung Exynos 5250") |
Ronald G. Minnich | b48605d | 2013-04-09 14:35:35 -0700 | [diff] [blame] | 100 | .enable_dev = enable_exynos5250_dev, |
David Hendricks | 6802dc8 | 2013-02-15 16:18:28 -0800 | [diff] [blame] | 101 | }; |
David Hendricks | c01d138 | 2013-03-28 19:04:58 -0700 | [diff] [blame] | 102 | |
| 103 | void exynos5250_config_l2_cache(void) |
| 104 | { |
| 105 | uint32_t val; |
| 106 | |
| 107 | /* |
| 108 | * Bit 9 - L2 tag RAM setup (1 cycle) |
| 109 | * Bits 8:6 - L2 tag RAM latency (3 cycles) |
| 110 | * Bit 5 - L2 data RAM setup (1 cycle) |
| 111 | * Bits 2:0 - L2 data RAM latency (3 cycles) |
| 112 | */ |
| 113 | val = (1 << 9) | (0x2 << 6) | (1 << 5) | (0x2); |
| 114 | write_l2ctlr(val); |
| 115 | } |