Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Luka Perkov | 9b91472 | 2012-09-05 08:01:25 +0000 | [diff] [blame] | 2 | /* |
Tony Dinh | f99a169 | 2022-02-01 21:59:27 -0800 | [diff] [blame] | 3 | * Copyright (C) 2022 Tony Dinh <mibodhi@gmail.com> |
Luka Perkov | 9b91472 | 2012-09-05 08:01:25 +0000 | [diff] [blame] | 4 | * Copyright (C) 2009-2012 |
| 5 | * Wojciech Dubowik <wojciech.dubowik@neratec.com> |
Luka Perkov | 3fdf759 | 2012-12-03 03:24:15 +0000 | [diff] [blame] | 6 | * Luka Perkov <luka@openwrt.org> |
Luka Perkov | 9b91472 | 2012-09-05 08:01:25 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Simon Glass | 691d719 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 10 | #include <init.h> |
Tony Dinh | f99a169 | 2022-02-01 21:59:27 -0800 | [diff] [blame] | 11 | #include <netdev.h> |
Luka Perkov | 9b91472 | 2012-09-05 08:01:25 +0000 | [diff] [blame] | 12 | #include <asm/arch/cpu.h> |
Stefan Roese | 3dc23f7 | 2014-10-22 12:13:06 +0200 | [diff] [blame] | 13 | #include <asm/arch/soc.h> |
Luka Perkov | 9b91472 | 2012-09-05 08:01:25 +0000 | [diff] [blame] | 14 | #include <asm/arch/mpp.h> |
Simon Glass | 401d1c4 | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 15 | #include <asm/global_data.h> |
Tony Dinh | f99a169 | 2022-02-01 21:59:27 -0800 | [diff] [blame] | 16 | #include <linux/bitops.h> |
Luka Perkov | 9b91472 | 2012-09-05 08:01:25 +0000 | [diff] [blame] | 17 | |
| 18 | DECLARE_GLOBAL_DATA_PTR; |
| 19 | |
Tony Dinh | f99a169 | 2022-02-01 21:59:27 -0800 | [diff] [blame] | 20 | #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 Perkov | 9b91472 | 2012-09-05 08:01:25 +0000 | [diff] [blame] | 25 | int 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 Roese | d5c5132 | 2014-10-22 12:13:11 +0200 | [diff] [blame] | 32 | mvebu_config_gpio(ICONNECT_OE_VAL_LOW, |
| 33 | ICONNECT_OE_VAL_HIGH, |
| 34 | ICONNECT_OE_LOW, ICONNECT_OE_HIGH); |
Luka Perkov | 9b91472 | 2012-09-05 08:01:25 +0000 | [diff] [blame] | 35 | |
| 36 | /* Multi-Purpose Pins Functionality configuration */ |
Albert ARIBAUD | 9d86f0c | 2012-11-26 11:27:36 +0000 | [diff] [blame] | 37 | static const u32 kwmpp_config[] = { |
Luka Perkov | 9b91472 | 2012-09-05 08:01:25 +0000 | [diff] [blame] | 38 | 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 Denk | 3765b3e | 2013-10-07 13:07:26 +0200 | [diff] [blame] | 46 | MPP8_TW_SDA, /* I2C */ |
Luka Perkov | 9b91472 | 2012-09-05 08:01:25 +0000 | [diff] [blame] | 47 | 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 Dinh | f99a169 | 2022-02-01 21:59:27 -0800 | [diff] [blame] | 94 | int board_eth_init(struct bd_info *bis) |
| 95 | { |
| 96 | return cpu_eth_init(bis); |
| 97 | } |
| 98 | |
Luka Perkov | 9b91472 | 2012-09-05 08:01:25 +0000 | [diff] [blame] | 99 | int board_init(void) |
| 100 | { |
Tony Dinh | f99a169 | 2022-02-01 21:59:27 -0800 | [diff] [blame] | 101 | /* address of boot parameters */ |
Stefan Roese | 96c5f08 | 2014-10-22 12:13:13 +0200 | [diff] [blame] | 102 | gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100; |
Luka Perkov | 9b91472 | 2012-09-05 08:01:25 +0000 | [diff] [blame] | 103 | |
| 104 | return 0; |
| 105 | } |
Tony Dinh | bbebd5b | 2022-01-01 20:57:38 -0800 | [diff] [blame] | 106 | |
| 107 | int board_late_init(void) |
| 108 | { |
| 109 | /* Do late init to ensure successful enumeration of PCIe devices */ |
| 110 | pci_init(); |
| 111 | return 0; |
| 112 | } |