Angel Pons | e3218a2 | 2020-04-05 13:21:04 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Ronald G. Minnich | f89e6b2 | 2012-12-10 16:13:43 -0800 | [diff] [blame] | 2 | |
Julius Werner | 1ed0c8c | 2014-10-20 13:16:29 -0700 | [diff] [blame] | 3 | #include <arch/cache.h> |
| 4 | #include <boot/coreboot_tables.h> |
David Hendricks | 50c0a50 | 2013-01-31 17:05:50 -0800 | [diff] [blame] | 5 | #include <console/console.h> |
Julius Werner | 1ed0c8c | 2014-10-20 13:16:29 -0700 | [diff] [blame] | 6 | #include <delay.h> |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 7 | #include <device/device.h> |
Nico Huber | 0f2dd1e | 2017-08-01 14:02:40 +0200 | [diff] [blame] | 8 | #include <device/i2c_simple.h> |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 9 | #include <drivers/ti/tps65090/tps65090.h> |
Julius Werner | 1ed0c8c | 2014-10-20 13:16:29 -0700 | [diff] [blame] | 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> |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 19 | #include <symbols.h> |
Patrick Rudolph | 8b56c8c | 2020-02-19 12:57:00 +0100 | [diff] [blame] | 20 | #include <framebuffer_info.h> |
David Hendricks | 0d4f97e | 2013-02-03 18:09:58 -0800 | [diff] [blame] | 21 | |
Stefan Reinauer | 043eb0e | 2013-05-10 16:21:58 -0700 | [diff] [blame] | 22 | #include "exynos5250.h" |
David Hendricks | 0d4f97e | 2013-02-03 18:09:58 -0800 | [diff] [blame] | 23 | |
Julius Werner | ad4556f2 | 2013-08-21 17:33:31 -0700 | [diff] [blame] | 24 | #define MMC0_GPIO_PIN (58) |
| 25 | |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 26 | /* convenient shorthand (in MB) */ |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 27 | #define DRAM_START ((uintptr_t)_dram/MiB) |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 28 | #define DRAM_SIZE CONFIG_DRAM_SIZE_MB |
| 29 | #define DRAM_END (DRAM_START + DRAM_SIZE) /* plus one... */ |
| 30 | |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 31 | /* TODO: transplanted DP stuff, clean up once we have something that works */ |
| 32 | static enum exynos5_gpio_pin dp_pd_l = GPIO_Y25; /* active low */ |
| 33 | static enum exynos5_gpio_pin dp_rst_l = GPIO_X15; /* active low */ |
| 34 | static enum exynos5_gpio_pin dp_hpd = GPIO_X07; /* active high */ |
| 35 | |
| 36 | static void exynos_dp_bridge_setup(void) |
Ronald G. Minnich | f89e6b2 | 2012-12-10 16:13:43 -0800 | [diff] [blame] | 37 | { |
Gabe Black | fe64060 | 2013-06-15 20:33:05 -0700 | [diff] [blame] | 38 | exynos_pinmux_dphpd(); |
David Hendricks | 0d4f97e | 2013-02-03 18:09:58 -0800 | [diff] [blame] | 39 | |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 40 | gpio_set_value(dp_pd_l, 1); |
Stefan Reinauer | dc006c1 | 2013-05-15 14:54:07 -0700 | [diff] [blame] | 41 | gpio_cfg_pin(dp_pd_l, GPIO_OUTPUT); |
| 42 | gpio_set_pull(dp_pd_l, GPIO_PULL_NONE); |
David Hendricks | 0d4f97e | 2013-02-03 18:09:58 -0800 | [diff] [blame] | 43 | |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 44 | gpio_set_value(dp_rst_l, 0); |
Stefan Reinauer | dc006c1 | 2013-05-15 14:54:07 -0700 | [diff] [blame] | 45 | gpio_cfg_pin(dp_rst_l, GPIO_OUTPUT); |
| 46 | gpio_set_pull(dp_rst_l, GPIO_PULL_NONE); |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 47 | udelay(10); |
| 48 | gpio_set_value(dp_rst_l, 1); |
Ronald G. Minnich | f89e6b2 | 2012-12-10 16:13:43 -0800 | [diff] [blame] | 49 | } |
| 50 | |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 51 | static void exynos_dp_bridge_init(void) |
| 52 | { |
| 53 | /* De-assert PD (and possibly RST) to power up the bridge */ |
| 54 | gpio_set_value(dp_pd_l, 1); |
| 55 | gpio_set_value(dp_rst_l, 1); |
| 56 | |
| 57 | /* |
| 58 | * We need to wait for 90ms after bringing up the bridge since |
| 59 | * there is a phantom "high" on the HPD chip during its |
| 60 | * bootup. The phantom high comes within 7ms of de-asserting |
| 61 | * PD and persists for at least 15ms. The real high comes |
| 62 | * roughly 50ms after PD is de-asserted. The phantom high |
| 63 | * makes it hard for us to know when the NXP chip is up. |
| 64 | */ |
| 65 | udelay(90000); |
| 66 | } |
| 67 | |
| 68 | static int exynos_dp_hotplug(void) |
| 69 | { |
| 70 | /* Check HPD. If it's high, we're all good. */ |
| 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 | /* paranoid delay period (300ms) */ |
| 79 | udelay(300 * 1000); |
| 80 | } |
| 81 | |
| 82 | /* |
| 83 | * This delay is T3 in the LCD timing spec (defined as >200ms). We set |
| 84 | * this down to 60ms since that's the approximate maximum amount of time |
| 85 | * it'll take a bridge to start outputting LVDS data. The delay of |
| 86 | * >200ms is just a conservative value to avoid turning on the backlight |
| 87 | * when there's random LCD data on the screen. Shaving 140ms off the |
| 88 | * boot is an acceptable trade-off. |
| 89 | */ |
| 90 | #define LCD_T3_DELAY_MS 60 |
| 91 | |
| 92 | #define LCD_T5_DELAY_MS 10 |
| 93 | #define LCD_T6_DELAY_MS 10 |
| 94 | |
Stefan Reinauer | 043eb0e | 2013-05-10 16:21:58 -0700 | [diff] [blame] | 95 | static void backlight_pwm(void) |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 96 | { |
| 97 | /*Configure backlight PWM as a simple output high (100% brightness) */ |
| 98 | gpio_direction_output(GPIO_B20, 1); |
| 99 | udelay(LCD_T6_DELAY_MS * 1000); |
| 100 | } |
| 101 | |
Stefan Reinauer | 043eb0e | 2013-05-10 16:21:58 -0700 | [diff] [blame] | 102 | static void backlight_en(void) |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 103 | { |
Stefan Reinauer | dc006c1 | 2013-05-15 14:54:07 -0700 | [diff] [blame] | 104 | /* Configure GPIO for LCD_BL_EN */ |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 105 | gpio_direction_output(GPIO_X30, 1); |
| 106 | } |
| 107 | |
Gabe Black | 49c98dc | 2014-01-22 21:06:32 -0800 | [diff] [blame] | 108 | #define TPS65090_BUS 4 /* Daisy-specific */ |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 109 | |
| 110 | #define FET1_CTRL 0x0f |
Julius Werner | ad4556f2 | 2013-08-21 17:33:31 -0700 | [diff] [blame] | 111 | #define FET4_CTRL 0x12 |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 112 | #define FET6_CTRL 0x14 |
| 113 | |
Stefan Reinauer | 043eb0e | 2013-05-10 16:21:58 -0700 | [diff] [blame] | 114 | static void lcd_vdd(void) |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 115 | { |
| 116 | /* Enable FET6, lcd panel */ |
David Hendricks | 8ccabb6 | 2013-08-01 19:12:56 -0700 | [diff] [blame] | 117 | tps65090_fet_enable(TPS65090_BUS, FET6_CTRL); |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 118 | } |
| 119 | |
Stefan Reinauer | 043eb0e | 2013-05-10 16:21:58 -0700 | [diff] [blame] | 120 | static void backlight_vdd(void) |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 121 | { |
| 122 | /* Enable FET1, backlight */ |
David Hendricks | 8ccabb6 | 2013-08-01 19:12:56 -0700 | [diff] [blame] | 123 | tps65090_fet_enable(TPS65090_BUS, FET1_CTRL); |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 124 | udelay(LCD_T5_DELAY_MS * 1000); |
| 125 | } |
| 126 | |
Julius Werner | ad4556f2 | 2013-08-21 17:33:31 -0700 | [diff] [blame] | 127 | static void sdmmc_vdd(void) |
| 128 | { |
| 129 | /* Enable FET4, P3.3V_SDCARD */ |
| 130 | tps65090_fet_enable(TPS65090_BUS, FET4_CTRL); |
| 131 | } |
| 132 | |
Julius Werner | 79bff70 | 2013-08-15 17:34:45 -0700 | [diff] [blame] | 133 | static enum exynos5_gpio_pin usb_host_vbus = GPIO_X11; |
| 134 | static enum exynos5_gpio_pin usb_drd_vbus = GPIO_X27; |
| 135 | /* static enum exynos5_gpio_pin hsic_reset_l = GPIO_E10; */ |
| 136 | |
Julius Werner | 68aef11 | 2013-09-03 15:07:31 -0700 | [diff] [blame] | 137 | static void prepare_usb(void) |
| 138 | { |
| 139 | /* Kick this reset off early so it gets at least 100ms to settle */ |
| 140 | reset_usb_drd_dwc3(); |
| 141 | } |
| 142 | |
Julius Werner | 79bff70 | 2013-08-15 17:34:45 -0700 | [diff] [blame] | 143 | static void setup_usb(void) |
| 144 | { |
| 145 | /* HSIC not needed in firmware on this board */ |
Julius Werner | 68aef11 | 2013-09-03 15:07:31 -0700 | [diff] [blame] | 146 | setup_usb_drd_phy(); |
| 147 | setup_usb_drd_dwc3(); |
Julius Werner | 79bff70 | 2013-08-15 17:34:45 -0700 | [diff] [blame] | 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 | |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 154 | //static struct video_info smdk5250_dp_config = { |
Stefan Reinauer | 043eb0e | 2013-05-10 16:21:58 -0700 | [diff] [blame] | 155 | static struct video_info dp_video_info = { |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 156 | /* FIXME: fix video_info struct to use const for name */ |
| 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 | /* FIXME: move some place more appropriate */ |
Stefan Reinauer | 043eb0e | 2013-05-10 16:21:58 -0700 | [diff] [blame] | 173 | #define MAX_DP_TRIES 5 |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 174 | |
| 175 | /* |
| 176 | * This function disables the USB3.0 PLL to save power |
| 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 | |
Julius Werner | ad4556f2 | 2013-08-21 17:33:31 -0700 | [diff] [blame] | 185 | static void setup_storage(void) |
| 186 | { |
| 187 | /* MMC0: Fixed, 8 bit mode, connected with GPIO. */ |
| 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 | /* MMC2: Removable, 4 bit mode, no GPIO. */ |
| 198 | /* (Must be after romstage to avoid breaking SDMMC boot.) */ |
| 199 | clock_set_mshci(PERIPH_ID_SDMMC2); |
| 200 | exynos_pinmux_sdmmc2(); |
| 201 | } |
| 202 | |
Gabe Black | 1387b43 | 2013-05-18 15:55:47 -0700 | [diff] [blame] | 203 | static void gpio_init(void) |
| 204 | { |
Martin Roth | 50863da | 2021-10-01 14:37:30 -0600 | [diff] [blame^] | 205 | /* Set up the I2C buses. */ |
Gabe Black | fe64060 | 2013-06-15 20:33:05 -0700 | [diff] [blame] | 206 | exynos_pinmux_i2c0(); |
| 207 | exynos_pinmux_i2c1(); |
| 208 | exynos_pinmux_i2c2(); |
| 209 | exynos_pinmux_i2c3(); |
| 210 | exynos_pinmux_i2c4(); |
| 211 | exynos_pinmux_i2c7(); |
Gabe Black | 1387b43 | 2013-05-18 15:55:47 -0700 | [diff] [blame] | 212 | |
| 213 | /* Set up the GPIOs used to arbitrate for I2C bus 4. */ |
| 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 | /* Set up the GPIO used to enable the audio codec. */ |
| 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 | |
Martin Roth | 50863da | 2021-10-01 14:37:30 -0600 | [diff] [blame^] | 225 | /* Set up the I2S buses. */ |
Gabe Black | e6789c1 | 2013-08-05 22:19:36 -0700 | [diff] [blame] | 226 | exynos_pinmux_i2s0(); |
Gabe Black | fe64060 | 2013-06-15 20:33:05 -0700 | [diff] [blame] | 227 | exynos_pinmux_i2s1(); |
Gabe Black | 1387b43 | 2013-05-18 15:55:47 -0700 | [diff] [blame] | 228 | } |
| 229 | |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 230 | /* this happens after cpu_init where exynos resources are set */ |
Elyes HAOUAS | d129d43 | 2018-05-04 20:23:33 +0200 | [diff] [blame] | 231 | static void mainboard_init(struct device *dev) |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 232 | { |
| 233 | int dp_tries; |
| 234 | struct s5p_dp_device dp_device = { |
Julius Werner | fa938c7 | 2013-08-29 14:17:36 -0700 | [diff] [blame] | 235 | .base = exynos_dp1, |
Stefan Reinauer | 043eb0e | 2013-05-10 16:21:58 -0700 | [diff] [blame] | 236 | .video_info = &dp_video_info, |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 237 | }; |
Stefan Reinauer | 6628744 | 2013-06-19 15:54:19 -0700 | [diff] [blame] | 238 | void *fb_addr = (void *)(get_fb_base_kb() * KiB); |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 239 | |
Julius Werner | 68aef11 | 2013-09-03 15:07:31 -0700 | [diff] [blame] | 240 | prepare_usb(); |
Gabe Black | 1387b43 | 2013-05-18 15:55:47 -0700 | [diff] [blame] | 241 | gpio_init(); |
Julius Werner | ad4556f2 | 2013-08-21 17:33:31 -0700 | [diff] [blame] | 242 | setup_storage(); |
Gabe Black | 1387b43 | 2013-05-18 15:55:47 -0700 | [diff] [blame] | 243 | |
David Hendricks | 8ccabb6 | 2013-08-01 19:12:56 -0700 | [diff] [blame] | 244 | i2c_init(TPS65090_BUS, I2C_0_SPEED, I2C_SLAVE); |
Stefan Reinauer | 043eb0e | 2013-05-10 16:21:58 -0700 | [diff] [blame] | 245 | i2c_init(7, I2C_0_SPEED, I2C_SLAVE); |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 246 | |
| 247 | tmu_init(&exynos5250_tmu_info); |
| 248 | |
| 249 | /* Clock Gating all the unused IP's to save power */ |
| 250 | clock_gate(); |
| 251 | |
| 252 | /* Disable USB3.0 PLL to save 250mW of power */ |
| 253 | disable_usb30_pll(); |
| 254 | |
Julius Werner | ad4556f2 | 2013-08-21 17:33:31 -0700 | [diff] [blame] | 255 | sdmmc_vdd(); |
| 256 | |
Patrick Rudolph | 8b56c8c | 2020-02-19 12:57:00 +0100 | [diff] [blame] | 257 | fb_add_framebuffer_info((uintptr_t)fb_addr, 1366, 768, 2 * 1366, 16); |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 258 | |
Stefan Reinauer | 043eb0e | 2013-05-10 16:21:58 -0700 | [diff] [blame] | 259 | lcd_vdd(); |
Stefan Reinauer | a86c33a | 2013-05-17 10:34:25 -0700 | [diff] [blame] | 260 | |
| 261 | // FIXME: should timeout |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 262 | do { |
| 263 | udelay(50); |
| 264 | } while (!exynos_dp_hotplug()); |
| 265 | |
| 266 | exynos_dp_bridge_setup(); |
Stefan Reinauer | 043eb0e | 2013-05-10 16:21:58 -0700 | [diff] [blame] | 267 | for (dp_tries = 1; dp_tries <= MAX_DP_TRIES; dp_tries++) { |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 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 | |
Stefan Reinauer | 043eb0e | 2013-05-10 16:21:58 -0700 | [diff] [blame] | 279 | backlight_vdd(); |
| 280 | backlight_pwm(); |
| 281 | backlight_en(); |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 282 | /* if we're here, we're successful */ |
| 283 | break; |
| 284 | } |
| 285 | |
Stefan Reinauer | 043eb0e | 2013-05-10 16:21:58 -0700 | [diff] [blame] | 286 | if (dp_tries > MAX_DP_TRIES) |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 287 | printk(BIOS_ERR, "%s: Failed to set up displayport\n", __func__); |
Stefan Reinauer | dc006c1 | 2013-05-15 14:54:07 -0700 | [diff] [blame] | 288 | |
Julius Werner | 68aef11 | 2013-09-03 15:07:31 -0700 | [diff] [blame] | 289 | setup_usb(); |
| 290 | |
Stefan Reinauer | a86c33a | 2013-05-17 10:34:25 -0700 | [diff] [blame] | 291 | // Uncomment to get excessive GPIO output: |
| 292 | // gpio_info(); |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 293 | } |
| 294 | |
Elyes HAOUAS | d129d43 | 2018-05-04 20:23:33 +0200 | [diff] [blame] | 295 | static void mainboard_enable(struct device *dev) |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 296 | { |
| 297 | dev->ops->init = &mainboard_init; |
| 298 | |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 299 | /* set up dcache and MMU */ |
| 300 | /* FIXME: this should happen via resource allocator */ |
| 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); |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 305 | mmu_config_range((uintptr_t)_dma_coherent/MiB, |
Julius Werner | 7e0dea6 | 2019-02-20 18:39:22 -0800 | [diff] [blame] | 306 | REGION_SIZE(dma_coherent)/MiB, DCACHE_OFF); |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 307 | mmu_config_range(DRAM_END, 4096 - DRAM_END, DCACHE_OFF); |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 308 | dcache_mmu_enable(); |
| 309 | |
Martin Roth | ad0f485 | 2019-10-23 21:41:43 -0600 | [diff] [blame] | 310 | const unsigned int epll_hz = 192000000; |
| 311 | const unsigned int sample_rate = 48000; |
| 312 | const unsigned int lr_frame_size = 256; |
Stefan Reinauer | 2ae6d6f | 2013-05-09 16:16:13 -0700 | [diff] [blame] | 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 | |
Ronald G. Minnich | f89e6b2 | 2012-12-10 16:13:43 -0800 | [diff] [blame] | 320 | struct chip_operations mainboard_ops = { |
David Hendricks | 054c83a | 2015-01-09 11:46:43 -0800 | [diff] [blame] | 321 | .name = "daisy", |
| 322 | .enable_dev = mainboard_enable, |
Ronald G. Minnich | f89e6b2 | 2012-12-10 16:13:43 -0800 | [diff] [blame] | 323 | }; |
Julius Werner | b8fad3d | 2013-08-27 15:48:32 -0700 | [diff] [blame] | 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); |
Patrick Georgi | 68999a8 | 2019-05-23 12:44:00 +0200 | [diff] [blame] | 330 | dma->tag = LB_TAG_DMA; |
Julius Werner | b8fad3d | 2013-08-27 15:48:32 -0700 | [diff] [blame] | 331 | dma->size = sizeof(*dma); |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 332 | dma->range_start = (uintptr_t)_dma_coherent; |
Julius Werner | 7e0dea6 | 2019-02-20 18:39:22 -0800 | [diff] [blame] | 333 | dma->range_size = REGION_SIZE(dma_coherent); |
Julius Werner | b8fad3d | 2013-08-27 15:48:32 -0700 | [diff] [blame] | 334 | } |