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