diff options
Diffstat (limited to 'firmware/target/arm/imx31/spi-imx31.h')
-rw-r--r-- | firmware/target/arm/imx31/spi-imx31.h | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/firmware/target/arm/imx31/spi-imx31.h b/firmware/target/arm/imx31/spi-imx31.h index cf536b646d..b5e31d46f2 100644 --- a/firmware/target/arm/imx31/spi-imx31.h +++ b/firmware/target/arm/imx31/spi-imx31.h | |||
@@ -61,29 +61,39 @@ struct spi_node | |||
61 | unsigned long periodreg; /* CSPI periodreg setup */ | 61 | unsigned long periodreg; /* CSPI periodreg setup */ |
62 | }; | 62 | }; |
63 | 63 | ||
64 | struct spi_transfer | 64 | struct spi_transfer_desc; |
65 | |||
66 | typedef void (*spi_transfer_cb_fn_type)(struct spi_transfer_desc *); | ||
67 | |||
68 | struct spi_transfer_desc | ||
65 | { | 69 | { |
66 | const void *txbuf; | 70 | const struct spi_node *node; /* node for this transfer */ |
67 | void *rxbuf; | 71 | const void *txbuf; /* buffer to transmit */ |
68 | int count; | 72 | void *rxbuf; /* buffer to receive */ |
73 | int count; /* number of elements */ | ||
74 | spi_transfer_cb_fn_type callback; /* function to call when done */ | ||
75 | struct spi_transfer_desc *next; /* next transfer queued, | ||
76 | spi layer sets this */ | ||
69 | }; | 77 | }; |
70 | 78 | ||
79 | /* NOTE: SPI updates the descrptor during the operation. Do not write | ||
80 | * to it until completion notification is received. If no callback is | ||
81 | * specified, the caller must find a way to ensure integrity. | ||
82 | * | ||
83 | * -1 will be written to 'count' if an error occurs, otherwise it will | ||
84 | * be zero when completed. | ||
85 | */ | ||
86 | |||
71 | /* One-time init of SPI driver */ | 87 | /* One-time init of SPI driver */ |
72 | void spi_init(void); | 88 | void spi_init(void); |
73 | 89 | ||
74 | /* Enable the specified module for the node */ | 90 | /* Enable the specified module for the node */ |
75 | void spi_enable_module(struct spi_node *node); | 91 | void spi_enable_module(const struct spi_node *node); |
76 | 92 | ||
77 | /* Disabled the specified module for the node */ | 93 | /* Disabled the specified module for the node */ |
78 | void spi_disable_module(struct spi_node *node); | 94 | void spi_disable_module(const struct spi_node *node); |
79 | |||
80 | /* Lock module mutex */ | ||
81 | void spi_lock(struct spi_node *node); | ||
82 | |||
83 | /* Unlock module mutex */ | ||
84 | void spi_unlock(struct spi_node *node); | ||
85 | 95 | ||
86 | /* Send and/or receive data on the specified node */ | 96 | /* Send and/or receive data on the specified node (asychronous) */ |
87 | int spi_transfer(struct spi_node *node, struct spi_transfer *trans); | 97 | bool spi_transfer(struct spi_transfer_desc *xfer); |
88 | 98 | ||
89 | #endif /* SPI_IMX31_H */ | 99 | #endif /* SPI_IMX31_H */ |