| 1 |
|
| 2 |
|
| 3 |
#include <arch/cache.h> |
| 4 |
#include <console/console.h> |
| 5 |
#include <device/mmio.h> |
| 6 |
#include <device/device.h> |
| 7 |
#include <ec/google/chromeec/ec.h> |
| 8 |
#include <soc/dp.h> |
| 9 |
#include <soc/fimd.h> |
| 10 |
#include <soc/cpu.h> |
| 11 |
#include <soc/clk.h> |
| 12 |
#include <string.h> |
| 13 |
|
| 14 |
#include "chip.h" |
| 15 |
|
| 16 |
static unsigned int cpu_id; |
| 17 |
static unsigned int cpu_rev; |
| 18 |
|
| 19 |
static void set_cpu_id(void) |
| 20 |
{ |
| 21 |
u32 pro_id = (read32((void *)EXYNOS5_PRO_ID) & 0x00FFF000) >> 12; |
| 22 |
|
| 23 |
switch (pro_id) { |
| 24 |
case 0x200: |
| 25 |
|
| 26 |
cpu_id = 0x4210; |
| 27 |
cpu_rev = 0; |
| 28 |
break; |
| 29 |
case 0x210: |
| 30 |
|
| 31 |
cpu_id = 0x4210; |
| 32 |
break; |
| 33 |
case 0x412: |
| 34 |
|
| 35 |
cpu_id = 0x4412; |
| 36 |
break; |
| 37 |
case 0x520: |
| 38 |
|
| 39 |
cpu_id = 0x5250; |
| 40 |
break; |
| 41 |
case 0x420: |
| 42 |
|
| 43 |
cpu_id = 0x5420; |
| 44 |
break; |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
static void exynos_displayport_init(struct device *dev, u32 lcdbase, |
| 56 |
unsigned long fb_size) |
| 57 |
{ |
| 58 |
struct soc_samsung_exynos5420_config *conf = dev->chip_info; |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
struct exynos5_fimd_panel panel; |
| 63 |
memset(&panel, 0, sizeof(panel)); |
| 64 |
|
| 65 |
panel.is_dp = 1; |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
panel.is_mipi = 0; |
| 71 |
panel.fixvclk = 0; |
| 72 |
panel.ivclk = 0; |
| 73 |
panel.clkval_f = conf->clkval_f; |
| 74 |
panel.upper_margin = conf->upper_margin; |
| 75 |
panel.lower_margin = conf->lower_margin; |
| 76 |
panel.vsync = conf->vsync; |
| 77 |
panel.left_margin = conf->left_margin; |
| 78 |
panel.right_margin = conf->right_margin; |
| 79 |
panel.hsync = conf->hsync; |
| 80 |
panel.xres = conf->xres; |
| 81 |
panel.yres = conf->yres; |
| 82 |
|
| 83 |
printk(BIOS_SPEW, "LCD framebuffer @%p\n", (void *)(lcdbase)); |
| 84 |
memset((void *)lcdbase, 0, fb_size); |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
uint32_t lower = ALIGN_DOWN(lcdbase, MiB); |
| 96 |
uint32_t upper = ALIGN_UP(lcdbase + fb_size, MiB); |
| 97 |
|
| 98 |
dcache_clean_invalidate_by_mva((void *)lower, upper - lower); |
| 99 |
mmu_config_range(lower / MiB, (upper - lower) / MiB, DCACHE_OFF); |
| 100 |
} |
| 101 |
|
| 102 |
static void tps65090_thru_ec_fet_disable(int index) |
| 103 |
{ |
| 104 |
uint8_t value = 0; |
| 105 |
|
| 106 |
if (google_chromeec_i2c_xfer(0x48, 0xe + index, 1, &value, 1, 0)) { |
| 107 |
printk(BIOS_ERR, |
| 108 |
"Error sending i2c pass through command to EC.\n"); |
| 109 |
return; |
| 110 |
} |
| 111 |
} |
| 112 |
|
| 113 |
static void cpu_enable(struct device *dev) |
| 114 |
{ |
| 115 |
unsigned long fb_size = FB_SIZE_KB * KiB; |
| 116 |
u32 lcdbase = get_fb_base_kb() * KiB; |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
tps65090_thru_ec_fet_disable(1); |
| 124 |
tps65090_thru_ec_fet_disable(6); |
| 125 |
|
| 126 |
exynos_displayport_init(dev, lcdbase, fb_size); |
| 127 |
|
| 128 |
set_cpu_id(); |
| 129 |
} |
| 130 |
|
| 131 |
static void cpu_read_resources(struct device *dev) |
| 132 |
{ |
| 133 |
unsigned long fb_size = FB_SIZE_KB * KiB; |
| 134 |
u32 lcdbase = get_fb_base_kb() * KiB; |
| 135 |
|
| 136 |
ram_range(dev, 0, RAM_BASE_KB * KiB, (RAM_SIZE_KB - FB_SIZE_KB) * KiB); |
| 137 |
mmio_range(dev, 1, lcdbase, fb_size); |
| 138 |
} |
| 139 |
|
| 140 |
static void cpu_init(struct device *dev) |
| 141 |
{ |
| 142 |
printk(BIOS_INFO, "CPU: S5P%X @ %ldMHz\n", |
| 143 |
cpu_id, get_arm_clk() / 1000000); |
| 144 |
} |
| 145 |
|
| 146 |
static struct device_operations cpu_ops = { |
| 147 |
.read_resources = cpu_read_resources, |
| 148 |
.set_resources = noop_set_resources, |
| 149 |
.enable_resources = cpu_enable, |
| 150 |
.init = cpu_init, |
| 151 |
}; |
| 152 |
|
| 153 |
static void enable_exynos5420_dev(struct device *dev) |
| 154 |
{ |
| 155 |
dev->ops = &cpu_ops; |
| 156 |
} |
| 157 |
|
| 158 |
struct chip_operations soc_samsung_exynos5420_ops = { |
| 159 |
.name = "SOC Samsung Exynos 5420", |
| 160 |
.enable_dev = enable_exynos5420_dev, |
| 161 |
}; |