tca642x.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright 2013 Texas Instruments, Inc.
  3. * Author: Dan Murphy <dmurphy@ti.com>
  4. *
  5. * Derived work from the pca953x.c driver
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #ifndef __TCA642X_H_
  23. #define __TCA642X_H_
  24. #ifdef CONFIG_CMD_TCA642X
  25. enum {
  26. TCA642X_CMD_INFO,
  27. TCA642X_CMD_DEVICE,
  28. TCA642X_CMD_OUTPUT,
  29. TCA642X_CMD_INPUT,
  30. TCA642X_CMD_INVERT,
  31. };
  32. #endif
  33. #define TCA642X_OUT_LOW 0
  34. #define TCA642X_OUT_HIGH 1
  35. #define TCA642X_POL_NORMAL 0
  36. #define TCA642X_POL_INVERT 1
  37. #define TCA642X_DIR_OUT 0
  38. #define TCA642X_DIR_IN 1
  39. /* Default to an address that hopefully won't corrupt other i2c devices */
  40. #ifndef CONFIG_SYS_I2C_TCA642X_ADDR
  41. #define CONFIG_SYS_I2C_TCA642X_ADDR (~0)
  42. #endif
  43. /* Default to an address that hopefully won't corrupt other i2c devices */
  44. #ifndef CONFIG_SYS_I2C_TCA642X_BUS_NUM
  45. #define CONFIG_SYS_I2C_TCA642X_BUS_NUM (0)
  46. #endif
  47. struct tca642x_bank_info {
  48. uint8_t input_reg;
  49. uint8_t output_reg;
  50. uint8_t polarity_reg;
  51. uint8_t configuration_reg;
  52. };
  53. int tca642x_set_val(uchar chip, uint8_t gpio_bank,
  54. uint8_t reg_bit, uint8_t data);
  55. int tca642x_set_pol(uchar chip, uint8_t gpio_bank,
  56. uint8_t reg_bit, uint8_t data);
  57. int tca642x_set_dir(uchar chip, uint8_t gpio_bank,
  58. uint8_t reg_bit, uint8_t data);
  59. int tca642x_get_val(uchar chip, uint8_t gpio_bank);
  60. int tca642x_set_inital_state(uchar chip, struct tca642x_bank_info init_data[]);
  61. #endif /* __TCA642X_H_ */