mc9sdz60.c 659 B

12345678910111213141516171819202122232425262728293031323334
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2010 Stefano Babic <sbabic@denx.de>
  4. */
  5. #include <config.h>
  6. #include <common.h>
  7. #include <linux/errno.h>
  8. #include <linux/types.h>
  9. #include <i2c.h>
  10. #include <mc9sdz60.h>
  11. #ifndef CONFIG_SYS_FSL_MC9SDZ60_I2C_ADDR
  12. #error "You have to configure I2C address for MC9SDZ60"
  13. #endif
  14. u8 mc9sdz60_reg_read(enum mc9sdz60_reg reg)
  15. {
  16. u8 val;
  17. if (i2c_read(CONFIG_SYS_FSL_MC9SDZ60_I2C_ADDR, reg, 1, &val, 1)) {
  18. puts("Error reading MC9SDZ60 register\n");
  19. return -1;
  20. }
  21. return val;
  22. }
  23. void mc9sdz60_reg_write(enum mc9sdz60_reg reg, u8 val)
  24. {
  25. i2c_write(CONFIG_SYS_FSL_MC9SDZ60_I2C_ADDR, reg, 1, &val, 1);
  26. }