i2c-stm32.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * i2c-stm32.h
  4. *
  5. * Copyright (C) M'boumba Cedric Madianga 2017
  6. * Copyright (C) STMicroelectronics 2017
  7. * Author: M'boumba Cedric Madianga <[email protected]>
  8. *
  9. */
  10. #ifndef _I2C_STM32_H
  11. #define _I2C_STM32_H
  12. #include <linux/dma-direction.h>
  13. #include <linux/dmaengine.h>
  14. #include <linux/dma-mapping.h>
  15. enum stm32_i2c_speed {
  16. STM32_I2C_SPEED_STANDARD, /* 100 kHz */
  17. STM32_I2C_SPEED_FAST, /* 400 kHz */
  18. STM32_I2C_SPEED_FAST_PLUS, /* 1 MHz */
  19. STM32_I2C_SPEED_END,
  20. };
  21. /**
  22. * struct stm32_i2c_dma - DMA specific data
  23. * @chan_tx: dma channel for TX transfer
  24. * @chan_rx: dma channel for RX transfer
  25. * @chan_using: dma channel used for the current transfer (TX or RX)
  26. * @dma_buf: dma buffer
  27. * @dma_len: dma buffer len
  28. * @dma_transfer_dir: dma transfer direction indicator
  29. * @dma_data_dir: dma transfer mode indicator
  30. * @dma_complete: dma transfer completion
  31. */
  32. struct stm32_i2c_dma {
  33. struct dma_chan *chan_tx;
  34. struct dma_chan *chan_rx;
  35. struct dma_chan *chan_using;
  36. dma_addr_t dma_buf;
  37. unsigned int dma_len;
  38. enum dma_transfer_direction dma_transfer_dir;
  39. enum dma_data_direction dma_data_dir;
  40. struct completion dma_complete;
  41. };
  42. struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev,
  43. dma_addr_t phy_addr,
  44. u32 txdr_offset, u32 rxdr_offset);
  45. void stm32_i2c_dma_free(struct stm32_i2c_dma *dma);
  46. int stm32_i2c_prep_dma_xfer(struct device *dev, struct stm32_i2c_dma *dma,
  47. bool rd_wr, u32 len, u8 *buf,
  48. dma_async_tx_callback callback,
  49. void *dma_async_param);
  50. #endif /* _I2C_STM32_H */