xref: /openbmc/u-boot/board/elgin/elgin_rv1108/elgin_rv1108.c (revision d597b26d5132643118333b2372757fb402ba0579)
1*e11ef3d2SOtavio Salvador // SPDX-License-Identifier: GPL-2.0+
2*e11ef3d2SOtavio Salvador /*
3*e11ef3d2SOtavio Salvador  * (C)Copyright 2016 Rockchip Electronics Co., Ltd
4*e11ef3d2SOtavio Salvador  * Authors: Andy Yan <andy.yan@rock-chips.com>
5*e11ef3d2SOtavio Salvador  */
6*e11ef3d2SOtavio Salvador 
7*e11ef3d2SOtavio Salvador #include <common.h>
8*e11ef3d2SOtavio Salvador #include <asm/io.h>
9*e11ef3d2SOtavio Salvador #include <fdtdec.h>
10*e11ef3d2SOtavio Salvador #include <asm/arch/grf_rv1108.h>
11*e11ef3d2SOtavio Salvador #include <asm/arch/hardware.h>
12*e11ef3d2SOtavio Salvador #include <asm/gpio.h>
13*e11ef3d2SOtavio Salvador 
14*e11ef3d2SOtavio Salvador DECLARE_GLOBAL_DATA_PTR;
15*e11ef3d2SOtavio Salvador 
mach_cpu_init(void)16*e11ef3d2SOtavio Salvador int mach_cpu_init(void)
17*e11ef3d2SOtavio Salvador {
18*e11ef3d2SOtavio Salvador 	int node;
19*e11ef3d2SOtavio Salvador 	struct rv1108_grf *grf;
20*e11ef3d2SOtavio Salvador 	enum {
21*e11ef3d2SOtavio Salvador 		GPIO3C3_SHIFT           = 6,
22*e11ef3d2SOtavio Salvador 		GPIO3C3_MASK            = 3 << GPIO3C3_SHIFT,
23*e11ef3d2SOtavio Salvador 
24*e11ef3d2SOtavio Salvador 		GPIO3C2_SHIFT           = 4,
25*e11ef3d2SOtavio Salvador 		GPIO3C2_MASK            = 3 << GPIO3C2_SHIFT,
26*e11ef3d2SOtavio Salvador 
27*e11ef3d2SOtavio Salvador 		GPIO2D2_SHIFT		= 4,
28*e11ef3d2SOtavio Salvador 		GPIO2D2_MASK		= 3 << GPIO2D2_SHIFT,
29*e11ef3d2SOtavio Salvador 		GPIO2D2_GPIO            = 0,
30*e11ef3d2SOtavio Salvador 		GPIO2D2_UART2_SOUT_M0,
31*e11ef3d2SOtavio Salvador 
32*e11ef3d2SOtavio Salvador 		GPIO2D1_SHIFT		= 2,
33*e11ef3d2SOtavio Salvador 		GPIO2D1_MASK		= 3 << GPIO2D1_SHIFT,
34*e11ef3d2SOtavio Salvador 		GPIO2D1_GPIO            = 0,
35*e11ef3d2SOtavio Salvador 		GPIO2D1_UART2_SIN_M0,
36*e11ef3d2SOtavio Salvador 	};
37*e11ef3d2SOtavio Salvador 
38*e11ef3d2SOtavio Salvador 	node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "rockchip,rv1108-grf");
39*e11ef3d2SOtavio Salvador 	grf = (struct rv1108_grf *)fdtdec_get_addr(gd->fdt_blob, node, "reg");
40*e11ef3d2SOtavio Salvador 
41*e11ef3d2SOtavio Salvador 	/* Elgin board use UART2 m0 for debug*/
42*e11ef3d2SOtavio Salvador 	rk_clrsetreg(&grf->gpio2d_iomux,
43*e11ef3d2SOtavio Salvador 		     GPIO2D2_MASK | GPIO2D1_MASK,
44*e11ef3d2SOtavio Salvador 		     GPIO2D2_UART2_SOUT_M0 << GPIO2D2_SHIFT |
45*e11ef3d2SOtavio Salvador 		     GPIO2D1_UART2_SIN_M0 << GPIO2D1_SHIFT);
46*e11ef3d2SOtavio Salvador 	rk_clrreg(&grf->gpio3c_iomux, GPIO3C3_MASK | GPIO3C2_MASK);
47*e11ef3d2SOtavio Salvador 
48*e11ef3d2SOtavio Salvador 	return 0;
49*e11ef3d2SOtavio Salvador }
50*e11ef3d2SOtavio Salvador 
51*e11ef3d2SOtavio Salvador #define MODEM_ENABLE_GPIO 111
52*e11ef3d2SOtavio Salvador 
board_init(void)53*e11ef3d2SOtavio Salvador int board_init(void)
54*e11ef3d2SOtavio Salvador {
55*e11ef3d2SOtavio Salvador 	gpio_request(MODEM_ENABLE_GPIO, "modem_enable");
56*e11ef3d2SOtavio Salvador 	gpio_direction_output(MODEM_ENABLE_GPIO, 0);
57*e11ef3d2SOtavio Salvador 
58*e11ef3d2SOtavio Salvador 	return 0;
59*e11ef3d2SOtavio Salvador }
60*e11ef3d2SOtavio Salvador 
dram_init(void)61*e11ef3d2SOtavio Salvador int dram_init(void)
62*e11ef3d2SOtavio Salvador {
63*e11ef3d2SOtavio Salvador 	gd->ram_size = 0x8000000;
64*e11ef3d2SOtavio Salvador 
65*e11ef3d2SOtavio Salvador 	return 0;
66*e11ef3d2SOtavio Salvador }
67*e11ef3d2SOtavio Salvador 
dram_init_banksize(void)68*e11ef3d2SOtavio Salvador int dram_init_banksize(void)
69*e11ef3d2SOtavio Salvador {
70*e11ef3d2SOtavio Salvador 	gd->bd->bi_dram[0].start = 0x60000000;
71*e11ef3d2SOtavio Salvador 	gd->bd->bi_dram[0].size = 0x8000000;
72*e11ef3d2SOtavio Salvador 
73*e11ef3d2SOtavio Salvador 	return 0;
74*e11ef3d2SOtavio Salvador }
75