2 * Copyright (c) 2011 The Chromium OS Authors.
4 * SPDX-License-Identifier: GPL-2.0+
12 int spi_set_wordlen(struct spi_slave *slave, unsigned int wordlen)
14 if (wordlen == 0 || wordlen > 32) {
15 printf("spi: invalid wordlen %u\n", wordlen);
19 slave->wordlen = wordlen;
24 void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
31 struct spi_slave *slave;
33 memset(ptr, '\0', size);
34 slave = (struct spi_slave *)(ptr + offset);
37 slave->wordlen = SPI_DEFAULT_WORDLEN;
44 struct spi_slave *spi_base_setup_slave_fdt(const void *blob, int busnum,
47 int cs, max_hz, mode = 0;
49 cs = fdtdec_get_int(blob, node, "reg", -1);
50 max_hz = fdtdec_get_int(blob, node, "spi-max-frequency", 100000);
51 if (fdtdec_get_bool(blob, node, "spi-cpol"))
53 if (fdtdec_get_bool(blob, node, "spi-cpha"))
55 if (fdtdec_get_bool(blob, node, "spi-cs-high"))
57 if (fdtdec_get_bool(blob, node, "spi-half-duplex"))
59 return spi_setup_slave(busnum, cs, max_hz, mode);