1 /*
2  * Copyright (c) 2013 Corey Tabaka
3  *
4  * Use of this source code is governed by a MIT-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/MIT
7  */
8 #pragma once
9 
10 #include <lk/compiler.h>
11 #include <dev/driver.h>
12 
13 /* spi transaction flags */
14 enum spi_flags {
15     SPI_READ        = (1<<0),
16     SPI_WRITE       = (1<<1),
17     SPI_CS_ASSERT   = (1<<2),
18     SPI_CS_DEASSERT = (1<<3),
19 };
20 
21 /* spi transaction */
22 struct spi_transaction {
23     enum spi_flags flags;
24     void *tx_buf;
25     void *rx_buf;
26     size_t len;
27 };
28 
29 /* spi interface */
30 struct spi_ops {
31     struct driver_ops std;
32 
33     ssize_t (*transaction)(struct device *dev, struct spi_transaction *txn, size_t count);
34 };
35 
36 __BEGIN_CDECLS
37 
38 ssize_t class_spi_transaction(struct device *dev, struct spi_transaction *txn, size_t count);
39 
40 __END_CDECLS
41 
42