core.h 4.1 KB

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