1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/pkg/devices/lib/spi/include/spi-x1600.h Fri Jun 07 16:12:32 2024 +0200
1.3 @@ -0,0 +1,94 @@
1.4 +/*
1.5 + * Perform SPI communication using the X1600 SPI peripheral.
1.6 + *
1.7 + * Copyright (C) 2023, 2024 Paul Boddie <paul@boddie.org.uk>
1.8 + *
1.9 + * This program is free software; you can redistribute it and/or
1.10 + * modify it under the terms of the GNU General Public License as
1.11 + * published by the Free Software Foundation; either version 2 of
1.12 + * the License, or (at your option) any later version.
1.13 + *
1.14 + * This program is distributed in the hope that it will be useful,
1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.17 + * GNU General Public License for more details.
1.18 + *
1.19 + * You should have received a copy of the GNU General Public License
1.20 + * along with this program; if not, write to the Free Software
1.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
1.22 + * Boston, MA 02110-1301, USA
1.23 + */
1.24 +
1.25 +#pragma once
1.26 +
1.27 +#include <l4/re/c/dma_space.h>
1.28 +#include <l4/sys/types.h>
1.29 +#include <stdint.h>
1.30 +
1.31 +
1.32 +
1.33 +#ifdef __cplusplus
1.34 +
1.35 +#include <l4/devices/dma-x1600.h>
1.36 +#include <l4/devices/spi-common.h>
1.37 +
1.38 +/* SPI peripheral channel. */
1.39 +
1.40 +class Spi_x1600_channel : public Spi_channel
1.41 +{
1.42 +public:
1.43 + explicit Spi_x1600_channel(l4_addr_t spi_start, l4_addr_t start,
1.44 + enum Clock_identifiers clock,
1.45 + Cpm_chip *cpm,
1.46 + Dma_channel *dma,
1.47 + enum Dma_x1600_request_type request_type,
1.48 + uint64_t frequency);
1.49 +};
1.50 +
1.51 +/* SPI peripheral. */
1.52 +
1.53 +class Spi_x1600_chip : public Spi_chip
1.54 +{
1.55 +protected:
1.56 + unsigned int num_channels()
1.57 + { return 1; }
1.58 +
1.59 + Spi_channel *_get_channel(uint8_t channel, Dma_channel *dma,
1.60 + uint64_t frequency);
1.61 +
1.62 +public:
1.63 + explicit Spi_x1600_chip(l4_addr_t spi_start, l4_addr_t start, l4_addr_t end, Cpm_chip *cpm);
1.64 +};
1.65 +
1.66 +#endif /* __cplusplus */
1.67 +
1.68 +
1.69 +
1.70 +/* C language interface. */
1.71 +
1.72 +EXTERN_C_BEGIN
1.73 +
1.74 +void *x1600_spi_init(l4_addr_t spi_start, l4_addr_t start, l4_addr_t end,
1.75 + void *cpm);
1.76 +
1.77 +void *x1600_spi_get_channel(void *spi, uint8_t channel, void *dma, uint64_t frequency);
1.78 +
1.79 +uint32_t x1600_spi_send(void *channel, uint32_t bytes, const uint8_t data[]);
1.80 +
1.81 +uint32_t x1600_spi_send_dc(void *channel, uint32_t bytes, const uint8_t data[],
1.82 + const int dc[], uint8_t char_size, int big_endian);
1.83 +
1.84 +uint32_t x1600_spi_send_units(void *channel, uint32_t bytes, const uint8_t data[],
1.85 + uint8_t unit_size, uint8_t char_size, int big_endian);
1.86 +
1.87 +uint32_t x1600_spi_transfer(void *channel, l4_addr_t vaddr,
1.88 + l4re_dma_space_dma_addr_t paddr, uint32_t count,
1.89 + uint8_t unit_size, uint8_t char_size);
1.90 +
1.91 +uint32_t x1600_spi_transfer_descriptor(void *channel, l4_addr_t vaddr,
1.92 + l4re_dma_space_dma_addr_t paddr,
1.93 + uint32_t count, uint8_t unit_size,
1.94 + uint8_t char_size, l4_addr_t desc_vaddr,
1.95 + l4re_dma_space_dma_addr_t desc_paddr);
1.96 +
1.97 +EXTERN_C_END