1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* 3 * Copyright (c) 2011 Samsung Electronics Co., Ltd 4 * http://www.samsung.com 5 */ 6 7 #ifndef __LINUX_MFD_SEC_CORE_H 8 #define __LINUX_MFD_SEC_CORE_H 9 10 /* Macros to represent minimum voltages for LDO/BUCK */ 11 #define MIN_3000_MV 3000000 12 #define MIN_2500_MV 2500000 13 #define MIN_2000_MV 2000000 14 #define MIN_1800_MV 1800000 15 #define MIN_1500_MV 1500000 16 #define MIN_1400_MV 1400000 17 #define MIN_1000_MV 1000000 18 19 #define MIN_900_MV 900000 20 #define MIN_850_MV 850000 21 #define MIN_800_MV 800000 22 #define MIN_750_MV 750000 23 #define MIN_600_MV 600000 24 #define MIN_500_MV 500000 25 26 /* Ramp delay in uV/us */ 27 #define RAMP_DELAY_12_MVUS 12000 28 29 /* Macros to represent steps for LDO/BUCK */ 30 #define STEP_50_MV 50000 31 #define STEP_25_MV 25000 32 #define STEP_12_5_MV 12500 33 #define STEP_6_25_MV 6250 34 35 struct gpio_desc; 36 37 enum sec_device_type { 38 S5M8751X, 39 S5M8763X, 40 S5M8767X, 41 S2MPA01, 42 S2MPS11X, 43 S2MPS13X, 44 S2MPS14X, 45 S2MPS15X, 46 S2MPU02, 47 }; 48 49 /** 50 * struct sec_pmic_dev - s2m/s5m master device for sub-drivers 51 * @dev: Master device of the chip 52 * @pdata: Platform data populated with data from DTS 53 * or board files 54 * @regmap_pmic: Regmap associated with PMIC's I2C address 55 * @i2c: I2C client of the main driver 56 * @device_type: Type of device, matches enum sec_device_type 57 * @irq_base: Base IRQ number for device, required for IRQs 58 * @irq: Generic IRQ number for device 59 * @irq_data: Runtime data structure for IRQ controller 60 * @wakeup: Whether or not this is a wakeup device 61 */ 62 struct sec_pmic_dev { 63 struct device *dev; 64 struct sec_platform_data *pdata; 65 struct regmap *regmap_pmic; 66 struct i2c_client *i2c; 67 68 unsigned long device_type; 69 int irq_base; 70 int irq; 71 struct regmap_irq_chip_data *irq_data; 72 73 bool wakeup; 74 }; 75 76 int sec_irq_init(struct sec_pmic_dev *sec_pmic); 77 void sec_irq_exit(struct sec_pmic_dev *sec_pmic); 78 int sec_irq_resume(struct sec_pmic_dev *sec_pmic); 79 80 struct sec_platform_data { 81 struct sec_regulator_data *regulators; 82 struct sec_opmode_data *opmode; 83 int device_type; 84 int num_regulators; 85 86 int irq_base; 87 int (*cfg_pmic_irq)(void); 88 89 bool wakeup; 90 bool buck_voltage_lock; 91 92 int buck_gpios[3]; 93 int buck_ds[3]; 94 unsigned int buck2_voltage[8]; 95 bool buck2_gpiodvs; 96 unsigned int buck3_voltage[8]; 97 bool buck3_gpiodvs; 98 unsigned int buck4_voltage[8]; 99 bool buck4_gpiodvs; 100 101 int buck_set1; 102 int buck_set2; 103 int buck_set3; 104 int buck2_enable; 105 int buck3_enable; 106 int buck4_enable; 107 int buck_default_idx; 108 int buck2_default_idx; 109 int buck3_default_idx; 110 int buck4_default_idx; 111 112 int buck_ramp_delay; 113 114 int buck2_ramp_delay; 115 int buck34_ramp_delay; 116 int buck5_ramp_delay; 117 int buck16_ramp_delay; 118 int buck7810_ramp_delay; 119 int buck9_ramp_delay; 120 int buck24_ramp_delay; 121 int buck3_ramp_delay; 122 int buck7_ramp_delay; 123 int buck8910_ramp_delay; 124 125 bool buck1_ramp_enable; 126 bool buck2_ramp_enable; 127 bool buck3_ramp_enable; 128 bool buck4_ramp_enable; 129 bool buck6_ramp_enable; 130 131 int buck2_init; 132 int buck3_init; 133 int buck4_init; 134 /* Whether or not manually set PWRHOLD to low during shutdown. */ 135 bool manual_poweroff; 136 /* Disable the WRSTBI (buck voltage warm reset) when probing? */ 137 bool disable_wrstbi; 138 }; 139 140 /** 141 * sec_regulator_data - regulator data 142 * @id: regulator id 143 * @initdata: regulator init data (contraints, supplies, ...) 144 */ 145 struct sec_regulator_data { 146 int id; 147 struct regulator_init_data *initdata; 148 struct device_node *reg_node; 149 struct gpio_desc *ext_control_gpiod; 150 }; 151 152 /* 153 * sec_opmode_data - regulator operation mode data 154 * @id: regulator id 155 * @mode: regulator operation mode 156 */ 157 struct sec_opmode_data { 158 int id; 159 unsigned int mode; 160 }; 161 162 /* 163 * samsung regulator operation mode 164 * SEC_OPMODE_OFF Regulator always OFF 165 * SEC_OPMODE_ON Regulator always ON 166 * SEC_OPMODE_LOWPOWER Regulator is on in low-power mode 167 * SEC_OPMODE_SUSPEND Regulator is changed by PWREN pin 168 * If PWREN is high, regulator is on 169 * If PWREN is low, regulator is off 170 */ 171 172 enum sec_opmode { 173 SEC_OPMODE_OFF, 174 SEC_OPMODE_ON, 175 SEC_OPMODE_LOWPOWER, 176 SEC_OPMODE_SUSPEND, 177 }; 178 179 #endif /* __LINUX_MFD_SEC_CORE_H */ 180