Back to home page

LXR

 
 

    


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

0001 /**
0002  *@file
0003  *
0004  *@brief
0005  *  - This file implements uart console for TLL6527M. TLL6527M has BF527 with
0006  *  second uart (uart-1) connected to the console.
0007  *
0008  * Target:   TLL6527v1-0
0009  * Compiler:
0010  *
0011  * COPYRIGHT (c) 2010 by ECE Northeastern University.
0012  *
0013  * The license and distribution terms for this file may be
0014  * found in the file LICENSE in this distribution or at
0015  * http://www.rtems.org/license
0016  *
0017  * @author Rohan Kangralkar, ECE, Northeastern University
0018  *         (kangralkar.r@husky.neu.edu)
0019  *
0020  * LastChange:
0021  */
0022 
0023 #include <rtems.h>
0024 #include <rtems/libio.h>
0025 #include <bsp.h>
0026 #include <rtems/bspIo.h>
0027 #include <rtems/console.h>
0028 
0029 #include <bsp/interrupt.h>
0030 #include <libcpu/uart.h>
0031 
0032 /***************************************************
0033 LOCAL DEFINES
0034  ***************************************************/
0035 
0036 
0037 /***************************************************
0038 STATIC GLOBALS
0039  ***************************************************/
0040 /**
0041  * Declaration of UART
0042  */
0043 static bfin_uart_channel_t channels[] = {
0044   {"/dev/console",
0045     UART1_BASE_ADDRESS,
0046     DMA10_BASE_ADDRESS,
0047     DMA11_BASE_ADDRESS,
0048     CONSOLE_USE_INTERRUPTS,
0049     UART_USE_DMA,
0050     CONSOLE_BAUDRATE,
0051     NULL,
0052     0,
0053     0}
0054 };
0055 
0056 /**
0057  * Over all configuration
0058  */
0059 static bfin_uart_config_t config = {
0060     SCLK,
0061     sizeof(channels) / sizeof(channels[0]),
0062     channels
0063 };
0064 
0065 
0066 #if CONSOLE_USE_INTERRUPTS
0067 /**
0068  * The Rx and Tx isr will get the same argument
0069  * The isr will have to find if it was the rx that caused the interrupt or
0070  * the tx
0071  */
0072 static bfin_isr_t bfinUARTISRs[] = {
0073 #if UART_USE_DMA
0074     /* For First uart */
0075     {IRQ_DMA10_UART1_RX, bfinUart_rxDmaIsr, (void *)&channels[0], 0},
0076     {IRQ_DMA11_UART1_TX, bfinUart_txDmaIsr, (void *)&channels[0], 0},
0077     /* For second uart */
0078 #else
0079     /* For First uart */
0080     {IRQ_DMA10_UART1_RX, bfinUart_rxIsr, &channels[0], 0},
0081     {IRQ_DMA11_UART1_TX, bfinUart_txIsr, &channels[0], 0},
0082     /* For second uart */
0083 #endif
0084 };
0085 #endif
0086 
0087 
0088 static void TLL6527_BSP_output_char(char c) {
0089 
0090   bfin_uart_poll_write(0, c);
0091 }
0092 
0093 static int TLL6527_BSP_poll_char(void) {
0094 
0095   return bfin_uart_poll_read(0);
0096 }
0097 
0098 BSP_output_char_function_type     BSP_output_char = TLL6527_BSP_output_char;
0099 BSP_polling_getchar_function_type BSP_poll_char   = TLL6527_BSP_poll_char;
0100 
0101 
0102 
0103 rtems_device_driver console_close(rtems_device_major_number major,
0104     rtems_device_minor_number minor,
0105     void *arg) {
0106 
0107   return rtems_termios_close(arg);
0108 }
0109 
0110 rtems_device_driver console_read(rtems_device_major_number major,
0111     rtems_device_minor_number minor,
0112     void *arg) {
0113 
0114   return rtems_termios_read(arg);
0115 }
0116 
0117 rtems_device_driver console_write(rtems_device_major_number major,
0118     rtems_device_minor_number minor,
0119     void *arg) {
0120 
0121   return rtems_termios_write(arg);
0122 }
0123 
0124 rtems_device_driver console_control(rtems_device_major_number major,
0125     rtems_device_minor_number minor,
0126     void *arg) {
0127 
0128   return rtems_termios_ioctl(arg);
0129 }
0130 
0131 
0132 
0133 /*
0134  *  Open entry point
0135  */
0136 rtems_device_driver console_open(rtems_device_major_number major,
0137     rtems_device_minor_number minor,
0138     void *arg) {
0139 
0140   return bfin_uart_open(major, minor, arg);
0141 }
0142 
0143 
0144 
0145 /**
0146  *
0147  * This routine initializes the console IO driver.
0148  *
0149  * Parameters
0150  * @param major major number
0151  * @param minor minor number
0152  *
0153  * Output parameters:  NONE
0154  *
0155  * @return void
0156  */
0157 rtems_device_driver console_initialize(rtems_device_major_number major,
0158     rtems_device_minor_number minor,
0159     void *arg) {
0160   rtems_status_code status = RTEMS_NOT_DEFINED;
0161 #if CONSOLE_USE_INTERRUPTS
0162   int               i      = 0;
0163 #endif
0164 
0165   status = bfin_uart_initialize(major, &config);
0166   if (status != RTEMS_SUCCESSFUL) {
0167     rtems_fatal_error_occurred(status);
0168   }
0169 
0170 #if CONSOLE_USE_INTERRUPTS
0171   for (i = 0; i < sizeof(bfinUARTISRs) / sizeof(bfinUARTISRs[0]); i++) {
0172     bfin_interrupt_register(&bfinUARTISRs[i]);
0173 #if INTERRUPT_USE_TABLE
0174 #else
0175     bfin_interrupt_enable(&bfinUARTISRs[i], 1);
0176 #endif
0177   }
0178 #endif
0179 
0180   return RTEMS_SUCCESSFUL;
0181 }