xref: /rk3399_rockchip-uboot/board/quipos/cairo/cairo.c (revision c7b9686d5d482c8e952598841ea467e6ec0ec0de)
1d275c40cSAlbert ARIBAUD \(3ADEV\) /*
2d275c40cSAlbert ARIBAUD \(3ADEV\)  * Copyright (c) 2014 DENX
3d275c40cSAlbert ARIBAUD \(3ADEV\)  * Written-by: Albert ARIBAUD <albert.aribaud@3adev.fr>
4d275c40cSAlbert ARIBAUD \(3ADEV\)  *
5d275c40cSAlbert ARIBAUD \(3ADEV\)  * Derived from code written by Robert Aigner (ra@spiid.net)
6d275c40cSAlbert ARIBAUD \(3ADEV\)  *
7d275c40cSAlbert ARIBAUD \(3ADEV\)  * Itself derived from Beagle Board and 3430 SDP code by
8d275c40cSAlbert ARIBAUD \(3ADEV\)  *	Richard Woodruff <r-woodruff2@ti.com>
9d275c40cSAlbert ARIBAUD \(3ADEV\)  *	Syed Mohammed Khasim <khasim@ti.com>
10d275c40cSAlbert ARIBAUD \(3ADEV\)  *
11d275c40cSAlbert ARIBAUD \(3ADEV\)  * SPDX-License-Identifier:	GPL-2.0+
12d275c40cSAlbert ARIBAUD \(3ADEV\)  */
13d275c40cSAlbert ARIBAUD \(3ADEV\) #include <common.h>
14d275c40cSAlbert ARIBAUD \(3ADEV\) #include <dm.h>
15d275c40cSAlbert ARIBAUD \(3ADEV\) #include <netdev.h>
16d275c40cSAlbert ARIBAUD \(3ADEV\) #include <ns16550.h>
17d275c40cSAlbert ARIBAUD \(3ADEV\) #include <asm/io.h>
18d275c40cSAlbert ARIBAUD \(3ADEV\) #include <asm/arch/mem.h>
19d275c40cSAlbert ARIBAUD \(3ADEV\) #include <asm/arch/mux.h>
20d275c40cSAlbert ARIBAUD \(3ADEV\) #include <asm/arch/sys_proto.h>
21d275c40cSAlbert ARIBAUD \(3ADEV\) #include <i2c.h>
22d275c40cSAlbert ARIBAUD \(3ADEV\) #include <asm/mach-types.h>
23d275c40cSAlbert ARIBAUD \(3ADEV\) #include <asm/omap_mmc.h>
24d275c40cSAlbert ARIBAUD \(3ADEV\) #include "cairo.h"
25d275c40cSAlbert ARIBAUD \(3ADEV\) 
26d275c40cSAlbert ARIBAUD \(3ADEV\) DECLARE_GLOBAL_DATA_PTR;
27d275c40cSAlbert ARIBAUD \(3ADEV\) 
28d275c40cSAlbert ARIBAUD \(3ADEV\) /*
29d275c40cSAlbert ARIBAUD \(3ADEV\)  * MUSB port on OMAP3EVM Rev >= E requires extvbus programming.
30d275c40cSAlbert ARIBAUD \(3ADEV\)  */
31d275c40cSAlbert ARIBAUD \(3ADEV\) u8 omap3_evm_need_extvbus(void)
32d275c40cSAlbert ARIBAUD \(3ADEV\) {
33d275c40cSAlbert ARIBAUD \(3ADEV\) 	u8 retval = 0;
34d275c40cSAlbert ARIBAUD \(3ADEV\) 
35d275c40cSAlbert ARIBAUD \(3ADEV\) 	/* TODO: verify if cairo handheld platform needs extvbus programming */
36d275c40cSAlbert ARIBAUD \(3ADEV\) 
37d275c40cSAlbert ARIBAUD \(3ADEV\) 	return retval;
38d275c40cSAlbert ARIBAUD \(3ADEV\) }
39d275c40cSAlbert ARIBAUD \(3ADEV\) 
40d275c40cSAlbert ARIBAUD \(3ADEV\) /*
41d275c40cSAlbert ARIBAUD \(3ADEV\)  * Routine: board_init
42d275c40cSAlbert ARIBAUD \(3ADEV\)  * Description: Early hardware init.
43d275c40cSAlbert ARIBAUD \(3ADEV\)  */
44d275c40cSAlbert ARIBAUD \(3ADEV\) int board_init(void)
45d275c40cSAlbert ARIBAUD \(3ADEV\) {
46d275c40cSAlbert ARIBAUD \(3ADEV\) 	gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
47d275c40cSAlbert ARIBAUD \(3ADEV\) 	/* board id for Linux */
48d275c40cSAlbert ARIBAUD \(3ADEV\) 	gd->bd->bi_arch_number = MACH_TYPE_OMAP3_CAIRO;
49d275c40cSAlbert ARIBAUD \(3ADEV\) 	/* boot param addr */
50d275c40cSAlbert ARIBAUD \(3ADEV\) 	gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
51d275c40cSAlbert ARIBAUD \(3ADEV\) 	return 0;
52d275c40cSAlbert ARIBAUD \(3ADEV\) }
53d275c40cSAlbert ARIBAUD \(3ADEV\) 
54d275c40cSAlbert ARIBAUD \(3ADEV\) /*
55d275c40cSAlbert ARIBAUD \(3ADEV\)  * Routine: set_muxconf_regs
56d275c40cSAlbert ARIBAUD \(3ADEV\)  * Description: Setting up the configuration Mux registers specific to the
57d275c40cSAlbert ARIBAUD \(3ADEV\)  *		hardware. Many pins need to be moved from protect to primary
58d275c40cSAlbert ARIBAUD \(3ADEV\)  *		mode.
59d275c40cSAlbert ARIBAUD \(3ADEV\)  */
60d275c40cSAlbert ARIBAUD \(3ADEV\) void set_muxconf_regs(void)
61d275c40cSAlbert ARIBAUD \(3ADEV\) {
62d275c40cSAlbert ARIBAUD \(3ADEV\) 	MUX_CAIRO();
63d275c40cSAlbert ARIBAUD \(3ADEV\) }
64d275c40cSAlbert ARIBAUD \(3ADEV\) 
65d275c40cSAlbert ARIBAUD \(3ADEV\) #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
66d275c40cSAlbert ARIBAUD \(3ADEV\) int board_mmc_init(bd_t *bis)
67d275c40cSAlbert ARIBAUD \(3ADEV\) {
68d275c40cSAlbert ARIBAUD \(3ADEV\) 	return omap_mmc_init(0, 0, 0, -1, -1);
69d275c40cSAlbert ARIBAUD \(3ADEV\) }
70d275c40cSAlbert ARIBAUD \(3ADEV\) #endif
71d275c40cSAlbert ARIBAUD \(3ADEV\) 
72d275c40cSAlbert ARIBAUD \(3ADEV\) #ifdef CONFIG_SPL_BUILD
73d275c40cSAlbert ARIBAUD \(3ADEV\) /*
74d275c40cSAlbert ARIBAUD \(3ADEV\)  * Routine: get_board_mem_timings
75d275c40cSAlbert ARIBAUD \(3ADEV\)  * Description: If we use SPL then there is no x-loader nor config header
76d275c40cSAlbert ARIBAUD \(3ADEV\)  * so we have to setup the DDR timings ourself on the first bank.  This
77d275c40cSAlbert ARIBAUD \(3ADEV\)  * provides the timing values back to the function that configures
78d275c40cSAlbert ARIBAUD \(3ADEV\)  * the memory.
79d275c40cSAlbert ARIBAUD \(3ADEV\)  *
80d275c40cSAlbert ARIBAUD \(3ADEV\)  * The Cairo board uses SAMSUNG DDR - K4X51163PG-FGC6
81d275c40cSAlbert ARIBAUD \(3ADEV\)  */
82d275c40cSAlbert ARIBAUD \(3ADEV\) void get_board_mem_timings(struct board_sdrc_timings *timings)
83d275c40cSAlbert ARIBAUD \(3ADEV\) {
84d275c40cSAlbert ARIBAUD \(3ADEV\) 	timings->sharing = SAMSUNG_SHARING;
85d275c40cSAlbert ARIBAUD \(3ADEV\) 	timings->mcfg = SAMSUNG_V_MCFG_165(128 << 20);
86d275c40cSAlbert ARIBAUD \(3ADEV\) 	timings->ctrla = SAMSUNG_V_ACTIMA_165;
87d275c40cSAlbert ARIBAUD \(3ADEV\) 	timings->ctrlb = SAMSUNG_V_ACTIMB_165;
88d275c40cSAlbert ARIBAUD \(3ADEV\) 	timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
89d275c40cSAlbert ARIBAUD \(3ADEV\) 	timings->mr = SAMSUNG_V_MR_165;
90d275c40cSAlbert ARIBAUD \(3ADEV\) }
91d275c40cSAlbert ARIBAUD \(3ADEV\) #endif
92d275c40cSAlbert ARIBAUD \(3ADEV\) 
93d275c40cSAlbert ARIBAUD \(3ADEV\) static const struct ns16550_platdata cairo_serial = {
94d275c40cSAlbert ARIBAUD \(3ADEV\) 	OMAP34XX_UART2,
95d275c40cSAlbert ARIBAUD \(3ADEV\) 	2,
96d275c40cSAlbert ARIBAUD \(3ADEV\) 	V_NS16550_CLK
97d275c40cSAlbert ARIBAUD \(3ADEV\) };
98d275c40cSAlbert ARIBAUD \(3ADEV\) 
99d275c40cSAlbert ARIBAUD \(3ADEV\) U_BOOT_DEVICE(cairo_uart) = {
100*c7b9686dSThomas Chou 	"ns16550_serial",
101d275c40cSAlbert ARIBAUD \(3ADEV\) 	&cairo_serial
102d275c40cSAlbert ARIBAUD \(3ADEV\) };
103d275c40cSAlbert ARIBAUD \(3ADEV\) 
104d275c40cSAlbert ARIBAUD \(3ADEV\) /* force SPL booting into U-Boot, not Linux */
105d275c40cSAlbert ARIBAUD \(3ADEV\) #ifdef CONFIG_SPL_OS_BOOT
106d275c40cSAlbert ARIBAUD \(3ADEV\) int spl_start_uboot(void)
107d275c40cSAlbert ARIBAUD \(3ADEV\) {
108d275c40cSAlbert ARIBAUD \(3ADEV\) 	return 1;
109d275c40cSAlbert ARIBAUD \(3ADEV\) }
110d275c40cSAlbert ARIBAUD \(3ADEV\) #endif
111