Nishad Kamdar | 90865a3 | 2019-08-03 19:43:35 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Pierre-Yves MORDRET | df8c847 | 2017-09-14 16:28:36 +0200 | [diff] [blame] | 2 | /* |
| 3 | * i2c-stm32.h |
| 4 | * |
| 5 | * Copyright (C) M'boumba Cedric Madianga 2017 |
Benjamin Gaignard | 9c41e45 | 2017-11-30 09:43:57 +0100 | [diff] [blame] | 6 | * Copyright (C) STMicroelectronics 2017 |
Pierre-Yves MORDRET | df8c847 | 2017-09-14 16:28:36 +0200 | [diff] [blame] | 7 | * Author: M'boumba Cedric Madianga <cedric.madianga@gmail.com> |
| 8 | * |
Pierre-Yves MORDRET | df8c847 | 2017-09-14 16:28:36 +0200 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #ifndef _I2C_STM32_H |
| 12 | #define _I2C_STM32_H |
| 13 | |
Pierre-Yves MORDRET | bb8822c | 2018-04-11 15:24:56 +0200 | [diff] [blame] | 14 | #include <linux/dma-direction.h> |
| 15 | #include <linux/dmaengine.h> |
| 16 | #include <linux/dma-mapping.h> |
| 17 | |
Pierre-Yves MORDRET | df8c847 | 2017-09-14 16:28:36 +0200 | [diff] [blame] | 18 | enum stm32_i2c_speed { |
| 19 | STM32_I2C_SPEED_STANDARD, /* 100 kHz */ |
| 20 | STM32_I2C_SPEED_FAST, /* 400 kHz */ |
| 21 | STM32_I2C_SPEED_FAST_PLUS, /* 1 MHz */ |
| 22 | STM32_I2C_SPEED_END, |
| 23 | }; |
| 24 | |
Pierre-Yves MORDRET | bb8822c | 2018-04-11 15:24:56 +0200 | [diff] [blame] | 25 | /** |
| 26 | * struct stm32_i2c_dma - DMA specific data |
| 27 | * @chan_tx: dma channel for TX transfer |
| 28 | * @chan_rx: dma channel for RX transfer |
| 29 | * @chan_using: dma channel used for the current transfer (TX or RX) |
| 30 | * @dma_buf: dma buffer |
| 31 | * @dma_len: dma buffer len |
| 32 | * @dma_transfer_dir: dma transfer direction indicator |
| 33 | * @dma_data_dir: dma transfer mode indicator |
| 34 | * @dma_complete: dma transfer completion |
| 35 | */ |
| 36 | struct stm32_i2c_dma { |
| 37 | struct dma_chan *chan_tx; |
| 38 | struct dma_chan *chan_rx; |
| 39 | struct dma_chan *chan_using; |
| 40 | dma_addr_t dma_buf; |
| 41 | unsigned int dma_len; |
| 42 | enum dma_transfer_direction dma_transfer_dir; |
| 43 | enum dma_data_direction dma_data_dir; |
| 44 | struct completion dma_complete; |
| 45 | }; |
| 46 | |
| 47 | struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev, |
| 48 | dma_addr_t phy_addr, |
| 49 | u32 txdr_offset, u32 rxdr_offset); |
| 50 | |
| 51 | void stm32_i2c_dma_free(struct stm32_i2c_dma *dma); |
| 52 | |
| 53 | int stm32_i2c_prep_dma_xfer(struct device *dev, struct stm32_i2c_dma *dma, |
| 54 | bool rd_wr, u32 len, u8 *buf, |
| 55 | dma_async_tx_callback callback, |
| 56 | void *dma_async_param); |
| 57 | |
Pierre-Yves MORDRET | df8c847 | 2017-09-14 16:28:36 +0200 | [diff] [blame] | 58 | #endif /* _I2C_STM32_H */ |