1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2015 Stefan Roese <sr@denx.de>
4  */
5 
6 #include <common.h>
7 #include <i2c.h>
8 #include <init.h>
9 #include <asm/global_data.h>
10 #include <asm/gpio.h>
11 #include <linux/bitops.h>
12 #include <linux/mbus.h>
13 #include <linux/io.h>
14 #include <asm/arch/cpu.h>
15 #include <asm/arch/soc.h>
16 
17 DECLARE_GLOBAL_DATA_PTR;
18 
19 /*
20  * These values and defines are taken from the Marvell U-Boot version
21  * "u-boot-2013.01-2016_T1.0.eng_drop_v6"
22  */
23 #define DB_DX_AC3_GPP_OUT_ENA_LOW	(~(BIT(0) | BIT(2) | BIT(3) | BIT(4) | BIT(6) | BIT(12) \
24 					| BIT(13) | BIT(16) | BIT(17) | BIT(20) | BIT(29)  | BIT(30)))
25 #define DB_DX_AC3_GPP_OUT_ENA_MID	(~(0))
26 #define DB_DX_AC3_GPP_OUT_VAL_LOW	(BIT(0) | BIT(2) | BIT(3) | BIT(4) | BIT(6) | BIT(12) \
27 					| BIT(13) | BIT(16) | BIT(17) | BIT(20) | BIT(29)  | BIT(30))
28 #define DB_DX_AC3_GPP_OUT_VAL_MID	0x0
29 #define DB_DX_AC3_GPP_POL_LOW		0x0
30 #define DB_DX_AC3_GPP_POL_MID		0x0
31 
board_early_init_f(void)32 int board_early_init_f(void)
33 {
34 	/* Configure MPP */
35 	writel(0x00142222, MVEBU_MPP_BASE + 0x00);
36 	writel(0x11122000, MVEBU_MPP_BASE + 0x04);
37 	writel(0x44444004, MVEBU_MPP_BASE + 0x08);
38 	writel(0x14444444, MVEBU_MPP_BASE + 0x0c);
39 	writel(0x00000001, MVEBU_MPP_BASE + 0x10);
40 
41 	/* Set GPP Out value */
42 	writel(DB_DX_AC3_GPP_OUT_VAL_LOW, MVEBU_GPIO0_BASE + 0x00);
43 	writel(DB_DX_AC3_GPP_OUT_VAL_MID, MVEBU_GPIO1_BASE + 0x00);
44 
45 	/* Set GPP Polarity */
46 	writel(DB_DX_AC3_GPP_POL_LOW, MVEBU_GPIO0_BASE + 0x0c);
47 	writel(DB_DX_AC3_GPP_POL_MID, MVEBU_GPIO1_BASE + 0x0c);
48 
49 	/* Set GPP Out Enable */
50 	writel(DB_DX_AC3_GPP_OUT_ENA_LOW, MVEBU_GPIO0_BASE + 0x04);
51 	writel(DB_DX_AC3_GPP_OUT_ENA_MID, MVEBU_GPIO1_BASE + 0x04);
52 
53 	return 0;
54 }
55 
board_init(void)56 int board_init(void)
57 {
58 	/* address of boot parameters */
59 	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
60 
61 	return 0;
62 }
63 
64 #ifdef CONFIG_DISPLAY_BOARDINFO
checkboard(void)65 int checkboard(void)
66 {
67 	puts("Board: " CONFIG_SYS_BOARD "\n");
68 
69 	return 0;
70 }
71 #endif
72