Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
core.h
Go to the documentation of this file.
1 /*
2  * core.h -- Core driver for NXP PCF50633
3  *
4  * (C) 2006-2008 by Openmoko, Inc.
5  * All rights reserved.
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_PCF50633_CORE_H
14 #define __LINUX_MFD_PCF50633_CORE_H
15 
16 #include <linux/i2c.h>
17 #include <linux/workqueue.h>
18 #include <linux/regulator/driver.h>
20 #include <linux/power_supply.h>
22 
23 struct pcf50633;
24 struct regmap;
25 
26 #define PCF50633_NUM_REGULATORS 11
27 
30 
31  char **batteries;
33 
34  /*
35  * Should be set accordingly to the reference resistor used, see
36  * I_{ch(ref)} charger reference current in the pcf50633 User
37  * Manual.
38  */
40 
41  /* Callbacks */
42  void (*probe_done)(struct pcf50633 *);
46 
48 
50 };
51 
52 struct pcf50633_irq {
53  void (*handler) (int, void *);
54  void *data;
55 };
56 
57 int pcf50633_register_irq(struct pcf50633 *pcf, int irq,
58  void (*handler) (int, void *), void *data);
59 int pcf50633_free_irq(struct pcf50633 *pcf, int irq);
60 
61 int pcf50633_irq_mask(struct pcf50633 *pcf, int irq);
62 int pcf50633_irq_unmask(struct pcf50633 *pcf, int irq);
63 int pcf50633_irq_mask_get(struct pcf50633 *pcf, int irq);
64 
65 int pcf50633_read_block(struct pcf50633 *, u8 reg,
66  int nr_regs, u8 *data);
67 int pcf50633_write_block(struct pcf50633 *pcf, u8 reg,
68  int nr_regs, u8 *data);
70 int pcf50633_reg_write(struct pcf50633 *pcf, u8 reg, u8 val);
71 
72 int pcf50633_reg_set_bit_mask(struct pcf50633 *pcf, u8 reg, u8 mask, u8 val);
73 int pcf50633_reg_clear_bits(struct pcf50633 *pcf, u8 reg, u8 bits);
74 
75 /* Interrupt registers */
76 
77 #define PCF50633_REG_INT1 0x02
78 #define PCF50633_REG_INT2 0x03
79 #define PCF50633_REG_INT3 0x04
80 #define PCF50633_REG_INT4 0x05
81 #define PCF50633_REG_INT5 0x06
82 
83 #define PCF50633_REG_INT1M 0x07
84 #define PCF50633_REG_INT2M 0x08
85 #define PCF50633_REG_INT3M 0x09
86 #define PCF50633_REG_INT4M 0x0a
87 #define PCF50633_REG_INT5M 0x0b
88 
89 enum {
90  /* Chip IRQs */
131 
132  /* Always last */
134 };
135 
136 struct pcf50633 {
137  struct device *dev;
138  struct regmap *regmap;
139 
141  int irq;
145  struct mutex lock;
146 
148 
152 
154 
161 };
162 
164  PCF50633_INT1_ADPINS = 0x01, /* Adapter inserted */
165  PCF50633_INT1_ADPREM = 0x02, /* Adapter removed */
166  PCF50633_INT1_USBINS = 0x04, /* USB inserted */
167  PCF50633_INT1_USBREM = 0x08, /* USB removed */
168  /* reserved */
169  PCF50633_INT1_ALARM = 0x40, /* RTC alarm time is reached */
170  PCF50633_INT1_SECOND = 0x80, /* RTC periodic second interrupt */
171 };
172 
174  PCF50633_INT2_ONKEYR = 0x01, /* ONKEY rising edge */
175  PCF50633_INT2_ONKEYF = 0x02, /* ONKEY falling edge */
176  PCF50633_INT2_EXTON1R = 0x04, /* EXTON1 rising edge */
177  PCF50633_INT2_EXTON1F = 0x08, /* EXTON1 falling edge */
178  PCF50633_INT2_EXTON2R = 0x10, /* EXTON2 rising edge */
179  PCF50633_INT2_EXTON2F = 0x20, /* EXTON2 falling edge */
180  PCF50633_INT2_EXTON3R = 0x40, /* EXTON3 rising edge */
181  PCF50633_INT2_EXTON3F = 0x80, /* EXTON3 falling edge */
182 };
183 
185  PCF50633_INT3_BATFULL = 0x01, /* Battery full */
186  PCF50633_INT3_CHGHALT = 0x02, /* Charger halt */
191  PCF50633_INT3_ADCRDY = 0x40, /* ADC result ready */
192  PCF50633_INT3_ONKEY1S = 0x80, /* ONKEY pressed 1 second */
193 };
194 
204 };
205 
215 };
216 
217 /* misc. registers */
218 #define PCF50633_REG_OOCSHDWN 0x0c
219 
220 /* LED registers */
221 #define PCF50633_REG_LEDOUT 0x28
222 #define PCF50633_REG_LEDENA 0x29
223 #define PCF50633_REG_LEDCTL 0x2a
224 #define PCF50633_REG_LEDDIM 0x2b
225 
226 static inline struct pcf50633 *dev_to_pcf50633(struct device *dev)
227 {
228  return dev_get_drvdata(dev);
229 }
230 
231 int pcf50633_irq_init(struct pcf50633 *pcf, int irq);
232 void pcf50633_irq_free(struct pcf50633 *pcf);
233 #ifdef CONFIG_PM
234 int pcf50633_irq_suspend(struct pcf50633 *pcf);
235 int pcf50633_irq_resume(struct pcf50633 *pcf);
236 #endif
237 
238 #endif