1*2874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 2f5714dc9SBalaji Rao /* 3f5714dc9SBalaji Rao * mbc.h -- Driver for NXP PCF50633 Main Battery Charger 4f5714dc9SBalaji Rao * 5f5714dc9SBalaji Rao * (C) 2006-2008 by Openmoko, Inc. 6f5714dc9SBalaji Rao * All rights reserved. 7f5714dc9SBalaji Rao */ 8f5714dc9SBalaji Rao 9f5714dc9SBalaji Rao #ifndef __LINUX_MFD_PCF50633_MBC_H 10f5714dc9SBalaji Rao #define __LINUX_MFD_PCF50633_MBC_H 11f5714dc9SBalaji Rao 12f5714dc9SBalaji Rao #include <linux/mfd/pcf50633/core.h> 13f5714dc9SBalaji Rao #include <linux/platform_device.h> 14f5714dc9SBalaji Rao 15f5714dc9SBalaji Rao #define PCF50633_REG_MBCC1 0x43 16f5714dc9SBalaji Rao #define PCF50633_REG_MBCC2 0x44 17f5714dc9SBalaji Rao #define PCF50633_REG_MBCC3 0x45 18f5714dc9SBalaji Rao #define PCF50633_REG_MBCC4 0x46 19f5714dc9SBalaji Rao #define PCF50633_REG_MBCC5 0x47 20f5714dc9SBalaji Rao #define PCF50633_REG_MBCC6 0x48 21f5714dc9SBalaji Rao #define PCF50633_REG_MBCC7 0x49 22f5714dc9SBalaji Rao #define PCF50633_REG_MBCC8 0x4a 23f5714dc9SBalaji Rao #define PCF50633_REG_MBCS1 0x4b 24f5714dc9SBalaji Rao #define PCF50633_REG_MBCS2 0x4c 25f5714dc9SBalaji Rao #define PCF50633_REG_MBCS3 0x4d 26f5714dc9SBalaji Rao 27f5714dc9SBalaji Rao enum pcf50633_reg_mbcc1 { 28f5714dc9SBalaji Rao PCF50633_MBCC1_CHGENA = 0x01, /* Charger enable */ 29f5714dc9SBalaji Rao PCF50633_MBCC1_AUTOSTOP = 0x02, 30f5714dc9SBalaji Rao PCF50633_MBCC1_AUTORES = 0x04, /* automatic resume */ 31f5714dc9SBalaji Rao PCF50633_MBCC1_RESUME = 0x08, /* explicit resume cmd */ 32f5714dc9SBalaji Rao PCF50633_MBCC1_RESTART = 0x10, /* restart charging */ 33f5714dc9SBalaji Rao PCF50633_MBCC1_PREWDTIME_60M = 0x20, /* max. precharging time */ 34f5714dc9SBalaji Rao PCF50633_MBCC1_WDTIME_1H = 0x00, 35f5714dc9SBalaji Rao PCF50633_MBCC1_WDTIME_2H = 0x40, 36f5714dc9SBalaji Rao PCF50633_MBCC1_WDTIME_4H = 0x80, 37f5714dc9SBalaji Rao PCF50633_MBCC1_WDTIME_6H = 0xc0, 38f5714dc9SBalaji Rao }; 39f5714dc9SBalaji Rao #define PCF50633_MBCC1_WDTIME_MASK 0xc0 40f5714dc9SBalaji Rao 41f5714dc9SBalaji Rao enum pcf50633_reg_mbcc2 { 42f5714dc9SBalaji Rao PCF50633_MBCC2_VBATCOND_2V7 = 0x00, 43f5714dc9SBalaji Rao PCF50633_MBCC2_VBATCOND_2V85 = 0x01, 44f5714dc9SBalaji Rao PCF50633_MBCC2_VBATCOND_3V0 = 0x02, 45f5714dc9SBalaji Rao PCF50633_MBCC2_VBATCOND_3V15 = 0x03, 46f5714dc9SBalaji Rao PCF50633_MBCC2_VMAX_4V = 0x00, 47f5714dc9SBalaji Rao PCF50633_MBCC2_VMAX_4V20 = 0x28, 48f5714dc9SBalaji Rao PCF50633_MBCC2_VRESDEBTIME_64S = 0x80, /* debounce time (32/64sec) */ 49f5714dc9SBalaji Rao }; 50f5714dc9SBalaji Rao 51f5714dc9SBalaji Rao enum pcf50633_reg_mbcc7 { 52f5714dc9SBalaji Rao PCF50633_MBCC7_USB_100mA = 0x00, 53f5714dc9SBalaji Rao PCF50633_MBCC7_USB_500mA = 0x01, 54f5714dc9SBalaji Rao PCF50633_MBCC7_USB_1000mA = 0x02, 55f5714dc9SBalaji Rao PCF50633_MBCC7_USB_SUSPEND = 0x03, 56f5714dc9SBalaji Rao PCF50633_MBCC7_BATTEMP_EN = 0x04, 57f5714dc9SBalaji Rao PCF50633_MBCC7_BATSYSIMAX_1A6 = 0x00, 58f5714dc9SBalaji Rao PCF50633_MBCC7_BATSYSIMAX_1A8 = 0x40, 59f5714dc9SBalaji Rao PCF50633_MBCC7_BATSYSIMAX_2A0 = 0x80, 60f5714dc9SBalaji Rao PCF50633_MBCC7_BATSYSIMAX_2A2 = 0xc0, 61f5714dc9SBalaji Rao }; 62f5714dc9SBalaji Rao #define PCF50633_MBCC7_USB_MASK 0x03 63f5714dc9SBalaji Rao 64f5714dc9SBalaji Rao enum pcf50633_reg_mbcc8 { 65f5714dc9SBalaji Rao PCF50633_MBCC8_USBENASUS = 0x10, 66f5714dc9SBalaji Rao }; 67f5714dc9SBalaji Rao 68f5714dc9SBalaji Rao enum pcf50633_reg_mbcs1 { 69f5714dc9SBalaji Rao PCF50633_MBCS1_USBPRES = 0x01, 70f5714dc9SBalaji Rao PCF50633_MBCS1_USBOK = 0x02, 71f5714dc9SBalaji Rao PCF50633_MBCS1_ADAPTPRES = 0x04, 72f5714dc9SBalaji Rao PCF50633_MBCS1_ADAPTOK = 0x08, 73f5714dc9SBalaji Rao PCF50633_MBCS1_TBAT_OK = 0x00, 74f5714dc9SBalaji Rao PCF50633_MBCS1_TBAT_ABOVE = 0x10, 75f5714dc9SBalaji Rao PCF50633_MBCS1_TBAT_BELOW = 0x20, 76f5714dc9SBalaji Rao PCF50633_MBCS1_TBAT_UNDEF = 0x30, 77f5714dc9SBalaji Rao PCF50633_MBCS1_PREWDTEXP = 0x40, 78f5714dc9SBalaji Rao PCF50633_MBCS1_WDTEXP = 0x80, 79f5714dc9SBalaji Rao }; 80f5714dc9SBalaji Rao 81f5714dc9SBalaji Rao enum pcf50633_reg_mbcs2_mbcmod { 82f5714dc9SBalaji Rao PCF50633_MBCS2_MBC_PLAY = 0x00, 83f5714dc9SBalaji Rao PCF50633_MBCS2_MBC_USB_PRE = 0x01, 84f5714dc9SBalaji Rao PCF50633_MBCS2_MBC_USB_PRE_WAIT = 0x02, 85f5714dc9SBalaji Rao PCF50633_MBCS2_MBC_USB_FAST = 0x03, 86f5714dc9SBalaji Rao PCF50633_MBCS2_MBC_USB_FAST_WAIT = 0x04, 87f5714dc9SBalaji Rao PCF50633_MBCS2_MBC_USB_SUSPEND = 0x05, 88f5714dc9SBalaji Rao PCF50633_MBCS2_MBC_ADP_PRE = 0x06, 89f5714dc9SBalaji Rao PCF50633_MBCS2_MBC_ADP_PRE_WAIT = 0x07, 90f5714dc9SBalaji Rao PCF50633_MBCS2_MBC_ADP_FAST = 0x08, 91f5714dc9SBalaji Rao PCF50633_MBCS2_MBC_ADP_FAST_WAIT = 0x09, 92f5714dc9SBalaji Rao PCF50633_MBCS2_MBC_BAT_FULL = 0x0a, 93f5714dc9SBalaji Rao PCF50633_MBCS2_MBC_HALT = 0x0b, 94f5714dc9SBalaji Rao }; 95f5714dc9SBalaji Rao #define PCF50633_MBCS2_MBC_MASK 0x0f 96f5714dc9SBalaji Rao enum pcf50633_reg_mbcs2_chgstat { 97f5714dc9SBalaji Rao PCF50633_MBCS2_CHGS_NONE = 0x00, 98f5714dc9SBalaji Rao PCF50633_MBCS2_CHGS_ADAPTER = 0x10, 99f5714dc9SBalaji Rao PCF50633_MBCS2_CHGS_USB = 0x20, 100f5714dc9SBalaji Rao PCF50633_MBCS2_CHGS_BOTH = 0x30, 101f5714dc9SBalaji Rao }; 102f5714dc9SBalaji Rao #define PCF50633_MBCS2_RESSTAT_AUTO 0x40 103f5714dc9SBalaji Rao 104f5714dc9SBalaji Rao enum pcf50633_reg_mbcs3 { 105f5714dc9SBalaji Rao PCF50633_MBCS3_USBLIM_PLAY = 0x01, 106f5714dc9SBalaji Rao PCF50633_MBCS3_USBLIM_CGH = 0x02, 107f5714dc9SBalaji Rao PCF50633_MBCS3_TLIM_PLAY = 0x04, 108f5714dc9SBalaji Rao PCF50633_MBCS3_TLIM_CHG = 0x08, 109f5714dc9SBalaji Rao PCF50633_MBCS3_ILIM = 0x10, /* 1: Ibat > Icutoff */ 110f5714dc9SBalaji Rao PCF50633_MBCS3_VLIM = 0x20, /* 1: Vbat == Vmax */ 111f5714dc9SBalaji Rao PCF50633_MBCS3_VBATSTAT = 0x40, /* 1: Vbat > Vbatcond */ 112f5714dc9SBalaji Rao PCF50633_MBCS3_VRES = 0x80, /* 1: Vbat > Vth(RES) */ 113f5714dc9SBalaji Rao }; 114f5714dc9SBalaji Rao 115f5714dc9SBalaji Rao #define PCF50633_MBCC2_VBATCOND_MASK 0x03 116f5714dc9SBalaji Rao #define PCF50633_MBCC2_VMAX_MASK 0x3c 117f5714dc9SBalaji Rao 118f5714dc9SBalaji Rao /* Charger status */ 119f5714dc9SBalaji Rao #define PCF50633_MBC_USB_ONLINE 0x01 120f5714dc9SBalaji Rao #define PCF50633_MBC_USB_ACTIVE 0x02 121f5714dc9SBalaji Rao #define PCF50633_MBC_ADAPTER_ONLINE 0x04 122f5714dc9SBalaji Rao #define PCF50633_MBC_ADAPTER_ACTIVE 0x08 123f5714dc9SBalaji Rao 124f5714dc9SBalaji Rao int pcf50633_mbc_usb_curlim_set(struct pcf50633 *pcf, int ma); 125f5714dc9SBalaji Rao 126f5714dc9SBalaji Rao int pcf50633_mbc_get_status(struct pcf50633 *); 127c3297950SPaul Fertser int pcf50633_mbc_get_usb_online_status(struct pcf50633 *); 128f5714dc9SBalaji Rao 129f5714dc9SBalaji Rao #endif 130f5714dc9SBalaji Rao 131