ddk750_swi2c.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*******************************************************************
  2. *
  3. * Copyright (c) 2007 by Silicon Motion, Inc. (SMI)
  4. *
  5. * All rights are reserved. Reproduction or in part is prohibited
  6. * without the written consent of the copyright owner.
  7. *
  8. * swi2c.h --- SM750/SM718 DDK
  9. * This file contains the definitions for i2c using software
  10. * implementation.
  11. *
  12. *******************************************************************/
  13. #ifndef _SWI2C_H_
  14. #define _SWI2C_H_
  15. /* Default i2c CLK and Data GPIO. These are the default i2c pins */
  16. #define DEFAULT_I2C_SCL 30
  17. #define DEFAULT_I2C_SDA 31
  18. /*
  19. * This function initializes the i2c attributes and bus
  20. *
  21. * Parameters:
  22. * i2cClkGPIO - The GPIO pin to be used as i2c SCL
  23. * i2cDataGPIO - The GPIO pin to be used as i2c SDA
  24. *
  25. * Return Value:
  26. * -1 - Fail to initialize the i2c
  27. * 0 - Success
  28. */
  29. long sm750_sw_i2c_init(
  30. unsigned char clk_gpio,
  31. unsigned char data_gpio
  32. );
  33. /*
  34. * This function reads the slave device's register
  35. *
  36. * Parameters:
  37. * addr - i2c Slave device address which register
  38. * to be read from
  39. * reg - Slave device's register to be read
  40. *
  41. * Return Value:
  42. * Register value
  43. */
  44. unsigned char sm750_sw_i2c_read_reg(
  45. unsigned char addr,
  46. unsigned char reg
  47. );
  48. /*
  49. * This function writes a value to the slave device's register
  50. *
  51. * Parameters:
  52. * addr - i2c Slave device address which register
  53. * to be written
  54. * reg - Slave device's register to be written
  55. * data - Data to be written to the register
  56. *
  57. * Result:
  58. * 0 - Success
  59. * -1 - Fail
  60. */
  61. long sm750_sw_i2c_write_reg(
  62. unsigned char addr,
  63. unsigned char reg,
  64. unsigned char data
  65. );
  66. #endif /* _SWI2C_H_ */