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