arch/mips/pic32/pic32mzda/early_console.c
Source file repositories/reference/linux-study-clean/arch/mips/pic32/pic32mzda/early_console.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/pic32/pic32mzda/early_console.c- Extension
.c- Size
- 3212 bytes
- Lines
- 163
- Domain
- Architecture Layer
- Bucket
- arch/mips
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
Dependency Surface
linux/io.hlinux/platform_data/pic32.hasm/fw/fw.hasm/setup.hpic32mzda.hearly_pin.h
Detected Declarations
function configure_uart_pinsfunction configure_uartfunction setup_early_consolefunction pic32_getcmdlinefunction get_port_from_cmdlinefunction get_baud_from_cmdlinefunction fw_init_early_consolefunction prom_putchar
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Joshua Henderson <joshua.henderson@microchip.com>
* Copyright (C) 2015 Microchip Technology Inc. All rights reserved.
*/
#include <linux/io.h>
#include <linux/platform_data/pic32.h>
#include <asm/fw/fw.h>
#include <asm/setup.h>
#include "pic32mzda.h"
#include "early_pin.h"
/* Default early console parameters */
#define EARLY_CONSOLE_PORT 1
#define EARLY_CONSOLE_BAUDRATE 115200
#define UART_ENABLE BIT(15)
#define UART_ENABLE_RX BIT(12)
#define UART_ENABLE_TX BIT(10)
#define UART_TX_FULL BIT(9)
/* UART1(x == 0) - UART6(x == 5) */
#define UART_BASE(x) ((x) * 0x0200)
#define U_MODE(x) UART_BASE(x)
#define U_STA(x) (UART_BASE(x) + 0x10)
#define U_TXR(x) (UART_BASE(x) + 0x20)
#define U_BRG(x) (UART_BASE(x) + 0x40)
static void __iomem *uart_base;
static int console_port = -1;
static int __init configure_uart_pins(int port)
{
switch (port) {
case 1:
pic32_pps_input(IN_FUNC_U2RX, IN_RPB0);
pic32_pps_output(OUT_FUNC_U2TX, OUT_RPG9);
break;
case 5:
pic32_pps_input(IN_FUNC_U6RX, IN_RPD0);
pic32_pps_output(OUT_FUNC_U6TX, OUT_RPB8);
break;
default:
return -1;
}
return 0;
}
static void __init configure_uart(int port, int baud)
{
u32 pbclk;
pbclk = pic32_get_pbclk(2);
__raw_writel(0, uart_base + U_MODE(port));
__raw_writel(((pbclk / baud) / 16) - 1, uart_base + U_BRG(port));
__raw_writel(UART_ENABLE, uart_base + U_MODE(port));
__raw_writel(UART_ENABLE_TX | UART_ENABLE_RX,
uart_base + PIC32_SET(U_STA(port)));
}
static void __init setup_early_console(int port, int baud)
{
if (configure_uart_pins(port))
return;
console_port = port;
configure_uart(console_port, baud);
}
static char * __init pic32_getcmdline(void)
{
/*
* arch_mem_init() has not been called yet, so we don't have a real
* command line setup if using CONFIG_CMDLINE_BOOL.
*/
#ifdef CONFIG_CMDLINE_OVERRIDE
return CONFIG_CMDLINE;
#else
return fw_getcmdline();
#endif
}
static int __init get_port_from_cmdline(char *arch_cmdline)
{
char *s;
int port = -1;
Annotation
- Immediate include surface: `linux/io.h`, `linux/platform_data/pic32.h`, `asm/fw/fw.h`, `asm/setup.h`, `pic32mzda.h`, `early_pin.h`.
- Detected declarations: `function configure_uart_pins`, `function configure_uart`, `function setup_early_console`, `function pic32_getcmdline`, `function get_port_from_cmdline`, `function get_baud_from_cmdline`, `function fw_init_early_console`, `function prom_putchar`.
- Atlas domain: Architecture Layer / arch/mips.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.