1*2874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 2f8ea79c2SMark Brown /* 3f8ea79c2SMark Brown * supply.h -- Power Supply Driver for Wolfson WM8350 PMIC 4f8ea79c2SMark Brown * 5f8ea79c2SMark Brown * Copyright 2007 Wolfson Microelectronics PLC 6f8ea79c2SMark Brown */ 7f8ea79c2SMark Brown 8f8ea79c2SMark Brown #ifndef __LINUX_MFD_WM8350_SUPPLY_H_ 9f8ea79c2SMark Brown #define __LINUX_MFD_WM8350_SUPPLY_H_ 10f8ea79c2SMark Brown 1114431aa0SMark Brown #include <linux/mutex.h> 1214431aa0SMark Brown #include <linux/power_supply.h> 13add41cb4SMark Brown 14f8ea79c2SMark Brown /* 15f8ea79c2SMark Brown * Charger registers 16f8ea79c2SMark Brown */ 17f8ea79c2SMark Brown #define WM8350_BATTERY_CHARGER_CONTROL_1 0xA8 18f8ea79c2SMark Brown #define WM8350_BATTERY_CHARGER_CONTROL_2 0xA9 19f8ea79c2SMark Brown #define WM8350_BATTERY_CHARGER_CONTROL_3 0xAA 20f8ea79c2SMark Brown 21f8ea79c2SMark Brown /* 22f8ea79c2SMark Brown * R168 (0xA8) - Battery Charger Control 1 23f8ea79c2SMark Brown */ 24f8ea79c2SMark Brown #define WM8350_CHG_ENA_R168 0x8000 25f8ea79c2SMark Brown #define WM8350_CHG_THR 0x2000 26f8ea79c2SMark Brown #define WM8350_CHG_EOC_SEL_MASK 0x1C00 27f8ea79c2SMark Brown #define WM8350_CHG_TRICKLE_TEMP_CHOKE 0x0200 28f8ea79c2SMark Brown #define WM8350_CHG_TRICKLE_USB_CHOKE 0x0100 29f8ea79c2SMark Brown #define WM8350_CHG_RECOVER_T 0x0080 30f8ea79c2SMark Brown #define WM8350_CHG_END_ACT 0x0040 31f8ea79c2SMark Brown #define WM8350_CHG_FAST 0x0020 32f8ea79c2SMark Brown #define WM8350_CHG_FAST_USB_THROTTLE 0x0010 33f8ea79c2SMark Brown #define WM8350_CHG_NTC_MON 0x0008 34f8ea79c2SMark Brown #define WM8350_CHG_BATT_HOT_MON 0x0004 35f8ea79c2SMark Brown #define WM8350_CHG_BATT_COLD_MON 0x0002 36f8ea79c2SMark Brown #define WM8350_CHG_CHIP_TEMP_MON 0x0001 37f8ea79c2SMark Brown 38f8ea79c2SMark Brown /* 39f8ea79c2SMark Brown * R169 (0xA9) - Battery Charger Control 2 40f8ea79c2SMark Brown */ 41f8ea79c2SMark Brown #define WM8350_CHG_ACTIVE 0x8000 42f8ea79c2SMark Brown #define WM8350_CHG_PAUSE 0x4000 43f8ea79c2SMark Brown #define WM8350_CHG_STS_MASK 0x3000 44f8ea79c2SMark Brown #define WM8350_CHG_TIME_MASK 0x0F00 45f8ea79c2SMark Brown #define WM8350_CHG_MASK_WALL_FB 0x0080 46f8ea79c2SMark Brown #define WM8350_CHG_TRICKLE_SEL 0x0040 47f8ea79c2SMark Brown #define WM8350_CHG_VSEL_MASK 0x0030 48f8ea79c2SMark Brown #define WM8350_CHG_ISEL_MASK 0x000F 49f8ea79c2SMark Brown #define WM8350_CHG_STS_OFF 0x0000 50f8ea79c2SMark Brown #define WM8350_CHG_STS_TRICKLE 0x1000 51f8ea79c2SMark Brown #define WM8350_CHG_STS_FAST 0x2000 52f8ea79c2SMark Brown 53f8ea79c2SMark Brown /* 54f8ea79c2SMark Brown * R170 (0xAA) - Battery Charger Control 3 55f8ea79c2SMark Brown */ 56f8ea79c2SMark Brown #define WM8350_CHG_THROTTLE_T_MASK 0x0060 57f8ea79c2SMark Brown #define WM8350_CHG_SMART 0x0010 58f8ea79c2SMark Brown #define WM8350_CHG_TIMER_ADJT_MASK 0x000F 59f8ea79c2SMark Brown 60f8ea79c2SMark Brown /* 61f8ea79c2SMark Brown * Charger Interrupts 62f8ea79c2SMark Brown */ 63f8ea79c2SMark Brown #define WM8350_IRQ_CHG_BAT_HOT 0 64f8ea79c2SMark Brown #define WM8350_IRQ_CHG_BAT_COLD 1 65f8ea79c2SMark Brown #define WM8350_IRQ_CHG_BAT_FAIL 2 66f8ea79c2SMark Brown #define WM8350_IRQ_CHG_TO 3 67f8ea79c2SMark Brown #define WM8350_IRQ_CHG_END 4 68f8ea79c2SMark Brown #define WM8350_IRQ_CHG_START 5 69f8ea79c2SMark Brown #define WM8350_IRQ_CHG_FAST_RDY 6 70f8ea79c2SMark Brown #define WM8350_IRQ_CHG_VBATT_LT_3P9 10 71f8ea79c2SMark Brown #define WM8350_IRQ_CHG_VBATT_LT_3P1 11 72f8ea79c2SMark Brown #define WM8350_IRQ_CHG_VBATT_LT_2P85 12 73f8ea79c2SMark Brown 74f8ea79c2SMark Brown /* 75f8ea79c2SMark Brown * Charger Policy 76f8ea79c2SMark Brown */ 77f8ea79c2SMark Brown #define WM8350_CHG_TRICKLE_50mA (0 << 6) 78f8ea79c2SMark Brown #define WM8350_CHG_TRICKLE_100mA (1 << 6) 79f8ea79c2SMark Brown #define WM8350_CHG_4_05V (0 << 4) 80f8ea79c2SMark Brown #define WM8350_CHG_4_10V (1 << 4) 81f8ea79c2SMark Brown #define WM8350_CHG_4_15V (2 << 4) 82f8ea79c2SMark Brown #define WM8350_CHG_4_20V (3 << 4) 83f8ea79c2SMark Brown #define WM8350_CHG_FAST_LIMIT_mA(x) ((x / 50) & 0xf) 84f8ea79c2SMark Brown #define WM8350_CHG_EOC_mA(x) (((x - 10) & 0x7) << 10) 85f8ea79c2SMark Brown #define WM8350_CHG_TRICKLE_3_1V (0 << 13) 86f8ea79c2SMark Brown #define WM8350_CHG_TRICKLE_3_9V (1 << 13) 87f8ea79c2SMark Brown 88f8ea79c2SMark Brown /* 89f8ea79c2SMark Brown * Supply Registers. 90f8ea79c2SMark Brown */ 91f8ea79c2SMark Brown #define WM8350_USB_VOLTAGE_READBACK 0x9C 92f8ea79c2SMark Brown #define WM8350_LINE_VOLTAGE_READBACK 0x9D 93f8ea79c2SMark Brown #define WM8350_BATT_VOLTAGE_READBACK 0x9E 94f8ea79c2SMark Brown 95f8ea79c2SMark Brown /* 96f8ea79c2SMark Brown * Supply Interrupts. 97f8ea79c2SMark Brown */ 98f8ea79c2SMark Brown #define WM8350_IRQ_USB_LIMIT 15 99f8ea79c2SMark Brown #define WM8350_IRQ_EXT_USB_FB 36 100f8ea79c2SMark Brown #define WM8350_IRQ_EXT_WALL_FB 37 101f8ea79c2SMark Brown #define WM8350_IRQ_EXT_BAT_FB 38 102f8ea79c2SMark Brown 10314431aa0SMark Brown /* 10414431aa0SMark Brown * Policy to control charger state machine. 10514431aa0SMark Brown */ 10614431aa0SMark Brown struct wm8350_charger_policy { 10714431aa0SMark Brown 10814431aa0SMark Brown /* charger state machine policy - set in machine driver */ 10914431aa0SMark Brown int eoc_mA; /* end of charge current (mA) */ 11014431aa0SMark Brown int charge_mV; /* charge voltage */ 11114431aa0SMark Brown int fast_limit_mA; /* fast charge current limit */ 11214431aa0SMark Brown int fast_limit_USB_mA; /* USB fast charge current limit */ 11314431aa0SMark Brown int charge_timeout; /* charge timeout (mins) */ 11414431aa0SMark Brown int trickle_start_mV; /* trickle charge starts at mV */ 11514431aa0SMark Brown int trickle_charge_mA; /* trickle charge current */ 11614431aa0SMark Brown int trickle_charge_USB_mA; /* USB trickle charge current */ 11714431aa0SMark Brown }; 11814431aa0SMark Brown 119add41cb4SMark Brown struct wm8350_power { 120add41cb4SMark Brown struct platform_device *pdev; 121297d716fSKrzysztof Kozlowski struct power_supply *battery; 122297d716fSKrzysztof Kozlowski struct power_supply *usb; 123297d716fSKrzysztof Kozlowski struct power_supply *ac; 12414431aa0SMark Brown struct wm8350_charger_policy *policy; 125d756f4a4SMark Brown 126d756f4a4SMark Brown int rev_g_coeff; 127add41cb4SMark Brown }; 128add41cb4SMark Brown 129f8ea79c2SMark Brown #endif 130