All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/4] Add support for TI TPS65090
@ 2013-04-02  0:04 Simon Glass
  2013-04-02  0:04 ` [U-Boot] [PATCH 1/4] power: Add support for TPS65090 PMU chip Simon Glass
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Simon Glass @ 2013-04-02  0:04 UTC (permalink / raw)
  To: u-boot

This series adds support for the TPS65090 PMIC as used on the Samsung
ARM Chromebook. It is plumbed into smdk5250 for now, while we await
the exynos5-dt board being applied upstream.


Aaron Durbin (3):
  exynos5: Enable tps65090 on smdk5250
  power: Explicitly select pmic device's bus
  exynos5: support tps65090 pmic

Tom Wai-Hong Tam (1):
  power: Add support for TPS65090 PMU chip.

 board/samsung/smdk5250/smdk5250.c           |  33 +++-
 doc/device-tree-bindings/power/tps65090.txt |  21 ++
 drivers/power/pmic/Makefile                 |   1 +
 drivers/power/pmic/pmic_tps65090.c          | 296 ++++++++++++++++++++++++++++
 drivers/power/power_i2c.c                   |   4 +
 include/configs/exynos5250-dt.h             |   1 +
 include/fdtdec.h                            |   1 +
 include/power/tps65090_pmic.h               |  83 ++++++++
 lib/fdtdec.c                                |   1 +
 9 files changed, 433 insertions(+), 8 deletions(-)
 create mode 100644 doc/device-tree-bindings/power/tps65090.txt
 create mode 100644 drivers/power/pmic/pmic_tps65090.c
 create mode 100644 include/power/tps65090_pmic.h

-- 
1.8.1.3

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

* [U-Boot] [PATCH 1/4] power: Add support for TPS65090 PMU chip.
  2013-04-02  0:04 [U-Boot] [PATCH 0/4] Add support for TI TPS65090 Simon Glass
@ 2013-04-02  0:04 ` Simon Glass
  2014-01-02  6:37   ` Minkyu Kang
  2013-04-02  0:04 ` [U-Boot] [PATCH 2/4] exynos5: Enable tps65090 on smdk5250 Simon Glass
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Simon Glass @ 2013-04-02  0:04 UTC (permalink / raw)
  To: u-boot

From: Tom Wai-Hong Tam <waihong@chromium.org>

This adds driver support for the TPS65090 PMU. Support includes
hooking into the pmic infrastructure  so that the pmic commands
can be used on the console. The TPS65090 supports the following
functionality:

- fet enable/disable/querying
- getting and setting of charge state

Even though it is connected to the pmic infrastructure it does
not hook into the pmic charging charging infrastructure.

Signed-off-by: Tom Wai-Hong Tam <waihong@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Hatim Ali <hatim.rv@samsung.com>
Signed-off-by: Katie Roberts-Hoffman <katierh@chromium.org>
Signed-off-by: Rong Chang <rongchang@chromium.org>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
---
 doc/device-tree-bindings/power/tps65090.txt |  21 ++
 drivers/power/pmic/Makefile                 |   1 +
 drivers/power/pmic/pmic_tps65090.c          | 296 ++++++++++++++++++++++++++++
 include/fdtdec.h                            |   1 +
 include/power/tps65090_pmic.h               |  83 ++++++++
 lib/fdtdec.c                                |   1 +
 6 files changed, 403 insertions(+)
 create mode 100644 doc/device-tree-bindings/power/tps65090.txt
 create mode 100644 drivers/power/pmic/pmic_tps65090.c
 create mode 100644 include/power/tps65090_pmic.h

diff --git a/doc/device-tree-bindings/power/tps65090.txt b/doc/device-tree-bindings/power/tps65090.txt
new file mode 100644
index 0000000..6a8a884
--- /dev/null
+++ b/doc/device-tree-bindings/power/tps65090.txt
@@ -0,0 +1,21 @@
+TPSchrome binding
+=================
+
+The device tree node which describes the operation of the Texas Instrument
+TPS65090 power regulator chip is as follows:
+
+Required properties :
+- compatible : "ti,tps65090"
+- reg : slave address on the i2c bus
+
+The tps65090 node should appear as a subnode of the i2c bus that connects it.
+
+Example
+=======
+
+	i2c at 12ca0000 {
+		power-regulator at 48 {
+			compatible = "ti,tps65090"
+			reg = <0x48>;
+		};
+	};
diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile
index 14d426f..a66d940 100644
--- a/drivers/power/pmic/Makefile
+++ b/drivers/power/pmic/Makefile
@@ -29,6 +29,7 @@ COBJS-$(CONFIG_POWER_MAX8998) += pmic_max8998.o
 COBJS-$(CONFIG_POWER_MAX8997) += pmic_max8997.o
 COBJS-$(CONFIG_POWER_MUIC_MAX8997) += muic_max8997.o
 COBJS-$(CONFIG_POWER_MAX77686) += pmic_max77686.o
+COBJS-$(CONFIG_POWER_TPS65090)	+= pmic_tps65090.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
diff --git a/drivers/power/pmic/pmic_tps65090.c b/drivers/power/pmic/pmic_tps65090.c
new file mode 100644
index 0000000..ef9f911
--- /dev/null
+++ b/drivers/power/pmic/pmic_tps65090.c
@@ -0,0 +1,296 @@
+/*
+ * Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <fdtdec.h>
+#include <i2c.h>
+#include <power/pmic.h>
+#include <power/tps65090_pmic.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define TPS65090_NAME "TPS65090_PMIC"
+
+/* TPS65090 register addresses */
+enum {
+	REG_CG_CTRL0 = 4,
+	REG_CG_STATUS1 = 0xa,
+	REG_FET1_CTRL = 0x0f,
+	REG_FET2_CTRL,
+	REG_FET3_CTRL,
+	REG_FET4_CTRL,
+	REG_FET5_CTRL,
+	REG_FET6_CTRL,
+	REG_FET7_CTRL,
+	TPS65090_NUM_REGS,
+};
+
+enum {
+	CG_CTRL0_ENC_MASK	= 0x01,
+
+	MAX_FET_NUM	= 7,
+	MAX_CTRL_READ_TRIES = 5,
+
+	/* TPS65090 FET_CTRL register values */
+	FET_CTRL_TOFET		= 1 << 7,  /* Timeout, startup, overload */
+	FET_CTRL_PGFET		= 1 << 4,  /* Power good for FET status */
+	FET_CTRL_WAIT		= 3 << 2,  /* Overcurrent timeout max */
+	FET_CTRL_ADENFET	= 1 << 1,  /* Enable output auto discharge */
+	FET_CTRL_ENFET		= 1 << 0,  /* Enable FET */
+};
+
+/**
+ * Checks for a valid FET number
+ *
+ * @param fet_id	FET number to check
+ * @return 0 if ok, -1 if FET value is out of range
+ */
+static int tps65090_check_fet(unsigned int fet_id)
+{
+	if (fet_id == 0 || fet_id > MAX_FET_NUM) {
+		debug("parameter fet_id is out of range, %u not in 1 ~ %u\n",
+		      fet_id, MAX_FET_NUM);
+		return -1;
+	}
+
+	return 0;
+}
+
+/**
+ * Set the power state for a FET
+ *
+ * @param pmic		pmic structure for the tps65090
+ * @param fet_id	Fet number to set (1..MAX_FET_NUM)
+ * @param set		1 to power on FET, 0 to power off
+ * @return FET_ERR_COMMS if we got a comms error, FET_ERR_NOT_READY if the
+ * FET failed to change state. If all is ok, returns 0.
+ */
+static int tps65090_fet_set(struct pmic *pmic, int fet_id, int set)
+{
+	int retry;
+	u32 reg, value;
+
+	value = FET_CTRL_ADENFET | FET_CTRL_WAIT;
+	if (set)
+		value |= FET_CTRL_ENFET;
+
+	if (pmic_reg_write(pmic, REG_FET1_CTRL + fet_id - 1, value))
+		return FET_ERR_COMMS;
+	/* Try reading until we get a result */
+	for (retry = 0; retry < MAX_CTRL_READ_TRIES; retry++) {
+		if (pmic_reg_read(pmic, REG_FET1_CTRL + fet_id - 1, &reg))
+			return FET_ERR_COMMS;
+
+		/* Check that the fet went into the expected state */
+		if (!!(reg & FET_CTRL_PGFET) == set)
+			return 0;
+
+		/* If we got a timeout, there is no point in waiting longer */
+		if (reg & FET_CTRL_TOFET)
+			break;
+
+		mdelay(1);
+	}
+
+	debug("FET %d: Power good should have set to %d but reg=%#02x\n",
+	      fet_id, set, reg);
+	return FET_ERR_NOT_READY;
+}
+
+int tps65090_fet_enable(unsigned int fet_id)
+{
+	int loops;
+	ulong start;
+	struct pmic *pmic;
+	int ret = 0;
+
+	if (tps65090_check_fet(fet_id))
+		return -1;
+
+	pmic = pmic_get(TPS65090_NAME);
+	if (pmic == NULL)
+		return -1;
+
+	start = get_timer(0);
+	for (loops = 0;; loops++) {
+		ret = tps65090_fet_set(pmic, fet_id, 1);
+		if (!ret)
+			break;
+
+		if (get_timer(start) > 100)
+			break;
+
+		/* Turn it off and try again until we time out */
+		tps65090_fet_set(pmic, fet_id, 0);
+	}
+
+	if (ret) {
+		debug("%s: FET%d failed to power on: time=%lums, loops=%d\n",
+		      __func__, fet_id, get_timer(start), loops);
+	} else if (loops) {
+		debug("%s: FET%d powered on after %lums, loops=%d\n",
+		      __func__, fet_id, get_timer(start), loops);
+	}
+	/*
+	 * Unfortunately, there are some conditions where the power
+	 * good bit will be 0, but the fet still comes up. One such
+	 * case occurs with the lcd backlight. We'll just return 0 here
+	 * and assume that the fet will eventually come up.
+	 */
+	if (ret == FET_ERR_NOT_READY)
+		ret = 0;
+
+	return ret;
+}
+
+int tps65090_fet_disable(unsigned int fet_id)
+{
+	int ret;
+	struct pmic *pmic;
+
+	if (tps65090_check_fet(fet_id))
+		return -1;
+
+	pmic = pmic_get(TPS65090_NAME);
+	if (pmic == NULL)
+		return -1;
+	ret = tps65090_fet_set(pmic, fet_id, 0);
+
+	return ret;
+}
+
+int tps65090_fet_is_enabled(unsigned int fet_id)
+{
+	u32 reg;
+	int ret;
+	struct pmic *pmic;
+
+	if (tps65090_check_fet(fet_id))
+		return -1;
+	pmic = pmic_get(TPS65090_NAME);
+	if (pmic == NULL)
+		return -1;
+	ret = pmic_reg_read(pmic, REG_FET1_CTRL + fet_id - 1, &reg);
+	if (ret) {
+		debug("fail to read FET%u_CTRL register over I2C", fet_id);
+		return -2;
+	}
+
+	return reg & FET_CTRL_ENFET;
+}
+
+int tps65090_get_charging(void)
+{
+	u32 val;
+	int ret;
+	struct pmic *pmic;
+
+	pmic = pmic_get(TPS65090_NAME);
+	if (pmic == NULL)
+		return -1;
+	ret = pmic_reg_read(pmic, REG_CG_CTRL0, &val);
+	if (ret)
+		return ret;
+	return val & CG_CTRL0_ENC_MASK ? 1 : 0;
+}
+
+int tps65090_set_charge_enable(int enable)
+{
+	u32 val;
+	int ret;
+	struct pmic *pmic;
+
+	pmic = pmic_get(TPS65090_NAME);
+	if (pmic == NULL)
+		return -1;
+
+	ret = pmic_reg_read(pmic, REG_CG_CTRL0, &val);
+	if (!ret) {
+		if (enable)
+			val |= CG_CTRL0_ENC_MASK;
+		else
+			val &= ~CG_CTRL0_ENC_MASK;
+		ret = pmic_reg_write(pmic, REG_CG_CTRL0, val);
+	}
+	if (ret) {
+		debug("%s: Failed to read/write register\n", __func__);
+		return ret;
+	}
+	return 0;
+}
+
+int tps65090_get_status(void)
+{
+	u32 val;
+	int ret;
+	struct pmic *pmic;
+
+	pmic = pmic_get(TPS65090_NAME);
+
+	if (pmic == NULL)
+		return -1;
+	ret = pmic_reg_read(pmic, REG_CG_STATUS1, &val);
+	if (ret)
+		return ret;
+	return val;
+}
+
+int tps65090_init(void)
+{
+	int bus;
+	int addr;
+	struct pmic *p;
+
+#ifdef CONFIG_OF_CONTROL
+	const void *blob = gd->fdt_blob;
+	int node, parent;
+
+	node = fdtdec_next_compatible(blob, 0, COMPAT_TI_TPS65090);
+	if (node < 0) {
+		debug("PMIC: No node for PMIC Chip in device tree\n");
+		debug("node = %d\n", node);
+		return -ENODEV;
+	}
+
+	parent = fdt_parent_offset(blob, node);
+	if (parent < 0) {
+		debug("%s: Cannot find node parent\n", __func__);
+		return -1;
+	}
+
+	bus = i2c_get_bus_num_fdt(parent);
+	if (p->bus < 0) {
+		debug("%s: Cannot find I2C bus\n", __func__);
+		return -1;
+	}
+	addr = fdtdec_get_int(blob, node, "reg", TPS65090_I2C_ADDR);
+#else
+	bus = CONFIG_POWER_TPS65090_BUS;
+	addr = TPS65090_I2C_ADDR;
+#endif
+	p = pmic_alloc();
+
+	if (!p) {
+		printf("%s: POWER allocation error!\n", __func__);
+		return -ENOMEM;
+	}
+
+	p->name = TPS65090_NAME;
+	p->bus = bus;
+	p->interface = PMIC_I2C;
+	p->number_of_regs = TPS65090_NUM_REGS;
+	p->hw.i2c.addr = addr;
+	p->hw.i2c.tx_num = 1;
+
+	puts("TPS65090 PMIC init\n");
+
+	return 0;
+}
diff --git a/include/fdtdec.h b/include/fdtdec.h
index e7e3ff9..92506fc 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -90,6 +90,7 @@ enum fdt_compat_id {
 	COMPAT_MAXIM_MAX77686_PMIC,	/* MAX77686 PMIC */
 	COMPAT_GENERIC_SPI_FLASH,	/* Generic SPI Flash chip */
 	COMPAT_MAXIM_98095_CODEC,	/* MAX98095 Codec */
+	COMPAT_TI_TPS65090,		/* Texas Instrument TPS65090 */
 
 	COMPAT_COUNT,
 };
diff --git a/include/power/tps65090_pmic.h b/include/power/tps65090_pmic.h
new file mode 100644
index 0000000..fde30eb
--- /dev/null
+++ b/include/power/tps65090_pmic.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ */
+
+#ifndef __TPS65090_PMIC_H_
+#define __TPS65090_PMIC_H_
+
+/* I2C device address for TPS65090 PMU */
+#define TPS65090_I2C_ADDR	0x48
+
+enum {
+	/* Status register fields */
+	TPS65090_ST1_OTC	= 1 << 0,
+	TPS65090_ST1_OCC	= 1 << 1,
+	TPS65090_ST1_STATE_SHIFT = 4,
+	TPS65090_ST1_STATE_MASK	= 0xf << TPS65090_ST1_STATE_SHIFT,
+};
+
+/* FET errors */
+enum {
+	FET_ERR_COMMS		= -1,	/* FET comms error */
+	FET_ERR_NOT_READY	= -2,	/* FET is not yet ready - retry */
+};
+
+/**
+ * Enable FET
+ *
+ * @param	fet_id	FET ID, value between 1 and 7
+ * @return	0 on success, non-0 on failure
+ */
+int tps65090_fet_enable(unsigned int fet_id);
+
+/**
+ * Disable FET
+ *
+ * @param	fet_id	FET ID, value between 1 and 7
+ * @return	0 on success, non-0 on failure
+ */
+int tps65090_fet_disable(unsigned int fet_id);
+
+/**
+ * Is FET enabled?
+ *
+ * @param	fet_id	FET ID, value between 1 and 7
+ * @return	1 enabled, 0 disabled, negative value on failure
+ */
+int tps65090_fet_is_enabled(unsigned int fet_id);
+
+/**
+ * Enable / disable the battery charger
+ *
+ * @param enable	0 to disable charging, non-zero to enable
+ */
+int tps65090_set_charge_enable(int enable);
+
+/**
+ * Check whether we have enabled battery charging
+ *
+ * @return 1 if enabled, 0 if disabled
+ */
+int tps65090_get_charging(void);
+
+/**
+ * Return the value of the status register
+ *
+ * @return status register value, or -1 on error
+ */
+int tps65090_get_status(void);
+
+/**
+ * Initialize the TPS65090 PMU.
+ *
+ * @return	0 on success, non-0 on failure
+ */
+int tps65090_init(void);
+
+#endif /* __TPS65090_PMIC_H_ */
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index e17dd00..d247366 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -63,6 +63,7 @@ static const char * const compat_names[COMPAT_COUNT] = {
 	COMPAT(MAXIM_MAX77686_PMIC, "maxim,max77686_pmic"),
 	COMPAT(GENERIC_SPI_FLASH, "spi-flash"),
 	COMPAT(MAXIM_98095_CODEC, "maxim,max98095-codec"),
+	COMPAT(TI_TPS65090, "ti,tps65090"),
 };
 
 const char *fdtdec_get_compatible(enum fdt_compat_id id)
-- 
1.8.1.3

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

* [U-Boot] [PATCH 2/4] exynos5: Enable tps65090 on smdk5250
  2013-04-02  0:04 [U-Boot] [PATCH 0/4] Add support for TI TPS65090 Simon Glass
  2013-04-02  0:04 ` [U-Boot] [PATCH 1/4] power: Add support for TPS65090 PMU chip Simon Glass
@ 2013-04-02  0:04 ` Simon Glass
  2013-04-02  0:04 ` [U-Boot] [PATCH 3/4] power: Explicitly select pmic device's bus Simon Glass
  2013-04-02  0:04 ` [U-Boot] [PATCH 4/4] exynos5: support tps65090 pmic Simon Glass
  3 siblings, 0 replies; 8+ messages in thread
From: Simon Glass @ 2013-04-02  0:04 UTC (permalink / raw)
  To: u-boot

From: Aaron Durbin <adurbin@chromium.org>

The TPS65090 pmic chip can be on exynos5250 boards. Therefore,
select the appropriate config option for TPS65090 devices.

This commit should really use exynos5-dt.c, when it is available.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 include/configs/exynos5250-dt.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h
index 2b9d6ac..4ae5b27 100644
--- a/include/configs/exynos5250-dt.h
+++ b/include/configs/exynos5250-dt.h
@@ -261,6 +261,7 @@
 #define CONFIG_POWER
 #define CONFIG_POWER_I2C
 #define CONFIG_POWER_MAX77686
+#define CONFIG_POWER_TPS65090
 
 /* SPI */
 #define CONFIG_ENV_IS_IN_SPI_FLASH
-- 
1.8.1.3

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

* [U-Boot] [PATCH 3/4] power: Explicitly select pmic device's bus
  2013-04-02  0:04 [U-Boot] [PATCH 0/4] Add support for TI TPS65090 Simon Glass
  2013-04-02  0:04 ` [U-Boot] [PATCH 1/4] power: Add support for TPS65090 PMU chip Simon Glass
  2013-04-02  0:04 ` [U-Boot] [PATCH 2/4] exynos5: Enable tps65090 on smdk5250 Simon Glass
@ 2013-04-02  0:04 ` Simon Glass
  2013-04-02  5:18   ` Rajeshwari Birje
  2013-04-02  0:04 ` [U-Boot] [PATCH 4/4] exynos5: support tps65090 pmic Simon Glass
  3 siblings, 1 reply; 8+ messages in thread
From: Simon Glass @ 2013-04-02  0:04 UTC (permalink / raw)
  To: u-boot

From: Aaron Durbin <adurbin@chromium.org>

The current pmic i2c code assumes the current i2c bus is
the same as the pmic device's bus. There is nothing ensuring
that to be true. Therefore, select the proper bus before performing
a transaction.

Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 drivers/power/power_i2c.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/power/power_i2c.c b/drivers/power/power_i2c.c
index 3e5a784..ec9701e 100644
--- a/drivers/power/power_i2c.c
+++ b/drivers/power/power_i2c.c
@@ -39,6 +39,8 @@ int pmic_reg_write(struct pmic *p, u32 reg, u32 val)
 	if (check_reg(p, reg))
 		return -1;
 
+	I2C_SET_BUS(p->bus);
+
 	switch (pmic_i2c_tx_num) {
 	case 3:
 		if (p->sensor_byte_order == PMIC_SENSOR_BYTE_ORDER_BIG) {
@@ -82,6 +84,8 @@ int pmic_reg_read(struct pmic *p, u32 reg, u32 *val)
 	if (check_reg(p, reg))
 		return -1;
 
+	I2C_SET_BUS(p->bus);
+
 	if (i2c_read(pmic_i2c_addr, reg, 1, buf, pmic_i2c_tx_num))
 		return -1;
 
-- 
1.8.1.3

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

* [U-Boot] [PATCH 4/4] exynos5: support tps65090 pmic
  2013-04-02  0:04 [U-Boot] [PATCH 0/4] Add support for TI TPS65090 Simon Glass
                   ` (2 preceding siblings ...)
  2013-04-02  0:04 ` [U-Boot] [PATCH 3/4] power: Explicitly select pmic device's bus Simon Glass
@ 2013-04-02  0:04 ` Simon Glass
  3 siblings, 0 replies; 8+ messages in thread
From: Simon Glass @ 2013-04-02  0:04 UTC (permalink / raw)
  To: u-boot

From: Aaron Durbin <adurbin@chromium.org>

The TSP65090 is a PMIC on some exynos5 boards. The init function is
called for the TPS65090 pmic. If that device is not a part of the device
tree (returns -ENODEV) then continue. Otherwise return a failure.

Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 board/samsung/smdk5250/smdk5250.c | 33 +++++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/board/samsung/smdk5250/smdk5250.c b/board/samsung/smdk5250/smdk5250.c
index 217c6df..06f9ea6 100644
--- a/board/samsung/smdk5250/smdk5250.c
+++ b/board/samsung/smdk5250/smdk5250.c
@@ -37,6 +37,7 @@
 #include <asm/arch/dp_info.h>
 #include <power/pmic.h>
 #include <power/max77686_pmic.h>
+#include <power/tps65090_pmic.h>
 #include <tmu.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -155,17 +156,10 @@ static int pmic_reg_update(struct pmic *p, int reg, uint regval)
 	return 0;
 }
 
-int power_init_board(void)
+int max77686_init(void)
 {
 	struct pmic *p;
 
-	set_ps_hold_ctrl();
-
-	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
-
-	if (pmic_init(I2C_PMIC))
-		return -1;
-
 	p = pmic_get("MAX77686_PMIC");
 	if (!p)
 		return -ENODEV;
@@ -250,6 +244,29 @@ int power_init_board(void)
 
 	return 0;
 }
+
+int power_init_board(void)
+{
+	int ret;
+
+	set_ps_hold_ctrl();
+
+	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+
+	if (pmic_init(I2C_PMIC))
+		return -1;
+
+	if (max77686_init())
+		return -1;
+
+	/* The TPS65090 may not be in the device tree. If so, it is not
+	 * an error. */
+	ret = tps65090_init();
+	if (ret == 0 || ret == -ENODEV)
+		return 0;
+
+	return -1;
+}
 #endif
 
 void dram_init_banksize(void)
-- 
1.8.1.3

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

* [U-Boot] [PATCH 3/4] power: Explicitly select pmic device's bus
  2013-04-02  0:04 ` [U-Boot] [PATCH 3/4] power: Explicitly select pmic device's bus Simon Glass
@ 2013-04-02  5:18   ` Rajeshwari Birje
  2013-05-11 18:55     ` Simon Glass
  0 siblings, 1 reply; 8+ messages in thread
From: Rajeshwari Birje @ 2013-04-02  5:18 UTC (permalink / raw)
  To: u-boot

Hi Simon,

Just had one following comment

On Tue, Apr 2, 2013 at 5:34 AM, Simon Glass <sjg@chromium.org> wrote:
> From: Aaron Durbin <adurbin@chromium.org>
>
> The current pmic i2c code assumes the current i2c bus is
> the same as the pmic device's bus. There is nothing ensuring
> that to be true. Therefore, select the proper bus before performing
> a transaction.
>
> Signed-off-by: Aaron Durbin <adurbin@chromium.org>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> ---
>  drivers/power/power_i2c.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/power/power_i2c.c b/drivers/power/power_i2c.c
> index 3e5a784..ec9701e 100644
> --- a/drivers/power/power_i2c.c
> +++ b/drivers/power/power_i2c.c
> @@ -39,6 +39,8 @@ int pmic_reg_write(struct pmic *p, u32 reg, u32 val)
>         if (check_reg(p, reg))
>                 return -1;
>
> +       I2C_SET_BUS(p->bus);
> +

Do we need to set I2C bus for each register read and write?
>         switch (pmic_i2c_tx_num) {
>         case 3:
>                 if (p->sensor_byte_order == PMIC_SENSOR_BYTE_ORDER_BIG) {
> @@ -82,6 +84,8 @@ int pmic_reg_read(struct pmic *p, u32 reg, u32 *val)
>         if (check_reg(p, reg))
>                 return -1;
>
> +       I2C_SET_BUS(p->bus);
> +
>         if (i2c_read(pmic_i2c_addr, reg, 1, buf, pmic_i2c_tx_num))
>                 return -1;
>
> --
> 1.8.1.3
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
-- 
Regards,
Rajeshwari Shinde

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

* [U-Boot] [PATCH 3/4] power: Explicitly select pmic device's bus
  2013-04-02  5:18   ` Rajeshwari Birje
@ 2013-05-11 18:55     ` Simon Glass
  0 siblings, 0 replies; 8+ messages in thread
From: Simon Glass @ 2013-05-11 18:55 UTC (permalink / raw)
  To: u-boot

Hi Rajeshwari,

On Mon, Apr 1, 2013 at 11:18 PM, Rajeshwari Birje
<rajeshwari.birje@gmail.com> wrote:
> Hi Simon,
>
> Just had one following comment
>
> On Tue, Apr 2, 2013 at 5:34 AM, Simon Glass <sjg@chromium.org> wrote:
>> From: Aaron Durbin <adurbin@chromium.org>
>>
>> The current pmic i2c code assumes the current i2c bus is
>> the same as the pmic device's bus. There is nothing ensuring
>> that to be true. Therefore, select the proper bus before performing
>> a transaction.
>>
>> Signed-off-by: Aaron Durbin <adurbin@chromium.org>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> Reviewed-by: Simon Glass <sjg@chromium.org>
>> ---
>>  drivers/power/power_i2c.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/power/power_i2c.c b/drivers/power/power_i2c.c
>> index 3e5a784..ec9701e 100644
>> --- a/drivers/power/power_i2c.c
>> +++ b/drivers/power/power_i2c.c
>> @@ -39,6 +39,8 @@ int pmic_reg_write(struct pmic *p, u32 reg, u32 val)
>>         if (check_reg(p, reg))
>>                 return -1;
>>
>> +       I2C_SET_BUS(p->bus);
>> +
>
> Do we need to set I2C bus for each register read and write?

It could potentially be done at a higher level, but it is tricky,
since the pmic is supposed to know its bus number. Nothing else should
need to know.

It's just setting a variable so does not take long. I think this sort
of thing will get cleaned up now that Heiko has posted the i2c
clean-up series (which I am going to take a look at).

Regards,
Simon


>>         switch (pmic_i2c_tx_num) {
>>         case 3:
>>                 if (p->sensor_byte_order == PMIC_SENSOR_BYTE_ORDER_BIG) {
>> @@ -82,6 +84,8 @@ int pmic_reg_read(struct pmic *p, u32 reg, u32 *val)
>>         if (check_reg(p, reg))
>>                 return -1;
>>
>> +       I2C_SET_BUS(p->bus);
>> +
>>         if (i2c_read(pmic_i2c_addr, reg, 1, buf, pmic_i2c_tx_num))
>>                 return -1;
>>
>> --
>> 1.8.1.3
>>
>> _______________________________________________
>> U-Boot mailing list
>> U-Boot at lists.denx.de
>> http://lists.denx.de/mailman/listinfo/u-boot
> --
> Regards,
> Rajeshwari Shinde

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

* [U-Boot] [PATCH 1/4] power: Add support for TPS65090 PMU chip.
  2013-04-02  0:04 ` [U-Boot] [PATCH 1/4] power: Add support for TPS65090 PMU chip Simon Glass
@ 2014-01-02  6:37   ` Minkyu Kang
  0 siblings, 0 replies; 8+ messages in thread
From: Minkyu Kang @ 2014-01-02  6:37 UTC (permalink / raw)
  To: u-boot

Hello,

On 02/04/13 09:04, Simon Glass wrote:
> From: Tom Wai-Hong Tam <waihong@chromium.org>
> 
> This adds driver support for the TPS65090 PMU. Support includes
> hooking into the pmic infrastructure  so that the pmic commands
> can be used on the console. The TPS65090 supports the following
> functionality:
> 
> - fet enable/disable/querying
> - getting and setting of charge state
> 
> Even though it is connected to the pmic infrastructure it does
> not hook into the pmic charging charging infrastructure.
> 
> Signed-off-by: Tom Wai-Hong Tam <waihong@chromium.org>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Hatim Ali <hatim.rv@samsung.com>
> Signed-off-by: Katie Roberts-Hoffman <katierh@chromium.org>
> Signed-off-by: Rong Chang <rongchang@chromium.org>
> Signed-off-by: Sean Paul <seanpaul@chromium.org>
> Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
> Signed-off-by: Aaron Durbin <adurbin@chromium.org>
> ---
>  doc/device-tree-bindings/power/tps65090.txt |  21 ++
>  drivers/power/pmic/Makefile                 |   1 +
>  drivers/power/pmic/pmic_tps65090.c          | 296 ++++++++++++++++++++++++++++
>  include/fdtdec.h                            |   1 +
>  include/power/tps65090_pmic.h               |  83 ++++++++
>  lib/fdtdec.c                                |   1 +
>  6 files changed, 403 insertions(+)
>  create mode 100644 doc/device-tree-bindings/power/tps65090.txt
>  create mode 100644 drivers/power/pmic/pmic_tps65090.c
>  create mode 100644 include/power/tps65090_pmic.h
> 

Is this patch still available?
also,
http://patchwork.ozlabs.org/patch/232842/
and
http://patchwork.ozlabs.org/patch/232849/

I didn't notice that patch was delegated to me, because this patch is for power.
I'm sorry for long pending.

Thanks,
Minkyu Kang.

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

end of thread, other threads:[~2014-01-02  6:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-02  0:04 [U-Boot] [PATCH 0/4] Add support for TI TPS65090 Simon Glass
2013-04-02  0:04 ` [U-Boot] [PATCH 1/4] power: Add support for TPS65090 PMU chip Simon Glass
2014-01-02  6:37   ` Minkyu Kang
2013-04-02  0:04 ` [U-Boot] [PATCH 2/4] exynos5: Enable tps65090 on smdk5250 Simon Glass
2013-04-02  0:04 ` [U-Boot] [PATCH 3/4] power: Explicitly select pmic device's bus Simon Glass
2013-04-02  5:18   ` Rajeshwari Birje
2013-05-11 18:55     ` Simon Glass
2013-04-02  0:04 ` [U-Boot] [PATCH 4/4] exynos5: support tps65090 pmic Simon Glass

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.