Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Chander Kashyap | 0d2f277 | 2013-08-21 10:38:56 +0530 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2013 Samsung Electronics |
Chander Kashyap | 0d2f277 | 2013-08-21 10:38:56 +0530 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Simon Glass | 370382c | 2019-11-14 12:57:35 -0700 | [diff] [blame] | 7 | #include <cpu_func.h> |
Simon Glass | 8e16b1e | 2019-12-28 10:45:05 -0700 | [diff] [blame] | 8 | #include <init.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 9 | #include <log.h> |
Inderpal Singh | 3260bc8 | 2014-01-08 09:19:57 +0530 | [diff] [blame] | 10 | #include <usb.h> |
Simon Glass | 37f1162 | 2014-10-20 19:48:37 -0600 | [diff] [blame] | 11 | #include <asm/gpio.h> |
Chander Kashyap | 0d2f277 | 2013-08-21 10:38:56 +0530 | [diff] [blame] | 12 | #include <asm/arch/pinmux.h> |
Inderpal Singh | 04bb737 | 2013-08-21 10:38:57 +0530 | [diff] [blame] | 13 | #include <asm/arch/dwmmc.h> |
Chander Kashyap | 0d2f277 | 2013-08-21 10:38:56 +0530 | [diff] [blame] | 14 | #include <asm/arch/power.h> |
| 15 | |
| 16 | DECLARE_GLOBAL_DATA_PTR; |
| 17 | |
Inderpal Singh | 3260bc8 | 2014-01-08 09:19:57 +0530 | [diff] [blame] | 18 | #ifdef CONFIG_USB_EHCI_EXYNOS |
| 19 | int board_usb_init(int index, enum usb_init_type init) |
| 20 | { |
Inderpal Singh | 3260bc8 | 2014-01-08 09:19:57 +0530 | [diff] [blame] | 21 | /* Configure gpios for usb 3503 hub: |
| 22 | * disconnect, toggle reset and connect |
| 23 | */ |
Simon Glass | 4f83d3d | 2014-10-20 19:48:39 -0600 | [diff] [blame] | 24 | gpio_request(EXYNOS5_GPIO_D17, "usb_connect"); |
| 25 | gpio_request(EXYNOS5_GPIO_X35, "usb_reset"); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 26 | gpio_direction_output(EXYNOS5_GPIO_D17, 0); |
| 27 | gpio_direction_output(EXYNOS5_GPIO_X35, 0); |
Inderpal Singh | 3260bc8 | 2014-01-08 09:19:57 +0530 | [diff] [blame] | 28 | |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 29 | gpio_direction_output(EXYNOS5_GPIO_X35, 1); |
| 30 | gpio_direction_output(EXYNOS5_GPIO_D17, 1); |
Inderpal Singh | 3260bc8 | 2014-01-08 09:19:57 +0530 | [diff] [blame] | 31 | |
| 32 | return 0; |
| 33 | } |
| 34 | #endif |
| 35 | |
Chander Kashyap | 0d2f277 | 2013-08-21 10:38:56 +0530 | [diff] [blame] | 36 | int board_init(void) |
| 37 | { |
| 38 | gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL); |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | int dram_init(void) |
| 43 | { |
| 44 | int i; |
| 45 | u32 addr; |
| 46 | |
| 47 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { |
| 48 | addr = CONFIG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE); |
| 49 | gd->ram_size += get_ram_size((long *)addr, SDRAM_BANK_SIZE); |
| 50 | } |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | int power_init_board(void) |
| 55 | { |
| 56 | set_ps_hold_ctrl(); |
| 57 | return 0; |
| 58 | } |
| 59 | |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 60 | int dram_init_banksize(void) |
Chander Kashyap | 0d2f277 | 2013-08-21 10:38:56 +0530 | [diff] [blame] | 61 | { |
| 62 | int i; |
| 63 | u32 addr, size; |
| 64 | |
| 65 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { |
| 66 | addr = CONFIG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE); |
| 67 | size = get_ram_size((long *)addr, SDRAM_BANK_SIZE); |
| 68 | |
| 69 | gd->bd->bi_dram[i].start = addr; |
| 70 | gd->bd->bi_dram[i].size = size; |
| 71 | } |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 72 | |
| 73 | return 0; |
Chander Kashyap | 0d2f277 | 2013-08-21 10:38:56 +0530 | [diff] [blame] | 74 | } |
| 75 | |
Masahiro Yamada | 0a78017 | 2017-05-09 20:31:39 +0900 | [diff] [blame] | 76 | #ifdef CONFIG_MMC |
Inderpal Singh | 04bb737 | 2013-08-21 10:38:57 +0530 | [diff] [blame] | 77 | int board_mmc_init(bd_t *bis) |
| 78 | { |
| 79 | int ret; |
| 80 | /* dwmmc initializattion for available channels */ |
| 81 | ret = exynos_dwmmc_init(gd->fdt_blob); |
| 82 | if (ret) |
| 83 | debug("dwmmc init failed\n"); |
| 84 | |
| 85 | return ret; |
| 86 | } |
| 87 | #endif |
| 88 | |
Chander Kashyap | 0d2f277 | 2013-08-21 10:38:56 +0530 | [diff] [blame] | 89 | static int board_uart_init(void) |
| 90 | { |
| 91 | int err = 0, uart_id; |
| 92 | |
| 93 | for (uart_id = PERIPH_ID_UART0; uart_id <= PERIPH_ID_UART3; uart_id++) { |
| 94 | err = exynos_pinmux_config(uart_id, PINMUX_FLAG_NONE); |
| 95 | if (err) { |
| 96 | debug("UART%d not configured\n", |
| 97 | (uart_id - PERIPH_ID_UART0)); |
| 98 | return err; |
| 99 | } |
| 100 | } |
| 101 | return err; |
| 102 | } |
| 103 | |
| 104 | #ifdef CONFIG_BOARD_EARLY_INIT_F |
| 105 | int board_early_init_f(void) |
| 106 | { |
| 107 | int err; |
| 108 | |
| 109 | err = board_uart_init(); |
| 110 | if (err) { |
| 111 | debug("UART init failed\n"); |
| 112 | return err; |
| 113 | } |
| 114 | return err; |
| 115 | } |
| 116 | #endif |
| 117 | |
| 118 | #ifdef CONFIG_DISPLAY_BOARDINFO |
| 119 | int checkboard(void) |
| 120 | { |
| 121 | printf("\nBoard: Arndale\n"); |
| 122 | |
| 123 | return 0; |
| 124 | } |
| 125 | #endif |
Andre Przywara | 64d4c22 | 2014-08-01 13:35:44 +0200 | [diff] [blame] | 126 | |
| 127 | #ifdef CONFIG_S5P_PA_SYSRAM |
| 128 | void smp_set_core_boot_addr(unsigned long addr, int corenr) |
| 129 | { |
| 130 | writel(addr, CONFIG_S5P_PA_SYSRAM); |
| 131 | |
| 132 | /* make sure this write is really executed */ |
| 133 | __asm__ volatile ("dsb\n"); |
| 134 | } |
| 135 | #endif |