Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:22:49

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *  LCD Console Output Driver for CSBx37
0005  */
0006 
0007 /*
0008  *  COPYRIGHT (c) 1989-2014.
0009  *  On-Line Applications Research Corporation (OAR).
0010  *
0011  *  Modified by Fernando Nicodemos <fgnicodemos@terra.com.br>
0012  *  from NCB - Sistemas Embarcados Ltda. (Brazil)
0013  *
0014  * Redistribution and use in source and binary forms, with or without
0015  * modification, are permitted provided that the following conditions
0016  * are met:
0017  * 1. Redistributions of source code must retain the above copyright
0018  *    notice, this list of conditions and the following disclaimer.
0019  * 2. Redistributions in binary form must reproduce the above copyright
0020  *    notice, this list of conditions and the following disclaimer in the
0021  *    documentation and/or other materials provided with the distribution.
0022  *
0023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0024  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0025  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0026  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0027  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0028  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0029  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0030  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0031  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0032  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0033  * POSSIBILITY OF SUCH DAMAGE.
0034  */
0035 
0036 #include <bsp.h>
0037 #include <rtems/libio.h>
0038 #include <termios.h>
0039 
0040 #include <rtems/bspIo.h>
0041 #include <libchip/serial.h>
0042 #include <libchip/sersupp.h>
0043 #include "sed1356.h"
0044 
0045 /* static function prototypes */
0046 static int     fbcons_first_open(int major, int minor, void *arg);
0047 static int     fbcons_last_close(int major, int minor, void *arg);
0048 static int     fbcons_read(int minor);
0049 static ssize_t fbcons_write(int minor, const char *buf, size_t len);
0050 static void    fbcons_init(int minor);
0051 static void    fbcons_write_polled(int minor, char c);
0052 static int     fbcons_set_attributes(int minor, const struct termios *t);
0053 
0054 /* Pointers to functions for handling the UART. */
0055 const console_fns fbcons_fns =
0056 {
0057   libchip_serial_default_probe,
0058   fbcons_first_open,
0059   fbcons_last_close,
0060   fbcons_read,
0061   fbcons_write,
0062   fbcons_init,
0063   fbcons_write_polled,   /* not used in this driver */
0064   fbcons_set_attributes,
0065   FALSE      /* TRUE if interrupt driven, FALSE if not. */
0066 };
0067 /*********************************************************************/
0068 /* Functions called via callbacks (i.e. the ones in uart_fns */
0069 /*********************************************************************/
0070 
0071 /*
0072  * This is called the first time each device is opened. Since
0073  * the driver is polled, we don't have to do anything. If the driver
0074  * were interrupt driven, we'd enable interrupts here.
0075  */
0076 static int fbcons_first_open(int major, int minor, void *arg)
0077 {
0078   /* printk( "Frame buffer -- first open\n" ); */
0079   return 0;
0080 }
0081 
0082 
0083 /*
0084  * This is called the last time each device is closed.  Since
0085  * the driver is polled, we don't have to do anything. If the driver
0086  * were interrupt driven, we'd disable interrupts here.
0087  */
0088 static int fbcons_last_close(int major, int minor, void *arg)
0089 {
0090   /* printk( "Frame buffer -- last close\n" ); */
0091   return 0;
0092 }
0093 
0094 
0095 /*
0096  * Read one character from UART.
0097  *
0098  * return -1 if there's no data, otherwise return
0099  * the character in lowest 8 bits of returned int.
0100  */
0101 static int fbcons_read(int minor)
0102 {
0103   /* printk( "Frame buffer -- read\n" ); */
0104   return -1;
0105 }
0106 
0107 
0108 /*
0109  * Write buffer to LCD
0110  *
0111  * return 1 on success, -1 on error
0112  */
0113 static ssize_t fbcons_write(int minor, const char *buf, size_t len)
0114 {
0115   int i;
0116 
0117   /* printk( "Frame buffer -- write\n" ); */
0118   for ( i=0 ; i<len ; i++ )
0119     sed_putchar( buf[i] );
0120 
0121   return 1;
0122 }
0123 
0124 
0125 /* Set up the LCD controller. */
0126 static void fbcons_init(int minor)
0127 {
0128   /* printk( "Initializing frame buffer\n" ); */
0129   sed_init();
0130 }
0131 
0132 /* This is used for putchark support */
0133 static void fbcons_write_polled(int minor, char c)
0134 {
0135   /* printk( "frame buffer -- write polled\n" ); */
0136   sed_putchar( c );
0137 }
0138 
0139 /* This is for setting baud rate, bits, etc. */
0140 static int fbcons_set_attributes(int minor, const struct termios *t)
0141 {
0142   /* printk( "frame buffer -- set attributes\n" ); */
0143   return 0;
0144 }