core.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * DA9150 MFD Driver - Core Data
  3. *
  4. * Copyright (c) 2014 Dialog Semiconductor
  5. *
  6. * Author: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. */
  13. #ifndef __DA9150_CORE_H
  14. #define __DA9150_CORE_H
  15. #include <linux/device.h>
  16. #include <linux/i2c.h>
  17. #include <linux/interrupt.h>
  18. #include <linux/regmap.h>
  19. /* I2C address paging */
  20. #define DA9150_REG_PAGE_SHIFT 8
  21. #define DA9150_REG_PAGE_MASK 0xFF
  22. /* IRQs */
  23. #define DA9150_NUM_IRQ_REGS 4
  24. #define DA9150_IRQ_VBUS 0
  25. #define DA9150_IRQ_CHG 1
  26. #define DA9150_IRQ_TCLASS 2
  27. #define DA9150_IRQ_TJUNC 3
  28. #define DA9150_IRQ_VFAULT 4
  29. #define DA9150_IRQ_CONF 5
  30. #define DA9150_IRQ_DAT 6
  31. #define DA9150_IRQ_DTYPE 7
  32. #define DA9150_IRQ_ID 8
  33. #define DA9150_IRQ_ADP 9
  34. #define DA9150_IRQ_SESS_END 10
  35. #define DA9150_IRQ_SESS_VLD 11
  36. #define DA9150_IRQ_FG 12
  37. #define DA9150_IRQ_GP 13
  38. #define DA9150_IRQ_TBAT 14
  39. #define DA9150_IRQ_GPIOA 15
  40. #define DA9150_IRQ_GPIOB 16
  41. #define DA9150_IRQ_GPIOC 17
  42. #define DA9150_IRQ_GPIOD 18
  43. #define DA9150_IRQ_GPADC 19
  44. #define DA9150_IRQ_WKUP 20
  45. /* I2C sub-device address */
  46. #define DA9150_QIF_I2C_ADDR_LSB 0x5
  47. struct da9150_fg_pdata {
  48. u32 update_interval; /* msecs */
  49. u8 warn_soc_lvl; /* % value */
  50. u8 crit_soc_lvl; /* % value */
  51. };
  52. struct da9150_pdata {
  53. int irq_base;
  54. struct da9150_fg_pdata *fg_pdata;
  55. };
  56. struct da9150 {
  57. struct device *dev;
  58. struct regmap *regmap;
  59. struct i2c_client *core_qif;
  60. struct regmap_irq_chip_data *regmap_irq_data;
  61. int irq;
  62. int irq_base;
  63. };
  64. /* Device I/O - Query Interface for FG and standard register access */
  65. void da9150_read_qif(struct da9150 *da9150, u8 addr, int count, u8 *buf);
  66. void da9150_write_qif(struct da9150 *da9150, u8 addr, int count, const u8 *buf);
  67. u8 da9150_reg_read(struct da9150 *da9150, u16 reg);
  68. void da9150_reg_write(struct da9150 *da9150, u16 reg, u8 val);
  69. void da9150_set_bits(struct da9150 *da9150, u16 reg, u8 mask, u8 val);
  70. void da9150_bulk_read(struct da9150 *da9150, u16 reg, int count, u8 *buf);
  71. void da9150_bulk_write(struct da9150 *da9150, u16 reg, int count, const u8 *buf);
  72. #endif /* __DA9150_CORE_H */