Hi,
This patchset adds support for MAX77836 device to the max14577 driver.
The MAX77836 is almost the same as MAX14577. Basically it is an extended
version of MAX14577. The chipsets have same MUIC component so the extcon,
charger and regulators require only little adjustments. More changes were
needed in the charger (because it uses lower charging current) and regulator
drivers (because mentioned different charing current and additional
regulators). The MAX77836 has also PMIC and Fuel Gauge (which is the same
as MAX17040/17048 Fuel Gauge).
The MAX77836 uses three I2C slave addresses and has additional interrupts
(related to PMIC and Fuel Gauge). It has also Interrupt Source register,
just like MAX77686 and MAX77693.
The patchset is organized in following way:
1. Patches from 1 to 6 clean up the max14577 drivers and add minor tweaks.
2. Patches from 7 to 12 prepare the driver for supporting MAX77836. They
mostly rename symbols and add additional logic related to different
deviec types.
3. Patches from 13 to 17 add support for MAX77836.
4. Patch 18 adds bindings documentation, which was not merged previously.
Here I tried to address also Tomasz Figa's comments from review.
The patchset is based on current Linus' tree (v3.13-8789-g54c0a4b46150).
Testing was done on 3.10.
TODO: Merge max14577, max77686 and max77693 into one common driver. They are
very similar.
Best regards,
Krzysztof Kozlowski
Chanwoo Choi (1):
extcon: max14577: Change extcon name instead of static name according
to device type
Krzysztof Kozlowski (17):
regulator: max14577: Remove unused state container definition
mfd: max14577: Remove unused enum max14577_irq_source
mfd: max14577: Remove not needed header inclusion
mfd: max14577: Add of_compatible to extcon mfd_cell
mfd: max14577: Use of_match_ptr() in i2c_driver
mfd: max14577: Rename and add MAX14577 symbols to prepare for
max77836
mfd: max14577: Rename state container to maxim_core
mfd: max14577: Add "muic" suffix to regmap and irq_chip
mfd: max14577: Add detection of device type
extcon: max14577: Add max14577 prefix to muic_irqs
extcon: max14577: Choose muic_irqs according to device type
mfd: max77836: Add max77836 support to max14577 driver
extcon: max14577: Add support for max77836
regulator: max14577: Add support for max77836 regulators
charger: max14577: Add support for MAX77836 charger
power: max17040: Add ID for max77836 Fuel Gauge block
mfd: max14577: Add device tree bindings document
Documentation/devicetree/bindings/mfd/max14577.txt | 104 ++++
drivers/extcon/extcon-max14577.c | 272 ++++++----
drivers/mfd/max14577.c | 377 ++++++++++---
drivers/power/max14577_charger.c | 170 +++---
drivers/power/max17040_battery.c | 1 +
drivers/regulator/max14577.c | 323 ++++++++---
include/linux/mfd/max14577-private.h | 565 ++++++++++++--------
include/linux/mfd/max14577.h | 24 +-
8 files changed, 1313 insertions(+), 523 deletions(-)
create mode 100644 Documentation/devicetree/bindings/mfd/max14577.txt
--
1.7.9.5
Remove not needed max14577-private.h header inclusion in the main driver
header. Remove obvious comment.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: Marek Szyprowski <[email protected]>
---
include/linux/mfd/max14577.h | 5 -----
1 file changed, 5 deletions(-)
diff --git a/include/linux/mfd/max14577.h b/include/linux/mfd/max14577.h
index 247b021dfaaf..736d39c3ec0d 100644
--- a/include/linux/mfd/max14577.h
+++ b/include/linux/mfd/max14577.h
@@ -25,13 +25,8 @@
#ifndef __MAX14577_H__
#define __MAX14577_H__
-#include <linux/mfd/max14577-private.h>
#include <linux/regulator/consumer.h>
-/*
- * MAX14577 Regulator
- */
-
/* MAX14577 regulator IDs */
enum max14577_regulators {
MAX14577_SAFEOUT = 0,
--
1.7.9.5
Remove the "struct max14577_regulator" because this is not used
anywhere. It should be removed earlier along with changing the driver
after review on the mailing lists.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: Marek Szyprowski <[email protected]>
---
drivers/regulator/max14577.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/regulator/max14577.c b/drivers/regulator/max14577.c
index b1078ba3f393..38821458d413 100644
--- a/drivers/regulator/max14577.c
+++ b/drivers/regulator/max14577.c
@@ -1,7 +1,7 @@
/*
* max14577.c - Regulator driver for the Maxim 14577
*
- * Copyright (C) 2013 Samsung Electronics
+ * Copyright (C) 2013,2014 Samsung Electronics
* Krzysztof Kozlowski <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
@@ -22,12 +22,6 @@
#include <linux/mfd/max14577-private.h>
#include <linux/regulator/of_regulator.h>
-struct max14577_regulator {
- struct device *dev;
- struct max14577 *max14577;
- struct regulator_dev **regulators;
-};
-
static int max14577_reg_is_enabled(struct regulator_dev *rdev)
{
int rid = rdev_get_id(rdev);
--
1.7.9.5
MAX77836 has the same Fuel Gauge as MAX17040. The max17040 driver can be
safely re-used. The patch adds MAX77836 ID to array with i2c_device_id.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: Marek Szyprowski <[email protected]>
Cc: Anton Vorontsov <[email protected]>
Cc: Dmitry Eremin-Solenikov <[email protected]>
Cc: David Woodhouse <[email protected]>
---
drivers/power/max17040_battery.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/power/max17040_battery.c b/drivers/power/max17040_battery.c
index c7ff6d67f158..591984a93f9f 100644
--- a/drivers/power/max17040_battery.c
+++ b/drivers/power/max17040_battery.c
@@ -277,6 +277,7 @@ static SIMPLE_DEV_PM_OPS(max17040_pm_ops, max17040_suspend, max17040_resume);
static const struct i2c_device_id max17040_id[] = {
{ "max17040", 0 },
+ { "max77836-battery", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, max17040_id);
--
1.7.9.5
Add document describing device tree bindings for MAX14577 MFD driver
(for both MAX14577 and MAX77836 chipsets).
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: Tomasz Figa <[email protected]>
Cc: Marek Szyprowski <[email protected]>
Cc: [email protected]
Cc: Rob Herring <[email protected]>
Cc: Pawel Moll <[email protected]>
Cc: Mark Rutland <[email protected]>
---
Documentation/devicetree/bindings/mfd/max14577.txt | 104 ++++++++++++++++++++
1 file changed, 104 insertions(+)
create mode 100644 Documentation/devicetree/bindings/mfd/max14577.txt
diff --git a/Documentation/devicetree/bindings/mfd/max14577.txt b/Documentation/devicetree/bindings/mfd/max14577.txt
new file mode 100644
index 000000000000..cb758f84be00
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/max14577.txt
@@ -0,0 +1,104 @@
+Maxim MAX14577/77836 Multi-Function Device
+
+MAX14577 is a Multi-Function Device with Micro-USB Interface Circuit, Li+
+Battery Charger and SFOUT LDO output for powering USB devices. It is
+interfaced to host controller using I2C.
+
+MAX77836 additionally contains PMIC (with two LDO regulators) and Fuel Gauge.
+
+
+Required properties:
+- compatible : Must be "maxim,max14577" or "maxim,max77836".
+- reg : I2C slave address for the max14577 chip (0x25 for max14577/max77836)
+- interrupts : IRQ line for the chip.
+- interrupt-parent : The parent interrupt controller.
+
+
+Optional nodes:
+- max14577-muic/max77836-muic :
+ Node used only by extcon consumers.
+ Required properties:
+ - compatible : "maxim,max14577-muic" or "maxim,max77836-muic"
+
+- regulators :
+ Required properties:
+ - compatible : "maxim,max14577-regulator"
+ or "maxim,max77836-regulator"
+
+ May contain a sub-node per regulator from the list below. Each
+ sub-node should contain the constraints and initialization information
+ for that regulator. See regulator.txt for a description of standard
+ properties for these sub-nodes.
+
+ List of valid regulator names:
+ - for max14577: CHARGER, SAFEOUT.
+ - for max77836: CHARGER, SAFEOUT, LDO1, LDO2.
+
+ The SAFEOUT is a fixed voltage regulator so there is no need to specify
+ voltages for it.
+
+
+Example:
+
+#include <dt-bindings/interrupt-controller/irq.h>
+
+max14577@25 {
+ compatible = "maxim,max14577";
+ reg = <0x25>;
+ interrupt-parent = <&gpx1>;
+ interrupts = <5 IRQ_TYPE_NONE>;
+
+ muic: max14577-muic {
+ compatible = "maxim,max14577-muic";
+ };
+
+ regulators {
+ compatible = "maxim,max14577-regulator";
+
+ SAFEOUT {
+ regulator-name = "SAFEOUT";
+ };
+ CHARGER {
+ regulator-name = "CHARGER";
+ regulator-min-microamp = <90000>;
+ regulator-max-microamp = <950000>;
+ regulator-boot-on;
+ };
+ };
+};
+
+
+max77836@25 {
+ compatible = "maxim,max77836";
+ reg = <0x25>;
+ interrupt-parent = <&gpx1>;
+ interrupts = <5 IRQ_TYPE_NONE>;
+
+ muic: max77836-muic {
+ compatible = "maxim,max77836-muic";
+ };
+
+ regulators {
+ compatible = "maxim,max77836-regulator";
+
+ SAFEOUT {
+ regulator-name = "SAFEOUT";
+ };
+ CHARGER {
+ regulator-name = "CHARGER";
+ regulator-min-microamp = <90000>;
+ regulator-max-microamp = <950000>;
+ regulator-boot-on;
+ };
+ LDO1 {
+ regulator-name = "LDO1";
+ regulator-min-microvolt = <2700000>;
+ regulator-max-microvolt = <2700000>;
+ };
+ LDO2 {
+ regulator-name = "LDO2";
+ regulator-min-microvolt = <800000>;
+ regulator-max-microvolt = <3950000>;
+ };
+ };
+};
--
1.7.9.5
Add support for MAX77836 chipset and its additional two LDO regulators.
These LDO regulators are controlled by the PMIC block with additional
regmap (different I2C slave address).
The MAX77836 charger and safeout regulators are almost identical to
MAX14577. The registry layout is the same, except values for charger's
current. The patch adds simple mapping between device type and supported
current by the charger regulator.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: Marek Szyprowski <[email protected]>
---
drivers/regulator/max14577.c | 275 +++++++++++++++++++++++++++++-----
include/linux/mfd/max14577-private.h | 32 +++-
include/linux/mfd/max14577.h | 10 ++
3 files changed, 281 insertions(+), 36 deletions(-)
diff --git a/drivers/regulator/max14577.c b/drivers/regulator/max14577.c
index 8856c660a5da..7150606ac482 100644
--- a/drivers/regulator/max14577.c
+++ b/drivers/regulator/max14577.c
@@ -1,5 +1,5 @@
/*
- * max14577.c - Regulator driver for the Maxim 14577
+ * max14577.c - Regulator driver for the Maxim 14577/77836
*
* Copyright (C) 2013,2014 Samsung Electronics
* Krzysztof Kozlowski <[email protected]>
@@ -22,6 +22,42 @@
#include <linux/mfd/max14577-private.h>
#include <linux/regulator/of_regulator.h>
+/*
+ * Valid limits of current for max14577 and max77836 chargers.
+ * They must correspond to MBCICHWRCL and MBCICHWRCH fields in CHGCTRL4
+ * register for given chipset.
+ */
+struct maxim_charger_current {
+ /* Minimal current, set in CHGCTRL4/MBCICHWRCL, uA */
+ unsigned int min;
+ /*
+ * Minimal current when high setting is active,
+ * set in CHGCTRL4/MBCICHWRCH, uA
+ */
+ unsigned int high_start;
+ /* Value of one step in high setting, uA */
+ unsigned int high_step;
+ /* Maximum current of high setting, uA */
+ unsigned int max;
+};
+
+/* Table of valid charger currents for different Maxim chipsets */
+static const struct maxim_charger_current maxim_charger_currents[] = {
+ [MAXIM_DEVICE_TYPE_UNKNOWN] = { 0, 0, 0, 0 },
+ [MAXIM_DEVICE_TYPE_MAX14577] = {
+ .min = MAX14577_REGULATOR_CURRENT_LIMIT_MIN,
+ .high_start = MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_START,
+ .high_step = MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_STEP,
+ .max = MAX14577_REGULATOR_CURRENT_LIMIT_MAX,
+ },
+ [MAXIM_DEVICE_TYPE_MAX77836] = {
+ .min = MAX77836_REGULATOR_CURRENT_LIMIT_MIN,
+ .high_start = MAX77836_REGULATOR_CURRENT_LIMIT_HIGH_START,
+ .high_step = MAX77836_REGULATOR_CURRENT_LIMIT_HIGH_STEP,
+ .max = MAX77836_REGULATOR_CURRENT_LIMIT_MAX,
+ },
+};
+
static int max14577_reg_is_enabled(struct regulator_dev *rdev)
{
int rid = rdev_get_id(rdev);
@@ -47,6 +83,9 @@ static int max14577_reg_get_current_limit(struct regulator_dev *rdev)
{
u8 reg_data;
struct regmap *rmap = rdev->regmap;
+ struct maxim_core *maxim_core = rdev_get_drvdata(rdev);
+ const struct maxim_charger_current *limits =
+ &maxim_charger_currents[maxim_core->dev_type];
if (rdev_get_id(rdev) != MAX14577_CHARGER)
return -EINVAL;
@@ -54,12 +93,11 @@ static int max14577_reg_get_current_limit(struct regulator_dev *rdev)
max14577_read_reg(rmap, MAXIM_CHG_REG_CHGCTRL4, ®_data);
if ((reg_data & MAXIM_CHGCTRL4_MBCICHWRCL_MASK) == 0)
- return MAX14577_REGULATOR_CURRENT_LIMIT_MIN;
+ return limits->min;
reg_data = ((reg_data & MAXIM_CHGCTRL4_MBCICHWRCH_MASK) >>
MAXIM_CHGCTRL4_MBCICHWRCH_SHIFT);
- return MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_START +
- reg_data * MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_STEP;
+ return limits->high_start + reg_data * limits->high_step;
}
static int max14577_reg_set_current_limit(struct regulator_dev *rdev,
@@ -67,33 +105,35 @@ static int max14577_reg_set_current_limit(struct regulator_dev *rdev,
{
int i, current_bits = 0xf;
u8 reg_data;
+ struct maxim_core *maxim_core = rdev_get_drvdata(rdev);
+ const struct maxim_charger_current *limits =
+ &maxim_charger_currents[maxim_core->dev_type];
if (rdev_get_id(rdev) != MAX14577_CHARGER)
return -EINVAL;
- if (min_uA > MAX14577_REGULATOR_CURRENT_LIMIT_MAX ||
- max_uA < MAX14577_REGULATOR_CURRENT_LIMIT_MIN)
+ if (min_uA > limits->max || max_uA < limits->min)
return -EINVAL;
- if (max_uA < MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_START) {
- /* Less than 200 mA, so set 90mA (turn only Low Bit off) */
+ if (max_uA < limits->high_start) {
+ /* Less than high_start,
+ * so set the minimal current (turn only Low Bit off) */
u8 reg_data = 0x0 << MAXIM_CHGCTRL4_MBCICHWRCL_SHIFT;
return max14577_update_reg(rdev->regmap,
MAXIM_CHG_REG_CHGCTRL4,
MAXIM_CHGCTRL4_MBCICHWRCL_MASK, reg_data);
}
- /* max_uA is in range: <LIMIT_HIGH_START, inifinite>, so search for
- * valid current starting from LIMIT_MAX. */
- for (i = MAX14577_REGULATOR_CURRENT_LIMIT_MAX;
- i >= MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_START;
- i -= MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_STEP) {
+ /* max_uA is in range: <high_start, inifinite>, so search for
+ * valid current starting from maximum current. */
+ for (i = limits->max; i >= limits->high_start; i -= limits->high_step) {
if (i <= max_uA)
break;
current_bits--;
}
BUG_ON(current_bits < 0); /* Cannot happen */
- /* Turn Low Bit on (use range 200mA-950 mA) */
+
+ /* Turn Low Bit on (use range high_start-max)... */
reg_data = 0x1 << MAXIM_CHGCTRL4_MBCICHWRCL_SHIFT;
/* and set proper High Bits */
reg_data |= current_bits << MAXIM_CHGCTRL4_MBCICHWRCH_SHIFT;
@@ -118,7 +158,7 @@ static struct regulator_ops max14577_charger_ops = {
.set_current_limit = max14577_reg_set_current_limit,
};
-static const struct regulator_desc supported_regulators[] = {
+static const struct regulator_desc max14577_supported_regulators[] = {
[MAX14577_SAFEOUT] = {
.name = "SAFEOUT",
.id = MAX14577_SAFEOUT,
@@ -141,16 +181,88 @@ static const struct regulator_desc supported_regulators[] = {
},
};
+static struct regulator_ops max77836_ldo_ops = {
+ .is_enabled = regulator_is_enabled_regmap,
+ .enable = regulator_enable_regmap,
+ .disable = regulator_disable_regmap,
+ .list_voltage = regulator_list_voltage_linear,
+ .map_voltage = regulator_map_voltage_linear,
+ .get_voltage_sel = regulator_get_voltage_sel_regmap,
+ .set_voltage_sel = regulator_set_voltage_sel_regmap,
+ /* TODO: add .set_suspend_mode */
+};
+
+static const struct regulator_desc max77836_supported_regulators[] = {
+ [MAX14577_SAFEOUT] = {
+ .name = "SAFEOUT",
+ .id = MAX14577_SAFEOUT,
+ .ops = &max14577_safeout_ops,
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE,
+ .n_voltages = 1,
+ .min_uV = MAX14577_REGULATOR_SAFEOUT_VOLTAGE,
+ .enable_reg = MAXIM_MUIC_REG_CONTROL2,
+ .enable_mask = MAXIM_CONTROL2_SFOUTORD_MASK,
+ },
+ [MAX14577_CHARGER] = {
+ .name = "CHARGER",
+ .id = MAX14577_CHARGER,
+ .ops = &max14577_charger_ops,
+ .type = REGULATOR_CURRENT,
+ .owner = THIS_MODULE,
+ .enable_reg = MAXIM_CHG_REG_CHGCTRL2,
+ .enable_mask = MAXIM_CHGCTRL2_MBCHOSTEN_MASK,
+ },
+ [MAX77836_LDO1] = {
+ .name = "LDO1",
+ .id = MAX77836_LDO1,
+ .ops = &max77836_ldo_ops,
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE,
+ .n_voltages = MAX77836_REGULATOR_LDO_VOLTAGE_STEPS_NUM,
+ .min_uV = MAX77836_REGULATOR_LDO_VOLTAGE_MIN,
+ .uV_step = MAX77836_REGULATOR_LDO_VOLTAGE_STEP,
+ .enable_reg = MAX77836_LDO_REG_CNFG1_LDO1,
+ .enable_mask = MAX77836_CNFG1_LDO_PWRMD_MASK,
+ .vsel_reg = MAX77836_LDO_REG_CNFG1_LDO1,
+ .vsel_mask = MAX77836_CNFG1_LDO_TV_MASK,
+ },
+ [MAX77836_LDO2] = {
+ .name = "LDO2",
+ .id = MAX77836_LDO2,
+ .ops = &max77836_ldo_ops,
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE,
+ .n_voltages = MAX77836_REGULATOR_LDO_VOLTAGE_STEPS_NUM,
+ .min_uV = MAX77836_REGULATOR_LDO_VOLTAGE_MIN,
+ .uV_step = MAX77836_REGULATOR_LDO_VOLTAGE_STEP,
+ .enable_reg = MAX77836_LDO_REG_CNFG1_LDO2,
+ .enable_mask = MAX77836_CNFG1_LDO_PWRMD_MASK,
+ .vsel_reg = MAX77836_LDO_REG_CNFG1_LDO2,
+ .vsel_mask = MAX77836_CNFG1_LDO_TV_MASK,
+ },
+};
+
#ifdef CONFIG_OF
static struct of_regulator_match max14577_regulator_matches[] = {
{ .name = "SAFEOUT", },
{ .name = "CHARGER", },
};
-static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev)
+static struct of_regulator_match max77836_regulator_matches[] = {
+ { .name = "SAFEOUT", },
+ { .name = "CHARGER", },
+ { .name = "LDO1", },
+ { .name = "LDO2", },
+};
+
+static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev,
+ enum maxim_device_type dev_type)
{
int ret;
struct device_node *np;
+ struct of_regulator_match *regulator_matches;
+ unsigned int regulator_matches_size;
np = of_get_child_by_name(pdev->dev.parent->of_node, "regulators");
if (!np) {
@@ -158,8 +270,19 @@ static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev)
return -EINVAL;
}
- ret = of_regulator_match(&pdev->dev, np, max14577_regulator_matches,
- ARRAY_SIZE(max14577_regulator_matches));
+ switch (dev_type) {
+ case MAXIM_DEVICE_TYPE_MAX77836:
+ regulator_matches = max77836_regulator_matches;
+ regulator_matches_size = ARRAY_SIZE(max77836_regulator_matches);
+ break;
+ case MAXIM_DEVICE_TYPE_MAX14577:
+ default:
+ regulator_matches = max14577_regulator_matches;
+ regulator_matches_size = ARRAY_SIZE(max14577_regulator_matches);
+ }
+
+ ret = of_regulator_match(&pdev->dev, np, regulator_matches,
+ regulator_matches_size);
if (ret < 0) {
dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", ret);
return ret;
@@ -168,31 +291,74 @@ static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev)
return 0;
}
-static inline struct regulator_init_data *match_init_data(int index)
+static inline struct regulator_init_data *match_init_data(int index,
+ enum maxim_device_type dev_type)
{
- return max14577_regulator_matches[index].init_data;
+ switch (dev_type) {
+ case MAXIM_DEVICE_TYPE_MAX77836:
+ return max77836_regulator_matches[index].init_data;
+
+ case MAXIM_DEVICE_TYPE_MAX14577:
+ default:
+ return max14577_regulator_matches[index].init_data;
+ }
}
-static inline struct device_node *match_of_node(int index)
+static inline struct device_node *match_of_node(int index,
+ enum maxim_device_type dev_type)
{
- return max14577_regulator_matches[index].of_node;
+ switch (dev_type) {
+ case MAXIM_DEVICE_TYPE_MAX77836:
+ return max77836_regulator_matches[index].of_node;
+
+ case MAXIM_DEVICE_TYPE_MAX14577:
+ default:
+ return max14577_regulator_matches[index].of_node;
+ }
}
#else /* CONFIG_OF */
-static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev)
+static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev,
+ enum maxim_device_type dev_type)
{
return 0;
}
-static inline struct regulator_init_data *match_init_data(int index)
+static inline struct regulator_init_data *match_init_data(int index,
+ enum maxim_device_type dev_type)
{
return NULL;
}
-static inline struct device_node *match_of_node(int index)
+static inline struct device_node *match_of_node(int index,
+ enum maxim_device_type dev_type)
{
return NULL;
}
#endif /* CONFIG_OF */
+/**
+ * Registers for regulators of max77836 use different I2C slave addresses so
+ * different regmaps must be used for them.
+ *
+ * Returns proper regmap for accessing regulator passed by id.
+ */
+static struct regmap *max14577_get_regmap(struct maxim_core *maxim_core,
+ int reg_id)
+{
+ switch (maxim_core->dev_type) {
+ case MAXIM_DEVICE_TYPE_MAX77836:
+ switch (reg_id) {
+ case MAX77836_SAFEOUT ... MAX77836_CHARGER:
+ return maxim_core->regmap_muic;
+ default:
+ /* MAX77836_LDO1 ... MAX77836_LDO2 */
+ return maxim_core->regmap_pmic;
+ }
+
+ case MAXIM_DEVICE_TYPE_MAX14577:
+ default:
+ return maxim_core->regmap_muic;
+ }
+}
static int max14577_regulator_probe(struct platform_device *pdev)
{
@@ -200,15 +366,29 @@ static int max14577_regulator_probe(struct platform_device *pdev)
struct max14577_platform_data *pdata = dev_get_platdata(maxim_core->dev);
int i, ret;
struct regulator_config config = {};
+ const struct regulator_desc *supported_regulators;
+ unsigned int supported_regulators_size;
+ enum maxim_device_type dev_type = maxim_core->dev_type;
- ret = max14577_regulator_dt_parse_pdata(pdev);
+ ret = max14577_regulator_dt_parse_pdata(pdev, dev_type);
if (ret)
return ret;
+ switch (dev_type) {
+ case MAXIM_DEVICE_TYPE_MAX77836:
+ supported_regulators = max77836_supported_regulators;
+ supported_regulators_size = ARRAY_SIZE(max77836_supported_regulators);
+ break;
+ case MAXIM_DEVICE_TYPE_MAX14577:
+ default:
+ supported_regulators = max14577_supported_regulators;
+ supported_regulators_size = ARRAY_SIZE(max14577_supported_regulators);
+ }
+
config.dev = &pdev->dev;
- config.regmap = maxim_core->regmap_muic;
+ config.driver_data = maxim_core;
- for (i = 0; i < ARRAY_SIZE(supported_regulators); i++) {
+ for (i = 0; i < supported_regulators_size; i++) {
struct regulator_dev *regulator;
/*
* Index of supported_regulators[] is also the id and must
@@ -218,38 +398,63 @@ static int max14577_regulator_probe(struct platform_device *pdev)
config.init_data = pdata->regulators[i].initdata;
config.of_node = pdata->regulators[i].of_node;
} else {
- config.init_data = match_init_data(i);
- config.of_node = match_of_node(i);
+ config.init_data = match_init_data(i, dev_type);
+ config.of_node = match_of_node(i, dev_type);
}
+ config.regmap = max14577_get_regmap(maxim_core,
+ supported_regulators[i].id);
regulator = devm_regulator_register(&pdev->dev,
&supported_regulators[i], &config);
if (IS_ERR(regulator)) {
ret = PTR_ERR(regulator);
dev_err(&pdev->dev,
- "Regulator init failed for ID %d with error: %d\n",
- i, ret);
+ "Regulator init failed for %d/%s with error: %d\n",
+ i, supported_regulators[i].name, ret);
return ret;
}
+ dev_dbg(&pdev->dev, "Registered regulator %d/%s\n", i,
+ supported_regulators[i].name);
}
return ret;
}
+static const struct platform_device_id max14577_regulator_id[] = {
+ { "max14577-regulator", MAXIM_DEVICE_TYPE_MAX14577, },
+ { "max77836-regulator", MAXIM_DEVICE_TYPE_MAX77836, },
+ { }
+};
+MODULE_DEVICE_TABLE(platform, max14577_regulator_id);
+
static struct platform_driver max14577_regulator_driver = {
.driver = {
.owner = THIS_MODULE,
.name = "max14577-regulator",
},
- .probe = max14577_regulator_probe,
+ .probe = max14577_regulator_probe,
+ .id_table = max14577_regulator_id,
};
static int __init max14577_regulator_init(void)
{
+ /* Check for valid values for charger */
BUILD_BUG_ON(MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_START +
MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_STEP * 0xf !=
MAX14577_REGULATOR_CURRENT_LIMIT_MAX);
- BUILD_BUG_ON(ARRAY_SIZE(supported_regulators) != MAX14577_REG_NUM);
+ BUILD_BUG_ON(MAX77836_REGULATOR_CURRENT_LIMIT_HIGH_START +
+ MAX77836_REGULATOR_CURRENT_LIMIT_HIGH_STEP * 0xf !=
+ MAX77836_REGULATOR_CURRENT_LIMIT_MAX);
+ /* Valid charger current values must be provided for each chipset */
+ BUILD_BUG_ON(ARRAY_SIZE(maxim_charger_currents) != MAXIM_DEVICE_TYPE_NUM);
+
+ BUILD_BUG_ON(ARRAY_SIZE(max14577_supported_regulators) != MAX14577_REG_NUM);
+ BUILD_BUG_ON(ARRAY_SIZE(max77836_supported_regulators) != MAX77836_REG_NUM);
+
+ BUILD_BUG_ON(MAX77836_REGULATOR_LDO_VOLTAGE_MIN +
+ (MAX77836_REGULATOR_LDO_VOLTAGE_STEP *
+ (MAX77836_REGULATOR_LDO_VOLTAGE_STEPS_NUM - 1)) !=
+ MAX77836_REGULATOR_LDO_VOLTAGE_MAX);
return platform_driver_register(&max14577_regulator_driver);
}
@@ -262,6 +467,6 @@ static void __exit max14577_regulator_exit(void)
module_exit(max14577_regulator_exit);
MODULE_AUTHOR("Krzysztof Kozlowski <[email protected]>");
-MODULE_DESCRIPTION("MAXIM 14577 regulator driver");
+MODULE_DESCRIPTION("Maxim 14577/77836 regulator driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:max14577-regulator");
diff --git a/include/linux/mfd/max14577-private.h b/include/linux/mfd/max14577-private.h
index f08fb59a21a0..621e24fc45df 100644
--- a/include/linux/mfd/max14577-private.h
+++ b/include/linux/mfd/max14577-private.h
@@ -238,10 +238,20 @@ enum maxim_muic_charger_type {
#define MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_STEP 50000
#define MAX14577_REGULATOR_CURRENT_LIMIT_MAX 950000
+/* MAX77836 regulator current limits (as in MAXIM_CHGCTRL4 register), uA */
+#define MAX77836_REGULATOR_CURRENT_LIMIT_MIN 45000
+#define MAX77836_REGULATOR_CURRENT_LIMIT_HIGH_START 100000
+#define MAX77836_REGULATOR_CURRENT_LIMIT_HIGH_STEP 25000
+#define MAX77836_REGULATOR_CURRENT_LIMIT_MAX 475000
+
/* MAX14577 regulator SFOUT LDO voltage, fixed, uV */
#define MAX14577_REGULATOR_SAFEOUT_VOLTAGE 4900000
-
+/* MAX77836 regulator LDOx voltage, uV */
+#define MAX77836_REGULATOR_LDO_VOLTAGE_MIN 800000
+#define MAX77836_REGULATOR_LDO_VOLTAGE_MAX 3950000
+#define MAX77836_REGULATOR_LDO_VOLTAGE_STEP 50000
+#define MAX77836_REGULATOR_LDO_VOLTAGE_STEPS_NUM 64
/* Slave addr = 0x46: PMIC */
enum max77836_pmic_reg {
@@ -277,6 +287,26 @@ enum max77836_pmic_reg {
#define MAX77836_TOPSYS_INT_T120C_MASK (0x1 << MAX77836_TOPSYS_INT_T120C_SHIFT)
#define MAX77836_TOPSYS_INT_T140C_MASK (0x1 << MAX77836_TOPSYS_INT_T140C_SHIFT)
+/* LDO1/LDO2 CONFIG1 register */
+#define MAX77836_CNFG1_LDO_PWRMD_SHIFT 6
+#define MAX77836_CNFG1_LDO_TV_SHIFT 0
+#define MAX77836_CNFG1_LDO_PWRMD_MASK (0x3 << MAX77836_CNFG1_LDO_PWRMD_SHIFT)
+#define MAX77836_CNFG1_LDO_TV_MASK (0x3f << MAX77836_CNFG1_LDO_TV_SHIFT)
+
+/* LDO1/LDO2 CONFIG2 register */
+#define MAX77836_CNFG2_LDO_OVCLMPEN_SHIFT 7
+#define MAX77836_CNFG2_LDO_ALPMEN_SHIFT 6
+#define MAX77836_CNFG2_LDO_COMP_SHIFT 4
+#define MAX77836_CNFG2_LDO_POK_SHIFT 3
+#define MAX77836_CNFG2_LDO_ADE_SHIFT 1
+#define MAX77836_CNFG2_LDO_SS_SHIFT 0
+#define MAX77836_CNFG2_LDO_OVCLMPEN_MASK (0x1 << MAX77836_CNFG2_LDO_OVCLMPEN_SHIFT)
+#define MAX77836_CNFG2_LDO_ALPMEN_MASK (0x1 << MAX77836_CNFG2_LDO_ALPMEN_SHIFT)
+#define MAX77836_CNFG2_LDO_COMP_MASK (0x3 << MAX77836_CNFG2_LDO_COMP_SHIFT)
+#define MAX77836_CNFG2_LDO_POK_MASK (0x1 << MAX77836_CNFG2_LDO_POK_SHIFT)
+#define MAX77836_CNFG2_LDO_ADE_MASK (0x1 << MAX77836_CNFG2_LDO_ADE_SHIFT)
+#define MAX77836_CNFG2_LDO_SS_MASK (0x1 << MAX77836_CNFG2_LDO_SS_SHIFT)
+
/* Slave addr = 0x6C: Fuel-Gauge/Battery */
enum max77836_fg_reg {
MAX77836_FG_REG_VCELL_MSB = 0x02,
diff --git a/include/linux/mfd/max14577.h b/include/linux/mfd/max14577.h
index 5e5fc77db977..178384dcfed8 100644
--- a/include/linux/mfd/max14577.h
+++ b/include/linux/mfd/max14577.h
@@ -38,6 +38,16 @@ enum max14577_regulators {
MAX14577_REG_NUM,
};
+/* MAX77836 regulator IDs */
+enum max77836_regulators {
+ MAX77836_SAFEOUT = 0,
+ MAX77836_CHARGER,
+ MAX77836_LDO1,
+ MAX77836_LDO2,
+
+ MAX77836_REG_NUM,
+};
+
struct max14577_regulator_platform_data {
int id;
struct regulator_init_data *initdata;
--
1.7.9.5
Add Maxim 77836 support to max14577 driver. The chipsets have same MUIC
component so the extcon, charger and regulators are almost the same. The
max77836 however has also PMIC and Fuel Gauge.
The MAX77836 uses three I2C slave addresses and has additional interrupts
(related to PMIC and Fuel Gauge). It has also Interrupt Source register,
just like MAX77686 and MAX77693.
The MAX77836 PMIC's TOPSYS and INTSRC interrupts are reported in the
PMIC block. The PMIC block has different I2C slave address and uses own
regmap so another regmap_irq_chip is needed.
Since we have two regmap_irq_chip, use shared interrupts on MAX77836.
This patch adds additional defines and functions to the max14577 MFD core
driver so the driver will handle both chipsets.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Signed-off-by: Chanwoo Choi <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: Marek Szyprowski <[email protected]>
---
drivers/mfd/max14577.c | 215 ++++++++++++++++++++++++++++++++--
include/linux/mfd/max14577-private.h | 85 +++++++++++++-
include/linux/mfd/max14577.h | 7 +-
3 files changed, 296 insertions(+), 11 deletions(-)
diff --git a/drivers/mfd/max14577.c b/drivers/mfd/max14577.c
index 224aba8c5b3f..5b10f6f89834 100644
--- a/drivers/mfd/max14577.c
+++ b/drivers/mfd/max14577.c
@@ -1,7 +1,7 @@
/*
- * max14577.c - mfd core driver for the Maxim 14577
+ * max14577.c - mfd core driver for the Maxim 14577/77836
*
- * Copyright (C) 2013 Samsung Electrnoics
+ * Copyright (C) 2013,2014 Samsung Electrnoics
* Chanwoo Choi <[email protected]>
* Krzysztof Kozlowski <[email protected]>
*
@@ -37,11 +37,31 @@ static struct mfd_cell max14577_devs[] = {
{ .name = "max14577-charger", },
};
+static struct mfd_cell max77836_devs[] = {
+ {
+ .name = "max77836-muic",
+ .of_compatible = "maxim,max77836-muic",
+ },
+ {
+ .name = "max77836-regulator",
+ .of_compatible = "maxim,max77836-regulator",
+ },
+ { .name = "max77836-charger", },
+ {
+ .name = "max77836-battery",
+ .of_compatible = "maxim,max77836-battery",
+ },
+};
+
static struct of_device_id max14577_dt_match[] = {
{
.compatible = "maxim,max14577",
.data = (void *)MAXIM_DEVICE_TYPE_MAX14577,
},
+ {
+ .compatible = "maxim,max77836",
+ .data = (void *)MAXIM_DEVICE_TYPE_MAX77836,
+ },
{},
};
@@ -56,6 +76,29 @@ static bool max14577_muic_volatile_reg(struct device *dev, unsigned int reg)
return false;
}
+static bool max77836_muic_volatile_reg(struct device *dev, unsigned int reg)
+{
+ /* Any max14577 volatile registers are also max77836 volatile. */
+ if (max14577_muic_volatile_reg(dev, reg))
+ return true;
+ switch (reg) {
+ case MAX77836_FG_REG_VCELL_MSB ... MAX77836_FG_REG_SOC_LSB:
+ case MAX77836_FG_REG_CRATE_MSB ... MAX77836_FG_REG_CRATE_LSB:
+ case MAX77836_FG_REG_STATUS_H ... MAX77836_FG_REG_STATUS_L:
+ /* fall through */
+ case MAX77836_PMIC_REG_INTSRC:
+ /* fall through */
+ case MAX77836_PMIC_REG_TOPSYS_INT:
+ /* fall through */
+ case MAX77836_PMIC_REG_TOPSYS_STAT:
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
+
static const struct regmap_config max14577_muic_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
@@ -63,6 +106,13 @@ static const struct regmap_config max14577_muic_regmap_config = {
.max_register = MAXIM_MUIC_REG_END,
};
+static const struct regmap_config max77836_pmic_regmap_config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+ .volatile_reg = max77836_muic_volatile_reg,
+ .max_register = MAX77836_PMIC_REG_END,
+};
+
static const struct regmap_irq max14577_irqs[] = {
/* INT1 interrupts */
{ .reg_offset = 0, .mask = MAXIM_INT1_ADC_MASK, },
@@ -91,6 +141,50 @@ static const struct regmap_irq_chip max14577_irq_chip = {
.num_irqs = ARRAY_SIZE(max14577_irqs),
};
+static const struct regmap_irq max77836_muic_irqs[] = {
+ /* INT1 interrupts */
+ { .reg_offset = 0, .mask = MAXIM_INT1_ADC_MASK, },
+ { .reg_offset = 0, .mask = MAXIM_INT1_ADCLOW_MASK, },
+ { .reg_offset = 0, .mask = MAXIM_INT1_ADCERR_MASK, },
+ /* INT2 interrupts */
+ { .reg_offset = 1, .mask = MAXIM_INT2_CHGTYP_MASK, },
+ { .reg_offset = 1, .mask = MAXIM_INT2_CHGDETRUN_MASK, },
+ { .reg_offset = 1, .mask = MAXIM_INT2_DCDTMR_MASK, },
+ { .reg_offset = 1, .mask = MAXIM_INT2_DBCHG_MASK, },
+ { .reg_offset = 1, .mask = MAXIM_INT2_VBVOLT_MASK, },
+ { .reg_offset = 1, .mask = MAX77836_INT2_VIDRM_MASK, },
+ /* INT3 interrupts */
+ { .reg_offset = 2, .mask = MAXIM_INT3_EOC_MASK, },
+ { .reg_offset = 2, .mask = MAXIM_INT3_CGMBC_MASK, },
+ { .reg_offset = 2, .mask = MAXIM_INT3_OVP_MASK, },
+ { .reg_offset = 2, .mask = MAXIM_INT3_MBCCHGERR_MASK, },
+};
+
+static const struct regmap_irq_chip max77836_muic_irq_chip = {
+ .name = "max77836-muic",
+ .status_base = MAXIM_MUIC_REG_INT1,
+ .mask_base = MAXIM_MUIC_REG_INTMASK1,
+ .mask_invert = 1,
+ .num_regs = 3,
+ .irqs = max77836_muic_irqs,
+ .num_irqs = ARRAY_SIZE(max77836_muic_irqs),
+};
+
+static const struct regmap_irq max77836_pmic_irqs[] = {
+ { .reg_offset = 0, .mask = MAX77836_TOPSYS_INT_T120C_MASK, },
+ { .reg_offset = 0, .mask = MAX77836_TOPSYS_INT_T140C_MASK, },
+};
+
+static const struct regmap_irq_chip max77836_pmic_irq_chip = {
+ .name = "max77836-pmic",
+ .status_base = MAX77836_PMIC_REG_TOPSYS_INT,
+ .mask_base = MAX77836_PMIC_REG_TOPSYS_INT_MASK,
+ .mask_invert = 0,
+ .num_regs = 1,
+ .irqs = max77836_pmic_irqs,
+ .num_irqs = ARRAY_SIZE(max77836_pmic_irqs),
+};
+
static void max14577_print_dev_type(struct maxim_core *maxim_core)
{
u8 reg_data, vendor_id, device_id;
@@ -111,6 +205,81 @@ static void max14577_print_dev_type(struct maxim_core *maxim_core)
maxim_core->dev_type, device_id, vendor_id);
}
+/*
+ * Max77836 specific initialization code for driver probe.
+ * Adds new I2C dummy device, regmap and regmap IRQ chip.
+ * Unmasks Interrupt Source register.
+ *
+ * On success returns 0.
+ * On failure returns errno and reverts any changes done so far (e.g. remove
+ * I2C dummy device), except masking the INT SRC register.
+ */
+static int max77836_init(struct maxim_core *maxim_core)
+{
+ int ret;
+ u8 intsrc_mask;
+
+ maxim_core->i2c_pmic = i2c_new_dummy(maxim_core->i2c->adapter,
+ I2C_ADDR_PMIC);
+ if (!maxim_core->i2c_pmic) {
+ dev_err(maxim_core->dev, "Failed to register PMIC I2C device\n");
+ return -EPERM;
+ }
+ i2c_set_clientdata(maxim_core->i2c_pmic, maxim_core);
+
+ maxim_core->regmap_pmic = devm_regmap_init_i2c(maxim_core->i2c_pmic,
+ &max77836_pmic_regmap_config);
+ if (IS_ERR(maxim_core->regmap_pmic)) {
+ ret = PTR_ERR(maxim_core->regmap_pmic);
+ dev_err(maxim_core->dev, "Failed to allocate PMIC register map: %d\n",
+ ret);
+ goto err;
+ }
+
+ /* Un-mask MAX77836 Interrupt Source register */
+ ret = max14577_read_reg(maxim_core->regmap_pmic,
+ MAX77836_PMIC_REG_INTSRC_MASK, &intsrc_mask);
+ if (ret < 0) {
+ dev_err(maxim_core->dev, "Failed to read PMIC register\n");
+ goto err;
+ }
+
+ intsrc_mask &= ~(MAX77836_INTSRC_MASK_TOP_INT_MASK);
+ intsrc_mask &= ~(MAX77836_INTSRC_MASK_MUIC_CHG_INT_MASK);
+ ret = max14577_write_reg(maxim_core->regmap_pmic,
+ MAX77836_PMIC_REG_INTSRC_MASK, intsrc_mask);
+ if (ret < 0) {
+ dev_err(maxim_core->dev, "Failed to write PMIC register\n");
+ goto err;
+ }
+
+ ret = regmap_add_irq_chip(maxim_core->regmap_pmic, maxim_core->irq,
+ IRQF_TRIGGER_FALLING | IRQF_ONESHOT | IRQF_SHARED,
+ 0, &max77836_pmic_irq_chip,
+ &maxim_core->irq_data_pmic);
+ if (ret != 0) {
+ dev_err(maxim_core->dev, "Failed to request PMIC IRQ %d: %d\n",
+ maxim_core->irq, ret);
+ goto err;
+ }
+
+ return 0;
+
+err:
+ i2c_unregister_device(maxim_core->i2c_pmic);
+
+ return ret;
+}
+
+/*
+ * Max77836 specific de-initialization code for driver remove.
+ */
+static void max77836_remove(struct maxim_core *maxim_core)
+{
+ regmap_del_irq_chip(maxim_core->irq, maxim_core->irq_data_pmic);
+ i2c_unregister_device(maxim_core->i2c_pmic);
+}
+
static int max14577_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
@@ -118,6 +287,10 @@ static int max14577_i2c_probe(struct i2c_client *i2c,
struct max14577_platform_data *pdata = dev_get_platdata(&i2c->dev);
struct device_node *np = i2c->dev.of_node;
int ret = 0;
+ const struct regmap_irq_chip *irq_chip;
+ struct mfd_cell *mfd_devs;
+ unsigned int mfd_devs_size;
+ int irq_flags;
if (np) {
pdata = devm_kzalloc(&i2c->dev, sizeof(*pdata), GFP_KERNEL);
@@ -160,9 +333,24 @@ static int max14577_i2c_probe(struct i2c_client *i2c,
max14577_print_dev_type(maxim_core);
+ switch (maxim_core->dev_type) {
+ case MAXIM_DEVICE_TYPE_MAX77836:
+ irq_chip = &max77836_muic_irq_chip;
+ mfd_devs = max77836_devs;
+ mfd_devs_size = ARRAY_SIZE(max77836_devs);
+ irq_flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT | IRQF_SHARED;
+ break;
+ case MAXIM_DEVICE_TYPE_MAX14577:
+ default:
+ irq_chip = &max14577_irq_chip;
+ mfd_devs = max14577_devs;
+ mfd_devs_size = ARRAY_SIZE(max14577_devs);
+ irq_flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT;
+ break;
+ }
+
ret = regmap_add_irq_chip(maxim_core->regmap_muic, maxim_core->irq,
- IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 0,
- &max14577_irq_chip,
+ irq_flags, 0, irq_chip,
&maxim_core->irq_data_muic);
if (ret != 0) {
dev_err(&i2c->dev, "Failed to request IRQ %d: %d\n",
@@ -170,8 +358,15 @@ static int max14577_i2c_probe(struct i2c_client *i2c,
return ret;
}
- ret = mfd_add_devices(maxim_core->dev, -1, max14577_devs,
- ARRAY_SIZE(max14577_devs), NULL, 0,
+ /* Max77836 specific initialization code (additional regmap) */
+ if (maxim_core->dev_type == MAXIM_DEVICE_TYPE_MAX77836) {
+ ret = max77836_init(maxim_core);
+ if (ret < 0)
+ goto err_max77836;
+ }
+
+ ret = mfd_add_devices(maxim_core->dev, -1, mfd_devs,
+ mfd_devs_size, NULL, 0,
regmap_irq_get_domain(maxim_core->irq_data_muic));
if (ret < 0)
goto err_mfd;
@@ -181,6 +376,9 @@ static int max14577_i2c_probe(struct i2c_client *i2c,
return 0;
err_mfd:
+ if (maxim_core->dev_type == MAXIM_DEVICE_TYPE_MAX77836)
+ max77836_remove(maxim_core);
+err_max77836:
regmap_del_irq_chip(maxim_core->irq, maxim_core->irq_data_muic);
return ret;
@@ -192,12 +390,15 @@ static int max14577_i2c_remove(struct i2c_client *i2c)
mfd_remove_devices(maxim_core->dev);
regmap_del_irq_chip(maxim_core->irq, maxim_core->irq_data_muic);
+ if (maxim_core->dev_type == MAXIM_DEVICE_TYPE_MAX77836)
+ max77836_remove(maxim_core);
return 0;
}
static const struct i2c_device_id max14577_i2c_id[] = {
{ "max14577", MAXIM_DEVICE_TYPE_MAX14577, },
+ { "max77836", MAXIM_DEVICE_TYPE_MAX77836, },
{ }
};
MODULE_DEVICE_TABLE(i2c, max14577_i2c_id);
@@ -268,5 +469,5 @@ static void __exit max14577_i2c_exit(void)
module_exit(max14577_i2c_exit);
MODULE_AUTHOR("Chanwoo Choi <[email protected]>, Krzysztof Kozlowski <[email protected]>");
-MODULE_DESCRIPTION("MAXIM 14577 multi-function core driver");
+MODULE_DESCRIPTION("Maxim 14577/77836 multi-function core driver");
MODULE_LICENSE("GPL");
diff --git a/include/linux/mfd/max14577-private.h b/include/linux/mfd/max14577-private.h
index 814bf013d3e8..e0dd27d937d6 100644
--- a/include/linux/mfd/max14577-private.h
+++ b/include/linux/mfd/max14577-private.h
@@ -1,7 +1,7 @@
/*
- * max14577-private.h - Common API for the Maxim 14577 internal sub chip
+ * max14577-private.h - Common API for the Maxim 14577/77836 internal sub chip
*
- * Copyright (C) 2013 Samsung Electrnoics
+ * Copyright (C) 2013,2014 Samsung Electrnoics
* Chanwoo Choi <[email protected]>
* Krzysztof Kozlowski <[email protected]>
*
@@ -22,9 +22,14 @@
#include <linux/i2c.h>
#include <linux/regmap.h>
+#define I2C_ADDR_PMIC (0x46 >> 1)
+#define I2C_ADDR_MUIC (0x4A >> 1)
+#define I2C_ADDR_FG (0x6C >> 1)
+
enum maxim_device_type {
MAXIM_DEVICE_TYPE_UNKNOWN = 0,
MAXIM_DEVICE_TYPE_MAX14577,
+ MAXIM_DEVICE_TYPE_MAX77836,
MAXIM_DEVICE_TYPE_NUM,
};
@@ -78,6 +83,7 @@ enum maxim_muic_charger_type {
#define MAXIM_INT2_DCDTMR_MASK (0x1 << 2)
#define MAXIM_INT2_DBCHG_MASK (0x1 << 3)
#define MAXIM_INT2_VBVOLT_MASK (0x1 << 4)
+#define MAX77836_INT2_VIDRM_MASK (0x1 << 5)
#define MAXIM_INT3_EOC_MASK (0x1 << 0)
#define MAXIM_INT3_CGMBC_MASK (0x1 << 1)
@@ -94,9 +100,11 @@ enum maxim_muic_charger_type {
#define MAXIM_STATUS1_ADC_SHIFT 0
#define MAXIM_STATUS1_ADCLOW_SHIFT 5
#define MAXIM_STATUS1_ADCERR_SHIFT 6
+#define MAX77836_STATUS1_ADC1K_SHIFT 7
#define MAXIM_STATUS1_ADC_MASK (0x1f << MAXIM_STATUS1_ADC_SHIFT)
#define MAXIM_STATUS1_ADCLOW_MASK (0x1 << MAXIM_STATUS1_ADCLOW_SHIFT)
#define MAXIM_STATUS1_ADCERR_MASK (0x1 << MAXIM_STATUS1_ADCERR_SHIFT)
+#define MAX77836_STATUS1_ADC1K_MASK (0x1 << MAX77836_STATUS1_ADC1K_SHIFT)
/* MAX14577 STATUS2 register */
#define MAXIM_STATUS2_CHGTYP_SHIFT 0
@@ -104,11 +112,13 @@ enum maxim_muic_charger_type {
#define MAXIM_STATUS2_DCDTMR_SHIFT 4
#define MAXIM_STATUS2_DBCHG_SHIFT 5
#define MAXIM_STATUS2_VBVOLT_SHIFT 6
+#define MAX77836_STATUS2_VIDRM_SHIFT 7
#define MAXIM_STATUS2_CHGTYP_MASK (0x7 << MAXIM_STATUS2_CHGTYP_SHIFT)
#define MAXIM_STATUS2_CHGDETRUN_MASK (0x1 << MAXIM_STATUS2_CHGDETRUN_SHIFT)
#define MAXIM_STATUS2_DCDTMR_MASK (0x1 << MAXIM_STATUS2_DCDTMR_SHIFT)
#define MAXIM_STATUS2_DBCHG_MASK (0x1 << MAXIM_STATUS2_DBCHG_SHIFT)
#define MAXIM_STATUS2_VBVOLT_MASK (0x1 << MAXIM_STATUS2_VBVOLT_SHIFT)
+#define MAX77836_STATUS2_VIDRM_MASK (0x1 << MAX77836_STATUS2_VIDRM_SHIFT)
/* MAX14577 STATUS3 register */
#define MAXIM_STATUS3_EOC_SHIFT 0
@@ -232,6 +242,70 @@ enum maxim_muic_charger_type {
+/* Slave addr = 0x46: PMIC */
+enum max77836_pmic_reg {
+ MAX77836_COMP_REG_COMP1 = 0x60,
+
+ MAX77836_LDO_REG_CNFG1_LDO1 = 0x51,
+ MAX77836_LDO_REG_CNFG2_LDO1 = 0x52,
+ MAX77836_LDO_REG_CNFG1_LDO2 = 0x53,
+ MAX77836_LDO_REG_CNFG2_LDO2 = 0x54,
+ MAX77836_LDO_REG_CNFG_LDO_BIAS = 0x55,
+
+ MAX77836_PMIC_REG_PMIC_ID = 0x20,
+ MAX77836_PMIC_REG_PMIC_REV = 0x21,
+ MAX77836_PMIC_REG_INTSRC = 0x22,
+ MAX77836_PMIC_REG_INTSRC_MASK = 0x23,
+ MAX77836_PMIC_REG_TOPSYS_INT = 0x24,
+ MAX77836_PMIC_REG_TOPSYS_INT_MASK = 0x26,
+ MAX77836_PMIC_REG_TOPSYS_STAT = 0x28,
+ MAX77836_PMIC_REG_MRSTB_CNTL = 0x2A,
+ MAX77836_PMIC_REG_LSCNFG = 0x2B,
+
+ MAX77836_PMIC_REG_END,
+};
+
+#define MAX77836_INTSRC_MASK_TOP_INT_SHIFT 1
+#define MAX77836_INTSRC_MASK_MUIC_CHG_INT_SHIFT 3
+#define MAX77836_INTSRC_MASK_TOP_INT_MASK (0x1 << MAX77836_INTSRC_MASK_TOP_INT_SHIFT)
+#define MAX77836_INTSRC_MASK_MUIC_CHG_INT_MASK (0x1 << MAX77836_INTSRC_MASK_MUIC_CHG_INT_SHIFT)
+
+/* MAX77836 PMIC interrupts */
+#define MAX77836_TOPSYS_INT_T120C_SHIFT 0
+#define MAX77836_TOPSYS_INT_T140C_SHIFT 1
+#define MAX77836_TOPSYS_INT_T120C_MASK (0x1 << MAX77836_TOPSYS_INT_T120C_SHIFT)
+#define MAX77836_TOPSYS_INT_T140C_MASK (0x1 << MAX77836_TOPSYS_INT_T140C_SHIFT)
+
+/* Slave addr = 0x6C: Fuel-Gauge/Battery */
+enum max77836_fg_reg {
+ MAX77836_FG_REG_VCELL_MSB = 0x02,
+ MAX77836_FG_REG_VCELL_LSB = 0x03,
+ MAX77836_FG_REG_SOC_MSB = 0x04,
+ MAX77836_FG_REG_SOC_LSB = 0x05,
+ MAX77836_FG_REG_MODE_H = 0x06,
+ MAX77836_FG_REG_MODE_L = 0x07,
+ MAX77836_FG_REG_VERSION_MSB = 0x08,
+ MAX77836_FG_REG_VERSION_LSB = 0x09,
+ MAX77836_FG_REG_HIBRT_H = 0x0A,
+ MAX77836_FG_REG_HIBRT_L = 0x0B,
+ MAX77836_FG_REG_CONFIG_H = 0x0C,
+ MAX77836_FG_REG_CONFIG_L = 0x0D,
+ MAX77836_FG_REG_VALRT_MIN = 0x14,
+ MAX77836_FG_REG_VALRT_MAX = 0x15,
+ MAX77836_FG_REG_CRATE_MSB = 0x16,
+ MAX77836_FG_REG_CRATE_LSB = 0x17,
+ MAX77836_FG_REG_VRESET = 0x18,
+ MAX77836_FG_REG_FGID = 0x19,
+ MAX77836_FG_REG_STATUS_H = 0x1A,
+ MAX77836_FG_REG_STATUS_L = 0x1B,
+ /*
+ * TODO: TABLE registers
+ * TODO: CMD register
+ */
+
+ MAX77836_FG_REG_END,
+};
+
enum maxim_irq {
/* INT1 */
MAXIM_IRQ_INT1_ADC,
@@ -251,6 +325,10 @@ enum maxim_irq {
MAXIM_IRQ_INT3_OVP,
MAXIM_IRQ_INT3_MBCCHGERR,
+ /* TOPSYS_INT */
+ MAXIM_IRQ_TOPSYS_T140C,
+ MAXIM_IRQ_TOPSYS_T120C,
+
MAXIM_IRQ_NUM,
};
@@ -260,11 +338,14 @@ enum maxim_irq {
struct maxim_core {
struct device *dev;
struct i2c_client *i2c; /* Slave addr = 0x4A */
+ struct i2c_client *i2c_pmic; /* Slave addr = 0x46 */
enum maxim_device_type dev_type;
struct regmap *regmap_muic;
+ struct regmap *regmap_pmic;
struct regmap_irq_chip_data *irq_data_muic;
+ struct regmap_irq_chip_data *irq_data_pmic;
int irq;
};
diff --git a/include/linux/mfd/max14577.h b/include/linux/mfd/max14577.h
index 75301be5c548..5e5fc77db977 100644
--- a/include/linux/mfd/max14577.h
+++ b/include/linux/mfd/max14577.h
@@ -1,7 +1,7 @@
/*
- * max14577.h - Driver for the Maxim 14577
+ * max14577.h - Driver for the Maxim 14577/77836
*
- * Copyright (C) 2013 Samsung Electrnoics
+ * Copyright (C) 2013,2014 Samsung Electrnoics
* Chanwoo Choi <[email protected]>
* Krzysztof Kozlowski <[email protected]>
*
@@ -20,6 +20,9 @@
* MAX14577 has MUIC, Charger devices.
* The devices share the same I2C bus and interrupt line
* included in this mfd driver.
+ *
+ * MAX77836 has additional PMIC and Fuel-Gauge on different I2C slave
+ * addresses.
*/
#ifndef __MAX14577_H__
--
1.7.9.5
Add support for MAX77836 charger to the max14577 driver. The MAX77836
charger is almost the same as 14577 model except:
- No dead-battery detection;
- Support for special charger (like in max77693);
- Support for DX over-voltage protection (like in max77693);
- Lower values of charging current (two times lower current for
slow/fast charge, much lower EOC current);
- Slightly different values in ChgTyp field of STATUS2 register. On
MAX14577 0x6 is reserved and 0x7 dead battery. On the MAX77836 the
0x6 means special charger and 0x7 is reserved. Regardless of these
differences the driver maps them to one enum maxim_muic_charger_type.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: Marek Szyprowski <[email protected]>
Cc: Anton Vorontsov <[email protected]>
Cc: Dmitry Eremin-Solenikov <[email protected]>
Cc: David Woodhouse <[email protected]>
---
drivers/extcon/extcon-max14577.c | 2 +-
drivers/power/max14577_charger.c | 81 +++++++++++++++++++++++++++-------
include/linux/mfd/max14577-private.h | 57 +++++++++++++++++-------
3 files changed, 106 insertions(+), 34 deletions(-)
diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
index 440b19ac5fba..9390471f1a56 100644
--- a/drivers/extcon/extcon-max14577.c
+++ b/drivers/extcon/extcon-max14577.c
@@ -498,7 +498,7 @@ static int max14577_muic_chg_handler(struct max14577_muic_info *info)
extcon_set_cable_state(info->edev, "Fast-charger", attached);
break;
case MAXIM_CHARGER_TYPE_NONE:
- case MAXIM_CHARGER_TYPE_DEAD_BATTERY:
+ case MAX14577_CHARGER_TYPE_DEAD_BATTERY:
break;
default:
dev_err(info->dev,
diff --git a/drivers/power/max14577_charger.c b/drivers/power/max14577_charger.c
index 58cddc3b15d6..405f4d736337 100644
--- a/drivers/power/max14577_charger.c
+++ b/drivers/power/max14577_charger.c
@@ -1,7 +1,7 @@
/*
- * Battery charger driver for the Maxim 14577
+ * max14577_charger.c - Battery charger driver for the Maxim 14577/77836
*
- * Copyright (C) 2013 Samsung Electronics
+ * Copyright (C) 2013,2014 Samsung Electronics
* Krzysztof Kozlowski <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
@@ -25,10 +25,35 @@ struct max14577_charger {
struct maxim_core *maxim_core;
struct power_supply charger;
- unsigned int charging_state;
- unsigned int battery_state;
+ unsigned int charging_state;
+ unsigned int battery_state;
};
+/*
+ * Helper function for mapping values of STATUS2/CHGTYP register on max14577
+ * and max77836 chipsets to enum maxim_muic_charger_type.
+ */
+static enum maxim_muic_charger_type maxim_get_charger_type(
+ enum maxim_device_type dev_type, u8 val) {
+ switch (val) {
+ case MAXIM_CHARGER_TYPE_NONE:
+ case MAXIM_CHARGER_TYPE_USB:
+ case MAXIM_CHARGER_TYPE_DOWNSTREAM_PORT:
+ case MAXIM_CHARGER_TYPE_DEDICATED_CHG:
+ case MAXIM_CHARGER_TYPE_SPECIAL_500MA:
+ case MAXIM_CHARGER_TYPE_SPECIAL_1A:
+ return val;
+ case MAX14577_CHARGER_TYPE_DEAD_BATTERY:
+ case MAX14577_CHARGER_TYPE_RESERVED:
+ if (dev_type == MAXIM_DEVICE_TYPE_MAX77836)
+ val |= 0x8;
+ return val;
+ default:
+ WARN_ONCE(1, "max14577: Unsupported chgtyp register value 0x%02x", val);
+ return val;
+ }
+}
+
static int max14577_get_charger_state(struct max14577_charger *chg)
{
struct regmap *rmap = chg->maxim_core->regmap_muic;
@@ -89,20 +114,24 @@ static int max14577_get_online(struct max14577_charger *chg)
{
struct regmap *rmap = chg->maxim_core->regmap_muic;
u8 reg_data;
+ enum maxim_muic_charger_type chg_type;
max14577_read_reg(rmap, MAXIM_MUIC_REG_STATUS2, ®_data);
reg_data = reg_data & MAXIM_STATUS2_CHGTYP_MASK;
reg_data >>= MAXIM_STATUS2_CHGTYP_SHIFT;
- switch (reg_data) {
+ chg_type = maxim_get_charger_type(chg->maxim_core->dev_type, reg_data);
+ switch (chg_type) {
case MAXIM_CHARGER_TYPE_USB:
case MAXIM_CHARGER_TYPE_DEDICATED_CHG:
case MAXIM_CHARGER_TYPE_SPECIAL_500MA:
case MAXIM_CHARGER_TYPE_SPECIAL_1A:
- case MAXIM_CHARGER_TYPE_DEAD_BATTERY:
+ case MAX14577_CHARGER_TYPE_DEAD_BATTERY:
+ case MAX77836_CHARGER_TYPE_SPECIAL_BIAS:
return 1;
case MAXIM_CHARGER_TYPE_NONE:
case MAXIM_CHARGER_TYPE_DOWNSTREAM_PORT:
- case MAXIM_CHARGER_TYPE_RESERVED:
+ case MAX14577_CHARGER_TYPE_RESERVED:
+ case MAX77836_CHARGER_TYPE_RESERVED:
default:
return 0;
}
@@ -119,11 +148,13 @@ static int max14577_get_battery_health(struct max14577_charger *chg)
struct regmap *rmap = chg->maxim_core->regmap_muic;
int state = POWER_SUPPLY_HEALTH_GOOD;
u8 reg_data;
+ enum maxim_muic_charger_type chg_type;
max14577_read_reg(rmap, MAXIM_MUIC_REG_STATUS2, ®_data);
reg_data = reg_data & MAXIM_STATUS2_CHGTYP_MASK;
reg_data >>= MAXIM_STATUS2_CHGTYP_SHIFT;
- if (reg_data == MAXIM_CHARGER_TYPE_DEAD_BATTERY) {
+ chg_type = maxim_get_charger_type(chg->maxim_core->dev_type, reg_data);
+ if (chg_type == MAX14577_CHARGER_TYPE_DEAD_BATTERY) {
state = POWER_SUPPLY_HEALTH_DEAD;
goto state_set;
}
@@ -170,7 +201,7 @@ static void max14577_charger_reg_init(struct max14577_charger *chg)
MAXIM_CDETCTRL1_CHGTYPMAN_MASK,
reg_data);
- /* Battery Fast-Charge Timer, from SM-V700: 6hrs */
+ /* Battery Fast-Charge Timer, set to: 6hrs */
reg_data = 0x3 << MAXIM_CHGCTRL1_TCHW_SHIFT;
max14577_write_reg(rmap, MAXIM_CHG_REG_CHGCTRL1, reg_data);
@@ -182,19 +213,22 @@ static void max14577_charger_reg_init(struct max14577_charger *chg)
reg_data |= 0x1 << MAXIM_CHGCTRL2_MBCHOSTEN_SHIFT;
max14577_write_reg(rmap, MAXIM_CHG_REG_CHGCTRL2, reg_data);
- /* Battery-Charger Constant Voltage (CV) Mode, from SM-V700: 4.35V */
+ /* Battery-Charger Constant Voltage (CV) Mode, set to: 4.35V */
reg_data = 0xf << MAXIM_CHGCTRL3_MBCCVWRC_SHIFT;
max14577_write_reg(rmap, MAXIM_CHG_REG_CHGCTRL3, reg_data);
/*
- * Fast Battery-Charge Current Low, default 200-950mA
- * Fast Battery-Charge Current High, from SM-V700: 450mA
+ * Fast Battery-Charge Current Low,
+ * default 200-950mA (max14577) / 100-475mA (max77836)
+ *
+ * Fast Battery-Charge Current High,
+ * set to 450mA (max14577) / 225mA (max77836)
*/
reg_data = 0x1 << MAXIM_CHGCTRL4_MBCICHWRCL_SHIFT;
reg_data |= 0x5 << MAXIM_CHGCTRL4_MBCICHWRCH_SHIFT;
max14577_write_reg(rmap, MAXIM_CHG_REG_CHGCTRL4, reg_data);
- /* End-of-Charge Current, from SM-V700: 50mA */
+ /* End-of-Charge Current, set to 50mA (max14577) / 7.5mA (max77836) */
reg_data = 0x0 << MAXIM_CHGCTRL5_EOCS_SHIFT;
max14577_write_reg(rmap, MAXIM_CHG_REG_CHGCTRL5, reg_data);
@@ -202,7 +236,7 @@ static void max14577_charger_reg_init(struct max14577_charger *chg)
reg_data = 0x0 << MAXIM_CHGCTRL6_AUTOSTOP_SHIFT;
max14577_write_reg(rmap, MAXIM_CHG_REG_CHGCTRL6, reg_data);
- /* Overvoltage-Protection Threshold, from SM-V700: 6.5V */
+ /* Overvoltage-Protection Threshold, set to 6.5V */
reg_data = 0x2 << MAXIM_CHGCTRL7_OTPCGHCVS_SHIFT;
max14577_write_reg(rmap, MAXIM_CHG_REG_CHGCTRL7, reg_data);
}
@@ -218,7 +252,11 @@ static enum power_supply_property max14577_charger_props[] = {
POWER_SUPPLY_PROP_MANUFACTURER,
};
-static const char *model_name = "MAX14577";
+static const char * const model_names[] = {
+ [MAXIM_DEVICE_TYPE_UNKNOWN] = "MAX14577-like",
+ [MAXIM_DEVICE_TYPE_MAX14577] = "MAX14577",
+ [MAXIM_DEVICE_TYPE_MAX77836] = "MAX77836",
+};
static const char *manufacturer = "Maxim Integrated";
static int max14577_charger_get_property(struct power_supply *psy,
@@ -247,7 +285,8 @@ static int max14577_charger_get_property(struct power_supply *psy,
val->intval = max14577_get_online(chg);
break;
case POWER_SUPPLY_PROP_MODEL_NAME:
- val->strval = model_name;
+ BUILD_BUG_ON(ARRAY_SIZE(model_names) != MAXIM_DEVICE_TYPE_NUM);
+ val->strval = model_names[chg->maxim_core->dev_type];
break;
case POWER_SUPPLY_PROP_MANUFACTURER:
val->strval = manufacturer;
@@ -299,6 +338,13 @@ static int max14577_charger_remove(struct platform_device *pdev)
return 0;
}
+static const struct platform_device_id max14577_charger_id[] = {
+ { "max14577-charger", MAXIM_DEVICE_TYPE_MAX14577, },
+ { "max77836-charger", MAXIM_DEVICE_TYPE_MAX77836, },
+ { }
+};
+MODULE_DEVICE_TABLE(platform, max14577_regulator_id);
+
static struct platform_driver max14577_charger_driver = {
.driver = {
.owner = THIS_MODULE,
@@ -306,9 +352,10 @@ static struct platform_driver max14577_charger_driver = {
},
.probe = max14577_charger_probe,
.remove = max14577_charger_remove,
+ .id_table = max14577_charger_id,
};
module_platform_driver(max14577_charger_driver);
MODULE_AUTHOR("Krzysztof Kozlowski <[email protected]>");
-MODULE_DESCRIPTION("MAXIM 14577 charger driver");
+MODULE_DESCRIPTION("Maxim 14577/77836 charger driver");
MODULE_LICENSE("GPL");
diff --git a/include/linux/mfd/max14577-private.h b/include/linux/mfd/max14577-private.h
index 621e24fc45df..6f45bcf804d3 100644
--- a/include/linux/mfd/max14577-private.h
+++ b/include/linux/mfd/max14577-private.h
@@ -62,15 +62,32 @@ enum maxim_muic_reg {
MAXIM_MUIC_REG_END,
};
+/*
+ * Combined charger types for max14577 and max77836.
+ *
+ * On max14577 three lower bits map to STATUS2/CHGTYP field.
+ * On max77836 two values of this field are bitwise OR-ed with 0x8 to indicate
+ * the difference.
+ */
enum maxim_muic_charger_type {
- MAXIM_CHARGER_TYPE_NONE = 0,
- MAXIM_CHARGER_TYPE_USB,
- MAXIM_CHARGER_TYPE_DOWNSTREAM_PORT,
- MAXIM_CHARGER_TYPE_DEDICATED_CHG,
- MAXIM_CHARGER_TYPE_SPECIAL_500MA,
- MAXIM_CHARGER_TYPE_SPECIAL_1A,
- MAXIM_CHARGER_TYPE_RESERVED,
- MAXIM_CHARGER_TYPE_DEAD_BATTERY = 7,
+ MAXIM_CHARGER_TYPE_NONE = 0x0,
+ MAXIM_CHARGER_TYPE_USB = 0x1,
+ MAXIM_CHARGER_TYPE_DOWNSTREAM_PORT = 0x2,
+ MAXIM_CHARGER_TYPE_DEDICATED_CHG = 0x3,
+ MAXIM_CHARGER_TYPE_SPECIAL_500MA = 0x4,
+ /* Special 1A or 2A charger */
+ MAXIM_CHARGER_TYPE_SPECIAL_1A = 0x5,
+ /* max14577: reserved, used on max77836 */
+ MAX14577_CHARGER_TYPE_RESERVED = 0x6,
+ /* max14577: dead-battery charing with maximum current 100mA */
+ MAX14577_CHARGER_TYPE_DEAD_BATTERY = 0x7,
+ /*
+ * max77836: special charger (bias on D+/D-),
+ * register value 0x6 | 0x8 (4th bit set)
+ */
+ MAX77836_CHARGER_TYPE_SPECIAL_BIAS = 0xe,
+ /* max77836: reserved, register value 0x7 | 0x8 (4th bit set) */
+ MAX77836_CHARGER_TYPE_RESERVED = 0xf,
};
/* MAX14577 interrupts */
@@ -111,13 +128,15 @@ enum maxim_muic_charger_type {
#define MAXIM_STATUS2_CHGTYP_SHIFT 0
#define MAXIM_STATUS2_CHGDETRUN_SHIFT 3
#define MAXIM_STATUS2_DCDTMR_SHIFT 4
-#define MAXIM_STATUS2_DBCHG_SHIFT 5
+#define MAX14577_STATUS2_DBCHG_SHIFT 5
+#define MAX77836_STATUS2_DXOVP_SHIFT 5
#define MAXIM_STATUS2_VBVOLT_SHIFT 6
#define MAX77836_STATUS2_VIDRM_SHIFT 7
#define MAXIM_STATUS2_CHGTYP_MASK (0x7 << MAXIM_STATUS2_CHGTYP_SHIFT)
#define MAXIM_STATUS2_CHGDETRUN_MASK (0x1 << MAXIM_STATUS2_CHGDETRUN_SHIFT)
#define MAXIM_STATUS2_DCDTMR_MASK (0x1 << MAXIM_STATUS2_DCDTMR_SHIFT)
-#define MAXIM_STATUS2_DBCHG_MASK (0x1 << MAXIM_STATUS2_DBCHG_SHIFT)
+#define MAX14577_STATUS2_DBCHG_MASK (0x1 << MAX14577_STATUS2_DBCHG_SHIFT)
+#define MAX77836_STATUS2_DXOVP_MASK (0x1 << MAX77836_STATUS2_DXOVP_SHIFT)
#define MAXIM_STATUS2_VBVOLT_MASK (0x1 << MAXIM_STATUS2_VBVOLT_SHIFT)
#define MAX77836_STATUS2_VIDRM_MASK (0x1 << MAX77836_STATUS2_VIDRM_SHIFT)
@@ -178,26 +197,32 @@ enum maxim_muic_charger_type {
#define MAXIM_CONTROL3_JIGSET_SHIFT 0
#define MAXIM_CONTROL3_BOOTSET_SHIFT 2
#define MAXIM_CONTROL3_ADCDBSET_SHIFT 4
+#define MAX14577_CONTROL3_WBTH_SHIFT 6
#define MAXIM_CONTROL3_JIGSET_MASK (0x3 << MAXIM_CONTROL3_JIGSET_SHIFT)
#define MAXIM_CONTROL3_BOOTSET_MASK (0x3 << MAXIM_CONTROL3_BOOTSET_SHIFT)
#define MAXIM_CONTROL3_ADCDBSET_MASK (0x3 << MAXIM_CONTROL3_ADCDBSET_SHIFT)
+#define MAX14577_CONTROL3_WBTH_MASK (0x3 << MAX14577_CONTROL3_WBTH_SHIFT)
/* MAX14577 CDETCTRL1 register */
#define MAXIM_CDETCTRL1_CHGDETEN_SHIFT 0
#define MAXIM_CDETCTRL1_CHGTYPMAN_SHIFT 1
#define MAXIM_CDETCTRL1_DCDEN_SHIFT 2
#define MAXIM_CDETCTRL1_DCD2SCT_SHIFT 3
-#define MAXIM_CDETCTRL1_DCHKTM_SHIFT 4
-#define MAXIM_CDETCTRL1_DBEXIT_SHIFT 5
-#define MAXIM_CDETCTRL1_DBIDLE_SHIFT 6
+#define MAX14577_CDETCTRL1_DCHKTM_SHIFT 4
+#define MAX77836_CDETCTRL1_CDLY_SHIFT 4
+#define MAX14577_CDETCTRL1_DBEXIT_SHIFT 5
+#define MAX77836_CDETCTRL1_DCDCPL_SHIFT 5
+#define MAX14577_CDETCTRL1_DBIDLE_SHIFT 6
#define MAXIM_CDETCTRL1_CDPDET_SHIFT 7
#define MAXIM_CDETCTRL1_CHGDETEN_MASK (0x1 << MAXIM_CDETCTRL1_CHGDETEN_SHIFT)
#define MAXIM_CDETCTRL1_CHGTYPMAN_MASK (0x1 << MAXIM_CDETCTRL1_CHGTYPMAN_SHIFT)
#define MAXIM_CDETCTRL1_DCDEN_MASK (0x1 << MAXIM_CDETCTRL1_DCDEN_SHIFT)
#define MAXIM_CDETCTRL1_DCD2SCT_MASK (0x1 << MAXIM_CDETCTRL1_DCD2SCT_SHIFT)
-#define MAXIM_CDETCTRL1_DCHKTM_MASK (0x1 << MAXIM_CDETCTRL1_DCHKTM_SHIFT)
-#define MAXIM_CDETCTRL1_DBEXIT_MASK (0x1 << MAXIM_CDETCTRL1_DBEXIT_SHIFT)
-#define MAXIM_CDETCTRL1_DBIDLE_MASK (0x1 << MAXIM_CDETCTRL1_DBIDLE_SHIFT)
+#define MAX14577_CDETCTRL1_DCHKTM_MASK (0x1 << MAX14577_CDETCTRL1_DCHKTM_SHIFT)
+#define MAX77836_CDETCTRL1_CDDLY_MASK (0x1 << MAX77836_CDETCTRL1_CDDLY_SHIFT)
+#define MAX14577_CDETCTRL1_DBEXIT_MASK (0x1 << MAX14577_CDETCTRL1_DBEXIT_SHIFT)
+#define MAX77836_CDETCTRL1_DCDCPL_MASK (0x1 << MAX77836_CDETCTRL1_DCDCPL_SHIFT)
+#define MAX14577_CDETCTRL1_DBIDLE_MASK (0x1 << MAX14577_CDETCTRL1_DBIDLE_SHIFT)
#define MAXIM_CDETCTRL1_CDPDET_MASK (0x1 << MAXIM_CDETCTRL1_CDPDET_SHIFT)
/* MAX14577 MAXIM_CHGCTRL1 register */
--
1.7.9.5
This patch continues the preparation for adding support for max77836
device to existing max14577 driver.
Add enum for types of devices supported by this driver. The device type
will be detected by matching of_device_id, or i2c_device_id as a
fallback.
The patch also moves to separate function the code related to displaying
DeviceID register values.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: Marek Szyprowski <[email protected]>
---
drivers/mfd/max14577.c | 61 +++++++++++++++++++++++-----------
include/linux/mfd/max14577-private.h | 12 ++++---
2 files changed, 50 insertions(+), 23 deletions(-)
diff --git a/drivers/mfd/max14577.c b/drivers/mfd/max14577.c
index 1d8104213b3e..224aba8c5b3f 100644
--- a/drivers/mfd/max14577.c
+++ b/drivers/mfd/max14577.c
@@ -20,6 +20,7 @@
#include <linux/module.h>
#include <linux/interrupt.h>
+#include <linux/of_device.h>
#include <linux/mfd/core.h>
#include <linux/mfd/max14577.h>
#include <linux/mfd/max14577-private.h>
@@ -36,6 +37,14 @@ static struct mfd_cell max14577_devs[] = {
{ .name = "max14577-charger", },
};
+static struct of_device_id max14577_dt_match[] = {
+ {
+ .compatible = "maxim,max14577",
+ .data = (void *)MAXIM_DEVICE_TYPE_MAX14577,
+ },
+ {},
+};
+
static bool max14577_muic_volatile_reg(struct device *dev, unsigned int reg)
{
switch (reg) {
@@ -82,13 +91,32 @@ static const struct regmap_irq_chip max14577_irq_chip = {
.num_irqs = ARRAY_SIZE(max14577_irqs),
};
+static void max14577_print_dev_type(struct maxim_core *maxim_core)
+{
+ u8 reg_data, vendor_id, device_id;
+ int ret = max14577_read_reg(maxim_core->regmap_muic,
+ MAXIM_MUIC_REG_DEVICEID, ®_data);
+ if (ret) {
+ dev_err(maxim_core->dev, "Failed to read DEVICEID register: %d\n",
+ ret);
+ return;
+ }
+
+ vendor_id = ((reg_data & MAXIM_DEVID_VENDORID_MASK) >>
+ MAXIM_DEVID_VENDORID_SHIFT);
+ device_id = ((reg_data & MAXIM_DEVID_DEVICEID_MASK) >>
+ MAXIM_DEVID_DEVICEID_SHIFT);
+
+ dev_info(maxim_core->dev, "Device type: %u (ID: 0x%x, vendor: 0x%x)\n",
+ maxim_core->dev_type, device_id, vendor_id);
+}
+
static int max14577_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct maxim_core *maxim_core;
struct max14577_platform_data *pdata = dev_get_platdata(&i2c->dev);
struct device_node *np = i2c->dev.of_node;
- u8 reg_data;
int ret = 0;
if (np) {
@@ -121,19 +149,16 @@ static int max14577_i2c_probe(struct i2c_client *i2c,
return ret;
}
- ret = max14577_read_reg(maxim_core->regmap_muic,
- MAXIM_MUIC_REG_DEVICEID, ®_data);
- if (ret) {
- dev_err(maxim_core->dev, "Device not found on this channel: %d\n",
- ret);
- return ret;
+ if (np) {
+ const struct of_device_id *of_id =
+ of_match_device(max14577_dt_match, &i2c->dev);
+ if (of_id)
+ maxim_core->dev_type = (unsigned int)of_id->data;
+ } else {
+ maxim_core->dev_type = id->driver_data;
}
- maxim_core->vendor_id = ((reg_data & MAXIM_DEVID_VENDORID_MASK) >>
- MAXIM_DEVID_VENDORID_SHIFT);
- maxim_core->device_id = ((reg_data & MAXIM_DEVID_DEVICEID_MASK) >>
- MAXIM_DEVID_DEVICEID_SHIFT);
- dev_info(maxim_core->dev, "Device ID: 0x%x, vendor: 0x%x\n",
- maxim_core->device_id, maxim_core->vendor_id);
+
+ max14577_print_dev_type(maxim_core);
ret = regmap_add_irq_chip(maxim_core->regmap_muic, maxim_core->irq,
IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 0,
@@ -172,7 +197,7 @@ static int max14577_i2c_remove(struct i2c_client *i2c)
}
static const struct i2c_device_id max14577_i2c_id[] = {
- { "max14577", 0 },
+ { "max14577", MAXIM_DEVICE_TYPE_MAX14577, },
{ }
};
MODULE_DEVICE_TABLE(i2c, max14577_i2c_id);
@@ -213,11 +238,6 @@ static int max14577_resume(struct device *dev)
return 0;
}
-static struct of_device_id max14577_dt_match[] = {
- { .compatible = "maxim,max14577", },
- {},
-};
-
static SIMPLE_DEV_PM_OPS(max14577_pm, max14577_suspend, max14577_resume);
static struct i2c_driver max14577_i2c_driver = {
@@ -234,6 +254,9 @@ static struct i2c_driver max14577_i2c_driver = {
static int __init max14577_i2c_init(void)
{
+ BUILD_BUG_ON(ARRAY_SIZE(max14577_i2c_id) != MAXIM_DEVICE_TYPE_NUM);
+ BUILD_BUG_ON(ARRAY_SIZE(max14577_dt_match) != MAXIM_DEVICE_TYPE_NUM);
+
return i2c_add_driver(&max14577_i2c_driver);
}
subsys_initcall(max14577_i2c_init);
diff --git a/include/linux/mfd/max14577-private.h b/include/linux/mfd/max14577-private.h
index 6cf417dc030c..814bf013d3e8 100644
--- a/include/linux/mfd/max14577-private.h
+++ b/include/linux/mfd/max14577-private.h
@@ -22,6 +22,13 @@
#include <linux/i2c.h>
#include <linux/regmap.h>
+enum maxim_device_type {
+ MAXIM_DEVICE_TYPE_UNKNOWN = 0,
+ MAXIM_DEVICE_TYPE_MAX14577,
+
+ MAXIM_DEVICE_TYPE_NUM,
+};
+
/* Slave addr = 0x4A: MUIC and Charger */
enum maxim_muic_reg {
MAXIM_MUIC_REG_DEVICEID = 0x00,
@@ -253,15 +260,12 @@ enum maxim_irq {
struct maxim_core {
struct device *dev;
struct i2c_client *i2c; /* Slave addr = 0x4A */
+ enum maxim_device_type dev_type;
struct regmap *regmap_muic;
struct regmap_irq_chip_data *irq_data_muic;
int irq;
-
- /* Device ID */
- u8 vendor_id; /* Vendor Identification */
- u8 device_id; /* Chip Version */
};
/* MAX14577 shared regmap API function */
--
1.7.9.5
This patch continues the preparation for adding support for max77836
device to existing max14577 driver.
The patch renames the struct "max14577" state container to "maxim_core".
This is only a rename-like patch, new code is not added.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: Marek Szyprowski <[email protected]>
---
drivers/extcon/extcon-max14577.c | 22 +++++------
drivers/mfd/max14577.c | 68 +++++++++++++++++-----------------
drivers/power/max14577_charger.c | 16 ++++----
drivers/regulator/max14577.c | 6 +--
include/linux/mfd/max14577-private.h | 5 ++-
5 files changed, 60 insertions(+), 57 deletions(-)
diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
index 6f7145a929cf..2879cc5844dc 100644
--- a/drivers/extcon/extcon-max14577.c
+++ b/drivers/extcon/extcon-max14577.c
@@ -41,7 +41,7 @@ enum max14577_muic_status {
struct max14577_muic_info {
struct device *dev;
- struct max14577 *max14577;
+ struct maxim_core *maxim_core;
struct extcon_dev *edev;
int prev_cable_type;
int prev_chg_type;
@@ -176,7 +176,7 @@ static int max14577_muic_set_debounce_time(struct max14577_muic_info *info,
case ADC_DEBOUNCE_TIME_10MS:
case ADC_DEBOUNCE_TIME_25MS:
case ADC_DEBOUNCE_TIME_38_62MS:
- ret = max14577_update_reg(info->max14577->regmap,
+ ret = max14577_update_reg(info->maxim_core->regmap,
MAXIM_MUIC_REG_CONTROL3,
MAXIM_CONTROL3_ADCDBSET_MASK,
time << MAXIM_CONTROL3_ADCDBSET_SHIFT);
@@ -210,7 +210,7 @@ static int max14577_muic_set_path(struct max14577_muic_info *info,
u8 ctrl1, ctrl2 = 0;
/* Set open state to path before changing hw path */
- ret = max14577_update_reg(info->max14577->regmap,
+ ret = max14577_update_reg(info->maxim_core->regmap,
MAXIM_MUIC_REG_CONTROL1,
MAXIM_CONTROL1_CLEAR_IDBEN_MICEN_MASK,
MAXIM_CONTROL1_SW_OPEN);
@@ -224,7 +224,7 @@ static int max14577_muic_set_path(struct max14577_muic_info *info,
else
ctrl1 = MAXIM_CONTROL1_SW_OPEN;
- ret = max14577_update_reg(info->max14577->regmap,
+ ret = max14577_update_reg(info->maxim_core->regmap,
MAXIM_MUIC_REG_CONTROL1,
MAXIM_CONTROL1_CLEAR_IDBEN_MICEN_MASK, ctrl1);
if (ret < 0) {
@@ -237,7 +237,7 @@ static int max14577_muic_set_path(struct max14577_muic_info *info,
else
ctrl2 |= MAXIM_CONTROL2_LOWPWR_MASK; /* LowPwr=1, CPEn=0 */
- ret = max14577_update_reg(info->max14577->regmap,
+ ret = max14577_update_reg(info->maxim_core->regmap,
MAXIM_MUIC_REG_CONTROL2,
MAXIM_CONTROL2_LOWPWR_MASK | MAXIM_CONTROL2_CPEN_MASK,
ctrl2);
@@ -505,7 +505,7 @@ static void max14577_muic_irq_work(struct work_struct *work)
mutex_lock(&info->mutex);
- ret = max14577_bulk_read(info->max14577->regmap,
+ ret = max14577_bulk_read(info->maxim_core->regmap,
MAXIM_MUIC_REG_STATUS1, info->status, 2);
if (ret) {
dev_err(info->dev, "failed to read MUIC register\n");
@@ -581,7 +581,7 @@ static int max14577_muic_detect_accessory(struct max14577_muic_info *info)
mutex_lock(&info->mutex);
/* Read STATUSx register to detect accessory */
- ret = max14577_bulk_read(info->max14577->regmap,
+ ret = max14577_bulk_read(info->maxim_core->regmap,
MAXIM_MUIC_REG_STATUS1, info->status, 2);
if (ret) {
dev_err(info->dev, "failed to read MUIC register\n");
@@ -626,7 +626,7 @@ static void max14577_muic_detect_cable_wq(struct work_struct *work)
static int max14577_muic_probe(struct platform_device *pdev)
{
- struct max14577 *max14577 = dev_get_drvdata(pdev->dev.parent);
+ struct maxim_core *maxim_core = dev_get_drvdata(pdev->dev.parent);
struct max14577_muic_info *info;
int delay_jiffies;
int ret;
@@ -639,7 +639,7 @@ static int max14577_muic_probe(struct platform_device *pdev)
return -ENOMEM;
}
info->dev = &pdev->dev;
- info->max14577 = max14577;
+ info->maxim_core = maxim_core;
platform_set_drvdata(pdev, info);
mutex_init(&info->mutex);
@@ -651,7 +651,7 @@ static int max14577_muic_probe(struct platform_device *pdev)
struct max14577_muic_irq *muic_irq = &muic_irqs[i];
unsigned int virq = 0;
- virq = regmap_irq_get_virq(max14577->irq_data, muic_irq->irq);
+ virq = regmap_irq_get_virq(maxim_core->irq_data, muic_irq->irq);
if (!virq)
return -EINVAL;
muic_irq->virq = virq;
@@ -693,7 +693,7 @@ static int max14577_muic_probe(struct platform_device *pdev)
max14577_muic_set_path(info, info->path_uart, true);
/* Check revision number of MUIC device*/
- ret = max14577_read_reg(info->max14577->regmap,
+ ret = max14577_read_reg(info->maxim_core->regmap,
MAXIM_MUIC_REG_DEVICEID, &id);
if (ret < 0) {
dev_err(&pdev->dev, "failed to read revision number\n");
diff --git a/drivers/mfd/max14577.c b/drivers/mfd/max14577.c
index a054f6f6c16d..f160e582712d 100644
--- a/drivers/mfd/max14577.c
+++ b/drivers/mfd/max14577.c
@@ -85,7 +85,7 @@ static const struct regmap_irq_chip max14577_irq_chip = {
static int max14577_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
- struct max14577 *max14577;
+ struct maxim_core *maxim_core;
struct max14577_platform_data *pdata = dev_get_platdata(&i2c->dev);
struct device_node *np = i2c->dev.of_node;
u8 reg_data;
@@ -103,70 +103,70 @@ static int max14577_i2c_probe(struct i2c_client *i2c,
return -EINVAL;
}
- max14577 = devm_kzalloc(&i2c->dev, sizeof(*max14577), GFP_KERNEL);
- if (!max14577)
+ maxim_core = devm_kzalloc(&i2c->dev, sizeof(*maxim_core), GFP_KERNEL);
+ if (!maxim_core)
return -ENOMEM;
- i2c_set_clientdata(i2c, max14577);
- max14577->dev = &i2c->dev;
- max14577->i2c = i2c;
- max14577->irq = i2c->irq;
+ i2c_set_clientdata(i2c, maxim_core);
+ maxim_core->dev = &i2c->dev;
+ maxim_core->i2c = i2c;
+ maxim_core->irq = i2c->irq;
- max14577->regmap = devm_regmap_init_i2c(i2c,
- &max14577_muic_regmap_config);
- if (IS_ERR(max14577->regmap)) {
- ret = PTR_ERR(max14577->regmap);
- dev_err(max14577->dev, "Failed to allocate register map: %d\n",
+ maxim_core->regmap = devm_regmap_init_i2c(i2c,
+ &max14577_muic_regmap_config);
+ if (IS_ERR(maxim_core->regmap)) {
+ ret = PTR_ERR(maxim_core->regmap);
+ dev_err(maxim_core->dev, "Failed to allocate register map: %d\n",
ret);
return ret;
}
- ret = max14577_read_reg(max14577->regmap, MAXIM_MUIC_REG_DEVICEID,
+ ret = max14577_read_reg(maxim_core->regmap, MAXIM_MUIC_REG_DEVICEID,
®_data);
if (ret) {
- dev_err(max14577->dev, "Device not found on this channel: %d\n",
+ dev_err(maxim_core->dev, "Device not found on this channel: %d\n",
ret);
return ret;
}
- max14577->vendor_id = ((reg_data & MAXIM_DEVID_VENDORID_MASK) >>
+ maxim_core->vendor_id = ((reg_data & MAXIM_DEVID_VENDORID_MASK) >>
MAXIM_DEVID_VENDORID_SHIFT);
- max14577->device_id = ((reg_data & MAXIM_DEVID_DEVICEID_MASK) >>
+ maxim_core->device_id = ((reg_data & MAXIM_DEVID_DEVICEID_MASK) >>
MAXIM_DEVID_DEVICEID_SHIFT);
- dev_info(max14577->dev, "Device ID: 0x%x, vendor: 0x%x\n",
- max14577->device_id, max14577->vendor_id);
+ dev_info(maxim_core->dev, "Device ID: 0x%x, vendor: 0x%x\n",
+ maxim_core->device_id, maxim_core->vendor_id);
- ret = regmap_add_irq_chip(max14577->regmap, max14577->irq,
+ ret = regmap_add_irq_chip(maxim_core->regmap, maxim_core->irq,
IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 0,
&max14577_irq_chip,
- &max14577->irq_data);
+ &maxim_core->irq_data);
if (ret != 0) {
dev_err(&i2c->dev, "Failed to request IRQ %d: %d\n",
- max14577->irq, ret);
+ maxim_core->irq, ret);
return ret;
}
- ret = mfd_add_devices(max14577->dev, -1, max14577_devs,
+ ret = mfd_add_devices(maxim_core->dev, -1, max14577_devs,
ARRAY_SIZE(max14577_devs), NULL, 0,
- regmap_irq_get_domain(max14577->irq_data));
+ regmap_irq_get_domain(maxim_core->irq_data));
if (ret < 0)
goto err_mfd;
- device_init_wakeup(max14577->dev, 1);
+ device_init_wakeup(maxim_core->dev, 1);
return 0;
err_mfd:
- regmap_del_irq_chip(max14577->irq, max14577->irq_data);
+ regmap_del_irq_chip(maxim_core->irq, maxim_core->irq_data);
return ret;
}
static int max14577_i2c_remove(struct i2c_client *i2c)
{
- struct max14577 *max14577 = i2c_get_clientdata(i2c);
+ struct maxim_core *maxim_core = i2c_get_clientdata(i2c);
- mfd_remove_devices(max14577->dev);
- regmap_del_irq_chip(max14577->irq, max14577->irq_data);
+ mfd_remove_devices(maxim_core->dev);
+ regmap_del_irq_chip(maxim_core->irq, maxim_core->irq_data);
return 0;
}
@@ -180,10 +180,10 @@ MODULE_DEVICE_TABLE(i2c, max14577_i2c_id);
static int max14577_suspend(struct device *dev)
{
struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
- struct max14577 *max14577 = i2c_get_clientdata(i2c);
+ struct maxim_core *maxim_core = i2c_get_clientdata(i2c);
if (device_may_wakeup(dev)) {
- enable_irq_wake(max14577->irq);
+ enable_irq_wake(maxim_core->irq);
/*
* MUIC IRQ must be disabled during suspend if this is
* a wake up source because it will be handled before
@@ -194,7 +194,7 @@ static int max14577_suspend(struct device *dev)
* Interrupt handler tries to read registers but this read
* will fail because I2C is still suspended.
*/
- disable_irq(max14577->irq);
+ disable_irq(maxim_core->irq);
}
return 0;
@@ -203,11 +203,11 @@ static int max14577_suspend(struct device *dev)
static int max14577_resume(struct device *dev)
{
struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
- struct max14577 *max14577 = i2c_get_clientdata(i2c);
+ struct maxim_core *maxim_core = i2c_get_clientdata(i2c);
if (device_may_wakeup(dev)) {
- disable_irq_wake(max14577->irq);
- enable_irq(max14577->irq);
+ disable_irq_wake(maxim_core->irq);
+ enable_irq(maxim_core->irq);
}
return 0;
diff --git a/drivers/power/max14577_charger.c b/drivers/power/max14577_charger.c
index 66a4e4edea42..335c42a13136 100644
--- a/drivers/power/max14577_charger.c
+++ b/drivers/power/max14577_charger.c
@@ -21,8 +21,8 @@
#include <linux/mfd/max14577-private.h>
struct max14577_charger {
- struct device *dev;
- struct max14577 *max14577;
+ struct device *dev;
+ struct maxim_core *maxim_core;
struct power_supply charger;
unsigned int charging_state;
@@ -31,7 +31,7 @@ struct max14577_charger {
static int max14577_get_charger_state(struct max14577_charger *chg)
{
- struct regmap *rmap = chg->max14577->regmap;
+ struct regmap *rmap = chg->maxim_core->regmap;
int state = POWER_SUPPLY_STATUS_DISCHARGING;
u8 reg_data;
@@ -87,7 +87,7 @@ static int max14577_get_charge_type(struct max14577_charger *chg)
static int max14577_get_online(struct max14577_charger *chg)
{
- struct regmap *rmap = chg->max14577->regmap;
+ struct regmap *rmap = chg->maxim_core->regmap;
u8 reg_data;
max14577_read_reg(rmap, MAXIM_MUIC_REG_STATUS2, ®_data);
@@ -116,7 +116,7 @@ static int max14577_get_online(struct max14577_charger *chg)
*/
static int max14577_get_battery_health(struct max14577_charger *chg)
{
- struct regmap *rmap = chg->max14577->regmap;
+ struct regmap *rmap = chg->maxim_core->regmap;
int state = POWER_SUPPLY_HEALTH_GOOD;
u8 reg_data;
@@ -156,7 +156,7 @@ static int max14577_get_present(struct max14577_charger *chg)
*/
static void max14577_charger_reg_init(struct max14577_charger *chg)
{
- struct regmap *rmap = chg->max14577->regmap;
+ struct regmap *rmap = chg->maxim_core->regmap;
u8 reg_data;
/*
@@ -262,7 +262,7 @@ static int max14577_charger_get_property(struct power_supply *psy,
static int max14577_charger_probe(struct platform_device *pdev)
{
struct max14577_charger *chg;
- struct max14577 *max14577 = dev_get_drvdata(pdev->dev.parent);
+ struct maxim_core *maxim_core = dev_get_drvdata(pdev->dev.parent);
int ret;
chg = devm_kzalloc(&pdev->dev, sizeof(*chg), GFP_KERNEL);
@@ -271,7 +271,7 @@ static int max14577_charger_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, chg);
chg->dev = &pdev->dev;
- chg->max14577 = max14577;
+ chg->maxim_core = maxim_core;
max14577_charger_reg_init(chg);
diff --git a/drivers/regulator/max14577.c b/drivers/regulator/max14577.c
index e65d61bb200f..ead56ec819b5 100644
--- a/drivers/regulator/max14577.c
+++ b/drivers/regulator/max14577.c
@@ -196,8 +196,8 @@ static inline struct device_node *match_of_node(int index)
static int max14577_regulator_probe(struct platform_device *pdev)
{
- struct max14577 *max14577 = dev_get_drvdata(pdev->dev.parent);
- struct max14577_platform_data *pdata = dev_get_platdata(max14577->dev);
+ struct maxim_core *maxim_core = dev_get_drvdata(pdev->dev.parent);
+ struct max14577_platform_data *pdata = dev_get_platdata(maxim_core->dev);
int i, ret;
struct regulator_config config = {};
@@ -206,7 +206,7 @@ static int max14577_regulator_probe(struct platform_device *pdev)
return ret;
config.dev = &pdev->dev;
- config.regmap = max14577->regmap;
+ config.regmap = maxim_core->regmap;
for (i = 0; i < ARRAY_SIZE(supported_regulators); i++) {
struct regulator_dev *regulator;
diff --git a/include/linux/mfd/max14577-private.h b/include/linux/mfd/max14577-private.h
index 9f5ce26cb54e..3fdc32b583be 100644
--- a/include/linux/mfd/max14577-private.h
+++ b/include/linux/mfd/max14577-private.h
@@ -247,7 +247,10 @@ enum maxim_irq {
MAXIM_IRQ_NUM,
};
-struct max14577 {
+/*
+ * State container for max14577-like drivers.
+ */
+struct maxim_core {
struct device *dev;
struct i2c_client *i2c; /* Slave addr = 0x4A */
--
1.7.9.5
This patch continues the preparation for adding support for max77836
device to existing max14577 driver.
During probe choose muic_irqs according to device type. Currently there
are only "max14577_muic_irqs" but later patch will add max77836
interrupts.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: Marek Szyprowski <[email protected]>
---
drivers/extcon/extcon-max14577.c | 65 ++++++++++++++++++++++----------------
1 file changed, 37 insertions(+), 28 deletions(-)
diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
index fb343f4042d2..e986a9b92b60 100644
--- a/drivers/extcon/extcon-max14577.c
+++ b/drivers/extcon/extcon-max14577.c
@@ -39,6 +39,29 @@ enum max14577_muic_status {
MAX14577_MUIC_STATUS_END,
};
+/**
+ * struct max14577_muic_irq
+ * @irq: the index of irq list of MUIC device.
+ * @name: the name of irq.
+ * @virq: the virtual irq to use irq domain
+ */
+struct max14577_muic_irq {
+ unsigned int irq;
+ const char *name;
+ unsigned int virq;
+};
+
+static struct max14577_muic_irq max14577_muic_irqs[] = {
+ { MAXIM_IRQ_INT1_ADC, "muic-ADC" },
+ { MAXIM_IRQ_INT1_ADCLOW, "muic-ADCLOW" },
+ { MAXIM_IRQ_INT1_ADCERR, "muic-ADCError" },
+ { MAXIM_IRQ_INT2_CHGTYP, "muic-CHGTYP" },
+ { MAXIM_IRQ_INT2_CHGDETRUN, "muic-CHGDETRUN" },
+ { MAXIM_IRQ_INT2_DCDTMR, "muic-DCDTMR" },
+ { MAXIM_IRQ_INT2_DBCHG, "muic-DBCHG" },
+ { MAXIM_IRQ_INT2_VBVOLT, "muic-VBVOLT" },
+};
+
struct max14577_muic_info {
struct device *dev;
struct maxim_core *maxim_core;
@@ -47,6 +70,8 @@ struct max14577_muic_info {
int prev_chg_type;
u8 status[MAX14577_MUIC_STATUS_END];
+ struct max14577_muic_irq *muic_irqs;
+ unsigned int muic_irqs_num;
bool irq_adc;
bool irq_chg;
struct work_struct irq_work;
@@ -73,29 +98,6 @@ enum max14577_muic_cable_group {
MAX14577_CABLE_GROUP_CHG,
};
-/**
- * struct max14577_muic_irq
- * @irq: the index of irq list of MUIC device.
- * @name: the name of irq.
- * @virq: the virtual irq to use irq domain
- */
-struct max14577_muic_irq {
- unsigned int irq;
- const char *name;
- unsigned int virq;
-};
-
-static struct max14577_muic_irq max14577_muic_irqs[] = {
- { MAXIM_IRQ_INT1_ADC, "muic-ADC" },
- { MAXIM_IRQ_INT1_ADCLOW, "muic-ADCLOW" },
- { MAXIM_IRQ_INT1_ADCERR, "muic-ADCError" },
- { MAXIM_IRQ_INT2_CHGTYP, "muic-CHGTYP" },
- { MAXIM_IRQ_INT2_CHGDETRUN, "muic-CHGDETRUN" },
- { MAXIM_IRQ_INT2_DCDTMR, "muic-DCDTMR" },
- { MAXIM_IRQ_INT2_DBCHG, "muic-DBCHG" },
- { MAXIM_IRQ_INT2_VBVOLT, "muic-VBVOLT" },
-};
-
/* Define supported accessory type */
enum max14577_muic_acc_type {
MAX14577_MUIC_ADC_GROUND = 0x0,
@@ -541,9 +543,9 @@ static irqreturn_t max14577_muic_irq_handler(int irq, void *data)
* However we only need to know whether it was ADC, charger
* or both interrupts so decode IRQ and turn on proper flags.
*/
- for (i = 0; i < ARRAY_SIZE(max14577_muic_irqs); i++)
- if (irq == max14577_muic_irqs[i].virq)
- irq_type = max14577_muic_irqs[i].irq;
+ for (i = 0; i < info->muic_irqs_num; i++)
+ if (irq == info->muic_irqs[i].virq)
+ irq_type = info->muic_irqs[i].irq;
switch (irq_type) {
case MAXIM_IRQ_INT1_ADC:
@@ -646,9 +648,16 @@ static int max14577_muic_probe(struct platform_device *pdev)
INIT_WORK(&info->irq_work, max14577_muic_irq_work);
+ switch (maxim_core->dev_type) {
+ case MAXIM_DEVICE_TYPE_MAX14577:
+ default:
+ info->muic_irqs = max14577_muic_irqs;
+ info->muic_irqs_num = ARRAY_SIZE(max14577_muic_irqs);
+ }
+
/* Support irq domain for max14577 MUIC device */
- for (i = 0; i < ARRAY_SIZE(max14577_muic_irqs); i++) {
- struct max14577_muic_irq *muic_irq = &max14577_muic_irqs[i];
+ for (i = 0; i < info->muic_irqs_num; i++) {
+ struct max14577_muic_irq *muic_irq = &info->muic_irqs[i];
unsigned int virq = 0;
virq = regmap_irq_get_virq(maxim_core->irq_data_muic,
--
1.7.9.5
Add support for MAX77836 chipset to the max14577 extcon driver. The
MAX77836 MUIC has additional interrupts (VIDRM, ADC1K) so IRQ handling
is split up into two functions: max14577_parse_irq() and
max77836_parse_irq().
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Signed-off-by: Chanwoo Choi <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: Marek Szyprowski <[email protected]>
---
drivers/extcon/extcon-max14577.c | 107 ++++++++++++++++++++++++++++------
drivers/mfd/max14577.c | 1 +
include/linux/mfd/max14577-private.h | 3 +
3 files changed, 93 insertions(+), 18 deletions(-)
diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
index e986a9b92b60..440b19ac5fba 100644
--- a/drivers/extcon/extcon-max14577.c
+++ b/drivers/extcon/extcon-max14577.c
@@ -1,8 +1,9 @@
/*
- * extcon-max14577.c - MAX14577 extcon driver to support MAX14577 MUIC
+ * extcon-max14577.c - MAX14577/77836 extcon driver to support MUIC
*
- * Copyright (C) 2013 Samsung Electrnoics
+ * Copyright (C) 2013,2014 Samsung Electrnoics
* Chanwoo Choi <[email protected]>
+ * Krzysztof Kozlowski <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -62,6 +63,19 @@ static struct max14577_muic_irq max14577_muic_irqs[] = {
{ MAXIM_IRQ_INT2_VBVOLT, "muic-VBVOLT" },
};
+static struct max14577_muic_irq max77836_muic_irqs[] = {
+ { MAXIM_IRQ_INT1_ADC, "muic-ADC" },
+ { MAXIM_IRQ_INT1_ADCLOW, "muic-ADCLOW" },
+ { MAXIM_IRQ_INT1_ADCERR, "muic-ADCError" },
+ { MAX77836_IRQ_INT1_ADC1K, "muic-ADC1K" },
+ { MAXIM_IRQ_INT2_CHGTYP, "muic-CHGTYP" },
+ { MAXIM_IRQ_INT2_CHGDETRUN, "muic-CHGDETRUN" },
+ { MAXIM_IRQ_INT2_DCDTMR, "muic-DCDTMR" },
+ { MAXIM_IRQ_INT2_DBCHG, "muic-DBCHG" },
+ { MAXIM_IRQ_INT2_VBVOLT, "muic-VBVOLT" },
+ { MAX77836_IRQ_INT2_VIDRM, "muic-VIDRM" },
+};
+
struct max14577_muic_info {
struct device *dev;
struct maxim_core *maxim_core;
@@ -532,21 +546,12 @@ static void max14577_muic_irq_work(struct work_struct *work)
return;
}
-static irqreturn_t max14577_muic_irq_handler(int irq, void *data)
+/*
+ * Sets irq_adc or irq_chg in max14577_muic_info and returns 1.
+ * Returns 0 if irq_type does not match registered IRQ for this device type.
+ */
+static int max14577_parse_irq(struct max14577_muic_info *info, int irq_type)
{
- struct max14577_muic_info *info = data;
- int i, irq_type = -1;
-
- /*
- * We may be called multiple times for different nested IRQ-s.
- * Including changes in INT1_ADC and INT2_CGHTYP at once.
- * However we only need to know whether it was ADC, charger
- * or both interrupts so decode IRQ and turn on proper flags.
- */
- for (i = 0; i < info->muic_irqs_num; i++)
- if (irq == info->muic_irqs[i].virq)
- irq_type = info->muic_irqs[i].irq;
-
switch (irq_type) {
case MAXIM_IRQ_INT1_ADC:
case MAXIM_IRQ_INT1_ADCLOW:
@@ -554,7 +559,7 @@ static irqreturn_t max14577_muic_irq_handler(int irq, void *data)
/* Handle all of accessory except for
type of charger accessory */
info->irq_adc = true;
- break;
+ return 1;
case MAXIM_IRQ_INT2_CHGTYP:
case MAXIM_IRQ_INT2_CHGDETRUN:
case MAXIM_IRQ_INT2_DCDTMR:
@@ -562,8 +567,62 @@ static irqreturn_t max14577_muic_irq_handler(int irq, void *data)
case MAXIM_IRQ_INT2_VBVOLT:
/* Handle charger accessory */
info->irq_chg = true;
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+/*
+ * Sets irq_adc or irq_chg in max14577_muic_info and returns 1.
+ * Returns 0 if irq_type does not match registered IRQ for this device type.
+ */
+static int max77836_parse_irq(struct max14577_muic_info *info, int irq_type)
+{
+ /* First check common max14577 interrupts */
+ if (max14577_parse_irq(info, irq_type))
+ return 1;
+
+ switch (irq_type) {
+ case MAX77836_IRQ_INT1_ADC1K:
+ info->irq_adc = true;
+ return 1;
+ case MAX77836_IRQ_INT2_VIDRM:
+ /* Handle charger accessory */
+ info->irq_chg = true;
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+static irqreturn_t max14577_muic_irq_handler(int irq, void *data)
+{
+ struct max14577_muic_info *info = data;
+ int i, irq_type = -1;
+ bool irq_parsed;
+
+ /*
+ * We may be called multiple times for different nested IRQ-s.
+ * Including changes in INT1_ADC and INT2_CGHTYP at once.
+ * However we only need to know whether it was ADC, charger
+ * or both interrupts so decode IRQ and turn on proper flags.
+ */
+ for (i = 0; i < info->muic_irqs_num; i++)
+ if (irq == info->muic_irqs[i].virq)
+ irq_type = info->muic_irqs[i].irq;
+
+ switch (info->maxim_core->dev_type) {
+ case MAXIM_DEVICE_TYPE_MAX77836:
+ irq_parsed = max77836_parse_irq(info, irq_type);
break;
+ case MAXIM_DEVICE_TYPE_MAX14577:
default:
+ irq_parsed = max14577_parse_irq(info, irq_type);
+ break;
+ }
+
+ if (!irq_parsed) {
dev_err(info->dev, "muic interrupt: irq %d occurred, skipped\n",
irq_type);
return IRQ_HANDLED;
@@ -649,6 +708,10 @@ static int max14577_muic_probe(struct platform_device *pdev)
INIT_WORK(&info->irq_work, max14577_muic_irq_work);
switch (maxim_core->dev_type) {
+ case MAXIM_DEVICE_TYPE_MAX77836:
+ info->muic_irqs = max77836_muic_irqs;
+ info->muic_irqs_num = ARRAY_SIZE(max77836_muic_irqs);
+ break;
case MAXIM_DEVICE_TYPE_MAX14577:
default:
info->muic_irqs = max14577_muic_irqs;
@@ -748,6 +811,13 @@ static int max14577_muic_remove(struct platform_device *pdev)
return 0;
}
+static const struct platform_device_id max14577_muic_id[] = {
+ { "max14577-muic", MAXIM_DEVICE_TYPE_MAX14577, },
+ { "max77836-muic", MAXIM_DEVICE_TYPE_MAX77836, },
+ { }
+};
+MODULE_DEVICE_TABLE(platform, max14577_muic_id);
+
static struct platform_driver max14577_muic_driver = {
.driver = {
.name = "max14577-muic",
@@ -755,11 +825,12 @@ static struct platform_driver max14577_muic_driver = {
},
.probe = max14577_muic_probe,
.remove = max14577_muic_remove,
+ .id_table = max14577_muic_id,
};
module_platform_driver(max14577_muic_driver);
-MODULE_DESCRIPTION("MAXIM 14577 Extcon driver");
+MODULE_DESCRIPTION("Maxim 14577/77836 Extcon driver");
MODULE_AUTHOR("Chanwoo Choi <[email protected]>");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:extcon-max14577");
diff --git a/drivers/mfd/max14577.c b/drivers/mfd/max14577.c
index 5b10f6f89834..561182e24430 100644
--- a/drivers/mfd/max14577.c
+++ b/drivers/mfd/max14577.c
@@ -146,6 +146,7 @@ static const struct regmap_irq max77836_muic_irqs[] = {
{ .reg_offset = 0, .mask = MAXIM_INT1_ADC_MASK, },
{ .reg_offset = 0, .mask = MAXIM_INT1_ADCLOW_MASK, },
{ .reg_offset = 0, .mask = MAXIM_INT1_ADCERR_MASK, },
+ { .reg_offset = 0, .mask = MAX77836_INT1_ADC1K_MASK, },
/* INT2 interrupts */
{ .reg_offset = 1, .mask = MAXIM_INT2_CHGTYP_MASK, },
{ .reg_offset = 1, .mask = MAXIM_INT2_CHGDETRUN_MASK, },
diff --git a/include/linux/mfd/max14577-private.h b/include/linux/mfd/max14577-private.h
index e0dd27d937d6..f08fb59a21a0 100644
--- a/include/linux/mfd/max14577-private.h
+++ b/include/linux/mfd/max14577-private.h
@@ -77,6 +77,7 @@ enum maxim_muic_charger_type {
#define MAXIM_INT1_ADC_MASK (0x1 << 0)
#define MAXIM_INT1_ADCLOW_MASK (0x1 << 1)
#define MAXIM_INT1_ADCERR_MASK (0x1 << 2)
+#define MAX77836_INT1_ADC1K_MASK (0x1 << 3)
#define MAXIM_INT2_CHGTYP_MASK (0x1 << 0)
#define MAXIM_INT2_CHGDETRUN_MASK (0x1 << 1)
@@ -311,6 +312,7 @@ enum maxim_irq {
MAXIM_IRQ_INT1_ADC,
MAXIM_IRQ_INT1_ADCLOW,
MAXIM_IRQ_INT1_ADCERR,
+ MAX77836_IRQ_INT1_ADC1K,
/* INT2 */
MAXIM_IRQ_INT2_CHGTYP,
@@ -318,6 +320,7 @@ enum maxim_irq {
MAXIM_IRQ_INT2_DCDTMR,
MAXIM_IRQ_INT2_DBCHG,
MAXIM_IRQ_INT2_VBVOLT,
+ MAX77836_IRQ_INT2_VIDRM,
/* INT3 */
MAXIM_IRQ_INT3_EOC,
--
1.7.9.5
Remove unused symbol: enum max14577_irq_source.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: Marek Szyprowski <[email protected]>
---
include/linux/mfd/max14577-private.h | 8 --------
1 file changed, 8 deletions(-)
diff --git a/include/linux/mfd/max14577-private.h b/include/linux/mfd/max14577-private.h
index a3d0185196d3..c9b332fb0d5d 100644
--- a/include/linux/mfd/max14577-private.h
+++ b/include/linux/mfd/max14577-private.h
@@ -248,14 +248,6 @@ enum max14577_charger_reg {
/* MAX14577 regulator SFOUT LDO voltage, fixed, uV */
#define MAX14577_REGULATOR_SAFEOUT_VOLTAGE 4900000
-enum max14577_irq_source {
- MAX14577_IRQ_INT1 = 0,
- MAX14577_IRQ_INT2,
- MAX14577_IRQ_INT3,
-
- MAX14577_IRQ_REGS_NUM,
-};
-
enum max14577_irq {
/* INT1 */
MAX14577_IRQ_INT1_ADC,
--
1.7.9.5
This patch continues the preparation for adding support for max77836
device to existing max14577 driver.
Add "muic" suffix to regmap and irq_data fields in maxim_core state
container to prepare for max77836 support.
This is only a rename-like patch, new code is not added.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: Marek Szyprowski <[email protected]>
---
drivers/extcon/extcon-max14577.c | 17 +++++++++--------
drivers/mfd/max14577.c | 22 +++++++++++-----------
drivers/power/max14577_charger.c | 8 ++++----
drivers/regulator/max14577.c | 2 +-
include/linux/mfd/max14577-private.h | 4 ++--
5 files changed, 27 insertions(+), 26 deletions(-)
diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
index 2879cc5844dc..fd48b4909470 100644
--- a/drivers/extcon/extcon-max14577.c
+++ b/drivers/extcon/extcon-max14577.c
@@ -176,7 +176,7 @@ static int max14577_muic_set_debounce_time(struct max14577_muic_info *info,
case ADC_DEBOUNCE_TIME_10MS:
case ADC_DEBOUNCE_TIME_25MS:
case ADC_DEBOUNCE_TIME_38_62MS:
- ret = max14577_update_reg(info->maxim_core->regmap,
+ ret = max14577_update_reg(info->maxim_core->regmap_muic,
MAXIM_MUIC_REG_CONTROL3,
MAXIM_CONTROL3_ADCDBSET_MASK,
time << MAXIM_CONTROL3_ADCDBSET_SHIFT);
@@ -210,7 +210,7 @@ static int max14577_muic_set_path(struct max14577_muic_info *info,
u8 ctrl1, ctrl2 = 0;
/* Set open state to path before changing hw path */
- ret = max14577_update_reg(info->maxim_core->regmap,
+ ret = max14577_update_reg(info->maxim_core->regmap_muic,
MAXIM_MUIC_REG_CONTROL1,
MAXIM_CONTROL1_CLEAR_IDBEN_MICEN_MASK,
MAXIM_CONTROL1_SW_OPEN);
@@ -224,7 +224,7 @@ static int max14577_muic_set_path(struct max14577_muic_info *info,
else
ctrl1 = MAXIM_CONTROL1_SW_OPEN;
- ret = max14577_update_reg(info->maxim_core->regmap,
+ ret = max14577_update_reg(info->maxim_core->regmap_muic,
MAXIM_MUIC_REG_CONTROL1,
MAXIM_CONTROL1_CLEAR_IDBEN_MICEN_MASK, ctrl1);
if (ret < 0) {
@@ -237,7 +237,7 @@ static int max14577_muic_set_path(struct max14577_muic_info *info,
else
ctrl2 |= MAXIM_CONTROL2_LOWPWR_MASK; /* LowPwr=1, CPEn=0 */
- ret = max14577_update_reg(info->maxim_core->regmap,
+ ret = max14577_update_reg(info->maxim_core->regmap_muic,
MAXIM_MUIC_REG_CONTROL2,
MAXIM_CONTROL2_LOWPWR_MASK | MAXIM_CONTROL2_CPEN_MASK,
ctrl2);
@@ -505,7 +505,7 @@ static void max14577_muic_irq_work(struct work_struct *work)
mutex_lock(&info->mutex);
- ret = max14577_bulk_read(info->maxim_core->regmap,
+ ret = max14577_bulk_read(info->maxim_core->regmap_muic,
MAXIM_MUIC_REG_STATUS1, info->status, 2);
if (ret) {
dev_err(info->dev, "failed to read MUIC register\n");
@@ -581,7 +581,7 @@ static int max14577_muic_detect_accessory(struct max14577_muic_info *info)
mutex_lock(&info->mutex);
/* Read STATUSx register to detect accessory */
- ret = max14577_bulk_read(info->maxim_core->regmap,
+ ret = max14577_bulk_read(info->maxim_core->regmap_muic,
MAXIM_MUIC_REG_STATUS1, info->status, 2);
if (ret) {
dev_err(info->dev, "failed to read MUIC register\n");
@@ -651,7 +651,8 @@ static int max14577_muic_probe(struct platform_device *pdev)
struct max14577_muic_irq *muic_irq = &muic_irqs[i];
unsigned int virq = 0;
- virq = regmap_irq_get_virq(maxim_core->irq_data, muic_irq->irq);
+ virq = regmap_irq_get_virq(maxim_core->irq_data_muic,
+ muic_irq->irq);
if (!virq)
return -EINVAL;
muic_irq->virq = virq;
@@ -693,7 +694,7 @@ static int max14577_muic_probe(struct platform_device *pdev)
max14577_muic_set_path(info, info->path_uart, true);
/* Check revision number of MUIC device*/
- ret = max14577_read_reg(info->maxim_core->regmap,
+ ret = max14577_read_reg(info->maxim_core->regmap_muic,
MAXIM_MUIC_REG_DEVICEID, &id);
if (ret < 0) {
dev_err(&pdev->dev, "failed to read revision number\n");
diff --git a/drivers/mfd/max14577.c b/drivers/mfd/max14577.c
index f160e582712d..1d8104213b3e 100644
--- a/drivers/mfd/max14577.c
+++ b/drivers/mfd/max14577.c
@@ -112,17 +112,17 @@ static int max14577_i2c_probe(struct i2c_client *i2c,
maxim_core->i2c = i2c;
maxim_core->irq = i2c->irq;
- maxim_core->regmap = devm_regmap_init_i2c(i2c,
- &max14577_muic_regmap_config);
- if (IS_ERR(maxim_core->regmap)) {
- ret = PTR_ERR(maxim_core->regmap);
+ maxim_core->regmap_muic = devm_regmap_init_i2c(i2c,
+ &max14577_muic_regmap_config);
+ if (IS_ERR(maxim_core->regmap_muic)) {
+ ret = PTR_ERR(maxim_core->regmap_muic);
dev_err(maxim_core->dev, "Failed to allocate register map: %d\n",
ret);
return ret;
}
- ret = max14577_read_reg(maxim_core->regmap, MAXIM_MUIC_REG_DEVICEID,
- ®_data);
+ ret = max14577_read_reg(maxim_core->regmap_muic,
+ MAXIM_MUIC_REG_DEVICEID, ®_data);
if (ret) {
dev_err(maxim_core->dev, "Device not found on this channel: %d\n",
ret);
@@ -135,10 +135,10 @@ static int max14577_i2c_probe(struct i2c_client *i2c,
dev_info(maxim_core->dev, "Device ID: 0x%x, vendor: 0x%x\n",
maxim_core->device_id, maxim_core->vendor_id);
- ret = regmap_add_irq_chip(maxim_core->regmap, maxim_core->irq,
+ ret = regmap_add_irq_chip(maxim_core->regmap_muic, maxim_core->irq,
IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 0,
&max14577_irq_chip,
- &maxim_core->irq_data);
+ &maxim_core->irq_data_muic);
if (ret != 0) {
dev_err(&i2c->dev, "Failed to request IRQ %d: %d\n",
maxim_core->irq, ret);
@@ -147,7 +147,7 @@ static int max14577_i2c_probe(struct i2c_client *i2c,
ret = mfd_add_devices(maxim_core->dev, -1, max14577_devs,
ARRAY_SIZE(max14577_devs), NULL, 0,
- regmap_irq_get_domain(maxim_core->irq_data));
+ regmap_irq_get_domain(maxim_core->irq_data_muic));
if (ret < 0)
goto err_mfd;
@@ -156,7 +156,7 @@ static int max14577_i2c_probe(struct i2c_client *i2c,
return 0;
err_mfd:
- regmap_del_irq_chip(maxim_core->irq, maxim_core->irq_data);
+ regmap_del_irq_chip(maxim_core->irq, maxim_core->irq_data_muic);
return ret;
}
@@ -166,7 +166,7 @@ static int max14577_i2c_remove(struct i2c_client *i2c)
struct maxim_core *maxim_core = i2c_get_clientdata(i2c);
mfd_remove_devices(maxim_core->dev);
- regmap_del_irq_chip(maxim_core->irq, maxim_core->irq_data);
+ regmap_del_irq_chip(maxim_core->irq, maxim_core->irq_data_muic);
return 0;
}
diff --git a/drivers/power/max14577_charger.c b/drivers/power/max14577_charger.c
index 335c42a13136..58cddc3b15d6 100644
--- a/drivers/power/max14577_charger.c
+++ b/drivers/power/max14577_charger.c
@@ -31,7 +31,7 @@ struct max14577_charger {
static int max14577_get_charger_state(struct max14577_charger *chg)
{
- struct regmap *rmap = chg->maxim_core->regmap;
+ struct regmap *rmap = chg->maxim_core->regmap_muic;
int state = POWER_SUPPLY_STATUS_DISCHARGING;
u8 reg_data;
@@ -87,7 +87,7 @@ static int max14577_get_charge_type(struct max14577_charger *chg)
static int max14577_get_online(struct max14577_charger *chg)
{
- struct regmap *rmap = chg->maxim_core->regmap;
+ struct regmap *rmap = chg->maxim_core->regmap_muic;
u8 reg_data;
max14577_read_reg(rmap, MAXIM_MUIC_REG_STATUS2, ®_data);
@@ -116,7 +116,7 @@ static int max14577_get_online(struct max14577_charger *chg)
*/
static int max14577_get_battery_health(struct max14577_charger *chg)
{
- struct regmap *rmap = chg->maxim_core->regmap;
+ struct regmap *rmap = chg->maxim_core->regmap_muic;
int state = POWER_SUPPLY_HEALTH_GOOD;
u8 reg_data;
@@ -156,7 +156,7 @@ static int max14577_get_present(struct max14577_charger *chg)
*/
static void max14577_charger_reg_init(struct max14577_charger *chg)
{
- struct regmap *rmap = chg->maxim_core->regmap;
+ struct regmap *rmap = chg->maxim_core->regmap_muic;
u8 reg_data;
/*
diff --git a/drivers/regulator/max14577.c b/drivers/regulator/max14577.c
index ead56ec819b5..8856c660a5da 100644
--- a/drivers/regulator/max14577.c
+++ b/drivers/regulator/max14577.c
@@ -206,7 +206,7 @@ static int max14577_regulator_probe(struct platform_device *pdev)
return ret;
config.dev = &pdev->dev;
- config.regmap = maxim_core->regmap;
+ config.regmap = maxim_core->regmap_muic;
for (i = 0; i < ARRAY_SIZE(supported_regulators); i++) {
struct regulator_dev *regulator;
diff --git a/include/linux/mfd/max14577-private.h b/include/linux/mfd/max14577-private.h
index 3fdc32b583be..6cf417dc030c 100644
--- a/include/linux/mfd/max14577-private.h
+++ b/include/linux/mfd/max14577-private.h
@@ -254,9 +254,9 @@ struct maxim_core {
struct device *dev;
struct i2c_client *i2c; /* Slave addr = 0x4A */
- struct regmap *regmap;
+ struct regmap *regmap_muic;
- struct regmap_irq_chip_data *irq_data;
+ struct regmap_irq_chip_data *irq_data_muic;
int irq;
/* Device ID */
--
1.7.9.5
Add max14577 prefix to muic_irqs array. This prepares for max77836
support in this extcon driver.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: Marek Szyprowski <[email protected]>
---
drivers/extcon/extcon-max14577.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
index fd48b4909470..fb343f4042d2 100644
--- a/drivers/extcon/extcon-max14577.c
+++ b/drivers/extcon/extcon-max14577.c
@@ -85,7 +85,7 @@ struct max14577_muic_irq {
unsigned int virq;
};
-static struct max14577_muic_irq muic_irqs[] = {
+static struct max14577_muic_irq max14577_muic_irqs[] = {
{ MAXIM_IRQ_INT1_ADC, "muic-ADC" },
{ MAXIM_IRQ_INT1_ADCLOW, "muic-ADCLOW" },
{ MAXIM_IRQ_INT1_ADCERR, "muic-ADCError" },
@@ -541,9 +541,9 @@ static irqreturn_t max14577_muic_irq_handler(int irq, void *data)
* However we only need to know whether it was ADC, charger
* or both interrupts so decode IRQ and turn on proper flags.
*/
- for (i = 0; i < ARRAY_SIZE(muic_irqs); i++)
- if (irq == muic_irqs[i].virq)
- irq_type = muic_irqs[i].irq;
+ for (i = 0; i < ARRAY_SIZE(max14577_muic_irqs); i++)
+ if (irq == max14577_muic_irqs[i].virq)
+ irq_type = max14577_muic_irqs[i].irq;
switch (irq_type) {
case MAXIM_IRQ_INT1_ADC:
@@ -647,8 +647,8 @@ static int max14577_muic_probe(struct platform_device *pdev)
INIT_WORK(&info->irq_work, max14577_muic_irq_work);
/* Support irq domain for max14577 MUIC device */
- for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) {
- struct max14577_muic_irq *muic_irq = &muic_irqs[i];
+ for (i = 0; i < ARRAY_SIZE(max14577_muic_irqs); i++) {
+ struct max14577_muic_irq *muic_irq = &max14577_muic_irqs[i];
unsigned int virq = 0;
virq = regmap_irq_get_virq(maxim_core->irq_data_muic,
--
1.7.9.5
From: Chanwoo Choi <[email protected]>
This patch use device name to make sysfs path according to device type:
max14577-muic
- /sys/class/extcon/max14577-muic/
max77836-muic
- /sys/class/extcon/max77836-muic/
Signed-off-by: Chanwoo Choi <[email protected]>
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: Marek Szyprowski <[email protected]>
---
drivers/extcon/extcon-max14577.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
index 3846941801b8..59f084fee4f3 100644
--- a/drivers/extcon/extcon-max14577.c
+++ b/drivers/extcon/extcon-max14577.c
@@ -24,7 +24,6 @@
#include <linux/mfd/max14577-private.h>
#include <linux/extcon.h>
-#define DEV_NAME "max14577-muic"
#define DELAY_MS_DEFAULT 17000 /* unit: millisecond */
enum max14577_muic_adc_debounce_time {
@@ -673,7 +672,8 @@ static int max14577_muic_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "failed to allocate memory for extcon\n");
return -ENOMEM;
}
- info->edev->name = DEV_NAME;
+
+ info->edev->name = dev_name(&pdev->dev);
info->edev->supported_cable = max14577_extcon_cable;
ret = extcon_dev_register(info->edev);
if (ret) {
@@ -737,7 +737,7 @@ static int max14577_muic_remove(struct platform_device *pdev)
static struct platform_driver max14577_muic_driver = {
.driver = {
- .name = DEV_NAME,
+ .name = "max14577-muic",
.owner = THIS_MODULE,
},
.probe = max14577_muic_probe,
--
1.7.9.5
This patch prepares for adding support for max77836 device to existing
max14577 driver:
1. Renames most of symbols and defines prefixed with MAX14577 to MAXIM.
2. Adds prefixes (MAXIM or MAX14577) to defines without any MAX* prefix.
This is only a rename-like patch, new code is not added.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: Marek Szyprowski <[email protected]>
---
drivers/extcon/extcon-max14577.c | 105 ++++-----
drivers/mfd/max14577.c | 51 ++---
drivers/power/max14577_charger.c | 81 +++----
drivers/regulator/max14577.c | 44 ++--
include/linux/mfd/max14577-private.h | 399 ++++++++++++++++------------------
include/linux/mfd/max14577.h | 2 +-
6 files changed, 333 insertions(+), 349 deletions(-)
diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
index 59f084fee4f3..6f7145a929cf 100644
--- a/drivers/extcon/extcon-max14577.c
+++ b/drivers/extcon/extcon-max14577.c
@@ -86,14 +86,14 @@ struct max14577_muic_irq {
};
static struct max14577_muic_irq muic_irqs[] = {
- { MAX14577_IRQ_INT1_ADC, "muic-ADC" },
- { MAX14577_IRQ_INT1_ADCLOW, "muic-ADCLOW" },
- { MAX14577_IRQ_INT1_ADCERR, "muic-ADCError" },
- { MAX14577_IRQ_INT2_CHGTYP, "muic-CHGTYP" },
- { MAX14577_IRQ_INT2_CHGDETRUN, "muic-CHGDETRUN" },
- { MAX14577_IRQ_INT2_DCDTMR, "muic-DCDTMR" },
- { MAX14577_IRQ_INT2_DBCHG, "muic-DBCHG" },
- { MAX14577_IRQ_INT2_VBVOLT, "muic-VBVOLT" },
+ { MAXIM_IRQ_INT1_ADC, "muic-ADC" },
+ { MAXIM_IRQ_INT1_ADCLOW, "muic-ADCLOW" },
+ { MAXIM_IRQ_INT1_ADCERR, "muic-ADCError" },
+ { MAXIM_IRQ_INT2_CHGTYP, "muic-CHGTYP" },
+ { MAXIM_IRQ_INT2_CHGDETRUN, "muic-CHGDETRUN" },
+ { MAXIM_IRQ_INT2_DCDTMR, "muic-DCDTMR" },
+ { MAXIM_IRQ_INT2_DBCHG, "muic-DBCHG" },
+ { MAXIM_IRQ_INT2_VBVOLT, "muic-VBVOLT" },
};
/* Define supported accessory type */
@@ -177,9 +177,9 @@ static int max14577_muic_set_debounce_time(struct max14577_muic_info *info,
case ADC_DEBOUNCE_TIME_25MS:
case ADC_DEBOUNCE_TIME_38_62MS:
ret = max14577_update_reg(info->max14577->regmap,
- MAX14577_MUIC_REG_CONTROL3,
- CTRL3_ADCDBSET_MASK,
- time << CTRL3_ADCDBSET_SHIFT);
+ MAXIM_MUIC_REG_CONTROL3,
+ MAXIM_CONTROL3_ADCDBSET_MASK,
+ time << MAXIM_CONTROL3_ADCDBSET_SHIFT);
if (ret) {
dev_err(info->dev, "failed to set ADC debounce time\n");
return ret;
@@ -211,8 +211,9 @@ static int max14577_muic_set_path(struct max14577_muic_info *info,
/* Set open state to path before changing hw path */
ret = max14577_update_reg(info->max14577->regmap,
- MAX14577_MUIC_REG_CONTROL1,
- CLEAR_IDBEN_MICEN_MASK, CTRL1_SW_OPEN);
+ MAXIM_MUIC_REG_CONTROL1,
+ MAXIM_CONTROL1_CLEAR_IDBEN_MICEN_MASK,
+ MAXIM_CONTROL1_SW_OPEN);
if (ret < 0) {
dev_err(info->dev, "failed to update MUIC register\n");
return ret;
@@ -221,24 +222,25 @@ static int max14577_muic_set_path(struct max14577_muic_info *info,
if (attached)
ctrl1 = val;
else
- ctrl1 = CTRL1_SW_OPEN;
+ ctrl1 = MAXIM_CONTROL1_SW_OPEN;
ret = max14577_update_reg(info->max14577->regmap,
- MAX14577_MUIC_REG_CONTROL1,
- CLEAR_IDBEN_MICEN_MASK, ctrl1);
+ MAXIM_MUIC_REG_CONTROL1,
+ MAXIM_CONTROL1_CLEAR_IDBEN_MICEN_MASK, ctrl1);
if (ret < 0) {
dev_err(info->dev, "failed to update MUIC register\n");
return ret;
}
if (attached)
- ctrl2 |= CTRL2_CPEN_MASK; /* LowPwr=0, CPEn=1 */
+ ctrl2 |= MAXIM_CONTROL2_CPEN_MASK; /* LowPwr=0, CPEn=1 */
else
- ctrl2 |= CTRL2_LOWPWR_MASK; /* LowPwr=1, CPEn=0 */
+ ctrl2 |= MAXIM_CONTROL2_LOWPWR_MASK; /* LowPwr=1, CPEn=0 */
ret = max14577_update_reg(info->max14577->regmap,
- MAX14577_REG_CONTROL2,
- CTRL2_LOWPWR_MASK | CTRL2_CPEN_MASK, ctrl2);
+ MAXIM_MUIC_REG_CONTROL2,
+ MAXIM_CONTROL2_LOWPWR_MASK | MAXIM_CONTROL2_CPEN_MASK,
+ ctrl2);
if (ret < 0) {
dev_err(info->dev, "failed to update MUIC register\n");
return ret;
@@ -275,8 +277,9 @@ static int max14577_muic_get_cable_type(struct max14577_muic_info *info,
* Read ADC value to check cable type and decide cable state
* according to cable type
*/
- adc = info->status[MAX14577_MUIC_STATUS1] & STATUS1_ADC_MASK;
- adc >>= STATUS1_ADC_SHIFT;
+ adc = info->status[MAX14577_MUIC_STATUS1] &
+ MAXIM_STATUS1_ADC_MASK;
+ adc >>= MAXIM_STATUS1_ADC_SHIFT;
/*
* Check current cable state/cable type and store cable type
@@ -300,14 +303,14 @@ static int max14577_muic_get_cable_type(struct max14577_muic_info *info,
* according to type of charger cable.
*/
chg_type = info->status[MAX14577_MUIC_STATUS2] &
- STATUS2_CHGTYP_MASK;
- chg_type >>= STATUS2_CHGTYP_SHIFT;
+ MAXIM_STATUS2_CHGTYP_MASK;
+ chg_type >>= MAXIM_STATUS2_CHGTYP_SHIFT;
- if (chg_type == MAX14577_CHARGER_TYPE_NONE) {
+ if (chg_type == MAXIM_CHARGER_TYPE_NONE) {
*attached = false;
cable_type = info->prev_chg_type;
- info->prev_chg_type = MAX14577_CHARGER_TYPE_NONE;
+ info->prev_chg_type = MAXIM_CHARGER_TYPE_NONE;
} else {
*attached = true;
@@ -334,7 +337,7 @@ static int max14577_muic_jig_handler(struct max14577_muic_info *info,
{
char cable_name[32];
int ret = 0;
- u8 path = CTRL1_SW_OPEN;
+ u8 path = MAXIM_CONTROL1_SW_OPEN;
dev_dbg(info->dev,
"external connector is %s (adc:0x%02x)\n",
@@ -344,17 +347,17 @@ static int max14577_muic_jig_handler(struct max14577_muic_info *info,
case MAX14577_MUIC_ADC_FACTORY_MODE_USB_OFF: /* ADC_JIG_USB_OFF */
/* PATH:AP_USB */
strcpy(cable_name, "JIG-USB-OFF");
- path = CTRL1_SW_USB;
+ path = MAXIM_CONTROL1_SW_USB;
break;
case MAX14577_MUIC_ADC_FACTORY_MODE_USB_ON: /* ADC_JIG_USB_ON */
/* PATH:AP_USB */
strcpy(cable_name, "JIG-USB-ON");
- path = CTRL1_SW_USB;
+ path = MAXIM_CONTROL1_SW_USB;
break;
case MAX14577_MUIC_ADC_FACTORY_MODE_UART_OFF: /* ADC_JIG_UART_OFF */
/* PATH:AP_UART */
strcpy(cable_name, "JIG-UART-OFF");
- path = CTRL1_SW_UART;
+ path = MAXIM_CONTROL1_SW_UART;
break;
default:
dev_err(info->dev, "failed to detect %s jig cable\n",
@@ -457,7 +460,7 @@ static int max14577_muic_chg_handler(struct max14577_muic_info *info)
chg_type, info->prev_chg_type);
switch (chg_type) {
- case MAX14577_CHARGER_TYPE_USB:
+ case MAXIM_CHARGER_TYPE_USB:
/* PATH:AP_USB */
ret = max14577_muic_set_path(info, info->path_usb, attached);
if (ret < 0)
@@ -465,21 +468,21 @@ static int max14577_muic_chg_handler(struct max14577_muic_info *info)
extcon_set_cable_state(info->edev, "USB", attached);
break;
- case MAX14577_CHARGER_TYPE_DEDICATED_CHG:
+ case MAXIM_CHARGER_TYPE_DEDICATED_CHG:
extcon_set_cable_state(info->edev, "TA", attached);
break;
- case MAX14577_CHARGER_TYPE_DOWNSTREAM_PORT:
+ case MAXIM_CHARGER_TYPE_DOWNSTREAM_PORT:
extcon_set_cable_state(info->edev,
"Charge-downstream", attached);
break;
- case MAX14577_CHARGER_TYPE_SPECIAL_500MA:
+ case MAXIM_CHARGER_TYPE_SPECIAL_500MA:
extcon_set_cable_state(info->edev, "Slow-charger", attached);
break;
- case MAX14577_CHARGER_TYPE_SPECIAL_1A:
+ case MAXIM_CHARGER_TYPE_SPECIAL_1A:
extcon_set_cable_state(info->edev, "Fast-charger", attached);
break;
- case MAX14577_CHARGER_TYPE_NONE:
- case MAX14577_CHARGER_TYPE_DEAD_BATTERY:
+ case MAXIM_CHARGER_TYPE_NONE:
+ case MAXIM_CHARGER_TYPE_DEAD_BATTERY:
break;
default:
dev_err(info->dev,
@@ -503,7 +506,7 @@ static void max14577_muic_irq_work(struct work_struct *work)
mutex_lock(&info->mutex);
ret = max14577_bulk_read(info->max14577->regmap,
- MAX14577_MUIC_REG_STATUS1, info->status, 2);
+ MAXIM_MUIC_REG_STATUS1, info->status, 2);
if (ret) {
dev_err(info->dev, "failed to read MUIC register\n");
mutex_unlock(&info->mutex);
@@ -543,18 +546,18 @@ static irqreturn_t max14577_muic_irq_handler(int irq, void *data)
irq_type = muic_irqs[i].irq;
switch (irq_type) {
- case MAX14577_IRQ_INT1_ADC:
- case MAX14577_IRQ_INT1_ADCLOW:
- case MAX14577_IRQ_INT1_ADCERR:
+ case MAXIM_IRQ_INT1_ADC:
+ case MAXIM_IRQ_INT1_ADCLOW:
+ case MAXIM_IRQ_INT1_ADCERR:
/* Handle all of accessory except for
type of charger accessory */
info->irq_adc = true;
break;
- case MAX14577_IRQ_INT2_CHGTYP:
- case MAX14577_IRQ_INT2_CHGDETRUN:
- case MAX14577_IRQ_INT2_DCDTMR:
- case MAX14577_IRQ_INT2_DBCHG:
- case MAX14577_IRQ_INT2_VBVOLT:
+ case MAXIM_IRQ_INT2_CHGTYP:
+ case MAXIM_IRQ_INT2_CHGDETRUN:
+ case MAXIM_IRQ_INT2_DCDTMR:
+ case MAXIM_IRQ_INT2_DBCHG:
+ case MAXIM_IRQ_INT2_VBVOLT:
/* Handle charger accessory */
info->irq_chg = true;
break;
@@ -579,7 +582,7 @@ static int max14577_muic_detect_accessory(struct max14577_muic_info *info)
/* Read STATUSx register to detect accessory */
ret = max14577_bulk_read(info->max14577->regmap,
- MAX14577_MUIC_REG_STATUS1, info->status, 2);
+ MAXIM_MUIC_REG_STATUS1, info->status, 2);
if (ret) {
dev_err(info->dev, "failed to read MUIC register\n");
mutex_unlock(&info->mutex);
@@ -599,7 +602,7 @@ static int max14577_muic_detect_accessory(struct max14577_muic_info *info)
chg_type = max14577_muic_get_cable_type(info, MAX14577_CABLE_GROUP_CHG,
&attached);
- if (attached && chg_type != MAX14577_CHARGER_TYPE_NONE) {
+ if (attached && chg_type != MAXIM_CHARGER_TYPE_NONE) {
ret = max14577_muic_chg_handler(info);
if (ret < 0) {
dev_err(info->dev, "Cannot detect charger accessory\n");
@@ -682,8 +685,8 @@ static int max14577_muic_probe(struct platform_device *pdev)
}
/* Default h/w line path */
- info->path_usb = CTRL1_SW_USB;
- info->path_uart = CTRL1_SW_UART;
+ info->path_usb = MAXIM_CONTROL1_SW_USB;
+ info->path_uart = MAXIM_CONTROL1_SW_UART;
delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT);
/* Set initial path for UART */
@@ -691,7 +694,7 @@ static int max14577_muic_probe(struct platform_device *pdev)
/* Check revision number of MUIC device*/
ret = max14577_read_reg(info->max14577->regmap,
- MAX14577_REG_DEVICEID, &id);
+ MAXIM_MUIC_REG_DEVICEID, &id);
if (ret < 0) {
dev_err(&pdev->dev, "failed to read revision number\n");
goto err_extcon;
diff --git a/drivers/mfd/max14577.c b/drivers/mfd/max14577.c
index 75b37082a3fe..a054f6f6c16d 100644
--- a/drivers/mfd/max14577.c
+++ b/drivers/mfd/max14577.c
@@ -36,10 +36,10 @@ static struct mfd_cell max14577_devs[] = {
{ .name = "max14577-charger", },
};
-static bool max14577_volatile_reg(struct device *dev, unsigned int reg)
+static bool max14577_muic_volatile_reg(struct device *dev, unsigned int reg)
{
switch (reg) {
- case MAX14577_REG_INT1 ... MAX14577_REG_STATUS3:
+ case MAXIM_MUIC_REG_INT1 ... MAXIM_MUIC_REG_STATUS3:
return true;
default:
break;
@@ -47,35 +47,35 @@ static bool max14577_volatile_reg(struct device *dev, unsigned int reg)
return false;
}
-static const struct regmap_config max14577_regmap_config = {
+static const struct regmap_config max14577_muic_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
- .volatile_reg = max14577_volatile_reg,
- .max_register = MAX14577_REG_END,
+ .volatile_reg = max14577_muic_volatile_reg,
+ .max_register = MAXIM_MUIC_REG_END,
};
static const struct regmap_irq max14577_irqs[] = {
/* INT1 interrupts */
- { .reg_offset = 0, .mask = INT1_ADC_MASK, },
- { .reg_offset = 0, .mask = INT1_ADCLOW_MASK, },
- { .reg_offset = 0, .mask = INT1_ADCERR_MASK, },
+ { .reg_offset = 0, .mask = MAXIM_INT1_ADC_MASK, },
+ { .reg_offset = 0, .mask = MAXIM_INT1_ADCLOW_MASK, },
+ { .reg_offset = 0, .mask = MAXIM_INT1_ADCERR_MASK, },
/* INT2 interrupts */
- { .reg_offset = 1, .mask = INT2_CHGTYP_MASK, },
- { .reg_offset = 1, .mask = INT2_CHGDETRUN_MASK, },
- { .reg_offset = 1, .mask = INT2_DCDTMR_MASK, },
- { .reg_offset = 1, .mask = INT2_DBCHG_MASK, },
- { .reg_offset = 1, .mask = INT2_VBVOLT_MASK, },
+ { .reg_offset = 1, .mask = MAXIM_INT2_CHGTYP_MASK, },
+ { .reg_offset = 1, .mask = MAXIM_INT2_CHGDETRUN_MASK, },
+ { .reg_offset = 1, .mask = MAXIM_INT2_DCDTMR_MASK, },
+ { .reg_offset = 1, .mask = MAXIM_INT2_DBCHG_MASK, },
+ { .reg_offset = 1, .mask = MAXIM_INT2_VBVOLT_MASK, },
/* INT3 interrupts */
- { .reg_offset = 2, .mask = INT3_EOC_MASK, },
- { .reg_offset = 2, .mask = INT3_CGMBC_MASK, },
- { .reg_offset = 2, .mask = INT3_OVP_MASK, },
- { .reg_offset = 2, .mask = INT3_MBCCHGERR_MASK, },
+ { .reg_offset = 2, .mask = MAXIM_INT3_EOC_MASK, },
+ { .reg_offset = 2, .mask = MAXIM_INT3_CGMBC_MASK, },
+ { .reg_offset = 2, .mask = MAXIM_INT3_OVP_MASK, },
+ { .reg_offset = 2, .mask = MAXIM_INT3_MBCCHGERR_MASK, },
};
static const struct regmap_irq_chip max14577_irq_chip = {
.name = "max14577",
- .status_base = MAX14577_REG_INT1,
- .mask_base = MAX14577_REG_INTMASK1,
+ .status_base = MAXIM_MUIC_REG_INT1,
+ .mask_base = MAXIM_MUIC_REG_INTMASK1,
.mask_invert = 1,
.num_regs = 3,
.irqs = max14577_irqs,
@@ -112,7 +112,8 @@ static int max14577_i2c_probe(struct i2c_client *i2c,
max14577->i2c = i2c;
max14577->irq = i2c->irq;
- max14577->regmap = devm_regmap_init_i2c(i2c, &max14577_regmap_config);
+ max14577->regmap = devm_regmap_init_i2c(i2c,
+ &max14577_muic_regmap_config);
if (IS_ERR(max14577->regmap)) {
ret = PTR_ERR(max14577->regmap);
dev_err(max14577->dev, "Failed to allocate register map: %d\n",
@@ -120,17 +121,17 @@ static int max14577_i2c_probe(struct i2c_client *i2c,
return ret;
}
- ret = max14577_read_reg(max14577->regmap, MAX14577_REG_DEVICEID,
+ ret = max14577_read_reg(max14577->regmap, MAXIM_MUIC_REG_DEVICEID,
®_data);
if (ret) {
dev_err(max14577->dev, "Device not found on this channel: %d\n",
ret);
return ret;
}
- max14577->vendor_id = ((reg_data & DEVID_VENDORID_MASK) >>
- DEVID_VENDORID_SHIFT);
- max14577->device_id = ((reg_data & DEVID_DEVICEID_MASK) >>
- DEVID_DEVICEID_SHIFT);
+ max14577->vendor_id = ((reg_data & MAXIM_DEVID_VENDORID_MASK) >>
+ MAXIM_DEVID_VENDORID_SHIFT);
+ max14577->device_id = ((reg_data & MAXIM_DEVID_DEVICEID_MASK) >>
+ MAXIM_DEVID_DEVICEID_SHIFT);
dev_info(max14577->dev, "Device ID: 0x%x, vendor: 0x%x\n",
max14577->device_id, max14577->vendor_id);
diff --git a/drivers/power/max14577_charger.c b/drivers/power/max14577_charger.c
index fad2a75b3604..66a4e4edea42 100644
--- a/drivers/power/max14577_charger.c
+++ b/drivers/power/max14577_charger.c
@@ -46,14 +46,14 @@ static int max14577_get_charger_state(struct max14577_charger *chg)
* - handle properly dead-battery charging (respect timer)
* - handle timers (fast-charge and prequal) /MBCCHGERR/
*/
- max14577_read_reg(rmap, MAX14577_CHG_REG_CHG_CTRL2, ®_data);
- if ((reg_data & CHGCTRL2_MBCHOSTEN_MASK) == 0)
+ max14577_read_reg(rmap, MAXIM_CHG_REG_CHGCTRL2, ®_data);
+ if ((reg_data & MAXIM_CHGCTRL2_MBCHOSTEN_MASK) == 0)
goto state_set;
- max14577_read_reg(rmap, MAX14577_CHG_REG_STATUS3, ®_data);
- if (reg_data & STATUS3_CGMBC_MASK) {
+ max14577_read_reg(rmap, MAXIM_MUIC_REG_STATUS3, ®_data);
+ if (reg_data & MAXIM_STATUS3_CGMBC_MASK) {
/* Charger or USB-cable is connected */
- if (reg_data & STATUS3_EOC_MASK)
+ if (reg_data & MAXIM_STATUS3_EOC_MASK)
state = POWER_SUPPLY_STATUS_FULL;
else
state = POWER_SUPPLY_STATUS_CHARGING;
@@ -90,18 +90,19 @@ static int max14577_get_online(struct max14577_charger *chg)
struct regmap *rmap = chg->max14577->regmap;
u8 reg_data;
- max14577_read_reg(rmap, MAX14577_MUIC_REG_STATUS2, ®_data);
- reg_data = ((reg_data & STATUS2_CHGTYP_MASK) >> STATUS2_CHGTYP_SHIFT);
+ max14577_read_reg(rmap, MAXIM_MUIC_REG_STATUS2, ®_data);
+ reg_data = reg_data & MAXIM_STATUS2_CHGTYP_MASK;
+ reg_data >>= MAXIM_STATUS2_CHGTYP_SHIFT;
switch (reg_data) {
- case MAX14577_CHARGER_TYPE_USB:
- case MAX14577_CHARGER_TYPE_DEDICATED_CHG:
- case MAX14577_CHARGER_TYPE_SPECIAL_500MA:
- case MAX14577_CHARGER_TYPE_SPECIAL_1A:
- case MAX14577_CHARGER_TYPE_DEAD_BATTERY:
+ case MAXIM_CHARGER_TYPE_USB:
+ case MAXIM_CHARGER_TYPE_DEDICATED_CHG:
+ case MAXIM_CHARGER_TYPE_SPECIAL_500MA:
+ case MAXIM_CHARGER_TYPE_SPECIAL_1A:
+ case MAXIM_CHARGER_TYPE_DEAD_BATTERY:
return 1;
- case MAX14577_CHARGER_TYPE_NONE:
- case MAX14577_CHARGER_TYPE_DOWNSTREAM_PORT:
- case MAX14577_CHARGER_TYPE_RESERVED:
+ case MAXIM_CHARGER_TYPE_NONE:
+ case MAXIM_CHARGER_TYPE_DOWNSTREAM_PORT:
+ case MAXIM_CHARGER_TYPE_RESERVED:
default:
return 0;
}
@@ -119,15 +120,16 @@ static int max14577_get_battery_health(struct max14577_charger *chg)
int state = POWER_SUPPLY_HEALTH_GOOD;
u8 reg_data;
- max14577_read_reg(rmap, MAX14577_MUIC_REG_STATUS2, ®_data);
- reg_data = ((reg_data & STATUS2_CHGTYP_MASK) >> STATUS2_CHGTYP_SHIFT);
- if (reg_data == MAX14577_CHARGER_TYPE_DEAD_BATTERY) {
+ max14577_read_reg(rmap, MAXIM_MUIC_REG_STATUS2, ®_data);
+ reg_data = reg_data & MAXIM_STATUS2_CHGTYP_MASK;
+ reg_data >>= MAXIM_STATUS2_CHGTYP_SHIFT;
+ if (reg_data == MAXIM_CHARGER_TYPE_DEAD_BATTERY) {
state = POWER_SUPPLY_HEALTH_DEAD;
goto state_set;
}
- max14577_read_reg(rmap, MAX14577_CHG_REG_STATUS3, ®_data);
- if (reg_data & STATUS3_OVP_MASK) {
+ max14577_read_reg(rmap, MAXIM_MUIC_REG_STATUS3, ®_data);
+ if (reg_data & MAXIM_STATUS3_OVP_MASK) {
state = POWER_SUPPLY_HEALTH_OVERVOLTAGE;
goto state_set;
}
@@ -162,46 +164,47 @@ static void max14577_charger_reg_init(struct max14577_charger *chg)
* Charger-Detection Enable, default on (set CHGDETEN to 1)
* Combined mask of CHGDETEN and CHGTYPMAN will zero the CHGTYPMAN bit
*/
- reg_data = 0x1 << CDETCTRL1_CHGDETEN_SHIFT;
- max14577_update_reg(rmap, MAX14577_REG_CDETCTRL1,
- CDETCTRL1_CHGDETEN_MASK | CDETCTRL1_CHGTYPMAN_MASK,
+ reg_data = 0x1 << MAXIM_CDETCTRL1_CHGDETEN_SHIFT;
+ max14577_update_reg(rmap, MAXIM_MUIC_REG_CDETCTRL1,
+ MAXIM_CDETCTRL1_CHGDETEN_MASK |
+ MAXIM_CDETCTRL1_CHGTYPMAN_MASK,
reg_data);
/* Battery Fast-Charge Timer, from SM-V700: 6hrs */
- reg_data = 0x3 << CHGCTRL1_TCHW_SHIFT;
- max14577_write_reg(rmap, MAX14577_REG_CHGCTRL1, reg_data);
+ reg_data = 0x3 << MAXIM_CHGCTRL1_TCHW_SHIFT;
+ max14577_write_reg(rmap, MAXIM_CHG_REG_CHGCTRL1, reg_data);
/*
* Wall-Adapter Rapid Charge, default on
* Battery-Charger, default on
*/
- reg_data = 0x1 << CHGCTRL2_VCHGR_RC_SHIFT;
- reg_data |= 0x1 << CHGCTRL2_MBCHOSTEN_SHIFT;
- max14577_write_reg(rmap, MAX14577_REG_CHGCTRL2, reg_data);
+ reg_data = 0x1 << MAXIM_CHGCTRL2_VCHGR_RC_SHIFT;
+ reg_data |= 0x1 << MAXIM_CHGCTRL2_MBCHOSTEN_SHIFT;
+ max14577_write_reg(rmap, MAXIM_CHG_REG_CHGCTRL2, reg_data);
/* Battery-Charger Constant Voltage (CV) Mode, from SM-V700: 4.35V */
- reg_data = 0xf << CHGCTRL3_MBCCVWRC_SHIFT;
- max14577_write_reg(rmap, MAX14577_REG_CHGCTRL3, reg_data);
+ reg_data = 0xf << MAXIM_CHGCTRL3_MBCCVWRC_SHIFT;
+ max14577_write_reg(rmap, MAXIM_CHG_REG_CHGCTRL3, reg_data);
/*
* Fast Battery-Charge Current Low, default 200-950mA
* Fast Battery-Charge Current High, from SM-V700: 450mA
*/
- reg_data = 0x1 << CHGCTRL4_MBCICHWRCL_SHIFT;
- reg_data |= 0x5 << CHGCTRL4_MBCICHWRCH_SHIFT;
- max14577_write_reg(rmap, MAX14577_REG_CHGCTRL4, reg_data);
+ reg_data = 0x1 << MAXIM_CHGCTRL4_MBCICHWRCL_SHIFT;
+ reg_data |= 0x5 << MAXIM_CHGCTRL4_MBCICHWRCH_SHIFT;
+ max14577_write_reg(rmap, MAXIM_CHG_REG_CHGCTRL4, reg_data);
/* End-of-Charge Current, from SM-V700: 50mA */
- reg_data = 0x0 << CHGCTRL5_EOCS_SHIFT;
- max14577_write_reg(rmap, MAX14577_REG_CHGCTRL5, reg_data);
+ reg_data = 0x0 << MAXIM_CHGCTRL5_EOCS_SHIFT;
+ max14577_write_reg(rmap, MAXIM_CHG_REG_CHGCTRL5, reg_data);
/* Auto Charging Stop, default off */
- reg_data = 0x0 << CHGCTRL6_AUTOSTOP_SHIFT;
- max14577_write_reg(rmap, MAX14577_REG_CHGCTRL6, reg_data);
+ reg_data = 0x0 << MAXIM_CHGCTRL6_AUTOSTOP_SHIFT;
+ max14577_write_reg(rmap, MAXIM_CHG_REG_CHGCTRL6, reg_data);
/* Overvoltage-Protection Threshold, from SM-V700: 6.5V */
- reg_data = 0x2 << CHGCTRL7_OTPCGHCVS_SHIFT;
- max14577_write_reg(rmap, MAX14577_REG_CHGCTRL7, reg_data);
+ reg_data = 0x2 << MAXIM_CHGCTRL7_OTPCGHCVS_SHIFT;
+ max14577_write_reg(rmap, MAXIM_CHG_REG_CHGCTRL7, reg_data);
}
/* Support property from charger */
diff --git a/drivers/regulator/max14577.c b/drivers/regulator/max14577.c
index 38821458d413..e65d61bb200f 100644
--- a/drivers/regulator/max14577.c
+++ b/drivers/regulator/max14577.c
@@ -30,11 +30,11 @@ static int max14577_reg_is_enabled(struct regulator_dev *rdev)
switch (rid) {
case MAX14577_CHARGER:
- max14577_read_reg(rmap, MAX14577_CHG_REG_CHG_CTRL2, ®_data);
- if ((reg_data & CHGCTRL2_MBCHOSTEN_MASK) == 0)
+ max14577_read_reg(rmap, MAXIM_CHG_REG_CHGCTRL2, ®_data);
+ if ((reg_data & MAXIM_CHGCTRL2_MBCHOSTEN_MASK) == 0)
return 0;
- max14577_read_reg(rmap, MAX14577_CHG_REG_STATUS3, ®_data);
- if ((reg_data & STATUS3_CGMBC_MASK) == 0)
+ max14577_read_reg(rmap, MAXIM_MUIC_REG_STATUS3, ®_data);
+ if ((reg_data & MAXIM_STATUS3_CGMBC_MASK) == 0)
return 0;
/* MBCHOSTEN and CGMBC are on */
return 1;
@@ -51,13 +51,13 @@ static int max14577_reg_get_current_limit(struct regulator_dev *rdev)
if (rdev_get_id(rdev) != MAX14577_CHARGER)
return -EINVAL;
- max14577_read_reg(rmap, MAX14577_CHG_REG_CHG_CTRL4, ®_data);
+ max14577_read_reg(rmap, MAXIM_CHG_REG_CHGCTRL4, ®_data);
- if ((reg_data & CHGCTRL4_MBCICHWRCL_MASK) == 0)
+ if ((reg_data & MAXIM_CHGCTRL4_MBCICHWRCL_MASK) == 0)
return MAX14577_REGULATOR_CURRENT_LIMIT_MIN;
- reg_data = ((reg_data & CHGCTRL4_MBCICHWRCH_MASK) >>
- CHGCTRL4_MBCICHWRCH_SHIFT);
+ reg_data = ((reg_data & MAXIM_CHGCTRL4_MBCICHWRCH_MASK) >>
+ MAXIM_CHGCTRL4_MBCICHWRCH_SHIFT);
return MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_START +
reg_data * MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_STEP;
}
@@ -77,10 +77,10 @@ static int max14577_reg_set_current_limit(struct regulator_dev *rdev,
if (max_uA < MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_START) {
/* Less than 200 mA, so set 90mA (turn only Low Bit off) */
- u8 reg_data = 0x0 << CHGCTRL4_MBCICHWRCL_SHIFT;
+ u8 reg_data = 0x0 << MAXIM_CHGCTRL4_MBCICHWRCL_SHIFT;
return max14577_update_reg(rdev->regmap,
- MAX14577_CHG_REG_CHG_CTRL4,
- CHGCTRL4_MBCICHWRCL_MASK, reg_data);
+ MAXIM_CHG_REG_CHGCTRL4,
+ MAXIM_CHGCTRL4_MBCICHWRCL_MASK, reg_data);
}
/* max_uA is in range: <LIMIT_HIGH_START, inifinite>, so search for
@@ -94,13 +94,13 @@ static int max14577_reg_set_current_limit(struct regulator_dev *rdev,
}
BUG_ON(current_bits < 0); /* Cannot happen */
/* Turn Low Bit on (use range 200mA-950 mA) */
- reg_data = 0x1 << CHGCTRL4_MBCICHWRCL_SHIFT;
+ reg_data = 0x1 << MAXIM_CHGCTRL4_MBCICHWRCL_SHIFT;
/* and set proper High Bits */
- reg_data |= current_bits << CHGCTRL4_MBCICHWRCH_SHIFT;
+ reg_data |= current_bits << MAXIM_CHGCTRL4_MBCICHWRCH_SHIFT;
- return max14577_update_reg(rdev->regmap, MAX14577_CHG_REG_CHG_CTRL4,
- CHGCTRL4_MBCICHWRCL_MASK | CHGCTRL4_MBCICHWRCH_MASK,
- reg_data);
+ return max14577_update_reg(rdev->regmap, MAXIM_CHG_REG_CHGCTRL4,
+ MAXIM_CHGCTRL4_MBCICHWRCL_MASK | MAXIM_CHGCTRL4_MBCICHWRCH_MASK,
+ reg_data);
}
static struct regulator_ops max14577_safeout_ops = {
@@ -127,8 +127,8 @@ static const struct regulator_desc supported_regulators[] = {
.owner = THIS_MODULE,
.n_voltages = 1,
.min_uV = MAX14577_REGULATOR_SAFEOUT_VOLTAGE,
- .enable_reg = MAX14577_REG_CONTROL2,
- .enable_mask = CTRL2_SFOUTORD_MASK,
+ .enable_reg = MAXIM_MUIC_REG_CONTROL2,
+ .enable_mask = MAXIM_CONTROL2_SFOUTORD_MASK,
},
[MAX14577_CHARGER] = {
.name = "CHARGER",
@@ -136,8 +136,8 @@ static const struct regulator_desc supported_regulators[] = {
.ops = &max14577_charger_ops,
.type = REGULATOR_CURRENT,
.owner = THIS_MODULE,
- .enable_reg = MAX14577_CHG_REG_CHG_CTRL2,
- .enable_mask = CHGCTRL2_MBCHOSTEN_MASK,
+ .enable_reg = MAXIM_CHG_REG_CHGCTRL2,
+ .enable_mask = MAXIM_CHGCTRL2_MBCHOSTEN_MASK,
},
};
@@ -159,7 +159,7 @@ static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev)
}
ret = of_regulator_match(&pdev->dev, np, max14577_regulator_matches,
- MAX14577_REG_MAX);
+ ARRAY_SIZE(max14577_regulator_matches));
if (ret < 0) {
dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", ret);
return ret;
@@ -249,7 +249,7 @@ static int __init max14577_regulator_init(void)
BUILD_BUG_ON(MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_START +
MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_STEP * 0xf !=
MAX14577_REGULATOR_CURRENT_LIMIT_MAX);
- BUILD_BUG_ON(ARRAY_SIZE(supported_regulators) != MAX14577_REG_MAX);
+ BUILD_BUG_ON(ARRAY_SIZE(supported_regulators) != MAX14577_REG_NUM);
return platform_driver_register(&max14577_regulator_driver);
}
diff --git a/include/linux/mfd/max14577-private.h b/include/linux/mfd/max14577-private.h
index c9b332fb0d5d..9f5ce26cb54e 100644
--- a/include/linux/mfd/max14577-private.h
+++ b/include/linux/mfd/max14577-private.h
@@ -22,224 +22,199 @@
#include <linux/i2c.h>
#include <linux/regmap.h>
-#define MAX14577_REG_INVALID (0xff)
-
-/* Slave addr = 0x4A: Interrupt */
-enum max14577_reg {
- MAX14577_REG_DEVICEID = 0x00,
- MAX14577_REG_INT1 = 0x01,
- MAX14577_REG_INT2 = 0x02,
- MAX14577_REG_INT3 = 0x03,
- MAX14577_REG_STATUS1 = 0x04,
- MAX14577_REG_STATUS2 = 0x05,
- MAX14577_REG_STATUS3 = 0x06,
- MAX14577_REG_INTMASK1 = 0x07,
- MAX14577_REG_INTMASK2 = 0x08,
- MAX14577_REG_INTMASK3 = 0x09,
- MAX14577_REG_CDETCTRL1 = 0x0A,
- MAX14577_REG_RFU = 0x0B,
- MAX14577_REG_CONTROL1 = 0x0C,
- MAX14577_REG_CONTROL2 = 0x0D,
- MAX14577_REG_CONTROL3 = 0x0E,
- MAX14577_REG_CHGCTRL1 = 0x0F,
- MAX14577_REG_CHGCTRL2 = 0x10,
- MAX14577_REG_CHGCTRL3 = 0x11,
- MAX14577_REG_CHGCTRL4 = 0x12,
- MAX14577_REG_CHGCTRL5 = 0x13,
- MAX14577_REG_CHGCTRL6 = 0x14,
- MAX14577_REG_CHGCTRL7 = 0x15,
-
- MAX14577_REG_END,
+/* Slave addr = 0x4A: MUIC and Charger */
+enum maxim_muic_reg {
+ MAXIM_MUIC_REG_DEVICEID = 0x00,
+ MAXIM_MUIC_REG_INT1 = 0x01,
+ MAXIM_MUIC_REG_INT2 = 0x02,
+ MAXIM_MUIC_REG_INT3 = 0x03,
+ MAXIM_MUIC_REG_STATUS1 = 0x04,
+ MAXIM_MUIC_REG_STATUS2 = 0x05,
+ MAXIM_MUIC_REG_STATUS3 = 0x06,
+ MAXIM_MUIC_REG_INTMASK1 = 0x07,
+ MAXIM_MUIC_REG_INTMASK2 = 0x08,
+ MAXIM_MUIC_REG_INTMASK3 = 0x09,
+ MAXIM_MUIC_REG_CDETCTRL1 = 0x0A,
+ MAXIM_MUIC_REG_RFU = 0x0B,
+ MAXIM_MUIC_REG_CONTROL1 = 0x0C,
+ MAXIM_MUIC_REG_CONTROL2 = 0x0D,
+ MAXIM_MUIC_REG_CONTROL3 = 0x0E,
+ MAXIM_CHG_REG_CHGCTRL1 = 0x0F,
+ MAXIM_CHG_REG_CHGCTRL2 = 0x10,
+ MAXIM_CHG_REG_CHGCTRL3 = 0x11,
+ MAXIM_CHG_REG_CHGCTRL4 = 0x12,
+ MAXIM_CHG_REG_CHGCTRL5 = 0x13,
+ MAXIM_CHG_REG_CHGCTRL6 = 0x14,
+ MAXIM_CHG_REG_CHGCTRL7 = 0x15,
+
+ MAXIM_MUIC_REG_END,
};
-/* Slave addr = 0x4A: MUIC */
-enum max14577_muic_reg {
- MAX14577_MUIC_REG_STATUS1 = 0x04,
- MAX14577_MUIC_REG_STATUS2 = 0x05,
- MAX14577_MUIC_REG_CONTROL1 = 0x0C,
- MAX14577_MUIC_REG_CONTROL3 = 0x0E,
-
- MAX14577_MUIC_REG_END,
-};
-
-enum max14577_muic_charger_type {
- MAX14577_CHARGER_TYPE_NONE = 0,
- MAX14577_CHARGER_TYPE_USB,
- MAX14577_CHARGER_TYPE_DOWNSTREAM_PORT,
- MAX14577_CHARGER_TYPE_DEDICATED_CHG,
- MAX14577_CHARGER_TYPE_SPECIAL_500MA,
- MAX14577_CHARGER_TYPE_SPECIAL_1A,
- MAX14577_CHARGER_TYPE_RESERVED,
- MAX14577_CHARGER_TYPE_DEAD_BATTERY = 7,
+enum maxim_muic_charger_type {
+ MAXIM_CHARGER_TYPE_NONE = 0,
+ MAXIM_CHARGER_TYPE_USB,
+ MAXIM_CHARGER_TYPE_DOWNSTREAM_PORT,
+ MAXIM_CHARGER_TYPE_DEDICATED_CHG,
+ MAXIM_CHARGER_TYPE_SPECIAL_500MA,
+ MAXIM_CHARGER_TYPE_SPECIAL_1A,
+ MAXIM_CHARGER_TYPE_RESERVED,
+ MAXIM_CHARGER_TYPE_DEAD_BATTERY = 7,
};
/* MAX14577 interrupts */
-#define INT1_ADC_MASK (0x1 << 0)
-#define INT1_ADCLOW_MASK (0x1 << 1)
-#define INT1_ADCERR_MASK (0x1 << 2)
+#define MAXIM_INT1_ADC_MASK (0x1 << 0)
+#define MAXIM_INT1_ADCLOW_MASK (0x1 << 1)
+#define MAXIM_INT1_ADCERR_MASK (0x1 << 2)
-#define INT2_CHGTYP_MASK (0x1 << 0)
-#define INT2_CHGDETRUN_MASK (0x1 << 1)
-#define INT2_DCDTMR_MASK (0x1 << 2)
-#define INT2_DBCHG_MASK (0x1 << 3)
-#define INT2_VBVOLT_MASK (0x1 << 4)
+#define MAXIM_INT2_CHGTYP_MASK (0x1 << 0)
+#define MAXIM_INT2_CHGDETRUN_MASK (0x1 << 1)
+#define MAXIM_INT2_DCDTMR_MASK (0x1 << 2)
+#define MAXIM_INT2_DBCHG_MASK (0x1 << 3)
+#define MAXIM_INT2_VBVOLT_MASK (0x1 << 4)
-#define INT3_EOC_MASK (0x1 << 0)
-#define INT3_CGMBC_MASK (0x1 << 1)
-#define INT3_OVP_MASK (0x1 << 2)
-#define INT3_MBCCHGERR_MASK (0x1 << 3)
+#define MAXIM_INT3_EOC_MASK (0x1 << 0)
+#define MAXIM_INT3_CGMBC_MASK (0x1 << 1)
+#define MAXIM_INT3_OVP_MASK (0x1 << 2)
+#define MAXIM_INT3_MBCCHGERR_MASK (0x1 << 3)
/* MAX14577 DEVICE ID register */
-#define DEVID_VENDORID_SHIFT 0
-#define DEVID_DEVICEID_SHIFT 3
-#define DEVID_VENDORID_MASK (0x07 << DEVID_VENDORID_SHIFT)
-#define DEVID_DEVICEID_MASK (0x1f << DEVID_DEVICEID_SHIFT)
+#define MAXIM_DEVID_VENDORID_SHIFT 0
+#define MAXIM_DEVID_DEVICEID_SHIFT 3
+#define MAXIM_DEVID_VENDORID_MASK (0x07 << MAXIM_DEVID_VENDORID_SHIFT)
+#define MAXIM_DEVID_DEVICEID_MASK (0x1f << MAXIM_DEVID_DEVICEID_SHIFT)
/* MAX14577 STATUS1 register */
-#define STATUS1_ADC_SHIFT 0
-#define STATUS1_ADCLOW_SHIFT 5
-#define STATUS1_ADCERR_SHIFT 6
-#define STATUS1_ADC_MASK (0x1f << STATUS1_ADC_SHIFT)
-#define STATUS1_ADCLOW_MASK (0x1 << STATUS1_ADCLOW_SHIFT)
-#define STATUS1_ADCERR_MASK (0x1 << STATUS1_ADCERR_SHIFT)
+#define MAXIM_STATUS1_ADC_SHIFT 0
+#define MAXIM_STATUS1_ADCLOW_SHIFT 5
+#define MAXIM_STATUS1_ADCERR_SHIFT 6
+#define MAXIM_STATUS1_ADC_MASK (0x1f << MAXIM_STATUS1_ADC_SHIFT)
+#define MAXIM_STATUS1_ADCLOW_MASK (0x1 << MAXIM_STATUS1_ADCLOW_SHIFT)
+#define MAXIM_STATUS1_ADCERR_MASK (0x1 << MAXIM_STATUS1_ADCERR_SHIFT)
/* MAX14577 STATUS2 register */
-#define STATUS2_CHGTYP_SHIFT 0
-#define STATUS2_CHGDETRUN_SHIFT 3
-#define STATUS2_DCDTMR_SHIFT 4
-#define STATUS2_DBCHG_SHIFT 5
-#define STATUS2_VBVOLT_SHIFT 6
-#define STATUS2_CHGTYP_MASK (0x7 << STATUS2_CHGTYP_SHIFT)
-#define STATUS2_CHGDETRUN_MASK (0x1 << STATUS2_CHGDETRUN_SHIFT)
-#define STATUS2_DCDTMR_MASK (0x1 << STATUS2_DCDTMR_SHIFT)
-#define STATUS2_DBCHG_MASK (0x1 << STATUS2_DBCHG_SHIFT)
-#define STATUS2_VBVOLT_MASK (0x1 << STATUS2_VBVOLT_SHIFT)
+#define MAXIM_STATUS2_CHGTYP_SHIFT 0
+#define MAXIM_STATUS2_CHGDETRUN_SHIFT 3
+#define MAXIM_STATUS2_DCDTMR_SHIFT 4
+#define MAXIM_STATUS2_DBCHG_SHIFT 5
+#define MAXIM_STATUS2_VBVOLT_SHIFT 6
+#define MAXIM_STATUS2_CHGTYP_MASK (0x7 << MAXIM_STATUS2_CHGTYP_SHIFT)
+#define MAXIM_STATUS2_CHGDETRUN_MASK (0x1 << MAXIM_STATUS2_CHGDETRUN_SHIFT)
+#define MAXIM_STATUS2_DCDTMR_MASK (0x1 << MAXIM_STATUS2_DCDTMR_SHIFT)
+#define MAXIM_STATUS2_DBCHG_MASK (0x1 << MAXIM_STATUS2_DBCHG_SHIFT)
+#define MAXIM_STATUS2_VBVOLT_MASK (0x1 << MAXIM_STATUS2_VBVOLT_SHIFT)
+
+/* MAX14577 STATUS3 register */
+#define MAXIM_STATUS3_EOC_SHIFT 0
+#define MAXIM_STATUS3_CGMBC_SHIFT 1
+#define MAXIM_STATUS3_OVP_SHIFT 2
+#define MAXIM_STATUS3_MBCCHGERR_SHIFT 3
+#define MAXIM_STATUS3_EOC_MASK (0x1 << MAXIM_STATUS3_EOC_SHIFT)
+#define MAXIM_STATUS3_CGMBC_MASK (0x1 << MAXIM_STATUS3_CGMBC_SHIFT)
+#define MAXIM_STATUS3_OVP_MASK (0x1 << MAXIM_STATUS3_OVP_SHIFT)
+#define MAXIM_STATUS3_MBCCHGERR_MASK (0x1 << MAXIM_STATUS3_MBCCHGERR_SHIFT)
/* MAX14577 CONTROL1 register */
-#define COMN1SW_SHIFT 0
-#define COMP2SW_SHIFT 3
-#define MICEN_SHIFT 6
-#define IDBEN_SHIFT 7
-#define COMN1SW_MASK (0x7 << COMN1SW_SHIFT)
-#define COMP2SW_MASK (0x7 << COMP2SW_SHIFT)
-#define MICEN_MASK (0x1 << MICEN_SHIFT)
-#define IDBEN_MASK (0x1 << IDBEN_SHIFT)
-#define CLEAR_IDBEN_MICEN_MASK (COMN1SW_MASK | COMP2SW_MASK)
-#define CTRL1_SW_USB ((1 << COMP2SW_SHIFT) \
- | (1 << COMN1SW_SHIFT))
-#define CTRL1_SW_AUDIO ((2 << COMP2SW_SHIFT) \
- | (2 << COMN1SW_SHIFT))
-#define CTRL1_SW_UART ((3 << COMP2SW_SHIFT) \
- | (3 << COMN1SW_SHIFT))
-#define CTRL1_SW_OPEN ((0 << COMP2SW_SHIFT) \
- | (0 << COMN1SW_SHIFT))
+#define MAXIM_CONTROL1_COMN1SW_SHIFT 0
+#define MAXIM_CONTROL1_COMP2SW_SHIFT 3
+#define MAXIM_CONTROL1_MICEN_SHIFT 6
+#define MAXIM_CONTROL1_IDBEN_SHIFT 7
+#define MAXIM_CONTROL1_COMN1SW_MASK (0x7 << MAXIM_CONTROL1_COMN1SW_SHIFT)
+#define MAXIM_CONTROL1_COMP2SW_MASK (0x7 << MAXIM_CONTROL1_COMP2SW_SHIFT)
+#define MAXIM_CONTROL1_MICEN_MASK (0x1 << MAXIM_CONTROL1_MICEN_SHIFT)
+#define MAXIM_CONTROL1_IDBEN_MASK (0x1 << MAXIM_CONTROL1_IDBEN_SHIFT)
+
+#define MAXIM_CONTROL1_CLEAR_IDBEN_MICEN_MASK (MAXIM_CONTROL1_COMN1SW_MASK | MAXIM_CONTROL1_COMP2SW_MASK)
+#define MAXIM_CONTROL1_SW_USB ((1 << MAXIM_CONTROL1_COMP2SW_SHIFT) \
+ | (1 << MAXIM_CONTROL1_COMN1SW_SHIFT))
+#define MAXIM_CONTROL1_SW_AUDIO ((2 << MAXIM_CONTROL1_COMP2SW_SHIFT) \
+ | (2 << MAXIM_CONTROL1_COMN1SW_SHIFT))
+#define MAXIM_CONTROL1_SW_UART ((3 << MAXIM_CONTROL1_COMP2SW_SHIFT) \
+ | (3 << MAXIM_CONTROL1_COMN1SW_SHIFT))
+#define MAXIM_CONTROL1_SW_OPEN ((0 << MAXIM_CONTROL1_COMP2SW_SHIFT) \
+ | (0 << MAXIM_CONTROL1_COMN1SW_SHIFT))
/* MAX14577 CONTROL2 register */
-#define CTRL2_LOWPWR_SHIFT (0)
-#define CTRL2_ADCEN_SHIFT (1)
-#define CTRL2_CPEN_SHIFT (2)
-#define CTRL2_SFOUTASRT_SHIFT (3)
-#define CTRL2_SFOUTORD_SHIFT (4)
-#define CTRL2_ACCDET_SHIFT (5)
-#define CTRL2_USBCPINT_SHIFT (6)
-#define CTRL2_RCPS_SHIFT (7)
-#define CTRL2_LOWPWR_MASK (0x1 << CTRL2_LOWPWR_SHIFT)
-#define CTRL2_ADCEN_MASK (0x1 << CTRL2_ADCEN_SHIFT)
-#define CTRL2_CPEN_MASK (0x1 << CTRL2_CPEN_SHIFT)
-#define CTRL2_SFOUTASRT_MASK (0x1 << CTRL2_SFOUTASRT_SHIFT)
-#define CTRL2_SFOUTORD_MASK (0x1 << CTRL2_SFOUTORD_SHIFT)
-#define CTRL2_ACCDET_MASK (0x1 << CTRL2_ACCDET_SHIFT)
-#define CTRL2_USBCPINT_MASK (0x1 << CTRL2_USBCPINT_SHIFT)
-#define CTRL2_RCPS_MASK (0x1 << CTR2_RCPS_SHIFT)
-
-#define CTRL2_CPEN1_LOWPWR0 ((1 << CTRL2_CPEN_SHIFT) | \
- (0 << CTRL2_LOWPWR_SHIFT))
-#define CTRL2_CPEN0_LOWPWR1 ((0 << CTRL2_CPEN_SHIFT) | \
- (1 << CTRL2_LOWPWR_SHIFT))
+#define MAXIM_CONTROL2_LOWPWR_SHIFT 0
+#define MAXIM_CONTROL2_ADCEN_SHIFT 1
+#define MAXIM_CONTROL2_CPEN_SHIFT 2
+#define MAXIM_CONTROL2_SFOUTASRT_SHIFT 3
+#define MAXIM_CONTROL2_SFOUTORD_SHIFT 4
+#define MAXIM_CONTROL2_ACCDET_SHIFT 5
+#define MAXIM_CONTROL2_USBCPINT_SHIFT 6
+#define MAXIM_CONTROL2_RCPS_SHIFT 7
+#define MAXIM_CONTROL2_LOWPWR_MASK (0x1 << MAXIM_CONTROL2_LOWPWR_SHIFT)
+#define MAXIM_CONTROL2_ADCEN_MASK (0x1 << MAXIM_CONTROL2_ADCEN_SHIFT)
+#define MAXIM_CONTROL2_CPEN_MASK (0x1 << MAXIM_CONTROL2_CPEN_SHIFT)
+#define MAXIM_CONTROL2_SFOUTASRT_MASK (0x1 << MAXIM_CONTROL2_SFOUTASRT_SHIFT)
+#define MAXIM_CONTROL2_SFOUTORD_MASK (0x1 << MAXIM_CONTROL2_SFOUTORD_SHIFT)
+#define MAXIM_CONTROL2_ACCDET_MASK (0x1 << MAXIM_CONTROL2_ACCDET_SHIFT)
+#define MAXIM_CONTROL2_USBCPINT_MASK (0x1 << MAXIM_CONTROL2_USBCPINT_SHIFT)
+#define MAXIM_CONTROL2_RCPS_MASK (0x1 << MAXIM_CONTROL2_RCPS_SHIFT)
+
+#define MAXIM_CONTROL2_CPEN1_LOWPWR0 ((1 << MAXIM_CONTROL2_CPEN_SHIFT) | \
+ (0 << MAXIM_CONTROL2_LOWPWR_SHIFT))
+#define MAXIM_CONTROL2_CPEN0_LOWPWR1 ((0 << MAXIM_CONTROL2_CPEN_SHIFT) | \
+ (1 << MAXIM_CONTROL2_LOWPWR_SHIFT))
/* MAX14577 CONTROL3 register */
-#define CTRL3_JIGSET_SHIFT 0
-#define CTRL3_BOOTSET_SHIFT 2
-#define CTRL3_ADCDBSET_SHIFT 4
-#define CTRL3_JIGSET_MASK (0x3 << CTRL3_JIGSET_SHIFT)
-#define CTRL3_BOOTSET_MASK (0x3 << CTRL3_BOOTSET_SHIFT)
-#define CTRL3_ADCDBSET_MASK (0x3 << CTRL3_ADCDBSET_SHIFT)
-
-/* Slave addr = 0x4A: Charger */
-enum max14577_charger_reg {
- MAX14577_CHG_REG_STATUS3 = 0x06,
- MAX14577_CHG_REG_CHG_CTRL1 = 0x0F,
- MAX14577_CHG_REG_CHG_CTRL2 = 0x10,
- MAX14577_CHG_REG_CHG_CTRL3 = 0x11,
- MAX14577_CHG_REG_CHG_CTRL4 = 0x12,
- MAX14577_CHG_REG_CHG_CTRL5 = 0x13,
- MAX14577_CHG_REG_CHG_CTRL6 = 0x14,
- MAX14577_CHG_REG_CHG_CTRL7 = 0x15,
-
- MAX14577_CHG_REG_END,
-};
-
-/* MAX14577 STATUS3 register */
-#define STATUS3_EOC_SHIFT 0
-#define STATUS3_CGMBC_SHIFT 1
-#define STATUS3_OVP_SHIFT 2
-#define STATUS3_MBCCHGERR_SHIFT 3
-#define STATUS3_EOC_MASK (0x1 << STATUS3_EOC_SHIFT)
-#define STATUS3_CGMBC_MASK (0x1 << STATUS3_CGMBC_SHIFT)
-#define STATUS3_OVP_MASK (0x1 << STATUS3_OVP_SHIFT)
-#define STATUS3_MBCCHGERR_MASK (0x1 << STATUS3_MBCCHGERR_SHIFT)
+#define MAXIM_CONTROL3_JIGSET_SHIFT 0
+#define MAXIM_CONTROL3_BOOTSET_SHIFT 2
+#define MAXIM_CONTROL3_ADCDBSET_SHIFT 4
+#define MAXIM_CONTROL3_JIGSET_MASK (0x3 << MAXIM_CONTROL3_JIGSET_SHIFT)
+#define MAXIM_CONTROL3_BOOTSET_MASK (0x3 << MAXIM_CONTROL3_BOOTSET_SHIFT)
+#define MAXIM_CONTROL3_ADCDBSET_MASK (0x3 << MAXIM_CONTROL3_ADCDBSET_SHIFT)
/* MAX14577 CDETCTRL1 register */
-#define CDETCTRL1_CHGDETEN_SHIFT 0
-#define CDETCTRL1_CHGTYPMAN_SHIFT 1
-#define CDETCTRL1_DCDEN_SHIFT 2
-#define CDETCTRL1_DCD2SCT_SHIFT 3
-#define CDETCTRL1_DCHKTM_SHIFT 4
-#define CDETCTRL1_DBEXIT_SHIFT 5
-#define CDETCTRL1_DBIDLE_SHIFT 6
-#define CDETCTRL1_CDPDET_SHIFT 7
-#define CDETCTRL1_CHGDETEN_MASK (0x1 << CDETCTRL1_CHGDETEN_SHIFT)
-#define CDETCTRL1_CHGTYPMAN_MASK (0x1 << CDETCTRL1_CHGTYPMAN_SHIFT)
-#define CDETCTRL1_DCDEN_MASK (0x1 << CDETCTRL1_DCDEN_SHIFT)
-#define CDETCTRL1_DCD2SCT_MASK (0x1 << CDETCTRL1_DCD2SCT_SHIFT)
-#define CDETCTRL1_DCHKTM_MASK (0x1 << CDETCTRL1_DCHKTM_SHIFT)
-#define CDETCTRL1_DBEXIT_MASK (0x1 << CDETCTRL1_DBEXIT_SHIFT)
-#define CDETCTRL1_DBIDLE_MASK (0x1 << CDETCTRL1_DBIDLE_SHIFT)
-#define CDETCTRL1_CDPDET_MASK (0x1 << CDETCTRL1_CDPDET_SHIFT)
-
-/* MAX14577 CHGCTRL1 register */
-#define CHGCTRL1_TCHW_SHIFT 4
-#define CHGCTRL1_TCHW_MASK (0x7 << CHGCTRL1_TCHW_SHIFT)
-
-/* MAX14577 CHGCTRL2 register */
-#define CHGCTRL2_MBCHOSTEN_SHIFT 6
-#define CHGCTRL2_MBCHOSTEN_MASK (0x1 << CHGCTRL2_MBCHOSTEN_SHIFT)
-#define CHGCTRL2_VCHGR_RC_SHIFT 7
-#define CHGCTRL2_VCHGR_RC_MASK (0x1 << CHGCTRL2_VCHGR_RC_SHIFT)
-
-/* MAX14577 CHGCTRL3 register */
-#define CHGCTRL3_MBCCVWRC_SHIFT 0
-#define CHGCTRL3_MBCCVWRC_MASK (0xf << CHGCTRL3_MBCCVWRC_SHIFT)
-
-/* MAX14577 CHGCTRL4 register */
-#define CHGCTRL4_MBCICHWRCH_SHIFT 0
-#define CHGCTRL4_MBCICHWRCH_MASK (0xf << CHGCTRL4_MBCICHWRCH_SHIFT)
-#define CHGCTRL4_MBCICHWRCL_SHIFT 4
-#define CHGCTRL4_MBCICHWRCL_MASK (0x1 << CHGCTRL4_MBCICHWRCL_SHIFT)
-
-/* MAX14577 CHGCTRL5 register */
-#define CHGCTRL5_EOCS_SHIFT 0
-#define CHGCTRL5_EOCS_MASK (0xf << CHGCTRL5_EOCS_SHIFT)
-
-/* MAX14577 CHGCTRL6 register */
-#define CHGCTRL6_AUTOSTOP_SHIFT 5
-#define CHGCTRL6_AUTOSTOP_MASK (0x1 << CHGCTRL6_AUTOSTOP_SHIFT)
-
-/* MAX14577 CHGCTRL7 register */
-#define CHGCTRL7_OTPCGHCVS_SHIFT 0
-#define CHGCTRL7_OTPCGHCVS_MASK (0x3 << CHGCTRL7_OTPCGHCVS_SHIFT)
-
-/* MAX14577 regulator current limits (as in CHGCTRL4 register), uA */
+#define MAXIM_CDETCTRL1_CHGDETEN_SHIFT 0
+#define MAXIM_CDETCTRL1_CHGTYPMAN_SHIFT 1
+#define MAXIM_CDETCTRL1_DCDEN_SHIFT 2
+#define MAXIM_CDETCTRL1_DCD2SCT_SHIFT 3
+#define MAXIM_CDETCTRL1_DCHKTM_SHIFT 4
+#define MAXIM_CDETCTRL1_DBEXIT_SHIFT 5
+#define MAXIM_CDETCTRL1_DBIDLE_SHIFT 6
+#define MAXIM_CDETCTRL1_CDPDET_SHIFT 7
+#define MAXIM_CDETCTRL1_CHGDETEN_MASK (0x1 << MAXIM_CDETCTRL1_CHGDETEN_SHIFT)
+#define MAXIM_CDETCTRL1_CHGTYPMAN_MASK (0x1 << MAXIM_CDETCTRL1_CHGTYPMAN_SHIFT)
+#define MAXIM_CDETCTRL1_DCDEN_MASK (0x1 << MAXIM_CDETCTRL1_DCDEN_SHIFT)
+#define MAXIM_CDETCTRL1_DCD2SCT_MASK (0x1 << MAXIM_CDETCTRL1_DCD2SCT_SHIFT)
+#define MAXIM_CDETCTRL1_DCHKTM_MASK (0x1 << MAXIM_CDETCTRL1_DCHKTM_SHIFT)
+#define MAXIM_CDETCTRL1_DBEXIT_MASK (0x1 << MAXIM_CDETCTRL1_DBEXIT_SHIFT)
+#define MAXIM_CDETCTRL1_DBIDLE_MASK (0x1 << MAXIM_CDETCTRL1_DBIDLE_SHIFT)
+#define MAXIM_CDETCTRL1_CDPDET_MASK (0x1 << MAXIM_CDETCTRL1_CDPDET_SHIFT)
+
+/* MAX14577 MAXIM_CHGCTRL1 register */
+#define MAXIM_CHGCTRL1_TCHW_SHIFT 4
+#define MAXIM_CHGCTRL1_TCHW_MASK (0x7 << MAXIM_CHGCTRL1_TCHW_SHIFT)
+
+/* MAX14577 MAXIM_CHGCTRL2 register */
+#define MAXIM_CHGCTRL2_MBCHOSTEN_SHIFT 6
+#define MAXIM_CHGCTRL2_MBCHOSTEN_MASK (0x1 << MAXIM_CHGCTRL2_MBCHOSTEN_SHIFT)
+#define MAXIM_CHGCTRL2_VCHGR_RC_SHIFT 7
+#define MAXIM_CHGCTRL2_VCHGR_RC_MASK (0x1 << MAXIM_CHGCTRL2_VCHGR_RC_SHIFT)
+
+/* MAX14577 MAXIM_CHGCTRL3 register */
+#define MAXIM_CHGCTRL3_MBCCVWRC_SHIFT 0
+#define MAXIM_CHGCTRL3_MBCCVWRC_MASK (0xf << MAXIM_CHGCTRL3_MBCCVWRC_SHIFT)
+
+/* MAX14577 MAXIM_CHGCTRL4 register */
+#define MAXIM_CHGCTRL4_MBCICHWRCH_SHIFT 0
+#define MAXIM_CHGCTRL4_MBCICHWRCH_MASK (0xf << MAXIM_CHGCTRL4_MBCICHWRCH_SHIFT)
+#define MAXIM_CHGCTRL4_MBCICHWRCL_SHIFT 4
+#define MAXIM_CHGCTRL4_MBCICHWRCL_MASK (0x1 << MAXIM_CHGCTRL4_MBCICHWRCL_SHIFT)
+
+/* MAX14577 MAXIM_CHGCTRL5 register */
+#define MAXIM_CHGCTRL5_EOCS_SHIFT 0
+#define MAXIM_CHGCTRL5_EOCS_MASK (0xf << MAXIM_CHGCTRL5_EOCS_SHIFT)
+
+/* MAX14577 MAXIM_CHGCTRL6 register */
+#define MAXIM_CHGCTRL6_AUTOSTOP_SHIFT 5
+#define MAXIM_CHGCTRL6_AUTOSTOP_MASK (0x1 << MAXIM_CHGCTRL6_AUTOSTOP_SHIFT)
+
+/* MAX14577 MAXIM_CHGCTRL7 register */
+#define MAXIM_CHGCTRL7_OTPCGHCVS_SHIFT 0
+#define MAXIM_CHGCTRL7_OTPCGHCVS_MASK (0x3 << MAXIM_CHGCTRL7_OTPCGHCVS_SHIFT)
+
+/* MAX14577 regulator current limits (as in MAXIM_CHGCTRL4 register), uA */
#define MAX14577_REGULATOR_CURRENT_LIMIT_MIN 90000
#define MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_START 200000
#define MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_STEP 50000
@@ -248,26 +223,28 @@ enum max14577_charger_reg {
/* MAX14577 regulator SFOUT LDO voltage, fixed, uV */
#define MAX14577_REGULATOR_SAFEOUT_VOLTAGE 4900000
-enum max14577_irq {
+
+
+enum maxim_irq {
/* INT1 */
- MAX14577_IRQ_INT1_ADC,
- MAX14577_IRQ_INT1_ADCLOW,
- MAX14577_IRQ_INT1_ADCERR,
+ MAXIM_IRQ_INT1_ADC,
+ MAXIM_IRQ_INT1_ADCLOW,
+ MAXIM_IRQ_INT1_ADCERR,
/* INT2 */
- MAX14577_IRQ_INT2_CHGTYP,
- MAX14577_IRQ_INT2_CHGDETRUN,
- MAX14577_IRQ_INT2_DCDTMR,
- MAX14577_IRQ_INT2_DBCHG,
- MAX14577_IRQ_INT2_VBVOLT,
+ MAXIM_IRQ_INT2_CHGTYP,
+ MAXIM_IRQ_INT2_CHGDETRUN,
+ MAXIM_IRQ_INT2_DCDTMR,
+ MAXIM_IRQ_INT2_DBCHG,
+ MAXIM_IRQ_INT2_VBVOLT,
/* INT3 */
- MAX14577_IRQ_INT3_EOC,
- MAX14577_IRQ_INT3_CGMBC,
- MAX14577_IRQ_INT3_OVP,
- MAX14577_IRQ_INT3_MBCCHGERR,
+ MAXIM_IRQ_INT3_EOC,
+ MAXIM_IRQ_INT3_CGMBC,
+ MAXIM_IRQ_INT3_OVP,
+ MAXIM_IRQ_INT3_MBCCHGERR,
- MAX14577_IRQ_NUM,
+ MAXIM_IRQ_NUM,
};
struct max14577 {
diff --git a/include/linux/mfd/max14577.h b/include/linux/mfd/max14577.h
index 736d39c3ec0d..75301be5c548 100644
--- a/include/linux/mfd/max14577.h
+++ b/include/linux/mfd/max14577.h
@@ -32,7 +32,7 @@ enum max14577_regulators {
MAX14577_SAFEOUT = 0,
MAX14577_CHARGER,
- MAX14577_REG_MAX,
+ MAX14577_REG_NUM,
};
struct max14577_regulator_platform_data {
--
1.7.9.5
Use of_match_ptr() in assignment of i2c_driver.of_match_table.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: Marek Szyprowski <[email protected]>
---
drivers/mfd/max14577.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mfd/max14577.c b/drivers/mfd/max14577.c
index 2ac2f2d7cea6..75b37082a3fe 100644
--- a/drivers/mfd/max14577.c
+++ b/drivers/mfd/max14577.c
@@ -224,7 +224,7 @@ static struct i2c_driver max14577_i2c_driver = {
.name = "max14577",
.owner = THIS_MODULE,
.pm = &max14577_pm,
- .of_match_table = max14577_dt_match,
+ .of_match_table = of_match_ptr(max14577_dt_match),
},
.probe = max14577_i2c_probe,
.remove = max14577_i2c_remove,
--
1.7.9.5
Add of_compatible ("maxim,max14577-muic") to the mfd_cell for extcon
driver. If entry with such compatible is present in the DTS, the extcon
driver will have of_node set.
This may be useful for extcon consumers and it is documented in
bindings documentation.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Cc: Kyungmin Park <[email protected]>
Cc: Marek Szyprowski <[email protected]>
---
drivers/mfd/max14577.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/mfd/max14577.c b/drivers/mfd/max14577.c
index ac514fb2b877..2ac2f2d7cea6 100644
--- a/drivers/mfd/max14577.c
+++ b/drivers/mfd/max14577.c
@@ -25,7 +25,10 @@
#include <linux/mfd/max14577-private.h>
static struct mfd_cell max14577_devs[] = {
- { .name = "max14577-muic", },
+ {
+ .name = "max14577-muic",
+ .of_compatible = "maxim,max14577-muic",
+ },
{
.name = "max14577-regulator",
.of_compatible = "maxim,max14577-regulator",
--
1.7.9.5
On Tue, Jan 28, 2014 at 01:18:25PM +0100, Krzysztof Kozlowski wrote:
> Remove the "struct max14577_regulator" because this is not used
> anywhere. It should be removed earlier along with changing the driver
> after review on the mailing lists.
Applied, thanks.
On Tue, Jan 28, 2014 at 01:18:39PM +0100, Krzysztof Kozlowski wrote:
> Add support for MAX77836 chipset and its additional two LDO regulators.
> These LDO regulators are controlled by the PMIC block with additional
> regmap (different I2C slave address).
Reviewed-by: Mark Brown <[email protected]>
This should go in with the rest of the changes I guess.
I would like to drop this patch.
It does not make sense as "max14577_dt_match" is always compiled and
of_match_ptr was removed on purpose by Sachin Kamat (ae679c12e8; mfd:
max14577: Remove redundant of_match_ptr helper).
Best regards,
Krzysztof Kozlowski
On Tue, 2014-01-28 at 13:18 +0100, Krzysztof Kozlowski wrote:
> Use of_match_ptr() in assignment of i2c_driver.of_match_table.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> Cc: Kyungmin Park <[email protected]>
> Cc: Marek Szyprowski <[email protected]>
> ---
> drivers/mfd/max14577.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/max14577.c b/drivers/mfd/max14577.c
> index 2ac2f2d7cea6..75b37082a3fe 100644
> --- a/drivers/mfd/max14577.c
> +++ b/drivers/mfd/max14577.c
> @@ -224,7 +224,7 @@ static struct i2c_driver max14577_i2c_driver = {
> .name = "max14577",
> .owner = THIS_MODULE,
> .pm = &max14577_pm,
> - .of_match_table = max14577_dt_match,
> + .of_match_table = of_match_ptr(max14577_dt_match),
> },
> .probe = max14577_i2c_probe,
> .remove = max14577_i2c_remove,
> Remove unused symbol: enum max14577_irq_source.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> Cc: Kyungmin Park <[email protected]>
> Cc: Marek Szyprowski <[email protected]>
> ---
> include/linux/mfd/max14577-private.h | 8 --------
> 1 file changed, 8 deletions(-)
Applied, thanks.
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
> Remove not needed max14577-private.h header inclusion in the main driver
> header. Remove obvious comment.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> Cc: Kyungmin Park <[email protected]>
> Cc: Marek Szyprowski <[email protected]>
> ---
> include/linux/mfd/max14577.h | 5 -----
> 1 file changed, 5 deletions(-)
Applied, thanks.
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
On Tue, 28 Jan 2014, Krzysztof Kozlowski wrote:
> Add of_compatible ("maxim,max14577-muic") to the mfd_cell for extcon
> driver. If entry with such compatible is present in the DTS, the extcon
> driver will have of_node set.
>
> This may be useful for extcon consumers and it is documented in
> bindings documentation.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> Cc: Kyungmin Park <[email protected]>
> Cc: Marek Szyprowski <[email protected]>
> ---
> drivers/mfd/max14577.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
Applied, thanks.
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
> Use of_match_ptr() in assignment of i2c_driver.of_match_table.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> Cc: Kyungmin Park <[email protected]>
> Cc: Marek Szyprowski <[email protected]>
> ---
> drivers/mfd/max14577.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/max14577.c b/drivers/mfd/max14577.c
> index 2ac2f2d7cea6..75b37082a3fe 100644
> --- a/drivers/mfd/max14577.c
> +++ b/drivers/mfd/max14577.c
> @@ -224,7 +224,7 @@ static struct i2c_driver max14577_i2c_driver = {
> .name = "max14577",
> .owner = THIS_MODULE,
> .pm = &max14577_pm,
> - .of_match_table = max14577_dt_match,
> + .of_match_table = of_match_ptr(max14577_dt_match),
Are you sure this is required?
> },
> .probe = max14577_i2c_probe,
> .remove = max14577_i2c_remove,
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
> This patch prepares for adding support for max77836 device to existing
> max14577 driver:
> 1. Renames most of symbols and defines prefixed with MAX14577 to MAXIM.
> 2. Adds prefixes (MAXIM or MAX14577) to defines without any MAX* prefix.
>
> This is only a rename-like patch, new code is not added.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> Cc: Kyungmin Park <[email protected]>
> Cc: Marek Szyprowski <[email protected]>
> ---
> drivers/extcon/extcon-max14577.c | 105 ++++-----
> drivers/mfd/max14577.c | 51 ++---
> drivers/power/max14577_charger.c | 81 +++----
> drivers/regulator/max14577.c | 44 ++--
> include/linux/mfd/max14577-private.h | 399 ++++++++++++++++------------------
> include/linux/mfd/max14577.h | 2 +-
> 6 files changed, 333 insertions(+), 349 deletions(-)
I think the name changes instil some clarity here.
I still need the other Acks before applying the patch though.
For now you can have my:
Acked-by: Lee Jones <[email protected]>
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
> This patch continues the preparation for adding support for max77836
> device to existing max14577 driver.
>
> The patch renames the struct "max14577" state container to "maxim_core".
> This is only a rename-like patch, new code is not added.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> Cc: Kyungmin Park <[email protected]>
> Cc: Marek Szyprowski <[email protected]>
> ---
> drivers/extcon/extcon-max14577.c | 22 +++++------
> drivers/mfd/max14577.c | 68 +++++++++++++++++-----------------
> drivers/power/max14577_charger.c | 16 ++++----
> drivers/regulator/max14577.c | 6 +--
> include/linux/mfd/max14577-private.h | 5 ++-
> 5 files changed, 60 insertions(+), 57 deletions(-)
Need some more maintainer Acks here.
> -struct max14577 {
> +/*
> + * State container for max14577-like drivers.
> + */
I don't think this comment is required.
Besides that, the code looks fine:
Acked-by: Lee Jones <[email protected]>
> +struct maxim_core {
> struct device *dev;
> struct i2c_client *i2c; /* Slave addr = 0x4A */
>
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
> This patch continues the preparation for adding support for max77836
> device to existing max14577 driver.
>
> Add "muic" suffix to regmap and irq_data fields in maxim_core state
> container to prepare for max77836 support.
> This is only a rename-like patch, new code is not added.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> Cc: Kyungmin Park <[email protected]>
> Cc: Marek Szyprowski <[email protected]>
> ---
> drivers/extcon/extcon-max14577.c | 17 +++++++++--------
> drivers/mfd/max14577.c | 22 +++++++++++-----------
> drivers/power/max14577_charger.c | 8 ++++----
> drivers/regulator/max14577.c | 2 +-
> include/linux/mfd/max14577-private.h | 4 ++--
> 5 files changed, 27 insertions(+), 26 deletions(-)
Happy to apply this with maintainer Acks.
Acked-by: Lee Jones <[email protected]>
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
> This patch continues the preparation for adding support for max77836
> device to existing max14577 driver.
>
> Add enum for types of devices supported by this driver. The device type
> will be detected by matching of_device_id, or i2c_device_id as a
> fallback.
>
> The patch also moves to separate function the code related to displaying
> DeviceID register values.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> Cc: Kyungmin Park <[email protected]>
> Cc: Marek Szyprowski <[email protected]>
> ---
> drivers/mfd/max14577.c | 61 +++++++++++++++++++++++-----------
> include/linux/mfd/max14577-private.h | 12 ++++---
> 2 files changed, 50 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/mfd/max14577.c b/drivers/mfd/max14577.c
> index 1d8104213b3e..224aba8c5b3f 100644
> --- a/drivers/mfd/max14577.c
> +++ b/drivers/mfd/max14577.c
> @@ -20,6 +20,7 @@
<snip>
> +static void max14577_print_dev_type(struct maxim_core *maxim_core)
> +{
> + u8 reg_data, vendor_id, device_id;
> + int ret = max14577_read_reg(maxim_core->regmap_muic,
> + MAXIM_MUIC_REG_DEVICEID, ®_data);
I'm not a big fan of declaring variables whilst feeding them with
function return values. Can you separate the two please?
> + if (ret) {
> + dev_err(maxim_core->dev, "Failed to read DEVICEID
> register: %d\n",
I think this is too many chars.
> + ret);
> + return;
> + }
> +
<snip>
> - ret = max14577_read_reg(maxim_core->regmap_muic,
> - MAXIM_MUIC_REG_DEVICEID, ®_data);
> - if (ret) {
> - dev_err(maxim_core->dev, "Device not found on this channel: %d\n",
> - ret);
> - return ret;
> + if (np) {
> + const struct of_device_id *of_id =
> + of_match_device(max14577_dt_match, &i2c->dev);
Again this is a bit messy. Bring it down onto a separate line.
> + if (of_id)
> + maxim_core->dev_type = (unsigned int)of_id->data;
> + } else {
> + maxim_core->dev_type = id->driver_data;
> }
<snip>
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
On Tue, 28 Jan 2014, Krzysztof Kozlowski wrote:
> Add Maxim 77836 support to max14577 driver. The chipsets have same MUIC
> component so the extcon, charger and regulators are almost the same. The
> max77836 however has also PMIC and Fuel Gauge.
>
> The MAX77836 uses three I2C slave addresses and has additional interrupts
> (related to PMIC and Fuel Gauge). It has also Interrupt Source register,
> just like MAX77686 and MAX77693.
>
> The MAX77836 PMIC's TOPSYS and INTSRC interrupts are reported in the
> PMIC block. The PMIC block has different I2C slave address and uses own
> regmap so another regmap_irq_chip is needed.
>
> Since we have two regmap_irq_chip, use shared interrupts on MAX77836.
>
> This patch adds additional defines and functions to the max14577 MFD core
> driver so the driver will handle both chipsets.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> Signed-off-by: Chanwoo Choi <[email protected]>
> Cc: Kyungmin Park <[email protected]>
> Cc: Marek Szyprowski <[email protected]>
> ---
> drivers/mfd/max14577.c | 215 ++++++++++++++++++++++++++++++++--
> include/linux/mfd/max14577-private.h | 85 +++++++++++++-
> include/linux/mfd/max14577.h | 7 +-
> 3 files changed, 296 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/mfd/max14577.c b/drivers/mfd/max14577.c
> index 224aba8c5b3f..5b10f6f89834 100644
> --- a/drivers/mfd/max14577.c
> +++ b/drivers/mfd/max14577.c
> @@ -1,7 +1,7 @@
> /*
> - * max14577.c - mfd core driver for the Maxim 14577
> + * max14577.c - mfd core driver for the Maxim 14577/77836
We may wish to consider changing the name of this file at a later
date.
> - * Copyright (C) 2013 Samsung Electrnoics
> + * Copyright (C) 2013,2014 Samsung Electrnoics
You can remove the the '2013' completely now.
> * Chanwoo Choi <[email protected]>
> * Krzysztof Kozlowski <[email protected]>
> *
> @@ -37,11 +37,31 @@ static struct mfd_cell max14577_devs[] = {
> { .name = "max14577-charger", },
> };
>
> +static struct mfd_cell max77836_devs[] = {
> + {
> + .name = "max77836-muic",
> + .of_compatible = "maxim,max77836-muic",
> + },
> + {
> + .name = "max77836-regulator",
> + .of_compatible = "maxim,max77836-regulator",
> + },
> + { .name = "max77836-charger", },
Why doesn't the charger require a compatible string?
> + {
> + .name = "max77836-battery",
> + .of_compatible = "maxim,max77836-battery",
> + },
> +};
> +
> @@ -56,6 +76,29 @@ static bool max14577_muic_volatile_reg(struct device *dev, unsigned int reg)
> return false;
> }
>
> +static bool max77836_muic_volatile_reg(struct device *dev, unsigned int reg)
> +{
> + /* Any max14577 volatile registers are also max77836 volatile. */
> + if (max14577_muic_volatile_reg(dev, reg))
> + return true;
New line here please.
> + switch (reg) {
> + case MAX77836_FG_REG_VCELL_MSB ... MAX77836_FG_REG_SOC_LSB:
> + case MAX77836_FG_REG_CRATE_MSB ... MAX77836_FG_REG_CRATE_LSB:
> + case MAX77836_FG_REG_STATUS_H ... MAX77836_FG_REG_STATUS_L:
> + /* fall through */
It's okay not to have these here. We know how switch statements
work. ;)
> + case MAX77836_PMIC_REG_INTSRC:
> + /* fall through */
> + case MAX77836_PMIC_REG_TOPSYS_INT:
> + /* fall through */
> + case MAX77836_PMIC_REG_TOPSYS_STAT:
> + return true;
> + default:
> + break;
> + }
> + return false;
> +}
> +
> +
Superfluous new line here.
> +static const struct regmap_irq_chip max77836_muic_irq_chip = {
> + .name = "max77836-muic",
> + .status_base = MAXIM_MUIC_REG_INT1,
> + .mask_base = MAXIM_MUIC_REG_INTMASK1,
> + .mask_invert = 1,
I'd prefer the use of 'true' or 'false' for bools.
> + .num_regs = 3,
> + .irqs = max77836_muic_irqs,
> + .num_irqs = ARRAY_SIZE(max77836_muic_irqs),
> +};
> +
<snip>
> +static const struct regmap_irq_chip max77836_pmic_irq_chip = {
> + .name = "max77836-pmic",
> + .status_base = MAX77836_PMIC_REG_TOPSYS_INT,
> + .mask_base = MAX77836_PMIC_REG_TOPSYS_INT_MASK,
> + .mask_invert = 0,
'false' please.
> + .num_regs = 1,
> + .irqs = max77836_pmic_irqs,
> + .num_irqs = ARRAY_SIZE(max77836_pmic_irqs),
> +};
> +
<snip>
> +static int max77836_init(struct maxim_core *maxim_core)
> +{
> + int ret;
> + u8 intsrc_mask;
> +
> + maxim_core->i2c_pmic = i2c_new_dummy(maxim_core->i2c->adapter,
> + I2C_ADDR_PMIC);
> + if (!maxim_core->i2c_pmic) {
> + dev_err(maxim_core->dev, "Failed to register PMIC I2C device\n");
> + return -EPERM;
Not sure this is the best errno to return.
Perhaps -ENODEV would be more suitable?
<snip>
> #define MAXIM_STATUS2_CHGTYP_MASK (0x7 << MAXIM_STATUS2_CHGTYP_SHIFT)
> #define MAXIM_STATUS2_CHGDETRUN_MASK (0x1 << MAXIM_STATUS2_CHGDETRUN_SHIFT)
> #define MAXIM_STATUS2_DCDTMR_MASK (0x1 << MAXIM_STATUS2_DCDTMR_SHIFT)
> #define MAXIM_STATUS2_DBCHG_MASK (0x1 << MAXIM_STATUS2_DBCHG_SHIFT)
> #define MAXIM_STATUS2_VBVOLT_MASK (0x1 << MAXIM_STATUS2_VBVOLT_SHIFT)
> +#define MAX77836_STATUS2_VIDRM_MASK (0x1 << MAX77836_STATUS2_VIDRM_SHIFT)
It's up to you, but all of these "0x1 <<"s can be replaced with the
BIT() macro if you so wished.
> /* MAX14577 STATUS3 register */
> #define MAXIM_STATUS3_EOC_SHIFT 0
> @@ -232,6 +242,70 @@ enum maxim_muic_charger_type {
>
>
>
Do all of these extra new lines really exist, or is it just a patch
thing? If they do, can you get rid of them please?
> +/* Slave addr = 0x46: PMIC */
> +enum max77836_pmic_reg {
> + MAX77836_COMP_REG_COMP1 = 0x60,
> +
> + MAX77836_LDO_REG_CNFG1_LDO1 = 0x51,
> + MAX77836_LDO_REG_CNFG2_LDO1 = 0x52,
> + MAX77836_LDO_REG_CNFG1_LDO2 = 0x53,
> + MAX77836_LDO_REG_CNFG2_LDO2 = 0x54,
> + MAX77836_LDO_REG_CNFG_LDO_BIAS = 0x55,
> +
> + MAX77836_PMIC_REG_PMIC_ID = 0x20,
> + MAX77836_PMIC_REG_PMIC_REV = 0x21,
> + MAX77836_PMIC_REG_INTSRC = 0x22,
> + MAX77836_PMIC_REG_INTSRC_MASK = 0x23,
> + MAX77836_PMIC_REG_TOPSYS_INT = 0x24,
> + MAX77836_PMIC_REG_TOPSYS_INT_MASK = 0x26,
> + MAX77836_PMIC_REG_TOPSYS_STAT = 0x28,
> + MAX77836_PMIC_REG_MRSTB_CNTL = 0x2A,
> + MAX77836_PMIC_REG_LSCNFG = 0x2B,
> +
> + MAX77836_PMIC_REG_END,
> +};
Any reason why these aren't in numerical order?
<snip>
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
On Tue, 28 Jan 2014, Krzysztof Kozlowski wrote:
> Add support for MAX77836 chipset to the max14577 extcon driver. The
> MAX77836 MUIC has additional interrupts (VIDRM, ADC1K) so IRQ handling
> is split up into two functions: max14577_parse_irq() and
> max77836_parse_irq().
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> Signed-off-by: Chanwoo Choi <[email protected]>
> Cc: Kyungmin Park <[email protected]>
> Cc: Marek Szyprowski <[email protected]>
> ---
> drivers/extcon/extcon-max14577.c | 107 ++++++++++++++++++++++++++++------
> drivers/mfd/max14577.c | 1 +
> include/linux/mfd/max14577-private.h | 3 +
> 3 files changed, 93 insertions(+), 18 deletions(-)
For the MFD changes:
Acked-by: Lee Jones <[email protected]>
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
On Tue, 28 Jan 2014, Krzysztof Kozlowski wrote:
> Add support for MAX77836 chipset and its additional two LDO regulators.
> These LDO regulators are controlled by the PMIC block with additional
> regmap (different I2C slave address).
>
> The MAX77836 charger and safeout regulators are almost identical to
> MAX14577. The registry layout is the same, except values for charger's
> current. The patch adds simple mapping between device type and supported
> current by the charger regulator.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> Cc: Kyungmin Park <[email protected]>
> Cc: Marek Szyprowski <[email protected]>
> ---
> drivers/regulator/max14577.c | 275 +++++++++++++++++++++++++++++-----
> include/linux/mfd/max14577-private.h | 32 +++-
> include/linux/mfd/max14577.h | 10 ++
> 3 files changed, 281 insertions(+), 36 deletions(-)
For the MFD changes:
Acked-by: Lee Jones <[email protected]>
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
On Tue, 28 Jan 2014, Krzysztof Kozlowski wrote:
> Add support for MAX77836 charger to the max14577 driver. The MAX77836
> charger is almost the same as 14577 model except:
> - No dead-battery detection;
> - Support for special charger (like in max77693);
> - Support for DX over-voltage protection (like in max77693);
> - Lower values of charging current (two times lower current for
> slow/fast charge, much lower EOC current);
> - Slightly different values in ChgTyp field of STATUS2 register. On
> MAX14577 0x6 is reserved and 0x7 dead battery. On the MAX77836 the
> 0x6 means special charger and 0x7 is reserved. Regardless of these
> differences the driver maps them to one enum maxim_muic_charger_type.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> Cc: Kyungmin Park <[email protected]>
> Cc: Marek Szyprowski <[email protected]>
> Cc: Anton Vorontsov <[email protected]>
> Cc: Dmitry Eremin-Solenikov <[email protected]>
> Cc: David Woodhouse <[email protected]>
> ---
> drivers/extcon/extcon-max14577.c | 2 +-
> drivers/power/max14577_charger.c | 81 +++++++++++++++++++++++++++-------
> include/linux/mfd/max14577-private.h | 57 +++++++++++++++++-------
> 3 files changed, 106 insertions(+), 34 deletions(-)
For the MFD changes:
Acked-by: Lee Jones <[email protected]>
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
On Tue, Jan 28, 2014 at 01:18:40PM +0100, Krzysztof Kozlowski wrote:
> - /* Battery-Charger Constant Voltage (CV) Mode, from SM-V700: 4.35V */
> + /* Battery-Charger Constant Voltage (CV) Mode, set to: 4.35V */
Does this charger chip support only 4.35V batteries? If the CV is hard coded
to 4.35V, it's not safe for 4.2V batteries.
> + /* End-of-Charge Current, set to 50mA (max14577) / 7.5mA (max77836) */
The End of charge current basically depend on battery and not on charger chip.
> - /* Overvoltage-Protection Threshold, from SM-V700: 6.5V */
> + /* Overvoltage-Protection Threshold, set to 6.5V */
6.5V as over voltage for battery? A 4.35V battery would have exploded by
that time!
On 01/28/2014 09:18 PM, Krzysztof Kozlowski wrote:
> From: Chanwoo Choi <[email protected]>
>
> This patch use device name to make sysfs path according to device type:
>
> max14577-muic
> - /sys/class/extcon/max14577-muic/
> max77836-muic
> - /sys/class/extcon/max77836-muic/
>
> Signed-off-by: Chanwoo Choi <[email protected]>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> Cc: Kyungmin Park <[email protected]>
> Cc: Marek Szyprowski <[email protected]>
> ---
Applied.
Thanks,
Chanwoo Choi
Hi Krzysztof,
Following patch has conflict on extcon-next branch(Linus 3.14-rc1)
when apply patchset by using git am.
[PATCH 11/18] extcon: max14577: Add max14577 prefix to muic_irqs
[PATCH 12/18] extcon: max14577: Choose muic_irqs according to device type
[PATCH 14/18] extcon: max14577: Add support for max77836
The base commit of this patchset isn't mainline. You need to rebase this patchset
on extcon-next branch and please resend this patchset.
Thanks,
Chanwoo Choi
On 01/28/2014 09:18 PM, Krzysztof Kozlowski wrote:
> Add max14577 prefix to muic_irqs array. This prepares for max77836
> support in this extcon driver.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> Cc: Kyungmin Park <[email protected]>
> Cc: Marek Szyprowski <[email protected]>
> ---
> drivers/extcon/extcon-max14577.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
> index fd48b4909470..fb343f4042d2 100644
> --- a/drivers/extcon/extcon-max14577.c
> +++ b/drivers/extcon/extcon-max14577.c
> @@ -85,7 +85,7 @@ struct max14577_muic_irq {
> unsigned int virq;
> };
>
> -static struct max14577_muic_irq muic_irqs[] = {
> +static struct max14577_muic_irq max14577_muic_irqs[] = {
> { MAXIM_IRQ_INT1_ADC, "muic-ADC" },
> { MAXIM_IRQ_INT1_ADCLOW, "muic-ADCLOW" },
> { MAXIM_IRQ_INT1_ADCERR, "muic-ADCError" },
> @@ -541,9 +541,9 @@ static irqreturn_t max14577_muic_irq_handler(int irq, void *data)
> * However we only need to know whether it was ADC, charger
> * or both interrupts so decode IRQ and turn on proper flags.
> */
> - for (i = 0; i < ARRAY_SIZE(muic_irqs); i++)
> - if (irq == muic_irqs[i].virq)
> - irq_type = muic_irqs[i].irq;
> + for (i = 0; i < ARRAY_SIZE(max14577_muic_irqs); i++)
> + if (irq == max14577_muic_irqs[i].virq)
> + irq_type = max14577_muic_irqs[i].irq;
>
> switch (irq_type) {
> case MAXIM_IRQ_INT1_ADC:
> @@ -647,8 +647,8 @@ static int max14577_muic_probe(struct platform_device *pdev)
> INIT_WORK(&info->irq_work, max14577_muic_irq_work);
>
> /* Support irq domain for max14577 MUIC device */
> - for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) {
> - struct max14577_muic_irq *muic_irq = &muic_irqs[i];
> + for (i = 0; i < ARRAY_SIZE(max14577_muic_irqs); i++) {
> + struct max14577_muic_irq *muic_irq = &max14577_muic_irqs[i];
> unsigned int virq = 0;
>
> virq = regmap_irq_get_virq(maxim_core->irq_data_muic,
>
On Wed, 2014-02-05 at 09:47 +0900, Chanwoo Choi wrote:
> Hi Krzysztof,
>
> Following patch has conflict on extcon-next branch(Linus 3.14-rc1)
> when apply patchset by using git am.
>
> [PATCH 11/18] extcon: max14577: Add max14577 prefix to muic_irqs
> [PATCH 12/18] extcon: max14577: Choose muic_irqs according to device type
> [PATCH 14/18] extcon: max14577: Add support for max77836
>
> The base commit of this patchset isn't mainline. You need to rebase this patchset
> on extcon-next branch and please resend this patchset.
>
> Thanks,
> Chanwoo Choi
Hi,
This patch patch (along with other) depends on previous rename patches
from this patchset:
[PATCH 07/18] mfd: max14577: Rename and add MAX14577 symbols to prepare
for max77836
http://article.gmane.org/gmane.linux.kernel/1636674
I can resolve the conflict but then they will return on applying patch
7/18.
I think this patch may wait for a little until the rename-like patches
will be accepted.
Can you ACK other patches touch extcon?
- [PATCH 07/18] mfd: max14577: Rename and add MAX14577 symbols...
- [PATCH 08/18] mfd: max14577: Rename state container to maxim_core
- [PATCH 09/18] mfd: max14577: Add "muic" suffix to regmap and irq_chip
Best regards,
Krzysztof
> On 01/28/2014 09:18 PM, Krzysztof Kozlowski wrote:
> > Add max14577 prefix to muic_irqs array. This prepares for max77836
> > support in this extcon driver.
> >
> > Signed-off-by: Krzysztof Kozlowski <[email protected]>
> > Cc: Kyungmin Park <[email protected]>
> > Cc: Marek Szyprowski <[email protected]>
> > ---
> > drivers/extcon/extcon-max14577.c | 12 ++++++------
> > 1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
> > index fd48b4909470..fb343f4042d2 100644
> > --- a/drivers/extcon/extcon-max14577.c
> > +++ b/drivers/extcon/extcon-max14577.c
> > @@ -85,7 +85,7 @@ struct max14577_muic_irq {
> > unsigned int virq;
> > };
> >
> > -static struct max14577_muic_irq muic_irqs[] = {
> > +static struct max14577_muic_irq max14577_muic_irqs[] = {
> > { MAXIM_IRQ_INT1_ADC, "muic-ADC" },
> > { MAXIM_IRQ_INT1_ADCLOW, "muic-ADCLOW" },
> > { MAXIM_IRQ_INT1_ADCERR, "muic-ADCError" },
> > @@ -541,9 +541,9 @@ static irqreturn_t max14577_muic_irq_handler(int irq, void *data)
> > * However we only need to know whether it was ADC, charger
> > * or both interrupts so decode IRQ and turn on proper flags.
> > */
> > - for (i = 0; i < ARRAY_SIZE(muic_irqs); i++)
> > - if (irq == muic_irqs[i].virq)
> > - irq_type = muic_irqs[i].irq;
> > + for (i = 0; i < ARRAY_SIZE(max14577_muic_irqs); i++)
> > + if (irq == max14577_muic_irqs[i].virq)
> > + irq_type = max14577_muic_irqs[i].irq;
> >
> > switch (irq_type) {
> > case MAXIM_IRQ_INT1_ADC:
> > @@ -647,8 +647,8 @@ static int max14577_muic_probe(struct platform_device *pdev)
> > INIT_WORK(&info->irq_work, max14577_muic_irq_work);
> >
> > /* Support irq domain for max14577 MUIC device */
> > - for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) {
> > - struct max14577_muic_irq *muic_irq = &muic_irqs[i];
> > + for (i = 0; i < ARRAY_SIZE(max14577_muic_irqs); i++) {
> > + struct max14577_muic_irq *muic_irq = &max14577_muic_irqs[i];
> > unsigned int virq = 0;
> >
> > virq = regmap_irq_get_virq(maxim_core->irq_data_muic,
> >
On Mon, 2014-02-03 at 09:30 +0000, Lee Jones wrote:
> > Use of_match_ptr() in assignment of i2c_driver.of_match_table.
> >
> > Signed-off-by: Krzysztof Kozlowski <[email protected]>
> > Cc: Kyungmin Park <[email protected]>
> > Cc: Marek Szyprowski <[email protected]>
> > ---
> > drivers/mfd/max14577.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/mfd/max14577.c b/drivers/mfd/max14577.c
> > index 2ac2f2d7cea6..75b37082a3fe 100644
> > --- a/drivers/mfd/max14577.c
> > +++ b/drivers/mfd/max14577.c
> > @@ -224,7 +224,7 @@ static struct i2c_driver max14577_i2c_driver = {
> > .name = "max14577",
> > .owner = THIS_MODULE,
> > .pm = &max14577_pm,
> > - .of_match_table = max14577_dt_match,
> > + .of_match_table = of_match_ptr(max14577_dt_match),
>
> Are you sure this is required?
No, it was my mistake. Please ignore this patch.
Krzysztof
Thanks for ACK.
Dear Chanwoo, Mark and Dmitry, can you ACK this patch and also 8/18 and
9/18:
http://thread.gmane.org/gmane.linux.kernel/1636654/focus=1636674
http://thread.gmane.org/gmane.linux.kernel/1636654/focus=1636674
?
Best regards,
Krzysztof
On Mon, 2014-02-03 at 09:38 +0000, Lee Jones wrote:
> > This patch prepares for adding support for max77836 device to existing
> > max14577 driver:
> > 1. Renames most of symbols and defines prefixed with MAX14577 to MAXIM.
> > 2. Adds prefixes (MAXIM or MAX14577) to defines without any MAX* prefix.
> >
> > This is only a rename-like patch, new code is not added.
> >
> > Signed-off-by: Krzysztof Kozlowski <[email protected]>
> > Cc: Kyungmin Park <[email protected]>
> > Cc: Marek Szyprowski <[email protected]>
> > ---
> > drivers/extcon/extcon-max14577.c | 105 ++++-----
> > drivers/mfd/max14577.c | 51 ++---
> > drivers/power/max14577_charger.c | 81 +++----
> > drivers/regulator/max14577.c | 44 ++--
> > include/linux/mfd/max14577-private.h | 399 ++++++++++++++++------------------
> > include/linux/mfd/max14577.h | 2 +-
> > 6 files changed, 333 insertions(+), 349 deletions(-)
>
> I think the name changes instil some clarity here.
>
> I still need the other Acks before applying the patch though.
>
> For now you can have my:
> Acked-by: Lee Jones <[email protected]>
>
+Cc: Chanwoo, Mark and Dmitry for ACK-s on their subsystems.
Krzysztof Kozlowski
On Mon, 2014-02-03 at 09:45 +0000, Lee Jones wrote:
> > This patch continues the preparation for adding support for max77836
> > device to existing max14577 driver.
> >
> > Add "muic" suffix to regmap and irq_data fields in maxim_core state
> > container to prepare for max77836 support.
> > This is only a rename-like patch, new code is not added.
> >
> > Signed-off-by: Krzysztof Kozlowski <[email protected]>
> > Cc: Kyungmin Park <[email protected]>
> > Cc: Marek Szyprowski <[email protected]>
> > ---
> > drivers/extcon/extcon-max14577.c | 17 +++++++++--------
> > drivers/mfd/max14577.c | 22 +++++++++++-----------
> > drivers/power/max14577_charger.c | 8 ++++----
> > drivers/regulator/max14577.c | 2 +-
> > include/linux/mfd/max14577-private.h | 4 ++--
> > 5 files changed, 27 insertions(+), 26 deletions(-)
>
> Happy to apply this with maintainer Acks.
> Acked-by: Lee Jones <[email protected]>
>
+Cc: Chanwoo, Mark and Dmitry for ACK-s on their subsystems.
Krzysztof Kozlowski
On Mon, 2014-02-03 at 09:42 +0000, Lee Jones wrote:
> > This patch continues the preparation for adding support for max77836
> > device to existing max14577 driver.
> >
> > The patch renames the struct "max14577" state container to "maxim_core".
> > This is only a rename-like patch, new code is not added.
> >
> > Signed-off-by: Krzysztof Kozlowski <[email protected]>
> > Cc: Kyungmin Park <[email protected]>
> > Cc: Marek Szyprowski <[email protected]>
> > ---
> > drivers/extcon/extcon-max14577.c | 22 +++++------
> > drivers/mfd/max14577.c | 68 +++++++++++++++++-----------------
> > drivers/power/max14577_charger.c | 16 ++++----
> > drivers/regulator/max14577.c | 6 +--
> > include/linux/mfd/max14577-private.h | 5 ++-
> > 5 files changed, 60 insertions(+), 57 deletions(-)
>
> Need some more maintainer Acks here.
>
> > -struct max14577 {
> > +/*
> > + * State container for max14577-like drivers.
> > + */
>
> I don't think this comment is required.
>
> Besides that, the code looks fine:
> Acked-by: Lee Jones <[email protected]>
>
> > +struct maxim_core {
> > struct device *dev;
> > struct i2c_client *i2c; /* Slave addr = 0x4A */
> >
>
Hi,
On Mon, 2014-02-03 at 17:00 +0530, Jenny Tc wrote:
> On Tue, Jan 28, 2014 at 01:18:40PM +0100, Krzysztof Kozlowski wrote:
> > - /* Battery-Charger Constant Voltage (CV) Mode, from SM-V700: 4.35V */
> > + /* Battery-Charger Constant Voltage (CV) Mode, set to: 4.35V */
>
> Does this charger chip support only 4.35V batteries? If the CV is hard coded
> to 4.35V, it's not safe for 4.2V batteries.
>
> > + /* End-of-Charge Current, set to 50mA (max14577) / 7.5mA (max77836) */
> The End of charge current basically depend on battery and not on charger chip.
>
> > - /* Overvoltage-Protection Threshold, from SM-V700: 6.5V */
> > + /* Overvoltage-Protection Threshold, set to 6.5V */
> 6.5V as over voltage for battery? A 4.35V battery would have exploded by
> that time!
Currently the max14577 driver has all these values hard-coded. This
patch doesn't change this, it only adds support for max77836. I agree
with you that hard-coding these values is not a proper way of doing
this.
I'll add another patch for parsing these values from DTS.
Best regards,
Krzysztof
On Mon, 2014-02-03 at 09:55 +0000, Lee Jones wrote:
> > This patch continues the preparation for adding support for max77836
> > device to existing max14577 driver.
> >
> > Add enum for types of devices supported by this driver. The device type
> > will be detected by matching of_device_id, or i2c_device_id as a
> > fallback.
> >
> > The patch also moves to separate function the code related to displaying
> > DeviceID register values.
> >
> > Signed-off-by: Krzysztof Kozlowski <[email protected]>
> > Cc: Kyungmin Park <[email protected]>
> > Cc: Marek Szyprowski <[email protected]>
> > ---
> > drivers/mfd/max14577.c | 61 +++++++++++++++++++++++-----------
> > include/linux/mfd/max14577-private.h | 12 ++++---
> > 2 files changed, 50 insertions(+), 23 deletions(-)
> >
> > diff --git a/drivers/mfd/max14577.c b/drivers/mfd/max14577.c
> > index 1d8104213b3e..224aba8c5b3f 100644
> > --- a/drivers/mfd/max14577.c
> > +++ b/drivers/mfd/max14577.c
> > @@ -20,6 +20,7 @@
>
> <snip>
>
> > +static void max14577_print_dev_type(struct maxim_core *maxim_core)
> > +{
> > + u8 reg_data, vendor_id, device_id;
> > + int ret = max14577_read_reg(maxim_core->regmap_muic,
> > + MAXIM_MUIC_REG_DEVICEID, ®_data);
>
> I'm not a big fan of declaring variables whilst feeding them with
> function return values. Can you separate the two please?
Sure.
>
> > + if (ret) {
> > + dev_err(maxim_core->dev, "Failed to read DEVICEID
> > register: %d\n",
>
> I think this is too many chars.
OK.
>
> > + ret);
> > + return;
> > + }
> > +
>
> <snip>
>
> > - ret = max14577_read_reg(maxim_core->regmap_muic,
> > - MAXIM_MUIC_REG_DEVICEID, ®_data);
> > - if (ret) {
> > - dev_err(maxim_core->dev, "Device not found on this channel: %d\n",
> > - ret);
> > - return ret;
> > + if (np) {
> > + const struct of_device_id *of_id =
> > + of_match_device(max14577_dt_match, &i2c->dev);
>
> Again this is a bit messy. Bring it down onto a separate line.
OK.
I'll send fixed version after grabbing more ACK-s for previous
rename-patches (this patch depends on them).
Best regards,
Krzysztof
> > Following patch has conflict on extcon-next branch(Linus 3.14-rc1)
> > when apply patchset by using git am.
> >
> > [PATCH 11/18] extcon: max14577: Add max14577 prefix to muic_irqs
> > [PATCH 12/18] extcon: max14577: Choose muic_irqs according to device type
> > [PATCH 14/18] extcon: max14577: Add support for max77836
> >
> > The base commit of this patchset isn't mainline. You need to rebase this patchset
> > on extcon-next branch and please resend this patchset.
<snip>
> This patch patch (along with other) depends on previous rename patches
> from this patchset:
> [PATCH 07/18] mfd: max14577: Rename and add MAX14577 symbols to prepare
> for max77836
> http://article.gmane.org/gmane.linux.kernel/1636674
>
> I can resolve the conflict but then they will return on applying patch
> 7/18.
>
> I think this patch may wait for a little until the rename-like patches
> will be accepted.
>
> Can you ACK other patches touch extcon?
> - [PATCH 07/18] mfd: max14577: Rename and add MAX14577 symbols...
> - [PATCH 08/18] mfd: max14577: Rename state container to maxim_core
> - [PATCH 09/18] mfd: max14577: Add "muic" suffix to regmap and irq_chip
If you can obtain Acks for all of the patches, I can apply the entire
patch-set to an immutable branch and issue a pull-request for the
other maintainers to pull from.
> > On 01/28/2014 09:18 PM, Krzysztof Kozlowski wrote:
> > > Add max14577 prefix to muic_irqs array. This prepares for max77836
> > > support in this extcon driver.
> > >
> > > Signed-off-by: Krzysztof Kozlowski <[email protected]>
> > > Cc: Kyungmin Park <[email protected]>
> > > Cc: Marek Szyprowski <[email protected]>
> > > ---
> > > drivers/extcon/extcon-max14577.c | 12 ++++++------
> > > 1 file changed, 6 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
> > > index fd48b4909470..fb343f4042d2 100644
> > > --- a/drivers/extcon/extcon-max14577.c
> > > +++ b/drivers/extcon/extcon-max14577.c
> > > @@ -85,7 +85,7 @@ struct max14577_muic_irq {
> > > unsigned int virq;
> > > };
> > >
> > > -static struct max14577_muic_irq muic_irqs[] = {
> > > +static struct max14577_muic_irq max14577_muic_irqs[] = {
> > > { MAXIM_IRQ_INT1_ADC, "muic-ADC" },
> > > { MAXIM_IRQ_INT1_ADCLOW, "muic-ADCLOW" },
> > > { MAXIM_IRQ_INT1_ADCERR, "muic-ADCError" },
> > > @@ -541,9 +541,9 @@ static irqreturn_t max14577_muic_irq_handler(int irq, void *data)
> > > * However we only need to know whether it was ADC, charger
> > > * or both interrupts so decode IRQ and turn on proper flags.
> > > */
> > > - for (i = 0; i < ARRAY_SIZE(muic_irqs); i++)
> > > - if (irq == muic_irqs[i].virq)
> > > - irq_type = muic_irqs[i].irq;
> > > + for (i = 0; i < ARRAY_SIZE(max14577_muic_irqs); i++)
> > > + if (irq == max14577_muic_irqs[i].virq)
> > > + irq_type = max14577_muic_irqs[i].irq;
> > >
> > > switch (irq_type) {
> > > case MAXIM_IRQ_INT1_ADC:
> > > @@ -647,8 +647,8 @@ static int max14577_muic_probe(struct platform_device *pdev)
> > > INIT_WORK(&info->irq_work, max14577_muic_irq_work);
> > >
> > > /* Support irq domain for max14577 MUIC device */
> > > - for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) {
> > > - struct max14577_muic_irq *muic_irq = &muic_irqs[i];
> > > + for (i = 0; i < ARRAY_SIZE(max14577_muic_irqs); i++) {
> > > + struct max14577_muic_irq *muic_irq = &max14577_muic_irqs[i];
> > > unsigned int virq = 0;
> > >
> > > virq = regmap_irq_get_virq(maxim_core->irq_data_muic,
> > >
>
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
On Mon, 2014-02-03 at 10:22 +0000, Lee Jones wrote:
> On Tue, 28 Jan 2014, Krzysztof Kozlowski wrote:
>
> > Add Maxim 77836 support to max14577 driver. The chipsets have same MUIC
> > component so the extcon, charger and regulators are almost the same. The
> > max77836 however has also PMIC and Fuel Gauge.
> >
> > The MAX77836 uses three I2C slave addresses and has additional interrupts
> > (related to PMIC and Fuel Gauge). It has also Interrupt Source register,
> > just like MAX77686 and MAX77693.
> >
> > The MAX77836 PMIC's TOPSYS and INTSRC interrupts are reported in the
> > PMIC block. The PMIC block has different I2C slave address and uses own
> > regmap so another regmap_irq_chip is needed.
> >
> > Since we have two regmap_irq_chip, use shared interrupts on MAX77836.
> >
> > This patch adds additional defines and functions to the max14577 MFD core
> > driver so the driver will handle both chipsets.
> >
> > Signed-off-by: Krzysztof Kozlowski <[email protected]>
> > Signed-off-by: Chanwoo Choi <[email protected]>
> > Cc: Kyungmin Park <[email protected]>
> > Cc: Marek Szyprowski <[email protected]>
> > ---
> > drivers/mfd/max14577.c | 215 ++++++++++++++++++++++++++++++++--
> > include/linux/mfd/max14577-private.h | 85 +++++++++++++-
> > include/linux/mfd/max14577.h | 7 +-
> > 3 files changed, 296 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/mfd/max14577.c b/drivers/mfd/max14577.c
> > index 224aba8c5b3f..5b10f6f89834 100644
> > --- a/drivers/mfd/max14577.c
> > +++ b/drivers/mfd/max14577.c
> > @@ -1,7 +1,7 @@
> > /*
> > - * max14577.c - mfd core driver for the Maxim 14577
> > + * max14577.c - mfd core driver for the Maxim 14577/77836
>
> We may wish to consider changing the name of this file at a later
> date.
I agree, maybe "maxim-pmic.c"? The 14577 is a MUIC/charger, 77836 is a
MUIC/charger/mini-PMIC. However other max-like chipsets (77693, 77686)
have full PMIC capabilities, so the name change could be introduced when
support for these devices would be added.
> > - * Copyright (C) 2013 Samsung Electrnoics
> > + * Copyright (C) 2013,2014 Samsung Electrnoics
>
> You can remove the the '2013' completely now.
Shouldn't it contain the date of first publication?
> > * Chanwoo Choi <[email protected]>
> > * Krzysztof Kozlowski <[email protected]>
> > *
> > @@ -37,11 +37,31 @@ static struct mfd_cell max14577_devs[] = {
> > { .name = "max14577-charger", },
> > };
> >
> > +static struct mfd_cell max77836_devs[] = {
> > + {
> > + .name = "max77836-muic",
> > + .of_compatible = "maxim,max77836-muic",
> > + },
> > + {
> > + .name = "max77836-regulator",
> > + .of_compatible = "maxim,max77836-regulator",
> > + },
> > + { .name = "max77836-charger", },
>
> Why doesn't the charger require a compatible string?
Currently the charger driver doesn't use DT and does not require it. The
device type is taken from parent's MFD of_compatible.
I'll add the compatible anyway because but during review of other
charger patch it was pointed that the charger should be configurable.
>
> > + {
> > + .name = "max77836-battery",
> > + .of_compatible = "maxim,max77836-battery",
> > + },
> > +};
> > +
> > @@ -56,6 +76,29 @@ static bool max14577_muic_volatile_reg(struct device *dev, unsigned int reg)
> > return false;
> > }
> >
> > +static bool max77836_muic_volatile_reg(struct device *dev, unsigned int reg)
> > +{
> > + /* Any max14577 volatile registers are also max77836 volatile. */
> > + if (max14577_muic_volatile_reg(dev, reg))
> > + return true;
>
> New line here please.
OK
>
> > + switch (reg) {
> > + case MAX77836_FG_REG_VCELL_MSB ... MAX77836_FG_REG_SOC_LSB:
> > + case MAX77836_FG_REG_CRATE_MSB ... MAX77836_FG_REG_CRATE_LSB:
> > + case MAX77836_FG_REG_STATUS_H ... MAX77836_FG_REG_STATUS_L:
> > + /* fall through */
>
> It's okay not to have these here. We know how switch statements
> work. ;)
Checkpatch complained about lack of this...
> > + case MAX77836_PMIC_REG_INTSRC:
> > + /* fall through */
> > + case MAX77836_PMIC_REG_TOPSYS_INT:
> > + /* fall through */
> > + case MAX77836_PMIC_REG_TOPSYS_STAT:
> > + return true;
> > + default:
> > + break;
> > + }
> > + return false;
> > +}
> > +
> > +
>
> Superfluous new line here.
OK
> > +static const struct regmap_irq_chip max77836_muic_irq_chip = {
> > + .name = "max77836-muic",
> > + .status_base = MAXIM_MUIC_REG_INT1,
> > + .mask_base = MAXIM_MUIC_REG_INTMASK1,
> > + .mask_invert = 1,
>
> I'd prefer the use of 'true' or 'false' for bools.
OK
> > + .num_regs = 3,
> > + .irqs = max77836_muic_irqs,
> > + .num_irqs = ARRAY_SIZE(max77836_muic_irqs),
> > +};
> > +
>
> <snip>
>
> > +static const struct regmap_irq_chip max77836_pmic_irq_chip = {
> > + .name = "max77836-pmic",
> > + .status_base = MAX77836_PMIC_REG_TOPSYS_INT,
> > + .mask_base = MAX77836_PMIC_REG_TOPSYS_INT_MASK,
> > + .mask_invert = 0,
>
> 'false' please.
OK
> > + .num_regs = 1,
> > + .irqs = max77836_pmic_irqs,
> > + .num_irqs = ARRAY_SIZE(max77836_pmic_irqs),
> > +};
> > +
>
> <snip>
>
> > +static int max77836_init(struct maxim_core *maxim_core)
> > +{
> > + int ret;
> > + u8 intsrc_mask;
> > +
> > + maxim_core->i2c_pmic = i2c_new_dummy(maxim_core->i2c->adapter,
> > + I2C_ADDR_PMIC);
> > + if (!maxim_core->i2c_pmic) {
> > + dev_err(maxim_core->dev, "Failed to register PMIC I2C device\n");
> > + return -EPERM;
>
> Not sure this is the best errno to return.
>
> Perhaps -ENODEV would be more suitable?
Hmmm... I am not sure. The i2c_new_dummy() returns NULL when:
- kzalloc fails,
- I2C address is wrong (EINVAL),
- I2C device is busy,
- device_add fails.
For me none of them matches but I don't mind returning ENODEV.
> <snip>
>
> > #define MAXIM_STATUS2_CHGTYP_MASK (0x7 << MAXIM_STATUS2_CHGTYP_SHIFT)
> > #define MAXIM_STATUS2_CHGDETRUN_MASK (0x1 << MAXIM_STATUS2_CHGDETRUN_SHIFT)
> > #define MAXIM_STATUS2_DCDTMR_MASK (0x1 << MAXIM_STATUS2_DCDTMR_SHIFT)
> > #define MAXIM_STATUS2_DBCHG_MASK (0x1 << MAXIM_STATUS2_DBCHG_SHIFT)
> > #define MAXIM_STATUS2_VBVOLT_MASK (0x1 << MAXIM_STATUS2_VBVOLT_SHIFT)
> > +#define MAX77836_STATUS2_VIDRM_MASK (0x1 << MAX77836_STATUS2_VIDRM_SHIFT)
>
> It's up to you, but all of these "0x1 <<"s can be replaced with the
> BIT() macro if you so wished.
OK
>
> > /* MAX14577 STATUS3 register */
> > #define MAXIM_STATUS3_EOC_SHIFT 0
> > @@ -232,6 +242,70 @@ enum maxim_muic_charger_type {
> >
> >
> >
>
> Do all of these extra new lines really exist, or is it just a patch
> thing? If they do, can you get rid of them please?
Sure.
> > +/* Slave addr = 0x46: PMIC */
> > +enum max77836_pmic_reg {
> > + MAX77836_COMP_REG_COMP1 = 0x60,
> > +
> > + MAX77836_LDO_REG_CNFG1_LDO1 = 0x51,
> > + MAX77836_LDO_REG_CNFG2_LDO1 = 0x52,
> > + MAX77836_LDO_REG_CNFG1_LDO2 = 0x53,
> > + MAX77836_LDO_REG_CNFG2_LDO2 = 0x54,
> > + MAX77836_LDO_REG_CNFG_LDO_BIAS = 0x55,
> > +
> > + MAX77836_PMIC_REG_PMIC_ID = 0x20,
> > + MAX77836_PMIC_REG_PMIC_REV = 0x21,
> > + MAX77836_PMIC_REG_INTSRC = 0x22,
> > + MAX77836_PMIC_REG_INTSRC_MASK = 0x23,
> > + MAX77836_PMIC_REG_TOPSYS_INT = 0x24,
> > + MAX77836_PMIC_REG_TOPSYS_INT_MASK = 0x26,
> > + MAX77836_PMIC_REG_TOPSYS_STAT = 0x28,
> > + MAX77836_PMIC_REG_MRSTB_CNTL = 0x2A,
> > + MAX77836_PMIC_REG_LSCNFG = 0x2B,
> > +
> > + MAX77836_PMIC_REG_END,
> > +};
>
> Any reason why these aren't in numerical order?
I'll fix this.
>
> <snip>
>
On 01/28/2014 09:18 PM, Krzysztof Kozlowski wrote:
> This patch prepares for adding support for max77836 device to existing
> max14577 driver:
> 1. Renames most of symbols and defines prefixed with MAX14577 to MAXIM.
> 2. Adds prefixes (MAXIM or MAX14577) to defines without any MAX* prefix.
>
> This is only a rename-like patch, new code is not added.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> Cc: Kyungmin Park <[email protected]>
> Cc: Marek Szyprowski <[email protected]>
> ---
> drivers/extcon/extcon-max14577.c | 105 ++++-----
> drivers/mfd/max14577.c | 51 ++---
> drivers/power/max14577_charger.c | 81 +++----
> drivers/regulator/max14577.c | 44 ++--
> include/linux/mfd/max14577-private.h | 399 ++++++++++++++++------------------
> include/linux/mfd/max14577.h | 2 +-
> 6 files changed, 333 insertions(+), 349 deletions(-)
>
For extcon:
Acked-by: Chanwoo Choi <[email protected]>
Thanks,
Chanwoo Choi
On 01/28/2014 09:18 PM, Krzysztof Kozlowski wrote:
> This patch continues the preparation for adding support for max77836
> device to existing max14577 driver.
>
> The patch renames the struct "max14577" state container to "maxim_core".
> This is only a rename-like patch, new code is not added.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> Cc: Kyungmin Park <[email protected]>
> Cc: Marek Szyprowski <[email protected]>
> ---
> drivers/extcon/extcon-max14577.c | 22 +++++------
> drivers/mfd/max14577.c | 68 +++++++++++++++++-----------------
> drivers/power/max14577_charger.c | 16 ++++----
> drivers/regulator/max14577.c | 6 +--
> include/linux/mfd/max14577-private.h | 5 ++-
> 5 files changed, 60 insertions(+), 57 deletions(-)
>
For extcon:
Acked-by: Chanwoo Choi <[email protected]>
For mfd/regulator/charger/extcon of max14577
Tested-by: Chanwoo Choi <[email protected]>
Thanks,
Chanwoo Choi
On 01/28/2014 09:18 PM, Krzysztof Kozlowski wrote:
> This patch continues the preparation for adding support for max77836
> device to existing max14577 driver.
>
> Add "muic" suffix to regmap and irq_data fields in maxim_core state
> container to prepare for max77836 support.
> This is only a rename-like patch, new code is not added.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> Cc: Kyungmin Park <[email protected]>
> Cc: Marek Szyprowski <[email protected]>
> ---
> drivers/extcon/extcon-max14577.c | 17 +++++++++--------
> drivers/mfd/max14577.c | 22 +++++++++++-----------
> drivers/power/max14577_charger.c | 8 ++++----
> drivers/regulator/max14577.c | 2 +-
> include/linux/mfd/max14577-private.h | 4 ++--
> 5 files changed, 27 insertions(+), 26 deletions(-)
>
For extcon:
Acked-by: Chanwoo Choi <[email protected]>
For mfd/regulator/charger/extcon of max14577
Tested-by: Chanwoo Choi <[email protected]>
Thanks,
Chanwoo Choi
On 02/05/2014 11:04 PM, Lee Jones wrote:
>>> Following patch has conflict on extcon-next branch(Linus 3.14-rc1)
>>> when apply patchset by using git am.
>>>
>>> [PATCH 11/18] extcon: max14577: Add max14577 prefix to muic_irqs
>>> [PATCH 12/18] extcon: max14577: Choose muic_irqs according to device type
>>> [PATCH 14/18] extcon: max14577: Add support for max77836
>>>
>>> The base commit of this patchset isn't mainline. You need to rebase this patchset
>>> on extcon-next branch and please resend this patchset.
>
> <snip>
>
>> This patch patch (along with other) depends on previous rename patches
>> from this patchset:
>> [PATCH 07/18] mfd: max14577: Rename and add MAX14577 symbols to prepare
>> for max77836
>> http://article.gmane.org/gmane.linux.kernel/1636674
>>
>> I can resolve the conflict but then they will return on applying patch
>> 7/18.
>>
>> I think this patch may wait for a little until the rename-like patches
>> will be accepted.
>>
>> Can you ACK other patches touch extcon?
>> - [PATCH 07/18] mfd: max14577: Rename and add MAX14577 symbols...
>> - [PATCH 08/18] mfd: max14577: Rename state container to maxim_core
>> - [PATCH 09/18] mfd: max14577: Add "muic" suffix to regmap and irq_chip
>
> If you can obtain Acks for all of the patches, I can apply the entire
> patch-set to an immutable branch and issue a pull-request for the
> other maintainers to pull from.
>
Hi Lee,
OK, I agree your opionion.
I'd like you to apply this patchset dependent on extcon subsytem
on your tree. I acked on following patchset and tested all of this patchset series.
Acked-by: Chanwoo Choi <[email protected]>
[PATCH 06/18] extcon: max14577: Change extcon name instead of static name according to device type
- I will delete this patch([PATCH 06/18]) on extcon-next branch.
[PATCH 07/18] mfd: max14577: Rename and add MAX14577 symbols...
[PATCH 08/18] mfd: max14577: Rename state container to maxim_core
[PATCH 09/18] mfd: max14577: Add "muic" suffix to regmap and irq_chip
[PATCH 11/18] extcon: max14577: Add max14577 prefix to muic_irqs
[PATCH 12/18] extcon: max14577: Choose muic_irqs according to device type
[PATCH 14/18] extcon: max14577: Add support for max77836
Thanks,
Chanwoo Choi