mc9sdz60.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * (C) Copyright 2010 Stefano Babic <sbabic@denx.de>
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  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. #include <config.h>
  23. #include <common.h>
  24. #include <asm/errno.h>
  25. #include <linux/types.h>
  26. #include <i2c.h>
  27. #include <mc9sdz60.h>
  28. #ifndef CONFIG_SYS_FSL_MC9SDZ60_I2C_ADDR
  29. #error "You have to configure I2C address for MC9SDZ60"
  30. #endif
  31. u8 mc9sdz60_reg_read(enum mc9sdz60_reg reg)
  32. {
  33. u8 val;
  34. if (i2c_read(CONFIG_SYS_FSL_MC9SDZ60_I2C_ADDR, reg, 1, &val, 1)) {
  35. puts("Error reading MC9SDZ60 register\n");
  36. return -1;
  37. }
  38. return val;
  39. }
  40. void mc9sdz60_reg_write(enum mc9sdz60_reg reg, u8 val)
  41. {
  42. i2c_write(CONFIG_SYS_FSL_MC9SDZ60_I2C_ADDR, reg, 1, &val, 1);
  43. }