blob: 0387160200190c35a6acad7f0097c0c6dde30204 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Luka Perkov9b914722012-09-05 08:01:25 +00002/*
Tony Dinhf99a1692022-02-01 21:59:27 -08003 * Copyright (C) 2022 Tony Dinh <mibodhi@gmail.com>
Luka Perkov9b914722012-09-05 08:01:25 +00004 * Copyright (C) 2009-2012
5 * Wojciech Dubowik <wojciech.dubowik@neratec.com>
Luka Perkov3fdf7592012-12-03 03:24:15 +00006 * Luka Perkov <luka@openwrt.org>
Luka Perkov9b914722012-09-05 08:01:25 +00007 */
8
9#include <common.h>
Simon Glass691d7192020-05-10 11:40:02 -060010#include <init.h>
Tony Dinhf99a1692022-02-01 21:59:27 -080011#include <netdev.h>
Luka Perkov9b914722012-09-05 08:01:25 +000012#include <asm/arch/cpu.h>
Stefan Roese3dc23f72014-10-22 12:13:06 +020013#include <asm/arch/soc.h>
Luka Perkov9b914722012-09-05 08:01:25 +000014#include <asm/arch/mpp.h>
Simon Glass401d1c42020-10-30 21:38:53 -060015#include <asm/global_data.h>
Tony Dinhf99a1692022-02-01 21:59:27 -080016#include <linux/bitops.h>
Luka Perkov9b914722012-09-05 08:01:25 +000017
18DECLARE_GLOBAL_DATA_PTR;
19
Tony Dinhf99a1692022-02-01 21:59:27 -080020#define ICONNECT_OE_LOW (~BIT(7))
21#define ICONNECT_OE_HIGH (~BIT(10))
22#define ICONNECT_OE_VAL_LOW (0)
23#define ICONNECT_OE_VAL_HIGH BIT(10)
24
Luka Perkov9b914722012-09-05 08:01:25 +000025int board_early_init_f(void)
26{
27 /*
28 * default gpio configuration
29 * There are maximum 64 gpios controlled through 2 sets of registers
30 * the below configuration configures mainly initial LED status
31 */
Stefan Roesed5c51322014-10-22 12:13:11 +020032 mvebu_config_gpio(ICONNECT_OE_VAL_LOW,
33 ICONNECT_OE_VAL_HIGH,
34 ICONNECT_OE_LOW, ICONNECT_OE_HIGH);
Luka Perkov9b914722012-09-05 08:01:25 +000035
36 /* Multi-Purpose Pins Functionality configuration */
Albert ARIBAUD9d86f0c2012-11-26 11:27:36 +000037 static const u32 kwmpp_config[] = {
Luka Perkov9b914722012-09-05 08:01:25 +000038 MPP0_NF_IO2,
39 MPP1_NF_IO3,
40 MPP2_NF_IO4,
41 MPP3_NF_IO5,
42 MPP4_NF_IO6,
43 MPP5_NF_IO7,
44 MPP6_SYSRST_OUTn, /* Reset signal */
45 MPP7_GPO,
Wolfgang Denk3765b3e2013-10-07 13:07:26 +020046 MPP8_TW_SDA, /* I2C */
Luka Perkov9b914722012-09-05 08:01:25 +000047 MPP9_TW_SCK, /* I2C */
48 MPP10_UART0_TXD,
49 MPP11_UART0_RXD,
50 MPP12_GPO, /* Reset button */
51 MPP13_SD_CMD,
52 MPP14_SD_D0,
53 MPP15_SD_D1,
54 MPP16_SD_D2,
55 MPP17_SD_D3,
56 MPP18_NF_IO0,
57 MPP19_NF_IO1,
58 MPP20_GE1_0,
59 MPP21_GE1_1,
60 MPP22_GE1_2,
61 MPP23_GE1_3,
62 MPP24_GE1_4,
63 MPP25_GE1_5,
64 MPP26_GE1_6,
65 MPP27_GE1_7,
66 MPP28_GPIO,
67 MPP29_GPIO,
68 MPP30_GE1_10,
69 MPP31_GE1_11,
70 MPP32_GE1_12,
71 MPP33_GE1_13,
72 MPP34_GE1_14,
73 MPP35_GPIO, /* OTB button */
74 MPP36_AUDIO_SPDIFI,
75 MPP37_AUDIO_SPDIFO,
76 MPP38_GPIO,
77 MPP39_TDM_SPI_CS0,
78 MPP40_TDM_SPI_SCK,
79 MPP41_GPIO, /* LED brightness */
80 MPP42_GPIO, /* LED power (blue) */
81 MPP43_GPIO, /* LED power (red) */
82 MPP44_GPIO, /* LED USB 1 */
83 MPP45_GPIO, /* LED USB 2 */
84 MPP46_GPIO, /* LED USB 3 */
85 MPP47_GPIO, /* LED USB 4 */
86 MPP48_GPIO, /* LED OTB */
87 MPP49_GPIO,
88 0
89 };
90 kirkwood_mpp_conf(kwmpp_config, NULL);
91 return 0;
92}
93
Tony Dinhf99a1692022-02-01 21:59:27 -080094int board_eth_init(struct bd_info *bis)
95{
96 return cpu_eth_init(bis);
97}
98
Luka Perkov9b914722012-09-05 08:01:25 +000099int board_init(void)
100{
Tony Dinhf99a1692022-02-01 21:59:27 -0800101 /* address of boot parameters */
Stefan Roese96c5f082014-10-22 12:13:13 +0200102 gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
Luka Perkov9b914722012-09-05 08:01:25 +0000103
104 return 0;
105}
Tony Dinhbbebd5b2022-01-01 20:57:38 -0800106
107int board_late_init(void)
108{
109 /* Do late init to ensure successful enumeration of PCIe devices */
110 pci_init();
111 return 0;
112}