serialio.c (4b4193256c8d3bc3a5397b5cd9494c2ad386317d) serialio.c (1941ab1d25e098e99df18b9041667e99858fd449)
1// SPDX-License-Identifier: GPL-2.0
2#include <linux/interrupt.h>
3#include <linux/ioport.h>
4
5#include "spk_types.h"
6#include "speakup.h"
7#include "spk_priv.h"
8#include "serialio.h"

--- 13 unchanged lines hidden (view full) ---

22static const struct old_serial_port rs_table[] = {
23 SERIAL_PORT_DFNS
24};
25
26static const struct old_serial_port *serstate;
27static int timeouts;
28
29static int spk_serial_out(struct spk_synth *in_synth, const char ch);
1// SPDX-License-Identifier: GPL-2.0
2#include <linux/interrupt.h>
3#include <linux/ioport.h>
4
5#include "spk_types.h"
6#include "speakup.h"
7#include "spk_priv.h"
8#include "serialio.h"

--- 13 unchanged lines hidden (view full) ---

22static const struct old_serial_port rs_table[] = {
23 SERIAL_PORT_DFNS
24};
25
26static const struct old_serial_port *serstate;
27static int timeouts;
28
29static int spk_serial_out(struct spk_synth *in_synth, const char ch);
30static void spk_serial_send_xchar(char ch);
31static void spk_serial_tiocmset(unsigned int set, unsigned int clear);
32static unsigned char spk_serial_in(void);
33static unsigned char spk_serial_in_nowait(void);
34static void spk_serial_flush_buffer(void);
30static void spk_serial_send_xchar(struct spk_synth *in_synth, char ch);
31static void spk_serial_tiocmset(struct spk_synth *in_synth, unsigned int set, unsigned int clear);
32static unsigned char spk_serial_in(struct spk_synth *in_synth);
33static unsigned char spk_serial_in_nowait(struct spk_synth *in_synth);
34static void spk_serial_flush_buffer(struct spk_synth *in_synth);
35static int spk_serial_wait_for_xmitr(struct spk_synth *in_synth);
36
37struct spk_io_ops spk_serial_io_ops = {
38 .synth_out = spk_serial_out,
39 .send_xchar = spk_serial_send_xchar,
40 .tiocmset = spk_serial_tiocmset,
41 .synth_in = spk_serial_in,
42 .synth_in_nowait = spk_serial_in_nowait,

--- 102 unchanged lines hidden (view full) ---

145 speakup_info.port_tts + UART_IER);
146 inb(speakup_info.port_tts + UART_LSR);
147 inb(speakup_info.port_tts + UART_RX);
148 inb(speakup_info.port_tts + UART_IIR);
149 inb(speakup_info.port_tts + UART_MSR);
150 outb(1, speakup_info.port_tts + UART_FCR); /* Turn FIFO On */
151}
152
35static int spk_serial_wait_for_xmitr(struct spk_synth *in_synth);
36
37struct spk_io_ops spk_serial_io_ops = {
38 .synth_out = spk_serial_out,
39 .send_xchar = spk_serial_send_xchar,
40 .tiocmset = spk_serial_tiocmset,
41 .synth_in = spk_serial_in,
42 .synth_in_nowait = spk_serial_in_nowait,

--- 102 unchanged lines hidden (view full) ---

145 speakup_info.port_tts + UART_IER);
146 inb(speakup_info.port_tts + UART_LSR);
147 inb(speakup_info.port_tts + UART_RX);
148 inb(speakup_info.port_tts + UART_IIR);
149 inb(speakup_info.port_tts + UART_MSR);
150 outb(1, speakup_info.port_tts + UART_FCR); /* Turn FIFO On */
151}
152
153static void spk_serial_send_xchar(char ch)
153static void spk_serial_send_xchar(struct spk_synth *synth, char ch)
154{
155 int timeout = SPK_XMITR_TIMEOUT;
156
157 while (spk_serial_tx_busy()) {
158 if (!--timeout)
159 break;
160 udelay(1);
161 }
162 outb(ch, speakup_info.port_tts);
163}
164
154{
155 int timeout = SPK_XMITR_TIMEOUT;
156
157 while (spk_serial_tx_busy()) {
158 if (!--timeout)
159 break;
160 udelay(1);
161 }
162 outb(ch, speakup_info.port_tts);
163}
164
165static void spk_serial_tiocmset(unsigned int set, unsigned int clear)
165static void spk_serial_tiocmset(struct spk_synth *in_synth, unsigned int set, unsigned int clear)
166{
167 int old = inb(speakup_info.port_tts + UART_MCR);
168
169 outb((old & ~clear) | set, speakup_info.port_tts + UART_MCR);
170}
171
172int spk_serial_synth_probe(struct spk_synth *synth)
173{

--- 72 unchanged lines hidden (view full) ---

246 return 0;
247 }
248 udelay(1);
249 }
250 timeouts = 0;
251 return 1;
252}
253
166{
167 int old = inb(speakup_info.port_tts + UART_MCR);
168
169 outb((old & ~clear) | set, speakup_info.port_tts + UART_MCR);
170}
171
172int spk_serial_synth_probe(struct spk_synth *synth)
173{

--- 72 unchanged lines hidden (view full) ---

246 return 0;
247 }
248 udelay(1);
249 }
250 timeouts = 0;
251 return 1;
252}
253
254static unsigned char spk_serial_in(void)
254static unsigned char spk_serial_in(struct spk_synth *in_synth)
255{
256 int tmout = SPK_SERIAL_TIMEOUT;
257
258 while (!(inb_p(speakup_info.port_tts + UART_LSR) & UART_LSR_DR)) {
259 if (--tmout == 0) {
260 pr_warn("time out while waiting for input.\n");
261 return 0xff;
262 }
263 udelay(1);
264 }
265 return inb_p(speakup_info.port_tts + UART_RX);
266}
267
255{
256 int tmout = SPK_SERIAL_TIMEOUT;
257
258 while (!(inb_p(speakup_info.port_tts + UART_LSR) & UART_LSR_DR)) {
259 if (--tmout == 0) {
260 pr_warn("time out while waiting for input.\n");
261 return 0xff;
262 }
263 udelay(1);
264 }
265 return inb_p(speakup_info.port_tts + UART_RX);
266}
267
268static unsigned char spk_serial_in_nowait(void)
268static unsigned char spk_serial_in_nowait(struct spk_synth *in_synth)
269{
270 unsigned char lsr;
271
272 lsr = inb_p(speakup_info.port_tts + UART_LSR);
273 if (!(lsr & UART_LSR_DR))
274 return 0;
275 return inb_p(speakup_info.port_tts + UART_RX);
276}
277
269{
270 unsigned char lsr;
271
272 lsr = inb_p(speakup_info.port_tts + UART_LSR);
273 if (!(lsr & UART_LSR_DR))
274 return 0;
275 return inb_p(speakup_info.port_tts + UART_RX);
276}
277
278static void spk_serial_flush_buffer(void)
278static void spk_serial_flush_buffer(struct spk_synth *in_synth)
279{
280 /* TODO: flush the UART 16550 buffer */
281}
282
283static int spk_serial_out(struct spk_synth *in_synth, const char ch)
284{
285 if (in_synth->alive && spk_serial_wait_for_xmitr(in_synth)) {
286 outb_p(ch, speakup_info.port_tts);

--- 15 unchanged lines hidden (view full) ---

302 else
303 return buff;
304 buff++;
305 }
306 return NULL;
307}
308EXPORT_SYMBOL_GPL(spk_serial_synth_immediate);
309
279{
280 /* TODO: flush the UART 16550 buffer */
281}
282
283static int spk_serial_out(struct spk_synth *in_synth, const char ch)
284{
285 if (in_synth->alive && spk_serial_wait_for_xmitr(in_synth)) {
286 outb_p(ch, speakup_info.port_tts);

--- 15 unchanged lines hidden (view full) ---

302 else
303 return buff;
304 buff++;
305 }
306 return NULL;
307}
308EXPORT_SYMBOL_GPL(spk_serial_synth_immediate);
309
310void spk_serial_release(void)
310void spk_serial_release(struct spk_synth *synth)
311{
312 spk_stop_serial_interrupt();
313 if (speakup_info.port_tts == 0)
314 return;
315 synth_release_region(speakup_info.port_tts, 8);
316 speakup_info.port_tts = 0;
317}
318EXPORT_SYMBOL_GPL(spk_serial_release);
311{
312 spk_stop_serial_interrupt();
313 if (speakup_info.port_tts == 0)
314 return;
315 synth_release_region(speakup_info.port_tts, 8);
316 speakup_info.port_tts = 0;
317}
318EXPORT_SYMBOL_GPL(spk_serial_release);