[f0f6e888] | 1 | /* |
---|
| 2 | * RTEMS support for MPC83xx |
---|
| 3 | * |
---|
| 4 | * This file contains the MPC83xx SPI driver declarations. |
---|
| 5 | * NOTE: This driver has the same API as a I2C driver. |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | /* |
---|
| 9 | * Copyright (c) 2007 embedded brains GmbH. All rights reserved. |
---|
| 10 | * |
---|
| 11 | * The license and distribution terms for this file may be |
---|
| 12 | * found in the file LICENSE in this distribution or at |
---|
| 13 | * http://www.rtems.org/license/LICENSE. |
---|
| 14 | */ |
---|
| 15 | |
---|
[7edabaf] | 16 | #ifndef _MPC83XX_SPIDRV_H |
---|
| 17 | #define _MPC83XX_SPIDRV_H |
---|
| 18 | |
---|
| 19 | #include <mpc83xx/mpc83xx.h> |
---|
| 20 | #include <rtems/libi2c.h> |
---|
| 21 | #include <rtems/irq.h> |
---|
| 22 | |
---|
| 23 | #ifdef __cplusplus |
---|
| 24 | extern "C" { |
---|
| 25 | #endif |
---|
| 26 | |
---|
| 27 | typedef struct mpc83xx_spi_softc { |
---|
| 28 | m83xxSPIRegisters_t *reg_ptr; |
---|
| 29 | int initialized; |
---|
| 30 | rtems_irq_number irq_number; |
---|
[42bf1b9] | 31 | uint32_t base_frq; /* input frq for baud rate divider */ |
---|
[7edabaf] | 32 | rtems_id irq_sema_id; |
---|
| 33 | uint32_t curr_addr; /* current spi address */ |
---|
[574fb67] | 34 | uint32_t idle_char; |
---|
[7edabaf] | 35 | uint8_t bytes_per_char; |
---|
| 36 | uint8_t bit_shift; |
---|
| 37 | } mpc83xx_spi_softc_t ; |
---|
| 38 | |
---|
| 39 | typedef struct { |
---|
[359e537] | 40 | rtems_libi2c_bus_t bus_desc; |
---|
[7edabaf] | 41 | mpc83xx_spi_softc_t softc; |
---|
| 42 | } mpc83xx_spi_desc_t; |
---|
| 43 | |
---|
| 44 | /*=========================================================================*\ |
---|
| 45 | | Function: | |
---|
| 46 | \*-------------------------------------------------------------------------*/ |
---|
| 47 | rtems_status_code mpc83xx_spi_init |
---|
| 48 | ( |
---|
| 49 | /*-------------------------------------------------------------------------*\ |
---|
| 50 | | Purpose: | |
---|
| 51 | | initialize the driver | |
---|
| 52 | +---------------------------------------------------------------------------+ |
---|
| 53 | | Input Parameters: | |
---|
| 54 | \*-------------------------------------------------------------------------*/ |
---|
| 55 | rtems_libi2c_bus_t *bh /* bus specifier structure */ |
---|
| 56 | ); |
---|
| 57 | /*-------------------------------------------------------------------------*\ |
---|
| 58 | | Return Value: | |
---|
| 59 | | o = ok or error code | |
---|
| 60 | \*=========================================================================*/ |
---|
| 61 | |
---|
| 62 | /*=========================================================================*\ |
---|
| 63 | | Function: | |
---|
| 64 | \*-------------------------------------------------------------------------*/ |
---|
| 65 | int mpc83xx_spi_read_write_bytes |
---|
| 66 | ( |
---|
| 67 | /*-------------------------------------------------------------------------*\ |
---|
| 68 | | Purpose: | |
---|
| 69 | | transmit/receive some bytes from SPI device | |
---|
| 70 | +---------------------------------------------------------------------------+ |
---|
| 71 | | Input Parameters: | |
---|
| 72 | \*-------------------------------------------------------------------------*/ |
---|
| 73 | rtems_libi2c_bus_t *bh, /* bus specifier structure */ |
---|
| 74 | unsigned char *rbuf, /* buffer to store bytes */ |
---|
| 75 | const unsigned char *tbuf, /* buffer to send bytes */ |
---|
| 76 | int len /* number of bytes to transceive */ |
---|
| 77 | ); |
---|
| 78 | /*-------------------------------------------------------------------------*\ |
---|
| 79 | | Return Value: | |
---|
| 80 | | number of bytes received or (negative) error code | |
---|
| 81 | \*=========================================================================*/ |
---|
| 82 | |
---|
| 83 | /*=========================================================================*\ |
---|
| 84 | | Function: | |
---|
| 85 | \*-------------------------------------------------------------------------*/ |
---|
| 86 | int mpc83xx_spi_read_bytes |
---|
| 87 | ( |
---|
| 88 | /*-------------------------------------------------------------------------*\ |
---|
| 89 | | Purpose: | |
---|
| 90 | | receive some bytes from SPI device | |
---|
| 91 | +---------------------------------------------------------------------------+ |
---|
| 92 | | Input Parameters: | |
---|
| 93 | \*-------------------------------------------------------------------------*/ |
---|
| 94 | rtems_libi2c_bus_t *bh, /* bus specifier structure */ |
---|
| 95 | unsigned char *buf, /* buffer to store bytes */ |
---|
| 96 | int len /* number of bytes to receive */ |
---|
| 97 | ); |
---|
| 98 | /*-------------------------------------------------------------------------*\ |
---|
| 99 | | Return Value: | |
---|
| 100 | | number of bytes received or (negative) error code | |
---|
| 101 | \*=========================================================================*/ |
---|
| 102 | |
---|
| 103 | /*=========================================================================*\ |
---|
| 104 | | Function: | |
---|
| 105 | \*-------------------------------------------------------------------------*/ |
---|
| 106 | int mpc83xx_spi_write_bytes |
---|
| 107 | ( |
---|
| 108 | /*-------------------------------------------------------------------------*\ |
---|
| 109 | | Purpose: | |
---|
| 110 | | send some bytes to SPI device | |
---|
| 111 | +---------------------------------------------------------------------------+ |
---|
| 112 | | Input Parameters: | |
---|
| 113 | \*-------------------------------------------------------------------------*/ |
---|
| 114 | rtems_libi2c_bus_t *bh, /* bus specifier structure */ |
---|
| 115 | unsigned char *buf, /* buffer to send */ |
---|
| 116 | int len /* number of bytes to send */ |
---|
| 117 | |
---|
| 118 | ); |
---|
| 119 | /*-------------------------------------------------------------------------*\ |
---|
| 120 | | Return Value: | |
---|
| 121 | | number of bytes sent or (negative) error code | |
---|
| 122 | \*=========================================================================*/ |
---|
| 123 | |
---|
| 124 | /*=========================================================================*\ |
---|
| 125 | | Function: | |
---|
| 126 | \*-------------------------------------------------------------------------*/ |
---|
| 127 | rtems_status_code mpc83xx_spi_set_tfr_mode |
---|
| 128 | ( |
---|
| 129 | /*-------------------------------------------------------------------------*\ |
---|
| 130 | | Purpose: | |
---|
| 131 | | set SPI to desired baudrate/clock mode/character mode | |
---|
| 132 | +---------------------------------------------------------------------------+ |
---|
| 133 | | Input Parameters: | |
---|
| 134 | \*-------------------------------------------------------------------------*/ |
---|
| 135 | rtems_libi2c_bus_t *bh, /* bus specifier structure */ |
---|
| 136 | const rtems_libi2c_tfr_mode_t *tfr_mode /* transfer mode info */ |
---|
| 137 | ); |
---|
| 138 | /*-------------------------------------------------------------------------*\ |
---|
| 139 | | Return Value: | |
---|
| 140 | | rtems_status_code | |
---|
| 141 | \*=========================================================================*/ |
---|
| 142 | |
---|
| 143 | /*=========================================================================*\ |
---|
| 144 | | Function: | |
---|
| 145 | \*-------------------------------------------------------------------------*/ |
---|
| 146 | int mpc83xx_spi_ioctl |
---|
| 147 | ( |
---|
| 148 | /*-------------------------------------------------------------------------*\ |
---|
| 149 | | Purpose: | |
---|
| 150 | | perform selected ioctl function for SPI | |
---|
| 151 | +---------------------------------------------------------------------------+ |
---|
| 152 | | Input Parameters: | |
---|
| 153 | \*-------------------------------------------------------------------------*/ |
---|
| 154 | rtems_libi2c_bus_t *bh, /* bus specifier structure */ |
---|
| 155 | int cmd, /* ioctl command code */ |
---|
| 156 | void *arg /* additional argument array */ |
---|
| 157 | ); |
---|
| 158 | /*-------------------------------------------------------------------------*\ |
---|
| 159 | | Return Value: | |
---|
| 160 | | rtems_status_code | |
---|
| 161 | \*=========================================================================*/ |
---|
| 162 | |
---|
| 163 | #ifdef __cplusplus |
---|
| 164 | } |
---|
| 165 | #endif |
---|
| 166 | |
---|
| 167 | |
---|
| 168 | #endif /* _MPC83XX_I2CDRV_H */ |
---|