blob: e6ec00a9c6cc6d47ab3b4eeae1ebda0d6f912738 [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
Simon Glass1ea97892020-05-10 11:40:00 -060012#include <bootstage.h>
Simon Glass97589732020-05-10 11:40:02 -060013#include <init.h>
Tony Dinh594e6502022-02-03 14:32:29 -080014#include <netdev.h>
Stefan Roesec2437842014-10-22 12:13:06 +020015#include <asm/arch/soc.h>
Eric Coopera3f41c82010-11-24 17:11:32 +053016#include <asm/arch/mpp.h>
Anatolij Gustschinc8b222e2011-10-29 10:09:22 +000017#include <asm/arch/cpu.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060018#include <asm/global_data.h>
Anatolij Gustschinc8b222e2011-10-29 10:09:22 +000019#include <asm/io.h>
Simon Glass0ffb9d62017-05-31 19:47:48 -060020#include <asm/mach-types.h>
Tony Dinh594e6502022-02-03 14:32:29 -080021#include <linux/bitops.h>
Eric Coopera3f41c82010-11-24 17:11:32 +053022
23DECLARE_GLOBAL_DATA_PTR;
24
Tony Dinh594e6502022-02-03 14:32:29 -080025#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 Coopera3f41c82010-11-24 17:11:32 +053030int 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 Roesec50ab392014-10-22 12:13:11 +020037 mvebu_config_gpio(DOCKSTAR_OE_VAL_LOW,
38 DOCKSTAR_OE_VAL_HIGH,
39 DOCKSTAR_OE_LOW, DOCKSTAR_OE_HIGH);
Eric Coopera3f41c82010-11-24 17:11:32 +053040
41 /* Multi-Purpose Pins Functionality configuration */
Albert ARIBAUD4d424312012-11-26 11:27:36 +000042 static const u32 kwmpp_config[] = {
Eric Coopera3f41c82010-11-24 17:11:32 +053043 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 Longchamp7d0d5022012-06-01 01:31:00 +000095 kirkwood_mpp_conf(kwmpp_config, NULL);
Eric Coopera3f41c82010-11-24 17:11:32 +053096 return 0;
97}
98
Tony Dinh594e6502022-02-03 14:32:29 -080099int board_eth_init(struct bd_info *bis)
100{
101 return cpu_eth_init(bis);
102}
103
Eric Coopera3f41c82010-11-24 17:11:32 +0530104int 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 Roese0b741752014-10-22 12:13:13 +0200112 gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
Eric Coopera3f41c82010-11-24 17:11:32 +0530113
114 return 0;
115}
116
Tom Rinia9765d02021-05-03 16:48:58 -0400117#if CONFIG_IS_ENABLED(BOOTSTAGE)
Tony Dinh594e6502022-02-03 14:32:29 -0800118#define GREEN_LED BIT(14)
119#define ORANGE_LED BIT(15)
Eric Coopera3f41c82010-11-24 17:11:32 +0530120#define BOTH_LEDS (GREEN_LED | ORANGE_LED)
121#define NEITHER_LED 0
122
123static void set_leds(u32 leds, u32 blinking)
124{
Stefan Roesec50ab392014-10-22 12:13:11 +0200125 struct kwgpio_registers *r = (struct kwgpio_registers *)MVEBU_GPIO1_BASE;
Tony Dinh594e6502022-02-03 14:32:29 -0800126 u32 oe;
127 u32 bl;
128
129 oe = readl(&r->oe) | BOTH_LEDS;
Eric Coopera3f41c82010-11-24 17:11:32 +0530130 writel(oe & ~leds, &r->oe); /* active low */
Tony Dinh594e6502022-02-03 14:32:29 -0800131 bl = readl(&r->blink_en) & ~BOTH_LEDS;
Eric Coopera3f41c82010-11-24 17:11:32 +0530132 writel(bl | blinking, &r->blink_en);
133}
134
135void show_boot_progress(int val)
136{
137 switch (val) {
Simon Glass29395642011-12-10 11:07:54 +0000138 case BOOTSTAGE_ID_RUN_OS: /* booting Linux */
Eric Coopera3f41c82010-11-24 17:11:32 +0530139 set_leds(BOTH_LEDS, NEITHER_LED);
140 break;
Simon Glass964d1d42012-01-14 15:24:52 +0000141 case BOOTSTAGE_ID_NET_ETH_START: /* Ethernet initialization */
Eric Coopera3f41c82010-11-24 17:11:32 +0530142 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 Rinia9765d02021-05-03 16:48:58 -0400150#endif