blob: d72e3ef24ee61f4d360af4d652cf7d193bbfe139 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Eric Coopera3f41c82010-11-24 17:11:32 +05302/*
Tony Dinh594e6502022-02-03 14:32:29 -08003 * Copyright (C) 2022 Tony Dinh <mibodhi@gmail.com>
Eric Coopera3f41c82010-11-24 17:11:32 +05304 * 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 Coopera3f41c82010-11-24 17:11:32 +053010 */
11
12#include <common.h>
Simon Glass1ea97892020-05-10 11:40:00 -060013#include <bootstage.h>
Simon Glass97589732020-05-10 11:40:02 -060014#include <init.h>
Tony Dinh594e6502022-02-03 14:32:29 -080015#include <netdev.h>
Stefan Roesec2437842014-10-22 12:13:06 +020016#include <asm/arch/soc.h>
Eric Coopera3f41c82010-11-24 17:11:32 +053017#include <asm/arch/mpp.h>
Anatolij Gustschinc8b222e2011-10-29 10:09:22 +000018#include <asm/arch/cpu.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060019#include <asm/global_data.h>
Anatolij Gustschinc8b222e2011-10-29 10:09:22 +000020#include <asm/io.h>
Simon Glass0ffb9d62017-05-31 19:47:48 -060021#include <asm/mach-types.h>
Tony Dinh594e6502022-02-03 14:32:29 -080022#include <linux/bitops.h>
Eric Coopera3f41c82010-11-24 17:11:32 +053023
24DECLARE_GLOBAL_DATA_PTR;
25
Tony Dinh594e6502022-02-03 14:32:29 -080026#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 Coopera3f41c82010-11-24 17:11:32 +053031int 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 Roesec50ab392014-10-22 12:13:11 +020038 mvebu_config_gpio(DOCKSTAR_OE_VAL_LOW,
39 DOCKSTAR_OE_VAL_HIGH,
40 DOCKSTAR_OE_LOW, DOCKSTAR_OE_HIGH);
Eric Coopera3f41c82010-11-24 17:11:32 +053041
42 /* Multi-Purpose Pins Functionality configuration */
Albert ARIBAUD4d424312012-11-26 11:27:36 +000043 static const u32 kwmpp_config[] = {
Eric Coopera3f41c82010-11-24 17:11:32 +053044 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 Longchamp7d0d5022012-06-01 01:31:00 +000096 kirkwood_mpp_conf(kwmpp_config, NULL);
Eric Coopera3f41c82010-11-24 17:11:32 +053097 return 0;
98}
99
Tony Dinh594e6502022-02-03 14:32:29 -0800100int board_eth_init(struct bd_info *bis)
101{
102 return cpu_eth_init(bis);
103}
104
Eric Coopera3f41c82010-11-24 17:11:32 +0530105int 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 Roese0b741752014-10-22 12:13:13 +0200113 gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
Eric Coopera3f41c82010-11-24 17:11:32 +0530114
115 return 0;
116}
117
Tom Rinia9765d02021-05-03 16:48:58 -0400118#if CONFIG_IS_ENABLED(BOOTSTAGE)
Tony Dinh594e6502022-02-03 14:32:29 -0800119#define GREEN_LED BIT(14)
120#define ORANGE_LED BIT(15)
Eric Coopera3f41c82010-11-24 17:11:32 +0530121#define BOTH_LEDS (GREEN_LED | ORANGE_LED)
122#define NEITHER_LED 0
123
124static void set_leds(u32 leds, u32 blinking)
125{
Stefan Roesec50ab392014-10-22 12:13:11 +0200126 struct kwgpio_registers *r = (struct kwgpio_registers *)MVEBU_GPIO1_BASE;
Tony Dinh594e6502022-02-03 14:32:29 -0800127 u32 oe;
128 u32 bl;
129
130 oe = readl(&r->oe) | BOTH_LEDS;
Eric Coopera3f41c82010-11-24 17:11:32 +0530131 writel(oe & ~leds, &r->oe); /* active low */
Tony Dinh594e6502022-02-03 14:32:29 -0800132 bl = readl(&r->blink_en) & ~BOTH_LEDS;
Eric Coopera3f41c82010-11-24 17:11:32 +0530133 writel(bl | blinking, &r->blink_en);
134}
135
136void show_boot_progress(int val)
137{
138 switch (val) {
Simon Glass29395642011-12-10 11:07:54 +0000139 case BOOTSTAGE_ID_RUN_OS: /* booting Linux */
Eric Coopera3f41c82010-11-24 17:11:32 +0530140 set_leds(BOTH_LEDS, NEITHER_LED);
141 break;
Simon Glass964d1d42012-01-14 15:24:52 +0000142 case BOOTSTAGE_ID_NET_ETH_START: /* Ethernet initialization */
Eric Coopera3f41c82010-11-24 17:11:32 +0530143 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 Rinia9765d02021-05-03 16:48:58 -0400151#endif