blob: b2703e6382d1403ac8b7191f462ea146ad6997fa [file] [log] [blame]
Chris Morganc56a7b22024-05-21 10:25:33 -05001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (c) 2023 Chris Morgan <macromorgan@hotmail.com>
4 */
5
6#include <asm/io.h>
7
8#define GPIO4_BASE 0xfe770000
9#define GPIO_SWPORT_DR_L 0x0000
10#define GPIO_SWPORT_DDR_L 0x0008
11#define GPIO_B4 BIT(12)
12#define GPIO_B5 BIT(13)
13#define GPIO_B6 BIT(14)
14
15#define GPIO_WRITEMASK(bits) ((bits) << 16)
16
17/*
18 * Start LED very early so user knows device is on. Set color
19 * to red.
20 */
21void spl_board_init(void)
22{
23 /* Set GPIO4_B4, GPIO4_B5, and GPIO4_B6 to output. */
24 writel(GPIO_WRITEMASK(GPIO_B6 | GPIO_B5 | GPIO_B4) | \
25 (GPIO_B6 | GPIO_B5 | GPIO_B4),
26 (GPIO4_BASE + GPIO_SWPORT_DDR_L));
27 /* Set GPIO4_B5 and GPIO4_B6 to 0 and GPIO4_B4 to 1. */
28 writel(GPIO_WRITEMASK(GPIO_B6 | GPIO_B5 | GPIO_B4) | GPIO_B4,
29 (GPIO4_BASE + GPIO_SWPORT_DR_L));
30}
31
32int rk_board_late_init(void)
33{
34 /* Turn off red LED and turn on orange LED. */
35 writel(GPIO_WRITEMASK(GPIO_B6 | GPIO_B5 | GPIO_B4) | GPIO_B6,
36 (GPIO4_BASE + GPIO_SWPORT_DR_L));
37
38 return 0;
39}