core.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. struct regmap_irq_chip_data *irq_data;
  47. int ono;
  48. u8 irq_masks_cur[NUM_IRQ_REGS];
  49. u8 irq_masks_cache[NUM_IRQ_REGS];
  50. int type;
  51. bool wakeup;
  52. };
  53. int sec_irq_init(struct sec_pmic_dev *sec_pmic);
  54. void sec_irq_exit(struct sec_pmic_dev *sec_pmic);
  55. int sec_irq_resume(struct sec_pmic_dev *sec_pmic);
  56. extern int sec_reg_read(struct sec_pmic_dev *sec_pmic, u8 reg, void *dest);
  57. extern int sec_bulk_read(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf);
  58. extern int sec_reg_write(struct sec_pmic_dev *sec_pmic, u8 reg, u8 value);
  59. extern int sec_bulk_write(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf);
  60. extern int sec_reg_update(struct sec_pmic_dev *sec_pmic, u8 reg, u8 val, u8 mask);
  61. struct sec_platform_data {
  62. struct sec_regulator_data *regulators;
  63. struct sec_opmode_data *opmode;
  64. int device_type;
  65. int num_regulators;
  66. int irq_base;
  67. int (*cfg_pmic_irq)(void);
  68. int ono;
  69. bool wakeup;
  70. bool buck_voltage_lock;
  71. int buck_gpios[3];
  72. int buck_ds[3];
  73. int buck2_voltage[8];
  74. bool buck2_gpiodvs;
  75. int buck3_voltage[8];
  76. bool buck3_gpiodvs;
  77. int buck4_voltage[8];
  78. bool buck4_gpiodvs;
  79. int buck_set1;
  80. int buck_set2;
  81. int buck_set3;
  82. int buck2_enable;
  83. int buck3_enable;
  84. int buck4_enable;
  85. int buck_default_idx;
  86. int buck2_default_idx;
  87. int buck3_default_idx;
  88. int buck4_default_idx;
  89. int buck_ramp_delay;
  90. int buck2_ramp_delay;
  91. int buck34_ramp_delay;
  92. int buck5_ramp_delay;
  93. int buck16_ramp_delay;
  94. int buck7810_ramp_delay;
  95. int buck9_ramp_delay;
  96. bool buck2_ramp_enable;
  97. bool buck3_ramp_enable;
  98. bool buck4_ramp_enable;
  99. bool buck6_ramp_enable;
  100. int buck2_init;
  101. int buck3_init;
  102. int buck4_init;
  103. };
  104. /**
  105. * sec_regulator_data - regulator data
  106. * @id: regulator id
  107. * @initdata: regulator init data (contraints, supplies, ...)
  108. */
  109. struct sec_regulator_data {
  110. int id;
  111. struct regulator_init_data *initdata;
  112. };
  113. /*
  114. * sec_opmode_data - regulator operation mode data
  115. * @id: regulator id
  116. * @mode: regulator operation mode
  117. */
  118. struct sec_opmode_data {
  119. int id;
  120. int mode;
  121. };
  122. /*
  123. * samsung regulator operation mode
  124. * SEC_OPMODE_OFF Regulator always OFF
  125. * SEC_OPMODE_ON Regulator always ON
  126. * SEC_OPMODE_LOWPOWER Regulator is on in low-power mode
  127. * SEC_OPMODE_SUSPEND Regulator is changed by PWREN pin
  128. * If PWREN is high, regulator is on
  129. * If PWREN is low, regulator is off
  130. */
  131. enum sec_opmode {
  132. SEC_OPMODE_OFF,
  133. SEC_OPMODE_ON,
  134. SEC_OPMODE_LOWPOWER,
  135. SEC_OPMODE_SUSPEND,
  136. };
  137. #endif /* __LINUX_MFD_SEC_CORE_H */