core.h 3.9 KB

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