mc9sdz60.c 662 B

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