diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2022-03-27 20:57:01 +0200 |
---|---|---|
committer | David Bauer <mail@david-bauer.net> | 2022-10-14 23:15:12 +0200 |
commit | f7a43e46065609910bdd2fa6f97ffa1deeda222b (patch) | |
tree | 33730b5a09fee04e3d66b03917c40c5f2699258c /target/linux/mpc85xx/image/spi-loader/include/spi.h | |
parent | c1fcca50ba924fcb2b51a03a8dbf68c2fe7ae60c (diff) | |
download | upstream-f7a43e46065609910bdd2fa6f97ffa1deeda222b.tar.gz upstream-f7a43e46065609910bdd2fa6f97ffa1deeda222b.tar.bz2 upstream-f7a43e46065609910bdd2fa6f97ffa1deeda222b.zip |
mpc85xx: add SPI kernel loader for TP-Link TL-WDR4900 v1
Similar to the lzma-loader on our MIPS targets, the spi-loader acts as
a second-stage loader that will then load and start the actual kernel.
As the TL-WDR4900 uses SPI-NOR and the P1010 family does not have support
for memory mapping of this type of flash, this loader needs to contain a
basic driver for the FSL ESPI controller.
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
(cherry picked from commit a296055b82fbb20457273492069ce9d62009e2a1)
Diffstat (limited to 'target/linux/mpc85xx/image/spi-loader/include/spi.h')
-rw-r--r-- | target/linux/mpc85xx/image/spi-loader/include/spi.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/target/linux/mpc85xx/image/spi-loader/include/spi.h b/target/linux/mpc85xx/image/spi-loader/include/spi.h new file mode 100644 index 0000000000..98e799ccaf --- /dev/null +++ b/target/linux/mpc85xx/image/spi-loader/include/spi.h @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Common SPI Interface: Controller-specific definitions + * + * Copyright (c) 2022 Matthias Schiffer <mschiffer@universe-factory.net> + * + * Based on U-boot's spi.h: + * + * (C) Copyright 2001 + * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com. + */ + +#pragma once + +#include <types.h> + +/* SPI mode flags */ +#define SPI_CPHA BIT(0) /* clock phase (1 = SPI_CLOCK_PHASE_SECOND) */ +#define SPI_CPOL BIT(1) /* clock polarity (1 = SPI_POLARITY_HIGH) */ +#define SPI_MODE_0 (0|0) /* (original MicroWire) */ +#define SPI_MODE_1 (0|SPI_CPHA) +#define SPI_MODE_2 (SPI_CPOL|0) +#define SPI_MODE_3 (SPI_CPOL|SPI_CPHA) + +struct spi_transfer { + const void *tx_buf; + void *rx_buf; + size_t len; +}; + +static inline size_t spi_message_len(const struct spi_transfer *msg, int n) { + size_t total = 0; + for (int i = 0; i < n; i++) { + total += msg[i].len; + } + return total; +} + +int spi_init(unsigned int cs, unsigned int max_hz, unsigned int mode); +int spi_claim_bus(void); +void spi_release_bus(void); +int spi_xfer(const struct spi_transfer *msg, int n); +size_t spi_max_xfer(void); |