Back to home page

LXR

 
 

    


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

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  *  @file
0005  *
0006  *  @ingroup m68k_m360spi
0007  *
0008  *  @brief this file contains the MC68360 SPI driver declarations
0009  */
0010 
0011 /*
0012  * Copyright (c) 2008 embedded brains GmbH & Co. KG
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 /**
0037  *  @defgroup m68k_m360spi M360_SPIDRV Support
0038  *
0039  *  @ingroup RTEMSBSPsM68kGen68360
0040  *
0041  *  @brief M360_SPIDRV Support Package
0042  */
0043 
0044 #ifndef _M360_SPIDRV_H
0045 #define _M360_SPIDRV_H
0046 
0047 #include <rtems/m68k/m68360.h>
0048 #include <rtems/libi2c.h>
0049 #include <rtems/irq.h>
0050 
0051 #ifdef __cplusplus
0052 extern "C" {
0053 #endif
0054 
0055 typedef struct m360_spi_softc {
0056   int                     initialized;
0057   rtems_id                irq_sema_id;
0058   rtems_isr_entry         old_handler;
0059   m360BufferDescriptor_t *rx_bd;
0060   m360BufferDescriptor_t *tx_bd;
0061 } m360_spi_softc_t ;
0062 
0063 typedef struct {
0064   rtems_libi2c_bus_t  bus_desc;
0065   m360_spi_softc_t softc;
0066 } m360_spi_desc_t;
0067 
0068 /*=========================================================================*\
0069 | Function:                                                                 |
0070 \*-------------------------------------------------------------------------*/
0071 rtems_status_code m360_spi_init
0072 (
0073 /*-------------------------------------------------------------------------*\
0074 | Purpose:                                                                  |
0075 |   initialize the driver                                                   |
0076 +---------------------------------------------------------------------------+
0077 | Input Parameters:                                                         |
0078 \*-------------------------------------------------------------------------*/
0079  rtems_libi2c_bus_t *bh                  /* bus specifier structure        */
0080  );
0081 /*-------------------------------------------------------------------------*\
0082 | Return Value:                                                             |
0083 |    o = ok or error code                                                   |
0084 \*=========================================================================*/
0085 
0086 /*=========================================================================*\
0087 | Function:                                                                 |
0088 \*-------------------------------------------------------------------------*/
0089 int m360_spi_read_bytes
0090 (
0091 /*-------------------------------------------------------------------------*\
0092 | Purpose:                                                                  |
0093 |   receive some bytes from SPI device                                      |
0094 +---------------------------------------------------------------------------+
0095 | Input Parameters:                                                         |
0096 \*-------------------------------------------------------------------------*/
0097  rtems_libi2c_bus_t *bh,                 /* bus specifier structure        */
0098  unsigned char *buf,                     /* buffer to store bytes          */
0099  int len                                 /* number of bytes to receive     */
0100  );
0101 /*-------------------------------------------------------------------------*\
0102 | Return Value:                                                             |
0103 |    number of bytes received or (negative) error code                      |
0104 \*=========================================================================*/
0105 
0106 /*=========================================================================*\
0107 | Function:                                                                 |
0108 \*-------------------------------------------------------------------------*/
0109 int m360_spi_write_bytes
0110 (
0111 /*-------------------------------------------------------------------------*\
0112 | Purpose:                                                                  |
0113 |   send some bytes to SPI device                                           |
0114 +---------------------------------------------------------------------------+
0115 | Input Parameters:                                                         |
0116 \*-------------------------------------------------------------------------*/
0117  rtems_libi2c_bus_t *bh,                 /* bus specifier structure        */
0118  unsigned char *buf,                     /* buffer to send                 */
0119  int len                                 /* number of bytes to send        */
0120 
0121  );
0122 /*-------------------------------------------------------------------------*\
0123 | Return Value:                                                             |
0124 |    number of bytes sent or (negative) error code                          |
0125 \*=========================================================================*/
0126 
0127 /*=========================================================================*\
0128 | Function:                                                                 |
0129 \*-------------------------------------------------------------------------*/
0130 rtems_status_code m360_spi_set_tfr_mode
0131 (
0132 /*-------------------------------------------------------------------------*\
0133 | Purpose:                                                                  |
0134 |   set SPI to desired baudrate/clock mode/character mode                   |
0135 +---------------------------------------------------------------------------+
0136 | Input Parameters:                                                         |
0137 \*-------------------------------------------------------------------------*/
0138  rtems_libi2c_bus_t *bh,                 /* bus specifier structure        */
0139  const rtems_libi2c_tfr_mode_t *tfr_mode /* transfer mode info             */
0140  );
0141 /*-------------------------------------------------------------------------*\
0142 | Return Value:                                                             |
0143 |    rtems_status_code                                                      |
0144 \*=========================================================================*/
0145 
0146 /*=========================================================================*\
0147 | Function:                                                                 |
0148 \*-------------------------------------------------------------------------*/
0149 int m360_spi_ioctl
0150 (
0151 /*-------------------------------------------------------------------------*\
0152 | Purpose:                                                                  |
0153 |   perform selected ioctl function for SPI                                 |
0154 +---------------------------------------------------------------------------+
0155 | Input Parameters:                                                         |
0156 \*-------------------------------------------------------------------------*/
0157  rtems_libi2c_bus_t *bh,                 /* bus specifier structure        */
0158  int                 cmd,                /* ioctl command code             */
0159  void               *arg                 /* additional argument array      */
0160  );
0161 /*-------------------------------------------------------------------------*\
0162 | Return Value:                                                             |
0163 |    rtems_status_code                                                      |
0164 \*=========================================================================*/
0165 
0166 #ifdef __cplusplus
0167 }
0168 #endif
0169 
0170 
0171 #endif /* _M360_SPIDRV_H */