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