mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-19 11:18:28 +00:00
5753d09b10
Current implementation only supports 8 bit word lengths, even though omap3 can handle anything between 4 and 32. Update the spi interface to support changing the SPI word length, and implement it in omap3_spi driver to support the full range of possible word lengths. This implementation is backwards compatible by defaulting to the old behavior of 8 bit word lengths. Also, it required a change to the omap3_spi non static I/O functions, but since they are not used anywhere else, no collateral changes are required. Cc: Tom Rini <trini@ti.com> Cc: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com> Cc: Igor Grinberg <grinberg@compulab.co.il> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
39 lines
696 B
C
39 lines
696 B
C
/*
|
|
* Copyright (c) 2011 The Chromium OS Authors.
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0+
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <malloc.h>
|
|
#include <spi.h>
|
|
|
|
int spi_set_wordlen(struct spi_slave *slave, unsigned int wordlen)
|
|
{
|
|
if (wordlen == 0 || wordlen > 32) {
|
|
printf("spi: invalid wordlen %d\n", wordlen);
|
|
return -1;
|
|
}
|
|
|
|
slave->wordlen = wordlen;
|
|
|
|
return 0;
|
|
}
|
|
|
|
void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
|
|
unsigned int cs)
|
|
{
|
|
struct spi_slave *slave;
|
|
void *ptr;
|
|
|
|
ptr = malloc(size);
|
|
if (ptr) {
|
|
memset(ptr, '\0', size);
|
|
slave = (struct spi_slave *)(ptr + offset);
|
|
slave->bus = bus;
|
|
slave->cs = cs;
|
|
slave->wordlen = SPI_DEFAULT_WORDLEN;
|
|
}
|
|
|
|
return ptr;
|
|
}
|