blob: 00b08987e9e8f6ac7072775c1454964ec18e40ca [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Luka Perkov9f497062012-09-05 08:01:25 +00002/*
Tony Dinhb2564072022-02-01 21:59:27 -08003 * Copyright (C) 2022 Tony Dinh <mibodhi@gmail.com>
Luka Perkov9f497062012-09-05 08:01:25 +00004 * Copyright (C) 2009-2012
5 * Wojciech Dubowik <wojciech.dubowik@neratec.com>
Luka Perkove91505d2012-12-03 03:24:15 +00006 * Luka Perkov <luka@openwrt.org>
Luka Perkov9f497062012-09-05 08:01:25 +00007 */
8
Simon Glass97589732020-05-10 11:40:02 -06009#include <init.h>
Tony Dinhb2564072022-02-01 21:59:27 -080010#include <netdev.h>
Luka Perkov9f497062012-09-05 08:01:25 +000011#include <asm/arch/cpu.h>
Stefan Roesec2437842014-10-22 12:13:06 +020012#include <asm/arch/soc.h>
Luka Perkov9f497062012-09-05 08:01:25 +000013#include <asm/arch/mpp.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060014#include <asm/global_data.h>
Tony Dinhb2564072022-02-01 21:59:27 -080015#include <linux/bitops.h>
Luka Perkov9f497062012-09-05 08:01:25 +000016
17DECLARE_GLOBAL_DATA_PTR;
18
Tony Dinhb2564072022-02-01 21:59:27 -080019#define ICONNECT_OE_LOW (~BIT(7))
20#define ICONNECT_OE_HIGH (~BIT(10))
21#define ICONNECT_OE_VAL_LOW (0)
22#define ICONNECT_OE_VAL_HIGH BIT(10)
23
Luka Perkov9f497062012-09-05 08:01:25 +000024int board_early_init_f(void)
25{
26 /*
27 * default gpio configuration
28 * There are maximum 64 gpios controlled through 2 sets of registers
29 * the below configuration configures mainly initial LED status
30 */
Stefan Roesec50ab392014-10-22 12:13:11 +020031 mvebu_config_gpio(ICONNECT_OE_VAL_LOW,
32 ICONNECT_OE_VAL_HIGH,
33 ICONNECT_OE_LOW, ICONNECT_OE_HIGH);
Luka Perkov9f497062012-09-05 08:01:25 +000034
35 /* Multi-Purpose Pins Functionality configuration */
Albert ARIBAUD4d424312012-11-26 11:27:36 +000036 static const u32 kwmpp_config[] = {
Luka Perkov9f497062012-09-05 08:01:25 +000037 MPP0_NF_IO2,
38 MPP1_NF_IO3,
39 MPP2_NF_IO4,
40 MPP3_NF_IO5,
41 MPP4_NF_IO6,
42 MPP5_NF_IO7,
43 MPP6_SYSRST_OUTn, /* Reset signal */
44 MPP7_GPO,
Wolfgang Denkbd8ec7e2013-10-07 13:07:26 +020045 MPP8_TW_SDA, /* I2C */
Luka Perkov9f497062012-09-05 08:01:25 +000046 MPP9_TW_SCK, /* I2C */
47 MPP10_UART0_TXD,
48 MPP11_UART0_RXD,
49 MPP12_GPO, /* Reset button */
50 MPP13_SD_CMD,
51 MPP14_SD_D0,
52 MPP15_SD_D1,
53 MPP16_SD_D2,
54 MPP17_SD_D3,
55 MPP18_NF_IO0,
56 MPP19_NF_IO1,
57 MPP20_GE1_0,
58 MPP21_GE1_1,
59 MPP22_GE1_2,
60 MPP23_GE1_3,
61 MPP24_GE1_4,
62 MPP25_GE1_5,
63 MPP26_GE1_6,
64 MPP27_GE1_7,
65 MPP28_GPIO,
66 MPP29_GPIO,
67 MPP30_GE1_10,
68 MPP31_GE1_11,
69 MPP32_GE1_12,
70 MPP33_GE1_13,
71 MPP34_GE1_14,
72 MPP35_GPIO, /* OTB button */
73 MPP36_AUDIO_SPDIFI,
74 MPP37_AUDIO_SPDIFO,
75 MPP38_GPIO,
76 MPP39_TDM_SPI_CS0,
77 MPP40_TDM_SPI_SCK,
78 MPP41_GPIO, /* LED brightness */
79 MPP42_GPIO, /* LED power (blue) */
80 MPP43_GPIO, /* LED power (red) */
81 MPP44_GPIO, /* LED USB 1 */
82 MPP45_GPIO, /* LED USB 2 */
83 MPP46_GPIO, /* LED USB 3 */
84 MPP47_GPIO, /* LED USB 4 */
85 MPP48_GPIO, /* LED OTB */
86 MPP49_GPIO,
87 0
88 };
89 kirkwood_mpp_conf(kwmpp_config, NULL);
90 return 0;
91}
92
Tony Dinhb2564072022-02-01 21:59:27 -080093int board_eth_init(struct bd_info *bis)
94{
95 return cpu_eth_init(bis);
96}
97
Luka Perkov9f497062012-09-05 08:01:25 +000098int board_init(void)
99{
Tony Dinhb2564072022-02-01 21:59:27 -0800100 /* address of boot parameters */
Stefan Roese0b741752014-10-22 12:13:13 +0200101 gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
Luka Perkov9f497062012-09-05 08:01:25 +0000102
103 return 0;
104}
Tony Dinh94142cc2022-01-01 20:57:38 -0800105
106int board_late_init(void)
107{
108 /* Do late init to ensure successful enumeration of PCIe devices */
109 pci_init();
110 return 0;
111}