core.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * core.h
  3. *
  4. * copyright (c) 2011 Samsung Electronics Co., Ltd
  5. * http://www.samsung.com
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. *
  12. */
  13. #ifndef __LINUX_MFD_SEC_CORE_H
  14. #define __LINUX_MFD_SEC_CORE_H
  15. #define NUM_IRQ_REGS 4
  16. enum sec_device_type {
  17. S5M8751X,
  18. S5M8763X,
  19. S5M8767X,
  20. };
  21. /**
  22. * struct sec_pmic_dev - s5m87xx master device for sub-drivers
  23. * @dev: master device of the chip (can be used to access platform data)
  24. * @i2c: i2c client private data for regulator
  25. * @rtc: i2c client private data for rtc
  26. * @iolock: mutex for serializing io access
  27. * @irqlock: mutex for buslock
  28. * @irq_base: base IRQ number for sec-pmic, required for IRQs
  29. * @irq: generic IRQ number for s5m87xx
  30. * @ono: power onoff IRQ number for s5m87xx
  31. * @irq_masks_cur: currently active value
  32. * @irq_masks_cache: cached hardware value
  33. * @type: indicate which s5m87xx "variant" is used
  34. */
  35. struct sec_pmic_dev {
  36. struct device *dev;
  37. struct regmap *regmap;
  38. struct i2c_client *i2c;
  39. struct i2c_client *rtc;
  40. struct mutex iolock;
  41. struct mutex irqlock;
  42. int device_type;
  43. int irq_base;
  44. int irq;
  45. int ono;
  46. u8 irq_masks_cur[NUM_IRQ_REGS];
  47. u8 irq_masks_cache[NUM_IRQ_REGS];
  48. int type;
  49. bool wakeup;
  50. };
  51. int sec_irq_init(struct sec_pmic_dev *sec_pmic);
  52. void sec_irq_exit(struct sec_pmic_dev *sec_pmic);
  53. int sec_irq_resume(struct sec_pmic_dev *sec_pmic);
  54. extern int sec_reg_read(struct sec_pmic_dev *sec_pmic, u8 reg, void *dest);
  55. extern int sec_bulk_read(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf);
  56. extern int sec_reg_write(struct sec_pmic_dev *sec_pmic, u8 reg, u8 value);
  57. extern int sec_bulk_write(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf);
  58. extern int sec_reg_update(struct sec_pmic_dev *sec_pmic, u8 reg, u8 val, u8 mask);
  59. struct sec_platform_data {
  60. struct sec_regulator_data *regulators;
  61. struct sec_opmode_data *opmode;
  62. int device_type;
  63. int num_regulators;
  64. int irq_base;
  65. int (*cfg_pmic_irq)(void);
  66. int ono;
  67. bool wakeup;
  68. bool buck_voltage_lock;
  69. int buck_gpios[3];
  70. int buck_ds[3];
  71. int buck2_voltage[8];
  72. bool buck2_gpiodvs;
  73. int buck3_voltage[8];
  74. bool buck3_gpiodvs;
  75. int buck4_voltage[8];
  76. bool buck4_gpiodvs;
  77. int buck_set1;
  78. int buck_set2;
  79. int buck_set3;
  80. int buck2_enable;
  81. int buck3_enable;
  82. int buck4_enable;
  83. int buck_default_idx;
  84. int buck2_default_idx;
  85. int buck3_default_idx;
  86. int buck4_default_idx;
  87. int buck_ramp_delay;
  88. bool buck2_ramp_enable;
  89. bool buck3_ramp_enable;
  90. bool buck4_ramp_enable;
  91. int buck2_init;
  92. int buck3_init;
  93. int buck4_init;
  94. };
  95. /**
  96. * sec_regulator_data - regulator data
  97. * @id: regulator id
  98. * @initdata: regulator init data (contraints, supplies, ...)
  99. */
  100. struct sec_regulator_data {
  101. int id;
  102. struct regulator_init_data *initdata;
  103. };
  104. /*
  105. * sec_opmode_data - regulator operation mode data
  106. * @id: regulator id
  107. * @mode: regulator operation mode
  108. */
  109. struct sec_opmode_data {
  110. int id;
  111. int mode;
  112. };
  113. /*
  114. * samsung regulator operation mode
  115. * SEC_OPMODE_OFF Regulator always OFF
  116. * SEC_OPMODE_ON Regulator always ON
  117. * SEC_OPMODE_LOWPOWER Regulator is on in low-power mode
  118. * SEC_OPMODE_SUSPEND Regulator is changed by PWREN pin
  119. * If PWREN is high, regulator is on
  120. * If PWREN is low, regulator is off
  121. */
  122. enum sec_opmode {
  123. SEC_OPMODE_OFF,
  124. SEC_OPMODE_ON,
  125. SEC_OPMODE_LOWPOWER,
  126. SEC_OPMODE_SUSPEND,
  127. };
  128. #endif /* __LINUX_MFD_SEC_CORE_H */