core.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. S2MPS11X,
  21. };
  22. /**
  23. * struct sec_pmic_dev - s5m87xx master device for sub-drivers
  24. * @dev: master device of the chip (can be used to access platform data)
  25. * @i2c: i2c client private data for regulator
  26. * @rtc: i2c client private data for rtc
  27. * @iolock: mutex for serializing io access
  28. * @irqlock: mutex for buslock
  29. * @irq_base: base IRQ number for sec-pmic, required for IRQs
  30. * @irq: generic IRQ number for s5m87xx
  31. * @ono: power onoff IRQ number for s5m87xx
  32. * @irq_masks_cur: currently active value
  33. * @irq_masks_cache: cached hardware value
  34. * @type: indicate which s5m87xx "variant" is used
  35. */
  36. struct sec_pmic_dev {
  37. struct device *dev;
  38. struct regmap *regmap;
  39. struct i2c_client *i2c;
  40. struct i2c_client *rtc;
  41. struct mutex iolock;
  42. struct mutex irqlock;
  43. int device_type;
  44. int irq_base;
  45. int irq;
  46. int ono;
  47. u8 irq_masks_cur[NUM_IRQ_REGS];
  48. u8 irq_masks_cache[NUM_IRQ_REGS];
  49. int type;
  50. bool wakeup;
  51. };
  52. int sec_irq_init(struct sec_pmic_dev *sec_pmic);
  53. void sec_irq_exit(struct sec_pmic_dev *sec_pmic);
  54. int sec_irq_resume(struct sec_pmic_dev *sec_pmic);
  55. extern int sec_reg_read(struct sec_pmic_dev *sec_pmic, u8 reg, void *dest);
  56. extern int sec_bulk_read(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf);
  57. extern int sec_reg_write(struct sec_pmic_dev *sec_pmic, u8 reg, u8 value);
  58. extern int sec_bulk_write(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf);
  59. extern int sec_reg_update(struct sec_pmic_dev *sec_pmic, u8 reg, u8 val, u8 mask);
  60. struct sec_platform_data {
  61. struct sec_regulator_data *regulators;
  62. struct sec_opmode_data *opmode;
  63. int device_type;
  64. int num_regulators;
  65. int irq_base;
  66. int (*cfg_pmic_irq)(void);
  67. int ono;
  68. bool wakeup;
  69. bool buck_voltage_lock;
  70. int buck_gpios[3];
  71. int buck_ds[3];
  72. int buck2_voltage[8];
  73. bool buck2_gpiodvs;
  74. int buck3_voltage[8];
  75. bool buck3_gpiodvs;
  76. int buck4_voltage[8];
  77. bool buck4_gpiodvs;
  78. int buck_set1;
  79. int buck_set2;
  80. int buck_set3;
  81. int buck2_enable;
  82. int buck3_enable;
  83. int buck4_enable;
  84. int buck_default_idx;
  85. int buck2_default_idx;
  86. int buck3_default_idx;
  87. int buck4_default_idx;
  88. int buck_ramp_delay;
  89. int buck2_ramp_delay;
  90. int buck34_ramp_delay;
  91. int buck5_ramp_delay;
  92. int buck16_ramp_delay;
  93. int buck7810_ramp_delay;
  94. int buck9_ramp_delay;
  95. bool buck2_ramp_enable;
  96. bool buck3_ramp_enable;
  97. bool buck4_ramp_enable;
  98. bool buck6_ramp_enable;
  99. int buck2_init;
  100. int buck3_init;
  101. int buck4_init;
  102. };
  103. /**
  104. * sec_regulator_data - regulator data
  105. * @id: regulator id
  106. * @initdata: regulator init data (contraints, supplies, ...)
  107. */
  108. struct sec_regulator_data {
  109. int id;
  110. struct regulator_init_data *initdata;
  111. };
  112. /*
  113. * sec_opmode_data - regulator operation mode data
  114. * @id: regulator id
  115. * @mode: regulator operation mode
  116. */
  117. struct sec_opmode_data {
  118. int id;
  119. int mode;
  120. };
  121. /*
  122. * samsung regulator operation mode
  123. * SEC_OPMODE_OFF Regulator always OFF
  124. * SEC_OPMODE_ON Regulator always ON
  125. * SEC_OPMODE_LOWPOWER Regulator is on in low-power mode
  126. * SEC_OPMODE_SUSPEND Regulator is changed by PWREN pin
  127. * If PWREN is high, regulator is on
  128. * If PWREN is low, regulator is off
  129. */
  130. enum sec_opmode {
  131. SEC_OPMODE_OFF,
  132. SEC_OPMODE_ON,
  133. SEC_OPMODE_LOWPOWER,
  134. SEC_OPMODE_SUSPEND,
  135. };
  136. #endif /* __LINUX_MFD_SEC_CORE_H */