RTEMS 6.1-rc5
Loading...
Searching...
No Matches
raspberrypi-spi.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
11/*
12 * Copyright (C) 2024 Ning Yang
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#ifndef LIBBSP_AARCH64_RASPBERRYPI_4_SPI_H
37#define LIBBSP_AARCH64_RASPBERRYPI_4_SPI_H
38
39#include <bsp/utility.h>
40#include <bsp/rpi-gpio.h>
41
42typedef struct
43{
44 uint32_t spics;
45#define RPI_SPICS_LEN_LONG BSP_BIT32(25)
46#define RPI_SPICS_DMA_LEN BSP_BIT32(24)
47#define RPI_SPICS_CSPOL2 BSP_BIT32(23)
48#define RPI_SPICS_CSPOL1 BSP_BIT32(22)
49#define RPI_SPICS_CSPOL0 BSP_BIT32(21)
50#define RPI_SPICS_RXF BSP_BIT32(20)
51#define RPI_SPICS_RXR BSP_BIT32(19)
52#define RPI_SPICS_TXD BSP_BIT32(18)
53#define RPI_SPICS_RXD BSP_BIT32(17)
54#define RPI_SPICS_DONE BSP_BIT32(16)
55#define RPI_SPICS_LEN BSP_BIT32(13)
56#define RPI_SPICS_REN BSP_BIT32(12)
57#define RPI_SPICS_ADCS BSP_BIT32(11)
58#define RPI_SPICS_INTR BSP_BIT32(10)
59#define RPI_SPICS_INTD BSP_BIT32(9)
60#define RPI_SPICS_DMAEN BSP_BIT32(8)
61#define RPI_SPICS_TA BSP_BIT32(7)
62#define RPI_SPICS_CSPOL BSP_BIT32(6)
63#define RPI_SPICS_CLEAR_TX BSP_BIT32(5)
64#define RPI_SPICS_CLEAR_RX BSP_BIT32(4)
65#define RPI_SPICS_CPOL BSP_BIT32(3)
66#define RPI_SPICS_CPHA BSP_BIT32(2)
67#define RPI_SPICS_CS(val) BSP_FLD32(val, 0, 1)
68#define RPI_SPICS_CS_SET(reg,val) BSP_FLD32SET(reg, val, 0, 1)
69 uint32_t spififo;
70#define RPI_SPIFIFO_DATA(val) BSP_FLD32(val, 0, 31)
71#define RPI_SPIFIFO_DATA_GET(reg) BSP_FLD32GET(reg, 0, 31)
72#define RPI_SPIFIFO_DATA_SET(reg, val) BSP_FLD32SET(reg, val, 0, 31)
73 uint32_t spiclk;
74#define RPI_SPICLK_CDIV(val) BSP_FLD32(val, 0, 15)
75#define RPI_SPICLK_CDIV_GET(reg) BSP_FLD32GET(reg, 0, 15)
76#define RPI_SPICLK_CDIV_SET(reg, val) BSP_FLD32SET(reg, val, 0, 15)
77 uint32_t spidlen;
78#define RPI_SPIDLEN_LEN(val) BSP_FLD32(val, 0, 15)
79#define RPI_SPIDLEN_LEN_GET(reg) BSP_FLD32GET(reg, 0, 15)
80#define RPI_SPIDLEN_LEN_SET(reg, val) BSP_FLD32SET(reg, val, 0, 15)
81 uint32_t spiltoh;
82#define RPI_SPILTOH_TOH(val) BSP_FLD32(val, 0, 3)
83#define RPI_SPILTOH_TOH_GET(reg) BSP_FLD32GET(reg, 0, 3)
84#define RPI_SPILTOH_TOH_SET(reg, val) BSP_FLD32SET(reg, val, 0, 3)
85 uint32_t spidc;
86#define RPI_SPIDC_RPANIC(val) BSP_FLD32(val, 24, 31)
87#define RPI_SPIDC_RPANIC_GET(reg) BSP_FLD32GET(reg, 24, 31)
88#define RPI_SPIDC_RPANIC_SET(reg, val) BSP_FLD32SET(reg, val, 24, 31)
89#define RPI_SPIDC_RDREQ(val) BSP_FLD32(val, 16, 23)
90#define RPI_SPIDC_RDREQ_GET(reg) BSP_FLD32GET(reg, 16, 23)
91#define RPI_SPIDC_RDREQ_SET(reg, val) BSP_FLD32SET(reg, val, 16, 23)
92#define RPI_SPIDC_TPANIC(val) BSP_FLD32(val, 8, 15)
93#define RPI_SPIDC_TPANIC_GET(reg) BSP_FLD32GET(reg, 8, 15)
94#define RPI_SPIDC_TPANIC_SET(reg, val) BSP_FLD32SET(reg, val, 8, 15)
95#define RPI_SPIDC_TDREQ(val) BSP_FLD32(val, 0, 7)
96#define RPI_SPIDC_TDREQ_GET(reg) BSP_FLD32GET(reg, 0, 7)
97#define RPI_SPIDC_TDREQ_SET(reg, val) BSP_FLD32SET(reg, val, 0, 7)
99
100typedef enum {
101 raspberrypi_SPI0,
102 raspberrypi_SPI3,
103 raspberrypi_SPI4,
104 raspberrypi_SPI5,
105 raspberrypi_SPI6
106} raspberrypi_spi_device;
107
120rtems_status_code raspberrypi_spi_init(raspberrypi_spi_device device);
121
122#endif /* LIBBSP_AARCH64_RASPBERRYPI_4_SPI_H */
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:85
This header file provides utility macros for BSPs.
rtems_status_code raspberrypi_spi_init(raspberrypi_spi_device device)
Register a spi device.
Definition: raspberrypi-spi.c:506
Definition: raspberrypi-spi.h:43