Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:05

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *
0005  *  COPYRIGHT (c) 1989-1999.
0006  *  On-Line Applications Research Corporation (OAR).
0007  *
0008  * Redistribution and use in source and binary forms, with or without
0009  * modification, are permitted provided that the following conditions
0010  * are met:
0011  * 1. Redistributions of source code must retain the above copyright
0012  *    notice, this list of conditions and the following disclaimer.
0013  * 2. Redistributions in binary form must reproduce the above copyright
0014  *    notice, this list of conditions and the following disclaimer in the
0015  *    documentation and/or other materials provided with the distribution.
0016  *
0017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0027  * POSSIBILITY OF SUCH DAMAGE.
0028  */
0029 
0030 #ifndef _MC68681_P_H_
0031 #define _MC68681_P_H_
0032 
0033 #ifdef __cplusplus
0034 extern "C" {
0035 #endif
0036 
0037 /*
0038  *  Define MC68681_STATIC to nothing while debugging so the entry points
0039  *  will show up in the symbol table.
0040  */
0041 
0042 #define MC68681_STATIC
0043 
0044 /* #define MC68681_STATIC static */
0045 
0046 /*
0047  * mc68681 register offsets Read/Write Addresses
0048  */
0049 
0050 #define MC68681_MODE_REG_1A  0  /* MR1A-MR Prior to Read */
0051 #define MC68681_MODE_REG_2A  0  /* MR2A-MR After Read    */
0052 
0053 #define MC68681_COUNT_MODE_CURRENT_MSB       6  /* CTU   */
0054 #define MC68681_COUNTER_TIMER_UPPER_REG      6  /* CTU   */
0055 #define MC68681_COUNT_MODE_CURRENT_LSB       7  /* CTL   */
0056 #define MC68681_COUNTER_TIMER_LOWER_REG      7  /* CTL   */
0057 #define MC68681_INTERRUPT_VECTOR_REG        12  /* IVR   */
0058 
0059 #define MC68681_MODE_REG_1B  8  /* MR1B-MR Prior to Read */
0060 #define MC68681_MODE_REG_2B  8  /* MR2BA-MR After Read   */
0061 
0062 /*
0063  * mc68681 register offsets Read Only  Addresses
0064  */
0065 
0066 #define MC68681_STATUS_REG_A                 1  /* SRA   */
0067 #define MC68681_MASK_ISR_REG                 2  /* MISR  */
0068 #define MC68681_RECEIVE_BUFFER_A             3  /* RHRA  */
0069 #define MC68681_INPUT_PORT_CHANGE_REG        4  /* IPCR  */
0070 #define MC68681_INTERRUPT_STATUS_REG         5  /* ISR   */
0071 #define MC68681_STATUS_REG_B                 9  /* SRB   */
0072 #define MC68681_RECEIVE_BUFFER_B            11  /* RHRB  */
0073 #define MC68681_INPUT_PORT                  13  /* IP    */
0074 #define MC68681_START_COUNT_CMD             14  /* SCC   */
0075 #define MC68681_STOP_COUNT_CMD              15  /* STC   */
0076 
0077 /*
0078  * mc68681 register offsets Write Only  Addresses
0079  */
0080 
0081 #define MC68681_CLOCK_SELECT_REG_A           1  /* CSRA  */
0082 #define MC68681_COMMAND_REG_A                2  /* CRA   */
0083 #define MC68681_TRANSMIT_BUFFER_A            3  /* THRA  */
0084 #define MC68681_AUX_CTRL_REG                 4  /* ACR   */
0085 #define MC68681_INTERRUPT_MASK_REG           5  /* IMR   */
0086 #define MC68681_CLOCK_SELECT_REG_B           9  /* CSRB  */
0087 #define MC68681_COMMAND_REG_B               10  /* CRB   */
0088 #define MC68681_TRANSMIT_BUFFER_B           11  /* THRB  */
0089 #define MC68681_OUTPUT_PORT_CONFIG_REG      13  /* OPCR  */
0090 #define MC68681_OUTPUT_PORT_SET_REG         14  /* SOPBC */
0091 #define MC68681_OUTPUT_PORT_RESET_BITS      15  /* COPBC */
0092 
0093 /*
0094  *  DUART Command Register Definitions:
0095  *
0096  *  MC68681_COMMAND_REG_A,MC68681_COMMAND_REG_B
0097  */
0098 
0099 #define MC68681_MODE_REG_ENABLE_RX                          0x01
0100 #define MC68681_MODE_REG_DISABLE_RX                         0x02
0101 #define MC68681_MODE_REG_ENABLE_TX                          0x04
0102 #define MC68681_MODE_REG_DISABLE_TX                         0x08
0103 #define MC68681_MODE_REG_RESET_MR_PTR                       0x10
0104 #define MC68681_MODE_REG_RESET_RX                           0x20
0105 #define MC68681_MODE_REG_RESET_TX                           0x30
0106 #define MC68681_MODE_REG_RESET_ERROR                        0x40
0107 #define MC68681_MODE_REG_RESET_BREAK                        0x50
0108 #define MC68681_MODE_REG_START_BREAK                        0x60
0109 #define MC68681_MODE_REG_STOP_BREAK                         0x70
0110 #define MC68681_MODE_REG_SET_RX_BRG                         0x80
0111 #define MC68681_MODE_REG_CLEAR_RX_BRG                       0x90
0112 #define MC68681_MODE_REG_SET_TX_BRG                         0xa0
0113 #define MC68681_MODE_REG_CLEAR_TX_BRG                       0xb0
0114 #define MC68681_MODE_REG_SET_STANDBY                        0xc0
0115 #define MC68681_MODE_REG_SET_ACTIVE                         0xd0
0116 
0117 /*
0118  * Mode Register Definitions
0119  *
0120  *  MC68681_MODE_REG_1A
0121  *  MC68681_MODE_REG_1B
0122  */
0123 
0124 #define MC68681_5BIT_CHARS                                  0x00
0125 #define MC68681_6BIT_CHARS                                  0x01
0126 #define MC68681_7BIT_CHARS                                  0x02
0127 #define MC68681_8BIT_CHARS                                  0x03
0128 
0129 #define MC68681_ODD_PARITY                                  0x00
0130 #define MC68681_EVEN_PARITY                                 0x04
0131 
0132 #define MC68681_WITH_PARITY                                 0x00
0133 #define MC68681_FORCE_PARITY                                0x08
0134 #define MC68681_NO_PARITY                                   0x10
0135 #define MC68681_MULTI_DROP                                  0x18
0136 
0137 #define MC68681_ERR_MODE_CHAR                               0x00
0138 #define MC68681_ERR_MODE_BLOCK                              0x20
0139 
0140 #define MC68681_RX_INTR_RX_READY                            0x00
0141 #define MC68681_RX_INTR_FFULL                               0x40
0142 
0143 #define MC68681_NO_RX_RTS_CTL                               0x00
0144 #define MC68681_RX_RTS_CTRL                                 0x80
0145 
0146 /*
0147  * Mode Register Definitions
0148  *
0149  *  MC68681_MODE_REG_2A
0150  *  MC68681_MODE_REG_2B
0151  */
0152 
0153 #define MC68681_STOP_BIT_LENGTH__563                        0x00
0154 #define MC68681_STOP_BIT_LENGTH__625                        0x01
0155 #define MC68681_STOP_BIT_LENGTH__688                        0x02
0156 #define MC68681_STOP_BIT_LENGTH__75                         0x03
0157 #define MC68681_STOP_BIT_LENGTH__813                        0x04
0158 #define MC68681_STOP_BIT_LENGTH__875                        0x05
0159 #define MC68681_STOP_BIT_LENGTH__938                        0x06
0160 #define MC68681_STOP_BIT_LENGTH_1                           0x07
0161 #define MC68681_STOP_BIT_LENGTH_1_563                       0x08
0162 #define MC68681_STOP_BIT_LENGTH_1_625                       0x09
0163 #define MC68681_STOP_BIT_LENGTH_1_688                       0x0a
0164 #define MC68681_STOP_BIT_LENGTH_1_75                        0x0b
0165 #define MC68681_STOP_BIT_LENGTH_1_813                       0x0c
0166 #define MC68681_STOP_BIT_LENGTH_1_875                       0x0d
0167 #define MC68681_STOP_BIT_LENGTH_1_938                       0x0e
0168 #define MC68681_STOP_BIT_LENGTH_2                           0x0f
0169 
0170 #define MC68681_CTS_ENABLE_TX                               0x10
0171 #define MC68681_TX_RTS_CTRL                                 0x20
0172 
0173 #define MC68681_CHANNEL_MODE_NORMAL                         0x00
0174 #define MC68681_CHANNEL_MODE_ECHO                           0x40
0175 #define MC68681_CHANNEL_MODE_LOCAL_LOOP                     0x80
0176 #define MC68681_CHANNEL_MODE_REMOTE_LOOP                    0xc0
0177 
0178 /*
0179  * Status Register Definitions
0180  *
0181  *    MC68681_STATUS_REG_A,  MC68681_STATUS_REG_B
0182  */
0183 
0184 #define MC68681_RX_READY                                    0x01
0185 #define MC68681_FFULL                                       0x02
0186 #define MC68681_TX_READY                                    0x04
0187 #define MC68681_TX_EMPTY                                    0x08
0188 #define MC68681_OVERRUN_ERROR                               0x10
0189 #define MC68681_PARITY_ERROR                                0x20
0190 #define MC68681_FRAMING_ERROR                               0x40
0191 #define MC68681_RECEIVED_BREAK                              0x80
0192 
0193 #define MC68681_RX_ERRORS \
0194   (MC68681_OVERRUN_ERROR|MC68681_PARITY_ERROR| \
0195    MC68681_FRAMING_ERROR|MC68681_RECEIVED_BREAK)
0196 
0197 /*
0198  * Interupt Status Register Definitions.
0199  *
0200  * MC68681_INTERRUPT_STATUS_REG
0201  */
0202 
0203 /*
0204  *  Interupt Mask Register Definitions
0205  *
0206  *  MC68681_INTERRUPT_MASK_REG
0207  */
0208 
0209 /* These are passed to mc68681_build_imr */
0210 #define MC68681_IR_TX_READY                                 0x01
0211 #define MC68681_IR_RX_READY                                 0x02
0212 #define MC68681_IR_BREAK                                    0x04
0213 #define MC68681_IMR_ENABLE_ALL                              0x07
0214 #define MC68681_IMR_DISABLE_ALL                             0x00
0215 #define MC68681_IMR_ENABLE_ALL_EXCEPT_TX                    0x06
0216 
0217 #define MC68681_IR_TX_READY_A                               0x01
0218 #define MC68681_IR_RX_READY_A                               0x02
0219 #define MC68681_IR_BREAK_A                                  0x04
0220 #define MC68681_IR_COUNTER_READY                            0x08
0221 #define MC68681_IR_TX_READY_B                               0x10
0222 #define MC68681_IR_RX_READY_B                               0x20
0223 #define MC68681_IR_BREAK_B                                  0x40
0224 #define MC68681_IR_INPUT_PORT_CHANGE                        0x80
0225 
0226 /*
0227  * Status Register Definitions.
0228  *
0229  * MC68681_STATUS_REG_A,MC68681_STATUS_REG_B
0230  */
0231 
0232 #define MC68681_STATUS_RXRDY                                0x01
0233 #define MC68681_STATUS_FFULL                                0x02
0234 #define MC68681_STATUS_TXRDY                                0x04
0235 #define MC68681_STATUS_TXEMT                                0x08
0236 #define MC68681_STATUS_OVERRUN_ERROR                        0x10
0237 #define MC68681_STATUS_PARITY_ERROR                         0x20
0238 #define MC68681_STATUS_FRAMING_ERROR                        0x40
0239 #define MC68681_STATUS_RECEIVED_BREAK                       0x80
0240 
0241 /*
0242  * Definitions for the Interrupt Vector Register:
0243  *
0244  * MC68681_INTERRUPT_VECTOR_REG
0245  */
0246 
0247 #define  MC68681_INTERRUPT_VECTOR_INIT                      0x0f
0248 
0249 /*
0250  * Definitions for the Auxiliary Control Register
0251  *
0252  * MC68681_AUX_CTRL_REG
0253  */
0254 
0255 #define MC68681_AUX_BRG_SET1                                0x00
0256 #define MC68681_AUX_BRG_SET2                                0x80
0257 
0258 /*
0259  *  Per chip context control
0260  */
0261 
0262 typedef struct _mc68681_context
0263 {
0264   int            mate;
0265   unsigned char  imr;
0266 } mc68681_context;
0267 
0268 /*
0269  * Driver functions
0270  */
0271 MC68681_STATIC void mc68681_initialize_context(
0272   int               minor,
0273   mc68681_context  *pmc68681Context
0274 );
0275 
0276 MC68681_STATIC bool mc68681_probe(int minor);
0277 
0278 MC68681_STATIC int mc68681_set_attributes(
0279   int minor,
0280   const struct termios *t
0281 );
0282 
0283 MC68681_STATIC void mc68681_init(int minor);
0284 
0285 MC68681_STATIC int mc68681_open(
0286   int major,
0287   int minor,
0288   void  * arg
0289 );
0290 
0291 MC68681_STATIC int mc68681_close(
0292   int major,
0293   int minor,
0294   void  * arg
0295 );
0296 
0297 MC68681_STATIC void mc68681_write_polled(
0298   int   minor,
0299   char  cChar
0300 );
0301 
0302 MC68681_STATIC void mc68681_initialize_interrupts(int minor);
0303 
0304 MC68681_STATIC ssize_t mc68681_write_support_int(
0305   int   minor,
0306   const char *buf,
0307   size_t len
0308 );
0309 
0310 MC68681_STATIC ssize_t mc68681_write_support_polled(
0311   int   minor,
0312   const char *buf,
0313   size_t   len
0314   );
0315 
0316 MC68681_STATIC int mc68681_inbyte_nonblocking_polled(
0317   int minor
0318 );
0319 
0320 MC68681_STATIC unsigned int mc68681_build_imr(
0321   int  minor,
0322   int  enable_flag
0323 );
0324 
0325 MC68681_STATIC void mc68681_process(
0326   int  minor
0327 );
0328 
0329 MC68681_STATIC void mc68681_enable_interrupts(
0330   int minor,
0331   int imr_mask
0332 );
0333 
0334 MC68681_STATIC rtems_isr mc68681_isr(
0335   rtems_vector_number vector
0336 );
0337 
0338 #ifdef __cplusplus
0339 }
0340 #endif
0341 
0342 #endif /* _MC68681_P_H_ */