1 | /* |
---|
2 | * LCD Console Output Driver for CSBx37 |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989-2009. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * |
---|
7 | * Modified by Fernando Nicodemos <fgnicodemos@terra.com.br> |
---|
8 | * from NCB - Sistemas Embarcados Ltda. (Brazil) |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.rtems.com/license/LICENSE. |
---|
13 | * |
---|
14 | * $Id$ |
---|
15 | */ |
---|
16 | |
---|
17 | #include <bsp.h> |
---|
18 | #include <rtems/libio.h> |
---|
19 | #include <termios.h> |
---|
20 | |
---|
21 | #include <rtems/bspIo.h> |
---|
22 | #include <libchip/serial.h> |
---|
23 | #include <libchip/sersupp.h> |
---|
24 | #include "sed1356.h" |
---|
25 | |
---|
26 | /* static function prototypes */ |
---|
27 | static int fbcons_first_open(int major, int minor, void *arg); |
---|
28 | static int fbcons_last_close(int major, int minor, void *arg); |
---|
29 | static int fbcons_read(int minor); |
---|
30 | static int fbcons_write(int minor, const char *buf, int len); |
---|
31 | static void fbcons_init(int minor); |
---|
32 | static void fbcons_write_polled(int minor, char c); |
---|
33 | static int fbcons_set_attributes(int minor, const struct termios *t); |
---|
34 | |
---|
35 | /* Pointers to functions for handling the UART. */ |
---|
36 | console_fns fbcons_fns = |
---|
37 | { |
---|
38 | libchip_serial_default_probe, |
---|
39 | fbcons_first_open, |
---|
40 | fbcons_last_close, |
---|
41 | fbcons_read, |
---|
42 | fbcons_write, |
---|
43 | fbcons_init, |
---|
44 | fbcons_write_polled, /* not used in this driver */ |
---|
45 | fbcons_set_attributes, |
---|
46 | FALSE /* TRUE if interrupt driven, FALSE if not. */ |
---|
47 | }; |
---|
48 | /*********************************************************************/ |
---|
49 | /* Functions called via callbacks (i.e. the ones in uart_fns */ |
---|
50 | /*********************************************************************/ |
---|
51 | |
---|
52 | /* |
---|
53 | * This is called the first time each device is opened. Since |
---|
54 | * the driver is polled, we don't have to do anything. If the driver |
---|
55 | * were interrupt driven, we'd enable interrupts here. |
---|
56 | */ |
---|
57 | static int fbcons_first_open(int major, int minor, void *arg) |
---|
58 | { |
---|
59 | /* printk( "Frame buffer -- first open\n" ); */ |
---|
60 | return 0; |
---|
61 | } |
---|
62 | |
---|
63 | |
---|
64 | /* |
---|
65 | * This is called the last time each device is closed. Since |
---|
66 | * the driver is polled, we don't have to do anything. If the driver |
---|
67 | * were interrupt driven, we'd disable interrupts here. |
---|
68 | */ |
---|
69 | static int fbcons_last_close(int major, int minor, void *arg) |
---|
70 | { |
---|
71 | /* printk( "Frame buffer -- last close\n" ); */ |
---|
72 | return 0; |
---|
73 | } |
---|
74 | |
---|
75 | |
---|
76 | /* |
---|
77 | * Read one character from UART. |
---|
78 | * |
---|
79 | * return -1 if there's no data, otherwise return |
---|
80 | * the character in lowest 8 bits of returned int. |
---|
81 | */ |
---|
82 | static int fbcons_read(int minor) |
---|
83 | { |
---|
84 | /* printk( "Frame buffer -- read\n" ); */ |
---|
85 | return -1; |
---|
86 | } |
---|
87 | |
---|
88 | |
---|
89 | /* |
---|
90 | * Write buffer to LCD |
---|
91 | * |
---|
92 | * return 1 on success, -1 on error |
---|
93 | */ |
---|
94 | static int fbcons_write(int minor, const char *buf, int len) |
---|
95 | { |
---|
96 | int i; |
---|
97 | |
---|
98 | /* printk( "Frame buffer -- write\n" ); */ |
---|
99 | for ( i=0 ; i<len ; i++ ) |
---|
100 | sed_putchar( buf[i] ); |
---|
101 | |
---|
102 | return 1; |
---|
103 | } |
---|
104 | |
---|
105 | |
---|
106 | /* Set up the LCD controller. */ |
---|
107 | static void fbcons_init(int minor) |
---|
108 | { |
---|
109 | /* printk( "Initializing frame buffer\n" ); */ |
---|
110 | sed_init(); |
---|
111 | } |
---|
112 | |
---|
113 | /* This is used for putchark support */ |
---|
114 | static void fbcons_write_polled(int minor, char c) |
---|
115 | { |
---|
116 | /* printk( "frame buffer -- write polled\n" ); */ |
---|
117 | sed_putchar( c ); |
---|
118 | } |
---|
119 | |
---|
120 | /* This is for setting baud rate, bits, etc. */ |
---|
121 | static int fbcons_set_attributes(int minor, const struct termios *t) |
---|
122 | { |
---|
123 | /* printk( "frame buffer -- set attributes\n" ); */ |
---|
124 | return 0; |
---|
125 | } |
---|
126 | |
---|
127 | /***********************************************************************/ |
---|
128 | /* |
---|
129 | * The following functions are not used by TERMIOS, but other RTEMS |
---|
130 | * functions use them instead. |
---|
131 | */ |
---|
132 | /***********************************************************************/ |
---|
133 | /* |
---|
134 | * Read from UART. This is used in the exit code, and can't |
---|
135 | * rely on interrupts. |
---|
136 | */ |
---|
137 | int fbcons_poll_read(int minor) |
---|
138 | { |
---|
139 | /* printk( "frame buffer -- poll read\n" ); */ |
---|
140 | return -1; |
---|
141 | } |
---|