Skip to contentSkip to conversation

imx: mx6sabre common: Factorize the Pfuze init function

PATCH New Ye.Li 1 participant 4 messages Sep 15, 2014

lore
Share & tools
lore

Ye.Li

author
#0 lore raw

PATCH v2 1/4 imx: mx6sabre common: Factorize the Pfuze init function

Since the Pfuze initializations are similar on various mx6 SABRE boards. Factorize the initialization to a common function in file board/freescale/common/pfuze.c. So that all SABRE boards BSP can share the function.

---
Changes since v1:
- Factorize the pfuze init function for sabre boards.

 board/freescale/common/Makefile |    1 +
 board/freescale/common/pfuze.c  |   54 +++++++++++++++++++++++++++++++++++++++
 board/freescale/common/pfuze.h  |   12 ++++++++
 3 files changed, 67 insertions(+), 0 deletions(-)
 create mode 100644 board/freescale/common/pfuze.c
 create mode 100644 board/freescale/common/pfuze.h
board/freescale/common/Makefile +1 -0
index 22b57cc..66fbdbc 100644
@@ -49,6 +49,7 @@ obj-$(CONFIG_P5040DS)		+= ics307_clk.o
 obj-$(CONFIG_VSC_CROSSBAR)    += vsc3316_3308.o
 obj-$(CONFIG_IDT8T49N222A)	+= idt8t49n222a_serdes_clk.o
 obj-$(CONFIG_ZM7300)		+= zm7300.o
+obj-$(CONFIG_POWER_PFUZE100)	+= pfuze.o
 
 # deal with common files for P-series corenet based devices
 obj-$(CONFIG_P2041RDB)	+= p_corenet/
board/freescale/common/pfuze.c new file +54 -0

54 lines not on this page · raw message

board/freescale/common/pfuze.h new file +12 -0
new file mode 100644
index 0000000..c5d1771
@@ -0,0 +1,12 @@
+/*
+ * Copyright 2014 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __PFUZE_BOARD_HELPER__
+#define __PFUZE_BOARD_HELPER__
+
+struct pmic * pfuze_common_init(unsigned char i2cbus);
+
+#endif
Signature · 1 line
1.7.4.1
author
#1 lore raw

PATCH v2 2/4 imx: mx6sabresd: Use the pfuze common init function

Modify the pfuze init for mx6q/dlsabresd to use the shared "pfuze_common_init" function.

---
Changes since v1:
- Factorize the pfuze init function for sabre boards.

 board/freescale/mx6sabresd/mx6sabresd.c |   40 +++---------------------------
 1 files changed, 4 insertions(+), 36 deletions(-)
board/freescale/mx6sabresd/mx6sabresd.c +4 -36
index 5f65f1b..53e548b 100644
@@ -27,6 +27,7 @@
 #include <i2c.h>
 #include <power/pmic.h>
 #include <power/pfuze100_pmic.h>
+#include "../common/pfuze.h"
 DECLARE_GLOBAL_DATA_PTR;
 
 #define UART_PAD_CTRL  (PAD_CTL_PUS_100K_UP |			\
@@ -459,20 +460,11 @@ int board_init(void)
 static int pfuze_init(void)
 {
 	struct pmic *p;
-	int ret;
 	unsigned int reg;
 
-	ret = power_pfuze100_init(I2C_PMIC);
-	if (ret)
-		return ret;
-
-	p = pmic_get("PFUZE100");
-	ret = pmic_probe(p);
-	if (ret)
-		return ret;
-
-	pmic_reg_read(p, PFUZE100_DEVICEID, &reg);
-	printf("PMIC:  PFUZE100 ID=0x%02x\n", reg);
+	p = pfuze_common_init(I2C_PMIC);
+	if (!p)
+		return -ENODEV;
 
 	/* Increase VGEN3 from 2.5 to 2.8V */
 	pmic_reg_read(p, PFUZE100_VGEN3VOL, &reg);
@@ -486,30 +478,6 @@ static int pfuze_init(void)
 	reg |= 0xc;
 	pmic_reg_write(p, PFUZE100_VGEN5VOL, reg);
 
-	/* Set SW1AB stanby volage to 0.975V */
-	pmic_reg_read(p, PFUZE100_SW1ABSTBY, &reg);
-	reg &= ~0x3f;
-	reg |= 0x1b;
-	pmic_reg_write(p, PFUZE100_SW1ABSTBY, reg);
-
-	/* Set SW1AB/VDDARM step ramp up time from 16us to 4us/25mV */
-	pmic_reg_read(p, PUZE_100_SW1ABCONF, &reg);
-	reg &= ~0xc0;
-	reg |= 0x40;
-	pmic_reg_write(p, PUZE_100_SW1ABCONF, reg);
-
-	/* Set SW1C standby voltage to 0.975V */
-	pmic_reg_read(p, PFUZE100_SW1CSTBY, &reg);
-	reg &= ~0x3f;
-	reg |= 0x1b;
-	pmic_reg_write(p, PFUZE100_SW1CSTBY, reg);
-
-	/* Set SW1C/VDDSOC step ramp up time from 16us to 4us/25mV */
-	pmic_reg_read(p, PFUZE100_SW1CCONF, &reg);
-	reg &= ~0xc0;
-	reg |= 0x40;
-	pmic_reg_write(p, PFUZE100_SW1CCONF, reg);
-
 	return 0;
 }
 
Signature · 1 line
1.7.4.1
author
#2 lore raw

PATCH v2 3/4 imx: mx6sxsabresd: Use the pfuze common init function

In reply to Ye.Li

Modify the pfuze init for mx6sxsabresd to use the shared "pfuze_common_init" function.

---
Changes since v1:
- Factorize the pfuze init function for sabre boards.

 board/freescale/mx6sxsabresd/mx6sxsabresd.c |   40 +++------------------------
 1 files changed, 4 insertions(+), 36 deletions(-)
board/freescale/mx6sxsabresd/mx6sxsabresd.c +4 -36
index 80d2d99..ea06ac3 100644
@@ -25,6 +25,7 @@
 #include <netdev.h>
 #include <power/pmic.h>
 #include <power/pfuze100_pmic.h>
+#include "../common/pfuze.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -173,44 +174,11 @@ struct i2c_pads_info i2c_pad_info1 = {
 static int pfuze_init(void)
 {
 	struct pmic *p;
-	int ret;
 	unsigned int reg;
 
-	ret = power_pfuze100_init(I2C_PMIC);
-	if (ret)
-		return ret;
-
-	p = pmic_get("PFUZE100");
-	ret = pmic_probe(p);
-	if (ret)
-		return ret;
-
-	pmic_reg_read(p, PFUZE100_DEVICEID, &reg);
-	printf("PMIC:  PFUZE100 ID=0x%02x\n", reg);
-
-	/* Set SW1AB standby voltage to 0.975V */
-	pmic_reg_read(p, PFUZE100_SW1ABSTBY, &reg);
-	reg &= ~0x3f;
-	reg |= 0x1b;
-	pmic_reg_write(p, PFUZE100_SW1ABSTBY, reg);
-
-	/* Set SW1AB/VDDARM step ramp up time from 16us to 4us/25mV */
-	pmic_reg_read(p, PUZE_100_SW1ABCONF, &reg);
-	reg &= ~0xc0;
-	reg |= 0x40;
-	pmic_reg_write(p, PUZE_100_SW1ABCONF, reg);
-
-	/* Set SW1C standby voltage to 0.975V */
-	pmic_reg_read(p, PFUZE100_SW1CSTBY, &reg);
-	reg &= ~0x3f;
-	reg |= 0x1b;
-	pmic_reg_write(p, PFUZE100_SW1CSTBY, reg);
-
-	/* Set SW1C/VDDSOC step ramp up time from 16us to 4us/25mV */
-	pmic_reg_read(p, PFUZE100_SW1CCONF, &reg);
-	reg &= ~0xc0;
-	reg |= 0x40;
-	pmic_reg_write(p, PFUZE100_SW1CCONF, reg);
+	p = pfuze_common_init(I2C_PMIC);
+	if (!p)
+		return -ENODEV;
 
 	/* Enable power of VGEN5 3V3, needed for SD3 */
 	pmic_reg_read(p, PFUZE100_VGEN5VOL, &reg);
Signature · 1 line
1.7.4.1
author
#3 lore raw

PATCH v2 4/4 imx: imx6q/dlsabreauto: Add PMIC Pfuze100 support

In reply to Ye.Li

Initialize the pfuze100 at board late init.

---
Changes since v1:
- Factorize the pfuze init function for sabre boards.

 board/freescale/mx6qsabreauto/mx6qsabreauto.c |   20 ++++++++++++++++++--
 include/configs/mx6qsabreauto.h               |    6 ++++++
 2 files changed, 24 insertions(+), 2 deletions(-)
board/freescale/mx6qsabreauto/mx6qsabreauto.c +18 -2
index bfb9b6a..fbb65c2 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Freescale Semiconductor, Inc.
+ * Copyright (C) 2012-2014 Freescale Semiconductor, Inc.
  *
  * Author: Fabio Estevam <[email protected]>
  *
@@ -23,7 +23,8 @@
 #include <netdev.h>
 #include <asm/arch/sys_proto.h>
 #include <i2c.h>
-
+#include <power/pmic.h>
+#include "../common/pfuze.h"
 DECLARE_GLOBAL_DATA_PTR;
 
 #define UART_PAD_CTRL  (PAD_CTL_PUS_100K_UP |			\
@@ -43,6 +44,8 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
 
+#define I2C_PMIC	1
+
 int dram_init(void)
 {
 	gd->ram_size = (phys_size_t)CONFIG_DDR_MB * 1024 * 1024;
@@ -259,6 +262,18 @@ int board_init(void)
 	return 0;
 }
 
+static int pfuze_init(void)
+{
+	struct pmic *p;
+
+	p = pfuze_common_init(I2C_PMIC);
+	if (!p)
+		return -ENODEV;
+
+	return 0;
+}
+
+
 #ifdef CONFIG_CMD_BMODE
 static const struct boot_mode board_boot_modes[] = {
 	/* 4 bit bus width */
@@ -272,6 +287,7 @@ int board_late_init(void)
 #ifdef CONFIG_CMD_BMODE
 	add_board_boot_modes(board_boot_modes);
 #endif
+	pfuze_init();
 
 	return 0;
 }
include/configs/mx6qsabreauto.h +6 -0
index e8580e6..d82563f 100644
@@ -40,6 +40,12 @@
 #define CONFIG_SYS_I2C_MXC
 #define CONFIG_SYS_I2C_SPEED		100000
 
+/* PMIC */
+#define CONFIG_POWER
+#define CONFIG_POWER_I2C
+#define CONFIG_POWER_PFUZE100
+#define CONFIG_POWER_PFUZE100_I2C_ADDR	0x08
+
 #define CONFIG_OF_SEPARATE
 #define CONFIG_DEFAULT_DEVICE_TREE   imx6q-sabreauto
 
Signature · 1 line
1.7.4.1