LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v7 0/5] Add new MFD driver for MAX77843
@ 2015-03-02 10:10 Jaewon Kim
  2015-03-02 10:10 ` [PATCH v7 1/5] mfd: max77843: Add max77843 MFD driver core driver Jaewon Kim
                   ` (4 more replies)
  0 siblings, 5 replies; 36+ messages in thread
From: Jaewon Kim @ 2015-03-02 10:10 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-pm, linux-input
  Cc: Inki Dae, SangBae Lee, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Lee Jones, Chanwoo Choi,
	Sebastian Reichel, Beomho Seo, Jaewon Kim, Dmitry Torokhov

This patch series adds MAX77843(Multi Function Device) driver.
The MAX77843 includes MUIC(Micro USB Interface Controller), Li+ Charger
with Fuel Gauge, 2 safeout LDOs for USB device and haptic controller using PWM.
It is interfaced to host controller using I2C. 

Changes in v7:
MFD Core
 - Fix indentation
 - Remove file name, MODULE information
POWER
 - Fix typos

Changes in v6:
HAPTIC
 - fixed a situation where holding a Mutex return.
 
Changes in v5: 
MFD Core
 - Use bracket in complex define.
 - Delete unnecessary letter '++'     
Charger
 - fix Kconfig merge conflict with Kernel version4.0
     
Changes in v4:
MFD Core
 - Fix indentation
 - Add haptic register define in header
HAPTIC
 - Add haptic driver

Changes in v3:
MFD Core
 - Fix wrong description and indentation in header.
 - Remove unnecessary variable.
Regulator
 - Use ARRAY_SIZE() instead of define.
   
Changes in v2:
MFD Core
 - Fix charger regmap handle and typo.
MUIC
 - Cleanup enum list.
 - Set path before send excon event.
 - Fix variable names and typos for readability.
Charger
 - Remove unnecessary header.
 - Chnage error message more readable.
 - Remove unnecessary lines.
Fuelgauge
 - Fix regmap_config and use regmap_read.
 - Add i2c_unregister_device function on *_remove function.
 - Fix typo in Kconfig.
Doc
 - Remove unnecessary lines.
 - Add example of charger regulator.Beomho Seo (2):

Jaewon Kim (3):
  mfd: max77843: Add max77843 MFD driver core driver
  Input: add haptic drvier on max77843
  Documentation: Add device tree bindings document for max77843

 Documentation/devicetree/bindings/mfd/max77843.txt |  110 +++++
 drivers/input/misc/Kconfig                         |   12 +
 drivers/input/misc/Makefile                        |    1 +
 drivers/input/misc/max77843-haptic.c               |  358 ++++++++++++++
 drivers/mfd/Kconfig                                |   14 +
 drivers/mfd/Makefile                               |    1 +
 drivers/mfd/max77843.c                             |  243 ++++++++++
 drivers/power/Kconfig                              |   16 +
 drivers/power/Makefile                             |    2 +
 drivers/power/max77843_battery.c                   |  286 +++++++++++
 drivers/power/max77843_charger.c                   |  508 ++++++++++++++++++++
 include/linux/mfd/max77843-private.h               |  454 +++++++++++++++++
 12 files changed, 2005 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/max77843.txt
 create mode 100644 drivers/input/misc/max77843-haptic.c
 create mode 100644 drivers/mfd/max77843.c
 create mode 100644 drivers/power/max77843_battery.c
 create mode 100644 drivers/power/max77843_charger.c
 create mode 100644 include/linux/mfd/max77843-private.h

-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH v7 1/5] mfd: max77843: Add max77843 MFD driver core driver
  2015-03-02 10:10 [PATCH v7 0/5] Add new MFD driver for MAX77843 Jaewon Kim
@ 2015-03-02 10:10 ` Jaewon Kim
  2015-03-02 10:20   ` Lee Jones
  2015-03-02 10:41   ` Lee Jones
  2015-03-02 10:10 ` [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver Jaewon Kim
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 36+ messages in thread
From: Jaewon Kim @ 2015-03-02 10:10 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-pm, linux-input
  Cc: Inki Dae, SangBae Lee, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Lee Jones, Chanwoo Choi,
	Sebastian Reichel, Beomho Seo, Jaewon Kim, Dmitry Torokhov

This patch adds MAX77843 core/irq driver to support PMIC,
MUIC(Micro USB Interface Controller), Charger, Fuel Gauge,
LED and Haptic device.

Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com>
Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
---
 drivers/mfd/Kconfig                  |   14 ++
 drivers/mfd/Makefile                 |    1 +
 drivers/mfd/max77843.c               |  243 ++++++++++++++++++
 include/linux/mfd/max77843-private.h |  454 ++++++++++++++++++++++++++++++++++
 4 files changed, 712 insertions(+)
 create mode 100644 drivers/mfd/max77843.c
 create mode 100644 include/linux/mfd/max77843-private.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 38356e3..f2fd5e5 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -455,6 +455,20 @@ config MFD_MAX77693
 	  additional drivers must be enabled in order to use the functionality
 	  of the device.
 
+config MFD_MAX77843
+	bool "Maxim Semiconductor MAX77843 PMIC Support"
+	depends on I2C=y
+	select MFD_CORE
+	select REGMAP_I2C
+	select REGMAP_IRQ
+	help
+	  Say yes here to add support for Maxim Semiconductor MAX77843.
+	  This is companion Power Management IC with LEDs, Haptic, Charger,
+	  Fuel Gauge, MUIC(Micro USB Interface Controller) controls on chip.
+	  This driver provides common support for accessing the device;
+	  additional drivers must be enabled in order to use the functionality
+	  of the device.
+
 config MFD_MAX8907
 	tristate "Maxim Semiconductor MAX8907 PMIC Support"
 	select MFD_CORE
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 19f3d74..b8ac555 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -117,6 +117,7 @@ obj-$(CONFIG_MFD_DA9150)	+= da9150-core.o
 obj-$(CONFIG_MFD_MAX14577)	+= max14577.o
 obj-$(CONFIG_MFD_MAX77686)	+= max77686.o
 obj-$(CONFIG_MFD_MAX77693)	+= max77693.o
+obj-$(CONFIG_MFD_MAX77843)	+= max77843.o
 obj-$(CONFIG_MFD_MAX8907)	+= max8907.o
 max8925-objs			:= max8925-core.o max8925-i2c.o
 obj-$(CONFIG_MFD_MAX8925)	+= max8925.o
diff --git a/drivers/mfd/max77843.c b/drivers/mfd/max77843.c
new file mode 100644
index 0000000..a354ac6
--- /dev/null
+++ b/drivers/mfd/max77843.c
@@ -0,0 +1,243 @@
+/*
+ * MFD core driver for the Maxim MAX77843
+ *
+ * Copyright (C) 2015 Samsung Electronics
+ * Author: Jaewon Kim <jaewon02.kim@samsung.com>
+ * Author: Beomho Seo <beomho.seo@samsung.com>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/max77843-private.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+
+static const struct mfd_cell max77843_devs[] = {
+	{
+		.name = "max77843-muic",
+		.of_compatible = "maxim,max77843-muic",
+	}, {
+		.name = "max77843-regulator",
+		.of_compatible = "maxim,max77843-regulator",
+	}, {
+		.name = "max77843-charger",
+		.of_compatible = "maxim,max77843-charger"
+	}, {
+		.name = "max77843-fuelgauge",
+		.of_compatible = "maxim,max77843-fuelgauge",
+	}, {
+		.name = "max77843-haptic",
+		.of_compatible = "maxim,max77843-haptic",
+	},
+};
+
+static const struct regmap_config max77843_charger_regmap_config = {
+	.reg_bits	= 8,
+	.val_bits	= 8,
+	.max_register	= MAX77843_CHG_REG_END,
+};
+
+static const struct regmap_config max77843_regmap_config = {
+	.reg_bits	= 8,
+	.val_bits	= 8,
+	.max_register	= MAX77843_SYS_REG_END,
+};
+
+static const struct regmap_irq max77843_irqs[] = {
+	/* TOPSYS interrupts */
+	{ .reg_offset = 0, .mask = MAX77843_SYS_IRQ_SYSUVLO_INT, },
+	{ .reg_offset = 0, .mask = MAX77843_SYS_IRQ_SYSOVLO_INT, },
+	{ .reg_offset = 0, .mask = MAX77843_SYS_IRQ_TSHDN_INT, },
+	{ .reg_offset = 0, .mask = MAX77843_SYS_IRQ_TM_INT, },
+};
+
+static const struct regmap_irq_chip max77843_irq_chip = {
+	.name		= "max77843",
+	.status_base	= MAX77843_SYS_REG_SYSINTSRC,
+	.mask_base	= MAX77843_SYS_REG_SYSINTMASK,
+	.mask_invert	= false,
+	.num_regs	= 1,
+	.irqs		= max77843_irqs,
+	.num_irqs	= ARRAY_SIZE(max77843_irqs),
+};
+
+/* Charger and Charger regulator use same regmap. */
+static int max77843_chg_init(struct max77843 *max77843)
+{
+	int ret;
+
+	max77843->i2c_chg = i2c_new_dummy(max77843->i2c->adapter, I2C_ADDR_CHG);
+	if (!max77843->i2c_chg) {
+		dev_err(&max77843->i2c->dev,
+				"Cannot allocate I2C device for Charger\n");
+		return PTR_ERR(max77843->i2c_chg);
+	}
+	i2c_set_clientdata(max77843->i2c_chg, max77843);
+
+	max77843->regmap_chg = devm_regmap_init_i2c(max77843->i2c_chg,
+			&max77843_charger_regmap_config);
+	if (IS_ERR(max77843->regmap_chg)) {
+		ret = PTR_ERR(max77843->regmap_chg);
+		goto err_chg_i2c;
+	}
+
+	return 0;
+
+err_chg_i2c:
+	i2c_unregister_device(max77843->i2c_chg);
+
+	return ret;
+}
+
+static int max77843_probe(struct i2c_client *i2c,
+			  const struct i2c_device_id *id)
+{
+	struct max77843 *max77843;
+	unsigned int reg_data;
+	int ret;
+
+	max77843 = devm_kzalloc(&i2c->dev, sizeof(*max77843), GFP_KERNEL);
+	if (!max77843)
+		return -ENOMEM;
+
+	i2c_set_clientdata(i2c, max77843);
+	max77843->dev = &i2c->dev;
+	max77843->i2c = i2c;
+	max77843->irq = i2c->irq;
+
+	max77843->regmap = devm_regmap_init_i2c(i2c,
+			&max77843_regmap_config);
+	if (IS_ERR(max77843->regmap)) {
+		dev_err(&i2c->dev, "Failed to allocate topsys register map\n");
+		return PTR_ERR(max77843->regmap);
+	}
+
+	ret = regmap_add_irq_chip(max77843->regmap, max77843->irq,
+			IRQF_TRIGGER_LOW | IRQF_ONESHOT | IRQF_SHARED,
+			0, &max77843_irq_chip, &max77843->irq_data);
+	if (ret) {
+		dev_err(&i2c->dev, "Failed to add TOPSYS IRQ chip\n");
+		return ret;
+	}
+
+	ret = regmap_read(max77843->regmap,
+			MAX77843_SYS_REG_PMICID, &reg_data);
+	if (ret < 0) {
+		dev_err(&i2c->dev, "Failed to read PMIC ID\n");
+		goto err_pmic_id;
+	}
+	dev_info(&i2c->dev, "device ID: 0x%x\n", reg_data);
+
+	ret = max77843_chg_init(max77843);
+	if (ret) {
+		dev_err(&i2c->dev, "Failed to init Charger\n");
+		goto err_pmic_id;
+	}
+
+	ret = regmap_update_bits(max77843->regmap,
+				 MAX77843_SYS_REG_INTSRCMASK,
+				 MAX77843_INTSRC_MASK_MASK,
+				 (unsigned int)~MAX77843_INTSRC_MASK_MASK);
+	if (ret < 0) {
+		dev_err(&i2c->dev, "Failed to unmask interrupt source\n");
+		goto err_pmic_id;
+	}
+
+	ret = mfd_add_devices(max77843->dev, -1, max77843_devs,
+			      ARRAY_SIZE(max77843_devs), NULL, 0, NULL);
+	if (ret < 0) {
+		dev_err(&i2c->dev, "Failed to add mfd device\n");
+		goto err_pmic_id;
+	}
+
+	device_init_wakeup(max77843->dev, true);
+
+	return 0;
+
+err_pmic_id:
+	regmap_del_irq_chip(max77843->irq, max77843->irq_data);
+
+	return ret;
+}
+
+static int max77843_remove(struct i2c_client *i2c)
+{
+	struct max77843 *max77843 = i2c_get_clientdata(i2c);
+
+	mfd_remove_devices(max77843->dev);
+
+	regmap_del_irq_chip(max77843->irq, max77843->irq_data);
+
+	i2c_unregister_device(max77843->i2c_chg);
+
+	return 0;
+}
+
+static const struct of_device_id max77843_dt_match[] = {
+	{ .compatible = "maxim,max77843", },
+	{ },
+};
+
+static const struct i2c_device_id max77843_id[] = {
+	{ "max77843", },
+	{ },
+};
+MODULE_DEVICE_TABLE(i2c, max77843_id);
+
+static int __maybe_unused max77843_suspend(struct device *dev)
+{
+	struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
+	struct max77843 *max77843 = i2c_get_clientdata(i2c);
+
+	disable_irq(max77843->irq);
+	if (device_may_wakeup(dev))
+		enable_irq_wake(max77843->irq);
+
+	return 0;
+}
+
+static int __maybe_unused max77843_resume(struct device *dev)
+{
+	struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
+	struct max77843 *max77843 = i2c_get_clientdata(i2c);
+
+	if (device_may_wakeup(dev))
+		disable_irq_wake(max77843->irq);
+	enable_irq(max77843->irq);
+
+	return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(max77843_pm, max77843_suspend, max77843_resume);
+
+static struct i2c_driver max77843_i2c_driver = {
+	.driver	= {
+		.name = "max77843",
+		.pm = &max77843_pm,
+		.of_match_table = max77843_dt_match,
+	},
+	.probe = max77843_probe,
+	.remove = max77843_remove,
+	.id_table = max77843_id,
+};
+
+static int __init max77843_i2c_init(void)
+{
+	return i2c_add_driver(&max77843_i2c_driver);
+}
+subsys_initcall(max77843_i2c_init);
+
+static void __exit max77843_i2c_exit(void)
+{
+	i2c_del_driver(&max77843_i2c_driver);
+}
+module_exit(max77843_i2c_exit);
diff --git a/include/linux/mfd/max77843-private.h b/include/linux/mfd/max77843-private.h
new file mode 100644
index 0000000..7178ace
--- /dev/null
+++ b/include/linux/mfd/max77843-private.h
@@ -0,0 +1,454 @@
+/*
+ * Common variables for the Maxim MAX77843 driver
+ *
+ * Copyright (C) 2015 Samsung Electronics
+ * Author: Jaewon Kim <jaewon02.kim@samsung.com>
+ * Author: Beomho Seo <beomho.seo@samsung.com>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __MAX77843_PRIVATE_H_
+#define __MAX77843_PRIVATE_H_
+
+#include <linux/i2c.h>
+#include <linux/regmap.h>
+
+#define I2C_ADDR_TOPSYS	(0xCC >> 1)
+#define I2C_ADDR_CHG	(0xD2 >> 1)
+#define I2C_ADDR_FG	(0x6C >> 1)
+#define I2C_ADDR_MUIC	(0x4A >> 1)
+
+/* Topsys, Haptic and LED registers */
+enum max77843_sys_reg {
+	MAX77843_SYS_REG_PMICID		= 0x00,
+	MAX77843_SYS_REG_PMICREV	= 0x01,
+	MAX77843_SYS_REG_MAINCTRL1	= 0x02,
+	MAX77843_SYS_REG_INTSRC		= 0x22,
+	MAX77843_SYS_REG_INTSRCMASK	= 0x23,
+	MAX77843_SYS_REG_SYSINTSRC	= 0x24,
+	MAX77843_SYS_REG_SYSINTMASK	= 0x26,
+	MAX77843_SYS_REG_TOPSYS_STAT	= 0x28,
+	MAX77843_SYS_REG_SAFEOUTCTRL	= 0xC6,
+
+	MAX77843_SYS_REG_END,
+};
+
+enum max77843_haptic_reg {
+	MAX77843_HAP_REG_MCONFIG	= 0x10,
+
+	MAX77843_HAP_REG_END,
+};
+
+enum max77843_led_reg {
+	MAX77843_LED_REG_LEDEN		= 0x30,
+	MAX77843_LED_REG_LED0BRT	= 0x31,
+	MAX77843_LED_REG_LED1BRT	= 0x32,
+	MAX77843_LED_REG_LED2BRT	= 0x33,
+	MAX77843_LED_REG_LED3BRT	= 0x34,
+	MAX77843_LED_REG_LEDBLNK	= 0x38,
+	MAX77843_LED_REG_LEDRAMP	= 0x36,
+
+	MAX77843_LED_REG_END,
+};
+
+/* Charger registers */
+enum max77843_charger_reg {
+	MAX77843_CHG_REG_CHG_INT	= 0xB0,
+	MAX77843_CHG_REG_CHG_INT_MASK	= 0xB1,
+	MAX77843_CHG_REG_CHG_INT_OK	= 0xB2,
+	MAX77843_CHG_REG_CHG_DTLS_00	= 0xB3,
+	MAX77843_CHG_REG_CHG_DTLS_01	= 0xB4,
+	MAX77843_CHG_REG_CHG_DTLS_02	= 0xB5,
+	MAX77843_CHG_REG_CHG_CNFG_00	= 0xB7,
+	MAX77843_CHG_REG_CHG_CNFG_01	= 0xB8,
+	MAX77843_CHG_REG_CHG_CNFG_02	= 0xB9,
+	MAX77843_CHG_REG_CHG_CNFG_03	= 0xBA,
+	MAX77843_CHG_REG_CHG_CNFG_04	= 0xBB,
+	MAX77843_CHG_REG_CHG_CNFG_06	= 0xBD,
+	MAX77843_CHG_REG_CHG_CNFG_07	= 0xBE,
+	MAX77843_CHG_REG_CHG_CNFG_09	= 0xC0,
+	MAX77843_CHG_REG_CHG_CNFG_10	= 0xC1,
+	MAX77843_CHG_REG_CHG_CNFG_11	= 0xC2,
+	MAX77843_CHG_REG_CHG_CNFG_12	= 0xC3,
+
+	MAX77843_CHG_REG_END,
+};
+
+/* Fuel gauge registers */
+enum max77843_fuelgauge {
+	MAX77843_FG_REG_STATUS		= 0x00,
+	MAX77843_FG_REG_VALRT_TH	= 0x01,
+	MAX77843_FG_REG_TALRT_TH	= 0x02,
+	MAX77843_FG_REG_SALRT_TH	= 0x03,
+	MAX77843_FG_RATE_AT_RATE	= 0x04,
+	MAX77843_FG_REG_REMCAP_REP	= 0x05,
+	MAX77843_FG_REG_SOCREP		= 0x06,
+	MAX77843_FG_REG_AGE		= 0x07,
+	MAX77843_FG_REG_TEMP		= 0x08,
+	MAX77843_FG_REG_VCELL		= 0x09,
+	MAX77843_FG_REG_CURRENT		= 0x0A,
+	MAX77843_FG_REG_AVG_CURRENT	= 0x0B,
+	MAX77843_FG_REG_SOCMIX		= 0x0D,
+	MAX77843_FG_REG_SOCAV		= 0x0E,
+	MAX77843_FG_REG_REMCAP_MIX	= 0x0F,
+	MAX77843_FG_REG_FULLCAP		= 0x10,
+	MAX77843_FG_REG_AVG_TEMP	= 0x16,
+	MAX77843_FG_REG_CYCLES		= 0x17,
+	MAX77843_FG_REG_AVG_VCELL	= 0x19,
+	MAX77843_FG_REG_CONFIG		= 0x1D,
+	MAX77843_FG_REG_REMCAP_AV	= 0x1F,
+	MAX77843_FG_REG_FULLCAP_NOM	= 0x23,
+	MAX77843_FG_REG_MISCCFG		= 0x2B,
+	MAX77843_FG_REG_RCOMP		= 0x38,
+	MAX77843_FG_REG_FSTAT		= 0x3D,
+	MAX77843_FG_REG_DQACC		= 0x45,
+	MAX77843_FG_REG_DPACC		= 0x46,
+	MAX77843_FG_REG_OCV		= 0xEE,
+	MAX77843_FG_REG_VFOCV		= 0xFB,
+	MAX77843_FG_SOCVF		= 0xFF,
+
+	MAX77843_FG_END,
+};
+
+/* MUIC registers */
+enum max77843_muic_reg {
+	MAX77843_MUIC_REG_ID		= 0x00,
+	MAX77843_MUIC_REG_INT1		= 0x01,
+	MAX77843_MUIC_REG_INT2		= 0x02,
+	MAX77843_MUIC_REG_INT3		= 0x03,
+	MAX77843_MUIC_REG_STATUS1	= 0x04,
+	MAX77843_MUIC_REG_STATUS2	= 0x05,
+	MAX77843_MUIC_REG_STATUS3	= 0x06,
+	MAX77843_MUIC_REG_INTMASK1	= 0x07,
+	MAX77843_MUIC_REG_INTMASK2	= 0x08,
+	MAX77843_MUIC_REG_INTMASK3	= 0x09,
+	MAX77843_MUIC_REG_CDETCTRL1	= 0x0A,
+	MAX77843_MUIC_REG_CDETCTRL2	= 0x0B,
+	MAX77843_MUIC_REG_CONTROL1	= 0x0C,
+	MAX77843_MUIC_REG_CONTROL2	= 0x0D,
+	MAX77843_MUIC_REG_CONTROL3	= 0x0E,
+	MAX77843_MUIC_REG_CONTROL4	= 0x16,
+	MAX77843_MUIC_REG_HVCONTROL1	= 0x17,
+	MAX77843_MUIC_REG_HVCONTROL2	= 0x18,
+
+	MAX77843_MUIC_REG_END,
+};
+
+enum max77843_irq {
+	/* Topsys: SYSTEM */
+	MAX77843_SYS_IRQ_SYSINTSRC_SYSUVLO_INT,
+	MAX77843_SYS_IRQ_SYSINTSRC_SYSOVLO_INT,
+	MAX77843_SYS_IRQ_SYSINTSRC_TSHDN_INT,
+	MAX77843_SYS_IRQ_SYSINTSRC_TM_INT,
+
+	/* Charger: CHG_INT */
+	MAX77843_CHG_IRQ_CHG_INT_BYP_I,
+	MAX77843_CHG_IRQ_CHG_INT_BATP_I,
+	MAX77843_CHG_IRQ_CHG_INT_BAT_I,
+	MAX77843_CHG_IRQ_CHG_INT_CHG_I,
+	MAX77843_CHG_IRQ_CHG_INT_WCIN_I,
+	MAX77843_CHG_IRQ_CHG_INT_CHGIN_I,
+	MAX77843_CHG_IRQ_CHG_INT_AICL_I,
+
+	MAX77843_IRQ_NUM,
+};
+
+enum max77843_irq_muic {
+	/* MUIC: INT1 */
+	MAX77843_MUIC_IRQ_INT1_ADC,
+	MAX77843_MUIC_IRQ_INT1_ADCERROR,
+	MAX77843_MUIC_IRQ_INT1_ADC1K,
+
+	/* MUIC: INT2 */
+	MAX77843_MUIC_IRQ_INT2_CHGTYP,
+	MAX77843_MUIC_IRQ_INT2_CHGDETRUN,
+	MAX77843_MUIC_IRQ_INT2_DCDTMR,
+	MAX77843_MUIC_IRQ_INT2_DXOVP,
+	MAX77843_MUIC_IRQ_INT2_VBVOLT,
+
+	/* MUIC: INT3 */
+	MAX77843_MUIC_IRQ_INT3_VBADC,
+	MAX77843_MUIC_IRQ_INT3_VDNMON,
+	MAX77843_MUIC_IRQ_INT3_DNRES,
+	MAX77843_MUIC_IRQ_INT3_MPNACK,
+	MAX77843_MUIC_IRQ_INT3_MRXBUFOW,
+	MAX77843_MUIC_IRQ_INT3_MRXTRF,
+	MAX77843_MUIC_IRQ_INT3_MRXPERR,
+	MAX77843_MUIC_IRQ_INT3_MRXRDY,
+
+	MAX77843_MUIC_IRQ_NUM,
+};
+
+/* MAX77843 interrupts */
+#define MAX77843_SYS_IRQ_SYSUVLO_INT		BIT(0)
+#define MAX77843_SYS_IRQ_SYSOVLO_INT		BIT(1)
+#define MAX77843_SYS_IRQ_TSHDN_INT		BIT(2)
+#define MAX77843_SYS_IRQ_TM_INT			BIT(3)
+
+/* MAX77843 MAINCTRL1 register */
+#define MAINCTRL1_BIASEN_SHIFT			7
+#define MAX77843_MAINCTRL1_BIASEN_MASK		BIT(MAINCTRL1_BIASEN_SHIFT)
+
+/* MAX77843 MCONFIG register */
+#define MCONFIG_MODE_SHIFT			7
+#define MCONFIG_MEN_SHIFT			6
+#define MCONFIG_PDIV_SHIFT			0
+
+#define MAX77843_MCONFIG_MODE_MASK		BIT(MCONFIG_MODE_SHIFT)
+#define MAX77843_MCONFIG_MEN_MASK		BIT(MCONFIG_MEN_SHIFT)
+#define MAX77843_MCONFIG_PDIV_MASK		(0x3 << MCONFIG_PDIV_SHIFT)
+
+/* Max77843 charger insterrupts */
+#define MAX77843_CHG_BYP_I			BIT(0)
+#define MAX77843_CHG_BATP_I			BIT(2)
+#define MAX77843_CHG_BAT_I			BIT(3)
+#define MAX77843_CHG_CHG_I			BIT(4)
+#define MAX77843_CHG_WCIN_I			BIT(5)
+#define MAX77843_CHG_CHGIN_I			BIT(6)
+#define MAX77843_CHG_AICL_I			BIT(7)
+
+/* MAX77843 CHG_INT_OK register */
+#define MAX77843_CHG_BYP_OK			BIT(0)
+#define MAX77843_CHG_BATP_OK			BIT(2)
+#define MAX77843_CHG_BAT_OK			BIT(3)
+#define MAX77843_CHG_CHG_OK			BIT(4)
+#define MAX77843_CHG_WCIN_OK			BIT(5)
+#define MAX77843_CHG_CHGIN_OK			BIT(6)
+#define MAX77843_CHG_AICL_OK			BIT(7)
+
+/* MAX77843 CHG_DETAILS_00 register */
+#define MAX77843_CHG_BAT_DTLS			BIT(0)
+
+/* MAX77843 CHG_DETAILS_01 register */
+#define MAX77843_CHG_DTLS_MASK			0x0f
+#define MAX77843_CHG_PQ_MODE			0x00
+#define MAX77843_CHG_CC_MODE			0x01
+#define MAX77843_CHG_CV_MODE			0x02
+#define MAX77843_CHG_TO_MODE			0x03
+#define MAX77843_CHG_DO_MODE			0x04
+#define MAX77843_CHG_HT_MODE			0x05
+#define MAX77843_CHG_TF_MODE			0x06
+#define MAX77843_CHG_TS_MODE			0x07
+#define MAX77843_CHG_OFF_MODE			0x08
+
+#define MAX77843_CHG_BAT_DTLS_MASK		0xf0
+#define MAX77843_CHG_NO_BAT			(0x00 << 4)
+#define MAX77843_CHG_LOW_VOLT_BAT		(0x01 << 4)
+#define MAX77843_CHG_LONG_BAT_TIME		(0x02 << 4)
+#define MAX77843_CHG_OK_BAT			(0x03 << 4)
+#define MAX77843_CHG_OK_LOW_VOLT_BAT		(0x04 << 4)
+#define MAX77843_CHG_OVER_VOLT_BAT		(0x05 << 4)
+#define MAX77843_CHG_OVER_CURRENT_BAT		(0x06 << 4)
+
+/* MAX77843 CHG_CNFG_00 register */
+#define MAX77843_CHG_DISABLE			0x00
+#define MAX77843_CHG_ENABLE			0x05
+#define MAX77843_CHG_MASK			0x01
+#define MAX77843_CHG_BUCK_MASK			0x04
+
+/* MAX77843 CHG_CNFG_01 register */
+#define MAX77843_CHG_RESTART_THRESHOLD_100	0x00
+#define MAX77843_CHG_RESTART_THRESHOLD_150	0x10
+#define MAX77843_CHG_RESTART_THRESHOLD_200	0x20
+#define MAX77843_CHG_RESTART_THRESHOLD_DISABLE	0x30
+
+/* MAX77843 CHG_CNFG_02 register */
+#define MAX77843_CHG_FAST_CHG_CURRENT_MIN	100000
+#define MAX77843_CHG_FAST_CHG_CURRENT_MAX	3150000
+#define MAX77843_CHG_FAST_CHG_CURRENT_STEP	50000
+#define MAX77843_CHG_FAST_CHG_CURRENT_MASK	0x3f
+#define MAX77843_CHG_OTG_ILIMIT_500		(0x00 << 6)
+#define MAX77843_CHG_OTG_ILIMIT_900		(0x01 << 6)
+#define MAX77843_CHG_OTG_ILIMIT_1200		(0x02 << 6)
+#define MAX77843_CHG_OTG_ILIMIT_1500		(0x03 << 6)
+#define MAX77843_CHG_OTG_ILIMIT_MASK		0xc0
+
+/* MAX77843 CHG_CNFG_03 register */
+#define MAX77843_CHG_TOP_OFF_CURRENT_MIN	125000
+#define MAX77843_CHG_TOP_OFF_CURRENT_MAX	650000
+#define MAX77843_CHG_TOP_OFF_CURRENT_STEP	75000
+#define MAX77843_CHG_TOP_OFF_CURRENT_MASK	0x07
+
+/* MAX77843 CHG_CNFG_06 register */
+#define MAX77843_CHG_WRITE_CAP_BLOCK		0x10
+#define MAX77843_CHG_WRITE_CAP_UNBLOCK		0x0C
+
+/* MAX77843_CHG_CNFG_09_register */
+#define MAX77843_CHG_INPUT_CURRENT_LIMIT_MIN	100000
+#define MAX77843_CHG_INPUT_CURRENT_LIMIT_MAX	4000000
+#define MAX77843_CHG_INPUT_CURRENT_LIMIT_REF	3367000
+#define MAX77843_CHG_INPUT_CURRENT_LIMIT_STEP	33000
+
+#define MAX77843_MUIC_ADC			BIT(0)
+#define MAX77843_MUIC_ADCERROR			BIT(2)
+#define MAX77843_MUIC_ADC1K			BIT(3)
+
+#define MAX77843_MUIC_CHGTYP			BIT(0)
+#define MAX77843_MUIC_CHGDETRUN			BIT(1)
+#define MAX77843_MUIC_DCDTMR			BIT(2)
+#define MAX77843_MUIC_DXOVP			BIT(3)
+#define MAX77843_MUIC_VBVOLT			BIT(4)
+
+#define MAX77843_MUIC_VBADC			BIT(0)
+#define MAX77843_MUIC_VDNMON			BIT(1)
+#define MAX77843_MUIC_DNRES			BIT(2)
+#define MAX77843_MUIC_MPNACK			BIT(3)
+#define MAX77843_MUIC_MRXBUFOW			BIT(4)
+#define MAX77843_MUIC_MRXTRF			BIT(5)
+#define MAX77843_MUIC_MRXPERR			BIT(6)
+#define MAX77843_MUIC_MRXRDY			BIT(7)
+
+/* MAX77843 INTSRCMASK register */
+#define MAX77843_INTSRCMASK_CHGR		0
+#define MAX77843_INTSRCMASK_SYS			1
+#define MAX77843_INTSRCMASK_FG			2
+#define MAX77843_INTSRCMASK_MUIC		3
+
+#define MAX77843_INTSRCMASK_CHGR_MASK          BIT(MAX77843_INTSRCMASK_CHGR)
+#define MAX77843_INTSRCMASK_SYS_MASK           BIT(MAX77843_INTSRCMASK_SYS)
+#define MAX77843_INTSRCMASK_FG_MASK            BIT(MAX77843_INTSRCMASK_FG)
+#define MAX77843_INTSRCMASK_MUIC_MASK          BIT(MAX77843_INTSRCMASK_MUIC)
+
+#define MAX77843_INTSRC_MASK_MASK \
+	(MAX77843_INTSRCMASK_MUIC_MASK | MAX77843_INTSRCMASK_FG_MASK | \
+	MAX77843_INTSRCMASK_SYS_MASK | MAX77843_INTSRCMASK_CHGR_MASK)
+
+/* MAX77843 STATUS register*/
+#define STATUS1_ADC_SHIFT			0
+#define STATUS1_ADCERROR_SHIFT			6
+#define STATUS1_ADC1K_SHIFT			7
+#define STATUS2_CHGTYP_SHIFT			0
+#define STATUS2_CHGDETRUN_SHIFT			3
+#define STATUS2_DCDTMR_SHIFT			4
+#define STATUS2_DXOVP_SHIFT			5
+#define STATUS2_VBVOLT_SHIFT			6
+#define STATUS3_VBADC_SHIFT			0
+#define STATUS3_VDNMON_SHIFT			4
+#define STATUS3_DNRES_SHIFT			5
+#define STATUS3_MPNACK_SHIFT			6
+
+#define MAX77843_MUIC_STATUS1_ADC_MASK		(0x1f << STATUS1_ADC_SHIFT)
+#define MAX77843_MUIC_STATUS1_ADCERROR_MASK	BIT(STATUS1_ADCERROR_SHIFT)
+#define MAX77843_MUIC_STATUS1_ADC1K_MASK	BIT(STATUS1_ADC1K_SHIFT)
+#define MAX77843_MUIC_STATUS2_CHGTYP_MASK	(0x7 << STATUS2_CHGTYP_SHIFT)
+#define MAX77843_MUIC_STATUS2_CHGDETRUN_MASK	BIT(STATUS2_CHGDETRUN_SHIFT)
+#define MAX77843_MUIC_STATUS2_DCDTMR_MASK	BIT(STATUS2_DCDTMR_SHIFT)
+#define MAX77843_MUIC_STATUS2_DXOVP_MASK	BIT(STATUS2_DXOVP_SHIFT)
+#define MAX77843_MUIC_STATUS2_VBVOLT_MASK	BIT(STATUS2_VBVOLT_SHIFT)
+#define MAX77843_MUIC_STATUS3_VBADC_MASK	(0xf << STATUS3_VBADC_SHIFT)
+#define MAX77843_MUIC_STATUS3_VDNMON_MASK	BIT(STATUS3_VDNMON_SHIFT)
+#define MAX77843_MUIC_STATUS3_DNRES_MASK	BIT(STATUS3_DNRES_SHIFT)
+#define MAX77843_MUIC_STATUS3_MPNACK_MASK	BIT(STATUS3_MPNACK_SHIFT)
+
+/* MAX77843 CONTROL register */
+#define CONTROL1_COMP1SW_SHIFT			0
+#define CONTROL1_COMP2SW_SHIFT			3
+#define CONTROL1_IDBEN_SHIFT			7
+#define CONTROL2_LOWPWR_SHIFT			0
+#define CONTROL2_ADCEN_SHIFT			1
+#define CONTROL2_CPEN_SHIFT			2
+#define CONTROL2_ACC_DET_SHIFT			5
+#define CONTROL2_USBCPINT_SHIFT			6
+#define CONTROL2_RCPS_SHIFT			7
+#define CONTROL3_JIGSET_SHIFT			0
+#define CONTROL4_ADCDBSET_SHIFT			0
+#define CONTROL4_USBAUTO_SHIFT			4
+#define CONTROL4_FCTAUTO_SHIFT			5
+#define CONTROL4_ADCMODE_SHIFT			6
+
+#define MAX77843_MUIC_CONTROL1_COMP1SW_MASK	(0x7 << CONTROL1_COMP1SW_SHIFT)
+#define MAX77843_MUIC_CONTROL1_COMP2SW_MASK	(0x7 << CONTROL1_COMP2SW_SHIFT)
+#define MAX77843_MUIC_CONTROL1_IDBEN_MASK	BIT(CONTROL1_IDBEN_SHIFT)
+#define MAX77843_MUIC_CONTROL2_LOWPWR_MASK	BIT(CONTROL2_LOWPWR_SHIFT)
+#define MAX77843_MUIC_CONTROL2_ADCEN_MASK	BIT(CONTROL2_ADCEN_SHIFT)
+#define MAX77843_MUIC_CONTROL2_CPEN_MASK	BIT(CONTROL2_CPEN_SHIFT)
+#define MAX77843_MUIC_CONTROL2_ACC_DET_MASK	BIT(CONTROL2_ACC_DET_SHIFT)
+#define MAX77843_MUIC_CONTROL2_USBCPINT_MASK	BIT(CONTROL2_USBCPINT_SHIFT)
+#define MAX77843_MUIC_CONTROL2_RCPS_MASK	BIT(CONTROL2_RCPS_SHIFT)
+#define MAX77843_MUIC_CONTROL3_JIGSET_MASK	(0x3 << CONTROL3_JIGSET_SHIFT)
+#define MAX77843_MUIC_CONTROL4_ADCDBSET_MASK	(0x3 << CONTROL4_ADCDBSET_SHIFT)
+#define MAX77843_MUIC_CONTROL4_USBAUTO_MASK	BIT(CONTROL4_USBAUTO_SHIFT)
+#define MAX77843_MUIC_CONTROL4_FCTAUTO_MASK	BIT(CONTROL4_FCTAUTO_SHIFT)
+#define MAX77843_MUIC_CONTROL4_ADCMODE_MASK	(0x3 << CONTROL4_ADCMODE_SHIFT)
+
+/* MAX77843 switch port */
+#define COM_OPEN				0
+#define COM_USB					1
+#define COM_AUDIO				2
+#define COM_UART				3
+#define COM_AUX_USB				4
+#define COM_AUX_UART				5
+
+#define CONTROL1_COM_SW \
+	((MAX77843_MUIC_CONTROL1_COMP1SW_MASK | \
+	 MAX77843_MUIC_CONTROL1_COMP2SW_MASK))
+
+#define CONTROL1_SW_OPEN \
+	((COM_OPEN << CONTROL1_COMP1SW_SHIFT | \
+	 COM_OPEN << CONTROL1_COMP2SW_SHIFT))
+#define CONTROL1_SW_USB \
+	((COM_USB << CONTROL1_COMP1SW_SHIFT | \
+	 COM_USB << CONTROL1_COMP2SW_SHIFT))
+#define CONTROL1_SW_AUDIO \
+	((COM_AUDIO << CONTROL1_COMP1SW_SHIFT | \
+	 COM_AUDIO << CONTROL1_COMP2SW_SHIFT))
+#define CONTROL1_SW_UART \
+	((COM_UART << CONTROL1_COMP1SW_SHIFT | \
+	 COM_UART << CONTROL1_COMP2SW_SHIFT))
+#define CONTROL1_SW_AUX_USB \
+	((COM_AUX_USB << CONTROL1_COMP1SW_SHIFT | \
+	 COM_AUX_USB << CONTROL1_COMP2SW_SHIFT))
+#define CONTROL1_SW_AUX_UART \
+	((COM_AUX_UART << CONTROL1_COMP1SW_SHIFT | \
+	 COM_AUX_UART << CONTROL1_COMP2SW_SHIFT))
+
+#define MAX77843_DISABLE			0
+#define MAX77843_ENABLE				1
+
+#define CONTROL4_AUTO_DISABLE \
+	((MAX77843_DISABLE << CONTROL4_USBAUTO_SHIFT) | \
+	(MAX77843_DISABLE << CONTROL4_FCTAUTO_SHIFT))
+#define CONTROL4_AUTO_ENABLE \
+	((MAX77843_ENABLE << CONTROL4_USBAUTO_SHIFT) | \
+	(MAX77843_ENABLE << CONTROL4_FCTAUTO_SHIFT))
+
+/* MAX77843 SAFEOUT LDO Control register */
+#define SAFEOUTCTRL_SAFEOUT1_SHIFT		0
+#define SAFEOUTCTRL_SAFEOUT2_SHIFT		2
+#define SAFEOUTCTRL_ENSAFEOUT1_SHIFT		6
+#define SAFEOUTCTRL_ENSAFEOUT2_SHIFT		7
+
+#define MAX77843_REG_SAFEOUTCTRL_ENSAFEOUT1 \
+		BIT(SAFEOUTCTRL_ENSAFEOUT1_SHIFT)
+#define MAX77843_REG_SAFEOUTCTRL_ENSAFEOUT2 \
+		BIT(SAFEOUTCTRL_ENSAFEOUT2_SHIFT)
+#define MAX77843_REG_SAFEOUTCTRL_SAFEOUT1_MASK \
+		(0x3 << SAFEOUTCTRL_SAFEOUT1_SHIFT)
+#define MAX77843_REG_SAFEOUTCTRL_SAFEOUT2_MASK \
+		(0x3 << SAFEOUTCTRL_SAFEOUT2_SHIFT)
+
+struct max77843 {
+	struct device *dev;
+
+	struct i2c_client *i2c;
+	struct i2c_client *i2c_chg;
+	struct i2c_client *i2c_fuel;
+	struct i2c_client *i2c_muic;
+
+	struct regmap *regmap;
+	struct regmap *regmap_chg;
+	struct regmap *regmap_fuel;
+	struct regmap *regmap_muic;
+
+	struct regmap_irq_chip_data *irq_data;
+	struct regmap_irq_chip_data *irq_data_chg;
+	struct regmap_irq_chip_data *irq_data_fuel;
+	struct regmap_irq_chip_data *irq_data_muic;
+
+	int irq;
+};
+#endif /* __MAX77843_H__ */
-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver
  2015-03-02 10:10 [PATCH v7 0/5] Add new MFD driver for MAX77843 Jaewon Kim
  2015-03-02 10:10 ` [PATCH v7 1/5] mfd: max77843: Add max77843 MFD driver core driver Jaewon Kim
@ 2015-03-02 10:10 ` Jaewon Kim
  2015-03-07 20:13   ` Sebastian Reichel
  2015-03-02 10:10 ` [PATCH v7 3/5] power: max77843_battery: Add Max77843 fuel gauge " Jaewon Kim
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 36+ messages in thread
From: Jaewon Kim @ 2015-03-02 10:10 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-pm, linux-input
  Cc: Inki Dae, SangBae Lee, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Lee Jones, Chanwoo Choi,
	Sebastian Reichel, Beomho Seo, Jaewon Kim, Dmitry Torokhov

From: Beomho Seo <beomho.seo@samsung.com>

This patch adds device driver of max77843 charger. This driver provide
initialize each charging mode(e.g. fast charge, top-off mode and constant
charging mode so on.). Additionally, control charging paramters to use
i2c interface.

Cc: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
---
 drivers/power/Kconfig            |    7 +
 drivers/power/Makefile           |    1 +
 drivers/power/max77843_charger.c |  508 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 516 insertions(+)
 create mode 100644 drivers/power/max77843_charger.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 27b751b..994793d 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -337,6 +337,13 @@ config CHARGER_MAX77693
 	help
 	  Say Y to enable support for the Maxim MAX77693 battery charger.
 
+config CHARGER_MAX77843
+	tristate "Maxim MAX77843 battery charger driver"
+	depends on MFD_MAX77843
+	help
+	  Say Y to enable support for the battery charger control sysfs and
+	  platform data of MAX77843
+
 config CHARGER_MAX8997
 	tristate "Maxim MAX8997/MAX8966 PMIC battery charger driver"
 	depends on MFD_MAX8997 && REGULATOR_MAX8997
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index 36f9e0d..ed69cea 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -53,6 +53,7 @@ obj-$(CONFIG_CHARGER_GPIO)	+= gpio-charger.o
 obj-$(CONFIG_CHARGER_MANAGER)	+= charger-manager.o
 obj-$(CONFIG_CHARGER_MAX14577)	+= max14577_charger.o
 obj-$(CONFIG_CHARGER_MAX77693)	+= max77693_charger.o
+obj-$(CONFIG_CHARGER_MAX77843)	+= max77843_charger.o
 obj-$(CONFIG_CHARGER_MAX8997)	+= max8997_charger.o
 obj-$(CONFIG_CHARGER_MAX8998)	+= max8998_charger.o
 obj-$(CONFIG_CHARGER_BQ2415X)	+= bq2415x_charger.o
diff --git a/drivers/power/max77843_charger.c b/drivers/power/max77843_charger.c
new file mode 100644
index 0000000..d4cce17
--- /dev/null
+++ b/drivers/power/max77843_charger.c
@@ -0,0 +1,508 @@
+/*
+ * Charger driver for Maxim MAX77843
+ *
+ * Copyright (C) 2015 Samsung Electronics, Co., Ltd.
+ * Author: Beomho Seo <beomho.seo@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/power_supply.h>
+#include <linux/mfd/max77843-private.h>
+
+struct max77843_charger_info {
+	u32 fast_charge_uamp;
+	u32 top_off_uamp;
+	u32 input_uamp_limit;
+};
+
+struct max77843_charger {
+	struct device		*dev;
+	struct max77843		*max77843;
+	struct i2c_client	*client;
+	struct regmap		*regmap;
+	struct power_supply	psy;
+
+	struct max77843_charger_info	*info;
+};
+
+static int max77843_charger_get_max_current(struct max77843_charger *charger)
+{
+	struct regmap *regmap = charger->regmap;
+	int ret, val = 0;
+	unsigned int reg_data;
+
+	ret = regmap_read(regmap, MAX77843_CHG_REG_CHG_CNFG_09, &reg_data);
+	if (ret) {
+		dev_err(charger->dev,
+			"Failed to read max current register: %d\n", ret);
+		return ret;
+	}
+
+	if (reg_data <= 0x03) {
+		val = MAX77843_CHG_INPUT_CURRENT_LIMIT_MIN;
+	} else if (reg_data >= 0x78) {
+		val = MAX77843_CHG_INPUT_CURRENT_LIMIT_MAX;
+	} else {
+		val = reg_data / 3;
+		if (reg_data % 3 == 0)
+			val *= 100000;
+		else if (reg_data % 3 == 1)
+			val = val * 100000 + 33000;
+		else
+			val = val * 100000 + 67000;
+	}
+
+	return val;
+}
+
+static int max77843_charger_get_now_current(struct max77843_charger *charger)
+{
+	struct regmap *regmap = charger->regmap;
+	int ret, val = 0;
+	unsigned int reg_data;
+
+	ret = regmap_read(regmap, MAX77843_CHG_REG_CHG_CNFG_02, &reg_data);
+	if (ret) {
+		dev_err(charger->dev,
+			"Failed to read charge current register: %d\n", ret);
+		return ret;
+	}
+
+	reg_data &= MAX77843_CHG_FAST_CHG_CURRENT_MASK;
+
+	if (reg_data <= 0x02)
+		val = MAX77843_CHG_FAST_CHG_CURRENT_MIN;
+	else if (reg_data >= 0x3f)
+		val = MAX77843_CHG_FAST_CHG_CURRENT_MAX;
+	else
+		val = reg_data * MAX77843_CHG_FAST_CHG_CURRENT_STEP;
+
+	return val;
+}
+
+static int max77843_charger_get_online(struct max77843_charger *charger)
+{
+	struct regmap *regmap = charger->regmap;
+	int ret, val = 0;
+	unsigned int reg_data;
+
+	ret = regmap_read(regmap, MAX77843_CHG_REG_CHG_INT_OK, &reg_data);
+	if (ret) {
+		dev_err(charger->dev,
+				"Failed to read charger status: %d\n", ret);
+		return ret;
+	}
+
+	if (reg_data & MAX77843_CHG_CHGIN_OK)
+		val = true;
+	else
+		val = false;
+
+	return val;
+}
+
+static int max77843_charger_get_present(struct max77843_charger *charger)
+{
+	struct regmap *regmap = charger->regmap;
+	int ret, val = 0;
+	unsigned int reg_data;
+
+	ret = regmap_read(regmap, MAX77843_CHG_REG_CHG_DTLS_00,	&reg_data);
+	if (ret) {
+		dev_err(charger->dev,
+				"Failed to read battery present: %d\n", ret);
+		return ret;
+	}
+
+	if (reg_data & MAX77843_CHG_BAT_DTLS)
+		val = false;
+	else
+		val = true;
+
+	return val;
+}
+
+static int max77843_charger_get_health(struct max77843_charger *charger)
+{
+	struct regmap *regmap = charger->regmap;
+	int ret, val = POWER_SUPPLY_HEALTH_UNKNOWN;
+	unsigned int reg_data;
+
+	ret = regmap_read(regmap, MAX77843_CHG_REG_CHG_DTLS_01,	&reg_data);
+	if (ret) {
+		dev_err(charger->dev,
+				"Failed to read battery health: %d\n", ret);
+		return ret;
+	}
+
+	reg_data &= MAX77843_CHG_BAT_DTLS_MASK;
+
+	switch (reg_data) {
+	case MAX77843_CHG_NO_BAT:
+		val = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE;
+		break;
+	case MAX77843_CHG_LOW_VOLT_BAT:
+	case MAX77843_CHG_OK_BAT:
+	case MAX77843_CHG_OK_LOW_VOLT_BAT:
+		val = POWER_SUPPLY_HEALTH_GOOD;
+		break;
+	case MAX77843_CHG_LONG_BAT_TIME:
+		val = POWER_SUPPLY_HEALTH_DEAD;
+		break;
+	case MAX77843_CHG_OVER_VOLT_BAT:
+	case MAX77843_CHG_OVER_CURRENT_BAT:
+		val = POWER_SUPPLY_HEALTH_OVERVOLTAGE;
+		break;
+	default:
+		val = POWER_SUPPLY_HEALTH_UNKNOWN;
+		break;
+	}
+
+	return val;
+}
+
+static int max77843_charger_get_status(struct max77843_charger *charger)
+{
+	struct regmap *regmap = charger->regmap;
+	int ret, val = 0;
+	unsigned int reg_data;
+
+	ret = regmap_read(regmap, MAX77843_CHG_REG_CHG_DTLS_01,	&reg_data);
+	if (ret) {
+		dev_err(charger->dev,
+				"Failed to read charger status: %d\n", ret);
+		return ret;
+	}
+
+	reg_data &= MAX77843_CHG_DTLS_MASK;
+
+	switch (reg_data) {
+	case MAX77843_CHG_PQ_MODE:
+	case MAX77843_CHG_CC_MODE:
+	case MAX77843_CHG_CV_MODE:
+		val = POWER_SUPPLY_STATUS_CHARGING;
+		break;
+	case MAX77843_CHG_TO_MODE:
+	case MAX77843_CHG_DO_MODE:
+		val = POWER_SUPPLY_STATUS_FULL;
+		break;
+	case MAX77843_CHG_HT_MODE:
+	case MAX77843_CHG_TF_MODE:
+	case MAX77843_CHG_TS_MODE:
+		val = POWER_SUPPLY_STATUS_NOT_CHARGING;
+		break;
+	case MAX77843_CHG_OFF_MODE:
+		val = POWER_SUPPLY_STATUS_DISCHARGING;
+		break;
+	default:
+		val = POWER_SUPPLY_STATUS_UNKNOWN;
+		break;
+	}
+
+	return val;
+}
+
+static const char *model_name = "MAX77843";
+static const char *manufacturer = "Maxim Integrated";
+
+static int max77843_charger_get_property(struct power_supply *psy,
+		enum power_supply_property psp,
+		union power_supply_propval *val)
+{
+	struct max77843_charger *charger = container_of(psy,
+				struct max77843_charger, psy);
+
+	switch (psp) {
+	case POWER_SUPPLY_PROP_STATUS:
+		val->intval = max77843_charger_get_status(charger);
+		break;
+	case POWER_SUPPLY_PROP_HEALTH:
+		val->intval = max77843_charger_get_health(charger);
+		break;
+	case POWER_SUPPLY_PROP_PRESENT:
+		val->intval = max77843_charger_get_present(charger);
+		break;
+	case POWER_SUPPLY_PROP_ONLINE:
+		val->intval = max77843_charger_get_online(charger);
+		break;
+	case POWER_SUPPLY_PROP_CURRENT_NOW:
+		val->intval = max77843_charger_get_now_current(charger);
+		break;
+	case POWER_SUPPLY_PROP_CURRENT_MAX:
+		val->intval = max77843_charger_get_max_current(charger);
+		break;
+	case POWER_SUPPLY_PROP_MODEL_NAME:
+		val->strval =  model_name;
+		break;
+	case POWER_SUPPLY_PROP_MANUFACTURER:
+		val->strval = manufacturer;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static enum power_supply_property max77843_charger_props[] = {
+	POWER_SUPPLY_PROP_STATUS,
+	POWER_SUPPLY_PROP_HEALTH,
+	POWER_SUPPLY_PROP_PRESENT,
+	POWER_SUPPLY_PROP_ONLINE,
+	POWER_SUPPLY_PROP_CURRENT_NOW,
+	POWER_SUPPLY_PROP_CURRENT_MAX,
+	POWER_SUPPLY_PROP_MODEL_NAME,
+	POWER_SUPPLY_PROP_MANUFACTURER,
+};
+
+static int max77843_charger_init_current_limit(struct max77843_charger *charger)
+{
+	struct regmap *regmap = charger->regmap;
+	struct max77843_charger_info *info = charger->info;
+	unsigned int input_uamp_limit = info->input_uamp_limit;
+	int ret;
+	unsigned int reg_data, val;
+
+	ret = regmap_update_bits(regmap, MAX77843_CHG_REG_CHG_CNFG_02,
+			MAX77843_CHG_OTG_ILIMIT_MASK,
+			MAX77843_CHG_OTG_ILIMIT_900);
+	if (ret) {
+		dev_err(charger->dev,
+			"Failed to write OTG current limit: %d\n", ret);
+		return ret;
+	}
+
+	if (input_uamp_limit == MAX77843_CHG_INPUT_CURRENT_LIMIT_MIN) {
+		reg_data = 0x03;
+	} else if (input_uamp_limit == MAX77843_CHG_INPUT_CURRENT_LIMIT_MAX) {
+		reg_data = 0x78;
+	} else {
+		if (input_uamp_limit < MAX77843_CHG_INPUT_CURRENT_LIMIT_REF)
+			val = 0x03;
+		else
+			val = 0x02;
+
+		input_uamp_limit -= MAX77843_CHG_INPUT_CURRENT_LIMIT_MIN;
+		input_uamp_limit /= MAX77843_CHG_INPUT_CURRENT_LIMIT_STEP;
+		reg_data = val + input_uamp_limit;
+	}
+
+	ret = regmap_write(regmap, MAX77843_CHG_REG_CHG_CNFG_09, reg_data);
+	if (ret)
+		dev_err(charger->dev,
+			"Failed to write charge current limit: %d\n", ret);
+
+	return ret;
+}
+
+static int max77843_charger_init_top_off(struct max77843_charger *charger)
+{
+	struct regmap *regmap = charger->regmap;
+	struct max77843_charger_info *info = charger->info;
+	unsigned int top_off_uamp = info->top_off_uamp;
+	int ret;
+	unsigned int reg_data;
+
+	if (top_off_uamp == MAX77843_CHG_TOP_OFF_CURRENT_MIN) {
+		reg_data = 0x00;
+	} else if (top_off_uamp == MAX77843_CHG_TOP_OFF_CURRENT_MAX) {
+		reg_data = 0x07;
+	} else {
+		top_off_uamp -= MAX77843_CHG_TOP_OFF_CURRENT_MIN;
+		top_off_uamp /= MAX77843_CHG_TOP_OFF_CURRENT_STEP;
+		reg_data = top_off_uamp;
+	}
+
+	ret = regmap_update_bits(regmap, MAX77843_CHG_REG_CHG_CNFG_03,
+			MAX77843_CHG_TOP_OFF_CURRENT_MASK, reg_data);
+	if (ret)
+		dev_err(charger->dev,
+				"Failed to write top off current: %d\n", ret);
+
+	return ret;
+}
+
+static int max77843_charger_init_fast_charge(struct max77843_charger *charger)
+{
+	struct regmap *regmap = charger->regmap;
+	struct max77843_charger_info *info = charger->info;
+	unsigned int fast_charge_uamp = info->fast_charge_uamp;
+	int ret;
+	unsigned int reg_data;
+
+	if (fast_charge_uamp < info->input_uamp_limit) {
+		reg_data = 0x09;
+	} else if (fast_charge_uamp == MAX77843_CHG_FAST_CHG_CURRENT_MIN) {
+		reg_data = 0x02;
+	} else if (fast_charge_uamp == MAX77843_CHG_FAST_CHG_CURRENT_MAX) {
+		reg_data = 0x3f;
+	} else {
+		fast_charge_uamp -= MAX77843_CHG_FAST_CHG_CURRENT_MIN;
+		fast_charge_uamp /= MAX77843_CHG_FAST_CHG_CURRENT_STEP;
+		reg_data = 0x02 + fast_charge_uamp;
+	}
+
+	ret = regmap_update_bits(regmap, MAX77843_CHG_REG_CHG_CNFG_02,
+			MAX77843_CHG_FAST_CHG_CURRENT_MASK, reg_data);
+	if (ret)
+		dev_err(charger->dev,
+			"Failed to write fast charge current: %d\n", ret);
+
+	return ret;
+}
+
+static int max77843_charger_init(struct max77843_charger *charger)
+{
+	struct regmap *regmap = charger->regmap;
+	int ret;
+
+	ret = regmap_write(regmap, MAX77843_CHG_REG_CHG_CNFG_06,
+			MAX77843_CHG_WRITE_CAP_UNBLOCK);
+	if (ret) {
+		dev_err(charger->dev,
+			"Failed to unblock write capability: %d\n", ret);
+		return ret;
+	}
+
+	ret = regmap_write(regmap, MAX77843_CHG_REG_CHG_CNFG_01,
+			MAX77843_CHG_RESTART_THRESHOLD_DISABLE);
+	if (ret) {
+		dev_err(charger->dev,
+			"Failed to write charger restart threshold: %d\n", ret);
+		return ret;
+	}
+
+	ret = max77843_charger_init_fast_charge(charger);
+	if (ret) {
+		dev_err(charger->dev,
+				"Failed to set fast charge mode: %d\n", ret);
+		return ret;
+	}
+
+	ret = max77843_charger_init_top_off(charger);
+	if (ret) {
+		dev_err(charger->dev, "Failed to set top off charge mode.\n");
+		return ret;
+	}
+
+	ret = max77843_charger_init_current_limit(charger);
+	if (ret)
+		dev_err(charger->dev, "Faied to set current limit.\n");
+
+	return 0;
+}
+
+static struct max77843_charger_info *max77843_charger_dt_init(
+		struct platform_device *pdev)
+{
+	struct max77843_charger_info *info;
+	struct device_node *np = pdev->dev.of_node;
+	int ret;
+
+	if (!np) {
+		dev_err(&pdev->dev, "No charger OF node\n");
+		return ERR_PTR(-EINVAL);
+	}
+
+	info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
+	if (!info)
+		return ERR_PTR(-ENOMEM);
+
+	ret = of_property_read_u32(np, "maxim,fast-charge-uamp",
+			&info->fast_charge_uamp);
+	if (ret) {
+		dev_err(&pdev->dev, "Cannot parse fast charge current.\n");
+		return ERR_PTR(ret);
+	}
+
+	ret = of_property_read_u32(np, "maxim,top-off-uamp",
+			&info->top_off_uamp);
+	if (ret) {
+		dev_err(&pdev->dev,
+			"Cannot parse primary charger termination voltage.\n");
+		return ERR_PTR(ret);
+	}
+
+	ret = of_property_read_u32(np, "maxim,input-uamp-limit",
+			&info->input_uamp_limit);
+	if (ret) {
+		dev_err(&pdev->dev, "Cannot parse input current limit value\n");
+		return ERR_PTR(ret);
+	}
+
+	return info;
+}
+
+static int max77843_charger_probe(struct platform_device *pdev)
+{
+	struct max77843 *max77843 = dev_get_drvdata(pdev->dev.parent);
+	struct max77843_charger *charger;
+	int ret;
+
+	charger = devm_kzalloc(&pdev->dev, sizeof(*charger), GFP_KERNEL);
+	if (!charger)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, charger);
+	charger->dev = &pdev->dev;
+	charger->max77843 = max77843;
+	charger->client = max77843->i2c_chg;
+	charger->regmap = max77843->regmap_chg;
+
+	charger->info = max77843_charger_dt_init(pdev);
+	if (IS_ERR_OR_NULL(charger->info))
+		return PTR_ERR(charger->info);
+
+	charger->psy.name	= "max77843-charger";
+	charger->psy.type	= POWER_SUPPLY_TYPE_MAINS;
+	charger->psy.get_property	= max77843_charger_get_property;
+	charger->psy.properties		= max77843_charger_props;
+	charger->psy.num_properties	= ARRAY_SIZE(max77843_charger_props);
+
+	ret = max77843_charger_init(charger);
+	if (ret)
+		return ret;
+
+	ret = power_supply_register(&pdev->dev, &charger->psy);
+	if (ret) {
+		dev_err(&pdev->dev,
+			"Failed to register power supply %d\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static int max77843_charger_remove(struct platform_device *pdev)
+{
+	struct max77843_charger *charger = platform_get_drvdata(pdev);
+
+	power_supply_unregister(&charger->psy);
+
+	return 0;
+}
+
+static const struct platform_device_id max77843_charger_id[] = {
+	{ "max77843-charger", },
+	{ }
+};
+MODULE_DEVICE_TABLE(platform, max77843_charger_id);
+
+static struct platform_driver max77843_charger_driver = {
+	.driver = {
+		.name = "max77843-charger",
+	},
+	.probe = max77843_charger_probe,
+	.remove = max77843_charger_remove,
+	.id_table = max77843_charger_id,
+};
+module_platform_driver(max77843_charger_driver);
+
+MODULE_DESCRIPTION("Maxim MAX77843 charger driver");
+MODULE_AUTHOR("Beomho Seo <beomho.seo@samsung.com>");
+MODULE_LICENSE("GPL v2");
-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH v7 3/5] power: max77843_battery: Add Max77843 fuel gauge device driver
  2015-03-02 10:10 [PATCH v7 0/5] Add new MFD driver for MAX77843 Jaewon Kim
  2015-03-02 10:10 ` [PATCH v7 1/5] mfd: max77843: Add max77843 MFD driver core driver Jaewon Kim
  2015-03-02 10:10 ` [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver Jaewon Kim
@ 2015-03-02 10:10 ` Jaewon Kim
  2015-03-07 20:14   ` Sebastian Reichel
  2015-03-02 10:10 ` [PATCH v7 4/5] Input: add haptic drvier on max77843 Jaewon Kim
  2015-03-02 10:10 ` [PATCH v7 5/5] Documentation: Add device tree bindings document for max77843 Jaewon Kim
  4 siblings, 1 reply; 36+ messages in thread
From: Jaewon Kim @ 2015-03-02 10:10 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-pm, linux-input
  Cc: Inki Dae, SangBae Lee, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Lee Jones, Chanwoo Choi,
	Sebastian Reichel, Beomho Seo, Jaewon Kim, Dmitry Torokhov

From: Beomho Seo <beomho.seo@samsung.com>

This patch adds device driver of max77843 fuel gauge.
The driver support for battery fuel gauge in Maxim Max77843.
It is fuel-gauge systems for lithuum-ion batteries in handled and
portable devices.

Cc: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
---
 drivers/power/Kconfig            |    9 ++
 drivers/power/Makefile           |    1 +
 drivers/power/max77843_battery.c |  286 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 296 insertions(+)
 create mode 100644 drivers/power/max77843_battery.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 994793d..42538e6 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -212,6 +212,15 @@ config BATTERY_MAX17042
 	  with MAX17042. This driver also supports max17047/50 chips which are
 	  improved version of max17042.
 
+config BATTERY_MAX77843
+	tristate "Maxim MAX77843 Fuel Gauge"
+	depends on MFD_MAX77843
+	help
+	  This adds support for battery fuel gauge in Maxim MAX77843. It is
+	  fuel-gauge for a lithium-ion batteries with a single cell and can be
+	  found in portable devices. The MAX77843 is configured to operate with
+	  a single lithium cell.
+
 config BATTERY_Z2
 	tristate "Z2 battery driver"
 	depends on I2C && MACH_ZIPIT2
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index ed69cea..59e3945 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_BATTERY_DA9030)	+= da9030_battery.o
 obj-$(CONFIG_BATTERY_DA9052)	+= da9052-battery.o
 obj-$(CONFIG_BATTERY_MAX17040)	+= max17040_battery.o
 obj-$(CONFIG_BATTERY_MAX17042)	+= max17042_battery.o
+obj-$(CONFIG_BATTERY_MAX77843)	+= max77843_battery.o
 obj-$(CONFIG_BATTERY_Z2)	+= z2_battery.o
 obj-$(CONFIG_BATTERY_RT5033)	+= rt5033_battery.o
 obj-$(CONFIG_BATTERY_S3C_ADC)	+= s3c_adc_battery.o
diff --git a/drivers/power/max77843_battery.c b/drivers/power/max77843_battery.c
new file mode 100644
index 0000000..a4266de
--- /dev/null
+++ b/drivers/power/max77843_battery.c
@@ -0,0 +1,286 @@
+/*
+ * Fuel gauge driver for Maxim MAX77843
+ *
+ * Copyright (C) 2015 Samsung Electronics, Co., Ltd.
+ * Author: Beomho Seo <beomho.seo@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/power_supply.h>
+#include <linux/mfd/max77843-private.h>
+
+struct max77843_battery {
+	struct device		*dev;
+	struct max77843		*max77843;
+	struct i2c_client	*client;
+	struct regmap		*regmap;
+	struct power_supply	psy;
+};
+
+static int max77843_battery_get_capacity(struct max77843_battery *battery)
+{
+	struct regmap *regmap = battery->regmap;
+	int ret, val;
+	unsigned int reg_data;
+
+	ret = regmap_read(regmap, MAX77843_FG_REG_SOCREP, &reg_data);
+	if (ret) {
+		dev_err(battery->dev, "Failed to read fuelgauge register\n");
+		return ret;
+	}
+
+	val = reg_data >> 8;
+
+	return val;
+}
+
+static int max77843_battery_get_energy_prop(struct max77843_battery *battery,
+		enum power_supply_property psp)
+{
+	struct regmap *regmap = battery->regmap;
+	unsigned int reg;
+	int ret, val;
+	unsigned int reg_data;
+
+	switch (psp) {
+	case POWER_SUPPLY_PROP_ENERGY_FULL:
+		reg = MAX77843_FG_REG_FULLCAP;
+		break;
+	case POWER_SUPPLY_PROP_ENERGY_NOW:
+		reg = MAX77843_FG_REG_REMCAP_REP;
+		break;
+	case POWER_SUPPLY_PROP_ENERGY_AVG:
+		reg = MAX77843_FG_REG_REMCAP_AV;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	ret = regmap_read(regmap, reg, &reg_data);
+	if (ret) {
+		dev_err(battery->dev, "Failed to read fuelgauge register\n");
+		return ret;
+	}
+
+	val = reg_data;
+
+	return val;
+}
+
+static int max77843_battery_get_current_prop(struct max77843_battery *battery,
+		enum power_supply_property psp)
+{
+	struct regmap *regmap = battery->regmap;
+	unsigned int reg;
+	int ret, val;
+	unsigned int reg_data;
+
+	switch (psp) {
+	case POWER_SUPPLY_PROP_CURRENT_NOW:
+		reg = MAX77843_FG_REG_CURRENT;
+		break;
+	case POWER_SUPPLY_PROP_CURRENT_AVG:
+		reg = MAX77843_FG_REG_AVG_CURRENT;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	ret = regmap_read(regmap, reg, &reg_data);
+	if (ret) {
+		dev_err(battery->dev, "Failed to read fuelgauge register\n");
+		return ret;
+	}
+
+	val = reg_data;
+	if (val & 0x8000) {
+		/* Negative */
+		val = ~val & 0xffff;
+		val++;
+		val *= -1;
+	}
+	/* Unit of current is mA */
+	val =  val * 15625 / 100000;
+
+	return val;
+}
+
+static int max77843_battery_get_voltage_prop(struct max77843_battery *battery,
+		enum power_supply_property psp)
+{
+	struct regmap *regmap = battery->regmap;
+	unsigned int reg;
+	int ret, val;
+	unsigned int reg_data;
+
+	switch (psp) {
+	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+		reg = MAX77843_FG_REG_VCELL;
+		break;
+	case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+		reg = MAX77843_FG_REG_AVG_VCELL;
+		break;
+	case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+		reg = MAX77843_FG_REG_OCV;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	ret = regmap_read(regmap, reg, &reg_data);
+	if (ret) {
+		dev_err(battery->dev, "Failed to read fuelgauge register\n");
+		return ret;
+	}
+
+	val = (reg_data >> 4)  * 125;
+	val /= 100;
+
+	return val;
+}
+
+static const char *model_name = "MAX77843";
+static const char *manufacturer = "Maxim Integrated";
+
+static int max77843_battery_get_property(struct power_supply *psy,
+		enum power_supply_property psp,
+		union power_supply_propval *val)
+{
+	struct max77843_battery *battery = container_of(psy,
+				struct max77843_battery, psy);
+	switch (psp) {
+	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+	case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+	case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+		val->intval = max77843_battery_get_voltage_prop(battery, psp);
+		break;
+	case POWER_SUPPLY_PROP_CURRENT_NOW:
+	case POWER_SUPPLY_PROP_CURRENT_AVG:
+		val->intval = max77843_battery_get_current_prop(battery, psp);
+		break;
+	case POWER_SUPPLY_PROP_ENERGY_FULL:
+	case POWER_SUPPLY_PROP_ENERGY_NOW:
+	case POWER_SUPPLY_PROP_ENERGY_AVG:
+		val->intval = max77843_battery_get_energy_prop(battery, psp);
+		break;
+	case POWER_SUPPLY_PROP_CAPACITY:
+		val->intval = max77843_battery_get_capacity(battery);
+		break;
+	case POWER_SUPPLY_PROP_MODEL_NAME:
+		val->strval =  model_name;
+		break;
+	case POWER_SUPPLY_PROP_MANUFACTURER:
+		val->strval = manufacturer;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static enum power_supply_property max77843_battery_props[] = {
+	POWER_SUPPLY_PROP_VOLTAGE_NOW,
+	POWER_SUPPLY_PROP_VOLTAGE_AVG,
+	POWER_SUPPLY_PROP_VOLTAGE_OCV,
+	POWER_SUPPLY_PROP_CURRENT_NOW,
+	POWER_SUPPLY_PROP_CURRENT_AVG,
+	POWER_SUPPLY_PROP_ENERGY_FULL,
+	POWER_SUPPLY_PROP_ENERGY_NOW,
+	POWER_SUPPLY_PROP_ENERGY_AVG,
+	POWER_SUPPLY_PROP_CAPACITY,
+	POWER_SUPPLY_PROP_MODEL_NAME,
+	POWER_SUPPLY_PROP_MANUFACTURER,
+};
+
+static const struct regmap_config max77843_fuel_regmap_config = {
+	.reg_bits	= 8,
+	.val_bits	= 16,
+	.val_format_endian = REGMAP_ENDIAN_NATIVE,
+	.max_register	= MAX77843_FG_END,
+};
+
+static int max77843_battery_probe(struct platform_device *pdev)
+{
+	struct max77843 *max77843 = dev_get_drvdata(pdev->dev.parent);
+	struct max77843_battery *battery;
+	int ret;
+
+	battery = devm_kzalloc(&pdev->dev, sizeof(*battery), GFP_KERNEL);
+	if (!battery)
+		return -ENOMEM;
+
+	battery->dev = &pdev->dev;
+	battery->max77843 = max77843;
+
+	battery->client = i2c_new_dummy(max77843->i2c->adapter, I2C_ADDR_FG);
+	if (!battery->client) {
+		dev_err(&pdev->dev, "Failed to get dummy i2c client.\n");
+		return PTR_ERR(battery->client);
+	}
+	i2c_set_clientdata(battery->client, max77843);
+
+	battery->regmap = devm_regmap_init_i2c(battery->client,
+			&max77843_fuel_regmap_config);
+	if (IS_ERR(battery->regmap)) {
+		ret = PTR_ERR(battery->regmap);
+		goto err_i2c;
+	}
+
+	platform_set_drvdata(pdev, battery);
+
+	battery->psy.name	= "max77843-fuelgauge";
+	battery->psy.type	= POWER_SUPPLY_TYPE_BATTERY;
+	battery->psy.get_property	= max77843_battery_get_property;
+	battery->psy.properties		= max77843_battery_props;
+	battery->psy.num_properties	= ARRAY_SIZE(max77843_battery_props);
+
+	ret = power_supply_register(&pdev->dev, &battery->psy);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed  to register power supply\n");
+		goto err_i2c;
+	}
+
+	return 0;
+
+err_i2c:
+	i2c_unregister_device(battery->client);
+
+	return ret;
+}
+
+static int max77843_battery_remove(struct platform_device *pdev)
+{
+	struct max77843_battery *battery = platform_get_drvdata(pdev);
+
+	power_supply_unregister(&battery->psy);
+
+	i2c_unregister_device(battery->client);
+
+	return 0;
+}
+
+static const struct platform_device_id max77843_battery_id[] = {
+	{ "max77843-fuelgauge", },
+	{ }
+};
+MODULE_DEVICE_TABLE(platform, max77843_battery_id);
+
+static struct platform_driver max77843_battery_driver = {
+	.driver = {
+		.name = "max77843-fuelgauge",
+	},
+	.probe = max77843_battery_probe,
+	.remove = max77843_battery_remove,
+	.id_table = max77843_battery_id,
+};
+module_platform_driver(max77843_battery_driver);
+
+MODULE_DESCRIPTION("Maxim MAX77843 fuel gauge driver");
+MODULE_AUTHOR("Beomho Seo <beomho.seo@samsung.com>");
+MODULE_LICENSE("GPL v2");
-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH v7 4/5] Input: add haptic drvier on max77843
  2015-03-02 10:10 [PATCH v7 0/5] Add new MFD driver for MAX77843 Jaewon Kim
                   ` (2 preceding siblings ...)
  2015-03-02 10:10 ` [PATCH v7 3/5] power: max77843_battery: Add Max77843 fuel gauge " Jaewon Kim
@ 2015-03-02 10:10 ` Jaewon Kim
  2015-03-02 17:32   ` Dmitry Torokhov
  2015-03-02 10:10 ` [PATCH v7 5/5] Documentation: Add device tree bindings document for max77843 Jaewon Kim
  4 siblings, 1 reply; 36+ messages in thread
From: Jaewon Kim @ 2015-03-02 10:10 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-pm, linux-input
  Cc: Inki Dae, SangBae Lee, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Lee Jones, Chanwoo Choi,
	Sebastian Reichel, Beomho Seo, Jaewon Kim, Dmitry Torokhov

This patch adds support for haptic driver on max77843
MFD(Multi Function Device) with PMIC, MUIC, LED, CHARGER.

This driver supports external pwm and LRA(Linear Resonant Actuator) motor.
And it supports ff-memless interface from inpu framework.

Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com>
---
 drivers/input/misc/Kconfig           |   12 ++
 drivers/input/misc/Makefile          |    1 +
 drivers/input/misc/max77843-haptic.c |  358 ++++++++++++++++++++++++++++++++++
 3 files changed, 371 insertions(+)
 create mode 100644 drivers/input/misc/max77843-haptic.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 6deb8da..aa8c072 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -165,6 +165,18 @@ config INPUT_MAX77693_HAPTIC
 	  To compile this driver as module, choose M here: the
 	  module will be called max77693-haptic.
 
+config INPUT_MAX77843_HAPTIC
+    tristate "MAXIM MAX77843 haptic controller support"
+    depends on MFD_MAX77843 && PWM
+    select INPUT_FF_MEMLESS
+    help
+      This option enables support for the haptic controller on
+      MAXIM MAX77843 chip. The driver supports ff-memless interface
+      from input framework.
+
+      To compile this driver as module, choose M here: the
+      module will be called max77843-haptic.
+
 config INPUT_MAX8925_ONKEY
 	tristate "MAX8925 ONKEY support"
 	depends on MFD_MAX8925
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 403a1a5..75b5884 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_INPUT_KEYSPAN_REMOTE)	+= keyspan_remote.o
 obj-$(CONFIG_INPUT_KXTJ9)		+= kxtj9.o
 obj-$(CONFIG_INPUT_M68K_BEEP)		+= m68kspkr.o
 obj-$(CONFIG_INPUT_MAX77693_HAPTIC)	+= max77693-haptic.o
+obj-$(CONFIG_INPUT_MAX77843_HAPTIC)	+= max77843-haptic.o
 obj-$(CONFIG_INPUT_MAX8925_ONKEY)	+= max8925_onkey.o
 obj-$(CONFIG_INPUT_MAX8997_HAPTIC)	+= max8997_haptic.o
 obj-$(CONFIG_INPUT_MC13783_PWRBUTTON)	+= mc13783-pwrbutton.o
diff --git a/drivers/input/misc/max77843-haptic.c b/drivers/input/misc/max77843-haptic.c
new file mode 100644
index 0000000..eef9862
--- /dev/null
+++ b/drivers/input/misc/max77843-haptic.c
@@ -0,0 +1,358 @@
+/*
+ * MAXIM MAX77693 Haptic device driver
+ *
+ * Copyright (C) 2015 Samsung Electronics
+ * Author: Jaewon Kim <jaewon02.kim@samsung.com>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/mfd/max77843-private.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/pwm.h>
+#include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
+#include <linux/slab.h>
+#include <linux/workqueue.h>
+
+#define MAX_MAGNITUDE_SHIFT        16
+
+enum max77843_haptic_motor_type {
+	MAX77843_HAPTIC_ERM = 0,
+	MAX77843_HAPTIC_LRA,
+};
+
+enum max77843_haptic_pwm_divisor {
+	MAX77843_HAPTIC_PWM_DIVISOR_32 = 0,
+	MAX77843_HAPTIC_PWM_DIVISOR_64,
+	MAX77843_HAPTIC_PWM_DIVISOR_128,
+	MAX77843_HAPTIC_PWM_DIVISOR_256,
+};
+
+struct max77843_haptic {
+	struct regmap *regmap_haptic;
+	struct device *dev;
+	struct input_dev *input_dev;
+	struct pwm_device *pwm_dev;
+	struct regulator *motor_reg;
+	struct work_struct work;
+	struct mutex mutex;
+
+	unsigned int magnitude;
+	unsigned int pwm_duty;
+
+	bool active;
+	bool suspended;
+
+	enum max77843_haptic_motor_type type;
+	enum max77843_haptic_pwm_divisor pwm_divisor;
+};
+
+static int max77843_haptic_set_duty_cycle(struct max77843_haptic *haptic)
+{
+	int delta = (haptic->pwm_dev->period + haptic->pwm_duty) / 2;
+	int error;
+
+	error = pwm_config(haptic->pwm_dev, delta, haptic->pwm_dev->period);
+	if (error) {
+		dev_err(haptic->dev, "failed to configure pwm: %d\n", error);
+		return error;
+	}
+
+	return 0;
+}
+
+static int max77843_haptic_bias(struct max77843_haptic *haptic, bool on)
+{
+	int error;
+
+	error = regmap_update_bits(haptic->regmap_haptic,
+			MAX77843_SYS_REG_MAINCTRL1,
+			MAX77843_MAINCTRL1_BIASEN_MASK,
+			on << MAINCTRL1_BIASEN_SHIFT);
+	if (error) {
+		dev_err(haptic->dev, "failed to %s bias: %d\n",
+			on ? "enable" : "disable", error);
+		return error;
+	}
+
+	return 0;
+}
+
+static int max77843_haptic_config(struct max77843_haptic *haptic, bool enable)
+{
+	unsigned int value;
+	int error;
+
+	value = ((haptic->type << MCONFIG_MODE_SHIFT) |
+		(enable << MCONFIG_MEN_SHIFT) |
+		(haptic->pwm_divisor << MCONFIG_PDIV_SHIFT));
+
+	error = regmap_write(haptic->regmap_haptic,
+			MAX77843_HAP_REG_MCONFIG, value);
+	if (error) {
+		dev_err(haptic->dev,
+			"failed to update haptic config: %d\n", error);
+		return error;
+	}
+
+	return 0;
+}
+
+static int max77843_haptic_enable(struct max77843_haptic *haptic)
+{
+	int error;
+
+	if (haptic->active)
+		return 0;
+
+	error = pwm_enable(haptic->pwm_dev);
+	if (error) {
+		dev_err(haptic->dev,
+			"failed to enable pwm device: %d\n", error);
+		return error;
+	}
+
+	error = max77843_haptic_config(haptic, true);
+	if (error)
+		goto err_config;
+
+	haptic->active = true;
+
+	return 0;
+
+err_config:
+	pwm_disable(haptic->pwm_dev);
+
+	return error;
+}
+
+static int max77843_haptic_disable(struct max77843_haptic *haptic)
+{
+	int error;
+
+	if (!haptic->active)
+		return 0;
+
+	error = max77843_haptic_config(haptic, false);
+	if (error)
+		return error;
+
+	pwm_disable(haptic->pwm_dev);
+
+	haptic->active = false;
+
+	return 0;
+}
+
+static void max77843_haptic_play_work(struct work_struct *work)
+{
+	struct max77843_haptic *haptic =
+			container_of(work, struct max77843_haptic, work);
+	int error;
+
+	mutex_lock(&haptic->mutex);
+
+	if (haptic->suspended)
+		goto out_unlock;
+
+	if (haptic->magnitude) {
+		error = max77843_haptic_set_duty_cycle(haptic);
+		if (error) {
+			dev_err(haptic->dev,
+				"failed to set duty cycle: %d\n", error);
+			goto out_unlock;
+		}
+
+		error = max77843_haptic_enable(haptic);
+		if (error)
+			dev_err(haptic->dev,
+				"cannot enable haptic: %d\n", error);
+	} else {
+		error = max77843_haptic_disable(haptic);
+		if (error)
+			dev_err(haptic->dev,
+				"cannot disable haptic: %d\n", error);
+	}
+
+out_unlock:
+	mutex_unlock(&haptic->mutex);
+}
+
+static int max77843_haptic_play_effect(struct input_dev *dev, void *data,
+		struct ff_effect *effect)
+{
+	struct max77843_haptic *haptic = input_get_drvdata(dev);
+	u64 period_mag_multi;
+
+	haptic->magnitude = effect->u.rumble.strong_magnitude;
+	if (!haptic->magnitude)
+		haptic->magnitude = effect->u.rumble.weak_magnitude;
+
+	period_mag_multi = (u64)haptic->pwm_dev->period * haptic->magnitude;
+	haptic->pwm_duty = (unsigned int)(period_mag_multi >>
+				MAX_MAGNITUDE_SHIFT);
+
+	schedule_work(&haptic->work);
+
+	return 0;
+}
+
+static int max77843_haptic_open(struct input_dev *dev)
+{
+	struct max77843_haptic *haptic = input_get_drvdata(dev);
+	int error;
+
+	error = max77843_haptic_bias(haptic, true);
+	if (error)
+		return error;
+
+	error = regulator_enable(haptic->motor_reg);
+	if (error) {
+		dev_err(haptic->dev,
+			"failed to enable regulator: %d\n", error);
+		return error;
+	}
+
+	return 0;
+}
+
+static void max77843_haptic_close(struct input_dev *dev)
+{
+	struct max77843_haptic *haptic = input_get_drvdata(dev);
+	int error;
+
+	cancel_work_sync(&haptic->work);
+	max77843_haptic_disable(haptic);
+
+	error = regulator_disable(haptic->motor_reg);
+	if (error)
+		dev_err(haptic->dev,
+			"failed to disable regulator: %d\n", error);
+
+	max77843_haptic_bias(haptic, false);
+}
+
+static int max77843_haptic_probe(struct platform_device *pdev)
+{
+	struct max77843 *max77843 = dev_get_drvdata(pdev->dev.parent);
+	struct max77843_haptic *haptic;
+	int error;
+
+	haptic = devm_kzalloc(&pdev->dev, sizeof(*haptic), GFP_KERNEL);
+	if (!haptic)
+		return -ENOMEM;
+
+	haptic->regmap_haptic = max77843->regmap;
+	haptic->dev = &pdev->dev;
+	haptic->type = MAX77843_HAPTIC_LRA;
+	haptic->pwm_divisor = MAX77843_HAPTIC_PWM_DIVISOR_128;
+
+	INIT_WORK(&haptic->work, max77843_haptic_play_work);
+	mutex_init(&haptic->mutex);
+
+	haptic->pwm_dev = devm_pwm_get(&pdev->dev, NULL);
+	if (IS_ERR(haptic->pwm_dev)) {
+		dev_err(&pdev->dev, "failed to get pwm device\n");
+		return PTR_ERR(haptic->pwm_dev);
+	}
+
+	haptic->motor_reg = devm_regulator_get_exclusive(&pdev->dev, "haptic");
+	if (IS_ERR(haptic->motor_reg)) {
+		dev_err(&pdev->dev, "failed to get regulator\n");
+		return PTR_ERR(haptic->motor_reg);
+	}
+
+	haptic->input_dev = devm_input_allocate_device(&pdev->dev);
+	if (!haptic->input_dev) {
+		dev_err(&pdev->dev, "failed to allocate input device\n");
+		return -ENOMEM;
+	}
+
+	haptic->input_dev->name = "max77843-haptic";
+	haptic->input_dev->id.version = 1;
+	haptic->input_dev->dev.parent = &pdev->dev;
+	haptic->input_dev->open = max77843_haptic_open;
+	haptic->input_dev->close = max77843_haptic_close;
+	input_set_drvdata(haptic->input_dev, haptic);
+	input_set_capability(haptic->input_dev, EV_FF, FF_RUMBLE);
+
+	error = input_ff_create_memless(haptic->input_dev, NULL,
+			max77843_haptic_play_effect);
+	if (error) {
+		dev_err(&pdev->dev, "failed to create force-feedback\n");
+		return error;
+	}
+
+	error = input_register_device(haptic->input_dev);
+	if (error) {
+		dev_err(&pdev->dev, "failed to register input device\n");
+		return error;
+	}
+
+	platform_set_drvdata(pdev, haptic);
+
+	return 0;
+}
+
+static int __maybe_unused max77843_haptic_suspend(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct max77843_haptic *haptic = platform_get_drvdata(pdev);
+	int error;
+
+	error = mutex_lock_interruptible(&haptic->mutex);
+	if (error)
+		return error;
+
+	max77843_haptic_disable(haptic);
+
+	haptic->suspended = true;
+
+	mutex_unlock(&haptic->mutex);
+
+	return 0;
+}
+
+static int __maybe_unused max77843_haptic_resume(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct max77843_haptic *haptic = platform_get_drvdata(pdev);
+	unsigned int magnitude;
+
+	mutex_lock(&haptic->mutex);
+
+	haptic->suspended = false;
+
+	magnitude = ACCESS_ONCE(haptic->magnitude);
+	if (magnitude)
+		max77843_haptic_enable(haptic);
+
+	mutex_unlock(&haptic->mutex);
+
+	return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(max77843_haptic_pm_ops,
+		max77843_haptic_suspend, max77843_haptic_resume);
+
+static struct platform_driver max77843_haptic_driver = {
+	.driver		= {
+		.name	= "max77843-haptic",
+		.pm	= &max77843_haptic_pm_ops,
+	},
+	.probe		= max77843_haptic_probe,
+};
+module_platform_driver(max77843_haptic_driver);
+
+MODULE_AUTHOR("Jaewon Kim <jaewon02.kim@samsung.com>");
+MODULE_DESCRIPTION("MAXIM MAX77843 Haptic driver");
+MODULE_LICENSE("GPL");
-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH v7 5/5] Documentation: Add device tree bindings document for max77843
  2015-03-02 10:10 [PATCH v7 0/5] Add new MFD driver for MAX77843 Jaewon Kim
                   ` (3 preceding siblings ...)
  2015-03-02 10:10 ` [PATCH v7 4/5] Input: add haptic drvier on max77843 Jaewon Kim
@ 2015-03-02 10:10 ` Jaewon Kim
  4 siblings, 0 replies; 36+ messages in thread
From: Jaewon Kim @ 2015-03-02 10:10 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-pm, linux-input
  Cc: Inki Dae, SangBae Lee, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Lee Jones, Chanwoo Choi,
	Sebastian Reichel, Beomho Seo, Jaewon Kim, Dmitry Torokhov

Add document describing device tree bindings for max77843 MFD.
Drivers: MFD core, regulator, extcon, charger and fuelgauge.

Cc: Rob Herring <robh+dt@kernel.org>
Cc: Pawel Moll <pawel.moll@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Ian Campbell <ijc+devicetree@hellion.org.uk>
Cc: Kumar Gala <galak@codeaurora.org>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com>
Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
---
 Documentation/devicetree/bindings/mfd/max77843.txt |  110 ++++++++++++++++++++
 1 file changed, 110 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/max77843.txt

diff --git a/Documentation/devicetree/bindings/mfd/max77843.txt b/Documentation/devicetree/bindings/mfd/max77843.txt
new file mode 100644
index 0000000..76426ca
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/max77843.txt
@@ -0,0 +1,110 @@
+Maxim MAX77843 multi-function device
+
+MAX77843 is a Multi-Function Device with the following submodules:
+- PMIC	  : 2 SAFEOUT LDOs for USB device
+- CHARGER : Li+ battery charger with Fuel Gauge
+- MUIC	  : Micro USB Interface Controller
+- HAPTIC  : Motor Controller for tactile feedback
+
+It is interfaced to host controller using I2C.
+
+Required properties:
+- compatible : Must be "maxim,max77843".
+- reg : I2C slave address of PMIC block.
+- interrupts : I2C line for main SoCs.
+- interrupt-parent : The parent of interrupt controller.
+
+Optional properties:
+- regulators : The regulators of max77843 have to be instantiated under subnode
+	named "regulators" using the following format.
+
+	[*]refer : Documentation/devicetree/bindings/regulator/regulator.txt
+
+	regulators {
+		SAFEOUT {
+			regulator-name = "SAFEOUT";
+		};
+	}
+
+	List of valid regulator names:
+	- SAFEOUT1, SAFEOUT2, CHARGER.
+
+- max77843-muic : This properties used by extcon consumers.
+	Required properties:
+		- compatible : Must be "maxim,max77842-muic".
+
+- max77843-charger : There battery charger of MAX77843 have to be instantiated
+	under sub-node named "max77843-charger" using the following format.
+	Required properties:
+		- compatible : Must be "maxim,max77842-charger".
+		- maxim,fast-charge-uamp : Fast charge current levels are
+			100 mA to 3150 mA programmed by I2C per 100 mA.
+		- maxim,top-off-uamp : Top off current threshold levels are
+			125 mA to 650 mA programmed by I2C per 75 mA.
+		- maxim,input-uamp-limit : Input current limit levels are
+			100 mA to 3533 mA programmed by I2C per 33 mA.
+
+- max77843-fuelgauge : There fuelgauge of MAX77843 have to be instantiated
+	under sub-node named "max77843-fuelgauge" using the following format.
+	Required properties:
+		- compatible : Must be "maxim,max77842-fuelgauge".
+
+- max77843-haptic : The MAX77843 haptic device provides the tactile feedback
+	to the user by using PWM(Pulse Width Modulation) signal.
+	Required properties:
+		- compatible : Must be "maxim,max77843-hpatic".
+		- haptic-supply : Power supply for the haptic motor.
+			[*] refer Documentation/devicetree/
+					bindings/regulator/regulator.txt
+		- pwms : phandle for the PWM(Pulse Width Modulation) device.
+			PWM properties should be named "pwms".
+			[*] refer Documentation/devicetree/bindings/pwm/pwm.txt
+
+Example:
+	max77843@66 {
+		compatible = "samsung,max77843";
+		reg = <0x66>;
+		interrupt-parent = <&gpa1>;
+		interrupts = <5 2>;
+
+		regulators {
+			SAFEOUT1 {
+				regulator-name = "SAFEOUT1";
+				regulator-min-microvolt = <3300000>;
+				regulator-max-microvolt = <4950000>;
+			};
+			SAFEOUT2 {
+				regulator-name = "SAFEOUT2";
+				regulator-min-microvolt = <3300000>;
+				regulator-max-microvolt = <4950000>;
+			};
+			CHARGER {
+				regulator-name = "CHARGER";
+				regulator-min-microamp = <100000>;
+				regulator-max-microamp = <3150000>;
+			};
+		};
+
+		haptic {
+			compatible = "maxim,max77843-haptic";
+			haptic-supply = <&haptic_supply>;
+			pwms = <&pwm 0 40000 0>;
+			pwm-names = "haptic";
+		};
+
+		max77843-muic {
+			compatible = "maxim,max77843-muic";
+		};
+
+		max77843-charger {
+			compatible = "maxim,max77843-charger";
+			maxim,fast-charge-uamp = <450000>;
+			maxim,top-off-uamp = <125000>;
+			maxim,input-uamp-limit = <500000>;
+		};
+
+		max77843-fuelgauge {
+			compatible = "maxim,max77843-fuelgauge";
+		};
+
+	};
-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 1/5] mfd: max77843: Add max77843 MFD driver core driver
  2015-03-02 10:10 ` [PATCH v7 1/5] mfd: max77843: Add max77843 MFD driver core driver Jaewon Kim
@ 2015-03-02 10:20   ` Lee Jones
  2015-03-02 10:36     ` Jaewon Kim
  2015-03-02 10:41   ` Lee Jones
  1 sibling, 1 reply; 36+ messages in thread
From: Lee Jones @ 2015-03-02 10:20 UTC (permalink / raw)
  To: Jaewon Kim
  Cc: linux-kernel, devicetree, linux-pm, linux-input, Inki Dae,
	SangBae Lee, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, Chanwoo Choi, Sebastian Reichel, Beomho Seo,
	Dmitry Torokhov

On Mon, 02 Mar 2015, Jaewon Kim wrote:

> This patch adds MAX77843 core/irq driver to support PMIC,
> MUIC(Micro USB Interface Controller), Charger, Fuel Gauge,
> LED and Haptic device.
> 
> Cc: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com>
> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
> ---
>  drivers/mfd/Kconfig                  |   14 ++
>  drivers/mfd/Makefile                 |    1 +
>  drivers/mfd/max77843.c               |  243 ++++++++++++++++++
>  include/linux/mfd/max77843-private.h |  454 ++++++++++++++++++++++++++++++++++
>  4 files changed, 712 insertions(+)
>  create mode 100644 drivers/mfd/max77843.c
>  create mode 100644 include/linux/mfd/max77843-private.h

If you have dealt with my previous review comments:

Acked-by: Lee Jones <lee.jones@linaro.org>

Which other Acks are you waiting for? 

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 1/5] mfd: max77843: Add max77843 MFD driver core driver
  2015-03-02 10:20   ` Lee Jones
@ 2015-03-02 10:36     ` Jaewon Kim
  0 siblings, 0 replies; 36+ messages in thread
From: Jaewon Kim @ 2015-03-02 10:36 UTC (permalink / raw)
  To: Lee Jones
  Cc: linux-kernel, devicetree, linux-pm, linux-input, Inki Dae,
	SangBae Lee, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, Chanwoo Choi, Sebastian Reichel, Beomho Seo,
	Dmitry Torokhov

Hi Lee Jones,

On 02/03/2015 19:20, Lee Jones wrote:
> On Mon, 02 Mar 2015, Jaewon Kim wrote:
>
>> This patch adds MAX77843 core/irq driver to support PMIC,
>> MUIC(Micro USB Interface Controller), Charger, Fuel Gauge,
>> LED and Haptic device.
>>
>> Cc: Lee Jones <lee.jones@linaro.org>
>> Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com>
>> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
>> ---
>>   drivers/mfd/Kconfig                  |   14 ++
>>   drivers/mfd/Makefile                 |    1 +
>>   drivers/mfd/max77843.c               |  243 ++++++++++++++++++
>>   include/linux/mfd/max77843-private.h |  454 ++++++++++++++++++++++++++++++++++
>>   4 files changed, 712 insertions(+)
>>   create mode 100644 drivers/mfd/max77843.c
>>   create mode 100644 include/linux/mfd/max77843-private.h
> If you have dealt with my previous review comments:
>
> Acked-by: Lee Jones <lee.jones@linaro.org>
>
> Which other Acks are you waiting for?
>

There is no dependency with other patchs.
Plz merge it first.

Thanks,
Jaewon Kim


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 1/5] mfd: max77843: Add max77843 MFD driver core driver
  2015-03-02 10:10 ` [PATCH v7 1/5] mfd: max77843: Add max77843 MFD driver core driver Jaewon Kim
  2015-03-02 10:20   ` Lee Jones
@ 2015-03-02 10:41   ` Lee Jones
  1 sibling, 0 replies; 36+ messages in thread
From: Lee Jones @ 2015-03-02 10:41 UTC (permalink / raw)
  To: Jaewon Kim
  Cc: linux-kernel, devicetree, linux-pm, linux-input, Inki Dae,
	SangBae Lee, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, Chanwoo Choi, Sebastian Reichel, Beomho Seo,
	Dmitry Torokhov

On Mon, 02 Mar 2015, Jaewon Kim wrote:

> This patch adds MAX77843 core/irq driver to support PMIC,
> MUIC(Micro USB Interface Controller), Charger, Fuel Gauge,
> LED and Haptic device.
> 
> Cc: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com>
> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
> ---
>  drivers/mfd/Kconfig                  |   14 ++
>  drivers/mfd/Makefile                 |    1 +
>  drivers/mfd/max77843.c               |  243 ++++++++++++++++++
>  include/linux/mfd/max77843-private.h |  454 ++++++++++++++++++++++++++++++++++
>  4 files changed, 712 insertions(+)
>  create mode 100644 drivers/mfd/max77843.c
>  create mode 100644 include/linux/mfd/max77843-private.h

Applied, thanks.

> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index 38356e3..f2fd5e5 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -455,6 +455,20 @@ config MFD_MAX77693
>  	  additional drivers must be enabled in order to use the functionality
>  	  of the device.
>  
> +config MFD_MAX77843
> +	bool "Maxim Semiconductor MAX77843 PMIC Support"
> +	depends on I2C=y
> +	select MFD_CORE
> +	select REGMAP_I2C
> +	select REGMAP_IRQ
> +	help
> +	  Say yes here to add support for Maxim Semiconductor MAX77843.
> +	  This is companion Power Management IC with LEDs, Haptic, Charger,
> +	  Fuel Gauge, MUIC(Micro USB Interface Controller) controls on chip.
> +	  This driver provides common support for accessing the device;
> +	  additional drivers must be enabled in order to use the functionality
> +	  of the device.
> +
>  config MFD_MAX8907
>  	tristate "Maxim Semiconductor MAX8907 PMIC Support"
>  	select MFD_CORE
> diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> index 19f3d74..b8ac555 100644
> --- a/drivers/mfd/Makefile
> +++ b/drivers/mfd/Makefile
> @@ -117,6 +117,7 @@ obj-$(CONFIG_MFD_DA9150)	+= da9150-core.o
>  obj-$(CONFIG_MFD_MAX14577)	+= max14577.o
>  obj-$(CONFIG_MFD_MAX77686)	+= max77686.o
>  obj-$(CONFIG_MFD_MAX77693)	+= max77693.o
> +obj-$(CONFIG_MFD_MAX77843)	+= max77843.o
>  obj-$(CONFIG_MFD_MAX8907)	+= max8907.o
>  max8925-objs			:= max8925-core.o max8925-i2c.o
>  obj-$(CONFIG_MFD_MAX8925)	+= max8925.o
> diff --git a/drivers/mfd/max77843.c b/drivers/mfd/max77843.c
> new file mode 100644
> index 0000000..a354ac6
> --- /dev/null
> +++ b/drivers/mfd/max77843.c
> @@ -0,0 +1,243 @@
> +/*
> + * MFD core driver for the Maxim MAX77843
> + *
> + * Copyright (C) 2015 Samsung Electronics
> + * Author: Jaewon Kim <jaewon02.kim@samsung.com>
> + * Author: Beomho Seo <beomho.seo@samsung.com>
> + *
> + * 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
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +
> +#include <linux/err.h>
> +#include <linux/i2c.h>
> +#include <linux/init.h>
> +#include <linux/interrupt.h>
> +#include <linux/module.h>
> +#include <linux/mfd/core.h>
> +#include <linux/mfd/max77843-private.h>
> +#include <linux/of_device.h>
> +#include <linux/platform_device.h>
> +
> +static const struct mfd_cell max77843_devs[] = {
> +	{
> +		.name = "max77843-muic",
> +		.of_compatible = "maxim,max77843-muic",
> +	}, {
> +		.name = "max77843-regulator",
> +		.of_compatible = "maxim,max77843-regulator",
> +	}, {
> +		.name = "max77843-charger",
> +		.of_compatible = "maxim,max77843-charger"
> +	}, {
> +		.name = "max77843-fuelgauge",
> +		.of_compatible = "maxim,max77843-fuelgauge",
> +	}, {
> +		.name = "max77843-haptic",
> +		.of_compatible = "maxim,max77843-haptic",
> +	},
> +};
> +
> +static const struct regmap_config max77843_charger_regmap_config = {
> +	.reg_bits	= 8,
> +	.val_bits	= 8,
> +	.max_register	= MAX77843_CHG_REG_END,
> +};
> +
> +static const struct regmap_config max77843_regmap_config = {
> +	.reg_bits	= 8,
> +	.val_bits	= 8,
> +	.max_register	= MAX77843_SYS_REG_END,
> +};
> +
> +static const struct regmap_irq max77843_irqs[] = {
> +	/* TOPSYS interrupts */
> +	{ .reg_offset = 0, .mask = MAX77843_SYS_IRQ_SYSUVLO_INT, },
> +	{ .reg_offset = 0, .mask = MAX77843_SYS_IRQ_SYSOVLO_INT, },
> +	{ .reg_offset = 0, .mask = MAX77843_SYS_IRQ_TSHDN_INT, },
> +	{ .reg_offset = 0, .mask = MAX77843_SYS_IRQ_TM_INT, },
> +};
> +
> +static const struct regmap_irq_chip max77843_irq_chip = {
> +	.name		= "max77843",
> +	.status_base	= MAX77843_SYS_REG_SYSINTSRC,
> +	.mask_base	= MAX77843_SYS_REG_SYSINTMASK,
> +	.mask_invert	= false,
> +	.num_regs	= 1,
> +	.irqs		= max77843_irqs,
> +	.num_irqs	= ARRAY_SIZE(max77843_irqs),
> +};
> +
> +/* Charger and Charger regulator use same regmap. */
> +static int max77843_chg_init(struct max77843 *max77843)
> +{
> +	int ret;
> +
> +	max77843->i2c_chg = i2c_new_dummy(max77843->i2c->adapter, I2C_ADDR_CHG);
> +	if (!max77843->i2c_chg) {
> +		dev_err(&max77843->i2c->dev,
> +				"Cannot allocate I2C device for Charger\n");
> +		return PTR_ERR(max77843->i2c_chg);
> +	}
> +	i2c_set_clientdata(max77843->i2c_chg, max77843);
> +
> +	max77843->regmap_chg = devm_regmap_init_i2c(max77843->i2c_chg,
> +			&max77843_charger_regmap_config);
> +	if (IS_ERR(max77843->regmap_chg)) {
> +		ret = PTR_ERR(max77843->regmap_chg);
> +		goto err_chg_i2c;
> +	}
> +
> +	return 0;
> +
> +err_chg_i2c:
> +	i2c_unregister_device(max77843->i2c_chg);
> +
> +	return ret;
> +}
> +
> +static int max77843_probe(struct i2c_client *i2c,
> +			  const struct i2c_device_id *id)
> +{
> +	struct max77843 *max77843;
> +	unsigned int reg_data;
> +	int ret;
> +
> +	max77843 = devm_kzalloc(&i2c->dev, sizeof(*max77843), GFP_KERNEL);
> +	if (!max77843)
> +		return -ENOMEM;
> +
> +	i2c_set_clientdata(i2c, max77843);
> +	max77843->dev = &i2c->dev;
> +	max77843->i2c = i2c;
> +	max77843->irq = i2c->irq;
> +
> +	max77843->regmap = devm_regmap_init_i2c(i2c,
> +			&max77843_regmap_config);
> +	if (IS_ERR(max77843->regmap)) {
> +		dev_err(&i2c->dev, "Failed to allocate topsys register map\n");
> +		return PTR_ERR(max77843->regmap);
> +	}
> +
> +	ret = regmap_add_irq_chip(max77843->regmap, max77843->irq,
> +			IRQF_TRIGGER_LOW | IRQF_ONESHOT | IRQF_SHARED,
> +			0, &max77843_irq_chip, &max77843->irq_data);
> +	if (ret) {
> +		dev_err(&i2c->dev, "Failed to add TOPSYS IRQ chip\n");
> +		return ret;
> +	}
> +
> +	ret = regmap_read(max77843->regmap,
> +			MAX77843_SYS_REG_PMICID, &reg_data);
> +	if (ret < 0) {
> +		dev_err(&i2c->dev, "Failed to read PMIC ID\n");
> +		goto err_pmic_id;
> +	}
> +	dev_info(&i2c->dev, "device ID: 0x%x\n", reg_data);
> +
> +	ret = max77843_chg_init(max77843);
> +	if (ret) {
> +		dev_err(&i2c->dev, "Failed to init Charger\n");
> +		goto err_pmic_id;
> +	}
> +
> +	ret = regmap_update_bits(max77843->regmap,
> +				 MAX77843_SYS_REG_INTSRCMASK,
> +				 MAX77843_INTSRC_MASK_MASK,
> +				 (unsigned int)~MAX77843_INTSRC_MASK_MASK);
> +	if (ret < 0) {
> +		dev_err(&i2c->dev, "Failed to unmask interrupt source\n");
> +		goto err_pmic_id;
> +	}
> +
> +	ret = mfd_add_devices(max77843->dev, -1, max77843_devs,
> +			      ARRAY_SIZE(max77843_devs), NULL, 0, NULL);
> +	if (ret < 0) {
> +		dev_err(&i2c->dev, "Failed to add mfd device\n");
> +		goto err_pmic_id;
> +	}
> +
> +	device_init_wakeup(max77843->dev, true);
> +
> +	return 0;
> +
> +err_pmic_id:
> +	regmap_del_irq_chip(max77843->irq, max77843->irq_data);
> +
> +	return ret;
> +}
> +
> +static int max77843_remove(struct i2c_client *i2c)
> +{
> +	struct max77843 *max77843 = i2c_get_clientdata(i2c);
> +
> +	mfd_remove_devices(max77843->dev);
> +
> +	regmap_del_irq_chip(max77843->irq, max77843->irq_data);
> +
> +	i2c_unregister_device(max77843->i2c_chg);
> +
> +	return 0;
> +}
> +
> +static const struct of_device_id max77843_dt_match[] = {
> +	{ .compatible = "maxim,max77843", },
> +	{ },
> +};
> +
> +static const struct i2c_device_id max77843_id[] = {
> +	{ "max77843", },
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(i2c, max77843_id);
> +
> +static int __maybe_unused max77843_suspend(struct device *dev)
> +{
> +	struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
> +	struct max77843 *max77843 = i2c_get_clientdata(i2c);
> +
> +	disable_irq(max77843->irq);
> +	if (device_may_wakeup(dev))
> +		enable_irq_wake(max77843->irq);
> +
> +	return 0;
> +}
> +
> +static int __maybe_unused max77843_resume(struct device *dev)
> +{
> +	struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
> +	struct max77843 *max77843 = i2c_get_clientdata(i2c);
> +
> +	if (device_may_wakeup(dev))
> +		disable_irq_wake(max77843->irq);
> +	enable_irq(max77843->irq);
> +
> +	return 0;
> +}
> +
> +static SIMPLE_DEV_PM_OPS(max77843_pm, max77843_suspend, max77843_resume);
> +
> +static struct i2c_driver max77843_i2c_driver = {
> +	.driver	= {
> +		.name = "max77843",
> +		.pm = &max77843_pm,
> +		.of_match_table = max77843_dt_match,
> +	},
> +	.probe = max77843_probe,
> +	.remove = max77843_remove,
> +	.id_table = max77843_id,
> +};
> +
> +static int __init max77843_i2c_init(void)
> +{
> +	return i2c_add_driver(&max77843_i2c_driver);
> +}
> +subsys_initcall(max77843_i2c_init);
> +
> +static void __exit max77843_i2c_exit(void)
> +{
> +	i2c_del_driver(&max77843_i2c_driver);
> +}
> +module_exit(max77843_i2c_exit);
> diff --git a/include/linux/mfd/max77843-private.h b/include/linux/mfd/max77843-private.h
> new file mode 100644
> index 0000000..7178ace
> --- /dev/null
> +++ b/include/linux/mfd/max77843-private.h
> @@ -0,0 +1,454 @@
> +/*
> + * Common variables for the Maxim MAX77843 driver
> + *
> + * Copyright (C) 2015 Samsung Electronics
> + * Author: Jaewon Kim <jaewon02.kim@samsung.com>
> + * Author: Beomho Seo <beomho.seo@samsung.com>
> + *
> + * 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
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +
> +#ifndef __MAX77843_PRIVATE_H_
> +#define __MAX77843_PRIVATE_H_
> +
> +#include <linux/i2c.h>
> +#include <linux/regmap.h>
> +
> +#define I2C_ADDR_TOPSYS	(0xCC >> 1)
> +#define I2C_ADDR_CHG	(0xD2 >> 1)
> +#define I2C_ADDR_FG	(0x6C >> 1)
> +#define I2C_ADDR_MUIC	(0x4A >> 1)
> +
> +/* Topsys, Haptic and LED registers */
> +enum max77843_sys_reg {
> +	MAX77843_SYS_REG_PMICID		= 0x00,
> +	MAX77843_SYS_REG_PMICREV	= 0x01,
> +	MAX77843_SYS_REG_MAINCTRL1	= 0x02,
> +	MAX77843_SYS_REG_INTSRC		= 0x22,
> +	MAX77843_SYS_REG_INTSRCMASK	= 0x23,
> +	MAX77843_SYS_REG_SYSINTSRC	= 0x24,
> +	MAX77843_SYS_REG_SYSINTMASK	= 0x26,
> +	MAX77843_SYS_REG_TOPSYS_STAT	= 0x28,
> +	MAX77843_SYS_REG_SAFEOUTCTRL	= 0xC6,
> +
> +	MAX77843_SYS_REG_END,
> +};
> +
> +enum max77843_haptic_reg {
> +	MAX77843_HAP_REG_MCONFIG	= 0x10,
> +
> +	MAX77843_HAP_REG_END,
> +};
> +
> +enum max77843_led_reg {
> +	MAX77843_LED_REG_LEDEN		= 0x30,
> +	MAX77843_LED_REG_LED0BRT	= 0x31,
> +	MAX77843_LED_REG_LED1BRT	= 0x32,
> +	MAX77843_LED_REG_LED2BRT	= 0x33,
> +	MAX77843_LED_REG_LED3BRT	= 0x34,
> +	MAX77843_LED_REG_LEDBLNK	= 0x38,
> +	MAX77843_LED_REG_LEDRAMP	= 0x36,
> +
> +	MAX77843_LED_REG_END,
> +};
> +
> +/* Charger registers */
> +enum max77843_charger_reg {
> +	MAX77843_CHG_REG_CHG_INT	= 0xB0,
> +	MAX77843_CHG_REG_CHG_INT_MASK	= 0xB1,
> +	MAX77843_CHG_REG_CHG_INT_OK	= 0xB2,
> +	MAX77843_CHG_REG_CHG_DTLS_00	= 0xB3,
> +	MAX77843_CHG_REG_CHG_DTLS_01	= 0xB4,
> +	MAX77843_CHG_REG_CHG_DTLS_02	= 0xB5,
> +	MAX77843_CHG_REG_CHG_CNFG_00	= 0xB7,
> +	MAX77843_CHG_REG_CHG_CNFG_01	= 0xB8,
> +	MAX77843_CHG_REG_CHG_CNFG_02	= 0xB9,
> +	MAX77843_CHG_REG_CHG_CNFG_03	= 0xBA,
> +	MAX77843_CHG_REG_CHG_CNFG_04	= 0xBB,
> +	MAX77843_CHG_REG_CHG_CNFG_06	= 0xBD,
> +	MAX77843_CHG_REG_CHG_CNFG_07	= 0xBE,
> +	MAX77843_CHG_REG_CHG_CNFG_09	= 0xC0,
> +	MAX77843_CHG_REG_CHG_CNFG_10	= 0xC1,
> +	MAX77843_CHG_REG_CHG_CNFG_11	= 0xC2,
> +	MAX77843_CHG_REG_CHG_CNFG_12	= 0xC3,
> +
> +	MAX77843_CHG_REG_END,
> +};
> +
> +/* Fuel gauge registers */
> +enum max77843_fuelgauge {
> +	MAX77843_FG_REG_STATUS		= 0x00,
> +	MAX77843_FG_REG_VALRT_TH	= 0x01,
> +	MAX77843_FG_REG_TALRT_TH	= 0x02,
> +	MAX77843_FG_REG_SALRT_TH	= 0x03,
> +	MAX77843_FG_RATE_AT_RATE	= 0x04,
> +	MAX77843_FG_REG_REMCAP_REP	= 0x05,
> +	MAX77843_FG_REG_SOCREP		= 0x06,
> +	MAX77843_FG_REG_AGE		= 0x07,
> +	MAX77843_FG_REG_TEMP		= 0x08,
> +	MAX77843_FG_REG_VCELL		= 0x09,
> +	MAX77843_FG_REG_CURRENT		= 0x0A,
> +	MAX77843_FG_REG_AVG_CURRENT	= 0x0B,
> +	MAX77843_FG_REG_SOCMIX		= 0x0D,
> +	MAX77843_FG_REG_SOCAV		= 0x0E,
> +	MAX77843_FG_REG_REMCAP_MIX	= 0x0F,
> +	MAX77843_FG_REG_FULLCAP		= 0x10,
> +	MAX77843_FG_REG_AVG_TEMP	= 0x16,
> +	MAX77843_FG_REG_CYCLES		= 0x17,
> +	MAX77843_FG_REG_AVG_VCELL	= 0x19,
> +	MAX77843_FG_REG_CONFIG		= 0x1D,
> +	MAX77843_FG_REG_REMCAP_AV	= 0x1F,
> +	MAX77843_FG_REG_FULLCAP_NOM	= 0x23,
> +	MAX77843_FG_REG_MISCCFG		= 0x2B,
> +	MAX77843_FG_REG_RCOMP		= 0x38,
> +	MAX77843_FG_REG_FSTAT		= 0x3D,
> +	MAX77843_FG_REG_DQACC		= 0x45,
> +	MAX77843_FG_REG_DPACC		= 0x46,
> +	MAX77843_FG_REG_OCV		= 0xEE,
> +	MAX77843_FG_REG_VFOCV		= 0xFB,
> +	MAX77843_FG_SOCVF		= 0xFF,
> +
> +	MAX77843_FG_END,
> +};
> +
> +/* MUIC registers */
> +enum max77843_muic_reg {
> +	MAX77843_MUIC_REG_ID		= 0x00,
> +	MAX77843_MUIC_REG_INT1		= 0x01,
> +	MAX77843_MUIC_REG_INT2		= 0x02,
> +	MAX77843_MUIC_REG_INT3		= 0x03,
> +	MAX77843_MUIC_REG_STATUS1	= 0x04,
> +	MAX77843_MUIC_REG_STATUS2	= 0x05,
> +	MAX77843_MUIC_REG_STATUS3	= 0x06,
> +	MAX77843_MUIC_REG_INTMASK1	= 0x07,
> +	MAX77843_MUIC_REG_INTMASK2	= 0x08,
> +	MAX77843_MUIC_REG_INTMASK3	= 0x09,
> +	MAX77843_MUIC_REG_CDETCTRL1	= 0x0A,
> +	MAX77843_MUIC_REG_CDETCTRL2	= 0x0B,
> +	MAX77843_MUIC_REG_CONTROL1	= 0x0C,
> +	MAX77843_MUIC_REG_CONTROL2	= 0x0D,
> +	MAX77843_MUIC_REG_CONTROL3	= 0x0E,
> +	MAX77843_MUIC_REG_CONTROL4	= 0x16,
> +	MAX77843_MUIC_REG_HVCONTROL1	= 0x17,
> +	MAX77843_MUIC_REG_HVCONTROL2	= 0x18,
> +
> +	MAX77843_MUIC_REG_END,
> +};
> +
> +enum max77843_irq {
> +	/* Topsys: SYSTEM */
> +	MAX77843_SYS_IRQ_SYSINTSRC_SYSUVLO_INT,
> +	MAX77843_SYS_IRQ_SYSINTSRC_SYSOVLO_INT,
> +	MAX77843_SYS_IRQ_SYSINTSRC_TSHDN_INT,
> +	MAX77843_SYS_IRQ_SYSINTSRC_TM_INT,
> +
> +	/* Charger: CHG_INT */
> +	MAX77843_CHG_IRQ_CHG_INT_BYP_I,
> +	MAX77843_CHG_IRQ_CHG_INT_BATP_I,
> +	MAX77843_CHG_IRQ_CHG_INT_BAT_I,
> +	MAX77843_CHG_IRQ_CHG_INT_CHG_I,
> +	MAX77843_CHG_IRQ_CHG_INT_WCIN_I,
> +	MAX77843_CHG_IRQ_CHG_INT_CHGIN_I,
> +	MAX77843_CHG_IRQ_CHG_INT_AICL_I,
> +
> +	MAX77843_IRQ_NUM,
> +};
> +
> +enum max77843_irq_muic {
> +	/* MUIC: INT1 */
> +	MAX77843_MUIC_IRQ_INT1_ADC,
> +	MAX77843_MUIC_IRQ_INT1_ADCERROR,
> +	MAX77843_MUIC_IRQ_INT1_ADC1K,
> +
> +	/* MUIC: INT2 */
> +	MAX77843_MUIC_IRQ_INT2_CHGTYP,
> +	MAX77843_MUIC_IRQ_INT2_CHGDETRUN,
> +	MAX77843_MUIC_IRQ_INT2_DCDTMR,
> +	MAX77843_MUIC_IRQ_INT2_DXOVP,
> +	MAX77843_MUIC_IRQ_INT2_VBVOLT,
> +
> +	/* MUIC: INT3 */
> +	MAX77843_MUIC_IRQ_INT3_VBADC,
> +	MAX77843_MUIC_IRQ_INT3_VDNMON,
> +	MAX77843_MUIC_IRQ_INT3_DNRES,
> +	MAX77843_MUIC_IRQ_INT3_MPNACK,
> +	MAX77843_MUIC_IRQ_INT3_MRXBUFOW,
> +	MAX77843_MUIC_IRQ_INT3_MRXTRF,
> +	MAX77843_MUIC_IRQ_INT3_MRXPERR,
> +	MAX77843_MUIC_IRQ_INT3_MRXRDY,
> +
> +	MAX77843_MUIC_IRQ_NUM,
> +};
> +
> +/* MAX77843 interrupts */
> +#define MAX77843_SYS_IRQ_SYSUVLO_INT		BIT(0)
> +#define MAX77843_SYS_IRQ_SYSOVLO_INT		BIT(1)
> +#define MAX77843_SYS_IRQ_TSHDN_INT		BIT(2)
> +#define MAX77843_SYS_IRQ_TM_INT			BIT(3)
> +
> +/* MAX77843 MAINCTRL1 register */
> +#define MAINCTRL1_BIASEN_SHIFT			7
> +#define MAX77843_MAINCTRL1_BIASEN_MASK		BIT(MAINCTRL1_BIASEN_SHIFT)
> +
> +/* MAX77843 MCONFIG register */
> +#define MCONFIG_MODE_SHIFT			7
> +#define MCONFIG_MEN_SHIFT			6
> +#define MCONFIG_PDIV_SHIFT			0
> +
> +#define MAX77843_MCONFIG_MODE_MASK		BIT(MCONFIG_MODE_SHIFT)
> +#define MAX77843_MCONFIG_MEN_MASK		BIT(MCONFIG_MEN_SHIFT)
> +#define MAX77843_MCONFIG_PDIV_MASK		(0x3 << MCONFIG_PDIV_SHIFT)
> +
> +/* Max77843 charger insterrupts */
> +#define MAX77843_CHG_BYP_I			BIT(0)
> +#define MAX77843_CHG_BATP_I			BIT(2)
> +#define MAX77843_CHG_BAT_I			BIT(3)
> +#define MAX77843_CHG_CHG_I			BIT(4)
> +#define MAX77843_CHG_WCIN_I			BIT(5)
> +#define MAX77843_CHG_CHGIN_I			BIT(6)
> +#define MAX77843_CHG_AICL_I			BIT(7)
> +
> +/* MAX77843 CHG_INT_OK register */
> +#define MAX77843_CHG_BYP_OK			BIT(0)
> +#define MAX77843_CHG_BATP_OK			BIT(2)
> +#define MAX77843_CHG_BAT_OK			BIT(3)
> +#define MAX77843_CHG_CHG_OK			BIT(4)
> +#define MAX77843_CHG_WCIN_OK			BIT(5)
> +#define MAX77843_CHG_CHGIN_OK			BIT(6)
> +#define MAX77843_CHG_AICL_OK			BIT(7)
> +
> +/* MAX77843 CHG_DETAILS_00 register */
> +#define MAX77843_CHG_BAT_DTLS			BIT(0)
> +
> +/* MAX77843 CHG_DETAILS_01 register */
> +#define MAX77843_CHG_DTLS_MASK			0x0f
> +#define MAX77843_CHG_PQ_MODE			0x00
> +#define MAX77843_CHG_CC_MODE			0x01
> +#define MAX77843_CHG_CV_MODE			0x02
> +#define MAX77843_CHG_TO_MODE			0x03
> +#define MAX77843_CHG_DO_MODE			0x04
> +#define MAX77843_CHG_HT_MODE			0x05
> +#define MAX77843_CHG_TF_MODE			0x06
> +#define MAX77843_CHG_TS_MODE			0x07
> +#define MAX77843_CHG_OFF_MODE			0x08
> +
> +#define MAX77843_CHG_BAT_DTLS_MASK		0xf0
> +#define MAX77843_CHG_NO_BAT			(0x00 << 4)
> +#define MAX77843_CHG_LOW_VOLT_BAT		(0x01 << 4)
> +#define MAX77843_CHG_LONG_BAT_TIME		(0x02 << 4)
> +#define MAX77843_CHG_OK_BAT			(0x03 << 4)
> +#define MAX77843_CHG_OK_LOW_VOLT_BAT		(0x04 << 4)
> +#define MAX77843_CHG_OVER_VOLT_BAT		(0x05 << 4)
> +#define MAX77843_CHG_OVER_CURRENT_BAT		(0x06 << 4)
> +
> +/* MAX77843 CHG_CNFG_00 register */
> +#define MAX77843_CHG_DISABLE			0x00
> +#define MAX77843_CHG_ENABLE			0x05
> +#define MAX77843_CHG_MASK			0x01
> +#define MAX77843_CHG_BUCK_MASK			0x04
> +
> +/* MAX77843 CHG_CNFG_01 register */
> +#define MAX77843_CHG_RESTART_THRESHOLD_100	0x00
> +#define MAX77843_CHG_RESTART_THRESHOLD_150	0x10
> +#define MAX77843_CHG_RESTART_THRESHOLD_200	0x20
> +#define MAX77843_CHG_RESTART_THRESHOLD_DISABLE	0x30
> +
> +/* MAX77843 CHG_CNFG_02 register */
> +#define MAX77843_CHG_FAST_CHG_CURRENT_MIN	100000
> +#define MAX77843_CHG_FAST_CHG_CURRENT_MAX	3150000
> +#define MAX77843_CHG_FAST_CHG_CURRENT_STEP	50000
> +#define MAX77843_CHG_FAST_CHG_CURRENT_MASK	0x3f
> +#define MAX77843_CHG_OTG_ILIMIT_500		(0x00 << 6)
> +#define MAX77843_CHG_OTG_ILIMIT_900		(0x01 << 6)
> +#define MAX77843_CHG_OTG_ILIMIT_1200		(0x02 << 6)
> +#define MAX77843_CHG_OTG_ILIMIT_1500		(0x03 << 6)
> +#define MAX77843_CHG_OTG_ILIMIT_MASK		0xc0
> +
> +/* MAX77843 CHG_CNFG_03 register */
> +#define MAX77843_CHG_TOP_OFF_CURRENT_MIN	125000
> +#define MAX77843_CHG_TOP_OFF_CURRENT_MAX	650000
> +#define MAX77843_CHG_TOP_OFF_CURRENT_STEP	75000
> +#define MAX77843_CHG_TOP_OFF_CURRENT_MASK	0x07
> +
> +/* MAX77843 CHG_CNFG_06 register */
> +#define MAX77843_CHG_WRITE_CAP_BLOCK		0x10
> +#define MAX77843_CHG_WRITE_CAP_UNBLOCK		0x0C
> +
> +/* MAX77843_CHG_CNFG_09_register */
> +#define MAX77843_CHG_INPUT_CURRENT_LIMIT_MIN	100000
> +#define MAX77843_CHG_INPUT_CURRENT_LIMIT_MAX	4000000
> +#define MAX77843_CHG_INPUT_CURRENT_LIMIT_REF	3367000
> +#define MAX77843_CHG_INPUT_CURRENT_LIMIT_STEP	33000
> +
> +#define MAX77843_MUIC_ADC			BIT(0)
> +#define MAX77843_MUIC_ADCERROR			BIT(2)
> +#define MAX77843_MUIC_ADC1K			BIT(3)
> +
> +#define MAX77843_MUIC_CHGTYP			BIT(0)
> +#define MAX77843_MUIC_CHGDETRUN			BIT(1)
> +#define MAX77843_MUIC_DCDTMR			BIT(2)
> +#define MAX77843_MUIC_DXOVP			BIT(3)
> +#define MAX77843_MUIC_VBVOLT			BIT(4)
> +
> +#define MAX77843_MUIC_VBADC			BIT(0)
> +#define MAX77843_MUIC_VDNMON			BIT(1)
> +#define MAX77843_MUIC_DNRES			BIT(2)
> +#define MAX77843_MUIC_MPNACK			BIT(3)
> +#define MAX77843_MUIC_MRXBUFOW			BIT(4)
> +#define MAX77843_MUIC_MRXTRF			BIT(5)
> +#define MAX77843_MUIC_MRXPERR			BIT(6)
> +#define MAX77843_MUIC_MRXRDY			BIT(7)
> +
> +/* MAX77843 INTSRCMASK register */
> +#define MAX77843_INTSRCMASK_CHGR		0
> +#define MAX77843_INTSRCMASK_SYS			1
> +#define MAX77843_INTSRCMASK_FG			2
> +#define MAX77843_INTSRCMASK_MUIC		3
> +
> +#define MAX77843_INTSRCMASK_CHGR_MASK          BIT(MAX77843_INTSRCMASK_CHGR)
> +#define MAX77843_INTSRCMASK_SYS_MASK           BIT(MAX77843_INTSRCMASK_SYS)
> +#define MAX77843_INTSRCMASK_FG_MASK            BIT(MAX77843_INTSRCMASK_FG)
> +#define MAX77843_INTSRCMASK_MUIC_MASK          BIT(MAX77843_INTSRCMASK_MUIC)
> +
> +#define MAX77843_INTSRC_MASK_MASK \
> +	(MAX77843_INTSRCMASK_MUIC_MASK | MAX77843_INTSRCMASK_FG_MASK | \
> +	MAX77843_INTSRCMASK_SYS_MASK | MAX77843_INTSRCMASK_CHGR_MASK)
> +
> +/* MAX77843 STATUS register*/
> +#define STATUS1_ADC_SHIFT			0
> +#define STATUS1_ADCERROR_SHIFT			6
> +#define STATUS1_ADC1K_SHIFT			7
> +#define STATUS2_CHGTYP_SHIFT			0
> +#define STATUS2_CHGDETRUN_SHIFT			3
> +#define STATUS2_DCDTMR_SHIFT			4
> +#define STATUS2_DXOVP_SHIFT			5
> +#define STATUS2_VBVOLT_SHIFT			6
> +#define STATUS3_VBADC_SHIFT			0
> +#define STATUS3_VDNMON_SHIFT			4
> +#define STATUS3_DNRES_SHIFT			5
> +#define STATUS3_MPNACK_SHIFT			6
> +
> +#define MAX77843_MUIC_STATUS1_ADC_MASK		(0x1f << STATUS1_ADC_SHIFT)
> +#define MAX77843_MUIC_STATUS1_ADCERROR_MASK	BIT(STATUS1_ADCERROR_SHIFT)
> +#define MAX77843_MUIC_STATUS1_ADC1K_MASK	BIT(STATUS1_ADC1K_SHIFT)
> +#define MAX77843_MUIC_STATUS2_CHGTYP_MASK	(0x7 << STATUS2_CHGTYP_SHIFT)
> +#define MAX77843_MUIC_STATUS2_CHGDETRUN_MASK	BIT(STATUS2_CHGDETRUN_SHIFT)
> +#define MAX77843_MUIC_STATUS2_DCDTMR_MASK	BIT(STATUS2_DCDTMR_SHIFT)
> +#define MAX77843_MUIC_STATUS2_DXOVP_MASK	BIT(STATUS2_DXOVP_SHIFT)
> +#define MAX77843_MUIC_STATUS2_VBVOLT_MASK	BIT(STATUS2_VBVOLT_SHIFT)
> +#define MAX77843_MUIC_STATUS3_VBADC_MASK	(0xf << STATUS3_VBADC_SHIFT)
> +#define MAX77843_MUIC_STATUS3_VDNMON_MASK	BIT(STATUS3_VDNMON_SHIFT)
> +#define MAX77843_MUIC_STATUS3_DNRES_MASK	BIT(STATUS3_DNRES_SHIFT)
> +#define MAX77843_MUIC_STATUS3_MPNACK_MASK	BIT(STATUS3_MPNACK_SHIFT)
> +
> +/* MAX77843 CONTROL register */
> +#define CONTROL1_COMP1SW_SHIFT			0
> +#define CONTROL1_COMP2SW_SHIFT			3
> +#define CONTROL1_IDBEN_SHIFT			7
> +#define CONTROL2_LOWPWR_SHIFT			0
> +#define CONTROL2_ADCEN_SHIFT			1
> +#define CONTROL2_CPEN_SHIFT			2
> +#define CONTROL2_ACC_DET_SHIFT			5
> +#define CONTROL2_USBCPINT_SHIFT			6
> +#define CONTROL2_RCPS_SHIFT			7
> +#define CONTROL3_JIGSET_SHIFT			0
> +#define CONTROL4_ADCDBSET_SHIFT			0
> +#define CONTROL4_USBAUTO_SHIFT			4
> +#define CONTROL4_FCTAUTO_SHIFT			5
> +#define CONTROL4_ADCMODE_SHIFT			6
> +
> +#define MAX77843_MUIC_CONTROL1_COMP1SW_MASK	(0x7 << CONTROL1_COMP1SW_SHIFT)
> +#define MAX77843_MUIC_CONTROL1_COMP2SW_MASK	(0x7 << CONTROL1_COMP2SW_SHIFT)
> +#define MAX77843_MUIC_CONTROL1_IDBEN_MASK	BIT(CONTROL1_IDBEN_SHIFT)
> +#define MAX77843_MUIC_CONTROL2_LOWPWR_MASK	BIT(CONTROL2_LOWPWR_SHIFT)
> +#define MAX77843_MUIC_CONTROL2_ADCEN_MASK	BIT(CONTROL2_ADCEN_SHIFT)
> +#define MAX77843_MUIC_CONTROL2_CPEN_MASK	BIT(CONTROL2_CPEN_SHIFT)
> +#define MAX77843_MUIC_CONTROL2_ACC_DET_MASK	BIT(CONTROL2_ACC_DET_SHIFT)
> +#define MAX77843_MUIC_CONTROL2_USBCPINT_MASK	BIT(CONTROL2_USBCPINT_SHIFT)
> +#define MAX77843_MUIC_CONTROL2_RCPS_MASK	BIT(CONTROL2_RCPS_SHIFT)
> +#define MAX77843_MUIC_CONTROL3_JIGSET_MASK	(0x3 << CONTROL3_JIGSET_SHIFT)
> +#define MAX77843_MUIC_CONTROL4_ADCDBSET_MASK	(0x3 << CONTROL4_ADCDBSET_SHIFT)
> +#define MAX77843_MUIC_CONTROL4_USBAUTO_MASK	BIT(CONTROL4_USBAUTO_SHIFT)
> +#define MAX77843_MUIC_CONTROL4_FCTAUTO_MASK	BIT(CONTROL4_FCTAUTO_SHIFT)
> +#define MAX77843_MUIC_CONTROL4_ADCMODE_MASK	(0x3 << CONTROL4_ADCMODE_SHIFT)
> +
> +/* MAX77843 switch port */
> +#define COM_OPEN				0
> +#define COM_USB					1
> +#define COM_AUDIO				2
> +#define COM_UART				3
> +#define COM_AUX_USB				4
> +#define COM_AUX_UART				5
> +
> +#define CONTROL1_COM_SW \
> +	((MAX77843_MUIC_CONTROL1_COMP1SW_MASK | \
> +	 MAX77843_MUIC_CONTROL1_COMP2SW_MASK))
> +
> +#define CONTROL1_SW_OPEN \
> +	((COM_OPEN << CONTROL1_COMP1SW_SHIFT | \
> +	 COM_OPEN << CONTROL1_COMP2SW_SHIFT))
> +#define CONTROL1_SW_USB \
> +	((COM_USB << CONTROL1_COMP1SW_SHIFT | \
> +	 COM_USB << CONTROL1_COMP2SW_SHIFT))
> +#define CONTROL1_SW_AUDIO \
> +	((COM_AUDIO << CONTROL1_COMP1SW_SHIFT | \
> +	 COM_AUDIO << CONTROL1_COMP2SW_SHIFT))
> +#define CONTROL1_SW_UART \
> +	((COM_UART << CONTROL1_COMP1SW_SHIFT | \
> +	 COM_UART << CONTROL1_COMP2SW_SHIFT))
> +#define CONTROL1_SW_AUX_USB \
> +	((COM_AUX_USB << CONTROL1_COMP1SW_SHIFT | \
> +	 COM_AUX_USB << CONTROL1_COMP2SW_SHIFT))
> +#define CONTROL1_SW_AUX_UART \
> +	((COM_AUX_UART << CONTROL1_COMP1SW_SHIFT | \
> +	 COM_AUX_UART << CONTROL1_COMP2SW_SHIFT))
> +
> +#define MAX77843_DISABLE			0
> +#define MAX77843_ENABLE				1
> +
> +#define CONTROL4_AUTO_DISABLE \
> +	((MAX77843_DISABLE << CONTROL4_USBAUTO_SHIFT) | \
> +	(MAX77843_DISABLE << CONTROL4_FCTAUTO_SHIFT))
> +#define CONTROL4_AUTO_ENABLE \
> +	((MAX77843_ENABLE << CONTROL4_USBAUTO_SHIFT) | \
> +	(MAX77843_ENABLE << CONTROL4_FCTAUTO_SHIFT))
> +
> +/* MAX77843 SAFEOUT LDO Control register */
> +#define SAFEOUTCTRL_SAFEOUT1_SHIFT		0
> +#define SAFEOUTCTRL_SAFEOUT2_SHIFT		2
> +#define SAFEOUTCTRL_ENSAFEOUT1_SHIFT		6
> +#define SAFEOUTCTRL_ENSAFEOUT2_SHIFT		7
> +
> +#define MAX77843_REG_SAFEOUTCTRL_ENSAFEOUT1 \
> +		BIT(SAFEOUTCTRL_ENSAFEOUT1_SHIFT)
> +#define MAX77843_REG_SAFEOUTCTRL_ENSAFEOUT2 \
> +		BIT(SAFEOUTCTRL_ENSAFEOUT2_SHIFT)
> +#define MAX77843_REG_SAFEOUTCTRL_SAFEOUT1_MASK \
> +		(0x3 << SAFEOUTCTRL_SAFEOUT1_SHIFT)
> +#define MAX77843_REG_SAFEOUTCTRL_SAFEOUT2_MASK \
> +		(0x3 << SAFEOUTCTRL_SAFEOUT2_SHIFT)
> +
> +struct max77843 {
> +	struct device *dev;
> +
> +	struct i2c_client *i2c;
> +	struct i2c_client *i2c_chg;
> +	struct i2c_client *i2c_fuel;
> +	struct i2c_client *i2c_muic;
> +
> +	struct regmap *regmap;
> +	struct regmap *regmap_chg;
> +	struct regmap *regmap_fuel;
> +	struct regmap *regmap_muic;
> +
> +	struct regmap_irq_chip_data *irq_data;
> +	struct regmap_irq_chip_data *irq_data_chg;
> +	struct regmap_irq_chip_data *irq_data_fuel;
> +	struct regmap_irq_chip_data *irq_data_muic;
> +
> +	int irq;
> +};
> +#endif /* __MAX77843_H__ */

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 4/5] Input: add haptic drvier on max77843
  2015-03-02 10:10 ` [PATCH v7 4/5] Input: add haptic drvier on max77843 Jaewon Kim
@ 2015-03-02 17:32   ` Dmitry Torokhov
  2015-03-03  1:35     ` Jaewon Kim
  0 siblings, 1 reply; 36+ messages in thread
From: Dmitry Torokhov @ 2015-03-02 17:32 UTC (permalink / raw)
  To: Jaewon Kim
  Cc: linux-kernel, devicetree, linux-pm, linux-input, Inki Dae,
	SangBae Lee, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, Lee Jones, Chanwoo Choi, Sebastian Reichel,
	Beomho Seo

On Mon, Mar 02, 2015 at 07:10:37PM +0900, Jaewon Kim wrote:
> This patch adds support for haptic driver on max77843
> MFD(Multi Function Device) with PMIC, MUIC, LED, CHARGER.
> 
> This driver supports external pwm and LRA(Linear Resonant Actuator) motor.
> And it supports ff-memless interface from inpu framework.
> 
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com>

Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Do you want it to go through my or MFD tree?

> ---
>  drivers/input/misc/Kconfig           |   12 ++
>  drivers/input/misc/Makefile          |    1 +
>  drivers/input/misc/max77843-haptic.c |  358 ++++++++++++++++++++++++++++++++++
>  3 files changed, 371 insertions(+)
>  create mode 100644 drivers/input/misc/max77843-haptic.c
> 
> diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
> index 6deb8da..aa8c072 100644
> --- a/drivers/input/misc/Kconfig
> +++ b/drivers/input/misc/Kconfig
> @@ -165,6 +165,18 @@ config INPUT_MAX77693_HAPTIC
>  	  To compile this driver as module, choose M here: the
>  	  module will be called max77693-haptic.
>  
> +config INPUT_MAX77843_HAPTIC
> +    tristate "MAXIM MAX77843 haptic controller support"
> +    depends on MFD_MAX77843 && PWM
> +    select INPUT_FF_MEMLESS
> +    help
> +      This option enables support for the haptic controller on
> +      MAXIM MAX77843 chip. The driver supports ff-memless interface
> +      from input framework.
> +
> +      To compile this driver as module, choose M here: the
> +      module will be called max77843-haptic.
> +
>  config INPUT_MAX8925_ONKEY
>  	tristate "MAX8925 ONKEY support"
>  	depends on MFD_MAX8925
> diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
> index 403a1a5..75b5884 100644
> --- a/drivers/input/misc/Makefile
> +++ b/drivers/input/misc/Makefile
> @@ -39,6 +39,7 @@ obj-$(CONFIG_INPUT_KEYSPAN_REMOTE)	+= keyspan_remote.o
>  obj-$(CONFIG_INPUT_KXTJ9)		+= kxtj9.o
>  obj-$(CONFIG_INPUT_M68K_BEEP)		+= m68kspkr.o
>  obj-$(CONFIG_INPUT_MAX77693_HAPTIC)	+= max77693-haptic.o
> +obj-$(CONFIG_INPUT_MAX77843_HAPTIC)	+= max77843-haptic.o
>  obj-$(CONFIG_INPUT_MAX8925_ONKEY)	+= max8925_onkey.o
>  obj-$(CONFIG_INPUT_MAX8997_HAPTIC)	+= max8997_haptic.o
>  obj-$(CONFIG_INPUT_MC13783_PWRBUTTON)	+= mc13783-pwrbutton.o
> diff --git a/drivers/input/misc/max77843-haptic.c b/drivers/input/misc/max77843-haptic.c
> new file mode 100644
> index 0000000..eef9862
> --- /dev/null
> +++ b/drivers/input/misc/max77843-haptic.c
> @@ -0,0 +1,358 @@
> +/*
> + * MAXIM MAX77693 Haptic device driver
> + *
> + * Copyright (C) 2015 Samsung Electronics
> + * Author: Jaewon Kim <jaewon02.kim@samsung.com>
> + *
> + * 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
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +
> +#include <linux/err.h>
> +#include <linux/i2c.h>
> +#include <linux/init.h>
> +#include <linux/input.h>
> +#include <linux/mfd/max77843-private.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/pwm.h>
> +#include <linux/regmap.h>
> +#include <linux/regulator/consumer.h>
> +#include <linux/slab.h>
> +#include <linux/workqueue.h>
> +
> +#define MAX_MAGNITUDE_SHIFT        16
> +
> +enum max77843_haptic_motor_type {
> +	MAX77843_HAPTIC_ERM = 0,
> +	MAX77843_HAPTIC_LRA,
> +};
> +
> +enum max77843_haptic_pwm_divisor {
> +	MAX77843_HAPTIC_PWM_DIVISOR_32 = 0,
> +	MAX77843_HAPTIC_PWM_DIVISOR_64,
> +	MAX77843_HAPTIC_PWM_DIVISOR_128,
> +	MAX77843_HAPTIC_PWM_DIVISOR_256,
> +};
> +
> +struct max77843_haptic {
> +	struct regmap *regmap_haptic;
> +	struct device *dev;
> +	struct input_dev *input_dev;
> +	struct pwm_device *pwm_dev;
> +	struct regulator *motor_reg;
> +	struct work_struct work;
> +	struct mutex mutex;
> +
> +	unsigned int magnitude;
> +	unsigned int pwm_duty;
> +
> +	bool active;
> +	bool suspended;
> +
> +	enum max77843_haptic_motor_type type;
> +	enum max77843_haptic_pwm_divisor pwm_divisor;
> +};
> +
> +static int max77843_haptic_set_duty_cycle(struct max77843_haptic *haptic)
> +{
> +	int delta = (haptic->pwm_dev->period + haptic->pwm_duty) / 2;
> +	int error;
> +
> +	error = pwm_config(haptic->pwm_dev, delta, haptic->pwm_dev->period);
> +	if (error) {
> +		dev_err(haptic->dev, "failed to configure pwm: %d\n", error);
> +		return error;
> +	}
> +
> +	return 0;
> +}
> +
> +static int max77843_haptic_bias(struct max77843_haptic *haptic, bool on)
> +{
> +	int error;
> +
> +	error = regmap_update_bits(haptic->regmap_haptic,
> +			MAX77843_SYS_REG_MAINCTRL1,
> +			MAX77843_MAINCTRL1_BIASEN_MASK,
> +			on << MAINCTRL1_BIASEN_SHIFT);
> +	if (error) {
> +		dev_err(haptic->dev, "failed to %s bias: %d\n",
> +			on ? "enable" : "disable", error);
> +		return error;
> +	}
> +
> +	return 0;
> +}
> +
> +static int max77843_haptic_config(struct max77843_haptic *haptic, bool enable)
> +{
> +	unsigned int value;
> +	int error;
> +
> +	value = ((haptic->type << MCONFIG_MODE_SHIFT) |
> +		(enable << MCONFIG_MEN_SHIFT) |
> +		(haptic->pwm_divisor << MCONFIG_PDIV_SHIFT));
> +
> +	error = regmap_write(haptic->regmap_haptic,
> +			MAX77843_HAP_REG_MCONFIG, value);
> +	if (error) {
> +		dev_err(haptic->dev,
> +			"failed to update haptic config: %d\n", error);
> +		return error;
> +	}
> +
> +	return 0;
> +}
> +
> +static int max77843_haptic_enable(struct max77843_haptic *haptic)
> +{
> +	int error;
> +
> +	if (haptic->active)
> +		return 0;
> +
> +	error = pwm_enable(haptic->pwm_dev);
> +	if (error) {
> +		dev_err(haptic->dev,
> +			"failed to enable pwm device: %d\n", error);
> +		return error;
> +	}
> +
> +	error = max77843_haptic_config(haptic, true);
> +	if (error)
> +		goto err_config;
> +
> +	haptic->active = true;
> +
> +	return 0;
> +
> +err_config:
> +	pwm_disable(haptic->pwm_dev);
> +
> +	return error;
> +}
> +
> +static int max77843_haptic_disable(struct max77843_haptic *haptic)
> +{
> +	int error;
> +
> +	if (!haptic->active)
> +		return 0;
> +
> +	error = max77843_haptic_config(haptic, false);
> +	if (error)
> +		return error;
> +
> +	pwm_disable(haptic->pwm_dev);
> +
> +	haptic->active = false;
> +
> +	return 0;
> +}
> +
> +static void max77843_haptic_play_work(struct work_struct *work)
> +{
> +	struct max77843_haptic *haptic =
> +			container_of(work, struct max77843_haptic, work);
> +	int error;
> +
> +	mutex_lock(&haptic->mutex);
> +
> +	if (haptic->suspended)
> +		goto out_unlock;
> +
> +	if (haptic->magnitude) {
> +		error = max77843_haptic_set_duty_cycle(haptic);
> +		if (error) {
> +			dev_err(haptic->dev,
> +				"failed to set duty cycle: %d\n", error);
> +			goto out_unlock;
> +		}
> +
> +		error = max77843_haptic_enable(haptic);
> +		if (error)
> +			dev_err(haptic->dev,
> +				"cannot enable haptic: %d\n", error);
> +	} else {
> +		error = max77843_haptic_disable(haptic);
> +		if (error)
> +			dev_err(haptic->dev,
> +				"cannot disable haptic: %d\n", error);
> +	}
> +
> +out_unlock:
> +	mutex_unlock(&haptic->mutex);
> +}
> +
> +static int max77843_haptic_play_effect(struct input_dev *dev, void *data,
> +		struct ff_effect *effect)
> +{
> +	struct max77843_haptic *haptic = input_get_drvdata(dev);
> +	u64 period_mag_multi;
> +
> +	haptic->magnitude = effect->u.rumble.strong_magnitude;
> +	if (!haptic->magnitude)
> +		haptic->magnitude = effect->u.rumble.weak_magnitude;
> +
> +	period_mag_multi = (u64)haptic->pwm_dev->period * haptic->magnitude;
> +	haptic->pwm_duty = (unsigned int)(period_mag_multi >>
> +				MAX_MAGNITUDE_SHIFT);
> +
> +	schedule_work(&haptic->work);
> +
> +	return 0;
> +}
> +
> +static int max77843_haptic_open(struct input_dev *dev)
> +{
> +	struct max77843_haptic *haptic = input_get_drvdata(dev);
> +	int error;
> +
> +	error = max77843_haptic_bias(haptic, true);
> +	if (error)
> +		return error;
> +
> +	error = regulator_enable(haptic->motor_reg);
> +	if (error) {
> +		dev_err(haptic->dev,
> +			"failed to enable regulator: %d\n", error);
> +		return error;
> +	}
> +
> +	return 0;
> +}
> +
> +static void max77843_haptic_close(struct input_dev *dev)
> +{
> +	struct max77843_haptic *haptic = input_get_drvdata(dev);
> +	int error;
> +
> +	cancel_work_sync(&haptic->work);
> +	max77843_haptic_disable(haptic);
> +
> +	error = regulator_disable(haptic->motor_reg);
> +	if (error)
> +		dev_err(haptic->dev,
> +			"failed to disable regulator: %d\n", error);
> +
> +	max77843_haptic_bias(haptic, false);
> +}
> +
> +static int max77843_haptic_probe(struct platform_device *pdev)
> +{
> +	struct max77843 *max77843 = dev_get_drvdata(pdev->dev.parent);
> +	struct max77843_haptic *haptic;
> +	int error;
> +
> +	haptic = devm_kzalloc(&pdev->dev, sizeof(*haptic), GFP_KERNEL);
> +	if (!haptic)
> +		return -ENOMEM;
> +
> +	haptic->regmap_haptic = max77843->regmap;
> +	haptic->dev = &pdev->dev;
> +	haptic->type = MAX77843_HAPTIC_LRA;
> +	haptic->pwm_divisor = MAX77843_HAPTIC_PWM_DIVISOR_128;
> +
> +	INIT_WORK(&haptic->work, max77843_haptic_play_work);
> +	mutex_init(&haptic->mutex);
> +
> +	haptic->pwm_dev = devm_pwm_get(&pdev->dev, NULL);
> +	if (IS_ERR(haptic->pwm_dev)) {
> +		dev_err(&pdev->dev, "failed to get pwm device\n");
> +		return PTR_ERR(haptic->pwm_dev);
> +	}
> +
> +	haptic->motor_reg = devm_regulator_get_exclusive(&pdev->dev, "haptic");
> +	if (IS_ERR(haptic->motor_reg)) {
> +		dev_err(&pdev->dev, "failed to get regulator\n");
> +		return PTR_ERR(haptic->motor_reg);
> +	}
> +
> +	haptic->input_dev = devm_input_allocate_device(&pdev->dev);
> +	if (!haptic->input_dev) {
> +		dev_err(&pdev->dev, "failed to allocate input device\n");
> +		return -ENOMEM;
> +	}
> +
> +	haptic->input_dev->name = "max77843-haptic";
> +	haptic->input_dev->id.version = 1;
> +	haptic->input_dev->dev.parent = &pdev->dev;
> +	haptic->input_dev->open = max77843_haptic_open;
> +	haptic->input_dev->close = max77843_haptic_close;
> +	input_set_drvdata(haptic->input_dev, haptic);
> +	input_set_capability(haptic->input_dev, EV_FF, FF_RUMBLE);
> +
> +	error = input_ff_create_memless(haptic->input_dev, NULL,
> +			max77843_haptic_play_effect);
> +	if (error) {
> +		dev_err(&pdev->dev, "failed to create force-feedback\n");
> +		return error;
> +	}
> +
> +	error = input_register_device(haptic->input_dev);
> +	if (error) {
> +		dev_err(&pdev->dev, "failed to register input device\n");
> +		return error;
> +	}
> +
> +	platform_set_drvdata(pdev, haptic);
> +
> +	return 0;
> +}
> +
> +static int __maybe_unused max77843_haptic_suspend(struct device *dev)
> +{
> +	struct platform_device *pdev = to_platform_device(dev);
> +	struct max77843_haptic *haptic = platform_get_drvdata(pdev);
> +	int error;
> +
> +	error = mutex_lock_interruptible(&haptic->mutex);
> +	if (error)
> +		return error;
> +
> +	max77843_haptic_disable(haptic);
> +
> +	haptic->suspended = true;
> +
> +	mutex_unlock(&haptic->mutex);
> +
> +	return 0;
> +}
> +
> +static int __maybe_unused max77843_haptic_resume(struct device *dev)
> +{
> +	struct platform_device *pdev = to_platform_device(dev);
> +	struct max77843_haptic *haptic = platform_get_drvdata(pdev);
> +	unsigned int magnitude;
> +
> +	mutex_lock(&haptic->mutex);
> +
> +	haptic->suspended = false;
> +
> +	magnitude = ACCESS_ONCE(haptic->magnitude);
> +	if (magnitude)
> +		max77843_haptic_enable(haptic);
> +
> +	mutex_unlock(&haptic->mutex);
> +
> +	return 0;
> +}
> +
> +static SIMPLE_DEV_PM_OPS(max77843_haptic_pm_ops,
> +		max77843_haptic_suspend, max77843_haptic_resume);
> +
> +static struct platform_driver max77843_haptic_driver = {
> +	.driver		= {
> +		.name	= "max77843-haptic",
> +		.pm	= &max77843_haptic_pm_ops,
> +	},
> +	.probe		= max77843_haptic_probe,
> +};
> +module_platform_driver(max77843_haptic_driver);
> +
> +MODULE_AUTHOR("Jaewon Kim <jaewon02.kim@samsung.com>");
> +MODULE_DESCRIPTION("MAXIM MAX77843 Haptic driver");
> +MODULE_LICENSE("GPL");
> -- 
> 1.7.9.5
> 

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 4/5] Input: add haptic drvier on max77843
  2015-03-02 17:32   ` Dmitry Torokhov
@ 2015-03-03  1:35     ` Jaewon Kim
  2015-03-04 22:47       ` Dmitry Torokhov
  0 siblings, 1 reply; 36+ messages in thread
From: Jaewon Kim @ 2015-03-03  1:35 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-kernel, devicetree, linux-pm, linux-input, Inki Dae,
	SangBae Lee, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, Lee Jones, Chanwoo Choi, Sebastian Reichel,
	Beomho Seo

Hi Dmitry,

On 03/03/2015 02:32, Dmitry Torokhov wrote:
> On Mon, Mar 02, 2015 at 07:10:37PM +0900, Jaewon Kim wrote:
>> This patch adds support for haptic driver on max77843
>> MFD(Multi Function Device) with PMIC, MUIC, LED, CHARGER.
>>
>> This driver supports external pwm and LRA(Linear Resonant Actuator) motor.
>> And it supports ff-memless interface from inpu framework.
>>
>> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>> Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com>
> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>
> Do you want it to go through my or MFD tree?
Other drivers merged in each maintainers git.
If you don`t hava a problem, please merge your input git tree.


>
>> ---
>>   drivers/input/misc/Kconfig           |   12 ++
>>   drivers/input/misc/Makefile          |    1 +
>>   drivers/input/misc/max77843-haptic.c |  358 ++++++++++++++++++++++++++++++++++
>>   3 files changed, 371 insertions(+)
>>   create mode 100644 drivers/input/misc/max77843-haptic.c
>>
>> diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
>> index 6deb8da..aa8c072 100644
>> --- a/drivers/input/misc/Kconfig
>> +++ b/drivers/input/misc/Kconfig
>> @@ -165,6 +165,18 @@ config INPUT_MAX77693_HAPTIC
>>   	  To compile this driver as module, choose M here: the
>>   	  module will be called max77693-haptic.
>>   
>> +config INPUT_MAX77843_HAPTIC
>> +    tristate "MAXIM MAX77843 haptic controller support"
>> +    depends on MFD_MAX77843 && PWM
>> +    select INPUT_FF_MEMLESS
>> +    help
>> +      This option enables support for the haptic controller on
>> +      MAXIM MAX77843 chip. The driver supports ff-memless interface
>> +      from input framework.
>> +
>> +      To compile this driver as module, choose M here: the
>> +      module will be called max77843-haptic.
>> +
>>   config INPUT_MAX8925_ONKEY
>>   	tristate "MAX8925 ONKEY support"
>>   	depends on MFD_MAX8925
>> diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
>> index 403a1a5..75b5884 100644
>> --- a/drivers/input/misc/Makefile
>> +++ b/drivers/input/misc/Makefile
>> @@ -39,6 +39,7 @@ obj-$(CONFIG_INPUT_KEYSPAN_REMOTE)	+= keyspan_remote.o
>>   obj-$(CONFIG_INPUT_KXTJ9)		+= kxtj9.o
>>   obj-$(CONFIG_INPUT_M68K_BEEP)		+= m68kspkr.o
>>   obj-$(CONFIG_INPUT_MAX77693_HAPTIC)	+= max77693-haptic.o
>> +obj-$(CONFIG_INPUT_MAX77843_HAPTIC)	+= max77843-haptic.o
>>   obj-$(CONFIG_INPUT_MAX8925_ONKEY)	+= max8925_onkey.o
>>   obj-$(CONFIG_INPUT_MAX8997_HAPTIC)	+= max8997_haptic.o
>>   obj-$(CONFIG_INPUT_MC13783_PWRBUTTON)	+= mc13783-pwrbutton.o
>> diff --git a/drivers/input/misc/max77843-haptic.c b/drivers/input/misc/max77843-haptic.c
>> new file mode 100644
>> index 0000000..eef9862
>> --- /dev/null
>> +++ b/drivers/input/misc/max77843-haptic.c
>> @@ -0,0 +1,358 @@
>> +/*
>> + * MAXIM MAX77693 Haptic device driver
>> + *
>> + * Copyright (C) 2015 Samsung Electronics
>> + * Author: Jaewon Kim <jaewon02.kim@samsung.com>
>> + *
>> + * 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
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + */
>> +
>> +#include <linux/err.h>
>> +#include <linux/i2c.h>
>> +#include <linux/init.h>
>> +#include <linux/input.h>
>> +#include <linux/mfd/max77843-private.h>
>> +#include <linux/module.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/pwm.h>
>> +#include <linux/regmap.h>
>> +#include <linux/regulator/consumer.h>
>> +#include <linux/slab.h>
>> +#include <linux/workqueue.h>
>> +
>> +#define MAX_MAGNITUDE_SHIFT        16
>> +
>> +enum max77843_haptic_motor_type {
>> +	MAX77843_HAPTIC_ERM = 0,
>> +	MAX77843_HAPTIC_LRA,
>> +};
>> +
>> +enum max77843_haptic_pwm_divisor {
>> +	MAX77843_HAPTIC_PWM_DIVISOR_32 = 0,
>> +	MAX77843_HAPTIC_PWM_DIVISOR_64,
>> +	MAX77843_HAPTIC_PWM_DIVISOR_128,
>> +	MAX77843_HAPTIC_PWM_DIVISOR_256,
>> +};
>> +
>> +struct max77843_haptic {
>> +	struct regmap *regmap_haptic;
>> +	struct device *dev;
>> +	struct input_dev *input_dev;
>> +	struct pwm_device *pwm_dev;
>> +	struct regulator *motor_reg;
>> +	struct work_struct work;
>> +	struct mutex mutex;
>> +
>> +	unsigned int magnitude;
>> +	unsigned int pwm_duty;
>> +
>> +	bool active;
>> +	bool suspended;
>> +
>> +	enum max77843_haptic_motor_type type;
>> +	enum max77843_haptic_pwm_divisor pwm_divisor;
>> +};
>> +
>> +static int max77843_haptic_set_duty_cycle(struct max77843_haptic *haptic)
>> +{
>> +	int delta = (haptic->pwm_dev->period + haptic->pwm_duty) / 2;
>> +	int error;
>> +
>> +	error = pwm_config(haptic->pwm_dev, delta, haptic->pwm_dev->period);
>> +	if (error) {
>> +		dev_err(haptic->dev, "failed to configure pwm: %d\n", error);
>> +		return error;
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>> +static int max77843_haptic_bias(struct max77843_haptic *haptic, bool on)
>> +{
>> +	int error;
>> +
>> +	error = regmap_update_bits(haptic->regmap_haptic,
>> +			MAX77843_SYS_REG_MAINCTRL1,
>> +			MAX77843_MAINCTRL1_BIASEN_MASK,
>> +			on << MAINCTRL1_BIASEN_SHIFT);
>> +	if (error) {
>> +		dev_err(haptic->dev, "failed to %s bias: %d\n",
>> +			on ? "enable" : "disable", error);
>> +		return error;
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>> +static int max77843_haptic_config(struct max77843_haptic *haptic, bool enable)
>> +{
>> +	unsigned int value;
>> +	int error;
>> +
>> +	value = ((haptic->type << MCONFIG_MODE_SHIFT) |
>> +		(enable << MCONFIG_MEN_SHIFT) |
>> +		(haptic->pwm_divisor << MCONFIG_PDIV_SHIFT));
>> +
>> +	error = regmap_write(haptic->regmap_haptic,
>> +			MAX77843_HAP_REG_MCONFIG, value);
>> +	if (error) {
>> +		dev_err(haptic->dev,
>> +			"failed to update haptic config: %d\n", error);
>> +		return error;
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>> +static int max77843_haptic_enable(struct max77843_haptic *haptic)
>> +{
>> +	int error;
>> +
>> +	if (haptic->active)
>> +		return 0;
>> +
>> +	error = pwm_enable(haptic->pwm_dev);
>> +	if (error) {
>> +		dev_err(haptic->dev,
>> +			"failed to enable pwm device: %d\n", error);
>> +		return error;
>> +	}
>> +
>> +	error = max77843_haptic_config(haptic, true);
>> +	if (error)
>> +		goto err_config;
>> +
>> +	haptic->active = true;
>> +
>> +	return 0;
>> +
>> +err_config:
>> +	pwm_disable(haptic->pwm_dev);
>> +
>> +	return error;
>> +}
>> +
>> +static int max77843_haptic_disable(struct max77843_haptic *haptic)
>> +{
>> +	int error;
>> +
>> +	if (!haptic->active)
>> +		return 0;
>> +
>> +	error = max77843_haptic_config(haptic, false);
>> +	if (error)
>> +		return error;
>> +
>> +	pwm_disable(haptic->pwm_dev);
>> +
>> +	haptic->active = false;
>> +
>> +	return 0;
>> +}
>> +
>> +static void max77843_haptic_play_work(struct work_struct *work)
>> +{
>> +	struct max77843_haptic *haptic =
>> +			container_of(work, struct max77843_haptic, work);
>> +	int error;
>> +
>> +	mutex_lock(&haptic->mutex);
>> +
>> +	if (haptic->suspended)
>> +		goto out_unlock;
>> +
>> +	if (haptic->magnitude) {
>> +		error = max77843_haptic_set_duty_cycle(haptic);
>> +		if (error) {
>> +			dev_err(haptic->dev,
>> +				"failed to set duty cycle: %d\n", error);
>> +			goto out_unlock;
>> +		}
>> +
>> +		error = max77843_haptic_enable(haptic);
>> +		if (error)
>> +			dev_err(haptic->dev,
>> +				"cannot enable haptic: %d\n", error);
>> +	} else {
>> +		error = max77843_haptic_disable(haptic);
>> +		if (error)
>> +			dev_err(haptic->dev,
>> +				"cannot disable haptic: %d\n", error);
>> +	}
>> +
>> +out_unlock:
>> +	mutex_unlock(&haptic->mutex);
>> +}
>> +
>> +static int max77843_haptic_play_effect(struct input_dev *dev, void *data,
>> +		struct ff_effect *effect)
>> +{
>> +	struct max77843_haptic *haptic = input_get_drvdata(dev);
>> +	u64 period_mag_multi;
>> +
>> +	haptic->magnitude = effect->u.rumble.strong_magnitude;
>> +	if (!haptic->magnitude)
>> +		haptic->magnitude = effect->u.rumble.weak_magnitude;
>> +
>> +	period_mag_multi = (u64)haptic->pwm_dev->period * haptic->magnitude;
>> +	haptic->pwm_duty = (unsigned int)(period_mag_multi >>
>> +				MAX_MAGNITUDE_SHIFT);
>> +
>> +	schedule_work(&haptic->work);
>> +
>> +	return 0;
>> +}
>> +
>> +static int max77843_haptic_open(struct input_dev *dev)
>> +{
>> +	struct max77843_haptic *haptic = input_get_drvdata(dev);
>> +	int error;
>> +
>> +	error = max77843_haptic_bias(haptic, true);
>> +	if (error)
>> +		return error;
>> +
>> +	error = regulator_enable(haptic->motor_reg);
>> +	if (error) {
>> +		dev_err(haptic->dev,
>> +			"failed to enable regulator: %d\n", error);
>> +		return error;
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>> +static void max77843_haptic_close(struct input_dev *dev)
>> +{
>> +	struct max77843_haptic *haptic = input_get_drvdata(dev);
>> +	int error;
>> +
>> +	cancel_work_sync(&haptic->work);
>> +	max77843_haptic_disable(haptic);
>> +
>> +	error = regulator_disable(haptic->motor_reg);
>> +	if (error)
>> +		dev_err(haptic->dev,
>> +			"failed to disable regulator: %d\n", error);
>> +
>> +	max77843_haptic_bias(haptic, false);
>> +}
>> +
>> +static int max77843_haptic_probe(struct platform_device *pdev)
>> +{
>> +	struct max77843 *max77843 = dev_get_drvdata(pdev->dev.parent);
>> +	struct max77843_haptic *haptic;
>> +	int error;
>> +
>> +	haptic = devm_kzalloc(&pdev->dev, sizeof(*haptic), GFP_KERNEL);
>> +	if (!haptic)
>> +		return -ENOMEM;
>> +
>> +	haptic->regmap_haptic = max77843->regmap;
>> +	haptic->dev = &pdev->dev;
>> +	haptic->type = MAX77843_HAPTIC_LRA;
>> +	haptic->pwm_divisor = MAX77843_HAPTIC_PWM_DIVISOR_128;
>> +
>> +	INIT_WORK(&haptic->work, max77843_haptic_play_work);
>> +	mutex_init(&haptic->mutex);
>> +
>> +	haptic->pwm_dev = devm_pwm_get(&pdev->dev, NULL);
>> +	if (IS_ERR(haptic->pwm_dev)) {
>> +		dev_err(&pdev->dev, "failed to get pwm device\n");
>> +		return PTR_ERR(haptic->pwm_dev);
>> +	}
>> +
>> +	haptic->motor_reg = devm_regulator_get_exclusive(&pdev->dev, "haptic");
>> +	if (IS_ERR(haptic->motor_reg)) {
>> +		dev_err(&pdev->dev, "failed to get regulator\n");
>> +		return PTR_ERR(haptic->motor_reg);
>> +	}
>> +
>> +	haptic->input_dev = devm_input_allocate_device(&pdev->dev);
>> +	if (!haptic->input_dev) {
>> +		dev_err(&pdev->dev, "failed to allocate input device\n");
>> +		return -ENOMEM;
>> +	}
>> +
>> +	haptic->input_dev->name = "max77843-haptic";
>> +	haptic->input_dev->id.version = 1;
>> +	haptic->input_dev->dev.parent = &pdev->dev;
>> +	haptic->input_dev->open = max77843_haptic_open;
>> +	haptic->input_dev->close = max77843_haptic_close;
>> +	input_set_drvdata(haptic->input_dev, haptic);
>> +	input_set_capability(haptic->input_dev, EV_FF, FF_RUMBLE);
>> +
>> +	error = input_ff_create_memless(haptic->input_dev, NULL,
>> +			max77843_haptic_play_effect);
>> +	if (error) {
>> +		dev_err(&pdev->dev, "failed to create force-feedback\n");
>> +		return error;
>> +	}
>> +
>> +	error = input_register_device(haptic->input_dev);
>> +	if (error) {
>> +		dev_err(&pdev->dev, "failed to register input device\n");
>> +		return error;
>> +	}
>> +
>> +	platform_set_drvdata(pdev, haptic);
>> +
>> +	return 0;
>> +}
>> +
>> +static int __maybe_unused max77843_haptic_suspend(struct device *dev)
>> +{
>> +	struct platform_device *pdev = to_platform_device(dev);
>> +	struct max77843_haptic *haptic = platform_get_drvdata(pdev);
>> +	int error;
>> +
>> +	error = mutex_lock_interruptible(&haptic->mutex);
>> +	if (error)
>> +		return error;
>> +
>> +	max77843_haptic_disable(haptic);
>> +
>> +	haptic->suspended = true;
>> +
>> +	mutex_unlock(&haptic->mutex);
>> +
>> +	return 0;
>> +}
>> +
>> +static int __maybe_unused max77843_haptic_resume(struct device *dev)
>> +{
>> +	struct platform_device *pdev = to_platform_device(dev);
>> +	struct max77843_haptic *haptic = platform_get_drvdata(pdev);
>> +	unsigned int magnitude;
>> +
>> +	mutex_lock(&haptic->mutex);
>> +
>> +	haptic->suspended = false;
>> +
>> +	magnitude = ACCESS_ONCE(haptic->magnitude);
>> +	if (magnitude)
>> +		max77843_haptic_enable(haptic);
>> +
>> +	mutex_unlock(&haptic->mutex);
>> +
>> +	return 0;
>> +}
>> +
>> +static SIMPLE_DEV_PM_OPS(max77843_haptic_pm_ops,
>> +		max77843_haptic_suspend, max77843_haptic_resume);
>> +
>> +static struct platform_driver max77843_haptic_driver = {
>> +	.driver		= {
>> +		.name	= "max77843-haptic",
>> +		.pm	= &max77843_haptic_pm_ops,
>> +	},
>> +	.probe		= max77843_haptic_probe,
>> +};
>> +module_platform_driver(max77843_haptic_driver);
>> +
>> +MODULE_AUTHOR("Jaewon Kim <jaewon02.kim@samsung.com>");
>> +MODULE_DESCRIPTION("MAXIM MAX77843 Haptic driver");
>> +MODULE_LICENSE("GPL");
>> -- 
>> 1.7.9.5
>>
> Thanks.
>
Thanks to review my patch.


Thanks,
Jaewon Kim

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 4/5] Input: add haptic drvier on max77843
  2015-03-03  1:35     ` Jaewon Kim
@ 2015-03-04 22:47       ` Dmitry Torokhov
  2015-03-07 20:21         ` Sebastian Reichel
  0 siblings, 1 reply; 36+ messages in thread
From: Dmitry Torokhov @ 2015-03-04 22:47 UTC (permalink / raw)
  To: Jaewon Kim
  Cc: linux-kernel, devicetree, linux-pm, linux-input, Inki Dae,
	SangBae Lee, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, Lee Jones, Chanwoo Choi, Sebastian Reichel,
	Beomho Seo

On Tue, Mar 03, 2015 at 10:35:33AM +0900, Jaewon Kim wrote:
> Hi Dmitry,
> 
> On 03/03/2015 02:32, Dmitry Torokhov wrote:
> >On Mon, Mar 02, 2015 at 07:10:37PM +0900, Jaewon Kim wrote:
> >>This patch adds support for haptic driver on max77843
> >>MFD(Multi Function Device) with PMIC, MUIC, LED, CHARGER.
> >>
> >>This driver supports external pwm and LRA(Linear Resonant Actuator) motor.
> >>And it supports ff-memless interface from inpu framework.
> >>
> >>Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> >>Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com>
> >Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> >
> >Do you want it to go through my or MFD tree?
> Other drivers merged in each maintainers git.
> If you don`t hava a problem, please merge your input git tree.

Applied, thank you.

> 
> 
> >
> >>---
> >>  drivers/input/misc/Kconfig           |   12 ++
> >>  drivers/input/misc/Makefile          |    1 +
> >>  drivers/input/misc/max77843-haptic.c |  358 ++++++++++++++++++++++++++++++++++
> >>  3 files changed, 371 insertions(+)
> >>  create mode 100644 drivers/input/misc/max77843-haptic.c
> >>
> >>diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
> >>index 6deb8da..aa8c072 100644
> >>--- a/drivers/input/misc/Kconfig
> >>+++ b/drivers/input/misc/Kconfig
> >>@@ -165,6 +165,18 @@ config INPUT_MAX77693_HAPTIC
> >>  	  To compile this driver as module, choose M here: the
> >>  	  module will be called max77693-haptic.
> >>+config INPUT_MAX77843_HAPTIC
> >>+    tristate "MAXIM MAX77843 haptic controller support"
> >>+    depends on MFD_MAX77843 && PWM
> >>+    select INPUT_FF_MEMLESS
> >>+    help
> >>+      This option enables support for the haptic controller on
> >>+      MAXIM MAX77843 chip. The driver supports ff-memless interface
> >>+      from input framework.
> >>+
> >>+      To compile this driver as module, choose M here: the
> >>+      module will be called max77843-haptic.
> >>+
> >>  config INPUT_MAX8925_ONKEY
> >>  	tristate "MAX8925 ONKEY support"
> >>  	depends on MFD_MAX8925
> >>diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
> >>index 403a1a5..75b5884 100644
> >>--- a/drivers/input/misc/Makefile
> >>+++ b/drivers/input/misc/Makefile
> >>@@ -39,6 +39,7 @@ obj-$(CONFIG_INPUT_KEYSPAN_REMOTE)	+= keyspan_remote.o
> >>  obj-$(CONFIG_INPUT_KXTJ9)		+= kxtj9.o
> >>  obj-$(CONFIG_INPUT_M68K_BEEP)		+= m68kspkr.o
> >>  obj-$(CONFIG_INPUT_MAX77693_HAPTIC)	+= max77693-haptic.o
> >>+obj-$(CONFIG_INPUT_MAX77843_HAPTIC)	+= max77843-haptic.o
> >>  obj-$(CONFIG_INPUT_MAX8925_ONKEY)	+= max8925_onkey.o
> >>  obj-$(CONFIG_INPUT_MAX8997_HAPTIC)	+= max8997_haptic.o
> >>  obj-$(CONFIG_INPUT_MC13783_PWRBUTTON)	+= mc13783-pwrbutton.o
> >>diff --git a/drivers/input/misc/max77843-haptic.c b/drivers/input/misc/max77843-haptic.c
> >>new file mode 100644
> >>index 0000000..eef9862
> >>--- /dev/null
> >>+++ b/drivers/input/misc/max77843-haptic.c
> >>@@ -0,0 +1,358 @@
> >>+/*
> >>+ * MAXIM MAX77693 Haptic device driver
> >>+ *
> >>+ * Copyright (C) 2015 Samsung Electronics
> >>+ * Author: Jaewon Kim <jaewon02.kim@samsung.com>
> >>+ *
> >>+ * 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
> >>+ * the Free Software Foundation; either version 2 of the License, or
> >>+ * (at your option) any later version.
> >>+ */
> >>+
> >>+#include <linux/err.h>
> >>+#include <linux/i2c.h>
> >>+#include <linux/init.h>
> >>+#include <linux/input.h>
> >>+#include <linux/mfd/max77843-private.h>
> >>+#include <linux/module.h>
> >>+#include <linux/platform_device.h>
> >>+#include <linux/pwm.h>
> >>+#include <linux/regmap.h>
> >>+#include <linux/regulator/consumer.h>
> >>+#include <linux/slab.h>
> >>+#include <linux/workqueue.h>
> >>+
> >>+#define MAX_MAGNITUDE_SHIFT        16
> >>+
> >>+enum max77843_haptic_motor_type {
> >>+	MAX77843_HAPTIC_ERM = 0,
> >>+	MAX77843_HAPTIC_LRA,
> >>+};
> >>+
> >>+enum max77843_haptic_pwm_divisor {
> >>+	MAX77843_HAPTIC_PWM_DIVISOR_32 = 0,
> >>+	MAX77843_HAPTIC_PWM_DIVISOR_64,
> >>+	MAX77843_HAPTIC_PWM_DIVISOR_128,
> >>+	MAX77843_HAPTIC_PWM_DIVISOR_256,
> >>+};
> >>+
> >>+struct max77843_haptic {
> >>+	struct regmap *regmap_haptic;
> >>+	struct device *dev;
> >>+	struct input_dev *input_dev;
> >>+	struct pwm_device *pwm_dev;
> >>+	struct regulator *motor_reg;
> >>+	struct work_struct work;
> >>+	struct mutex mutex;
> >>+
> >>+	unsigned int magnitude;
> >>+	unsigned int pwm_duty;
> >>+
> >>+	bool active;
> >>+	bool suspended;
> >>+
> >>+	enum max77843_haptic_motor_type type;
> >>+	enum max77843_haptic_pwm_divisor pwm_divisor;
> >>+};
> >>+
> >>+static int max77843_haptic_set_duty_cycle(struct max77843_haptic *haptic)
> >>+{
> >>+	int delta = (haptic->pwm_dev->period + haptic->pwm_duty) / 2;
> >>+	int error;
> >>+
> >>+	error = pwm_config(haptic->pwm_dev, delta, haptic->pwm_dev->period);
> >>+	if (error) {
> >>+		dev_err(haptic->dev, "failed to configure pwm: %d\n", error);
> >>+		return error;
> >>+	}
> >>+
> >>+	return 0;
> >>+}
> >>+
> >>+static int max77843_haptic_bias(struct max77843_haptic *haptic, bool on)
> >>+{
> >>+	int error;
> >>+
> >>+	error = regmap_update_bits(haptic->regmap_haptic,
> >>+			MAX77843_SYS_REG_MAINCTRL1,
> >>+			MAX77843_MAINCTRL1_BIASEN_MASK,
> >>+			on << MAINCTRL1_BIASEN_SHIFT);
> >>+	if (error) {
> >>+		dev_err(haptic->dev, "failed to %s bias: %d\n",
> >>+			on ? "enable" : "disable", error);
> >>+		return error;
> >>+	}
> >>+
> >>+	return 0;
> >>+}
> >>+
> >>+static int max77843_haptic_config(struct max77843_haptic *haptic, bool enable)
> >>+{
> >>+	unsigned int value;
> >>+	int error;
> >>+
> >>+	value = ((haptic->type << MCONFIG_MODE_SHIFT) |
> >>+		(enable << MCONFIG_MEN_SHIFT) |
> >>+		(haptic->pwm_divisor << MCONFIG_PDIV_SHIFT));
> >>+
> >>+	error = regmap_write(haptic->regmap_haptic,
> >>+			MAX77843_HAP_REG_MCONFIG, value);
> >>+	if (error) {
> >>+		dev_err(haptic->dev,
> >>+			"failed to update haptic config: %d\n", error);
> >>+		return error;
> >>+	}
> >>+
> >>+	return 0;
> >>+}
> >>+
> >>+static int max77843_haptic_enable(struct max77843_haptic *haptic)
> >>+{
> >>+	int error;
> >>+
> >>+	if (haptic->active)
> >>+		return 0;
> >>+
> >>+	error = pwm_enable(haptic->pwm_dev);
> >>+	if (error) {
> >>+		dev_err(haptic->dev,
> >>+			"failed to enable pwm device: %d\n", error);
> >>+		return error;
> >>+	}
> >>+
> >>+	error = max77843_haptic_config(haptic, true);
> >>+	if (error)
> >>+		goto err_config;
> >>+
> >>+	haptic->active = true;
> >>+
> >>+	return 0;
> >>+
> >>+err_config:
> >>+	pwm_disable(haptic->pwm_dev);
> >>+
> >>+	return error;
> >>+}
> >>+
> >>+static int max77843_haptic_disable(struct max77843_haptic *haptic)
> >>+{
> >>+	int error;
> >>+
> >>+	if (!haptic->active)
> >>+		return 0;
> >>+
> >>+	error = max77843_haptic_config(haptic, false);
> >>+	if (error)
> >>+		return error;
> >>+
> >>+	pwm_disable(haptic->pwm_dev);
> >>+
> >>+	haptic->active = false;
> >>+
> >>+	return 0;
> >>+}
> >>+
> >>+static void max77843_haptic_play_work(struct work_struct *work)
> >>+{
> >>+	struct max77843_haptic *haptic =
> >>+			container_of(work, struct max77843_haptic, work);
> >>+	int error;
> >>+
> >>+	mutex_lock(&haptic->mutex);
> >>+
> >>+	if (haptic->suspended)
> >>+		goto out_unlock;
> >>+
> >>+	if (haptic->magnitude) {
> >>+		error = max77843_haptic_set_duty_cycle(haptic);
> >>+		if (error) {
> >>+			dev_err(haptic->dev,
> >>+				"failed to set duty cycle: %d\n", error);
> >>+			goto out_unlock;
> >>+		}
> >>+
> >>+		error = max77843_haptic_enable(haptic);
> >>+		if (error)
> >>+			dev_err(haptic->dev,
> >>+				"cannot enable haptic: %d\n", error);
> >>+	} else {
> >>+		error = max77843_haptic_disable(haptic);
> >>+		if (error)
> >>+			dev_err(haptic->dev,
> >>+				"cannot disable haptic: %d\n", error);
> >>+	}
> >>+
> >>+out_unlock:
> >>+	mutex_unlock(&haptic->mutex);
> >>+}
> >>+
> >>+static int max77843_haptic_play_effect(struct input_dev *dev, void *data,
> >>+		struct ff_effect *effect)
> >>+{
> >>+	struct max77843_haptic *haptic = input_get_drvdata(dev);
> >>+	u64 period_mag_multi;
> >>+
> >>+	haptic->magnitude = effect->u.rumble.strong_magnitude;
> >>+	if (!haptic->magnitude)
> >>+		haptic->magnitude = effect->u.rumble.weak_magnitude;
> >>+
> >>+	period_mag_multi = (u64)haptic->pwm_dev->period * haptic->magnitude;
> >>+	haptic->pwm_duty = (unsigned int)(period_mag_multi >>
> >>+				MAX_MAGNITUDE_SHIFT);
> >>+
> >>+	schedule_work(&haptic->work);
> >>+
> >>+	return 0;
> >>+}
> >>+
> >>+static int max77843_haptic_open(struct input_dev *dev)
> >>+{
> >>+	struct max77843_haptic *haptic = input_get_drvdata(dev);
> >>+	int error;
> >>+
> >>+	error = max77843_haptic_bias(haptic, true);
> >>+	if (error)
> >>+		return error;
> >>+
> >>+	error = regulator_enable(haptic->motor_reg);
> >>+	if (error) {
> >>+		dev_err(haptic->dev,
> >>+			"failed to enable regulator: %d\n", error);
> >>+		return error;
> >>+	}
> >>+
> >>+	return 0;
> >>+}
> >>+
> >>+static void max77843_haptic_close(struct input_dev *dev)
> >>+{
> >>+	struct max77843_haptic *haptic = input_get_drvdata(dev);
> >>+	int error;
> >>+
> >>+	cancel_work_sync(&haptic->work);
> >>+	max77843_haptic_disable(haptic);
> >>+
> >>+	error = regulator_disable(haptic->motor_reg);
> >>+	if (error)
> >>+		dev_err(haptic->dev,
> >>+			"failed to disable regulator: %d\n", error);
> >>+
> >>+	max77843_haptic_bias(haptic, false);
> >>+}
> >>+
> >>+static int max77843_haptic_probe(struct platform_device *pdev)
> >>+{
> >>+	struct max77843 *max77843 = dev_get_drvdata(pdev->dev.parent);
> >>+	struct max77843_haptic *haptic;
> >>+	int error;
> >>+
> >>+	haptic = devm_kzalloc(&pdev->dev, sizeof(*haptic), GFP_KERNEL);
> >>+	if (!haptic)
> >>+		return -ENOMEM;
> >>+
> >>+	haptic->regmap_haptic = max77843->regmap;
> >>+	haptic->dev = &pdev->dev;
> >>+	haptic->type = MAX77843_HAPTIC_LRA;
> >>+	haptic->pwm_divisor = MAX77843_HAPTIC_PWM_DIVISOR_128;
> >>+
> >>+	INIT_WORK(&haptic->work, max77843_haptic_play_work);
> >>+	mutex_init(&haptic->mutex);
> >>+
> >>+	haptic->pwm_dev = devm_pwm_get(&pdev->dev, NULL);
> >>+	if (IS_ERR(haptic->pwm_dev)) {
> >>+		dev_err(&pdev->dev, "failed to get pwm device\n");
> >>+		return PTR_ERR(haptic->pwm_dev);
> >>+	}
> >>+
> >>+	haptic->motor_reg = devm_regulator_get_exclusive(&pdev->dev, "haptic");
> >>+	if (IS_ERR(haptic->motor_reg)) {
> >>+		dev_err(&pdev->dev, "failed to get regulator\n");
> >>+		return PTR_ERR(haptic->motor_reg);
> >>+	}
> >>+
> >>+	haptic->input_dev = devm_input_allocate_device(&pdev->dev);
> >>+	if (!haptic->input_dev) {
> >>+		dev_err(&pdev->dev, "failed to allocate input device\n");
> >>+		return -ENOMEM;
> >>+	}
> >>+
> >>+	haptic->input_dev->name = "max77843-haptic";
> >>+	haptic->input_dev->id.version = 1;
> >>+	haptic->input_dev->dev.parent = &pdev->dev;
> >>+	haptic->input_dev->open = max77843_haptic_open;
> >>+	haptic->input_dev->close = max77843_haptic_close;
> >>+	input_set_drvdata(haptic->input_dev, haptic);
> >>+	input_set_capability(haptic->input_dev, EV_FF, FF_RUMBLE);
> >>+
> >>+	error = input_ff_create_memless(haptic->input_dev, NULL,
> >>+			max77843_haptic_play_effect);
> >>+	if (error) {
> >>+		dev_err(&pdev->dev, "failed to create force-feedback\n");
> >>+		return error;
> >>+	}
> >>+
> >>+	error = input_register_device(haptic->input_dev);
> >>+	if (error) {
> >>+		dev_err(&pdev->dev, "failed to register input device\n");
> >>+		return error;
> >>+	}
> >>+
> >>+	platform_set_drvdata(pdev, haptic);
> >>+
> >>+	return 0;
> >>+}
> >>+
> >>+static int __maybe_unused max77843_haptic_suspend(struct device *dev)
> >>+{
> >>+	struct platform_device *pdev = to_platform_device(dev);
> >>+	struct max77843_haptic *haptic = platform_get_drvdata(pdev);
> >>+	int error;
> >>+
> >>+	error = mutex_lock_interruptible(&haptic->mutex);
> >>+	if (error)
> >>+		return error;
> >>+
> >>+	max77843_haptic_disable(haptic);
> >>+
> >>+	haptic->suspended = true;
> >>+
> >>+	mutex_unlock(&haptic->mutex);
> >>+
> >>+	return 0;
> >>+}
> >>+
> >>+static int __maybe_unused max77843_haptic_resume(struct device *dev)
> >>+{
> >>+	struct platform_device *pdev = to_platform_device(dev);
> >>+	struct max77843_haptic *haptic = platform_get_drvdata(pdev);
> >>+	unsigned int magnitude;
> >>+
> >>+	mutex_lock(&haptic->mutex);
> >>+
> >>+	haptic->suspended = false;
> >>+
> >>+	magnitude = ACCESS_ONCE(haptic->magnitude);
> >>+	if (magnitude)
> >>+		max77843_haptic_enable(haptic);
> >>+
> >>+	mutex_unlock(&haptic->mutex);
> >>+
> >>+	return 0;
> >>+}
> >>+
> >>+static SIMPLE_DEV_PM_OPS(max77843_haptic_pm_ops,
> >>+		max77843_haptic_suspend, max77843_haptic_resume);
> >>+
> >>+static struct platform_driver max77843_haptic_driver = {
> >>+	.driver		= {
> >>+		.name	= "max77843-haptic",
> >>+		.pm	= &max77843_haptic_pm_ops,
> >>+	},
> >>+	.probe		= max77843_haptic_probe,
> >>+};
> >>+module_platform_driver(max77843_haptic_driver);
> >>+
> >>+MODULE_AUTHOR("Jaewon Kim <jaewon02.kim@samsung.com>");
> >>+MODULE_DESCRIPTION("MAXIM MAX77843 Haptic driver");
> >>+MODULE_LICENSE("GPL");
> >>-- 
> >>1.7.9.5
> >>
> >Thanks.
> >
> Thanks to review my patch.
> 
> 
> Thanks,
> Jaewon Kim

-- 
Dmitry

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver
  2015-03-02 10:10 ` [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver Jaewon Kim
@ 2015-03-07 20:13   ` Sebastian Reichel
  2015-03-09  0:35     ` Beomho Seo
  0 siblings, 1 reply; 36+ messages in thread
From: Sebastian Reichel @ 2015-03-07 20:13 UTC (permalink / raw)
  To: Jaewon Kim
  Cc: linux-kernel, devicetree, linux-pm, linux-input, Inki Dae,
	SangBae Lee, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, Lee Jones, Chanwoo Choi, Beomho Seo, Dmitry Torokhov

[-- Attachment #1: Type: text/plain, Size: 603 bytes --]

On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
> From: Beomho Seo <beomho.seo@samsung.com>
> 
> This patch adds device driver of max77843 charger. This driver provide
> initialize each charging mode(e.g. fast charge, top-off mode and constant
> charging mode so on.). Additionally, control charging paramters to use
> i2c interface.
> 
> Cc: Sebastian Reichel <sre@kernel.org>
> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>

Reviewed-By: Sebastian Reichel <sre@kernel.org>

I can't take it as is, since it depends on the private header file
of PATCHv1.

-- Sebastian

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 3/5] power: max77843_battery: Add Max77843 fuel gauge device driver
  2015-03-02 10:10 ` [PATCH v7 3/5] power: max77843_battery: Add Max77843 fuel gauge " Jaewon Kim
@ 2015-03-07 20:14   ` Sebastian Reichel
  2015-03-09  0:36     ` Beomho Seo
  0 siblings, 1 reply; 36+ messages in thread
From: Sebastian Reichel @ 2015-03-07 20:14 UTC (permalink / raw)
  To: Jaewon Kim
  Cc: linux-kernel, devicetree, linux-pm, linux-input, Inki Dae,
	SangBae Lee, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, Lee Jones, Chanwoo Choi, Beomho Seo, Dmitry Torokhov

[-- Attachment #1: Type: text/plain, Size: 578 bytes --]

Hi,

On Mon, Mar 02, 2015 at 07:10:36PM +0900, Jaewon Kim wrote:
> From: Beomho Seo <beomho.seo@samsung.com>
> 
> This patch adds device driver of max77843 fuel gauge.
> The driver support for battery fuel gauge in Maxim Max77843.
> It is fuel-gauge systems for lithuum-ion batteries in handled and
> portable devices.
> 
> Cc: Sebastian Reichel <sre@kernel.org>
> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>

Reviewed-By: Sebastian Reichel <sre@kernel.org>

I can't take it as is, since it depends on the private header file
of PATCH 1.

-- Sebastian

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 4/5] Input: add haptic drvier on max77843
  2015-03-04 22:47       ` Dmitry Torokhov
@ 2015-03-07 20:21         ` Sebastian Reichel
  2015-03-08  4:55           ` Dmitry Torokhov
  0 siblings, 1 reply; 36+ messages in thread
From: Sebastian Reichel @ 2015-03-07 20:21 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Jaewon Kim, linux-kernel, devicetree, linux-pm, linux-input,
	Inki Dae, SangBae Lee, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Lee Jones, Chanwoo Choi, Beomho Seo

[-- Attachment #1: Type: text/plain, Size: 603 bytes --]

Hi,

On Wed, Mar 04, 2015 at 02:47:42PM -0800, Dmitry Torokhov wrote:
> [...]
> > >Do you want it to go through my or MFD tree?
> > Other drivers merged in each maintainers git.

Actually only Lee took PATCH 1 so far.

> > If you don`t hava a problem, please merge your input git tree.
> 
> Applied, thank you.

Patches 2-4 depend on linux/mfd/max77843-private.h from Patch 1,
so taking them independently will introduce build problems.

> [...]
> > >>+++ b/drivers/input/misc/max77843-haptic.c
> > >>[...]
> > >>+#include <linux/mfd/max77843-private.h>
> > >>[...]

-- Sebastian

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 4/5] Input: add haptic drvier on max77843
  2015-03-07 20:21         ` Sebastian Reichel
@ 2015-03-08  4:55           ` Dmitry Torokhov
  0 siblings, 0 replies; 36+ messages in thread
From: Dmitry Torokhov @ 2015-03-08  4:55 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Jaewon Kim, linux-kernel, devicetree, linux-pm, linux-input,
	Inki Dae, SangBae Lee, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Lee Jones, Chanwoo Choi, Beomho Seo

On Sat, Mar 07, 2015 at 09:21:02PM +0100, Sebastian Reichel wrote:
> Hi,
> 
> On Wed, Mar 04, 2015 at 02:47:42PM -0800, Dmitry Torokhov wrote:
> > [...]
> > > >Do you want it to go through my or MFD tree?
> > > Other drivers merged in each maintainers git.
> 
> Actually only Lee took PATCH 1 so far.
> 
> > > If you don`t hava a problem, please merge your input git tree.
> > 
> > Applied, thank you.
> 
> Patches 2-4 depend on linux/mfd/max77843-private.h from Patch 1,
> so taking them independently will introduce build problems.

Luckily at least the input driver depends no MFD core so while I agree
that the situation is not ideal it is pretty safe since make *config
will not allow selecting it.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver
  2015-03-07 20:13   ` Sebastian Reichel
@ 2015-03-09  0:35     ` Beomho Seo
  2015-03-09 11:02       ` Krzysztof Kozlowski
  0 siblings, 1 reply; 36+ messages in thread
From: Beomho Seo @ 2015-03-09  0:35 UTC (permalink / raw)
  To: Lee Jones
  Cc: Sebastian Reichel, Jaewon Kim, linux-kernel, devicetree,
	linux-pm, linux-input, Inki Dae, SangBae Lee, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, Chanwoo Choi,
	Dmitry Torokhov

On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
> On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
>> From: Beomho Seo <beomho.seo@samsung.com>
>>
>> This patch adds device driver of max77843 charger. This driver provide
>> initialize each charging mode(e.g. fast charge, top-off mode and constant
>> charging mode so on.). Additionally, control charging paramters to use
>> i2c interface.
>>
>> Cc: Sebastian Reichel <sre@kernel.org>
>> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
> 
> Reviewed-By: Sebastian Reichel <sre@kernel.org>
> 
> I can't take it as is, since it depends on the private header file
> of PATCHv1.
> 
> -- Sebastian
> 

This patch reviewed by Sebastian.
Could you Please merge that your git tree ?

Best regards,
Beomho Seo

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 3/5] power: max77843_battery: Add Max77843 fuel gauge device driver
  2015-03-07 20:14   ` Sebastian Reichel
@ 2015-03-09  0:36     ` Beomho Seo
  2015-03-09 10:01       ` Krzysztof Kozlowski
  0 siblings, 1 reply; 36+ messages in thread
From: Beomho Seo @ 2015-03-09  0:36 UTC (permalink / raw)
  To: Lee Jones
  Cc: Sebastian Reichel, Jaewon Kim, linux-kernel, devicetree,
	linux-pm, linux-input, Inki Dae, SangBae Lee, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, Chanwoo Choi,
	Dmitry Torokhov

On 03/08/2015 05:14 AM, Sebastian Reichel wrote:
> Hi,
> 
> On Mon, Mar 02, 2015 at 07:10:36PM +0900, Jaewon Kim wrote:
>> From: Beomho Seo <beomho.seo@samsung.com>
>>
>> This patch adds device driver of max77843 fuel gauge.
>> The driver support for battery fuel gauge in Maxim Max77843.
>> It is fuel-gauge systems for lithuum-ion batteries in handled and
>> portable devices.
>>
>> Cc: Sebastian Reichel <sre@kernel.org>
>> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
> 
> Reviewed-By: Sebastian Reichel <sre@kernel.org>
> 
> I can't take it as is, since it depends on the private header file
> of PATCH 1.
> 
> -- Sebastian
> 

This patch reviewed by Sebastian.
Could you Please merge that your git tree ?

Best regards,
Beomho Seo

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 3/5] power: max77843_battery: Add Max77843 fuel gauge device driver
  2015-03-09  0:36     ` Beomho Seo
@ 2015-03-09 10:01       ` Krzysztof Kozlowski
  2015-03-10 13:44         ` Beomho Seo
  0 siblings, 1 reply; 36+ messages in thread
From: Krzysztof Kozlowski @ 2015-03-09 10:01 UTC (permalink / raw)
  To: Beomho Seo
  Cc: Lee Jones, Sebastian Reichel, Jaewon Kim, linux-kernel,
	devicetree, linux-pm, linux-input, Inki Dae, SangBae Lee,
	Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Chanwoo Choi, Dmitry Torokhov

2015-03-09 1:36 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
> On 03/08/2015 05:14 AM, Sebastian Reichel wrote:
>> Hi,
>>
>> On Mon, Mar 02, 2015 at 07:10:36PM +0900, Jaewon Kim wrote:
>>> From: Beomho Seo <beomho.seo@samsung.com>
>>>
>>> This patch adds device driver of max77843 fuel gauge.
>>> The driver support for battery fuel gauge in Maxim Max77843.
>>> It is fuel-gauge systems for lithuum-ion batteries in handled and
>>> portable devices.
>>>
>>> Cc: Sebastian Reichel <sre@kernel.org>
>>> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
>>
>> Reviewed-By: Sebastian Reichel <sre@kernel.org>
>>
>> I can't take it as is, since it depends on the private header file
>> of PATCH 1.
>>
>> -- Sebastian
>>
>
> This patch reviewed by Sebastian.
> Could you Please merge that your git tree ?

Hi,

Sorry for late response, but I finally got some time to look at this.
This driver looks very similar to max17042_battery.c fuel gauge
driver. Obtaining some properties looks exactly the same. The
difference seems to be in new properties. The I2C address is the same.

I highly recommend to extend the max17042 driver instead. It already
supports also max17047, max17050 and max77693.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver
  2015-03-09  0:35     ` Beomho Seo
@ 2015-03-09 11:02       ` Krzysztof Kozlowski
  2015-03-09 11:46         ` Beomho Seo
  0 siblings, 1 reply; 36+ messages in thread
From: Krzysztof Kozlowski @ 2015-03-09 11:02 UTC (permalink / raw)
  To: Beomho Seo
  Cc: Lee Jones, Sebastian Reichel, Jaewon Kim, linux-kernel,
	devicetree, linux-pm, linux-input, Inki Dae, SangBae Lee,
	Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Chanwoo Choi, Dmitry Torokhov

2015-03-09 1:35 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
> On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
>> On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
>>> From: Beomho Seo <beomho.seo@samsung.com>
>>>
>>> This patch adds device driver of max77843 charger. This driver provide
>>> initialize each charging mode(e.g. fast charge, top-off mode and constant
>>> charging mode so on.). Additionally, control charging paramters to use
>>> i2c interface.
>>>
>>> Cc: Sebastian Reichel <sre@kernel.org>
>>> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
>>
>> Reviewed-By: Sebastian Reichel <sre@kernel.org>
>>
>> I can't take it as is, since it depends on the private header file
>> of PATCHv1.
>>
>> -- Sebastian
>>
>
> This patch reviewed by Sebastian.
> Could you Please merge that your git tree ?

Hi,

... and again we are adding a new driver for very similar chipset to
already supported. I looked at spec and the charger's registers are
almost the same as for max77693. Their layout and addresses are the
same. I see some minor differences, probably the most important would
be different values current (fast-charge, top-off). But still 90% of
registers are the same... Do we really have to add new driver?

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver
  2015-03-09 11:02       ` Krzysztof Kozlowski
@ 2015-03-09 11:46         ` Beomho Seo
  2015-03-09 12:13           ` Krzysztof Kozlowski
  0 siblings, 1 reply; 36+ messages in thread
From: Beomho Seo @ 2015-03-09 11:46 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Lee Jones, Sebastian Reichel, Jaewon Kim, linux-kernel,
	devicetree, linux-pm, linux-input, Inki Dae, SangBae Lee,
	Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Chanwoo Choi, Dmitry Torokhov

On 03/09/2015 08:02 PM, Krzysztof Kozlowski wrote:
> 2015-03-09 1:35 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
>> On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
>>> On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
>>>> From: Beomho Seo <beomho.seo@samsung.com>
>>>>
>>>> This patch adds device driver of max77843 charger. This driver provide
>>>> initialize each charging mode(e.g. fast charge, top-off mode and constant
>>>> charging mode so on.). Additionally, control charging paramters to use
>>>> i2c interface.
>>>>
>>>> Cc: Sebastian Reichel <sre@kernel.org>
>>>> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
>>>
>>> Reviewed-By: Sebastian Reichel <sre@kernel.org>
>>>
>>> I can't take it as is, since it depends on the private header file
>>> of PATCHv1.
>>>
>>> -- Sebastian
>>>
>>
>> This patch reviewed by Sebastian.
>> Could you Please merge that your git tree ?
> 
> Hi,
> 
> ... and again we are adding a new driver for very similar chipset to
> already supported. I looked at spec and the charger's registers are
> almost the same as for max77693. Their layout and addresses are the
> same. I see some minor differences, probably the most important would
> be different values current (fast-charge, top-off). But still 90% of
> registers are the same... Do we really have to add new driver?
> 
> Best regards,
> Krzysztof
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

Hi,

Thank you for your comment. As you say, both chip set are similar.
But new driver need for support max77843. It is support different below
- Provide Battery presence information.
- Can OTG FET control.
- Bigger Fast charge current, Top Off current Threshold selection.
- Various and bigger OTG current limitation.
- Bigger primary charger termination voltage setting.
- Different maximum input current limit selection(Different step).

I respect your opinion but I think add new driver better.

Best regards,
Beomho Seo



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver
  2015-03-09 11:46         ` Beomho Seo
@ 2015-03-09 12:13           ` Krzysztof Kozlowski
  2015-03-10 13:44             ` Beomho Seo
  0 siblings, 1 reply; 36+ messages in thread
From: Krzysztof Kozlowski @ 2015-03-09 12:13 UTC (permalink / raw)
  To: Beomho Seo
  Cc: Lee Jones, Sebastian Reichel, Jaewon Kim, linux-kernel,
	devicetree, linux-pm, linux-input, Inki Dae, SangBae Lee,
	Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Chanwoo Choi, Dmitry Torokhov

On pon, 2015-03-09 at 20:46 +0900, Beomho Seo wrote:
> On 03/09/2015 08:02 PM, Krzysztof Kozlowski wrote:
> > 2015-03-09 1:35 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
> >> On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
> >>> On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
> >>>> From: Beomho Seo <beomho.seo@samsung.com>
> >>>>
> >>>> This patch adds device driver of max77843 charger. This driver provide
> >>>> initialize each charging mode(e.g. fast charge, top-off mode and constant
> >>>> charging mode so on.). Additionally, control charging paramters to use
> >>>> i2c interface.
> >>>>
> >>>> Cc: Sebastian Reichel <sre@kernel.org>
> >>>> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
> >>>
> >>> Reviewed-By: Sebastian Reichel <sre@kernel.org>
> >>>
> >>> I can't take it as is, since it depends on the private header file
> >>> of PATCHv1.
> >>>
> >>> -- Sebastian
> >>>
> >>
> >> This patch reviewed by Sebastian.
> >> Could you Please merge that your git tree ?
> > 
> > Hi,
> > 
> > ... and again we are adding a new driver for very similar chipset to
> > already supported. I looked at spec and the charger's registers are
> > almost the same as for max77693. Their layout and addresses are the
> > same. I see some minor differences, probably the most important would
> > be different values current (fast-charge, top-off). But still 90% of
> > registers are the same... Do we really have to add new driver?
> > 
> > Best regards,
> > Krzysztof
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-input" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
> 
> Hi,
> 
> Thank you for your comment. As you say, both chip set are similar.
> But new driver need for support max77843. It is support different below
> - Provide Battery presence information.

Another set of power supply properties could be added for that chip.
This way the get_property() function would be the same but actually the
POWER_SUPPLY_PROP_PRESENT won't be called for max77693.

> - Can OTG FET control.

Where the OTG FET feature is it enabled in your driver? I couldn't find
it.

> - Bigger Fast charge current, Top Off current Threshold selection.
> - Various and bigger OTG current limitation.
> - Bigger primary charger termination voltage setting.
> - Different maximum input current limit selection(Different step).

Yes, I mentioned some of these differences (the Fast/top-off
differences). These are differences in values so it does not require new
driver. There is need to develop new driver just to support different
current (3.0 A instead of 2.1 A) or voltage threshold.

So the only new feature - battery presence - can be easily added to
existing driver. The driver can be extended for different
current/voltage values. Such extension may even be beneficial for new
Maxim MUIC/PMIC chipsets.


Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 3/5] power: max77843_battery: Add Max77843 fuel gauge device driver
  2015-03-09 10:01       ` Krzysztof Kozlowski
@ 2015-03-10 13:44         ` Beomho Seo
  2015-03-24  8:02           ` Beomho Seo
  0 siblings, 1 reply; 36+ messages in thread
From: Beomho Seo @ 2015-03-10 13:44 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Lee Jones, Sebastian Reichel, Jaewon Kim, linux-kernel,
	devicetree, linux-pm, linux-input, Inki Dae, SangBae Lee,
	Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Chanwoo Choi, Dmitry Torokhov

On 03/09/2015 07:01 PM, Krzysztof Kozlowski wrote:
> 2015-03-09 1:36 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
>> On 03/08/2015 05:14 AM, Sebastian Reichel wrote:
>>> Hi,
>>>
>>> On Mon, Mar 02, 2015 at 07:10:36PM +0900, Jaewon Kim wrote:
>>>> From: Beomho Seo <beomho.seo@samsung.com>
>>>>
>>>> This patch adds device driver of max77843 fuel gauge.
>>>> The driver support for battery fuel gauge in Maxim Max77843.
>>>> It is fuel-gauge systems for lithuum-ion batteries in handled and
>>>> portable devices.
>>>>
>>>> Cc: Sebastian Reichel <sre@kernel.org>
>>>> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
>>>
>>> Reviewed-By: Sebastian Reichel <sre@kernel.org>
>>>
>>> I can't take it as is, since it depends on the private header file
>>> of PATCH 1.
>>>
>>> -- Sebastian
>>>
>>
>> This patch reviewed by Sebastian.
>> Could you Please merge that your git tree ?
> 
> Hi,
> 
> Sorry for late response, but I finally got some time to look at this.
> This driver looks very similar to max17042_battery.c fuel gauge
> driver. Obtaining some properties looks exactly the same. The
> difference seems to be in new properties. The I2C address is the same.
> 
> I highly recommend to extend the max17042 driver instead. It already
> supports also max17047, max17050 and max77693.
> 
> Best regards,
> Krzysztof
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

OK. I will follow your opinion about fuel gauge. I will extend the max17042 driver.
After test on my board, I will send a new patch set.

Best regards,
Beomho Seo

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver
  2015-03-09 12:13           ` Krzysztof Kozlowski
@ 2015-03-10 13:44             ` Beomho Seo
  2015-03-24  8:01               ` Beomho Seo
  0 siblings, 1 reply; 36+ messages in thread
From: Beomho Seo @ 2015-03-10 13:44 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Lee Jones, Sebastian Reichel, Jaewon Kim, linux-kernel,
	devicetree, linux-pm, linux-input, Inki Dae, SangBae Lee,
	Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Chanwoo Choi, Dmitry Torokhov

On 03/09/2015 09:13 PM, Krzysztof Kozlowski wrote:
> On pon, 2015-03-09 at 20:46 +0900, Beomho Seo wrote:
>> On 03/09/2015 08:02 PM, Krzysztof Kozlowski wrote:
>>> 2015-03-09 1:35 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
>>>> On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
>>>>> On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
>>>>>> From: Beomho Seo <beomho.seo@samsung.com>
>>>>>>
>>>>>> This patch adds device driver of max77843 charger. This driver provide
>>>>>> initialize each charging mode(e.g. fast charge, top-off mode and constant
>>>>>> charging mode so on.). Additionally, control charging paramters to use
>>>>>> i2c interface.
>>>>>>
>>>>>> Cc: Sebastian Reichel <sre@kernel.org>
>>>>>> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
>>>>>
>>>>> Reviewed-By: Sebastian Reichel <sre@kernel.org>
>>>>>
>>>>> I can't take it as is, since it depends on the private header file
>>>>> of PATCHv1.
>>>>>
>>>>> -- Sebastian
>>>>>
>>>>
>>>> This patch reviewed by Sebastian.
>>>> Could you Please merge that your git tree ?
>>>
>>> Hi,
>>>
>>> ... and again we are adding a new driver for very similar chipset to
>>> already supported. I looked at spec and the charger's registers are
>>> almost the same as for max77693. Their layout and addresses are the
>>> same. I see some minor differences, probably the most important would
>>> be different values current (fast-charge, top-off). But still 90% of
>>> registers are the same... Do we really have to add new driver?
>>>
>>> Best regards,
>>> Krzysztof
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-input" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>
>>
>> Hi,
>>
>> Thank you for your comment. As you say, both chip set are similar.
>> But new driver need for support max77843. It is support different below
>> - Provide Battery presence information.
> 
> Another set of power supply properties could be added for that chip.
> This way the get_property() function would be the same but actually the
> POWER_SUPPLY_PROP_PRESENT won't be called for max77693.
> 
>> - Can OTG FET control.
> 
> Where the OTG FET feature is it enabled in your driver? I couldn't find
> it.
> 

Sorry. This driver don't control OTG FET feature.

>> - Bigger Fast charge current, Top Off current Threshold selection.
>> - Various and bigger OTG current limitation.
>> - Bigger primary charger termination voltage setting.
>> - Different maximum input current limit selection(Different step).
> 
> Yes, I mentioned some of these differences (the Fast/top-off
> differences). These are differences in values so it does not require new
> driver. There is need to develop new driver just to support different
> current (3.0 A instead of 2.1 A) or voltage threshold.
> 

They are different charging current, OTG current limitation, top off current,
charging limitation value. In case OTG current limitation different not
limitation value but using register bit(max77843 use[7:6] max77693 use[7]
bit only). Even if this driver not support all feature, some register
different with max77693(support value, use register bit).

If this driver will combined with max77693 may even be beneficial for
new Maxim driver. But the present, this driver is related with
max77843 core driver and max77843-regulator. So I hope this driver
merge first. And then will extend two driver(max77843 charger and max77693 charger).

> So the only new feature - battery presence - can be easily added to
> existing driver. The driver can be extended for different
> current/voltage values. Such extension may even be beneficial for new
> Maxim MUIC/PMIC chipsets.
> 
> 
> Best regards,
> Krzysztof
> 

Best regards,
Beomho Seo

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver
  2015-03-10 13:44             ` Beomho Seo
@ 2015-03-24  8:01               ` Beomho Seo
  2015-03-24  8:38                 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 36+ messages in thread
From: Beomho Seo @ 2015-03-24  8:01 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Lee Jones, Sebastian Reichel, Jaewon Kim, linux-kernel,
	devicetree, linux-pm, linux-input, Inki Dae, SangBae Lee,
	Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Chanwoo Choi, Dmitry Torokhov

On 03/10/2015 10:44 PM, Beomho Seo wrote:
> On 03/09/2015 09:13 PM, Krzysztof Kozlowski wrote:
>> On pon, 2015-03-09 at 20:46 +0900, Beomho Seo wrote:
>>> On 03/09/2015 08:02 PM, Krzysztof Kozlowski wrote:
>>>> 2015-03-09 1:35 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
>>>>> On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
>>>>>> On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
>>>>>>> From: Beomho Seo <beomho.seo@samsung.com>
>>>>>>>
>>>>>>> This patch adds device driver of max77843 charger. This driver provide
>>>>>>> initialize each charging mode(e.g. fast charge, top-off mode and constant
>>>>>>> charging mode so on.). Additionally, control charging paramters to use
>>>>>>> i2c interface.
>>>>>>>
>>>>>>> Cc: Sebastian Reichel <sre@kernel.org>
>>>>>>> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
>>>>>>
>>>>>> Reviewed-By: Sebastian Reichel <sre@kernel.org>
>>>>>>
>>>>>> I can't take it as is, since it depends on the private header file
>>>>>> of PATCHv1.
>>>>>>
>>>>>> -- Sebastian
>>>>>>
>>>>>
>>>>> This patch reviewed by Sebastian.
>>>>> Could you Please merge that your git tree ?
>>>>
>>>> Hi,
>>>>
>>>> ... and again we are adding a new driver for very similar chipset to
>>>> already supported. I looked at spec and the charger's registers are
>>>> almost the same as for max77693. Their layout and addresses are the
>>>> same. I see some minor differences, probably the most important would
>>>> be different values current (fast-charge, top-off). But still 90% of
>>>> registers are the same... Do we really have to add new driver?
>>>>
>>>> Best regards,
>>>> Krzysztof
>>>> --
>>>> To unsubscribe from this list: send the line "unsubscribe linux-input" in
>>>> the body of a message to majordomo@vger.kernel.org
>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>>
>>>
>>> Hi,
>>>
>>> Thank you for your comment. As you say, both chip set are similar.
>>> But new driver need for support max77843. It is support different below
>>> - Provide Battery presence information.
>>
>> Another set of power supply properties could be added for that chip.
>> This way the get_property() function would be the same but actually the
>> POWER_SUPPLY_PROP_PRESENT won't be called for max77693.
>>
>>> - Can OTG FET control.
>>
>> Where the OTG FET feature is it enabled in your driver? I couldn't find
>> it.
>>
> 
> Sorry. This driver don't control OTG FET feature.
> 
>>> - Bigger Fast charge current, Top Off current Threshold selection.
>>> - Various and bigger OTG current limitation.
>>> - Bigger primary charger termination voltage setting.
>>> - Different maximum input current limit selection(Different step).
>>
>> Yes, I mentioned some of these differences (the Fast/top-off
>> differences). These are differences in values so it does not require new
>> driver. There is need to develop new driver just to support different
>> current (3.0 A instead of 2.1 A) or voltage threshold.
>>
> 
> They are different charging current, OTG current limitation, top off current,
> charging limitation value. In case OTG current limitation different not
> limitation value but using register bit(max77843 use[7:6] max77693 use[7]
> bit only). Even if this driver not support all feature, some register
> different with max77693(support value, use register bit).
> 
> If this driver will combined with max77693 may even be beneficial for
> new Maxim driver. But the present, this driver is related with
> max77843 core driver and max77843-regulator. So I hope this driver
> merge first. And then will extend two driver(max77843 charger and max77693 charger).
> 
>> So the only new feature - battery presence - can be easily added to
>> existing driver. The driver can be extended for different
>> current/voltage values. Such extension may even be beneficial for new
>> Maxim MUIC/PMIC chipsets.
>>
>>
>> Best regards,
>> Krzysztof
>>
> 
> Best regards,
> Beomho Seo

Krzysztof, gentle ping?

Best regards,
Beomho Seo


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 3/5] power: max77843_battery: Add Max77843 fuel gauge device driver
  2015-03-10 13:44         ` Beomho Seo
@ 2015-03-24  8:02           ` Beomho Seo
  2015-03-24  8:39             ` Krzysztof Kozlowski
  0 siblings, 1 reply; 36+ messages in thread
From: Beomho Seo @ 2015-03-24  8:02 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Lee Jones, Sebastian Reichel, Jaewon Kim, linux-kernel,
	devicetree, linux-pm, linux-input, Inki Dae, SangBae Lee,
	Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Chanwoo Choi, Dmitry Torokhov

On 03/10/2015 10:44 PM, Beomho Seo wrote:
> On 03/09/2015 07:01 PM, Krzysztof Kozlowski wrote:
>> 2015-03-09 1:36 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
>>> On 03/08/2015 05:14 AM, Sebastian Reichel wrote:
>>>> Hi,
>>>>
>>>> On Mon, Mar 02, 2015 at 07:10:36PM +0900, Jaewon Kim wrote:
>>>>> From: Beomho Seo <beomho.seo@samsung.com>
>>>>>
>>>>> This patch adds device driver of max77843 fuel gauge.
>>>>> The driver support for battery fuel gauge in Maxim Max77843.
>>>>> It is fuel-gauge systems for lithuum-ion batteries in handled and
>>>>> portable devices.
>>>>>
>>>>> Cc: Sebastian Reichel <sre@kernel.org>
>>>>> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
>>>>
>>>> Reviewed-By: Sebastian Reichel <sre@kernel.org>
>>>>
>>>> I can't take it as is, since it depends on the private header file
>>>> of PATCH 1.
>>>>
>>>> -- Sebastian
>>>>
>>>
>>> This patch reviewed by Sebastian.
>>> Could you Please merge that your git tree ?
>>
>> Hi,
>>
>> Sorry for late response, but I finally got some time to look at this.
>> This driver looks very similar to max17042_battery.c fuel gauge
>> driver. Obtaining some properties looks exactly the same. The
>> difference seems to be in new properties. The I2C address is the same.
>>
>> I highly recommend to extend the max17042 driver instead. It already
>> supports also max17047, max17050 and max77693.
>>
>> Best regards,
>> Krzysztof
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
> 
> OK. I will follow your opinion about fuel gauge. I will extend the max17042 driver.
> After test on my board, I will send a new patch set.
> 
> Best regards,
> Beomho Seo

Krzysztof, gentle ping?

I will extend the max17042 driver.

Best regards,
Beomho Seo


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver
  2015-03-24  8:01               ` Beomho Seo
@ 2015-03-24  8:38                 ` Krzysztof Kozlowski
  2015-03-25  0:39                   ` Beomho Seo
  2015-03-26 13:25                   ` Beomho Seo
  0 siblings, 2 replies; 36+ messages in thread
From: Krzysztof Kozlowski @ 2015-03-24  8:38 UTC (permalink / raw)
  To: Beomho Seo
  Cc: Krzysztof Kozlowski, Lee Jones, Sebastian Reichel, Jaewon Kim,
	linux-kernel, devicetree, linux-pm, linux-input, Inki Dae,
	SangBae Lee, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, Chanwoo Choi, Dmitry Torokhov

2015-03-24 9:01 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
> On 03/10/2015 10:44 PM, Beomho Seo wrote:
>> On 03/09/2015 09:13 PM, Krzysztof Kozlowski wrote:
>>> On pon, 2015-03-09 at 20:46 +0900, Beomho Seo wrote:
>>>> On 03/09/2015 08:02 PM, Krzysztof Kozlowski wrote:
>>>>> 2015-03-09 1:35 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
>>>>>> On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
>>>>>>> On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
>>>>>>>> From: Beomho Seo <beomho.seo@samsung.com>
>>>>>>>>
>>>>>>>> This patch adds device driver of max77843 charger. This driver provide
>>>>>>>> initialize each charging mode(e.g. fast charge, top-off mode and constant
>>>>>>>> charging mode so on.). Additionally, control charging paramters to use
>>>>>>>> i2c interface.
>>>>>>>>
>>>>>>>> Cc: Sebastian Reichel <sre@kernel.org>
>>>>>>>> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
>>>>>>>
>>>>>>> Reviewed-By: Sebastian Reichel <sre@kernel.org>
>>>>>>>
>>>>>>> I can't take it as is, since it depends on the private header file
>>>>>>> of PATCHv1.
>>>>>>>
>>>>>>> -- Sebastian
>>>>>>>
>>>>>>
>>>>>> This patch reviewed by Sebastian.
>>>>>> Could you Please merge that your git tree ?
>>>>>
>>>>> Hi,
>>>>>
>>>>> ... and again we are adding a new driver for very similar chipset to
>>>>> already supported. I looked at spec and the charger's registers are
>>>>> almost the same as for max77693. Their layout and addresses are the
>>>>> same. I see some minor differences, probably the most important would
>>>>> be different values current (fast-charge, top-off). But still 90% of
>>>>> registers are the same... Do we really have to add new driver?
>>>>>
>>>>> Best regards,
>>>>> Krzysztof
>>>>> --
>>>>> To unsubscribe from this list: send the line "unsubscribe linux-input" in
>>>>> the body of a message to majordomo@vger.kernel.org
>>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>>>
>>>>
>>>> Hi,
>>>>
>>>> Thank you for your comment. As you say, both chip set are similar.
>>>> But new driver need for support max77843. It is support different below
>>>> - Provide Battery presence information.
>>>
>>> Another set of power supply properties could be added for that chip.
>>> This way the get_property() function would be the same but actually the
>>> POWER_SUPPLY_PROP_PRESENT won't be called for max77693.
>>>
>>>> - Can OTG FET control.
>>>
>>> Where the OTG FET feature is it enabled in your driver? I couldn't find
>>> it.
>>>
>>
>> Sorry. This driver don't control OTG FET feature.
>>
>>>> - Bigger Fast charge current, Top Off current Threshold selection.
>>>> - Various and bigger OTG current limitation.
>>>> - Bigger primary charger termination voltage setting.
>>>> - Different maximum input current limit selection(Different step).
>>>
>>> Yes, I mentioned some of these differences (the Fast/top-off
>>> differences). These are differences in values so it does not require new
>>> driver. There is need to develop new driver just to support different
>>> current (3.0 A instead of 2.1 A) or voltage threshold.
>>>
>>
>> They are different charging current, OTG current limitation, top off current,
>> charging limitation value. In case OTG current limitation different not
>> limitation value but using register bit(max77843 use[7:6] max77693 use[7]
>> bit only). Even if this driver not support all feature, some register
>> different with max77693(support value, use register bit).
>>
>> If this driver will combined with max77693 may even be beneficial for
>> new Maxim driver. But the present, this driver is related with
>> max77843 core driver and max77843-regulator. So I hope this driver
>> merge first. And then will extend two driver(max77843 charger and max77693 charger).

I still prefer merging common drivers into one instead of creating
some more of them.
However I understand your point and I am not entirely opposed against.
Especially that you invested quite a bit of time for developing this
and my feedback was quite late. To summarize I am fine with your
approach.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 3/5] power: max77843_battery: Add Max77843 fuel gauge device driver
  2015-03-24  8:02           ` Beomho Seo
@ 2015-03-24  8:39             ` Krzysztof Kozlowski
  0 siblings, 0 replies; 36+ messages in thread
From: Krzysztof Kozlowski @ 2015-03-24  8:39 UTC (permalink / raw)
  To: Beomho Seo
  Cc: Krzysztof Kozlowski, Lee Jones, Sebastian Reichel, Jaewon Kim,
	linux-kernel, devicetree, linux-pm, linux-input, Inki Dae,
	SangBae Lee, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, Chanwoo Choi, Dmitry Torokhov

2015-03-24 9:02 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
> On 03/10/2015 10:44 PM, Beomho Seo wrote:
>> On 03/09/2015 07:01 PM, Krzysztof Kozlowski wrote:
>>> 2015-03-09 1:36 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
>>>> On 03/08/2015 05:14 AM, Sebastian Reichel wrote:
>>>>> Hi,
>>>>>
>>>>> On Mon, Mar 02, 2015 at 07:10:36PM +0900, Jaewon Kim wrote:
>>>>>> From: Beomho Seo <beomho.seo@samsung.com>
>>>>>>
>>>>>> This patch adds device driver of max77843 fuel gauge.
>>>>>> The driver support for battery fuel gauge in Maxim Max77843.
>>>>>> It is fuel-gauge systems for lithuum-ion batteries in handled and
>>>>>> portable devices.
>>>>>>
>>>>>> Cc: Sebastian Reichel <sre@kernel.org>
>>>>>> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
>>>>>
>>>>> Reviewed-By: Sebastian Reichel <sre@kernel.org>
>>>>>
>>>>> I can't take it as is, since it depends on the private header file
>>>>> of PATCH 1.
>>>>>
>>>>> -- Sebastian
>>>>>
>>>>
>>>> This patch reviewed by Sebastian.
>>>> Could you Please merge that your git tree ?
>>>
>>> Hi,
>>>
>>> Sorry for late response, but I finally got some time to look at this.
>>> This driver looks very similar to max17042_battery.c fuel gauge
>>> driver. Obtaining some properties looks exactly the same. The
>>> difference seems to be in new properties. The I2C address is the same.
>>>
>>> I highly recommend to extend the max17042 driver instead. It already
>>> supports also max17047, max17050 and max77693.
>>>
>>> Best regards,
>>> Krzysztof
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>
>>
>> OK. I will follow your opinion about fuel gauge. I will extend the max17042 driver.
>> After test on my board, I will send a new patch set.
>>
>> Best regards,
>> Beomho Seo
>
> Krzysztof, gentle ping?
>
> I will extend the max17042 driver.

That would be great, thanks1

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver
  2015-03-24  8:38                 ` Krzysztof Kozlowski
@ 2015-03-25  0:39                   ` Beomho Seo
  2015-03-26  7:16                     ` Krzysztof Kozlowski
  2015-03-26 13:25                   ` Beomho Seo
  1 sibling, 1 reply; 36+ messages in thread
From: Beomho Seo @ 2015-03-25  0:39 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Lee Jones, Sebastian Reichel, Jaewon Kim, linux-kernel,
	devicetree, linux-pm, linux-input, Inki Dae, SangBae Lee,
	Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Chanwoo Choi, Dmitry Torokhov

On 03/24/2015 05:38 PM, Krzysztof Kozlowski wrote:
> 2015-03-24 9:01 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
>> On 03/10/2015 10:44 PM, Beomho Seo wrote:
>>> On 03/09/2015 09:13 PM, Krzysztof Kozlowski wrote:
>>>> On pon, 2015-03-09 at 20:46 +0900, Beomho Seo wrote:
>>>>> On 03/09/2015 08:02 PM, Krzysztof Kozlowski wrote:
>>>>>> 2015-03-09 1:35 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
>>>>>>> On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
>>>>>>>> On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
>>>>>>>>> From: Beomho Seo <beomho.seo@samsung.com>
>>>>>>>>>
>>>>>>>>> This patch adds device driver of max77843 charger. This driver provide
>>>>>>>>> initialize each charging mode(e.g. fast charge, top-off mode and constant
>>>>>>>>> charging mode so on.). Additionally, control charging paramters to use
>>>>>>>>> i2c interface.
>>>>>>>>>
>>>>>>>>> Cc: Sebastian Reichel <sre@kernel.org>
>>>>>>>>> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
>>>>>>>>
>>>>>>>> Reviewed-By: Sebastian Reichel <sre@kernel.org>
>>>>>>>>
>>>>>>>> I can't take it as is, since it depends on the private header file
>>>>>>>> of PATCHv1.
>>>>>>>>
>>>>>>>> -- Sebastian
>>>>>>>>
>>>>>>>
>>>>>>> This patch reviewed by Sebastian.
>>>>>>> Could you Please merge that your git tree ?
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> ... and again we are adding a new driver for very similar chipset to
>>>>>> already supported. I looked at spec and the charger's registers are
>>>>>> almost the same as for max77693. Their layout and addresses are the
>>>>>> same. I see some minor differences, probably the most important would
>>>>>> be different values current (fast-charge, top-off). But still 90% of
>>>>>> registers are the same... Do we really have to add new driver?
>>>>>>
>>>>>> Best regards,
>>>>>> Krzysztof
>>>>>> --
>>>>>> To unsubscribe from this list: send the line "unsubscribe linux-input" in
>>>>>> the body of a message to majordomo@vger.kernel.org
>>>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> Thank you for your comment. As you say, both chip set are similar.
>>>>> But new driver need for support max77843. It is support different below
>>>>> - Provide Battery presence information.
>>>>
>>>> Another set of power supply properties could be added for that chip.
>>>> This way the get_property() function would be the same but actually the
>>>> POWER_SUPPLY_PROP_PRESENT won't be called for max77693.
>>>>
>>>>> - Can OTG FET control.
>>>>
>>>> Where the OTG FET feature is it enabled in your driver? I couldn't find
>>>> it.
>>>>
>>>
>>> Sorry. This driver don't control OTG FET feature.
>>>
>>>>> - Bigger Fast charge current, Top Off current Threshold selection.
>>>>> - Various and bigger OTG current limitation.
>>>>> - Bigger primary charger termination voltage setting.
>>>>> - Different maximum input current limit selection(Different step).
>>>>
>>>> Yes, I mentioned some of these differences (the Fast/top-off
>>>> differences). These are differences in values so it does not require new
>>>> driver. There is need to develop new driver just to support different
>>>> current (3.0 A instead of 2.1 A) or voltage threshold.
>>>>
>>>
>>> They are different charging current, OTG current limitation, top off current,
>>> charging limitation value. In case OTG current limitation different not
>>> limitation value but using register bit(max77843 use[7:6] max77693 use[7]
>>> bit only). Even if this driver not support all feature, some register
>>> different with max77693(support value, use register bit).
>>>
>>> If this driver will combined with max77693 may even be beneficial for
>>> new Maxim driver. But the present, this driver is related with
>>> max77843 core driver and max77843-regulator. So I hope this driver
>>> merge first. And then will extend two driver(max77843 charger and max77693 charger).
> 
> I still prefer merging common drivers into one instead of creating
> some more of them.
> However I understand your point and I am not entirely opposed against.
> Especially that you invested quite a bit of time for developing this
> and my feedback was quite late. To summarize I am fine with your
> approach.
> 
> Best regards,
> Krzysztof
> 

Then, Can I request merge this patch ?

Best regards,
Beomho

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver
  2015-03-25  0:39                   ` Beomho Seo
@ 2015-03-26  7:16                     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 36+ messages in thread
From: Krzysztof Kozlowski @ 2015-03-26  7:16 UTC (permalink / raw)
  To: Beomho Seo
  Cc: Krzysztof Kozlowski, Lee Jones, Sebastian Reichel, Jaewon Kim,
	linux-kernel, devicetree, linux-pm, linux-input, Inki Dae,
	SangBae Lee, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, Chanwoo Choi, Dmitry Torokhov

2015-03-25 1:39 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
>
> Then, Can I request merge this patch ?

Yes, but it is not up to me :).

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver
  2015-03-24  8:38                 ` Krzysztof Kozlowski
  2015-03-25  0:39                   ` Beomho Seo
@ 2015-03-26 13:25                   ` Beomho Seo
  2015-03-26 13:54                     ` Lee Jones
  1 sibling, 1 reply; 36+ messages in thread
From: Beomho Seo @ 2015-03-26 13:25 UTC (permalink / raw)
  To: Lee Jones
  Cc: Krzysztof Kozlowski, Sebastian Reichel, Jaewon Kim, linux-kernel,
	devicetree, linux-pm, linux-input, Inki Dae, SangBae Lee,
	Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Chanwoo Choi, Dmitry Torokhov

On 03/24/2015 05:38 PM, Krzysztof Kozlowski wrote:
> 2015-03-24 9:01 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
>> On 03/10/2015 10:44 PM, Beomho Seo wrote:
>>> On 03/09/2015 09:13 PM, Krzysztof Kozlowski wrote:
>>>> On pon, 2015-03-09 at 20:46 +0900, Beomho Seo wrote:
>>>>> On 03/09/2015 08:02 PM, Krzysztof Kozlowski wrote:
>>>>>> 2015-03-09 1:35 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
>>>>>>> On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
>>>>>>>> On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
>>>>>>>>> From: Beomho Seo <beomho.seo@samsung.com>
>>>>>>>>>
>>>>>>>>> This patch adds device driver of max77843 charger. This driver provide
>>>>>>>>> initialize each charging mode(e.g. fast charge, top-off mode and constant
>>>>>>>>> charging mode so on.). Additionally, control charging paramters to use
>>>>>>>>> i2c interface.
>>>>>>>>>
>>>>>>>>> Cc: Sebastian Reichel <sre@kernel.org>
>>>>>>>>> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
>>>>>>>>
>>>>>>>> Reviewed-By: Sebastian Reichel <sre@kernel.org>
>>>>>>>>
>>>>>>>> I can't take it as is, since it depends on the private header file
>>>>>>>> of PATCHv1.
>>>>>>>>
>>>>>>>> -- Sebastian
>>>>>>>>
>>>>>>>
>>>>>>> This patch reviewed by Sebastian.
>>>>>>> Could you Please merge that your git tree ?
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> ... and again we are adding a new driver for very similar chipset to
>>>>>> already supported. I looked at spec and the charger's registers are
>>>>>> almost the same as for max77693. Their layout and addresses are the
>>>>>> same. I see some minor differences, probably the most important would
>>>>>> be different values current (fast-charge, top-off). But still 90% of
>>>>>> registers are the same... Do we really have to add new driver?
>>>>>>
>>>>>> Best regards,
>>>>>> Krzysztof
>>>>>> --
>>>>>> To unsubscribe from this list: send the line "unsubscribe linux-input" in
>>>>>> the body of a message to majordomo@vger.kernel.org
>>>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> Thank you for your comment. As you say, both chip set are similar.
>>>>> But new driver need for support max77843. It is support different below
>>>>> - Provide Battery presence information.
>>>>
>>>> Another set of power supply properties could be added for that chip.
>>>> This way the get_property() function would be the same but actually the
>>>> POWER_SUPPLY_PROP_PRESENT won't be called for max77693.
>>>>
>>>>> - Can OTG FET control.
>>>>
>>>> Where the OTG FET feature is it enabled in your driver? I couldn't find
>>>> it.
>>>>
>>>
>>> Sorry. This driver don't control OTG FET feature.
>>>
>>>>> - Bigger Fast charge current, Top Off current Threshold selection.
>>>>> - Various and bigger OTG current limitation.
>>>>> - Bigger primary charger termination voltage setting.
>>>>> - Different maximum input current limit selection(Different step).
>>>>
>>>> Yes, I mentioned some of these differences (the Fast/top-off
>>>> differences). These are differences in values so it does not require new
>>>> driver. There is need to develop new driver just to support different
>>>> current (3.0 A instead of 2.1 A) or voltage threshold.
>>>>
>>>
>>> They are different charging current, OTG current limitation, top off current,
>>> charging limitation value. In case OTG current limitation different not
>>> limitation value but using register bit(max77843 use[7:6] max77693 use[7]
>>> bit only). Even if this driver not support all feature, some register
>>> different with max77693(support value, use register bit).
>>>
>>> If this driver will combined with max77693 may even be beneficial for
>>> new Maxim driver. But the present, this driver is related with
>>> max77843 core driver and max77843-regulator. So I hope this driver
>>> merge first. And then will extend two driver(max77843 charger and max77693 charger).
> 
> I still prefer merging common drivers into one instead of creating
> some more of them.
> However I understand your point and I am not entirely opposed against.
> Especially that you invested quite a bit of time for developing this
> and my feedback was quite late. To summarize I am fine with your
> approach.
> 
> Best regards,
> Krzysztof
>

Dear Lee Jones,

Could you please merge that your git tree ?

Best regards,
Beomho Seo

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver
  2015-03-26 13:25                   ` Beomho Seo
@ 2015-03-26 13:54                     ` Lee Jones
  2015-03-26 23:49                       ` Beomho Seo
  0 siblings, 1 reply; 36+ messages in thread
From: Lee Jones @ 2015-03-26 13:54 UTC (permalink / raw)
  To: Beomho Seo
  Cc: Krzysztof Kozlowski, Sebastian Reichel, Jaewon Kim, linux-kernel,
	devicetree, linux-pm, linux-input, Inki Dae, SangBae Lee,
	Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Chanwoo Choi, Dmitry Torokhov

On Thu, 26 Mar 2015, Beomho Seo wrote:
> On 03/24/2015 05:38 PM, Krzysztof Kozlowski wrote:
> > 2015-03-24 9:01 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
> >> On 03/10/2015 10:44 PM, Beomho Seo wrote:
> >>> On 03/09/2015 09:13 PM, Krzysztof Kozlowski wrote:
> >>>> On pon, 2015-03-09 at 20:46 +0900, Beomho Seo wrote:
> >>>>> On 03/09/2015 08:02 PM, Krzysztof Kozlowski wrote:
> >>>>>> 2015-03-09 1:35 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
> >>>>>>> On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
> >>>>>>>> On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
> >>>>>>>>> From: Beomho Seo <beomho.seo@samsung.com>
> >>>>>>>>>
> >>>>>>>>> This patch adds device driver of max77843 charger. This driver provide
> >>>>>>>>> initialize each charging mode(e.g. fast charge, top-off mode and constant
> >>>>>>>>> charging mode so on.). Additionally, control charging paramters to use
> >>>>>>>>> i2c interface.
> >>>>>>>>>
> >>>>>>>>> Cc: Sebastian Reichel <sre@kernel.org>
> >>>>>>>>> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
> >>>>>>>>
> >>>>>>>> Reviewed-By: Sebastian Reichel <sre@kernel.org>
> >>>>>>>>
> >>>>>>>> I can't take it as is, since it depends on the private header file
> >>>>>>>> of PATCHv1.
> >>>>>>>>
> >>>>>>>> -- Sebastian
> >>>>>>>>
> >>>>>>>
> >>>>>>> This patch reviewed by Sebastian.
> >>>>>>> Could you Please merge that your git tree ?
> >>>>>>
> >>>>>> Hi,
> >>>>>>
> >>>>>> ... and again we are adding a new driver for very similar chipset to
> >>>>>> already supported. I looked at spec and the charger's registers are
> >>>>>> almost the same as for max77693. Their layout and addresses are the
> >>>>>> same. I see some minor differences, probably the most important would
> >>>>>> be different values current (fast-charge, top-off). But still 90% of
> >>>>>> registers are the same... Do we really have to add new driver?
> >>>>>>
> >>>>>> Best regards,
> >>>>>> Krzysztof
> >>>>>>
> >>>>>
> >>>>> Hi,
> >>>>>
> >>>>> Thank you for your comment. As you say, both chip set are similar.
> >>>>> But new driver need for support max77843. It is support different below
> >>>>> - Provide Battery presence information.
> >>>>
> >>>> Another set of power supply properties could be added for that chip.
> >>>> This way the get_property() function would be the same but actually the
> >>>> POWER_SUPPLY_PROP_PRESENT won't be called for max77693.
> >>>>
> >>>>> - Can OTG FET control.
> >>>>
> >>>> Where the OTG FET feature is it enabled in your driver? I couldn't find
> >>>> it.
> >>>>
> >>>
> >>> Sorry. This driver don't control OTG FET feature.
> >>>
> >>>>> - Bigger Fast charge current, Top Off current Threshold selection.
> >>>>> - Various and bigger OTG current limitation.
> >>>>> - Bigger primary charger termination voltage setting.
> >>>>> - Different maximum input current limit selection(Different step).
> >>>>
> >>>> Yes, I mentioned some of these differences (the Fast/top-off
> >>>> differences). These are differences in values so it does not require new
> >>>> driver. There is need to develop new driver just to support different
> >>>> current (3.0 A instead of 2.1 A) or voltage threshold.
> >>>>
> >>>
> >>> They are different charging current, OTG current limitation, top off current,
> >>> charging limitation value. In case OTG current limitation different not
> >>> limitation value but using register bit(max77843 use[7:6] max77693 use[7]
> >>> bit only). Even if this driver not support all feature, some register
> >>> different with max77693(support value, use register bit).
> >>>
> >>> If this driver will combined with max77693 may even be beneficial for
> >>> new Maxim driver. But the present, this driver is related with
> >>> max77843 core driver and max77843-regulator. So I hope this driver
> >>> merge first. And then will extend two driver(max77843 charger and max77693 charger).
> > 
> > I still prefer merging common drivers into one instead of creating
> > some more of them.
> > However I understand your point and I am not entirely opposed against.
> > Especially that you invested quite a bit of time for developing this
> > and my feedback was quite late. To summarize I am fine with your
> > approach.
> > 
> > Best regards,
> > Krzysztof
> >
> 
> Dear Lee Jones,
> 
> Could you please merge that your git tree ?

Sorry, I'm lost.  Why am I taking this though the MFD tree?  What
patches are left?  Where are they going?  Am I taking any other
patches?

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver
  2015-03-26 13:54                     ` Lee Jones
@ 2015-03-26 23:49                       ` Beomho Seo
  2015-03-27  7:57                         ` Lee Jones
  0 siblings, 1 reply; 36+ messages in thread
From: Beomho Seo @ 2015-03-26 23:49 UTC (permalink / raw)
  To: Lee Jones
  Cc: Krzysztof Kozlowski, Sebastian Reichel, Jaewon Kim, linux-kernel,
	devicetree, linux-pm, linux-input, Inki Dae, SangBae Lee,
	Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Chanwoo Choi, Dmitry Torokhov

On 03/26/2015 10:54 PM, Lee Jones wrote:
> On Thu, 26 Mar 2015, Beomho Seo wrote:
>> On 03/24/2015 05:38 PM, Krzysztof Kozlowski wrote:
>>> 2015-03-24 9:01 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
>>>> On 03/10/2015 10:44 PM, Beomho Seo wrote:
>>>>> On 03/09/2015 09:13 PM, Krzysztof Kozlowski wrote:
>>>>>> On pon, 2015-03-09 at 20:46 +0900, Beomho Seo wrote:
>>>>>>> On 03/09/2015 08:02 PM, Krzysztof Kozlowski wrote:
>>>>>>>> 2015-03-09 1:35 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
>>>>>>>>> On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
>>>>>>>>>> On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
>>>>>>>>>>> From: Beomho Seo <beomho.seo@samsung.com>
>>>>>>>>>>>
>>>>>>>>>>> This patch adds device driver of max77843 charger. This driver provide
>>>>>>>>>>> initialize each charging mode(e.g. fast charge, top-off mode and constant
>>>>>>>>>>> charging mode so on.). Additionally, control charging paramters to use
>>>>>>>>>>> i2c interface.
>>>>>>>>>>>
>>>>>>>>>>> Cc: Sebastian Reichel <sre@kernel.org>
>>>>>>>>>>> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
>>>>>>>>>>
>>>>>>>>>> Reviewed-By: Sebastian Reichel <sre@kernel.org>
>>>>>>>>>>
>>>>>>>>>> I can't take it as is, since it depends on the private header file
>>>>>>>>>> of PATCHv1.
>>>>>>>>>>
>>>>>>>>>> -- Sebastian
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> This patch reviewed by Sebastian.
>>>>>>>>> Could you Please merge that your git tree ?
>>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> ... and again we are adding a new driver for very similar chipset to
>>>>>>>> already supported. I looked at spec and the charger's registers are
>>>>>>>> almost the same as for max77693. Their layout and addresses are the
>>>>>>>> same. I see some minor differences, probably the most important would
>>>>>>>> be different values current (fast-charge, top-off). But still 90% of
>>>>>>>> registers are the same... Do we really have to add new driver?
>>>>>>>>
>>>>>>>> Best regards,
>>>>>>>> Krzysztof
>>>>>>>>
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> Thank you for your comment. As you say, both chip set are similar.
>>>>>>> But new driver need for support max77843. It is support different below
>>>>>>> - Provide Battery presence information.
>>>>>>
>>>>>> Another set of power supply properties could be added for that chip.
>>>>>> This way the get_property() function would be the same but actually the
>>>>>> POWER_SUPPLY_PROP_PRESENT won't be called for max77693.
>>>>>>
>>>>>>> - Can OTG FET control.
>>>>>>
>>>>>> Where the OTG FET feature is it enabled in your driver? I couldn't find
>>>>>> it.
>>>>>>
>>>>>
>>>>> Sorry. This driver don't control OTG FET feature.
>>>>>
>>>>>>> - Bigger Fast charge current, Top Off current Threshold selection.
>>>>>>> - Various and bigger OTG current limitation.
>>>>>>> - Bigger primary charger termination voltage setting.
>>>>>>> - Different maximum input current limit selection(Different step).
>>>>>>
>>>>>> Yes, I mentioned some of these differences (the Fast/top-off
>>>>>> differences). These are differences in values so it does not require new
>>>>>> driver. There is need to develop new driver just to support different
>>>>>> current (3.0 A instead of 2.1 A) or voltage threshold.
>>>>>>
>>>>>
>>>>> They are different charging current, OTG current limitation, top off current,
>>>>> charging limitation value. In case OTG current limitation different not
>>>>> limitation value but using register bit(max77843 use[7:6] max77693 use[7]
>>>>> bit only). Even if this driver not support all feature, some register
>>>>> different with max77693(support value, use register bit).
>>>>>
>>>>> If this driver will combined with max77693 may even be beneficial for
>>>>> new Maxim driver. But the present, this driver is related with
>>>>> max77843 core driver and max77843-regulator. So I hope this driver
>>>>> merge first. And then will extend two driver(max77843 charger and max77693 charger).
>>>
>>> I still prefer merging common drivers into one instead of creating
>>> some more of them.
>>> However I understand your point and I am not entirely opposed against.
>>> Especially that you invested quite a bit of time for developing this
>>> and my feedback was quite late. To summarize I am fine with your
>>> approach.
>>>
>>> Best regards,
>>> Krzysztof
>>>
>>
>> Dear Lee Jones,
>>
>> Could you please merge that your git tree ?
> 
> Sorry, I'm lost.  Why am I taking this though the MFD tree?  What
> patches are left?  Where are they going?  Am I taking any other
> patches?
> 

Max77843 charger driver is max77843 mfd core dependency.
If you think this patch will suitable for battery tree(or other tree),
I would like request for merge battery tree.
Also, I will send again this patch and device tree binding document.

Best regards,
Beomho Seo

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver
  2015-03-26 23:49                       ` Beomho Seo
@ 2015-03-27  7:57                         ` Lee Jones
  2015-03-27  8:45                           ` Beomho Seo
  0 siblings, 1 reply; 36+ messages in thread
From: Lee Jones @ 2015-03-27  7:57 UTC (permalink / raw)
  To: Beomho Seo
  Cc: Krzysztof Kozlowski, Sebastian Reichel, Jaewon Kim, linux-kernel,
	devicetree, linux-pm, linux-input, Inki Dae, SangBae Lee,
	Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Chanwoo Choi, Dmitry Torokhov

On Fri, 27 Mar 2015, Beomho Seo wrote:
> On 03/26/2015 10:54 PM, Lee Jones wrote:
> > On Thu, 26 Mar 2015, Beomho Seo wrote:
> >> On 03/24/2015 05:38 PM, Krzysztof Kozlowski wrote:
> >>> 2015-03-24 9:01 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
> >>>> On 03/10/2015 10:44 PM, Beomho Seo wrote:
> >>>>> On 03/09/2015 09:13 PM, Krzysztof Kozlowski wrote:
> >>>>>> On pon, 2015-03-09 at 20:46 +0900, Beomho Seo wrote:
> >>>>>>> On 03/09/2015 08:02 PM, Krzysztof Kozlowski wrote:
> >>>>>>>> 2015-03-09 1:35 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
> >>>>>>>>> On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
> >>>>>>>>>> On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
> >>>>>>>>>>> From: Beomho Seo <beomho.seo@samsung.com>
> >>>>>>>>>>>
> >>>>>>>>>>> This patch adds device driver of max77843 charger. This driver provide
> >>>>>>>>>>> initialize each charging mode(e.g. fast charge, top-off mode and constant
> >>>>>>>>>>> charging mode so on.). Additionally, control charging paramters to use
> >>>>>>>>>>> i2c interface.
> >>>>>>>>>>>
> >>>>>>>>>>> Cc: Sebastian Reichel <sre@kernel.org>
> >>>>>>>>>>> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
> >>>>>>>>>>
> >>>>>>>>>> Reviewed-By: Sebastian Reichel <sre@kernel.org>
> >>>>>>>>>>
> >>>>>>>>>> I can't take it as is, since it depends on the private header file
> >>>>>>>>>> of PATCHv1.
> >>>>>>>>>>
> >>>>>>>>>> -- Sebastian
> >>>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> This patch reviewed by Sebastian.
> >>>>>>>>> Could you Please merge that your git tree ?
> >>>>>>>>
> >>>>>>>> Hi,
> >>>>>>>>
> >>>>>>>> ... and again we are adding a new driver for very similar chipset to
> >>>>>>>> already supported. I looked at spec and the charger's registers are
> >>>>>>>> almost the same as for max77693. Their layout and addresses are the
> >>>>>>>> same. I see some minor differences, probably the most important would
> >>>>>>>> be different values current (fast-charge, top-off). But still 90% of
> >>>>>>>> registers are the same... Do we really have to add new driver?
> >>>>>>>>
> >>>>>>>> Best regards,
> >>>>>>>> Krzysztof
> >>>>>>>>
> >>>>>>>
> >>>>>>> Hi,
> >>>>>>>
> >>>>>>> Thank you for your comment. As you say, both chip set are similar.
> >>>>>>> But new driver need for support max77843. It is support different below
> >>>>>>> - Provide Battery presence information.
> >>>>>>
> >>>>>> Another set of power supply properties could be added for that chip.
> >>>>>> This way the get_property() function would be the same but actually the
> >>>>>> POWER_SUPPLY_PROP_PRESENT won't be called for max77693.
> >>>>>>
> >>>>>>> - Can OTG FET control.
> >>>>>>
> >>>>>> Where the OTG FET feature is it enabled in your driver? I couldn't find
> >>>>>> it.
> >>>>>>
> >>>>>
> >>>>> Sorry. This driver don't control OTG FET feature.
> >>>>>
> >>>>>>> - Bigger Fast charge current, Top Off current Threshold selection.
> >>>>>>> - Various and bigger OTG current limitation.
> >>>>>>> - Bigger primary charger termination voltage setting.
> >>>>>>> - Different maximum input current limit selection(Different step).
> >>>>>>
> >>>>>> Yes, I mentioned some of these differences (the Fast/top-off
> >>>>>> differences). These are differences in values so it does not require new
> >>>>>> driver. There is need to develop new driver just to support different
> >>>>>> current (3.0 A instead of 2.1 A) or voltage threshold.
> >>>>>>
> >>>>>
> >>>>> They are different charging current, OTG current limitation, top off current,
> >>>>> charging limitation value. In case OTG current limitation different not
> >>>>> limitation value but using register bit(max77843 use[7:6] max77693 use[7]
> >>>>> bit only). Even if this driver not support all feature, some register
> >>>>> different with max77693(support value, use register bit).
> >>>>>
> >>>>> If this driver will combined with max77693 may even be beneficial for
> >>>>> new Maxim driver. But the present, this driver is related with
> >>>>> max77843 core driver and max77843-regulator. So I hope this driver
> >>>>> merge first. And then will extend two driver(max77843 charger and max77693 charger).
> >>>
> >>> I still prefer merging common drivers into one instead of creating
> >>> some more of them.
> >>> However I understand your point and I am not entirely opposed against.
> >>> Especially that you invested quite a bit of time for developing this
> >>> and my feedback was quite late. To summarize I am fine with your
> >>> approach.
> >>>
> >>> Best regards,
> >>> Krzysztof
> >>>
> >>
> >> Dear Lee Jones,
> >>
> >> Could you please merge that your git tree ?
> > 
> > Sorry, I'm lost.  Why am I taking this though the MFD tree?  What
> > patches are left?  Where are they going?  Am I taking any other
> > patches?
> > 
> 
> Max77843 charger driver is max77843 mfd core dependency.

What kind of dependancy?  Runtime or build?  Where is the patch that
it depends on?  Is it in -next for in Mainline already?

> If you think this patch will suitable for battery tree(or other tree),
> I would like request for merge battery tree.

If this patch has no build dependencies on patches which are in -next,
but not in Mainline then it will have to go in via the same tree that
the dependencies were applied to.  If the dependencies are already in
Mainline, or they are not build-deps, then it should go in via the
correct tree, which I believe is Sebastian's tree.

> Also, I will send again this patch and device tree binding document.

Either way you should do that.  Mark them as RESEND instead of PATCH
and apply all of the Acks you have accumulated so far.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver
  2015-03-27  7:57                         ` Lee Jones
@ 2015-03-27  8:45                           ` Beomho Seo
  2015-03-27 10:08                             ` Lee Jones
  0 siblings, 1 reply; 36+ messages in thread
From: Beomho Seo @ 2015-03-27  8:45 UTC (permalink / raw)
  To: Lee Jones
  Cc: Krzysztof Kozlowski, Sebastian Reichel, Jaewon Kim, linux-kernel,
	devicetree, linux-pm, linux-input, Inki Dae, SangBae Lee,
	Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Chanwoo Choi, Dmitry Torokhov

On 03/27/2015 04:57 PM, Lee Jones wrote:
> On Fri, 27 Mar 2015, Beomho Seo wrote:
>> On 03/26/2015 10:54 PM, Lee Jones wrote:
>>> On Thu, 26 Mar 2015, Beomho Seo wrote:
>>>> On 03/24/2015 05:38 PM, Krzysztof Kozlowski wrote:
>>>>> 2015-03-24 9:01 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
>>>>>> On 03/10/2015 10:44 PM, Beomho Seo wrote:
>>>>>>> On 03/09/2015 09:13 PM, Krzysztof Kozlowski wrote:
>>>>>>>> On pon, 2015-03-09 at 20:46 +0900, Beomho Seo wrote:
>>>>>>>>> On 03/09/2015 08:02 PM, Krzysztof Kozlowski wrote:
>>>>>>>>>> 2015-03-09 1:35 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
>>>>>>>>>>> On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
>>>>>>>>>>>> On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
>>>>>>>>>>>>> From: Beomho Seo <beomho.seo@samsung.com>
>>>>>>>>>>>>>
>>>>>>>>>>>>> This patch adds device driver of max77843 charger. This driver provide
>>>>>>>>>>>>> initialize each charging mode(e.g. fast charge, top-off mode and constant
>>>>>>>>>>>>> charging mode so on.). Additionally, control charging paramters to use
>>>>>>>>>>>>> i2c interface.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Cc: Sebastian Reichel <sre@kernel.org>
>>>>>>>>>>>>> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
>>>>>>>>>>>>
>>>>>>>>>>>> Reviewed-By: Sebastian Reichel <sre@kernel.org>
>>>>>>>>>>>>
>>>>>>>>>>>> I can't take it as is, since it depends on the private header file
>>>>>>>>>>>> of PATCHv1.
>>>>>>>>>>>>
>>>>>>>>>>>> -- Sebastian
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> This patch reviewed by Sebastian.
>>>>>>>>>>> Could you Please merge that your git tree ?
>>>>>>>>>>
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> ... and again we are adding a new driver for very similar chipset to
>>>>>>>>>> already supported. I looked at spec and the charger's registers are
>>>>>>>>>> almost the same as for max77693. Their layout and addresses are the
>>>>>>>>>> same. I see some minor differences, probably the most important would
>>>>>>>>>> be different values current (fast-charge, top-off). But still 90% of
>>>>>>>>>> registers are the same... Do we really have to add new driver?
>>>>>>>>>>
>>>>>>>>>> Best regards,
>>>>>>>>>> Krzysztof
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> Thank you for your comment. As you say, both chip set are similar.
>>>>>>>>> But new driver need for support max77843. It is support different below
>>>>>>>>> - Provide Battery presence information.
>>>>>>>>
>>>>>>>> Another set of power supply properties could be added for that chip.
>>>>>>>> This way the get_property() function would be the same but actually the
>>>>>>>> POWER_SUPPLY_PROP_PRESENT won't be called for max77693.
>>>>>>>>
>>>>>>>>> - Can OTG FET control.
>>>>>>>>
>>>>>>>> Where the OTG FET feature is it enabled in your driver? I couldn't find
>>>>>>>> it.
>>>>>>>>
>>>>>>>
>>>>>>> Sorry. This driver don't control OTG FET feature.
>>>>>>>
>>>>>>>>> - Bigger Fast charge current, Top Off current Threshold selection.
>>>>>>>>> - Various and bigger OTG current limitation.
>>>>>>>>> - Bigger primary charger termination voltage setting.
>>>>>>>>> - Different maximum input current limit selection(Different step).
>>>>>>>>
>>>>>>>> Yes, I mentioned some of these differences (the Fast/top-off
>>>>>>>> differences). These are differences in values so it does not require new
>>>>>>>> driver. There is need to develop new driver just to support different
>>>>>>>> current (3.0 A instead of 2.1 A) or voltage threshold.
>>>>>>>>
>>>>>>>
>>>>>>> They are different charging current, OTG current limitation, top off current,
>>>>>>> charging limitation value. In case OTG current limitation different not
>>>>>>> limitation value but using register bit(max77843 use[7:6] max77693 use[7]
>>>>>>> bit only). Even if this driver not support all feature, some register
>>>>>>> different with max77693(support value, use register bit).
>>>>>>>
>>>>>>> If this driver will combined with max77693 may even be beneficial for
>>>>>>> new Maxim driver. But the present, this driver is related with
>>>>>>> max77843 core driver and max77843-regulator. So I hope this driver
>>>>>>> merge first. And then will extend two driver(max77843 charger and max77693 charger).
>>>>>
>>>>> I still prefer merging common drivers into one instead of creating
>>>>> some more of them.
>>>>> However I understand your point and I am not entirely opposed against.
>>>>> Especially that you invested quite a bit of time for developing this
>>>>> and my feedback was quite late. To summarize I am fine with your
>>>>> approach.
>>>>>
>>>>> Best regards,
>>>>> Krzysztof
>>>>>
>>>>
>>>> Dear Lee Jones,
>>>>
>>>> Could you please merge that your git tree ?
>>>
>>> Sorry, I'm lost.  Why am I taking this though the MFD tree?  What
>>> patches are left?  Where are they going?  Am I taking any other
>>> patches?
>>>
>>
>> Max77843 charger driver is max77843 mfd core dependency.
> 
> What kind of dependancy?  Runtime or build?  Where is the patch that
> it depends on?  Is it in -next for in Mainline already?
> 

Build. Max77843 charger driver use max77843-private.h. It is in for-mfd-next branch.

c7f585f mfd: max77843: Add max77843 MFD driver core driver

>> If you think this patch will suitable for battery tree(or other tree),
>> I would like request for merge battery tree.
> 
> If this patch has no build dependencies on patches which are in -next,
> but not in Mainline then it will have to go in via the same tree that
> the dependencies were applied to.  If the dependencies are already in
> Mainline, or they are not build-deps, then it should go in via the
> correct tree, which I believe is Sebastian's tree.
> 
>> Also, I will send again this patch and device tree binding document.
> 
> Either way you should do that.  Mark them as RESEND instead of PATCH
> and apply all of the Acks you have accumulated so far.
> 

I will send new version because binding document have been modified.
As your comment patch will be mark.

Best regards
Beomho Seo

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver
  2015-03-27  8:45                           ` Beomho Seo
@ 2015-03-27 10:08                             ` Lee Jones
  0 siblings, 0 replies; 36+ messages in thread
From: Lee Jones @ 2015-03-27 10:08 UTC (permalink / raw)
  To: Beomho Seo
  Cc: Krzysztof Kozlowski, Sebastian Reichel, Jaewon Kim, linux-kernel,
	devicetree, linux-pm, linux-input, Inki Dae, SangBae Lee,
	Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Chanwoo Choi, Dmitry Torokhov

On Fri, 27 Mar 2015, Beomho Seo wrote:

> On 03/27/2015 04:57 PM, Lee Jones wrote:
> > On Fri, 27 Mar 2015, Beomho Seo wrote:
> >> On 03/26/2015 10:54 PM, Lee Jones wrote:
> >>> On Thu, 26 Mar 2015, Beomho Seo wrote:
> >>>> On 03/24/2015 05:38 PM, Krzysztof Kozlowski wrote:
> >>>>> 2015-03-24 9:01 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
> >>>>>> On 03/10/2015 10:44 PM, Beomho Seo wrote:
> >>>>>>> On 03/09/2015 09:13 PM, Krzysztof Kozlowski wrote:
> >>>>>>>> On pon, 2015-03-09 at 20:46 +0900, Beomho Seo wrote:
> >>>>>>>>> On 03/09/2015 08:02 PM, Krzysztof Kozlowski wrote:
> >>>>>>>>>> 2015-03-09 1:35 GMT+01:00 Beomho Seo <beomho.seo@samsung.com>:
> >>>>>>>>>>> On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
> >>>>>>>>>>>> On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
> >>>>>>>>>>>>> From: Beomho Seo <beomho.seo@samsung.com>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> This patch adds device driver of max77843 charger. This driver provide
> >>>>>>>>>>>>> initialize each charging mode(e.g. fast charge, top-off mode and constant
> >>>>>>>>>>>>> charging mode so on.). Additionally, control charging paramters to use
> >>>>>>>>>>>>> i2c interface.
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Cc: Sebastian Reichel <sre@kernel.org>
> >>>>>>>>>>>>> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
> >>>>>>>>>>>>
> >>>>>>>>>>>> Reviewed-By: Sebastian Reichel <sre@kernel.org>
> >>>>>>>>>>>>
> >>>>>>>>>>>> I can't take it as is, since it depends on the private header file
> >>>>>>>>>>>> of PATCHv1.
> >>>>>>>>>>>>
> >>>>>>>>>>>> -- Sebastian
> >>>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>> This patch reviewed by Sebastian.
> >>>>>>>>>>> Could you Please merge that your git tree ?
> >>>>>>>>>>
> >>>>>>>>>> Hi,
> >>>>>>>>>>
> >>>>>>>>>> ... and again we are adding a new driver for very similar chipset to
> >>>>>>>>>> already supported. I looked at spec and the charger's registers are
> >>>>>>>>>> almost the same as for max77693. Their layout and addresses are the
> >>>>>>>>>> same. I see some minor differences, probably the most important would
> >>>>>>>>>> be different values current (fast-charge, top-off). But still 90% of
> >>>>>>>>>> registers are the same... Do we really have to add new driver?
> >>>>>>>>>>
> >>>>>>>>>> Best regards,
> >>>>>>>>>> Krzysztof
> >>>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> Hi,
> >>>>>>>>>
> >>>>>>>>> Thank you for your comment. As you say, both chip set are similar.
> >>>>>>>>> But new driver need for support max77843. It is support different below
> >>>>>>>>> - Provide Battery presence information.
> >>>>>>>>
> >>>>>>>> Another set of power supply properties could be added for that chip.
> >>>>>>>> This way the get_property() function would be the same but actually the
> >>>>>>>> POWER_SUPPLY_PROP_PRESENT won't be called for max77693.
> >>>>>>>>
> >>>>>>>>> - Can OTG FET control.
> >>>>>>>>
> >>>>>>>> Where the OTG FET feature is it enabled in your driver? I couldn't find
> >>>>>>>> it.
> >>>>>>>>
> >>>>>>>
> >>>>>>> Sorry. This driver don't control OTG FET feature.
> >>>>>>>
> >>>>>>>>> - Bigger Fast charge current, Top Off current Threshold selection.
> >>>>>>>>> - Various and bigger OTG current limitation.
> >>>>>>>>> - Bigger primary charger termination voltage setting.
> >>>>>>>>> - Different maximum input current limit selection(Different step).
> >>>>>>>>
> >>>>>>>> Yes, I mentioned some of these differences (the Fast/top-off
> >>>>>>>> differences). These are differences in values so it does not require new
> >>>>>>>> driver. There is need to develop new driver just to support different
> >>>>>>>> current (3.0 A instead of 2.1 A) or voltage threshold.
> >>>>>>>>
> >>>>>>>
> >>>>>>> They are different charging current, OTG current limitation, top off current,
> >>>>>>> charging limitation value. In case OTG current limitation different not
> >>>>>>> limitation value but using register bit(max77843 use[7:6] max77693 use[7]
> >>>>>>> bit only). Even if this driver not support all feature, some register
> >>>>>>> different with max77693(support value, use register bit).
> >>>>>>>
> >>>>>>> If this driver will combined with max77693 may even be beneficial for
> >>>>>>> new Maxim driver. But the present, this driver is related with
> >>>>>>> max77843 core driver and max77843-regulator. So I hope this driver
> >>>>>>> merge first. And then will extend two driver(max77843 charger and max77693 charger).
> >>>>>
> >>>>> I still prefer merging common drivers into one instead of creating
> >>>>> some more of them.
> >>>>> However I understand your point and I am not entirely opposed against.
> >>>>> Especially that you invested quite a bit of time for developing this
> >>>>> and my feedback was quite late. To summarize I am fine with your
> >>>>> approach.
> >>>>>
> >>>>> Best regards,
> >>>>> Krzysztof
> >>>>>
> >>>>
> >>>> Dear Lee Jones,
> >>>>
> >>>> Could you please merge that your git tree ?
> >>>
> >>> Sorry, I'm lost.  Why am I taking this though the MFD tree?  What
> >>> patches are left?  Where are they going?  Am I taking any other
> >>> patches?
> >>>
> >>
> >> Max77843 charger driver is max77843 mfd core dependency.
> > 
> > What kind of dependancy?  Runtime or build?  Where is the patch that
> > it depends on?  Is it in -next for in Mainline already?
> > 
> 
> Build. Max77843 charger driver use max77843-private.h. It is in for-mfd-next branch.
> 
> c7f585f mfd: max77843: Add max77843 MFD driver core driver

If that's the case, then yes, I can take this patch through the MFD
tree with the correct Acks applied.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2015-03-27 10:09 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-02 10:10 [PATCH v7 0/5] Add new MFD driver for MAX77843 Jaewon Kim
2015-03-02 10:10 ` [PATCH v7 1/5] mfd: max77843: Add max77843 MFD driver core driver Jaewon Kim
2015-03-02 10:20   ` Lee Jones
2015-03-02 10:36     ` Jaewon Kim
2015-03-02 10:41   ` Lee Jones
2015-03-02 10:10 ` [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver Jaewon Kim
2015-03-07 20:13   ` Sebastian Reichel
2015-03-09  0:35     ` Beomho Seo
2015-03-09 11:02       ` Krzysztof Kozlowski
2015-03-09 11:46         ` Beomho Seo
2015-03-09 12:13           ` Krzysztof Kozlowski
2015-03-10 13:44             ` Beomho Seo
2015-03-24  8:01               ` Beomho Seo
2015-03-24  8:38                 ` Krzysztof Kozlowski
2015-03-25  0:39                   ` Beomho Seo
2015-03-26  7:16                     ` Krzysztof Kozlowski
2015-03-26 13:25                   ` Beomho Seo
2015-03-26 13:54                     ` Lee Jones
2015-03-26 23:49                       ` Beomho Seo
2015-03-27  7:57                         ` Lee Jones
2015-03-27  8:45                           ` Beomho Seo
2015-03-27 10:08                             ` Lee Jones
2015-03-02 10:10 ` [PATCH v7 3/5] power: max77843_battery: Add Max77843 fuel gauge " Jaewon Kim
2015-03-07 20:14   ` Sebastian Reichel
2015-03-09  0:36     ` Beomho Seo
2015-03-09 10:01       ` Krzysztof Kozlowski
2015-03-10 13:44         ` Beomho Seo
2015-03-24  8:02           ` Beomho Seo
2015-03-24  8:39             ` Krzysztof Kozlowski
2015-03-02 10:10 ` [PATCH v7 4/5] Input: add haptic drvier on max77843 Jaewon Kim
2015-03-02 17:32   ` Dmitry Torokhov
2015-03-03  1:35     ` Jaewon Kim
2015-03-04 22:47       ` Dmitry Torokhov
2015-03-07 20:21         ` Sebastian Reichel
2015-03-08  4:55           ` Dmitry Torokhov
2015-03-02 10:10 ` [PATCH v7 5/5] Documentation: Add device tree bindings document for max77843 Jaewon Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).