tegra124: re-factor tegra_spi_init()
This re-factors tegra_spi_init() to return a pointer to a channel struct. This allows the caller to modify configurable parameters (namely frame header). It's not exactly the most elegant interface, but it allows us to set device-specific parameters from mainboard-specific code and avoid making assumptions about board configuration in the SoC code. It also avoids adding function args that are meaningless most of the time. BUG=none BRANCH=none TEST=tested on nyan Signed-off-by: David Hendricks <dhendrix@chromium.org> Change-Id: Ibf7d315b54b1c23f19d7421713acb8d58b8e22c0 Reviewed-on: https://chromium-review.googlesource.com/174639 Reviewed-by: David Hendricks <dhendrix@chromium.org> Commit-Queue: David Hendricks <dhendrix@chromium.org> Tested-by: David Hendricks <dhendrix@chromium.org>
This commit is contained in:
parent
e24773eb94
commit
88354b9964
2 changed files with 18 additions and 17 deletions
|
|
@ -157,29 +157,30 @@ enum spi_direction {
|
|||
SPI_RECEIVE,
|
||||
};
|
||||
|
||||
void tegra_spi_init(unsigned int bus)
|
||||
struct tegra_spi_channel *tegra_spi_init(unsigned int bus)
|
||||
{
|
||||
int i;
|
||||
struct tegra_spi_channel *spi = NULL;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(tegra_spi_channels); i++) {
|
||||
struct tegra_spi_regs *regs;
|
||||
|
||||
if (tegra_spi_channels[i].slave.bus == bus)
|
||||
regs = tegra_spi_channels[i].regs;
|
||||
else
|
||||
continue;
|
||||
|
||||
/* software drives chip-select, set value to high */
|
||||
setbits_le32(®s->command1,
|
||||
SPI_CMD1_CS_SW_HW | SPI_CMD1_CS_SW_VAL);
|
||||
|
||||
/* 8-bit transfers, unpacked mode, most significant bit first */
|
||||
clrbits_le32(®s->command1,
|
||||
SPI_CMD1_BIT_LEN_MASK | SPI_CMD1_PACKED);
|
||||
setbits_le32(®s->command1, 7 << SPI_CMD1_BIT_LEN_SHIFT);
|
||||
if (tegra_spi_channels[i].slave.bus == bus) {
|
||||
spi = &tegra_spi_channels[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
printk(BIOS_INFO, "Tegra SPI bus %d initialized.\n", bus);
|
||||
if (!spi)
|
||||
return NULL;
|
||||
|
||||
/* software drives chip-select, set value to high */
|
||||
setbits_le32(&spi->regs->command1,
|
||||
SPI_CMD1_CS_SW_HW | SPI_CMD1_CS_SW_VAL);
|
||||
|
||||
/* 8-bit transfers, unpacked mode, most significant bit first */
|
||||
clrbits_le32(&spi->regs->command1,
|
||||
SPI_CMD1_BIT_LEN_MASK | SPI_CMD1_PACKED);
|
||||
setbits_le32(&spi->regs->command1, 7 << SPI_CMD1_BIT_LEN_SHIFT);
|
||||
|
||||
return spi;
|
||||
}
|
||||
|
||||
static struct tegra_spi_channel * const to_tegra_spi(int bus) {
|
||||
|
|
|
|||
|
|
@ -66,6 +66,6 @@ int initialize_tegra_spi_cbfs_media(struct cbfs_media *media,
|
|||
void *buffer_address,
|
||||
size_t buffer_size);
|
||||
|
||||
void tegra_spi_init(unsigned int bus);
|
||||
struct tegra_spi_channel *tegra_spi_init(unsigned int bus);
|
||||
|
||||
#endif /* __NVIDIA_TEGRA124_SPI_H__ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue