Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * supply.h  --  Power Supply Driver for Wolfson WM8350 PMIC
0004  *
0005  * Copyright 2007 Wolfson Microelectronics PLC
0006  */
0007 
0008 #ifndef __LINUX_MFD_WM8350_SUPPLY_H_
0009 #define __LINUX_MFD_WM8350_SUPPLY_H_
0010 
0011 #include <linux/mutex.h>
0012 #include <linux/power_supply.h>
0013 
0014 /*
0015  * Charger registers
0016  */
0017 #define WM8350_BATTERY_CHARGER_CONTROL_1        0xA8
0018 #define WM8350_BATTERY_CHARGER_CONTROL_2        0xA9
0019 #define WM8350_BATTERY_CHARGER_CONTROL_3        0xAA
0020 
0021 /*
0022  * R168 (0xA8) - Battery Charger Control 1
0023  */
0024 #define WM8350_CHG_ENA_R168                     0x8000
0025 #define WM8350_CHG_THR                          0x2000
0026 #define WM8350_CHG_EOC_SEL_MASK                 0x1C00
0027 #define WM8350_CHG_TRICKLE_TEMP_CHOKE           0x0200
0028 #define WM8350_CHG_TRICKLE_USB_CHOKE            0x0100
0029 #define WM8350_CHG_RECOVER_T                    0x0080
0030 #define WM8350_CHG_END_ACT                      0x0040
0031 #define WM8350_CHG_FAST                         0x0020
0032 #define WM8350_CHG_FAST_USB_THROTTLE            0x0010
0033 #define WM8350_CHG_NTC_MON                      0x0008
0034 #define WM8350_CHG_BATT_HOT_MON                 0x0004
0035 #define WM8350_CHG_BATT_COLD_MON                0x0002
0036 #define WM8350_CHG_CHIP_TEMP_MON                0x0001
0037 
0038 /*
0039  * R169 (0xA9) - Battery Charger Control 2
0040  */
0041 #define WM8350_CHG_ACTIVE                       0x8000
0042 #define WM8350_CHG_PAUSE                        0x4000
0043 #define WM8350_CHG_STS_MASK                     0x3000
0044 #define WM8350_CHG_TIME_MASK                    0x0F00
0045 #define WM8350_CHG_MASK_WALL_FB                 0x0080
0046 #define WM8350_CHG_TRICKLE_SEL                  0x0040
0047 #define WM8350_CHG_VSEL_MASK                    0x0030
0048 #define WM8350_CHG_ISEL_MASK                    0x000F
0049 #define WM8350_CHG_STS_OFF                      0x0000
0050 #define WM8350_CHG_STS_TRICKLE                  0x1000
0051 #define WM8350_CHG_STS_FAST                     0x2000
0052 
0053 /*
0054  * R170 (0xAA) - Battery Charger Control 3
0055  */
0056 #define WM8350_CHG_THROTTLE_T_MASK              0x0060
0057 #define WM8350_CHG_SMART                        0x0010
0058 #define WM8350_CHG_TIMER_ADJT_MASK              0x000F
0059 
0060 /*
0061  * Charger Interrupts
0062  */
0063 #define WM8350_IRQ_CHG_BAT_HOT          0
0064 #define WM8350_IRQ_CHG_BAT_COLD         1
0065 #define WM8350_IRQ_CHG_BAT_FAIL         2
0066 #define WM8350_IRQ_CHG_TO           3
0067 #define WM8350_IRQ_CHG_END          4
0068 #define WM8350_IRQ_CHG_START            5
0069 #define WM8350_IRQ_CHG_FAST_RDY         6
0070 #define WM8350_IRQ_CHG_VBATT_LT_3P9     10
0071 #define WM8350_IRQ_CHG_VBATT_LT_3P1     11
0072 #define WM8350_IRQ_CHG_VBATT_LT_2P85        12
0073 
0074 /*
0075  * Charger Policy
0076  */
0077 #define WM8350_CHG_TRICKLE_50mA         (0 << 6)
0078 #define WM8350_CHG_TRICKLE_100mA        (1 << 6)
0079 #define WM8350_CHG_4_05V            (0 << 4)
0080 #define WM8350_CHG_4_10V            (1 << 4)
0081 #define WM8350_CHG_4_15V            (2 << 4)
0082 #define WM8350_CHG_4_20V            (3 << 4)
0083 #define WM8350_CHG_FAST_LIMIT_mA(x)     ((x / 50) & 0xf)
0084 #define WM8350_CHG_EOC_mA(x)            (((x - 10) & 0x7) << 10)
0085 #define WM8350_CHG_TRICKLE_3_1V         (0 << 13)
0086 #define WM8350_CHG_TRICKLE_3_9V         (1 << 13)
0087 
0088 /*
0089  * Supply Registers.
0090  */
0091 #define WM8350_USB_VOLTAGE_READBACK             0x9C
0092 #define WM8350_LINE_VOLTAGE_READBACK            0x9D
0093 #define WM8350_BATT_VOLTAGE_READBACK            0x9E
0094 
0095 /*
0096  * Supply Interrupts.
0097  */
0098 #define WM8350_IRQ_USB_LIMIT            15
0099 #define WM8350_IRQ_EXT_USB_FB           36
0100 #define WM8350_IRQ_EXT_WALL_FB          37
0101 #define WM8350_IRQ_EXT_BAT_FB           38
0102 
0103 /*
0104  * Policy to control charger state machine.
0105  */
0106 struct wm8350_charger_policy {
0107 
0108     /* charger state machine policy  - set in machine driver */
0109     int eoc_mA;     /* end of charge current (mA)  */
0110     int charge_mV;      /* charge voltage */
0111     int fast_limit_mA;  /* fast charge current limit */
0112     int fast_limit_USB_mA;  /* USB fast charge current limit */
0113     int charge_timeout; /* charge timeout (mins) */
0114     int trickle_start_mV;   /* trickle charge starts at mV */
0115     int trickle_charge_mA;  /* trickle charge current */
0116     int trickle_charge_USB_mA;  /* USB trickle charge current */
0117 };
0118 
0119 struct wm8350_power {
0120     struct platform_device *pdev;
0121     struct power_supply *battery;
0122     struct power_supply *usb;
0123     struct power_supply *ac;
0124     struct wm8350_charger_policy *policy;
0125 
0126     int rev_g_coeff;
0127 };
0128 
0129 #endif