dev_i2c_dm.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-11-26 GuEe-GUI first version
  9. */
  10. #ifndef __DEV_I2C_DM_H__
  11. #define __DEV_I2C_DM_H__
  12. #include <rthw.h>
  13. #include <rtthread.h>
  14. #include <drivers/core/bus.h>
  15. /* I2C Frequency Modes */
  16. #define I2C_MAX_STANDARD_MODE_FREQ 100000
  17. #define I2C_MAX_FAST_MODE_FREQ 400000
  18. #define I2C_MAX_FAST_MODE_PLUS_FREQ 1000000
  19. #define I2C_MAX_TURBO_MODE_FREQ 1400000
  20. #define I2C_MAX_HIGH_SPEED_MODE_FREQ 3400000
  21. #define I2C_MAX_ULTRA_FAST_MODE_FREQ 5000000
  22. struct i2c_timings
  23. {
  24. rt_uint32_t bus_freq_hz; /* the bus frequency in Hz */
  25. rt_uint32_t scl_rise_ns; /* time SCL signal takes to rise in ns; t(r) in the I2C specification */
  26. rt_uint32_t scl_fall_ns; /* time SCL signal takes to fall in ns; t(f) in the I2C specification */
  27. rt_uint32_t scl_int_delay_ns; /* time IP core additionally needs to setup SCL in ns */
  28. rt_uint32_t sda_fall_ns; /* time SDA signal takes to fall in ns; t(f) in the I2C specification */
  29. rt_uint32_t sda_hold_ns; /* time IP core additionally needs to hold SDA in ns */
  30. rt_uint32_t digital_filter_width_ns; /* width in ns of spikes on i2c lines that the IP core digital filter can filter out */
  31. rt_uint32_t analog_filter_cutoff_freq_hz; /* threshold frequency for the low pass IP core analog filter */
  32. };
  33. #ifdef RT_USING_OFW
  34. rt_err_t i2c_timings_ofw_parse(struct rt_ofw_node *dev_np, struct i2c_timings *timings,
  35. rt_bool_t use_defaults);
  36. #else
  37. rt_inline rt_err_t i2c_timings_ofw_parse(struct rt_ofw_node *dev_np, struct i2c_timings *timings,
  38. rt_bool_t use_defaults)
  39. {
  40. return RT_EOK;
  41. }
  42. #endif /* RT_USING_OFW */
  43. void i2c_bus_scan_clients(struct rt_i2c_bus_device *bus);
  44. #endif /* __DEV_I2C_DM_H__ */