File indexing completed on 2025-05-11 08:22:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef LIBBSP_ARM_BEAGLE_SPI_H
0020 #define LIBBSP_ARM_BEAGLE_SPI_H
0021
0022 #include <bsp.h>
0023 #include <rtems/libi2c.h>
0024 #include <rtems/irq.h>
0025
0026 #ifdef __cplusplus
0027 extern "C" {
0028 #endif
0029
0030 #define BBB_SPI_TIMEOUT 1000
0031
0032 #define BBB_SPI_0_BUS_PATH "/dev/spi-0"
0033
0034 #define BBB_SPI_0_IRQ AM335X_INT_SPI0INT
0035
0036 typedef enum {
0037 SPI0,
0038 SPI1,
0039 SPI_COUNT
0040 } bbb_spi_id_t;
0041
0042
0043
0044 typedef struct BEAGLE_SPI_BufferDescriptor_ {
0045 unsigned short status;
0046 unsigned short length;
0047 volatile void *buffer;
0048 } BEAGLE_SPI_BufferDescriptor_t;
0049
0050 typedef struct beagle_spi_softc {
0051 int initialized;
0052 rtems_id task_id;
0053 uintptr_t regs_base;
0054 rtems_vector_number irq;
0055 } beagle_spi_softc_t;
0056
0057 typedef struct {
0058 rtems_libi2c_bus_t bus_desc;
0059 beagle_spi_softc_t softc;
0060 } beagle_spi_desc_t;
0061
0062
0063
0064
0065
0066
0067 rtems_status_code beagle_spi_init
0068 (
0069 rtems_libi2c_bus_t *bh
0070 );
0071
0072
0073
0074
0075
0076
0077 int beagle_spi_read_bytes
0078 (
0079 rtems_libi2c_bus_t *bh,
0080 unsigned char *buf,
0081 int len
0082 );
0083
0084
0085
0086
0087
0088
0089 int beagle_spi_write_bytes
0090 (
0091 rtems_libi2c_bus_t *bh,
0092 unsigned char *buf,
0093 int len
0094 );
0095
0096
0097
0098
0099
0100
0101 rtems_status_code beagle_spi_set_tfr_mode
0102 (
0103 rtems_libi2c_bus_t *bh,
0104 const rtems_libi2c_tfr_mode_t *tfr_mode
0105 );
0106
0107
0108
0109
0110
0111
0112 int beagle_spi_ioctl
0113 (
0114 rtems_libi2c_bus_t *bh,
0115 int cmd,
0116 void *arg
0117 );
0118
0119
0120
0121
0122
0123
0124 rtems_status_code bsp_register_spi
0125 (
0126 const char *bus_path,
0127 uintptr_t register_base,
0128 rtems_vector_number irq
0129 );
0130
0131 static inline rtems_status_code bbb_register_spi_0(void)
0132 {
0133 return bsp_register_spi(
0134 BBB_SPI_0_BUS_PATH,
0135 AM335X_SPI0_BASE,
0136 BBB_SPI_0_IRQ
0137 );
0138 }
0139
0140 #ifdef __cplusplus
0141 }
0142 #endif
0143
0144 #endif