Commit 04750447124143dfc9444a0c3335ffc9636e1df8
Committed by
Minkyu Kang
1 parent
12eba1b493
Exists in
master
and in
56 other branches
drivers:power:max77693: add support for new multi function pmic max77693
This patch add support for new multi function pmic max77693. The driver is split into three modules: pmic, muic and fuelgage. Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
Showing 8 changed files with 512 additions and 0 deletions Side-by-side Diff
Makefile
| ... | ... | @@ -284,6 +284,7 @@ |
| 284 | 284 | LIBS-y += drivers/pcmcia/libpcmcia.o |
| 285 | 285 | LIBS-y += drivers/power/libpower.o \ |
| 286 | 286 | drivers/power/fuel_gauge/libfuel_gauge.o \ |
| 287 | + drivers/power/mfd/libmfd.o \ | |
| 287 | 288 | drivers/power/pmic/libpmic.o \ |
| 288 | 289 | drivers/power/battery/libbattery.o |
| 289 | 290 | LIBS-y += drivers/spi/libspi.o |
drivers/power/mfd/Makefile
| 1 | +# | |
| 2 | +# Copyright (C) 2013 Samsung Electronics | |
| 3 | +# Piotr Wilczek <p.wilczek@samsung.com> | |
| 4 | +# | |
| 5 | +# SPDX-License-Identifier: GPL-2.0+ | |
| 6 | +# | |
| 7 | + | |
| 8 | +include $(TOPDIR)/config.mk | |
| 9 | + | |
| 10 | +LIB := $(obj)libmfd.o | |
| 11 | + | |
| 12 | +COBJS-$(CONFIG_POWER_PMIC_MAX77693) += pmic_max77693.o | |
| 13 | +COBJS-$(CONFIG_POWER_MUIC_MAX77693) += muic_max77693.o | |
| 14 | +COBJS-$(CONFIG_POWER_FG_MAX77693) += fg_max77693.o | |
| 15 | + | |
| 16 | +COBJS := $(COBJS-y) | |
| 17 | +SRCS := $(COBJS:.o=.c) | |
| 18 | +OBJS := $(addprefix $(obj),$(COBJS)) | |
| 19 | + | |
| 20 | +all: $(LIB) | |
| 21 | + | |
| 22 | +$(LIB): $(obj).depend $(OBJS) | |
| 23 | + $(call cmd_link_o_target, $(OBJS)) | |
| 24 | + | |
| 25 | + | |
| 26 | +######################################################################### | |
| 27 | + | |
| 28 | +# defines $(obj).depend target | |
| 29 | +include $(SRCTREE)/rules.mk | |
| 30 | + | |
| 31 | +sinclude $(obj).depend | |
| 32 | + | |
| 33 | +######################################################################## |
drivers/power/mfd/fg_max77693.c
| 1 | +/* | |
| 2 | + * Copyright (C) 2013 Samsung Electronics | |
| 3 | + * Piotr Wilczek <p.wilczek@samsung.com> | |
| 4 | + * | |
| 5 | + * SPDX-License-Identifier: GPL-2.0+ | |
| 6 | + */ | |
| 7 | + | |
| 8 | +#include <common.h> | |
| 9 | +#include <power/pmic.h> | |
| 10 | +#include <power/max77693_fg.h> | |
| 11 | +#include <i2c.h> | |
| 12 | +#include <power/power_chrg.h> | |
| 13 | +#include <power/battery.h> | |
| 14 | +#include <power/fg_battery_cell_params.h> | |
| 15 | +#include <errno.h> | |
| 16 | + | |
| 17 | +static int max77693_get_vcell(u32 *vcell) | |
| 18 | +{ | |
| 19 | + u16 value; | |
| 20 | + u8 ret; | |
| 21 | + | |
| 22 | + ret = i2c_read(MAX77693_FUEL_I2C_ADDR, MAX77693_VCELL, 1, | |
| 23 | + (u8 *)&value, 2); | |
| 24 | + if (ret) | |
| 25 | + return ret; | |
| 26 | + | |
| 27 | + *vcell = (u32)(value >> 3); | |
| 28 | + *vcell = *vcell * 625; | |
| 29 | + | |
| 30 | + return 0; | |
| 31 | +} | |
| 32 | + | |
| 33 | +static int max77693_get_soc(u32 *soc) | |
| 34 | +{ | |
| 35 | + u16 value; | |
| 36 | + u8 ret; | |
| 37 | + | |
| 38 | + ret = i2c_read(MAX77693_FUEL_I2C_ADDR, MAX77693_VFSOC, 1, | |
| 39 | + (u8 *)&value, 2); | |
| 40 | + if (ret) | |
| 41 | + return ret; | |
| 42 | + | |
| 43 | + *soc = (u32)(value >> 8); | |
| 44 | + | |
| 45 | + return 0; | |
| 46 | +} | |
| 47 | + | |
| 48 | +static int power_update_battery(struct pmic *p, struct pmic *bat) | |
| 49 | +{ | |
| 50 | + struct power_battery *pb = bat->pbat; | |
| 51 | + int ret; | |
| 52 | + | |
| 53 | + if (pmic_probe(p)) { | |
| 54 | + puts("Can't find max77693 fuel gauge\n"); | |
| 55 | + return -1; | |
| 56 | + } | |
| 57 | + | |
| 58 | + ret = max77693_get_soc(&pb->bat->state_of_chrg); | |
| 59 | + if (ret) | |
| 60 | + return ret; | |
| 61 | + | |
| 62 | + max77693_get_vcell(&pb->bat->voltage_uV); | |
| 63 | + if (ret) | |
| 64 | + return ret; | |
| 65 | + | |
| 66 | + return 0; | |
| 67 | +} | |
| 68 | + | |
| 69 | +static int power_check_battery(struct pmic *p, struct pmic *bat) | |
| 70 | +{ | |
| 71 | + struct power_battery *pb = bat->pbat; | |
| 72 | + unsigned int val; | |
| 73 | + int ret = 0; | |
| 74 | + | |
| 75 | + if (pmic_probe(p)) { | |
| 76 | + puts("Can't find max77693 fuel gauge\n"); | |
| 77 | + return -1; | |
| 78 | + } | |
| 79 | + | |
| 80 | + ret = pmic_reg_read(p, MAX77693_STATUS, &val); | |
| 81 | + if (ret) | |
| 82 | + return ret; | |
| 83 | + debug("fg status: 0x%x\n", val); | |
| 84 | + | |
| 85 | + ret = pmic_reg_read(p, MAX77693_VERSION, &pb->bat->version); | |
| 86 | + if (ret) | |
| 87 | + return ret; | |
| 88 | + | |
| 89 | + ret = power_update_battery(p, bat); | |
| 90 | + if (ret) | |
| 91 | + return ret; | |
| 92 | + debug("fg ver: 0x%x\n", pb->bat->version); | |
| 93 | + printf("BAT: state_of_charge(SOC):%d%%\n", | |
| 94 | + pb->bat->state_of_chrg); | |
| 95 | + | |
| 96 | + printf(" voltage: %d.%6.6d [V] (expected to be %d [mAh])\n", | |
| 97 | + pb->bat->voltage_uV / 1000000, | |
| 98 | + pb->bat->voltage_uV % 1000000, | |
| 99 | + pb->bat->capacity); | |
| 100 | + | |
| 101 | + if (pb->bat->voltage_uV > 3850000) | |
| 102 | + pb->bat->state = EXT_SOURCE; | |
| 103 | + else if (pb->bat->voltage_uV < 3600000 || pb->bat->state_of_chrg < 5) | |
| 104 | + pb->bat->state = CHARGE; | |
| 105 | + else | |
| 106 | + pb->bat->state = NORMAL; | |
| 107 | + | |
| 108 | + return 0; | |
| 109 | +} | |
| 110 | + | |
| 111 | +static struct power_fg power_fg_ops = { | |
| 112 | + .fg_battery_check = power_check_battery, | |
| 113 | + .fg_battery_update = power_update_battery, | |
| 114 | +}; | |
| 115 | + | |
| 116 | +int power_fg_init(unsigned char bus) | |
| 117 | +{ | |
| 118 | + static const char name[] = "MAX77693_FG"; | |
| 119 | + struct pmic *p = pmic_alloc(); | |
| 120 | + | |
| 121 | + if (!p) { | |
| 122 | + printf("%s: POWER allocation error!\n", __func__); | |
| 123 | + return -ENOMEM; | |
| 124 | + } | |
| 125 | + | |
| 126 | + debug("Board Fuel Gauge init\n"); | |
| 127 | + | |
| 128 | + p->name = name; | |
| 129 | + p->interface = PMIC_I2C; | |
| 130 | + p->number_of_regs = FG_NUM_OF_REGS; | |
| 131 | + p->hw.i2c.addr = MAX77693_FUEL_I2C_ADDR; | |
| 132 | + p->hw.i2c.tx_num = 2; | |
| 133 | + p->sensor_byte_order = PMIC_SENSOR_BYTE_ORDER_BIG; | |
| 134 | + p->bus = bus; | |
| 135 | + | |
| 136 | + p->fg = &power_fg_ops; | |
| 137 | + | |
| 138 | + return 0; | |
| 139 | +} |
drivers/power/mfd/muic_max77693.c
| 1 | +/* | |
| 2 | + * Copyright (C) 2013 Samsung Electronics | |
| 3 | + * Piotr Wilczek <p.wilczek@samsung.com> | |
| 4 | + * | |
| 5 | + * SPDX-License-Identifier: GPL-2.0+ | |
| 6 | + */ | |
| 7 | + | |
| 8 | +#include <common.h> | |
| 9 | +#include <power/pmic.h> | |
| 10 | +#include <power/power_chrg.h> | |
| 11 | +#include <power/max77693_muic.h> | |
| 12 | +#include <i2c.h> | |
| 13 | +#include <errno.h> | |
| 14 | + | |
| 15 | +static int power_chrg_get_type(struct pmic *p) | |
| 16 | +{ | |
| 17 | + unsigned int val; | |
| 18 | + unsigned int charge_type, charger; | |
| 19 | + | |
| 20 | + /* if probe failed, return cable none */ | |
| 21 | + if (pmic_probe(p)) | |
| 22 | + return CHARGER_NO; | |
| 23 | + | |
| 24 | + pmic_reg_read(p, MAX77693_MUIC_STATUS2, &val); | |
| 25 | + | |
| 26 | + charge_type = val & MAX77693_MUIC_CHG_MASK; | |
| 27 | + | |
| 28 | + switch (charge_type) { | |
| 29 | + case MAX77693_MUIC_CHG_NO: | |
| 30 | + charger = CHARGER_NO; | |
| 31 | + break; | |
| 32 | + case MAX77693_MUIC_CHG_USB: | |
| 33 | + case MAX77693_MUIC_CHG_USB_D: | |
| 34 | + charger = CHARGER_USB; | |
| 35 | + break; | |
| 36 | + case MAX77693_MUIC_CHG_TA: | |
| 37 | + case MAX77693_MUIC_CHG_TA_1A: | |
| 38 | + charger = CHARGER_TA; | |
| 39 | + break; | |
| 40 | + case MAX77693_MUIC_CHG_TA_500: | |
| 41 | + charger = CHARGER_TA_500; | |
| 42 | + break; | |
| 43 | + default: | |
| 44 | + charger = CHARGER_UNKNOWN; | |
| 45 | + break; | |
| 46 | + } | |
| 47 | + | |
| 48 | + return charger; | |
| 49 | +} | |
| 50 | + | |
| 51 | +static struct power_chrg power_chrg_muic_ops = { | |
| 52 | + .chrg_type = power_chrg_get_type, | |
| 53 | +}; | |
| 54 | + | |
| 55 | +int power_muic_init(unsigned int bus) | |
| 56 | +{ | |
| 57 | + static const char name[] = "MAX77693_MUIC"; | |
| 58 | + struct pmic *p = pmic_alloc(); | |
| 59 | + | |
| 60 | + if (!p) { | |
| 61 | + printf("%s: POWER allocation error!\n", __func__); | |
| 62 | + return -ENOMEM; | |
| 63 | + } | |
| 64 | + | |
| 65 | + debug("Board Micro USB Interface Controller init\n"); | |
| 66 | + | |
| 67 | + p->name = name; | |
| 68 | + p->interface = PMIC_I2C; | |
| 69 | + p->number_of_regs = MUIC_NUM_OF_REGS; | |
| 70 | + p->hw.i2c.addr = MAX77693_MUIC_I2C_ADDR; | |
| 71 | + p->hw.i2c.tx_num = 1; | |
| 72 | + p->bus = bus; | |
| 73 | + | |
| 74 | + p->chrg = &power_chrg_muic_ops; | |
| 75 | + | |
| 76 | + return 0; | |
| 77 | +} |
drivers/power/mfd/pmic_max77693.c
| 1 | +/* | |
| 2 | + * Copyright (C) 2013 Samsung Electronics | |
| 3 | + * Piotr Wilczek <p.wilczek@samsung.com> | |
| 4 | + * | |
| 5 | + * SPDX-License-Identifier: GPL-2.0+ | |
| 6 | + */ | |
| 7 | + | |
| 8 | +#include <common.h> | |
| 9 | +#include <power/pmic.h> | |
| 10 | +#include <power/max77693_pmic.h> | |
| 11 | +#include <i2c.h> | |
| 12 | +#include <errno.h> | |
| 13 | + | |
| 14 | +static int max77693_charger_state(struct pmic *p, int state, int current) | |
| 15 | +{ | |
| 16 | + unsigned int val; | |
| 17 | + | |
| 18 | + if (pmic_probe(p)) | |
| 19 | + return -1; | |
| 20 | + | |
| 21 | + /* unlock write capability */ | |
| 22 | + val = MAX77693_CHG_UNLOCK; | |
| 23 | + pmic_reg_write(p, MAX77693_CHG_CNFG_06, val); | |
| 24 | + | |
| 25 | + if (state == CHARGER_DISABLE) { | |
| 26 | + puts("Disable the charger.\n"); | |
| 27 | + pmic_reg_read(p, MAX77693_CHG_CNFG_00, &val); | |
| 28 | + val &= ~0x01; | |
| 29 | + pmic_reg_write(p, MAX77693_CHG_CNFG_00, val); | |
| 30 | + return -1; | |
| 31 | + } | |
| 32 | + | |
| 33 | + if (current < CHARGER_MIN_CURRENT || current > CHARGER_MAX_CURRENT) { | |
| 34 | + printf("%s: Wrong charge current: %d [mA]\n", | |
| 35 | + __func__, current); | |
| 36 | + return -1; | |
| 37 | + } | |
| 38 | + | |
| 39 | + /* set charging current */ | |
| 40 | + pmic_reg_read(p, MAX77693_CHG_CNFG_02, &val); | |
| 41 | + val &= ~MAX77693_CHG_CC; | |
| 42 | + val |= current * 10 / 333; /* 0.1A/3 steps */ | |
| 43 | + pmic_reg_write(p, MAX77693_CHG_CNFG_02, val); | |
| 44 | + | |
| 45 | + /* enable charging */ | |
| 46 | + val = MAX77693_CHG_MODE_ON; | |
| 47 | + pmic_reg_write(p, MAX77693_CHG_CNFG_00, val); | |
| 48 | + | |
| 49 | + /* check charging current */ | |
| 50 | + pmic_reg_read(p, MAX77693_CHG_CNFG_02, &val); | |
| 51 | + val &= 0x3f; | |
| 52 | + printf("Enable the charger @ %d [mA]\n", val * 333 / 10); | |
| 53 | + | |
| 54 | + return 0; | |
| 55 | +} | |
| 56 | + | |
| 57 | +static int max77693_charger_bat_present(struct pmic *p) | |
| 58 | +{ | |
| 59 | + unsigned int val; | |
| 60 | + | |
| 61 | + if (pmic_probe(p)) | |
| 62 | + return -1; | |
| 63 | + | |
| 64 | + pmic_reg_read(p, MAX77693_CHG_INT_OK, &val); | |
| 65 | + | |
| 66 | + return !(val & MAX77693_CHG_DETBAT); | |
| 67 | +} | |
| 68 | + | |
| 69 | +static struct power_chrg power_chrg_pmic_ops = { | |
| 70 | + .chrg_bat_present = max77693_charger_bat_present, | |
| 71 | + .chrg_state = max77693_charger_state, | |
| 72 | +}; | |
| 73 | + | |
| 74 | +int pmic_init_max77693(unsigned char bus) | |
| 75 | +{ | |
| 76 | + static const char name[] = "MAX77693_PMIC"; | |
| 77 | + struct pmic *p = pmic_alloc(); | |
| 78 | + | |
| 79 | + if (!p) { | |
| 80 | + printf("%s: POWER allocation error!\n", __func__); | |
| 81 | + return -ENOMEM; | |
| 82 | + } | |
| 83 | + | |
| 84 | + debug("Board PMIC init\n"); | |
| 85 | + | |
| 86 | + p->name = name; | |
| 87 | + p->interface = PMIC_I2C; | |
| 88 | + p->number_of_regs = PMIC_NUM_OF_REGS; | |
| 89 | + p->hw.i2c.addr = MAX77693_PMIC_I2C_ADDR; | |
| 90 | + p->hw.i2c.tx_num = 1; | |
| 91 | + p->bus = bus; | |
| 92 | + | |
| 93 | + p->chrg = &power_chrg_pmic_ops; | |
| 94 | + | |
| 95 | + return 0; | |
| 96 | +} |
include/power/max77693_fg.h
| 1 | +/* | |
| 2 | + * Copyright (C) 2013 Samsung Electronics | |
| 3 | + * Piotr Wilczek <p.wilczek@samsung.com> | |
| 4 | + * | |
| 5 | + * SPDX-License-Identifier: GPL-2.0+ | |
| 6 | + */ | |
| 7 | + | |
| 8 | +#ifndef __MAX77693_FG_H_ | |
| 9 | +#define __MAX77693_FG_H_ | |
| 10 | + | |
| 11 | +/* MAX 77693 registers */ | |
| 12 | +enum { | |
| 13 | + MAX77693_STATUS = 0x00, | |
| 14 | + MAX77693_SOCREP = 0x06, | |
| 15 | + MAX77693_VCELL = 0x09, | |
| 16 | + MAX77693_CURRENT = 0x0A, | |
| 17 | + MAX77693_AVG_CURRENT = 0x0B, | |
| 18 | + MAX77693_SOCMIX = 0x0D, | |
| 19 | + MAX77693_SOCAV = 0x0E, | |
| 20 | + MAX77693_DESIGN_CAP = 0x18, | |
| 21 | + MAX77693_AVG_VCELL = 0x19, | |
| 22 | + MAX77693_CONFIG = 0x1D, | |
| 23 | + MAX77693_VERSION = 0x21, | |
| 24 | + MAX77693_LEARNCFG = 0x28, | |
| 25 | + MAX77693_FILTERCFG = 0x29, | |
| 26 | + MAX77693_RELAXCFG = 0x2A, | |
| 27 | + MAX77693_MISCCFG = 0x2B, | |
| 28 | + MAX77693_CGAIN = 0x2E, | |
| 29 | + MAX77693_COFF = 0x2F, | |
| 30 | + MAX77693_RCOMP0 = 0x38, | |
| 31 | + MAX77693_TEMPCO = 0x39, | |
| 32 | + MAX77693_FSTAT = 0x3D, | |
| 33 | + MAX77693_VFOCV = 0xEE, | |
| 34 | + MAX77693_VFSOC = 0xFF, | |
| 35 | + | |
| 36 | + FG_NUM_OF_REGS = 0x100, | |
| 37 | +}; | |
| 38 | + | |
| 39 | +#define MAX77693_POR (1 << 1) | |
| 40 | + | |
| 41 | +#define MODEL_UNLOCK1 0x0059 | |
| 42 | +#define MODEL_UNLOCK2 0x00c4 | |
| 43 | +#define MODEL_LOCK1 0x0000 | |
| 44 | +#define MODEL_LOCK2 0x0000 | |
| 45 | + | |
| 46 | +#define MAX77693_FUEL_I2C_ADDR (0x6C >> 1) | |
| 47 | + | |
| 48 | +int power_fg_init(unsigned char bus); | |
| 49 | +#endif /* __MAX77693_FG_H_ */ |
include/power/max77693_muic.h
| 1 | +/* | |
| 2 | + * Copyright (C) 2013 Samsung Electronics | |
| 3 | + * Piotr Wilczek <p.wilczek@samsung.com> | |
| 4 | + * | |
| 5 | + * SPDX-License-Identifier: GPL-2.0+ | |
| 6 | + */ | |
| 7 | + | |
| 8 | +#ifndef __MAX77693_MUIC_H_ | |
| 9 | +#define __MAX77693_MUIC_H_ | |
| 10 | + | |
| 11 | +#include <power/power_chrg.h> | |
| 12 | + | |
| 13 | +/* | |
| 14 | + * MUIC REGISTER | |
| 15 | + */ | |
| 16 | + | |
| 17 | +#define MAX77693_MUIC_PREFIX "max77693-muic:" | |
| 18 | + | |
| 19 | +/* MAX77693_MUIC_STATUS1 */ | |
| 20 | +#define MAX77693_MUIC_ADC_MASK 0x1F | |
| 21 | + | |
| 22 | +/* MAX77693_MUIC_STATUS2 */ | |
| 23 | +#define MAX77693_MUIC_CHG_NO 0x00 | |
| 24 | +#define MAX77693_MUIC_CHG_USB 0x01 | |
| 25 | +#define MAX77693_MUIC_CHG_USB_D 0x02 | |
| 26 | +#define MAX77693_MUIC_CHG_TA 0x03 | |
| 27 | +#define MAX77693_MUIC_CHG_TA_500 0x04 | |
| 28 | +#define MAX77693_MUIC_CHG_TA_1A 0x05 | |
| 29 | +#define MAX77693_MUIC_CHG_MASK 0x07 | |
| 30 | + | |
| 31 | +/* MAX77693_MUIC_CONTROL1 */ | |
| 32 | +#define MAX77693_MUIC_CTRL1_DN1DP2 ((0x1 << 3) | 0x1) | |
| 33 | +#define MAX77693_MUIC_CTRL1_UT1UR2 ((0x3 << 3) | 0x3) | |
| 34 | +#define MAX77693_MUIC_CTRL1_ADN1ADP2 ((0x4 << 3) | 0x4) | |
| 35 | +#define MAX77693_MUIC_CTRL1_AUT1AUR2 ((0x5 << 3) | 0x5) | |
| 36 | +#define MAX77693_MUIC_CTRL1_MASK 0xC0 | |
| 37 | + | |
| 38 | +#define MUIC_PATH_USB 0 | |
| 39 | +#define MUIC_PATH_UART 1 | |
| 40 | + | |
| 41 | +#define MUIC_PATH_CP 0 | |
| 42 | +#define MUIC_PATH_AP 1 | |
| 43 | + | |
| 44 | +enum muic_path { | |
| 45 | + MUIC_PATH_USB_CP, | |
| 46 | + MUIC_PATH_USB_AP, | |
| 47 | + MUIC_PATH_UART_CP, | |
| 48 | + MUIC_PATH_UART_AP, | |
| 49 | +}; | |
| 50 | + | |
| 51 | +/* MAX 777693 MUIC registers */ | |
| 52 | +enum { | |
| 53 | + MAX77693_MUIC_ID = 0x00, | |
| 54 | + MAX77693_MUIC_INT1 = 0x01, | |
| 55 | + MAX77693_MUIC_INT2 = 0x02, | |
| 56 | + MAX77693_MUIC_INT3 = 0x03, | |
| 57 | + MAX77693_MUIC_STATUS1 = 0x04, | |
| 58 | + MAX77693_MUIC_STATUS2 = 0x05, | |
| 59 | + MAX77693_MUIC_STATUS3 = 0x06, | |
| 60 | + MAX77693_MUIC_INTMASK1 = 0x07, | |
| 61 | + MAX77693_MUIC_INTMASK2 = 0x08, | |
| 62 | + MAX77693_MUIC_INTMASK3 = 0x09, | |
| 63 | + MAX77693_MUIC_CDETCTRL = 0x0A, | |
| 64 | + MAX77693_MUIC_CONTROL1 = 0x0C, | |
| 65 | + MAX77693_MUIC_CONTROL2 = 0x0D, | |
| 66 | + MAX77693_MUIC_CONTROL3 = 0x0E, | |
| 67 | + | |
| 68 | + MUIC_NUM_OF_REGS = 0x0F, | |
| 69 | +}; | |
| 70 | + | |
| 71 | +#define MAX77693_MUIC_I2C_ADDR (0x4A >> 1) | |
| 72 | + | |
| 73 | +int power_muic_init(unsigned int bus); | |
| 74 | +#endif /* __MAX77693_MUIC_H_ */ |
include/power/max77693_pmic.h
| 1 | +/* | |
| 2 | + * Copyright (C) 2013 Samsung Electronics | |
| 3 | + * Piotr Wilczek <p.wilczek@samsung.com> | |
| 4 | + * | |
| 5 | + * SPDX-License-Identifier: GPL-2.0+ | |
| 6 | + */ | |
| 7 | + | |
| 8 | +#ifndef __MAX77693_PMIC_H_ | |
| 9 | +#define __MAX77693_PMIC_H_ | |
| 10 | + | |
| 11 | +#include <power/power_chrg.h> | |
| 12 | + | |
| 13 | +enum {CHARGER_ENABLE, CHARGER_DISABLE}; | |
| 14 | + | |
| 15 | +#define CHARGER_MIN_CURRENT 200 | |
| 16 | +#define CHARGER_MAX_CURRENT 2000 | |
| 17 | + | |
| 18 | +#define MAX77693_CHG_PREFIX "max77693-chg:" | |
| 19 | + | |
| 20 | +/* Registers */ | |
| 21 | + | |
| 22 | +#define MAX77693_CHG_BASE 0xB0 | |
| 23 | +#define MAX77693_CHG_INT_OK 0xB2 | |
| 24 | +#define MAX77693_CHG_CNFG_00 0xB7 | |
| 25 | +#define MAX77693_CHG_CNFG_02 0xB9 | |
| 26 | +#define MAX77693_CHG_CNFG_06 0xBD | |
| 27 | +#define MAX77693_SAFEOUT 0xC6 | |
| 28 | + | |
| 29 | +#define PMIC_NUM_OF_REGS 0xC7 | |
| 30 | + | |
| 31 | +#define MAX77693_CHG_DETBAT (0x1 << 7) /* MAX77693_CHG_INT_OK */ | |
| 32 | +#define MAX77693_CHG_MODE_ON 0x05 /* MAX77693_CHG_CNFG_00 */ | |
| 33 | +#define MAX77693_CHG_CC 0x3F /* MAX77693_CHG_CNFG_02 */ | |
| 34 | +#define MAX77693_CHG_LOCK (0x0 << 2) /* MAX77693_CHG_CNFG_06 */ | |
| 35 | +#define MAX77693_CHG_UNLOCK (0x3 << 2) /* MAX77693_CHG_CNFG_06 */ | |
| 36 | + | |
| 37 | +#define MAX77693_ENSAFEOUT1 (1 << 6) | |
| 38 | +#define MAX77693_ENSAFEOUT2 (1 << 7) | |
| 39 | + | |
| 40 | +#define MAX77693_PMIC_I2C_ADDR (0xCC >> 1) | |
| 41 | + | |
| 42 | +int pmic_init_max77693(unsigned char bus); | |
| 43 | +#endif /* __MAX77693_PMIC_H_ */ |