xref: /OK3568_Linux_fs/u-boot/include/stdio_dev.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * (C) Copyright 2000
3  * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 
8 #ifndef _STDIO_DEV_H_
9 #define _STDIO_DEV_H_
10 
11 #include <linux/list.h>
12 
13 /*
14  * STDIO DEVICES
15  */
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 */
19 #define DEV_FLAGS_DM     0x00000004	/* Device priv is a struct udevice * */
20 
21 /* Device information */
22 struct stdio_dev {
23 	int	flags;			/* Device flags: input/output/system	*/
24 	int	ext;			/* Supported extensions			*/
25 	char	name[32];		/* Device name				*/
26 
27 /* GENERAL functions */
28 
29 	int (*start)(struct stdio_dev *dev);	/* To start the device */
30 	int (*stop)(struct stdio_dev *dev);	/* To stop the device */
31 
32 /* OUTPUT functions */
33 
34 	/* To put a char */
35 	void (*putc)(struct stdio_dev *dev, const char c);
36 	/* To put a string (accelerator) */
37 	void (*puts)(struct stdio_dev *dev, const char *s);
38 
39 /* Clear functions */
40 	void (*clear)(struct stdio_dev *dev);
41 
42 /* INPUT functions */
43 
44 	/* To test if a char is ready... */
45 	int (*tstc)(struct stdio_dev *dev);
46 	int (*getc)(struct stdio_dev *dev);	/* To get that char */
47 
48 /* Other functions */
49 
50 	void *priv;			/* Private extensions			*/
51 	struct list_head list;
52 };
53 
54 /*
55  * VIDEO EXTENSIONS
56  */
57 #define VIDEO_FORMAT_RGB_INDEXED	0x0000
58 #define VIDEO_FORMAT_RGB_DIRECTCOLOR	0x0001
59 #define VIDEO_FORMAT_YUYV_4_4_4		0x0010
60 #define VIDEO_FORMAT_YUYV_4_2_2		0x0011
61 
62 typedef struct {
63 	void *address;			/* Address of framebuffer		*/
64 	ushort	width;			/* Horizontal resolution		*/
65 	ushort	height;			/* Vertical resolution			*/
66 	uchar	format;			/* Format				*/
67 	uchar	colors;			/* Colors number or color depth		*/
68 	void (*setcolreg) (int, int, int, int);
69 	void (*getcolreg) (int, void *);
70 } video_ext_t;
71 
72 /*
73  * VARIABLES
74  */
75 extern struct stdio_dev *stdio_devices[];
76 extern char *stdio_names[MAX_FILES];
77 
78 /*
79  * PROTOTYPES
80  */
81 int	stdio_register (struct stdio_dev * dev);
82 int stdio_register_dev(struct stdio_dev *dev, struct stdio_dev **devp);
83 
84 /**
85  * stdio_init_tables() - set up stdio tables ready for devices
86  *
87  * This does not add any devices, but just prepares stdio for use.
88  */
89 int stdio_init_tables(void);
90 
91 /**
92  * stdio_add_devices() - Add stdio devices to the table
93  *
94  * This makes calls to all the various subsystems that use stdio, to make
95  * them register with stdio.
96  */
97 int stdio_add_devices(void);
98 
99 /**
100  * stdio_init() - Sets up stdio ready for use
101  *
102  * This calls stdio_init_tables() and stdio_add_devices()
103  */
104 int stdio_init(void);
105 
106 void	stdio_print_current_devices(void);
107 #if CONFIG_IS_ENABLED(SYS_STDIO_DEREGISTER)
108 int stdio_deregister(const char *devname, int force);
109 int stdio_deregister_dev(struct stdio_dev *dev, int force);
110 #endif
111 struct list_head* stdio_get_list(void);
112 struct stdio_dev* stdio_get_by_name(const char* name);
113 struct stdio_dev* stdio_clone(struct stdio_dev *dev);
114 
115 #ifdef CONFIG_LCD
116 int	drv_lcd_init (void);
117 #endif
118 #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
119 int	drv_video_init (void);
120 #endif
121 #ifdef CONFIG_KEYBOARD
122 int	drv_keyboard_init (void);
123 #endif
124 #ifdef CONFIG_USB_TTY
125 int	drv_usbtty_init (void);
126 #endif
127 #ifdef CONFIG_NETCONSOLE
128 int	drv_nc_init (void);
129 #endif
130 #ifdef CONFIG_JTAG_CONSOLE
131 int drv_jtag_console_init (void);
132 #endif
133 #ifdef CONFIG_CBMEM_CONSOLE
134 int cbmemc_init(void);
135 #endif
136 
137 #endif
138