pmic.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (C) 2011 Samsung Electronics
  3. * Lukasz Majewski <l.majewski@samsung.com>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #ifndef __CORE_PMIC_H_
  24. #define __CORE_PMIC_H_
  25. enum { PMIC_I2C, PMIC_SPI, };
  26. enum { I2C_PMIC, I2C_NUM, };
  27. enum { PMIC_READ, PMIC_WRITE, };
  28. struct p_i2c {
  29. unsigned char addr;
  30. unsigned char *buf;
  31. unsigned char tx_num;
  32. };
  33. struct p_spi {
  34. unsigned int cs;
  35. unsigned int mode;
  36. unsigned int bitlen;
  37. unsigned int clk;
  38. unsigned int flags;
  39. u32 (*prepare_tx)(u32 reg, u32 *val, u32 write);
  40. };
  41. struct pmic {
  42. const char *name;
  43. unsigned char bus;
  44. unsigned char interface;
  45. unsigned char number_of_regs;
  46. union hw {
  47. struct p_i2c i2c;
  48. struct p_spi spi;
  49. } hw;
  50. };
  51. int pmic_init(void);
  52. int check_reg(u32 reg);
  53. struct pmic *get_pmic(void);
  54. int pmic_probe(struct pmic *p);
  55. int pmic_reg_read(struct pmic *p, u32 reg, u32 *val);
  56. int pmic_reg_write(struct pmic *p, u32 reg, u32 val);
  57. int pmic_set_output(struct pmic *p, u32 reg, int ldo, int on);
  58. #define pmic_i2c_addr (p->hw.i2c.addr)
  59. #define pmic_i2c_tx_num (p->hw.i2c.tx_num)
  60. #define pmic_spi_bitlen (p->hw.spi.bitlen)
  61. #define pmic_spi_flags (p->hw.spi.flags)
  62. #endif /* __CORE_PMIC_H_ */