All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <l.majewski@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 11/21] pmic:muic: Support for MUIC built into MAX8997 device
Date: Fri, 05 Oct 2012 10:16:33 +0200	[thread overview]
Message-ID: <1349425003-32523-12-git-send-email-l.majewski@samsung.com> (raw)
In-Reply-To: <1349425003-32523-1-git-send-email-l.majewski@samsung.com>

Support for MUIC (Micro USB Integrated Circuit) built into the MAX8997
power management device.

The MUIC device will work with redesigned PMIC framework.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Stefano Babic <sbabic@denx.de>

---
Changes for v2:
- power_init_battery now available as a callback from MUIC struct pmic
  instance
---
 drivers/power/Makefile               |    1 +
 drivers/power/max8997/muic_max8997.c |   91 ++++++++++++++++++++++++++++++++++
 include/power/max8997_muic.h         |   61 +++++++++++++++++++++++
 3 files changed, 153 insertions(+), 0 deletions(-)
 create mode 100644 drivers/power/max8997/muic_max8997.c
 create mode 100644 include/power/max8997_muic.h

diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index 74a0990..f07644c 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -39,6 +39,7 @@ COBJS-$(CONFIG_PMIC_SPI) += pmic_spi.o
 COBJS-$(CONFIG_PMIC_MAX8998) += max8998/pmic_max8998.o
 COBJS-$(CONFIG_PMIC_MAX8997) += max8997/pmic_max8997.o
 COBJS-$(CONFIG_POWER_BATTERY_TRATS) += battery/bat_trats.o
+COBJS-$(CONFIG_POWER_MUIC_MAX8997) += max8997/muic_max8997.o
 
 COBJS	:= $(COBJS-y)
 SRCS 	:= $(COBJS:.o=.c)
diff --git a/drivers/power/max8997/muic_max8997.c b/drivers/power/max8997/muic_max8997.c
new file mode 100644
index 0000000..e2da067
--- /dev/null
+++ b/drivers/power/max8997/muic_max8997.c
@@ -0,0 +1,91 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *  Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <power/pmic.h>
+#include <power/power_chrg.h>
+#include <power/max8997_muic.h>
+#include <i2c.h>
+
+static int power_chrg_get_type(struct pmic *p)
+{
+	unsigned int val;
+	unsigned char charge_type, charger;
+
+	if (pmic_probe(p))
+		return CHARGER_NO;
+
+	pmic_reg_read(p, MAX8997_MUIC_STATUS2, &val);
+	charge_type = val & MAX8997_MUIC_CHG_MASK;
+
+	switch (charge_type) {
+	case MAX8997_MUIC_CHG_NO:
+		charger = CHARGER_NO;
+		break;
+	case MAX8997_MUIC_CHG_USB:
+	case MAX8997_MUIC_CHG_USB_D:
+		charger = CHARGER_USB;
+		break;
+	case MAX8997_MUIC_CHG_TA:
+	case MAX8997_MUIC_CHG_TA_1A:
+		charger = CHARGER_TA;
+		break;
+	case MAX8997_MUIC_CHG_TA_500:
+		charger = CHARGER_TA_500;
+		break;
+	default:
+		charger = CHARGER_UNKNOWN;
+		break;
+	}
+
+	return charger;
+}
+
+static int power_init_battery(struct pmic *p, struct pmic *bat)
+{
+	struct power_battery *pb = bat->pwr_bat;
+
+	pb->chrg_type = power_chrg_get_type;
+	pb->muic = p;
+
+	return 0;
+}
+
+int power_muic_init(unsigned int bus)
+{
+	struct pmic *p = pmic_alloc();
+	static const char name[] = "MAX8997_MUIC";
+
+	debug("Board Micro USB Interface Controller init\n");
+
+	p->name = name;
+	p->interface = PMIC_I2C;
+	p->number_of_regs = MUIC_NUM_OF_REGS;
+	p->hw.i2c.addr = MAX8997_MUIC_I2C_ADDR;
+	p->hw.i2c.tx_num = 1;
+	p->bus = bus;
+
+	p->battery_init = power_init_battery;
+
+	return 0;
+}
diff --git a/include/power/max8997_muic.h b/include/power/max8997_muic.h
new file mode 100644
index 0000000..0149c12
--- /dev/null
+++ b/include/power/max8997_muic.h
@@ -0,0 +1,61 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *  Lukasz Majewski <l.majewski@samsung.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __MAX8997_MUIC_H_
+#define __MAX8997_MUIC_H_
+
+#include <power/power_chrg.h>
+
+/* MAX8997_MUIC_STATUS2 */
+#define MAX8997_MUIC_CHG_NO	0x00
+#define MAX8997_MUIC_CHG_USB	0x01
+#define MAX8997_MUIC_CHG_USB_D	0x02
+#define MAX8997_MUIC_CHG_TA	0x03
+#define MAX8997_MUIC_CHG_TA_500 0x04
+#define MAX8997_MUIC_CHG_TA_1A	0x05
+#define MAX8997_MUIC_CHG_MASK	0x07
+
+/* MAX 8997 MUIC registers */
+enum {
+	MAX8997_MUIC_ID         = 0x00,
+	MAX8997_MUIC_INT1	= 0x01,
+	MAX8997_MUIC_INT2	= 0x02,
+	MAX8997_MUIC_INT3	= 0x03,
+	MAX8997_MUIC_STATUS1	= 0x04,
+	MAX8997_MUIC_STATUS2	= 0x05,
+	MAX8997_MUIC_STATUS3	= 0x06,
+	MAX8997_MUIC_INTMASK1	= 0x07,
+	MAX8997_MUIC_INTMASK2	= 0x08,
+	MAX8997_MUIC_INTMASK3	= 0x09,
+	MAX8997_MUIC_CDETCTRL	= 0x0A,
+	MAX8997_MUIC_CONTROL1	= 0x0C,
+	MAX8997_MUIC_CONTROL2	= 0x0D,
+	MAX8997_MUIC_CONTROL3	= 0x0E,
+
+	MUIC_NUM_OF_REGS = 0x0F,
+};
+
+#define MAX8997_MUIC_I2C_ADDR	(0x4A >> 1)
+
+int power_muic_init(unsigned int bus);
+#endif /* __MAX8997_MUIC_H_ */
-- 
1.7.2.3

  parent reply	other threads:[~2012-10-05  8:16 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-05  8:16 [U-Boot] [PATCH v2 00/21] pmic: Redesign PMIC framework to support multiple instances of devices Lukasz Majewski
2012-10-05  8:16 ` [U-Boot] [PATCH v2 01/21] pmic:i2c: Handle PMIC I2C transmission comprising of two bytes Lukasz Majewski
2012-10-05  8:16 ` [U-Boot] [PATCH v2 02/21] pmic:i2c: Add I2C byte order to PMIC framework Lukasz Majewski
2012-10-09  8:36   ` Stefano Babic
2012-10-09  9:52     ` Lukasz Majewski
2012-10-09 11:02       ` Stefano Babic
2012-10-05  8:16 ` [U-Boot] [PATCH v2 03/21] pmic:max8997: Switch the MAX8997 PMIC to be used with multibus I2C Lukasz Majewski
2012-10-05  8:16 ` [U-Boot] [PATCH v2 04/21] pmic: Extend PMIC framework to support multiple instances of PMIC devices Lukasz Majewski
2012-10-05  8:16 ` [U-Boot] [PATCH v2 05/21] pmic: Introduce power_board_init() method at ./lib/board.c file Lukasz Majewski
2012-10-09  8:54   ` Stefano Babic
2012-10-09 10:25     ` Lukasz Majewski
2012-10-09 11:34       ` Stefano Babic
2012-10-09 18:05         ` Tom Rini
2012-10-10  6:24           ` Lukasz Majewski
2012-10-05  8:16 ` [U-Boot] [PATCH v2 06/21] pmic: Enable power_board_init() support at TRATS Lukasz Majewski
2012-10-09  8:56   ` Stefano Babic
2012-10-09 10:30     ` Lukasz Majewski
2012-10-09 11:37       ` Stefano Babic
2012-10-09 12:06         ` Lukasz Majewski
2012-10-05  8:16 ` [U-Boot] [PATCH v2 07/21] pmic:chrg: Common information about charger and battery (power_chrg.h) Lukasz Majewski
2012-10-05  8:16 ` [U-Boot] [PATCH v2 08/21] pmic: Move pmic related code to ./drivers/power directory Lukasz Majewski
2012-10-09  8:58   ` Stefano Babic
2012-10-09 10:37     ` Lukasz Majewski
2012-10-05  8:16 ` [U-Boot] [PATCH v2 09/21] pmic: Extend struct pmic to support battery and charger related operations Lukasz Majewski
2012-10-11  7:52   ` Stefano Babic
2012-10-12  7:54     ` Lukasz Majewski
2012-10-18 16:09     ` [U-Boot] [PATCH v2 09/21] pmic: Extend struct pmic to support battery and charger related operations [explanation] Lukasz Majewski
2012-10-05  8:16 ` [U-Boot] [PATCH v2 10/21] pmic:battery: Support for Trats Battery at PMIC framework Lukasz Majewski
2012-10-05  8:16 ` Lukasz Majewski [this message]
2012-10-05  8:16 ` [U-Boot] [PATCH v2 12/21] pmic:fuel-gauge: Support for MAX17042 fuel-gauge Lukasz Majewski
2012-10-05  8:16 ` [U-Boot] [PATCH v2 13/21] pmic:max8997: Function for calculating LDO internal register value Lukasz Majewski
2012-10-05  8:16 ` [U-Boot] [PATCH v2 14/21] arm:trats:pmic: Default PMIC(MAX8997) initialization for Samsung's TRATS board Lukasz Majewski
2012-10-05  8:16 ` [U-Boot] [PATCH v2 15/21] arm:trats:pmic: Enable MUIC (MAX8997) at " Lukasz Majewski
2012-10-05  8:16 ` [U-Boot] [PATCH v2 16/21] arm:trats:pmic: Enable fuel-gauge (MAX17042) " Lukasz Majewski
2012-10-05  8:16 ` [U-Boot] [PATCH v2 17/21] arm:trats:pmic: Enable battery support " Lukasz Majewski
2012-10-05  8:16 ` [U-Boot] [PATCH v2 18/21] pmic:max8997: Support for MAX8997 internal charger control Lukasz Majewski
2012-10-05  8:16 ` [U-Boot] [PATCH v2 19/21] arm:trats:pmic: Power consumption reduction state for Samsung's TRATS board Lukasz Majewski
2012-10-05  8:16 ` [U-Boot] [PATCH v2 20/21] arm:trats:pmic: Support for charging battery at " Lukasz Majewski
2012-10-05  8:16 ` [U-Boot] [PATCH v2 21/21] pmic: Extend PMIC framework to support battery related commands Lukasz Majewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1349425003-32523-12-git-send-email-l.majewski@samsung.com \
    --to=l.majewski@samsung.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.