Add the rt linux 4.1.3-rt3 as base
[kvmfornfv.git] / kernel / include / linux / mfd / wm8350 / supply.h
1 /*
2  * supply.h  --  Power Supply Driver for Wolfson WM8350 PMIC
3  *
4  * Copyright 2007 Wolfson Microelectronics PLC
5  *
6  *  This program is free software; you can redistribute  it and/or modify it
7  *  under  the terms of  the GNU General  Public License as published by the
8  *  Free Software Foundation;  either version 2 of the  License, or (at your
9  *  option) any later version.
10  *
11  */
12
13 #ifndef __LINUX_MFD_WM8350_SUPPLY_H_
14 #define __LINUX_MFD_WM8350_SUPPLY_H_
15
16 #include <linux/mutex.h>
17 #include <linux/power_supply.h>
18
19 /*
20  * Charger registers
21  */
22 #define WM8350_BATTERY_CHARGER_CONTROL_1        0xA8
23 #define WM8350_BATTERY_CHARGER_CONTROL_2        0xA9
24 #define WM8350_BATTERY_CHARGER_CONTROL_3        0xAA
25
26 /*
27  * R168 (0xA8) - Battery Charger Control 1
28  */
29 #define WM8350_CHG_ENA_R168                     0x8000
30 #define WM8350_CHG_THR                          0x2000
31 #define WM8350_CHG_EOC_SEL_MASK                 0x1C00
32 #define WM8350_CHG_TRICKLE_TEMP_CHOKE           0x0200
33 #define WM8350_CHG_TRICKLE_USB_CHOKE            0x0100
34 #define WM8350_CHG_RECOVER_T                    0x0080
35 #define WM8350_CHG_END_ACT                      0x0040
36 #define WM8350_CHG_FAST                         0x0020
37 #define WM8350_CHG_FAST_USB_THROTTLE            0x0010
38 #define WM8350_CHG_NTC_MON                      0x0008
39 #define WM8350_CHG_BATT_HOT_MON                 0x0004
40 #define WM8350_CHG_BATT_COLD_MON                0x0002
41 #define WM8350_CHG_CHIP_TEMP_MON                0x0001
42
43 /*
44  * R169 (0xA9) - Battery Charger Control 2
45  */
46 #define WM8350_CHG_ACTIVE                       0x8000
47 #define WM8350_CHG_PAUSE                        0x4000
48 #define WM8350_CHG_STS_MASK                     0x3000
49 #define WM8350_CHG_TIME_MASK                    0x0F00
50 #define WM8350_CHG_MASK_WALL_FB                 0x0080
51 #define WM8350_CHG_TRICKLE_SEL                  0x0040
52 #define WM8350_CHG_VSEL_MASK                    0x0030
53 #define WM8350_CHG_ISEL_MASK                    0x000F
54 #define WM8350_CHG_STS_OFF                      0x0000
55 #define WM8350_CHG_STS_TRICKLE                  0x1000
56 #define WM8350_CHG_STS_FAST                     0x2000
57
58 /*
59  * R170 (0xAA) - Battery Charger Control 3
60  */
61 #define WM8350_CHG_THROTTLE_T_MASK              0x0060
62 #define WM8350_CHG_SMART                        0x0010
63 #define WM8350_CHG_TIMER_ADJT_MASK              0x000F
64
65 /*
66  * Charger Interrupts
67  */
68 #define WM8350_IRQ_CHG_BAT_HOT                  0
69 #define WM8350_IRQ_CHG_BAT_COLD                 1
70 #define WM8350_IRQ_CHG_BAT_FAIL                 2
71 #define WM8350_IRQ_CHG_TO                       3
72 #define WM8350_IRQ_CHG_END                      4
73 #define WM8350_IRQ_CHG_START                    5
74 #define WM8350_IRQ_CHG_FAST_RDY                 6
75 #define WM8350_IRQ_CHG_VBATT_LT_3P9             10
76 #define WM8350_IRQ_CHG_VBATT_LT_3P1             11
77 #define WM8350_IRQ_CHG_VBATT_LT_2P85            12
78
79 /*
80  * Charger Policy
81  */
82 #define WM8350_CHG_TRICKLE_50mA                 (0 << 6)
83 #define WM8350_CHG_TRICKLE_100mA                (1 << 6)
84 #define WM8350_CHG_4_05V                        (0 << 4)
85 #define WM8350_CHG_4_10V                        (1 << 4)
86 #define WM8350_CHG_4_15V                        (2 << 4)
87 #define WM8350_CHG_4_20V                        (3 << 4)
88 #define WM8350_CHG_FAST_LIMIT_mA(x)             ((x / 50) & 0xf)
89 #define WM8350_CHG_EOC_mA(x)                    (((x - 10) & 0x7) << 10)
90 #define WM8350_CHG_TRICKLE_3_1V                 (0 << 13)
91 #define WM8350_CHG_TRICKLE_3_9V                 (1 << 13)
92
93 /*
94  * Supply Registers.
95  */
96 #define WM8350_USB_VOLTAGE_READBACK             0x9C
97 #define WM8350_LINE_VOLTAGE_READBACK            0x9D
98 #define WM8350_BATT_VOLTAGE_READBACK            0x9E
99
100 /*
101  * Supply Interrupts.
102  */
103 #define WM8350_IRQ_USB_LIMIT                    15
104 #define WM8350_IRQ_EXT_USB_FB                   36
105 #define WM8350_IRQ_EXT_WALL_FB                  37
106 #define WM8350_IRQ_EXT_BAT_FB                   38
107
108 /*
109  * Policy to control charger state machine.
110  */
111 struct wm8350_charger_policy {
112
113         /* charger state machine policy  - set in machine driver */
114         int eoc_mA;             /* end of charge current (mA)  */
115         int charge_mV;          /* charge voltage */
116         int fast_limit_mA;      /* fast charge current limit */
117         int fast_limit_USB_mA;  /* USB fast charge current limit */
118         int charge_timeout;     /* charge timeout (mins) */
119         int trickle_start_mV;   /* trickle charge starts at mV */
120         int trickle_charge_mA;  /* trickle charge current */
121         int trickle_charge_USB_mA;      /* USB trickle charge current */
122 };
123
124 struct wm8350_power {
125         struct platform_device *pdev;
126         struct power_supply *battery;
127         struct power_supply *usb;
128         struct power_supply *ac;
129         struct wm8350_charger_policy *policy;
130
131         int rev_g_coeff;
132 };
133
134 #endif