| 1 |
|
| 2 |
|
| 3 |
#include <arch/cache.h> |
| 4 |
#include <boot/coreboot_tables.h> |
| 5 |
#include <console/console.h> |
| 6 |
#include <delay.h> |
| 7 |
#include <device/device.h> |
| 8 |
#include <device/i2c_simple.h> |
| 9 |
#include <drivers/ti/tps65090/tps65090.h> |
| 10 |
#include <soc/clk.h> |
| 11 |
#include <soc/dp.h> |
| 12 |
#include <soc/dp-core.h> |
| 13 |
#include <soc/gpio.h> |
| 14 |
#include <soc/i2c.h> |
| 15 |
#include <soc/periph.h> |
| 16 |
#include <soc/power.h> |
| 17 |
#include <soc/tmu.h> |
| 18 |
#include <soc/usb.h> |
| 19 |
#include <symbols.h> |
| 20 |
#include <framebuffer_info.h> |
| 21 |
|
| 22 |
#include "exynos5250.h" |
| 23 |
|
| 24 |
#define MMC0_GPIO_PIN (58) |
| 25 |
|
| 26 |
|
| 27 |
#define DRAM_START ((uintptr_t)_dram/MiB) |
| 28 |
#define DRAM_SIZE CONFIG_DRAM_SIZE_MB |
| 29 |
#define DRAM_END (DRAM_START + DRAM_SIZE) |
| 30 |
|
| 31 |
|
| 32 |
static enum exynos5_gpio_pin dp_pd_l = GPIO_Y25; |
| 33 |
static enum exynos5_gpio_pin dp_rst_l = GPIO_X15; |
| 34 |
static enum exynos5_gpio_pin dp_hpd = GPIO_X07; |
| 35 |
|
| 36 |
static void exynos_dp_bridge_setup(void) |
| 37 |
{ |
| 38 |
exynos_pinmux_dphpd(); |
| 39 |
|
| 40 |
gpio_set_value(dp_pd_l, 1); |
| 41 |
gpio_cfg_pin(dp_pd_l, GPIO_OUTPUT); |
| 42 |
gpio_set_pull(dp_pd_l, GPIO_PULL_NONE); |
| 43 |
|
| 44 |
gpio_set_value(dp_rst_l, 0); |
| 45 |
gpio_cfg_pin(dp_rst_l, GPIO_OUTPUT); |
| 46 |
gpio_set_pull(dp_rst_l, GPIO_PULL_NONE); |
| 47 |
udelay(10); |
| 48 |
gpio_set_value(dp_rst_l, 1); |
| 49 |
} |
| 50 |
|
| 51 |
static void exynos_dp_bridge_init(void) |
| 52 |
{ |
| 53 |
|
| 54 |
gpio_set_value(dp_pd_l, 1); |
| 55 |
gpio_set_value(dp_rst_l, 1); |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
udelay(90000); |
| 66 |
} |
| 67 |
|
| 68 |
static int exynos_dp_hotplug(void) |
| 69 |
{ |
| 70 |
|
| 71 |
return gpio_get_value(dp_hpd) ? 0 : 1; |
| 72 |
} |
| 73 |
|
| 74 |
static void exynos_dp_reset(void) |
| 75 |
{ |
| 76 |
gpio_set_value(dp_pd_l, 0); |
| 77 |
gpio_set_value(dp_rst_l, 0); |
| 78 |
|
| 79 |
udelay(300 * 1000); |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
#define LCD_T3_DELAY_MS 60 |
| 91 |
|
| 92 |
#define LCD_T5_DELAY_MS 10 |
| 93 |
#define LCD_T6_DELAY_MS 10 |
| 94 |
|
| 95 |
static void backlight_pwm(void) |
| 96 |
{ |
| 97 |
|
| 98 |
gpio_direction_output(GPIO_B20, 1); |
| 99 |
udelay(LCD_T6_DELAY_MS * 1000); |
| 100 |
} |
| 101 |
|
| 102 |
static void backlight_en(void) |
| 103 |
{ |
| 104 |
|
| 105 |
gpio_direction_output(GPIO_X30, 1); |
| 106 |
} |
| 107 |
|
| 108 |
#define TPS65090_BUS 4 |
| 109 |
|
| 110 |
#define FET1_CTRL 0x0f |
| 111 |
#define FET4_CTRL 0x12 |
| 112 |
#define FET6_CTRL 0x14 |
| 113 |
|
| 114 |
static void lcd_vdd(void) |
| 115 |
{ |
| 116 |
|
| 117 |
tps65090_fet_enable(TPS65090_BUS, FET6_CTRL); |
| 118 |
} |
| 119 |
|
| 120 |
static void backlight_vdd(void) |
| 121 |
{ |
| 122 |
|
| 123 |
tps65090_fet_enable(TPS65090_BUS, FET1_CTRL); |
| 124 |
udelay(LCD_T5_DELAY_MS * 1000); |
| 125 |
} |
| 126 |
|
| 127 |
static void sdmmc_vdd(void) |
| 128 |
{ |
| 129 |
|
| 130 |
tps65090_fet_enable(TPS65090_BUS, FET4_CTRL); |
| 131 |
} |
| 132 |
|
| 133 |
static enum exynos5_gpio_pin usb_host_vbus = GPIO_X11; |
| 134 |
static enum exynos5_gpio_pin usb_drd_vbus = GPIO_X27; |
| 135 |
|
| 136 |
|
| 137 |
static void prepare_usb(void) |
| 138 |
{ |
| 139 |
|
| 140 |
reset_usb_drd_dwc3(); |
| 141 |
} |
| 142 |
|
| 143 |
static void setup_usb(void) |
| 144 |
{ |
| 145 |
|
| 146 |
setup_usb_drd_phy(); |
| 147 |
setup_usb_drd_dwc3(); |
| 148 |
setup_usb_host_phy(0); |
| 149 |
|
| 150 |
gpio_direction_output(usb_host_vbus, 1); |
| 151 |
gpio_direction_output(usb_drd_vbus, 1); |
| 152 |
} |
| 153 |
|
| 154 |
|
| 155 |
static struct video_info dp_video_info = { |
| 156 |
|
| 157 |
.name = (char *)"eDP-LVDS NXP PTN3460", |
| 158 |
|
| 159 |
.h_sync_polarity = 0, |
| 160 |
.v_sync_polarity = 0, |
| 161 |
.interlaced = 0, |
| 162 |
|
| 163 |
.color_space = COLOR_RGB, |
| 164 |
.dynamic_range = VESA, |
| 165 |
.ycbcr_coeff = COLOR_YCBCR601, |
| 166 |
.color_depth = COLOR_8, |
| 167 |
|
| 168 |
.link_rate = LINK_RATE_2_70GBPS, |
| 169 |
.lane_count = LANE_COUNT2, |
| 170 |
}; |
| 171 |
|
| 172 |
|
| 173 |
#define MAX_DP_TRIES 5 |
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
static void disable_usb30_pll(void) |
| 179 |
{ |
| 180 |
enum exynos5_gpio_pin usb3_pll_l = GPIO_Y11; |
| 181 |
|
| 182 |
gpio_direction_output(usb3_pll_l, 0); |
| 183 |
} |
| 184 |
|
| 185 |
static void setup_storage(void) |
| 186 |
{ |
| 187 |
|
| 188 |
if (clock_set_mshci(PERIPH_ID_SDMMC0)) |
| 189 |
printk(BIOS_CRIT, "%s: Failed to set MMC0 clock.\n", __func__); |
| 190 |
if (gpio_direction_output(MMC0_GPIO_PIN, 1)) { |
| 191 |
printk(BIOS_CRIT, "%s: Unable to power on MMC0.\n", __func__); |
| 192 |
} |
| 193 |
gpio_set_pull(MMC0_GPIO_PIN, GPIO_PULL_NONE); |
| 194 |
gpio_set_drv(MMC0_GPIO_PIN, GPIO_DRV_4X); |
| 195 |
exynos_pinmux_sdmmc0(); |
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
clock_set_mshci(PERIPH_ID_SDMMC2); |
| 200 |
exynos_pinmux_sdmmc2(); |
| 201 |
} |
| 202 |
|
| 203 |
static void gpio_init(void) |
| 204 |
{ |
| 205 |
|
| 206 |
exynos_pinmux_i2c0(); |
| 207 |
exynos_pinmux_i2c1(); |
| 208 |
exynos_pinmux_i2c2(); |
| 209 |
exynos_pinmux_i2c3(); |
| 210 |
exynos_pinmux_i2c4(); |
| 211 |
exynos_pinmux_i2c7(); |
| 212 |
|
| 213 |
|
| 214 |
gpio_set_pull(GPIO_F03, GPIO_PULL_NONE); |
| 215 |
gpio_set_pull(GPIO_E04, GPIO_PULL_NONE); |
| 216 |
gpio_direction_output(GPIO_F03, 1); |
| 217 |
gpio_direction_input(GPIO_E04); |
| 218 |
|
| 219 |
|
| 220 |
gpio_set_pull(GPIO_X17, GPIO_PULL_NONE); |
| 221 |
gpio_set_pull(GPIO_X15, GPIO_PULL_NONE); |
| 222 |
gpio_direction_output(GPIO_X17, 1); |
| 223 |
gpio_direction_output(GPIO_X15, 1); |
| 224 |
|
| 225 |
|
| 226 |
exynos_pinmux_i2s0(); |
| 227 |
exynos_pinmux_i2s1(); |
| 228 |
} |
| 229 |
|
| 230 |
|
| 231 |
static void mainboard_init(struct device *dev) |
| 232 |
{ |
| 233 |
int dp_tries; |
| 234 |
struct s5p_dp_device dp_device = { |
| 235 |
.base = exynos_dp1, |
| 236 |
.video_info = &dp_video_info, |
| 237 |
}; |
| 238 |
void *fb_addr = (void *)(get_fb_base_kb() * KiB); |
| 239 |
|
| 240 |
prepare_usb(); |
| 241 |
gpio_init(); |
| 242 |
setup_storage(); |
| 243 |
|
| 244 |
i2c_init(TPS65090_BUS, I2C_0_SPEED, I2C_SLAVE); |
| 245 |
i2c_init(7, I2C_0_SPEED, I2C_SLAVE); |
| 246 |
|
| 247 |
tmu_init(&exynos5250_tmu_info); |
| 248 |
|
| 249 |
|
| 250 |
clock_gate(); |
| 251 |
|
| 252 |
|
| 253 |
disable_usb30_pll(); |
| 254 |
|
| 255 |
sdmmc_vdd(); |
| 256 |
|
| 257 |
fb_add_framebuffer_info((uintptr_t)fb_addr, 1366, 768, 2 * 1366, 16); |
| 258 |
|
| 259 |
lcd_vdd(); |
| 260 |
|
| 261 |
|
| 262 |
do { |
| 263 |
udelay(50); |
| 264 |
} while (!exynos_dp_hotplug()); |
| 265 |
|
| 266 |
exynos_dp_bridge_setup(); |
| 267 |
for (dp_tries = 1; dp_tries <= MAX_DP_TRIES; dp_tries++) { |
| 268 |
exynos_dp_bridge_init(); |
| 269 |
if (exynos_dp_hotplug()) { |
| 270 |
exynos_dp_reset(); |
| 271 |
continue; |
| 272 |
} |
| 273 |
|
| 274 |
if (dp_controller_init(&dp_device)) |
| 275 |
continue; |
| 276 |
|
| 277 |
udelay(LCD_T3_DELAY_MS * 1000); |
| 278 |
|
| 279 |
backlight_vdd(); |
| 280 |
backlight_pwm(); |
| 281 |
backlight_en(); |
| 282 |
|
| 283 |
break; |
| 284 |
} |
| 285 |
|
| 286 |
if (dp_tries > MAX_DP_TRIES) |
| 287 |
printk(BIOS_ERR, "%s: Failed to set up displayport\n", __func__); |
| 288 |
|
| 289 |
setup_usb(); |
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
} |
| 294 |
|
| 295 |
static void mainboard_enable(struct device *dev) |
| 296 |
{ |
| 297 |
dev->ops->init = &mainboard_init; |
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
exynos5250_config_l2_cache(); |
| 302 |
mmu_init(); |
| 303 |
mmu_config_range(0, DRAM_START, DCACHE_OFF); |
| 304 |
mmu_config_range(DRAM_START, DRAM_SIZE, DCACHE_WRITEBACK); |
| 305 |
mmu_config_range((uintptr_t)_dma_coherent/MiB, |
| 306 |
REGION_SIZE(dma_coherent)/MiB, DCACHE_OFF); |
| 307 |
mmu_config_range(DRAM_END, 4096 - DRAM_END, DCACHE_OFF); |
| 308 |
dcache_mmu_enable(); |
| 309 |
|
| 310 |
const unsigned int epll_hz = 192000000; |
| 311 |
const unsigned int sample_rate = 48000; |
| 312 |
const unsigned int lr_frame_size = 256; |
| 313 |
clock_epll_set_rate(epll_hz); |
| 314 |
clock_select_i2s_clk_source(); |
| 315 |
clock_set_i2s_clk_prescaler(epll_hz, sample_rate * lr_frame_size); |
| 316 |
|
| 317 |
power_enable_xclkout(); |
| 318 |
} |
| 319 |
|
| 320 |
struct chip_operations mainboard_ops = { |
| 321 |
.name = "daisy", |
| 322 |
.enable_dev = mainboard_enable, |
| 323 |
}; |
| 324 |
|
| 325 |
void lb_board(struct lb_header *header) |
| 326 |
{ |
| 327 |
struct lb_range *dma; |
| 328 |
|
| 329 |
dma = (struct lb_range *)lb_new_record(header); |
| 330 |
dma->tag = LB_TAG_DMA; |
| 331 |
dma->size = sizeof(*dma); |
| 332 |
dma->range_start = (uintptr_t)_dma_coherent; |
| 333 |
dma->range_size = REGION_SIZE(dma_coherent); |
| 334 |
} |