blob: 4e3c4708f807a61e3c251a4c76bab5870272502f [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
wdenke831ad52002-10-17 21:52:26 +00002/*
3 * (C) Copyright 2000
4 * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it
wdenke831ad52002-10-17 21:52:26 +00005 */
6
Jean-Christophe PLAGNIOL-VILLARD52cb4d42009-05-16 12:14:54 +02007#ifndef _STDIO_DEV_H_
8#define _STDIO_DEV_H_
9
Tom Rini27b42252018-05-03 09:12:26 -040010#include <stdio.h>
Jean-Christophe PLAGNIOL-VILLARDc1de7a62008-08-31 04:24:55 +020011#include <linux/list.h>
wdenke831ad52002-10-17 21:52:26 +000012
wdenke831ad52002-10-17 21:52:26 +000013/*
Jean-Christophe PLAGNIOL-VILLARD52cb4d42009-05-16 12:14:54 +020014 * STDIO DEVICES
wdenke831ad52002-10-17 21:52:26 +000015 */
16
17#define DEV_FLAGS_INPUT 0x00000001 /* Device can be used as input console */
18#define DEV_FLAGS_OUTPUT 0x00000002 /* Device can be used as output console */
Simon Glass7b3c4c32017-07-27 09:31:04 -060019#define DEV_FLAGS_DM 0x00000004 /* Device priv is a struct udevice * */
Heinrich Schuchardt6da11cc2023-09-29 02:47:17 +020020#define STDIO_NAME_LEN 32
wdenke831ad52002-10-17 21:52:26 +000021
Andy Shevchenkod9b0ac92021-02-11 17:09:36 +020022int stdio_file_to_flags(const int file);
23
wdenk47cd00f2003-03-06 13:39:27 +000024/* Device information */
Jean-Christophe PLAGNIOL-VILLARD52cb4d42009-05-16 12:14:54 +020025struct stdio_dev {
wdenke831ad52002-10-17 21:52:26 +000026 int flags; /* Device flags: input/output/system */
27 int ext; /* Supported extensions */
Heinrich Schuchardt6da11cc2023-09-29 02:47:17 +020028 char name[STDIO_NAME_LEN]; /* Device name */
wdenke831ad52002-10-17 21:52:26 +000029
30/* GENERAL functions */
31
Simon Glass709ea542014-07-23 06:54:59 -060032 int (*start)(struct stdio_dev *dev); /* To start the device */
33 int (*stop)(struct stdio_dev *dev); /* To stop the device */
wdenke831ad52002-10-17 21:52:26 +000034
35/* OUTPUT functions */
36
Simon Glass709ea542014-07-23 06:54:59 -060037 /* To put a char */
38 void (*putc)(struct stdio_dev *dev, const char c);
39 /* To put a string (accelerator) */
40 void (*puts)(struct stdio_dev *dev, const char *s);
Pali Rohár974f4832022-09-05 11:31:17 +020041#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
42 /* To flush output queue */
43 void (*flush)(struct stdio_dev *dev);
44#define STDIO_DEV_ASSIGN_FLUSH(dev, flush_func) ((dev)->flush = (flush_func))
45#else
46#define STDIO_DEV_ASSIGN_FLUSH(dev, flush_func)
47#endif
wdenke831ad52002-10-17 21:52:26 +000048
49/* INPUT functions */
50
Simon Glass709ea542014-07-23 06:54:59 -060051 /* To test if a char is ready... */
52 int (*tstc)(struct stdio_dev *dev);
53 int (*getc)(struct stdio_dev *dev); /* To get that char */
wdenke831ad52002-10-17 21:52:26 +000054
55/* Other functions */
56
57 void *priv; /* Private extensions */
Jean-Christophe PLAGNIOL-VILLARDc1de7a62008-08-31 04:24:55 +020058 struct list_head list;
Jean-Christophe PLAGNIOL-VILLARD52cb4d42009-05-16 12:14:54 +020059};
wdenke831ad52002-10-17 21:52:26 +000060
61/*
wdenke831ad52002-10-17 21:52:26 +000062 * VARIABLES
63 */
Jean-Christophe PLAGNIOL-VILLARD52cb4d42009-05-16 12:14:54 +020064extern struct stdio_dev *stdio_devices[];
wdenke831ad52002-10-17 21:52:26 +000065extern char *stdio_names[MAX_FILES];
66
67/*
68 * PROTOTYPES
69 */
Simon Glass3bcd0ce2020-08-11 11:23:38 -060070int stdio_register(struct stdio_dev *dev);
Simon Glassd97143a2014-07-23 06:55:05 -060071int stdio_register_dev(struct stdio_dev *dev, struct stdio_dev **devp);
Simon Glass9fb02492014-09-03 17:37:01 -060072
73/**
74 * stdio_init_tables() - set up stdio tables ready for devices
75 *
76 * This does not add any devices, but just prepares stdio for use.
77 */
78int stdio_init_tables(void);
79
80/**
81 * stdio_add_devices() - Add stdio devices to the table
82 *
83 * This makes calls to all the various subsystems that use stdio, to make
84 * them register with stdio.
85 */
86int stdio_add_devices(void);
87
Simon Glass4225f2f2020-08-11 11:23:41 -060088/**
89 * stdio_deregister_dev() - deregister the device "devname".
90 *
91 * @dev: Stdio device to deregister
92 * @force: true to force deregistration even if in use
93 *
94 * returns 0 on success, -EBUSY if device is assigned
95 */
Hans de Goede32d01922014-09-20 16:54:37 +020096int stdio_deregister_dev(struct stdio_dev *dev, int force);
Simon Glass3bcd0ce2020-08-11 11:23:38 -060097struct list_head *stdio_get_list(void);
98struct stdio_dev *stdio_get_by_name(const char *name);
99struct stdio_dev *stdio_clone(struct stdio_dev *dev);
Jean-Christophe PLAGNIOL-VILLARDc1de7a62008-08-31 04:24:55 +0200100
Simon Glass3bcd0ce2020-08-11 11:23:38 -0600101int drv_lcd_init(void);
102int drv_video_init(void);
103int drv_keyboard_init(void);
104int drv_usbtty_init(void);
Loic Poulainfc2b3992021-11-25 18:16:15 +0100105int drv_usbacm_init(void);
Simon Glass3bcd0ce2020-08-11 11:23:38 -0600106int drv_nc_init(void);
107int drv_jtag_console_init(void);
Vadim Bendebury98ab4352012-10-12 18:48:47 +0000108int cbmemc_init(void);
wdenke831ad52002-10-17 21:52:26 +0000109
Jean-Christophe PLAGNIOL-VILLARD52cb4d42009-05-16 12:14:54 +0200110#endif