summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/freescale/mx7d_12x12_lpddr3_arm2/mx7d_12x12_lpddr3_arm2.c64
-rw-r--r--board/freescale/mx7dsabresd/mx7dsabresd.c64
-rw-r--r--drivers/power/pmic/Makefile1
-rw-r--r--drivers/power/pmic/pmic_pfuze300.c32
-rw-r--r--include/configs/mx7d_12x12_lpddr3_arm2.h10
-rw-r--r--include/configs/mx7dsabresd.h9
-rw-r--r--include/power/pfuze300_pmic.h78
7 files changed, 168 insertions, 90 deletions
diff --git a/board/freescale/mx7d_12x12_lpddr3_arm2/mx7d_12x12_lpddr3_arm2.c b/board/freescale/mx7d_12x12_lpddr3_arm2/mx7d_12x12_lpddr3_arm2.c
index cd1dabe..6122308 100644
--- a/board/freescale/mx7d_12x12_lpddr3_arm2/mx7d_12x12_lpddr3_arm2.c
+++ b/board/freescale/mx7d_12x12_lpddr3_arm2/mx7d_12x12_lpddr3_arm2.c
@@ -18,6 +18,9 @@
#include <mmc.h>
#include <miiphy.h>
#include <netdev.h>
+#include <power/pmic.h>
+#include <power/pfuze300_pmic.h>
+#include "../common/pfuze.h"
#ifdef CONFIG_SYS_I2C_MXC
#include <i2c.h>
#include <asm/imx-common/mxc_i2c.h>
@@ -586,42 +589,31 @@ static const struct boot_mode board_boot_modes[] = {
};
#endif
-#ifdef CONFIG_PFUZE3000_PMIC_I2C
-#define PFUZE_DEVICEID 0x0
-#define PFUZE_REVID 0x3
-#define PFUZE_FABID 0x4
-
-#define PFUZE_LDOGCTL 0x69
-
-static int setup_pmic_voltages(void)
+#ifdef CONFIG_POWER
+#define I2C_PMIC 0
+int power_init_board(void)
{
- unsigned char value, rev_id = 0;
+ struct pmic *p;
+ int ret;
+ unsigned int reg, rev_id;
- i2c_set_bus_num(CONFIG_PMIC_I2C_BUS);
+ ret = power_pfuze300_init(I2C_PMIC);
+ if (ret)
+ return ret;
- i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_PMIC_I2C_SLAVE);
- if (!i2c_probe(CONFIG_PMIC_I2C_SLAVE)) {
- if (i2c_read(CONFIG_PMIC_I2C_SLAVE, PFUZE_DEVICEID, 1, &value, 1)) {
- printf("Read device ID error!\n");
- return -1;
- }
- if (i2c_read(CONFIG_PMIC_I2C_SLAVE, PFUZE_REVID, 1, &rev_id, 1)) {
- printf("Read Rev ID error!\n");
- return -1;
- }
- printf("Found PFUZE300! deviceid 0x%x, revid 0x%x\n", value, rev_id);
+ p = pmic_get("PFUZE300");
+ ret = pmic_probe(p);
+ if (ret)
+ return ret;
- /* disable Low Power Mode during standby mode */
- if (i2c_read(CONFIG_PMIC_I2C_SLAVE, PFUZE_LDOGCTL, 1, &value, 1)) {
- printf("Read LDOCTL error!\n");
- return -1;
- }
- value |= 0x1;
- if (i2c_write(CONFIG_PMIC_I2C_SLAVE, PFUZE_LDOGCTL, 1, &value, 1)) {
- printf("Set LDOCTL error!\n");
- return -1;
- }
- }
+ pmic_reg_read(p, PFUZE300_DEVICEID, &reg);
+ pmic_reg_read(p, PFUZE300_REVID, &rev_id);
+ printf("PMIC: PFUZE300 DEV_ID=0x%x REV_ID=0x%x\n", reg, rev_id);
+
+ /* disable Low Power Mode during standby mode */
+ pmic_reg_read(p, PFUZE300_LDOGCTL, &reg);
+ reg |= 0x1;
+ pmic_reg_write(p, PFUZE300_LDOGCTL, reg);
return 0;
}
@@ -633,14 +625,6 @@ int board_late_init(void)
add_board_boot_modes(board_boot_modes);
#endif
-#ifdef CONFIG_PFUZE3000_PMIC_I2C
- int ret = 0;
-
- ret = setup_pmic_voltages();
- if (ret)
- return ret;
-#endif
-
#ifdef CONFIG_ENV_IS_IN_MMC
board_late_mmc_init();
#endif
diff --git a/board/freescale/mx7dsabresd/mx7dsabresd.c b/board/freescale/mx7dsabresd/mx7dsabresd.c
index 13aed0e..f7188af 100644
--- a/board/freescale/mx7dsabresd/mx7dsabresd.c
+++ b/board/freescale/mx7dsabresd/mx7dsabresd.c
@@ -18,6 +18,9 @@
#include <mmc.h>
#include <miiphy.h>
#include <netdev.h>
+#include <power/pmic.h>
+#include <power/pfuze300_pmic.h>
+#include "../common/pfuze.h"
#ifdef CONFIG_SYS_I2C_MXC
#include <i2c.h>
#include <asm/imx-common/mxc_i2c.h>
@@ -788,42 +791,31 @@ static const struct boot_mode board_boot_modes[] = {
};
#endif
-#ifdef CONFIG_PFUZE3000_PMIC_I2C
-#define PFUZE_DEVICEID 0x0
-#define PFUZE_REVID 0x3
-#define PFUZE_FABID 0x4
-
-#define PFUZE_LDOGCTL 0x69
-
-static int setup_pmic_voltages(void)
+#ifdef CONFIG_POWER
+#define I2C_PMIC 0
+int power_init_board(void)
{
- unsigned char value, rev_id = 0;
+ struct pmic *p;
+ int ret;
+ unsigned int reg, rev_id;
- i2c_set_bus_num(CONFIG_PMIC_I2C_BUS);
+ ret = power_pfuze300_init(I2C_PMIC);
+ if (ret)
+ return ret;
- i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_PMIC_I2C_SLAVE);
- if (!i2c_probe(CONFIG_PMIC_I2C_SLAVE)) {
- if (i2c_read(CONFIG_PMIC_I2C_SLAVE, PFUZE_DEVICEID, 1, &value, 1)) {
- printf("Read device ID error!\n");
- return -1;
- }
- if (i2c_read(CONFIG_PMIC_I2C_SLAVE, PFUZE_REVID, 1, &rev_id, 1)) {
- printf("Read Rev ID error!\n");
- return -1;
- }
- printf("Found PFUZE300! deviceid 0x%x, revid 0x%x\n", value, rev_id);
+ p = pmic_get("PFUZE300");
+ ret = pmic_probe(p);
+ if (ret)
+ return ret;
- /* disable Low Power Mode during standby mode */
- if (i2c_read(CONFIG_PMIC_I2C_SLAVE, PFUZE_LDOGCTL, 1, &value, 1)) {
- printf("Read LDOCTL error!\n");
- return -1;
- }
- value |= 0x1;
- if (i2c_write(CONFIG_PMIC_I2C_SLAVE, PFUZE_LDOGCTL, 1, &value, 1)) {
- printf("Set LDOCTL error!\n");
- return -1;
- }
- }
+ pmic_reg_read(p, PFUZE300_DEVICEID, &reg);
+ pmic_reg_read(p, PFUZE300_REVID, &rev_id);
+ printf("PMIC: PFUZE300 DEV_ID=0x%x REV_ID=0x%x\n", reg, rev_id);
+
+ /* disable Low Power Mode during standby mode */
+ pmic_reg_read(p, PFUZE300_LDOGCTL, &reg);
+ reg |= 0x1;
+ pmic_reg_write(p, PFUZE300_LDOGCTL, reg);
return 0;
}
@@ -835,14 +827,6 @@ int board_late_init(void)
add_board_boot_modes(board_boot_modes);
#endif
-#ifdef CONFIG_PFUZE3000_PMIC_I2C
- int ret = 0;
-
- ret = setup_pmic_voltages();
- if (ret)
- return ret;
-#endif
-
#ifdef CONFIG_ENV_IS_IN_MMC
board_late_mmc_init();
#endif
diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile
index 985cfdb..b6257c9 100644
--- a/drivers/power/pmic/Makefile
+++ b/drivers/power/pmic/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_POWER_MAX8997) += pmic_max8997.o
obj-$(CONFIG_POWER_MUIC_MAX8997) += muic_max8997.o
obj-$(CONFIG_POWER_MAX77686) += pmic_max77686.o
obj-$(CONFIG_POWER_PFUZE100) += pmic_pfuze100.o
+obj-$(CONFIG_POWER_PFUZE300) += pmic_pfuze300.o
obj-$(CONFIG_POWER_TPS65090_I2C) += pmic_tps65090.o
obj-$(CONFIG_POWER_TPS65090_EC) += pmic_tps65090_ec.o
obj-$(CONFIG_POWER_TPS65217) += pmic_tps65217.o
diff --git a/drivers/power/pmic/pmic_pfuze300.c b/drivers/power/pmic/pmic_pfuze300.c
new file mode 100644
index 0000000..4304ddd
--- /dev/null
+++ b/drivers/power/pmic/pmic_pfuze300.c
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2015 Freescale Semiconductor, Inc.
+ * Peng Fan <Peng.Fan@freescale.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <i2c.h>
+#include <power/pmic.h>
+#include <power/pfuze300_pmic.h>
+
+int power_pfuze300_init(unsigned char bus)
+{
+ static const char name[] = "PFUZE300";
+ struct pmic *p = pmic_alloc();
+
+ if (!p) {
+ printf("%s: POWER allocation error!\n", __func__);
+ return -ENOMEM;
+ }
+
+ p->name = name;
+ p->interface = PMIC_I2C;
+ p->number_of_regs = PMIC_NUM_OF_REGS;
+ p->hw.i2c.addr = CONFIG_POWER_PFUZE300_I2C_ADDR;
+ p->hw.i2c.tx_num = 1;
+ p->bus = bus;
+
+ return 0;
+}
diff --git a/include/configs/mx7d_12x12_lpddr3_arm2.h b/include/configs/mx7d_12x12_lpddr3_arm2.h
index 8bdc3da..c6cd1c1 100644
--- a/include/configs/mx7d_12x12_lpddr3_arm2.h
+++ b/include/configs/mx7d_12x12_lpddr3_arm2.h
@@ -45,11 +45,11 @@
#endif
/* PMIC */
-#define CONFIG_PFUZE3000_PMIC_I2C
-#ifdef CONFIG_PFUZE3000_PMIC_I2C
-#define CONFIG_PMIC_I2C_BUS 0
-#define CONFIG_PMIC_I2C_SLAVE 0x8
-#endif
+/* PMIC */
+#define CONFIG_POWER
+#define CONFIG_POWER_I2C
+#define CONFIG_POWER_PFUZE300
+#define CONFIG_POWER_PFUZE300_I2C_ADDR 0x08
#ifdef CONFIG_SYS_USE_SPINOR
#define CONFIG_CMD_SF
diff --git a/include/configs/mx7dsabresd.h b/include/configs/mx7dsabresd.h
index 014e86a..c52e44a 100644
--- a/include/configs/mx7dsabresd.h
+++ b/include/configs/mx7dsabresd.h
@@ -84,11 +84,10 @@
#define IMX_FEC_BASE ENET_IPS_BASE_ADDR
/* PMIC */
-#define CONFIG_PFUZE3000_PMIC_I2C
-#ifdef CONFIG_PFUZE3000_PMIC_I2C
-#define CONFIG_PMIC_I2C_BUS 0
-#define CONFIG_PMIC_I2C_SLAVE 0x8
-#endif
+#define CONFIG_POWER
+#define CONFIG_POWER_I2C
+#define CONFIG_POWER_PFUZE300
+#define CONFIG_POWER_PFUZE300_I2C_ADDR 0x08
#undef CONFIG_BOOTM_NETBSD
#undef CONFIG_BOOTM_PLAN9
diff --git a/include/power/pfuze300_pmic.h b/include/power/pfuze300_pmic.h
new file mode 100644
index 0000000..c7ec5ce
--- /dev/null
+++ b/include/power/pfuze300_pmic.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2015 Freescale Semiconductor, Inc
+ * Peng Fan <Peng.Fan@freescale.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+#ifndef __PFUZE300_PMIC_H_
+#define __PFUZE300_PMIC_H_
+
+/* PFUZE300 registers */
+enum {
+ PFUZE300_DEVICEID = 0x00,
+
+ PFUZE300_REVID = 0x03,
+ PFUZE300_FABID = 0x04,
+ PFUZE300_INTSTAT0 = 0x05,
+ PFUZE300_INTMASK0 = 0x06,
+ PFUZE300_INTSENSE0 = 0x07,
+ PFUZE300_INTSTAT1 = 0x08,
+ PFUZE300_INTMASK1 = 0x09,
+ PFUZE300_INTSENSE1 = 0x0A,
+
+ PFUZE300_INTSTAT3 = 0x0E,
+ PFUZE300_INTMASK3 = 0x0F,
+ PFUZE300_INTSENSE3 = 0x10,
+ PFUZE300_INTSTAT4 = 0x11,
+ PFUZE300_INTMASK4 = 0x12,
+ PFUZE300_INTSENSE4 = 0x13,
+
+ PFUZE300_COINCTL = 0x1A,
+ PFUZE300_PWRCTL = 0x1B,
+ PFUZE300_MEMA = 0x1C,
+ PFUZE300_MEMB = 0x1D,
+ PFUZE300_MEMC = 0x1E,
+ PFUZE300_MEMD = 0x1F,
+
+ PFUZE300_SW1AVOLT = 0x20,
+ PFUZE300_SW1ASTBY = 0x21,
+ PFUZE300_SW1AOFF = 0x22,
+ PFUZE300_SW1AMODE = 0x23,
+ PFUZE300_SW1ACONF = 0x24,
+
+ PFUZE300_SW1BVOLT = 0x2E,
+ PFUZE300_SW1BSTBY = 0x2F,
+ PFUZE300_SW1BOFF = 0x30,
+ PFUZE300_SW1BMODE = 0x31,
+ PFUZE300_SW1BCONF = 0x32,
+
+ PFUZE300_SW2VOLT = 0x35,
+ PFUZE300_SW2STBY = 0x36,
+ PFUZE300_SW2OFF = 0x37,
+ PFUZE300_SW2MODE = 0x38,
+ PFUZE300_SW2CONF = 0x39,
+
+ PFUZE300_SW3VOLT = 0x3C,
+ PFUZE300_SW3STBY = 0x3D,
+ PFUZE300_SW3OFF = 0x3E,
+ PFUZE300_SW3MODE = 0x3F,
+ PFUZE300_SW3CONF = 0x40,
+
+ PFUZE300_SWBSTCTL = 0x66,
+
+ PFUZE300_LDOGCTL = 0x69,
+ PFUZE300_VREFDDRCTL = 0x6A,
+ PFUZE300_VSNVSCTL = 0x6B,
+ PFUZE300_VLDO1CTL = 0x6C,
+ PFUZE300_VLDO2CTL = 0x6D,
+ PFUZE300_VCC_SDCTL = 0x6E,
+ PFUZE300_V33CTL = 0x6F,
+ PFUZE300_VLDO3CTL = 0x70,
+ PFUZE300_VLD4CTL = 0x71,
+
+ PMIC_NUM_OF_REGS = 0x7F,
+};
+
+int power_pfuze300_init(unsigned char bus);
+
+#endif