mfd: ricoh583: Support shutdown through input signal
[linux-2.6.git] / include / linux / mfd / ricoh583.h
1 /* include/linux/mfd/ricoh583.h
2  *
3  * Core driver interface to access RICOH583 power management chip.
4  *
5  * Copyright (C) 2011 NVIDIA Corporation
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15  * more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20  *
21  */
22
23 #ifndef __LINUX_MFD_RICOH583_H
24 #define __LINUX_MFD_RICOH583_H
25
26 /* RICOH583 IRQ definitions */
27 enum {
28         RICOH583_IRQ_ONKEY,
29         RICOH583_IRQ_ACOK,
30         RICOH583_IRQ_LIDOPEN,
31         RICOH583_IRQ_PREOT,
32         RICOH583_IRQ_CLKSTP,
33         RICOH583_IRQ_ONKEY_OFF,
34         RICOH583_IRQ_WD,
35         RICOH583_IRQ_EN_PWRREQ1,
36         RICOH583_IRQ_EN_PWRREQ2,
37         RICOH583_IRQ_PRE_VINDET,
38
39         RICOH583_IRQ_DC0LIM,
40         RICOH583_IRQ_DC1LIM,
41         RICOH583_IRQ_DC2LIM,
42         RICOH583_IRQ_DC3LIM,
43
44         RICOH583_IRQ_CTC,
45         RICOH583_IRQ_YALE,
46         RICOH583_IRQ_DALE,
47         RICOH583_IRQ_WALE,
48
49         RICOH583_IRQ_AIN1L,
50         RICOH583_IRQ_AIN2L,
51         RICOH583_IRQ_AIN3L,
52         RICOH583_IRQ_VBATL,
53         RICOH583_IRQ_VIN3L,
54         RICOH583_IRQ_VIN8L,
55         RICOH583_IRQ_AIN1H,
56         RICOH583_IRQ_AIN2H,
57         RICOH583_IRQ_AIN3H,
58         RICOH583_IRQ_VBATH,
59         RICOH583_IRQ_VIN3H,
60         RICOH583_IRQ_VIN8H,
61         RICOH583_IRQ_ADCEND,
62
63         RICOH583_IRQ_GPIO0,
64         RICOH583_IRQ_GPIO1,
65         RICOH583_IRQ_GPIO2,
66         RICOH583_IRQ_GPIO3,
67         RICOH583_IRQ_GPIO4,
68         RICOH583_IRQ_GPIO5,
69         RICOH583_IRQ_GPIO6,
70         RICOH583_IRQ_GPIO7,
71         RICOH583_NR_IRQS,
72 };
73
74 /* Ricoh583 gpio definitions */
75 enum {
76         RICOH583_GPIO0,
77         RICOH583_GPIO1,
78         RICOH583_GPIO2,
79         RICOH583_GPIO3,
80         RICOH583_GPIO4,
81         RICOH583_GPIO5,
82         RICOH583_GPIO6,
83         RICOH583_GPIO7,
84
85         RICOH583_NR_GPIO,
86 };
87
88 enum ricoh583_deepsleep_control_id {
89         RICOH583_DS_NONE,
90         RICOH583_DS_DC0,
91         RICOH583_DS_DC1,
92         RICOH583_DS_DC2,
93         RICOH583_DS_DC3,
94         RICOH583_DS_LDO0,
95         RICOH583_DS_LDO1,
96         RICOH583_DS_LDO2,
97         RICOH583_DS_LDO3,
98         RICOH583_DS_LDO4,
99         RICOH583_DS_LDO5,
100         RICOH583_DS_LDO6,
101         RICOH583_DS_LDO7,
102         RICOH583_DS_LDO8,
103         RICOH583_DS_LDO9,
104         RICOH583_DS_PSO0,
105         RICOH583_DS_PSO1,
106         RICOH583_DS_PSO2,
107         RICOH583_DS_PSO3,
108         RICOH583_DS_PSO4,
109         RICOH583_DS_PSO5,
110         RICOH583_DS_PSO6,
111         RICOH583_DS_PSO7,
112 };
113 enum ricoh583_ext_pwrreq_control {
114         RICOH583_EXT_PWRREQ1_CONTROL = 0x1,
115         RICOH583_EXT_PWRREQ2_CONTROL = 0x2,
116 };
117
118 struct ricoh583_subdev_info {
119         int             id;
120         const char      *name;
121         void            *platform_data;
122 };
123
124 struct ricoh583_rtc_platform_data {
125         int irq;
126 };
127
128 struct ricoh583_gpio_init_data {
129         unsigned pulldn_en:1;   /* Enable pull down */
130         unsigned output_mode_en:1; /* Enable output mode during init */
131         unsigned output_val:1;  /* Output value if it is in output mode */
132         unsigned init_apply:1;  /* Apply init data on configuring gpios*/
133 };
134
135 struct ricoh583_platform_data {
136         int             num_subdevs;
137         struct  ricoh583_subdev_info *subdevs;
138         int             gpio_base;
139         int             irq_base;
140
141         struct ricoh583_gpio_init_data *gpio_init_data;
142         int num_gpioinit_data;
143         bool enable_shutdown_pin;
144 };
145
146 extern int ricoh583_read(struct device *dev, uint8_t reg, uint8_t *val);
147 extern int ricoh583_bulk_read(struct device *dev, u8 reg, u8 count,
148                                 uint8_t *val);
149 extern int ricoh583_write(struct device *dev, u8 reg, uint8_t val);
150 extern int ricoh583_bulk_write(struct device *dev, u8 reg, u8 count,
151                                 uint8_t *val);
152 extern int ricoh583_set_bits(struct device *dev, u8 reg, uint8_t bit_mask);
153 extern int ricoh583_clr_bits(struct device *dev, u8 reg, uint8_t bit_mask);
154 extern int ricoh583_update(struct device *dev, u8 reg, uint8_t val,
155                                         uint8_t mask);
156 extern int ricoh583_ext_power_req_config(struct device *dev,
157                 enum ricoh583_deepsleep_control_id control_id,
158                 enum ricoh583_ext_pwrreq_control ext_pwr_req,
159                 int deepsleep_slot_nr);
160 extern int ricoh583_power_off(void);
161
162 #endif