]> Git Repo - u-boot.git/blob - drivers/spi/spi.c
spi: spi-uclass: Read chipselect and restrict capabilities
[u-boot.git] / drivers / spi / spi.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (c) 2011 The Chromium OS Authors.
4  */
5
6 #include <fdtdec.h>
7 #include <malloc.h>
8 #include <spi.h>
9
10 int spi_set_wordlen(struct spi_slave *slave, unsigned int wordlen)
11 {
12         if (wordlen == 0 || wordlen > 32) {
13                 printf("spi: invalid wordlen %u\n", wordlen);
14                 return -1;
15         }
16
17         slave->wordlen = wordlen;
18
19         return 0;
20 }
21
22 void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
23                          unsigned int cs)
24 {
25         u8 *ptr;
26
27         ptr = malloc(size);
28         if (ptr) {
29                 struct spi_slave *slave;
30
31                 memset(ptr, '\0', size);
32                 slave = (struct spi_slave *)(ptr + offset);
33                 slave->bus = bus;
34                 slave->cs = cs;
35                 slave->wordlen = SPI_DEFAULT_WORDLEN;
36         }
37
38         return ptr;
39 }
This page took 0.025492 seconds and 4 git commands to generate.