spi: Fix parameter types for spi functions
1. Use size_t instead of unsigned int for bytes_out and bytes_in. 2. Use const attribute for spi_slave structure passed into xfer, claim bus and release bus functions. BUG=chrome-os-partner:59832 BRANCH=None TEST=Compiles successfully Change-Id: Ie70b3520b51c42d750f907892545510c6058f85a Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://review.coreboot.org/17682 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
52896c6c33
commit
0dba0254ea
|
@ -48,8 +48,8 @@ static void spi_flash_addr(u32 addr, u8 *cmd)
|
|||
* FIXME: This really should be abstracted better, but that will
|
||||
* require overhauling the entire SPI infrastructure.
|
||||
*/
|
||||
static int do_spi_flash_cmd(struct spi_slave *spi, const void *dout,
|
||||
unsigned int bytes_out, void *din, unsigned int bytes_in)
|
||||
static int do_spi_flash_cmd(const struct spi_slave *spi, const void *dout,
|
||||
size_t bytes_out, void *din, size_t bytes_in)
|
||||
{
|
||||
int ret = 1;
|
||||
|
||||
|
|
|
@ -37,11 +37,11 @@
|
|||
/* SPI Interface descriptor used by the driver. */
|
||||
struct tpm_spi_if {
|
||||
struct spi_slave *slave;
|
||||
int (*cs_assert)(struct spi_slave *slave);
|
||||
void (*cs_deassert)(struct spi_slave *slave);
|
||||
int (*xfer)(struct spi_slave *slave, const void *dout,
|
||||
unsigned bytesout, void *din,
|
||||
unsigned bytesin);
|
||||
int (*cs_assert)(const struct spi_slave *slave);
|
||||
void (*cs_deassert)(const struct spi_slave *slave);
|
||||
int (*xfer)(const struct spi_slave *slave, const void *dout,
|
||||
size_t bytesout, void *din,
|
||||
size_t bytesin);
|
||||
};
|
||||
|
||||
/* Use the common SPI driver wrapper as the interface callbacks. */
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#define _SPI_GENERIC_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/* Controller-specific definitions: */
|
||||
|
||||
|
@ -67,7 +68,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs);
|
|||
* Returns: 0 if the bus was claimed successfully, or a negative value
|
||||
* if it wasn't.
|
||||
*/
|
||||
int spi_claim_bus(struct spi_slave *slave);
|
||||
int spi_claim_bus(const struct spi_slave *slave);
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* Release the SPI bus
|
||||
|
@ -78,7 +79,7 @@ int spi_claim_bus(struct spi_slave *slave);
|
|||
*
|
||||
* slave: The SPI slave
|
||||
*/
|
||||
void spi_release_bus(struct spi_slave *slave);
|
||||
void spi_release_bus(const struct spi_slave *slave);
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* SPI transfer
|
||||
|
@ -92,10 +93,8 @@ void spi_release_bus(struct spi_slave *slave);
|
|||
*
|
||||
* Returns: 0 on success, not 0 on failure
|
||||
*/
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout, unsigned int bytesout,
|
||||
void *din, unsigned int bytesin);
|
||||
|
||||
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout, size_t bytesout,
|
||||
void *din, size_t bytesin);
|
||||
|
||||
unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len);
|
||||
|
||||
|
@ -108,7 +107,7 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len);
|
|||
*
|
||||
* TODO: This function probably shouldn't be inlined.
|
||||
*/
|
||||
static inline int spi_w8r8(struct spi_slave *slave, unsigned char byte)
|
||||
static inline int spi_w8r8(const struct spi_slave *slave, unsigned char byte)
|
||||
{
|
||||
unsigned char dout[2];
|
||||
unsigned char din[2];
|
||||
|
|
|
@ -156,7 +156,7 @@ static int mspi_enable(struct qspi_priv *priv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
struct qspi_priv *priv = to_qspi_slave(slave);
|
||||
|
||||
|
@ -175,7 +175,7 @@ int spi_claim_bus(struct spi_slave *slave)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
struct qspi_priv *priv = to_qspi_slave(slave);
|
||||
|
||||
|
@ -189,8 +189,8 @@ void spi_release_bus(struct spi_slave *slave)
|
|||
#define RXRAM_8B(p, i) (REG_RD((p)->reg + MSPI_RXRAM_REG + \
|
||||
((((i) << 1) + 1) << 2)) & 0xff)
|
||||
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout, unsigned int bytesout,
|
||||
void *din, unsigned int bytesin)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout, size_t bytesout,
|
||||
void *din, size_t bytesin)
|
||||
{
|
||||
struct qspi_priv *priv = to_qspi_slave(slave);
|
||||
const u8 *tx = (const u8 *)dout;
|
||||
|
|
|
@ -60,7 +60,7 @@ static int wait_status(u32 reg, u32 shift)
|
|||
}
|
||||
|
||||
/* Transmitter function. Fills TX FIFO with data before enabling SPIM */
|
||||
static int transmitdata(struct spi_slave *slave, u8 *buffer, u32 size)
|
||||
static int transmitdata(const struct spi_slave *slave, u8 *buffer, u32 size)
|
||||
{
|
||||
u32 blocksize, base, write_data;
|
||||
int ret;
|
||||
|
@ -97,7 +97,7 @@ static int transmitdata(struct spi_slave *slave, u8 *buffer, u32 size)
|
|||
}
|
||||
|
||||
/* Receiver function */
|
||||
static int receivedata(struct spi_slave *slave, u8 *buffer, u32 size)
|
||||
static int receivedata(const struct spi_slave *slave, u8 *buffer, u32 size)
|
||||
{
|
||||
u32 read_data, base;
|
||||
int ret;
|
||||
|
@ -141,7 +141,7 @@ static int receivedata(struct spi_slave *slave, u8 *buffer, u32 size)
|
|||
}
|
||||
|
||||
/* Sets port parameters in port state register. */
|
||||
static void setparams(struct spi_slave *slave, u32 port,
|
||||
static void setparams(const struct spi_slave *slave, u32 port,
|
||||
struct spim_device_parameters *params)
|
||||
{
|
||||
u32 spim_parameters, port_state, base;
|
||||
|
@ -247,7 +247,7 @@ static u32 control_reg_setup(struct spim_buffer *first,
|
|||
}
|
||||
|
||||
/* Checks the given buffer information */
|
||||
static int check_buffers(struct spi_slave *slave, struct spim_buffer *first,
|
||||
static int check_buffers(const struct spi_slave *slave, struct spim_buffer *first,
|
||||
struct spim_buffer *second){
|
||||
|
||||
if (!(container_of(slave, struct img_spi_slave, slave)->initialised))
|
||||
|
@ -325,7 +325,7 @@ static int check_device_params(struct spim_device_parameters *pdev_param)
|
|||
}
|
||||
|
||||
/* Function that carries out read/write operations */
|
||||
static int spim_io(struct spi_slave *slave, struct spim_buffer *first,
|
||||
static int spim_io(const struct spi_slave *slave, struct spim_buffer *first,
|
||||
struct spim_buffer *second)
|
||||
{
|
||||
u32 reg, base;
|
||||
|
@ -459,7 +459,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs)
|
|||
}
|
||||
|
||||
/* Claim the bus and prepare it for communication */
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
int ret;
|
||||
struct img_spi_slave *img_slave;
|
||||
|
@ -490,7 +490,7 @@ int spi_claim_bus(struct spi_slave *slave)
|
|||
}
|
||||
|
||||
/* Release the SPI bus */
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
struct img_spi_slave *img_slave;
|
||||
|
||||
|
@ -508,8 +508,8 @@ void spi_release_bus(struct spi_slave *slave)
|
|||
}
|
||||
|
||||
/* SPI transfer */
|
||||
static int do_spi_xfer(struct spi_slave *slave, const void *dout,
|
||||
unsigned int bytesout, void *din, unsigned int bytesin)
|
||||
static int do_spi_xfer(const struct spi_slave *slave, const void *dout,
|
||||
size_t bytesout, void *din, size_t bytesin)
|
||||
{
|
||||
struct spim_buffer buff_0;
|
||||
struct spim_buffer buff_1;
|
||||
|
@ -532,8 +532,8 @@ static int do_spi_xfer(struct spi_slave *slave, const void *dout,
|
|||
return spim_io(slave, &buff_0, (dout && din) ? &buff_1 : NULL);
|
||||
}
|
||||
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout, unsigned int bytesout,
|
||||
void *din, unsigned int bytesin)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout, size_t bytesout,
|
||||
void *din, size_t bytesin)
|
||||
{
|
||||
unsigned int in_sz, out_sz;
|
||||
int ret;
|
||||
|
|
|
@ -184,8 +184,8 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
|
|||
return MIN(buf_len, SPIBAR_FDATA_FIFO_SIZE);
|
||||
}
|
||||
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout,
|
||||
unsigned int bytesout, void *din, unsigned int bytesin)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout,
|
||||
size_t bytesout, void *din, size_t bytesin)
|
||||
{
|
||||
printk(BIOS_DEBUG, "NOT IMPLEMENTED: %s() !!!\n", __func__);
|
||||
return E_NOT_IMPLEMENTED;
|
||||
|
@ -215,13 +215,13 @@ void spi_init(void)
|
|||
pci_write_config32(ctx->pci_dev, SPIBAR_BIOS_CONTROL, bios_ctl);
|
||||
}
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* There's nothing we need to to here. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* No magic needed here. */
|
||||
}
|
||||
|
|
|
@ -317,13 +317,13 @@ static void spi_init_cb(void *unused)
|
|||
|
||||
BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, spi_init_cb, NULL);
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Handled by ICH automatically. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Handled by ICH automatically. */
|
||||
}
|
||||
|
@ -489,8 +489,8 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
|
|||
return min(cntlr.databytes, buf_len);
|
||||
}
|
||||
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout,
|
||||
unsigned int bytesout, void *din, unsigned int bytesin)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout,
|
||||
size_t bytesout, void *din, size_t bytesin)
|
||||
{
|
||||
uint16_t control;
|
||||
int16_t opcode_index;
|
||||
|
|
|
@ -296,13 +296,13 @@ static void spi_init_cb(void *unused)
|
|||
|
||||
BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, spi_init_cb, NULL);
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Handled by ICH automatically. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Handled by ICH automatically. */
|
||||
}
|
||||
|
@ -470,8 +470,8 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
|
|||
return min(cntlr.databytes, buf_len);
|
||||
}
|
||||
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout,
|
||||
unsigned int bytesout, void *din, unsigned int bytesin)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout,
|
||||
size_t bytesout, void *din, size_t bytesin)
|
||||
{
|
||||
uint16_t control;
|
||||
int16_t opcode_index;
|
||||
|
|
|
@ -313,13 +313,13 @@ static void spi_init_cb(void *unused)
|
|||
|
||||
BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, spi_init_cb, NULL);
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Handled by ICH automatically. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Handled by ICH automatically. */
|
||||
}
|
||||
|
@ -485,8 +485,8 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
|
|||
return min(cntlr.databytes, buf_len);
|
||||
}
|
||||
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout,
|
||||
unsigned int bytesout, void *din, unsigned int bytesin)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout,
|
||||
size_t bytesout, void *din, size_t bytesin)
|
||||
{
|
||||
uint16_t control;
|
||||
int16_t opcode_index;
|
||||
|
|
|
@ -297,13 +297,13 @@ void spi_init(void)
|
|||
cntlr.preop = &ich9_spi->preop;
|
||||
}
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Handled by ICH automatically. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Handled by ICH automatically. */
|
||||
}
|
||||
|
@ -469,8 +469,8 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
|
|||
return min(cntlr.databytes, buf_len);
|
||||
}
|
||||
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout,
|
||||
unsigned int bytesout, void *din, unsigned int bytesin)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout,
|
||||
size_t bytesout, void *din, size_t bytesin)
|
||||
{
|
||||
uint16_t control;
|
||||
int16_t opcode_index;
|
||||
|
|
|
@ -312,13 +312,13 @@ void spi_init(void)
|
|||
pci_write_config_byte(dev, 0xdc, bios_cntl | 0x1);
|
||||
}
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Handled by ICH automatically. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Handled by ICH automatically. */
|
||||
}
|
||||
|
@ -484,8 +484,8 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
|
|||
return min(cntlr.databytes, buf_len);
|
||||
}
|
||||
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout,
|
||||
unsigned int bytesout, void *din, unsigned int bytesin)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout,
|
||||
size_t bytesout, void *din, size_t bytesin)
|
||||
{
|
||||
uint16_t control;
|
||||
int16_t opcode_index;
|
||||
|
|
|
@ -151,8 +151,8 @@ static size_t spi_get_flash_size(pch_spi_regs *spi_bar)
|
|||
return size;
|
||||
}
|
||||
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout,
|
||||
unsigned int bytesout, void *din, unsigned int bytesin)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout,
|
||||
size_t bytesout, void *din, size_t bytesin)
|
||||
{
|
||||
/* TODO: Define xfer for hardware sequencing. */
|
||||
return -1;
|
||||
|
@ -170,13 +170,13 @@ void spi_init(void)
|
|||
pci_write_config_byte(dev, SPIBAR_BIOS_CNTL, bios_cntl);
|
||||
}
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Handled by PCH automatically. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Handled by PCH automatically. */
|
||||
}
|
||||
|
|
|
@ -409,8 +409,8 @@ int mv_spi_8bit_data_tx_rx(unsigned char spi_id,
|
|||
return MV_OK;
|
||||
}
|
||||
|
||||
static int mrvl_spi_xfer(struct spi_slave *slave,
|
||||
unsigned int bitlen,
|
||||
static int mrvl_spi_xfer(const struct spi_slave *slave,
|
||||
size_t bitlen,
|
||||
const void *dout,
|
||||
void *din)
|
||||
{
|
||||
|
@ -454,14 +454,14 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs)
|
|||
return slave;
|
||||
}
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
mv_spi_cs_set(slave->bus, slave->cs);
|
||||
mv_spi_cs_assert(slave->bus);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
mv_spi_cs_deassert(slave->bus);
|
||||
}
|
||||
|
@ -471,11 +471,11 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
|
|||
return buf_len;
|
||||
}
|
||||
|
||||
int spi_xfer(struct spi_slave *slave,
|
||||
int spi_xfer(const struct spi_slave *slave,
|
||||
const void *dout,
|
||||
unsigned out_bytes,
|
||||
size_t out_bytes,
|
||||
void *din,
|
||||
unsigned in_bytes)
|
||||
size_t in_bytes)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
|
|
|
@ -20,17 +20,17 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
}
|
||||
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout,
|
||||
unsigned out_bytes, void *din, unsigned in_bytes)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout,
|
||||
size_t out_bytes, void *din, size_t in_bytes)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ static struct mtk_spi_bus spi_bus[1] = {
|
|||
}
|
||||
};
|
||||
|
||||
static inline struct mtk_spi_bus *to_mtk_spi(struct spi_slave *slave)
|
||||
static inline struct mtk_spi_bus *to_mtk_spi(const struct spi_slave *slave)
|
||||
{
|
||||
return container_of(slave, struct mtk_spi_bus, slave);
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs)
|
|||
};
|
||||
}
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
struct mtk_spi_bus *mtk_slave = to_mtk_spi(slave);
|
||||
struct mtk_spi_regs *regs = mtk_slave->regs;
|
||||
|
@ -193,8 +193,8 @@ int spi_claim_bus(struct spi_slave *slave)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mtk_spi_fifo_transfer(struct spi_slave *slave, void *in,
|
||||
const void *out, u32 size)
|
||||
static int mtk_spi_fifo_transfer(const struct spi_slave *slave, void *in,
|
||||
const void *out, size_t size)
|
||||
{
|
||||
struct mtk_spi_bus *mtk_slave = to_mtk_spi(slave);
|
||||
struct mtk_spi_regs *regs = mtk_slave->regs;
|
||||
|
@ -269,10 +269,10 @@ error:
|
|||
return -1;
|
||||
}
|
||||
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout, unsigned int bytes_out,
|
||||
void *din, unsigned int bytes_in)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout, size_t bytes_out,
|
||||
void *din, size_t bytes_in)
|
||||
{
|
||||
uint32_t min_size = 0;
|
||||
size_t min_size = 0;
|
||||
int ret;
|
||||
|
||||
while (bytes_out || bytes_in) {
|
||||
|
@ -301,7 +301,7 @@ int spi_xfer(struct spi_slave *slave, const void *dout, unsigned int bytes_out,
|
|||
return 0;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
struct mtk_spi_bus *mtk_slave = to_mtk_spi(slave);
|
||||
struct mtk_spi_regs *regs = mtk_slave->regs;
|
||||
|
|
|
@ -209,7 +209,7 @@ static unsigned int tegra_spi_speed(unsigned int bus)
|
|||
return 50000000;
|
||||
}
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
struct tegra_spi_regs *regs = to_tegra_spi(slave->bus)->regs;
|
||||
u32 val;
|
||||
|
@ -232,7 +232,7 @@ int spi_claim_bus(struct spi_slave *slave)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
struct tegra_spi_regs *regs = to_tegra_spi(slave->bus)->regs;
|
||||
u32 val;
|
||||
|
@ -719,13 +719,13 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
|
|||
return buf_len;
|
||||
}
|
||||
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout,
|
||||
unsigned int out_bytes, void *din, unsigned int in_bytes)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout,
|
||||
size_t out_bytes, void *din, size_t in_bytes)
|
||||
{
|
||||
struct tegra_spi_channel *spi = to_tegra_spi(slave->bus);
|
||||
u8 *out_buf = (u8 *)dout;
|
||||
u8 *in_buf = (u8 *)din;
|
||||
unsigned int todo;
|
||||
size_t todo;
|
||||
int ret = 0;
|
||||
|
||||
/* tegra bus numbers start at 1 */
|
||||
|
|
|
@ -208,7 +208,7 @@ static struct tegra_spi_channel * const to_tegra_spi(int bus) {
|
|||
return &tegra_spi_channels[bus - 1];
|
||||
}
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
struct tegra_spi_regs *regs = to_tegra_spi(slave->bus)->regs;
|
||||
u32 val;
|
||||
|
@ -231,7 +231,7 @@ int spi_claim_bus(struct spi_slave *slave)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
struct tegra_spi_regs *regs = to_tegra_spi(slave->bus)->regs;
|
||||
u32 val;
|
||||
|
@ -755,13 +755,13 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
|
|||
return buf_len;
|
||||
}
|
||||
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout,
|
||||
unsigned int out_bytes, void *din, unsigned int in_bytes)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout,
|
||||
size_t out_bytes, void *din, size_t in_bytes)
|
||||
{
|
||||
struct tegra_spi_channel *spi = to_tegra_spi(slave->bus);
|
||||
u8 *out_buf = (u8 *)dout;
|
||||
u8 *in_buf = (u8 *)din;
|
||||
unsigned int todo;
|
||||
size_t todo;
|
||||
int ret = 0;
|
||||
|
||||
/* tegra bus numbers start at 1 */
|
||||
|
@ -827,8 +827,8 @@ int spi_xfer(struct spi_slave *slave, const void *dout,
|
|||
|
||||
if (ret < 0) {
|
||||
printk(BIOS_ERR, "%s: Error detected\n", __func__);
|
||||
printk(BIOS_ERR, "Transaction size: %u, bytes remaining: "
|
||||
"%u out / %u in\n", todo, out_bytes, in_bytes);
|
||||
printk(BIOS_ERR, "Transaction size: %zu, bytes remaining: "
|
||||
"%zu out / %zu in\n", todo, out_bytes, in_bytes);
|
||||
clear_fifo_status(spi);
|
||||
}
|
||||
return ret;
|
||||
|
|
|
@ -186,7 +186,7 @@ struct ipq_spi_slave {
|
|||
int allocated;
|
||||
};
|
||||
|
||||
static inline struct ipq_spi_slave *to_ipq_spi(struct spi_slave *slave)
|
||||
static inline struct ipq_spi_slave *to_ipq_spi(const struct spi_slave *slave)
|
||||
{
|
||||
return container_of(slave, struct ipq_spi_slave, slave);
|
||||
}
|
||||
|
|
|
@ -320,7 +320,7 @@ static int spi_hw_init(struct ipq_spi_slave *ds)
|
|||
return SUCCESS;
|
||||
}
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
struct ipq_spi_slave *ds = to_ipq_spi(slave);
|
||||
unsigned int ret;
|
||||
|
@ -332,7 +332,7 @@ int spi_claim_bus(struct spi_slave *slave)
|
|||
return SUCCESS;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
struct ipq_spi_slave *ds = to_ipq_spi(slave);
|
||||
|
||||
|
@ -341,7 +341,7 @@ void spi_release_bus(struct spi_slave *slave)
|
|||
ds->initialized = 0;
|
||||
}
|
||||
|
||||
static void write_force_cs(struct spi_slave *slave, int assert)
|
||||
static void write_force_cs(const struct spi_slave *slave, int assert)
|
||||
{
|
||||
struct ipq_spi_slave *ds = to_ipq_spi(slave);
|
||||
|
||||
|
@ -633,8 +633,8 @@ static int blsp_spi_write(struct ipq_spi_slave *ds, u8 *cmd_buffer,
|
|||
* This function is invoked with either tx_buf or rx_buf.
|
||||
* Calling this function with both null does a chip select change.
|
||||
*/
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout,
|
||||
unsigned out_bytes, void *din, unsigned in_bytes)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout,
|
||||
size_t out_bytes, void *din, size_t in_bytes)
|
||||
{
|
||||
struct ipq_spi_slave *ds = to_ipq_spi(slave);
|
||||
u8 *txp = (u8 *)dout;
|
||||
|
|
|
@ -271,7 +271,7 @@ struct ipq_spi_slave {
|
|||
int allocated;
|
||||
};
|
||||
|
||||
static inline struct ipq_spi_slave *to_ipq_spi(struct spi_slave *slave)
|
||||
static inline struct ipq_spi_slave *to_ipq_spi(const struct spi_slave *slave)
|
||||
{
|
||||
return container_of(slave, struct ipq_spi_slave, slave);
|
||||
}
|
||||
|
|
|
@ -618,7 +618,7 @@ static int spi_hw_init(struct ipq_spi_slave *ds)
|
|||
return SUCCESS;
|
||||
}
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
struct ipq_spi_slave *ds = to_ipq_spi(slave);
|
||||
unsigned int ret;
|
||||
|
@ -641,7 +641,7 @@ int spi_claim_bus(struct spi_slave *slave)
|
|||
return SUCCESS;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
struct ipq_spi_slave *ds = to_ipq_spi(slave);
|
||||
|
||||
|
@ -711,8 +711,8 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
|
|||
return min(MAX_PACKET_COUNT, buf_len);
|
||||
}
|
||||
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout,
|
||||
unsigned out_bytes, void *din, unsigned in_bytes)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout,
|
||||
size_t out_bytes, void *din, size_t in_bytes)
|
||||
{
|
||||
int ret;
|
||||
struct ipq_spi_slave *ds = to_ipq_spi(slave);
|
||||
|
|
|
@ -68,7 +68,7 @@ static struct rockchip_spi_slave rockchip_spi_slaves[] = {
|
|||
#endif
|
||||
};
|
||||
|
||||
static struct rockchip_spi_slave *to_rockchip_spi(struct spi_slave *slave)
|
||||
static struct rockchip_spi_slave *to_rockchip_spi(const struct spi_slave *slave)
|
||||
{
|
||||
return container_of(slave, struct rockchip_spi_slave, slave);
|
||||
}
|
||||
|
@ -79,13 +79,13 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs)
|
|||
return &(rockchip_spi_slaves[bus].slave);
|
||||
}
|
||||
|
||||
static void spi_cs_activate(struct spi_slave *slave)
|
||||
static void spi_cs_activate(const struct spi_slave *slave)
|
||||
{
|
||||
struct rockchip_spi *regs = to_rockchip_spi(slave)->regs;
|
||||
setbits_le32(®s->ser, 1);
|
||||
}
|
||||
|
||||
static void spi_cs_deactivate(struct spi_slave *slave)
|
||||
static void spi_cs_deactivate(const struct spi_slave *slave)
|
||||
{
|
||||
struct rockchip_spi *regs = to_rockchip_spi(slave)->regs;
|
||||
clrbits_le32(®s->ser, 1);
|
||||
|
@ -157,13 +157,13 @@ void rockchip_spi_set_sample_delay(unsigned int bus, unsigned int delay_ns)
|
|||
rsd << SPI_RXDSD_OFFSET);
|
||||
}
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
spi_cs_activate(slave);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
spi_cs_deactivate(slave);
|
||||
}
|
||||
|
@ -203,11 +203,11 @@ static void set_transfer_mode(struct rockchip_spi *regs,
|
|||
|
||||
/* returns 0 to indicate success, <0 otherwise */
|
||||
static int do_xfer(struct rockchip_spi *regs, bool use_16bit, const void *dout,
|
||||
unsigned int *bytes_out, void *din, unsigned int *bytes_in)
|
||||
size_t *bytes_out, void *din, size_t *bytes_in)
|
||||
{
|
||||
uint8_t *in_buf = din;
|
||||
uint8_t *out_buf = (uint8_t *)dout;
|
||||
unsigned int min_xfer;
|
||||
size_t min_xfer;
|
||||
|
||||
if (*bytes_out == 0)
|
||||
min_xfer = *bytes_in;
|
||||
|
@ -268,8 +268,8 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
|
|||
return min(65535, buf_len);
|
||||
}
|
||||
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout,
|
||||
unsigned int bytes_out, void *din, unsigned int bytes_in)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout,
|
||||
size_t bytes_out, void *din, size_t bytes_in)
|
||||
{
|
||||
struct rockchip_spi *regs = to_rockchip_spi(slave)->regs;
|
||||
int ret = 0;
|
||||
|
@ -283,10 +283,10 @@ int spi_xfer(struct spi_slave *slave, const void *dout,
|
|||
* seems to work fine.
|
||||
*/
|
||||
while (bytes_out || bytes_in) {
|
||||
unsigned int in_now = MIN(bytes_in, 0xfffe);
|
||||
unsigned int out_now = MIN(bytes_out, 0xfffe);
|
||||
unsigned int in_rem, out_rem;
|
||||
unsigned int mask;
|
||||
size_t in_now = MIN(bytes_in, 0xfffe);
|
||||
size_t out_now = MIN(bytes_out, 0xfffe);
|
||||
size_t in_rem, out_rem;
|
||||
size_t mask;
|
||||
bool use_16bit;
|
||||
|
||||
rockchip_spi_enable_chip(regs, 0);
|
||||
|
@ -324,13 +324,13 @@ int spi_xfer(struct spi_slave *slave, const void *dout,
|
|||
break;
|
||||
|
||||
if (bytes_out) {
|
||||
unsigned int sent = out_now - out_rem;
|
||||
size_t sent = out_now - out_rem;
|
||||
bytes_out -= sent;
|
||||
dout += sent;
|
||||
}
|
||||
|
||||
if (bytes_in) {
|
||||
unsigned int received = in_now - in_rem;
|
||||
size_t received = in_now - in_rem;
|
||||
bytes_in -= received;
|
||||
din += received;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ static struct exynos_spi_slave exynos_spi_slaves[3] = {
|
|||
},
|
||||
};
|
||||
|
||||
static inline struct exynos_spi_slave *to_exynos_spi(struct spi_slave *slave)
|
||||
static inline struct exynos_spi_slave *to_exynos_spi(const struct spi_slave *slave)
|
||||
{
|
||||
return container_of(slave, struct exynos_spi_slave, slave);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs)
|
|||
return &eslave->slave;
|
||||
}
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
struct exynos_spi *regs = to_exynos_spi(slave)->regs;
|
||||
// TODO(hungte) Add some delay if too many transactions happen at once.
|
||||
|
@ -137,19 +137,19 @@ int spi_claim_bus(struct spi_slave *slave)
|
|||
}
|
||||
|
||||
static void spi_transfer(struct exynos_spi *regs, void *in, const void *out,
|
||||
u32 size)
|
||||
size_t size)
|
||||
{
|
||||
u8 *inb = in;
|
||||
const u8 *outb = out;
|
||||
|
||||
int width = (size % 4) ? 1 : 4;
|
||||
size_t width = (size % 4) ? 1 : 4;
|
||||
|
||||
while (size) {
|
||||
int packets = size / width;
|
||||
size_t packets = size / width;
|
||||
// The packet count field is 16 bits wide.
|
||||
packets = MIN(packets, (1 << 16) - 1);
|
||||
|
||||
int out_bytes, in_bytes;
|
||||
size_t out_bytes, in_bytes;
|
||||
out_bytes = in_bytes = packets * width;
|
||||
|
||||
spi_sw_reset(regs, width == 4);
|
||||
|
@ -188,13 +188,13 @@ static void spi_transfer(struct exynos_spi *regs, void *in, const void *out,
|
|||
}
|
||||
}
|
||||
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout, unsigned int bytes_out,
|
||||
void *din, unsigned int bytes_in)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout, size_t bytes_out,
|
||||
void *din, size_t bytes_in)
|
||||
{
|
||||
struct exynos_spi *regs = to_exynos_spi(slave)->regs;
|
||||
|
||||
if (bytes_out && bytes_in) {
|
||||
u32 min_size = MIN(bytes_out, bytes_in);
|
||||
size_t min_size = MIN(bytes_out, bytes_in);
|
||||
|
||||
spi_transfer(regs, din, dout, min_size);
|
||||
|
||||
|
@ -213,7 +213,7 @@ int spi_xfer(struct spi_slave *slave, const void *dout, unsigned int bytes_out,
|
|||
return 0;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
struct exynos_spi *regs = to_exynos_spi(slave)->regs;
|
||||
setbits_le32(®s->cs_reg, SPI_SLAVE_SIG_INACT);
|
||||
|
|
|
@ -90,13 +90,13 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
|
|||
return min(AMD_SB_SPI_TX_LEN - cmd_len, buf_len);
|
||||
}
|
||||
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout,
|
||||
unsigned int bytesout, void *din, unsigned int bytesin)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout,
|
||||
size_t bytesout, void *din, size_t bytesin)
|
||||
{
|
||||
/* First byte is cmd which can not being sent through FIFO. */
|
||||
u8 cmd = *(u8 *)dout++;
|
||||
u8 readoffby1;
|
||||
u8 count;
|
||||
size_t count;
|
||||
|
||||
bytesout--;
|
||||
|
||||
|
@ -147,13 +147,13 @@ int spi_xfer(struct spi_slave *slave, const void *dout,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Nothing is required. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Nothing is required. */
|
||||
}
|
||||
|
|
|
@ -59,14 +59,14 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
|
|||
return min(AMD_SB_SPI_TX_LEN - cmd_len, buf_len);
|
||||
}
|
||||
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout,
|
||||
unsigned int bytesout, void *din, unsigned int bytesin)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout,
|
||||
size_t bytesout, void *din, size_t bytesin)
|
||||
{
|
||||
/* First byte is cmd which can not being sent through FIFO. */
|
||||
u8 cmd = *(u8 *)dout++;
|
||||
u8 readoffby1;
|
||||
u8 readwrite;
|
||||
u8 count;
|
||||
size_t count;
|
||||
|
||||
bytesout--;
|
||||
|
||||
|
@ -138,13 +138,13 @@ static void ImcWakeup(void)
|
|||
WaitForEcLDN9MailboxCmdAck();
|
||||
}
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Nothing is required. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Nothing is required. */
|
||||
return;
|
||||
|
|
|
@ -65,13 +65,13 @@ static void execute_command(void)
|
|||
(read8((void *)(spibar+3)) & 0x80));
|
||||
}
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Handled internally by the SB700 */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Handled internally by the SB700 */
|
||||
}
|
||||
|
@ -89,14 +89,14 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs)
|
|||
return slave;
|
||||
}
|
||||
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout,
|
||||
unsigned int bytesout, void *din, unsigned int bytesin)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout,
|
||||
size_t bytesout, void *din, size_t bytesin)
|
||||
{
|
||||
/* First byte is cmd which cannot be sent through the FIFO. */
|
||||
u8 cmd = *(u8 *)dout++;
|
||||
u8 readoffby1;
|
||||
u8 readwrite;
|
||||
u8 count;
|
||||
size_t count;
|
||||
|
||||
uint32_t spibar = get_spi_bar();
|
||||
|
||||
|
|
|
@ -13,5 +13,5 @@
|
|||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave);
|
||||
void spi_release_bus(struct spi_slave *slave);
|
||||
int spi_claim_bus(const struct spi_slave *slave);
|
||||
void spi_release_bus(const struct spi_slave *slave);
|
||||
|
|
|
@ -357,13 +357,13 @@ static void spi_init_cb(void *unused)
|
|||
|
||||
BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_ENTRY, spi_init_cb, NULL);
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Handled by ICH automatically. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Handled by ICH automatically. */
|
||||
}
|
||||
|
@ -536,8 +536,8 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
|
|||
return min(cntlr.databytes, buf_len);
|
||||
}
|
||||
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout,
|
||||
unsigned int bytesout, void *din, unsigned int bytesin)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout,
|
||||
size_t bytesout, void *din, size_t bytesin)
|
||||
{
|
||||
uint16_t control;
|
||||
int16_t opcode_index;
|
||||
|
|
|
@ -429,13 +429,13 @@ void spi_init(void)
|
|||
}
|
||||
}
|
||||
|
||||
int spi_claim_bus(struct spi_slave *slave)
|
||||
int spi_claim_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Handled by ICH automatically. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void spi_release_bus(struct spi_slave *slave)
|
||||
void spi_release_bus(const struct spi_slave *slave)
|
||||
{
|
||||
/* Handled by ICH automatically. */
|
||||
}
|
||||
|
@ -601,8 +601,8 @@ unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
|
|||
return min(cntlr.databytes, buf_len);
|
||||
}
|
||||
|
||||
int spi_xfer(struct spi_slave *slave, const void *dout,
|
||||
unsigned int bytesout, void *din, unsigned int bytesin)
|
||||
int spi_xfer(const struct spi_slave *slave, const void *dout,
|
||||
size_t bytesout, void *din, size_t bytesin)
|
||||
{
|
||||
uint16_t control;
|
||||
int16_t opcode_index;
|
||||
|
|
Loading…
Reference in New Issue