Stefan Roese | 2052a93 | 2018-08-16 15:27:30 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (C) 2018 Stefan Roese <sr@denx.de> |
| 4 | */ |
| 5 | |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 6 | #include <init.h> |
Stefan Roese | 2052a93 | 2018-08-16 15:27:30 +0200 | [diff] [blame] | 7 | #include <asm/io.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 8 | #include <linux/bitops.h> |
Stefan Roese | 2052a93 | 2018-08-16 15:27:30 +0200 | [diff] [blame] | 9 | |
Stefan Roese | bfb27b1 | 2018-10-09 08:59:15 +0200 | [diff] [blame] | 10 | #define MT76XX_GPIO1_MODE 0x10000060 |
Stefan Roese | 2052a93 | 2018-08-16 15:27:30 +0200 | [diff] [blame] | 11 | |
| 12 | void board_debug_uart_init(void) |
| 13 | { |
Stefan Roese | bfb27b1 | 2018-10-09 08:59:15 +0200 | [diff] [blame] | 14 | void __iomem *gpio_mode; |
| 15 | |
Stefan Roese | 2052a93 | 2018-08-16 15:27:30 +0200 | [diff] [blame] | 16 | /* Select UART2 mode instead of GPIO mode (default) */ |
Stefan Roese | bfb27b1 | 2018-10-09 08:59:15 +0200 | [diff] [blame] | 17 | gpio_mode = ioremap_nocache(MT76XX_GPIO1_MODE, 0x100); |
| 18 | clrbits_le32(gpio_mode, GENMASK(27, 26)); |
Stefan Roese | 2052a93 | 2018-08-16 15:27:30 +0200 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | int board_early_init_f(void) |
| 22 | { |
| 23 | /* |
| 24 | * The pin muxing of UART2 also needs to be done, if debug uart |
| 25 | * is not enabled. So we need to call this function here as well. |
| 26 | */ |
| 27 | board_debug_uart_init(); |
| 28 | |
| 29 | return 0; |
| 30 | } |