6b5bc77c9b
Stefan thinks they don't add value. Command used: sed -i -e '/file is part of /d' $(git grep "file is part of " |egrep ":( */\*.*\*/\$|#|;#|-- | *\* )" | cut -d: -f1 |grep -v crossgcc |grep -v gcov | grep -v /elf.h |grep -v nvramtool) The exceptions are for: - crossgcc (patch file) - gcov (imported from gcc) - elf.h (imported from GNU's libc) - nvramtool (more complicated header) The removed lines are: - fmt.Fprintln(f, "/* This file is part of the coreboot project. */") -# This file is part of a set of unofficial pre-commit hooks available -/* This file is part of coreboot */ -# This file is part of msrtool. -/* This file is part of msrtool. */ - * This file is part of ncurses, designed to be appended after curses.h.in -/* This file is part of pgtblgen. */ - * This file is part of the coreboot project. - /* This file is part of the coreboot project. */ -# This file is part of the coreboot project. -# This file is part of the coreboot project. -## This file is part of the coreboot project. --- This file is part of the coreboot project. -/* This file is part of the coreboot project */ -/* This file is part of the coreboot project. */ -;## This file is part of the coreboot project. -# This file is part of the coreboot project. It originated in the - * This file is part of the coreinfo project. -## This file is part of the coreinfo project. - * This file is part of the depthcharge project. -/* This file is part of the depthcharge project. */ -/* This file is part of the ectool project. */ - * This file is part of the GNU C Library. - * This file is part of the libpayload project. -## This file is part of the libpayload project. -/* This file is part of the Linux kernel. */ -## This file is part of the superiotool project. -/* This file is part of the superiotool project */ -/* This file is part of uio_usbdebug */ Change-Id: I82d872b3b337388c93d5f5bf704e9ee9e53ab3a9 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/41194 Reviewed-by: HAOUAS Elyes <ehaouas@noos.fr> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
71 lines
1.7 KiB
C
71 lines
1.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
|
|
#include <console/console.h>
|
|
#include <delay.h>
|
|
#include <spi_bitbang.h>
|
|
|
|
/* Set to 1 to dump all SPI transfers to the UART. */
|
|
#define TRACE 0
|
|
/*
|
|
* In theory, this should work fine with 0 delay since the bus is fully clocked
|
|
* by the master and the slave just needs to follow clock transitions whenever
|
|
* they happen. We're not going to be "too fast" by bit-banging anyway. However,
|
|
* if something doesn't work right, try increasing this value to slow it down.
|
|
*/
|
|
#define HALF_CLOCK_US 0
|
|
|
|
int spi_bitbang_claim_bus(const struct spi_bitbang_ops *ops)
|
|
{
|
|
ops->set_cs(ops, 0);
|
|
return 0;
|
|
}
|
|
|
|
void spi_bitbang_release_bus(const struct spi_bitbang_ops *ops)
|
|
{
|
|
ops->set_cs(ops, 1);
|
|
}
|
|
|
|
/* Implements a CPOL=0, CPH=0, MSB first 8-bit controller. */
|
|
int spi_bitbang_xfer(const struct spi_bitbang_ops *ops, const void *dout,
|
|
size_t bytes_out, void *din, size_t bytes_in)
|
|
{
|
|
if (TRACE) {
|
|
if (bytes_in && bytes_out)
|
|
printk(BIOS_SPEW, "!");
|
|
else if (bytes_in)
|
|
printk(BIOS_SPEW, "<");
|
|
else if (bytes_out)
|
|
printk(BIOS_SPEW, ">");
|
|
}
|
|
|
|
while (bytes_out || bytes_in) {
|
|
int i;
|
|
uint8_t in_byte = 0, out_byte = 0;
|
|
if (bytes_out) {
|
|
out_byte = *(const uint8_t *)dout++;
|
|
bytes_out--;
|
|
if (TRACE)
|
|
printk(BIOS_SPEW, "%02x", out_byte);
|
|
}
|
|
for (i = 7; i >= 0; i--) {
|
|
ops->set_mosi(ops, !!(out_byte & (1 << i)));
|
|
if (HALF_CLOCK_US)
|
|
udelay(HALF_CLOCK_US);
|
|
ops->set_clk(ops, 1);
|
|
in_byte |= !!ops->get_miso(ops) << i;
|
|
if (HALF_CLOCK_US)
|
|
udelay(HALF_CLOCK_US);
|
|
ops->set_clk(ops, 0);
|
|
}
|
|
if (bytes_in) {
|
|
*(uint8_t *)din++ = in_byte;
|
|
bytes_in--;
|
|
if (TRACE)
|
|
printk(BIOS_SPEW, "%02x", in_byte);
|
|
}
|
|
}
|
|
|
|
if (TRACE)
|
|
printk(BIOS_SPEW, "\n");
|
|
return 0;
|
|
}
|