Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Eric Cooper | a3f41c8 | 2010-11-24 17:11:32 +0530 | [diff] [blame] | 2 | /* |
Tony Dinh | 594e650 | 2022-02-03 14:32:29 -0800 | [diff] [blame] | 3 | * Copyright (C) 2022 Tony Dinh <mibodhi@gmail.com> |
Eric Cooper | a3f41c8 | 2010-11-24 17:11:32 +0530 | [diff] [blame] | 4 | * Copyright (C) 2010 Eric C. Cooper <ecc@cmu.edu> |
| 5 | * |
| 6 | * Based on sheevaplug.c originally written by |
| 7 | * Prafulla Wadaskar <prafulla@marvell.com> |
| 8 | * (C) Copyright 2009 |
| 9 | * Marvell Semiconductor <www.marvell.com> |
Eric Cooper | a3f41c8 | 2010-11-24 17:11:32 +0530 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <common.h> |
Simon Glass | 1ea9789 | 2020-05-10 11:40:00 -0600 | [diff] [blame] | 13 | #include <bootstage.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 14 | #include <init.h> |
Tony Dinh | 594e650 | 2022-02-03 14:32:29 -0800 | [diff] [blame] | 15 | #include <netdev.h> |
Stefan Roese | c243784 | 2014-10-22 12:13:06 +0200 | [diff] [blame] | 16 | #include <asm/arch/soc.h> |
Eric Cooper | a3f41c8 | 2010-11-24 17:11:32 +0530 | [diff] [blame] | 17 | #include <asm/arch/mpp.h> |
Anatolij Gustschin | c8b222e | 2011-10-29 10:09:22 +0000 | [diff] [blame] | 18 | #include <asm/arch/cpu.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 19 | #include <asm/global_data.h> |
Anatolij Gustschin | c8b222e | 2011-10-29 10:09:22 +0000 | [diff] [blame] | 20 | #include <asm/io.h> |
Simon Glass | 0ffb9d6 | 2017-05-31 19:47:48 -0600 | [diff] [blame] | 21 | #include <asm/mach-types.h> |
Tony Dinh | 594e650 | 2022-02-03 14:32:29 -0800 | [diff] [blame] | 22 | #include <linux/bitops.h> |
Eric Cooper | a3f41c8 | 2010-11-24 17:11:32 +0530 | [diff] [blame] | 23 | |
| 24 | DECLARE_GLOBAL_DATA_PTR; |
| 25 | |
Tony Dinh | 594e650 | 2022-02-03 14:32:29 -0800 | [diff] [blame] | 26 | #define DOCKSTAR_OE_LOW (~(0)) |
| 27 | #define DOCKSTAR_OE_HIGH (~(0)) |
| 28 | #define DOCKSTAR_OE_VAL_LOW BIT(29) /* USB_PWEN low */ |
| 29 | #define DOCKSTAR_OE_VAL_HIGH BIT(17) /* LED pin high */ |
| 30 | |
Eric Cooper | a3f41c8 | 2010-11-24 17:11:32 +0530 | [diff] [blame] | 31 | int board_early_init_f(void) |
| 32 | { |
| 33 | /* |
| 34 | * default gpio configuration |
| 35 | * There are maximum 64 gpios controlled through 2 sets of registers |
| 36 | * the below configuration configures mainly initial LED status |
| 37 | */ |
Stefan Roese | c50ab39 | 2014-10-22 12:13:11 +0200 | [diff] [blame] | 38 | mvebu_config_gpio(DOCKSTAR_OE_VAL_LOW, |
| 39 | DOCKSTAR_OE_VAL_HIGH, |
| 40 | DOCKSTAR_OE_LOW, DOCKSTAR_OE_HIGH); |
Eric Cooper | a3f41c8 | 2010-11-24 17:11:32 +0530 | [diff] [blame] | 41 | |
| 42 | /* Multi-Purpose Pins Functionality configuration */ |
Albert ARIBAUD | 4d42431 | 2012-11-26 11:27:36 +0000 | [diff] [blame] | 43 | static const u32 kwmpp_config[] = { |
Eric Cooper | a3f41c8 | 2010-11-24 17:11:32 +0530 | [diff] [blame] | 44 | MPP0_NF_IO2, |
| 45 | MPP1_NF_IO3, |
| 46 | MPP2_NF_IO4, |
| 47 | MPP3_NF_IO5, |
| 48 | MPP4_NF_IO6, |
| 49 | MPP5_NF_IO7, |
| 50 | MPP6_SYSRST_OUTn, |
| 51 | MPP7_GPO, |
| 52 | MPP8_UART0_RTS, |
| 53 | MPP9_UART0_CTS, |
| 54 | MPP10_UART0_TXD, |
| 55 | MPP11_UART0_RXD, |
| 56 | MPP12_SD_CLK, |
| 57 | MPP13_SD_CMD, |
| 58 | MPP14_SD_D0, |
| 59 | MPP15_SD_D1, |
| 60 | MPP16_SD_D2, |
| 61 | MPP17_SD_D3, |
| 62 | MPP18_NF_IO0, |
| 63 | MPP19_NF_IO1, |
| 64 | MPP20_GPIO, |
| 65 | MPP21_GPIO, |
| 66 | MPP22_GPIO, |
| 67 | MPP23_GPIO, |
| 68 | MPP24_GPIO, |
| 69 | MPP25_GPIO, |
| 70 | MPP26_GPIO, |
| 71 | MPP27_GPIO, |
| 72 | MPP28_GPIO, |
| 73 | MPP29_TSMP9, |
| 74 | MPP30_GPIO, |
| 75 | MPP31_GPIO, |
| 76 | MPP32_GPIO, |
| 77 | MPP33_GPIO, |
| 78 | MPP34_GPIO, |
| 79 | MPP35_GPIO, |
| 80 | MPP36_GPIO, |
| 81 | MPP37_GPIO, |
| 82 | MPP38_GPIO, |
| 83 | MPP39_GPIO, |
| 84 | MPP40_GPIO, |
| 85 | MPP41_GPIO, |
| 86 | MPP42_GPIO, |
| 87 | MPP43_GPIO, |
| 88 | MPP44_GPIO, |
| 89 | MPP45_GPIO, |
| 90 | MPP46_GPIO, |
| 91 | MPP47_GPIO, |
| 92 | MPP48_GPIO, |
| 93 | MPP49_GPIO, |
| 94 | 0 |
| 95 | }; |
Valentin Longchamp | 7d0d502 | 2012-06-01 01:31:00 +0000 | [diff] [blame] | 96 | kirkwood_mpp_conf(kwmpp_config, NULL); |
Eric Cooper | a3f41c8 | 2010-11-24 17:11:32 +0530 | [diff] [blame] | 97 | return 0; |
| 98 | } |
| 99 | |
Tony Dinh | 594e650 | 2022-02-03 14:32:29 -0800 | [diff] [blame] | 100 | int board_eth_init(struct bd_info *bis) |
| 101 | { |
| 102 | return cpu_eth_init(bis); |
| 103 | } |
| 104 | |
Eric Cooper | a3f41c8 | 2010-11-24 17:11:32 +0530 | [diff] [blame] | 105 | int board_init(void) |
| 106 | { |
| 107 | /* |
| 108 | * arch number of board |
| 109 | */ |
| 110 | gd->bd->bi_arch_number = MACH_TYPE_DOCKSTAR; |
| 111 | |
| 112 | /* address of boot parameters */ |
Stefan Roese | 0b74175 | 2014-10-22 12:13:13 +0200 | [diff] [blame] | 113 | gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100; |
Eric Cooper | a3f41c8 | 2010-11-24 17:11:32 +0530 | [diff] [blame] | 114 | |
| 115 | return 0; |
| 116 | } |
| 117 | |
Tom Rini | a9765d0 | 2021-05-03 16:48:58 -0400 | [diff] [blame] | 118 | #if CONFIG_IS_ENABLED(BOOTSTAGE) |
Tony Dinh | 594e650 | 2022-02-03 14:32:29 -0800 | [diff] [blame] | 119 | #define GREEN_LED BIT(14) |
| 120 | #define ORANGE_LED BIT(15) |
Eric Cooper | a3f41c8 | 2010-11-24 17:11:32 +0530 | [diff] [blame] | 121 | #define BOTH_LEDS (GREEN_LED | ORANGE_LED) |
| 122 | #define NEITHER_LED 0 |
| 123 | |
| 124 | static void set_leds(u32 leds, u32 blinking) |
| 125 | { |
Stefan Roese | c50ab39 | 2014-10-22 12:13:11 +0200 | [diff] [blame] | 126 | struct kwgpio_registers *r = (struct kwgpio_registers *)MVEBU_GPIO1_BASE; |
Tony Dinh | 594e650 | 2022-02-03 14:32:29 -0800 | [diff] [blame] | 127 | u32 oe; |
| 128 | u32 bl; |
| 129 | |
| 130 | oe = readl(&r->oe) | BOTH_LEDS; |
Eric Cooper | a3f41c8 | 2010-11-24 17:11:32 +0530 | [diff] [blame] | 131 | writel(oe & ~leds, &r->oe); /* active low */ |
Tony Dinh | 594e650 | 2022-02-03 14:32:29 -0800 | [diff] [blame] | 132 | bl = readl(&r->blink_en) & ~BOTH_LEDS; |
Eric Cooper | a3f41c8 | 2010-11-24 17:11:32 +0530 | [diff] [blame] | 133 | writel(bl | blinking, &r->blink_en); |
| 134 | } |
| 135 | |
| 136 | void show_boot_progress(int val) |
| 137 | { |
| 138 | switch (val) { |
Simon Glass | 2939564 | 2011-12-10 11:07:54 +0000 | [diff] [blame] | 139 | case BOOTSTAGE_ID_RUN_OS: /* booting Linux */ |
Eric Cooper | a3f41c8 | 2010-11-24 17:11:32 +0530 | [diff] [blame] | 140 | set_leds(BOTH_LEDS, NEITHER_LED); |
| 141 | break; |
Simon Glass | 964d1d4 | 2012-01-14 15:24:52 +0000 | [diff] [blame] | 142 | case BOOTSTAGE_ID_NET_ETH_START: /* Ethernet initialization */ |
Eric Cooper | a3f41c8 | 2010-11-24 17:11:32 +0530 | [diff] [blame] | 143 | set_leds(GREEN_LED, GREEN_LED); |
| 144 | break; |
| 145 | default: |
| 146 | if (val < 0) /* error */ |
| 147 | set_leds(ORANGE_LED, ORANGE_LED); |
| 148 | break; |
| 149 | } |
| 150 | } |
Tom Rini | a9765d0 | 2021-05-03 16:48:58 -0400 | [diff] [blame] | 151 | #endif |