Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:43

0001 /**
0002  *  @file
0003  *  
0004  */
0005 
0006 /*
0007  *  COPYRIGHT (c) 1998 by Radstone Technology
0008  *
0009  *  THIS FILE IS PROVIDED TO YOU, THE USER, "AS IS", WITHOUT WARRANTY OF ANY
0010  *  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
0011  *  IMPLIED WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK
0012  *  AS TO THE QUALITY AND PERFORMANCE OF ALL CODE IN THIS FILE IS WITH YOU.
0013  *
0014  *  You are hereby granted permission to use, copy, modify, and distribute
0015  *  this file, provided that this notice, plus the above copyright notice
0016  *  and disclaimer, appears in all copies. Radstone Technology will provide
0017  *  no support for this code.
0018  *
0019  *  COPYRIGHT (c) 1989-2012.
0020  *  On-Line Applications Research Corporation (OAR).
0021  *
0022  *  The license and distribution terms for this file may be
0023  *  found in the file LICENSE in this distribution or at
0024  *  http://www.rtems.org/license/LICENSE.
0025  */
0026 
0027 #ifndef _NS16550_H_
0028 #define _NS16550_H_
0029 
0030 #include <rtems/termiostypes.h>
0031 #include <libchip/serial.h>
0032 
0033 #ifdef __cplusplus
0034 extern "C" {
0035 #endif
0036 
0037 /*
0038  * Driver function table
0039  */
0040 
0041 extern const console_fns ns16550_fns;
0042 extern const console_fns ns16550_fns_polled;
0043 
0044 /*
0045  * Flow control function tables
0046  */
0047 
0048 extern const console_flow ns16550_flow_RTSCTS;
0049 extern const console_flow ns16550_flow_DTRCTS;
0050 
0051 /*
0052  *  Helpers for printk
0053  */
0054 void ns16550_outch_polled(console_tbl *c, char out);
0055 int ns16550_inch_polled(console_tbl *c);
0056 
0057 /* Alternative NS16550 driver using the Termios device context */
0058 
0059 typedef uint8_t (*ns16550_get_reg)(uintptr_t port, uint8_t reg);
0060 
0061 typedef void (*ns16550_set_reg)(uintptr_t port, uint8_t reg, uint8_t value);
0062 
0063 typedef struct ns16550_context ns16550_context;
0064 
0065 typedef uint32_t (*ns16550_calculate_baud_divisor)(ns16550_context *ctx, uint32_t baud);
0066 
0067 struct ns16550_context{
0068   rtems_termios_device_context base;
0069   ns16550_get_reg get_reg;
0070   ns16550_set_reg set_reg;
0071   uintptr_t port;
0072   rtems_vector_number irq;
0073   uint32_t clock;
0074   uint32_t initial_baud;
0075   bool has_fractional_divider_register;
0076   bool has_precision_clock_synthesizer;
0077   uint8_t modem_control;
0078   uint8_t line_control;
0079   uint32_t baud_divisor;
0080   size_t out_total;
0081   size_t out_remaining;
0082   size_t out_current;
0083   const char *out_buf;
0084   rtems_termios_tty *tty;
0085   ns16550_calculate_baud_divisor calculate_baud_divisor;
0086 };
0087 
0088 extern const rtems_termios_device_handler ns16550_handler_interrupt;
0089 extern const rtems_termios_device_handler ns16550_handler_polled;
0090 extern const rtems_termios_device_handler ns16550_handler_task;
0091 
0092 extern const rtems_termios_device_flow ns16550_flow_rtscts;
0093 extern const rtems_termios_device_flow ns16550_flow_dtrcts;
0094 
0095 void ns16550_polled_putchar(rtems_termios_device_context *base, char out);
0096 
0097 int ns16550_polled_getchar(rtems_termios_device_context *base);
0098 
0099 bool ns16550_probe(rtems_termios_device_context *base);
0100 
0101 #ifdef __cplusplus
0102 }
0103 #endif
0104 
0105 #endif /* _NS16550_H_ */