Lines Matching +full:console +full:- +full:size
1 // SPDX-License-Identifier: GPL-2.0
7 * (c) Copyright 2004 Hewlett-Packard Development Company, L.P.
13 #include <linux/console.h>
29 static struct console early_con = {
39 static void __iomem * __init earlycon_map(resource_size_t paddr, size_t size) in earlycon_map() argument
47 base = ioremap(paddr, size); in earlycon_map()
58 struct console *earlycon = device->con; in earlycon_init()
62 /* scan backwards from end of string for first non-numeral */ in earlycon_init()
64 s > name && s[-1] >= '0' && s[-1] <= '9'; in earlycon_init()
65 s--) in earlycon_init()
68 earlycon->index = simple_strtoul(s, NULL, 10); in earlycon_init()
69 len = s - name; in earlycon_init()
70 strscpy(earlycon->name, name, min(len + 1, sizeof(earlycon->name))); in earlycon_init()
71 earlycon->data = &early_console_dev; in earlycon_init()
76 struct console *earlycon = device->con; in earlycon_print_info()
77 struct uart_port *port = &device->port; in earlycon_print_info()
79 if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM16 || in earlycon_print_info()
80 port->iotype == UPIO_MEM32 || port->iotype == UPIO_MEM32BE) in earlycon_print_info()
82 earlycon->name, earlycon->index, in earlycon_print_info()
83 (port->iotype == UPIO_MEM) ? "" : in earlycon_print_info()
84 (port->iotype == UPIO_MEM16) ? "16" : in earlycon_print_info()
85 (port->iotype == UPIO_MEM32) ? "32" : "32be", in earlycon_print_info()
86 &port->mapbase, device->options); in earlycon_print_info()
89 earlycon->name, earlycon->index, in earlycon_print_info()
90 port->iobase, device->options); in earlycon_print_info()
95 struct uart_port *port = &device->port; in parse_options()
99 if (uart_parse_earlycon(options, &port->iotype, &addr, &options)) in parse_options()
100 return -EINVAL; in parse_options()
102 switch (port->iotype) { in parse_options()
104 port->mapbase = addr; in parse_options()
107 port->regshift = 1; in parse_options()
108 port->mapbase = addr; in parse_options()
112 port->regshift = 2; in parse_options()
113 port->mapbase = addr; in parse_options()
116 port->iobase = addr; in parse_options()
119 return -EINVAL; in parse_options()
125 device->baud = simple_strtoul(options, NULL, 0); in parse_options()
127 if (uartclk && kstrtouint(uartclk + 1, 0, &port->uartclk) < 0) in parse_options()
131 (size_t)(sizeof(device->options))); in parse_options()
132 strscpy(device->options, options, length); in parse_options()
147 spin_lock_init(&port->lock); in register_earlycon()
148 if (!port->uartclk) in register_earlycon()
149 port->uartclk = BASE_BAUD * 16; in register_earlycon()
150 if (port->mapbase) in register_earlycon()
151 port->membase = earlycon_map(port->mapbase, 64); in register_earlycon()
153 earlycon_init(&early_console_dev, match->name); in register_earlycon()
154 err = match->setup(&early_console_dev, buf); in register_earlycon()
158 if (!early_console_dev.con->write) in register_earlycon()
159 return -ENODEV; in register_earlycon()
166 * setup_earlycon - match and register earlycon console
169 * Registers the earlycon console matching the earlycon specified
189 return -EINVAL; in setup_earlycon()
192 return -EALREADY; in setup_earlycon()
196 size_t len = strlen(match->name); in setup_earlycon()
198 if (strncmp(buf, match->name, len)) in setup_earlycon()
202 if (empty_compatible && *match->compatible) in setup_earlycon()
220 return -ENOENT; in setup_earlycon()
224 * This defers the initialization of the early console until after ACPI has
245 if (err == -ENOENT || err == -EALREADY) in param_setup_earlycon()
252 * The `console` parameter is overloaded. It's handled here as an early param
255 * the `console=uartXXX` alias. See the comment in `8250_early.c`.
260 * A plain `console` parameter must not enable the SPCR `bootconsole` in param_setup_earlycon_console_alias()
263 * A `console=` parameter that specifies an empty value is used to in param_setup_earlycon_console_alias()
264 * disable the `console`, not the `earlycon` `bootconsole`. The in param_setup_earlycon_console_alias()
265 * disabling of the `console` is handled by `printk.c`. in param_setup_earlycon_console_alias()
272 early_param("console", param_setup_earlycon_console_alias);
287 return -EALREADY; in of_setup_earlycon()
289 spin_lock_init(&port->lock); in of_setup_earlycon()
290 port->iotype = UPIO_MEM; in of_setup_earlycon()
293 pr_warn("[%s] bad address\n", match->name); in of_setup_earlycon()
294 return -ENXIO; in of_setup_earlycon()
296 port->mapbase = addr; in of_setup_earlycon()
298 val = of_get_flat_dt_prop(node, "reg-offset", NULL); in of_setup_earlycon()
300 port->mapbase += be32_to_cpu(*val); in of_setup_earlycon()
301 port->membase = earlycon_map(port->mapbase, SZ_4K); in of_setup_earlycon()
303 val = of_get_flat_dt_prop(node, "reg-shift", NULL); in of_setup_earlycon()
305 port->regshift = be32_to_cpu(*val); in of_setup_earlycon()
306 big_endian = of_get_flat_dt_prop(node, "big-endian", NULL) != NULL || in of_setup_earlycon()
308 of_get_flat_dt_prop(node, "native-endian", NULL) != NULL); in of_setup_earlycon()
309 val = of_get_flat_dt_prop(node, "reg-io-width", NULL); in of_setup_earlycon()
313 port->iotype = UPIO_MEM; in of_setup_earlycon()
316 port->iotype = UPIO_MEM16; in of_setup_earlycon()
319 port->iotype = (big_endian) ? UPIO_MEM32BE : UPIO_MEM32; in of_setup_earlycon()
322 pr_warn("[%s] unsupported reg-io-width\n", match->name); in of_setup_earlycon()
323 return -EINVAL; in of_setup_earlycon()
327 val = of_get_flat_dt_prop(node, "current-speed", NULL); in of_setup_earlycon()
331 val = of_get_flat_dt_prop(node, "clock-frequency", NULL); in of_setup_earlycon()
333 port->uartclk = be32_to_cpu(*val); in of_setup_earlycon()
340 earlycon_init(&early_console_dev, match->name); in of_setup_earlycon()
341 err = match->setup(&early_console_dev, options); in of_setup_earlycon()
345 if (!early_console_dev.con->write) in of_setup_earlycon()
346 return -ENODEV; in of_setup_earlycon()