diff options
Diffstat (limited to 'include/console.h')
-rw-r--r-- | include/console.h | 104 |
1 files changed, 75 insertions, 29 deletions
diff --git a/include/console.h b/include/console.h index 7afe59e93a..62d13d7aa0 100644 --- a/include/console.h +++ b/include/console.h @@ -1,26 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * (C) Copyright 2000 * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it - * - * See file CREDITS for list of people who contributed to this - * project. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #ifndef _CONSOLE_H_ #define _CONSOLE_H_ #include <param.h> +#include <linux/clk.h> #include <linux/list.h> #include <driver.h> #include <serdev.h> @@ -31,14 +19,16 @@ #define CONSOLE_STDOUT (1 << 1) #define CONSOLE_STDERR (1 << 2) +#define CONSOLE_STDIOE (CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR) + enum console_mode { CONSOLE_MODE_NORMAL, CONSOLE_MODE_RS485, }; struct console_device { - struct device_d *dev; - struct device_d class_dev; + struct device *dev; + struct device class_dev; int (*tstc)(struct console_device *cdev); void (*putc)(struct console_device *cdev, char c); @@ -64,6 +54,8 @@ struct console_device { unsigned int baudrate_param; const char *linux_console_name; + const char *linux_earlycon_name; + void __iomem *phys_base; struct cdev devfs; struct cdev_operations fops; @@ -71,7 +63,7 @@ struct console_device { struct serdev_device serdev; }; -static inline struct serdev_device *to_serdev_device(struct device_d *d) +static inline struct serdev_device *to_serdev_device(struct device *d) { struct console_device *cdev = container_of(d, struct console_device, class_dev); @@ -87,10 +79,10 @@ to_console_device(struct serdev_device *serdev) static inline struct device_node * console_is_serdev_node(struct console_device *cdev) { - struct device_d *dev = cdev->dev; - if (dev && dev->device_node && - of_get_child_count(dev->device_node)) - return dev->device_node; + struct device *dev = cdev->dev; + if (dev && dev->of_node && + of_get_child_count(dev->of_node)) + return dev->of_node; return NULL; } @@ -98,25 +90,21 @@ console_is_serdev_node(struct console_device *cdev) int console_register(struct console_device *cdev); int console_unregister(struct console_device *cdev); -struct console_device *console_get_by_dev(struct device_d *dev); +struct console_device *console_get_by_dev(struct device *dev); struct console_device *console_get_by_name(const char *name); - -extern struct list_head console_list; -#define for_each_console(console) list_for_each_entry(console, &console_list, list) +struct console_device *of_console_get_by_alias(const char *alias); #define CFG_PBSIZE (CONFIG_CBSIZE+sizeof(CONFIG_PROMPT)+16) -extern int barebox_loglevel; - -struct console_device *console_get_first_active(void); - int console_open(struct console_device *cdev); int console_close(struct console_device *cdev); int console_set_active(struct console_device *cdev, unsigned active); unsigned console_get_active(struct console_device *cdev); int console_set_baudrate(struct console_device *cdev, unsigned baudrate); unsigned console_get_baudrate(struct console_device *cdev); +void console_set_stdoutpath(struct console_device *cdev, unsigned baudrate); +struct console_device *of_console_by_stdout_path(void); /** * console_fifo_fill - fill FIFO with as much console data as possible @@ -207,7 +195,65 @@ static inline void pbl_set_putc(void (*putcf)(void *ctx, int c), void *ctx) {} bool console_allow_color(void); +#ifndef CONFIG_CONSOLE_NONE +extern struct list_head console_list; +#define for_each_console(console) list_for_each_entry(console, &console_list, list) + +struct console_device *console_get_first_active(void); + +extern int barebox_loglevel; +static inline int barebox_set_loglevel(int loglevel) +{ + int old_loglevel = barebox_loglevel; + barebox_loglevel = loglevel; + return old_loglevel; +} +#else +#define for_each_console(console) while (((void)console, 0)) + +static inline struct console_device *console_get_first_active(void) +{ + return NULL; +} + +static inline int barebox_set_loglevel(int loglevel) +{ + return loglevel; +} +#endif + +#ifdef CONFIG_CONSOLE_FULL void console_ctrlc_allow(void); void console_ctrlc_forbid(void); +#else +static inline void console_ctrlc_allow(void) { } +static inline void console_ctrlc_forbid(void) { } +#endif + +/** + * clk_get_for_console - get clock, ignoring known unavailable clock controller + * @dev: device for clock "consumer" + * @id: clock consumer ID + * + * Return: a struct clk corresponding to the clock producer, a + * valid IS_ERR() condition containing errno or NULL if it could + * be determined that the clock producer will never be probed in + * absence of modules. The NULL return allows serial drivers to + * skip clock handling for the stdout console and rely on CONFIG_DEBUG_LL. + */ +static inline struct clk *clk_get_for_console(struct device *dev, const char *id) +{ + __always_unused unsigned baudrate; + struct clk *clk; + + if (!IS_ENABLED(CONFIG_DEBUG_LL) || !of_device_is_stdout_path(dev, &baudrate)) + return clk_get(dev, id); + + clk = clk_get_if_available(dev, id); + if (clk == NULL) + dev_warn(dev, "couldn't get clock (ignoring)\n"); + + return clk; +} #endif |