public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] switch to generic PMIC driver for i.MX boards
@ 2011-10-08 16:35 Stefano Babic
  2011-10-08 16:35 ` [U-Boot] [PATCH 01/13] MX5: vision2: use new pmic driver Stefano Babic
                   ` (14 more replies)
  0 siblings, 15 replies; 42+ messages in thread
From: Stefano Babic @ 2011-10-08 16:35 UTC (permalink / raw)
  To: u-boot

Changes from V1: please ignore V1, a couple of patches were
not sent.

This patchset is based on ?ukasz Majewski's patches that
introduce a generic PMIC (Power Microcontroller) driver:

http://patchwork.ozlabs.org/patch/117565/
http://patchwork.ozlabs.org/patch/117563/
http://patchwork.ozlabs.org/patch/117818/
http://patchwork.ozlabs.org/patch/118071/

The patchset replaced the old driver used on i.MX boards
(Freescale PMIC) and switches to the new generic driver.

 board/davedenx/qong/qong.c        |   11 ++-
 board/efikamx/efikamx.c           |   51 +++++----
 board/freescale/mx35pdk/mx35pdk.c |   18 ++-
 board/freescale/mx51evk/mx51evk.c |   47 ++++----
 board/freescale/mx53evk/mx53evk.c |   17 ++-
 board/ttcontrol/vision2/vision2.c |   33 +++---
 drivers/i2c/mxc_i2c.c             |    5 +
 drivers/misc/Makefile             |    1 -
 drivers/misc/fsl_pmic.c           |  235 -------------------------------------
 drivers/misc/pmic_fsl.c           |   17 ++-
 drivers/rtc/mc13783-rtc.c         |   20 ++--
 include/configs/efikamx.h         |    5 +-
 include/configs/imx31_litekit.h   |    9 +-
 include/configs/mx31ads.h         |    8 +-
 include/configs/mx31pdk.h         |    6 +-
 include/configs/mx35pdk.h         |    5 +-
 include/configs/mx51evk.h         |    6 +-
 include/configs/mx53evk.h         |    5 +-
 include/configs/qong.h            |    5 +-
 include/configs/vision2.h         |    5 +-
 20 files changed, 174 insertions(+), 335 deletions(-)


[PATCH 01/13] MX5: vision2: use new pmic driver
[PATCH 02/13] RTC: Switch mc13783 to generic pmic code
[PATCH 03/13] MX3: qong: use new pmic driver
[PATCH V2 04/13] MX5: efikamx/efikasb: use new pmic driver
[PATCH 05/13] I2c: add missing i2c_set_bus_num to mxc_i2c
[PATCH V2 06/13] misc: pmic: addI2C  support to pmic_fsl driver
[PATCH 07/13] MX35: mx35pdk: use new pmic driver
[PATCH V2 08/13] MX5: mx51evk: use new pmic driver
[PATCH V2 09/13] MX5: mx53evk: use new pmic driver
[PATCH 10/13] MX31: mx31_litekit: use new pmic driver
[PATCH 11/13] MX31: mx31ads: use new pmic driver
[PATCH 12/13] MX31: mx31pdk: use new pmic driver
[PATCH 13/13] misc: pmic: drop old Freescale's pmic driver

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

* [U-Boot] [PATCH 01/13] MX5: vision2: use new pmic driver
  2011-10-08 16:35 [U-Boot] switch to generic PMIC driver for i.MX boards Stefano Babic
@ 2011-10-08 16:35 ` Stefano Babic
  2011-10-08 16:35 ` [U-Boot] [PATCH 02/13] RTC: Switch mc13783 to generic pmic code Stefano Babic
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 42+ messages in thread
From: Stefano Babic @ 2011-10-08 16:35 UTC (permalink / raw)
  To: u-boot

Switch to new pmic generic driver.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 board/ttcontrol/vision2/vision2.c |   33 +++++++++++++++++++--------------
 include/configs/vision2.h         |    5 ++++-
 2 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/board/ttcontrol/vision2/vision2.c b/board/ttcontrol/vision2/vision2.c
index e496f64..d3815b2 100644
--- a/board/ttcontrol/vision2/vision2.c
+++ b/board/ttcontrol/vision2/vision2.c
@@ -34,6 +34,7 @@
 #include <asm/errno.h>
 #include <i2c.h>
 #include <mmc.h>
+#include <pmic.h>
 #include <fsl_esdhc.h>
 #include <fsl_pmic.h>
 #include <mc13892.h>
@@ -313,59 +314,63 @@ static void reset_peripherals(int reset)
 static void power_init_mx51(void)
 {
 	unsigned int val;
+	struct pmic *p;
+
+	pmic_init();
+	p = get_pmic();
 
 	/* Write needed to Power Gate 2 register */
-	val = pmic_reg_read(REG_POWER_MISC);
+	pmic_reg_read(p, REG_POWER_MISC, &val);
 
 	/* enable VCAM with 2.775V to enable read from PMIC */
 	val = VCAMCONFIG | VCAMEN;
-	pmic_reg_write(REG_MODE_1, val);
+	pmic_reg_write(p, REG_MODE_1, val);
 
 	/*
 	 * Set switchers in Auto in NORMAL mode & STANDBY mode
 	 * Setup the switcher mode for SW1 & SW2
 	 */
-	val = pmic_reg_read(REG_SW_4);
+	pmic_reg_read(p, REG_SW_4, &val);
 	val = (val & ~((SWMODE_MASK << SWMODE1_SHIFT) |
 		(SWMODE_MASK << SWMODE2_SHIFT)));
 	val |= (SWMODE_AUTO_AUTO << SWMODE1_SHIFT) |
 		(SWMODE_AUTO_AUTO << SWMODE2_SHIFT);
-	pmic_reg_write(REG_SW_4, val);
+	pmic_reg_write(p, REG_SW_4, val);
 
 	/* Setup the switcher mode for SW3 & SW4 */
-	val = pmic_reg_read(REG_SW_5);
+	pmic_reg_read(p, REG_SW_5, &val);
 	val &= ~((SWMODE_MASK << SWMODE4_SHIFT) |
 		(SWMODE_MASK << SWMODE3_SHIFT));
 	val |= (SWMODE_AUTO_AUTO << SWMODE4_SHIFT) |
 		(SWMODE_AUTO_AUTO << SWMODE3_SHIFT);
-	pmic_reg_write(REG_SW_5, val);
+	pmic_reg_write(p, REG_SW_5, val);
 
 
 	/* Set VGEN3 to 1.8V, VCAM to 3.0V */
-	val = pmic_reg_read(REG_SETTING_0);
+	pmic_reg_read(p, REG_SETTING_0, &val);
 	val &= ~(VCAM_MASK | VGEN3_MASK);
 	val |= VCAM_3_0;
-	pmic_reg_write(REG_SETTING_0, val);
+	pmic_reg_write(p, REG_SETTING_0, val);
 
 	/* Set VVIDEO to 2.775V, VAUDIO to 3V0, VSD to 1.8V */
-	val = pmic_reg_read(REG_SETTING_1);
+	pmic_reg_read(p, REG_SETTING_1, &val);
 	val &= ~(VVIDEO_MASK | VSD_MASK | VAUDIO_MASK);
 	val |= VVIDEO_2_775 | VAUDIO_3_0 | VSD_1_8;
-	pmic_reg_write(REG_SETTING_1, val);
+	pmic_reg_write(p, REG_SETTING_1, val);
 
 	/* Configure VGEN3 and VCAM regulators to use external PNP */
 	val = VGEN3CONFIG | VCAMCONFIG;
-	pmic_reg_write(REG_MODE_1, val);
+	pmic_reg_write(p, REG_MODE_1, val);
 	udelay(200);
 
 	/* Enable VGEN3, VCAM, VAUDIO, VVIDEO, VSD regulators */
 	val = VGEN3EN | VGEN3CONFIG | VCAMEN | VCAMCONFIG |
 		VVIDEOEN | VAUDIOEN  | VSDEN;
-	pmic_reg_write(REG_MODE_1, val);
+	pmic_reg_write(p, REG_MODE_1, val);
 
-	val = pmic_reg_read(REG_POWER_CTL2);
+	pmic_reg_read(p, REG_POWER_CTL2, &val);
 	val |= WDIRESET;
-	pmic_reg_write(REG_POWER_CTL2, val);
+	pmic_reg_write(p, REG_POWER_CTL2, val);
 
 	udelay(2500);
 
diff --git a/include/configs/vision2.h b/include/configs/vision2.h
index 4c6ed3d..17d1d15 100644
--- a/include/configs/vision2.h
+++ b/include/configs/vision2.h
@@ -91,11 +91,14 @@
 #define CONFIG_ENV_IS_IN_SPI_FLASH
 
 /* PMIC Controller */
-#define CONFIG_FSL_PMIC
+#define CONFIG_PMIC
+#define CONFIG_PMIC_SPI
+#define CONFIG_PMIC_FSL
 #define CONFIG_FSL_PMIC_BUS	0
 #define CONFIG_FSL_PMIC_CS	0
 #define CONFIG_FSL_PMIC_CLK	2500000
 #define CONFIG_FSL_PMIC_MODE	SPI_MODE_0
+#define CONFIG_FSL_PMIC_BITLEN	32
 #define CONFIG_RTC_MC13783
 
 /*
-- 
1.7.1

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

* [U-Boot] [PATCH 02/13] RTC: Switch mc13783 to generic pmic code
  2011-10-08 16:35 [U-Boot] switch to generic PMIC driver for i.MX boards Stefano Babic
  2011-10-08 16:35 ` [U-Boot] [PATCH 01/13] MX5: vision2: use new pmic driver Stefano Babic
@ 2011-10-08 16:35 ` Stefano Babic
  2011-10-08 16:35 ` [U-Boot] [PATCH 03/13] MX3: qong: use new pmic driver Stefano Babic
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 42+ messages in thread
From: Stefano Babic @ 2011-10-08 16:35 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 drivers/rtc/mc13783-rtc.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/rtc/mc13783-rtc.c b/drivers/rtc/mc13783-rtc.c
index 4e18f80..70ea8a1 100644
--- a/drivers/rtc/mc13783-rtc.c
+++ b/drivers/rtc/mc13783-rtc.c
@@ -23,24 +23,27 @@
 #include <common.h>
 #include <rtc.h>
 #include <spi.h>
+#include <pmic.h>
 #include <fsl_pmic.h>
 
 int rtc_get(struct rtc_time *rtc)
 {
 	u32 day1, day2, time;
 	int tim, i = 0;
+	struct pmic *p = get_pmic();
+	int ret;
 
 	do {
-		day1 = pmic_reg_read(REG_RTC_DAY);
-		if (day1 < 0)
+		ret = pmic_reg_read(p, REG_RTC_DAY, &day1);
+		if (ret < 0)
 			return -1;
 
-		time = pmic_reg_read(REG_RTC_TIME);
-		if (time < 0)
+		ret = pmic_reg_read(p, REG_RTC_TIME, &time);
+		if (ret < 0)
 			return -1;
 
-		day2 = pmic_reg_read(REG_RTC_DAY);
-		if (day2 < 0)
+		ret = pmic_reg_read(p, REG_RTC_DAY, &day2);
+		if (ret < 0)
 			return -1;
 
 	} while (day1 != day2 && i++ < 3);
@@ -58,14 +61,15 @@ int rtc_get(struct rtc_time *rtc)
 int rtc_set(struct rtc_time *rtc)
 {
 	u32 time, day;
+	struct pmic *p = get_pmic();
 
 	time = mktime(rtc->tm_year, rtc->tm_mon, rtc->tm_mday,
 		      rtc->tm_hour, rtc->tm_min, rtc->tm_sec);
 	day = time / 86400;
 	time %= 86400;
 
-	pmic_reg_write(REG_RTC_DAY, day);
-	pmic_reg_write(REG_RTC_TIME, time);
+	pmic_reg_write(p, REG_RTC_DAY, day);
+	pmic_reg_write(p, REG_RTC_TIME, time);
 
 	return 0;
 }
-- 
1.7.1

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

* [U-Boot] [PATCH 03/13] MX3: qong: use new pmic driver
  2011-10-08 16:35 [U-Boot] switch to generic PMIC driver for i.MX boards Stefano Babic
  2011-10-08 16:35 ` [U-Boot] [PATCH 01/13] MX5: vision2: use new pmic driver Stefano Babic
  2011-10-08 16:35 ` [U-Boot] [PATCH 02/13] RTC: Switch mc13783 to generic pmic code Stefano Babic
@ 2011-10-08 16:35 ` Stefano Babic
  2011-10-08 16:36 ` [U-Boot] [PATCH V2 04/13] MX5: efikamx/efikasb: " Stefano Babic
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 42+ messages in thread
From: Stefano Babic @ 2011-10-08 16:35 UTC (permalink / raw)
  To: u-boot

Switch to new pmic generic driver.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 board/davedenx/qong/qong.c |   11 ++++++++---
 include/configs/qong.h     |    5 ++++-
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/board/davedenx/qong/qong.c b/board/davedenx/qong/qong.c
index 9fca1f8..a9f2ef0 100644
--- a/board/davedenx/qong/qong.c
+++ b/board/davedenx/qong/qong.c
@@ -28,6 +28,7 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/io.h>
 #include <nand.h>
+#include <pmic.h>
 #include <fsl_pmic.h>
 #include <asm/gpio.h>
 #include "qong_fpga.h"
@@ -176,11 +177,15 @@ int board_init (void)
 int board_late_init(void)
 {
 	u32 val;
+	struct pmic *p;
+
+	pmic_init();
+	p = get_pmic();
 
 	/* Enable RTC battery */
-	val = pmic_reg_read(REG_POWER_CTL0);
-	pmic_reg_write(REG_POWER_CTL0, val | COINCHEN);
-	pmic_reg_write(REG_INT_STATUS1, RTCRSTI);
+	pmic_reg_read(p, REG_POWER_CTL0, &val);
+	pmic_reg_write(p, REG_POWER_CTL0, val | COINCHEN);
+	pmic_reg_write(p, REG_INT_STATUS1, RTCRSTI);
 
 #ifdef CONFIG_HW_WATCHDOG
 	mxc_hw_watchdog_enable();
diff --git a/include/configs/qong.h b/include/configs/qong.h
index 78b3701..ec99021 100644
--- a/include/configs/qong.h
+++ b/include/configs/qong.h
@@ -60,11 +60,14 @@
 #define CONFIG_DEFAULT_SPI_MODE	(SPI_MODE_0 | SPI_CS_HIGH)
 #define CONFIG_RTC_MC13783
 
-#define CONFIG_FSL_PMIC
+#define CONFIG_PMIC
+#define CONFIG_PMIC_SPI
+#define CONFIG_PMIC_FSL
 #define CONFIG_FSL_PMIC_BUS	1
 #define CONFIG_FSL_PMIC_CS	0
 #define CONFIG_FSL_PMIC_CLK	100000
 #define CONFIG_FSL_PMIC_MODE	(SPI_MODE_0 | SPI_CS_HIGH)
+#define CONFIG_FSL_PMIC_BITLEN	32
 
 /* FPGA */
 #define CONFIG_FPGA
-- 
1.7.1

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

* [U-Boot] [PATCH V2 04/13] MX5: efikamx/efikasb: use new pmic driver
  2011-10-08 16:35 [U-Boot] switch to generic PMIC driver for i.MX boards Stefano Babic
                   ` (2 preceding siblings ...)
  2011-10-08 16:35 ` [U-Boot] [PATCH 03/13] MX3: qong: use new pmic driver Stefano Babic
@ 2011-10-08 16:36 ` Stefano Babic
  2011-10-08 16:57   ` Marek Vasut
  2011-10-08 16:36 ` [U-Boot] [PATCH 05/13] I2c: add missing i2c_set_bus_num to mxc_i2c Stefano Babic
                   ` (10 subsequent siblings)
  14 siblings, 1 reply; 42+ messages in thread
From: Stefano Babic @ 2011-10-08 16:36 UTC (permalink / raw)
  To: u-boot

Switch to new pmic generic driver.

Signed-off-by: Stefano Babic <sbabic@denx.de>
CC: Marek Vasut <marek.vasut@gmail.com>
---

Changes:

 -moved pmic_init into power_init() (Marek Vasut)

 board/efikamx/efikamx.c   |   51 ++++++++++++++++++++++++--------------------
 include/configs/efikamx.h |    5 +++-
 2 files changed, 32 insertions(+), 24 deletions(-)

diff --git a/board/efikamx/efikamx.c b/board/efikamx/efikamx.c
index 0c4e24b..b78bf6c 100644
--- a/board/efikamx/efikamx.c
+++ b/board/efikamx/efikamx.c
@@ -34,6 +34,7 @@
 #include <i2c.h>
 #include <mmc.h>
 #include <fsl_esdhc.h>
+#include <pmic.h>
 #include <fsl_pmic.h>
 #include <mc13892.h>
 
@@ -205,34 +206,38 @@ static void power_init(void)
 {
 	unsigned int val;
 	struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)MXC_CCM_BASE;
+	struct pmic *p;
+
+	pmic_init();
+	p = get_pmic();
 
 	/* Write needed to Power Gate 2 register */
-	val = pmic_reg_read(REG_POWER_MISC);
+	pmic_reg_read(p, REG_POWER_MISC, &val);
 	val &= ~PWGT2SPIEN;
-	pmic_reg_write(REG_POWER_MISC, val);
+	pmic_reg_write(p, REG_POWER_MISC, val);
 
 	/* Externally powered */
-	val = pmic_reg_read(REG_CHARGE);
+	pmic_reg_read(p, REG_CHARGE, &val);
 	val |= ICHRG0 | ICHRG1 | ICHRG2 | ICHRG3 | CHGAUTOB;
-	pmic_reg_write(REG_CHARGE, val);
+	pmic_reg_write(p, REG_CHARGE, val);
 
 	/* power up the system first */
-	pmic_reg_write(REG_POWER_MISC, PWUP);
+	pmic_reg_write(p, REG_POWER_MISC, PWUP);
 
 	/* Set core voltage to 1.1V */
-	val = pmic_reg_read(REG_SW_0);
+	pmic_reg_read(p, REG_SW_0, &val);
 	val = (val & ~SWx_VOLT_MASK) | SWx_1_100V;
-	pmic_reg_write(REG_SW_0, val);
+	pmic_reg_write(p, REG_SW_0, val);
 
 	/* Setup VCC (SW2) to 1.25 */
-	val = pmic_reg_read(REG_SW_1);
+	pmic_reg_read(p, REG_SW_1, &val);
 	val = (val & ~SWx_VOLT_MASK) | SWx_1_250V;
-	pmic_reg_write(REG_SW_1, val);
+	pmic_reg_write(p, REG_SW_1, val);
 
 	/* Setup 1V2_DIG1 (SW3) to 1.25 */
-	val = pmic_reg_read(REG_SW_2);
+	pmic_reg_read(p, REG_SW_2, &val);
 	val = (val & ~SWx_VOLT_MASK) | SWx_1_250V;
-	pmic_reg_write(REG_SW_2, val);
+	pmic_reg_write(p, REG_SW_2, val);
 	udelay(50);
 
 	/* Raise the core frequency to 800MHz */
@@ -240,46 +245,46 @@ static void power_init(void)
 
 	/* Set switchers in Auto in NORMAL mode & STANDBY mode */
 	/* Setup the switcher mode for SW1 & SW2*/
-	val = pmic_reg_read(REG_SW_4);
+	pmic_reg_read(p, REG_SW_4, &val);
 	val = (val & ~((SWMODE_MASK << SWMODE1_SHIFT) |
 		(SWMODE_MASK << SWMODE2_SHIFT)));
 	val |= (SWMODE_AUTO_AUTO << SWMODE1_SHIFT) |
 		(SWMODE_AUTO_AUTO << SWMODE2_SHIFT);
-	pmic_reg_write(REG_SW_4, val);
+	pmic_reg_write(p, REG_SW_4, val);
 
 	/* Setup the switcher mode for SW3 & SW4 */
-	val = pmic_reg_read(REG_SW_5);
+	pmic_reg_read(p, REG_SW_5, &val);
 	val = (val & ~((SWMODE_MASK << SWMODE3_SHIFT) |
 		(SWMODE_MASK << SWMODE4_SHIFT)));
 	val |= (SWMODE_AUTO_AUTO << SWMODE3_SHIFT) |
 		(SWMODE_AUTO_AUTO << SWMODE4_SHIFT);
-	pmic_reg_write(REG_SW_5, val);
+	pmic_reg_write(p, REG_SW_5, val);
 
 	/* Set VDIG to 1.65V, VGEN3 to 1.8V, VCAM to 2.6V */
-	val = pmic_reg_read(REG_SETTING_0);
+	pmic_reg_read(p, REG_SETTING_0, &val);
 	val &= ~(VCAM_MASK | VGEN3_MASK | VDIG_MASK);
 	val |= VDIG_1_65 | VGEN3_1_8 | VCAM_2_6;
-	pmic_reg_write(REG_SETTING_0, val);
+	pmic_reg_write(p, REG_SETTING_0, val);
 
 	/* Set VVIDEO to 2.775V, VAUDIO to 3V, VSD to 3.15V */
-	val = pmic_reg_read(REG_SETTING_1);
+	pmic_reg_read(p, REG_SETTING_1, &val);
 	val &= ~(VVIDEO_MASK | VSD_MASK | VAUDIO_MASK);
 	val |= VSD_3_15 | VAUDIO_3_0 | VVIDEO_2_775;
-	pmic_reg_write(REG_SETTING_1, val);
+	pmic_reg_write(p, REG_SETTING_1, val);
 
 	/* Configure VGEN3 and VCAM regulators to use external PNP */
 	val = VGEN3CONFIG | VCAMCONFIG;
-	pmic_reg_write(REG_MODE_1, val);
+	pmic_reg_write(p, REG_MODE_1, val);
 	udelay(200);
 
 	/* Enable VGEN3, VCAM, VAUDIO, VVIDEO, VSD regulators */
 	val = VGEN3EN | VGEN3CONFIG | VCAMEN | VCAMCONFIG |
 		VVIDEOEN | VAUDIOEN  | VSDEN;
-	pmic_reg_write(REG_MODE_1, val);
+	pmic_reg_write(p, REG_MODE_1, val);
 
-	val = pmic_reg_read(REG_POWER_CTL2);
+	pmic_reg_read(p, REG_POWER_CTL2, &val);
 	val |= WDIRESET;
-	pmic_reg_write(REG_POWER_CTL2, val);
+	pmic_reg_write(p, REG_POWER_CTL2, val);
 
 	udelay(2500);
 }
diff --git a/include/configs/efikamx.h b/include/configs/efikamx.h
index 54f48e4..7e4b424 100644
--- a/include/configs/efikamx.h
+++ b/include/configs/efikamx.h
@@ -124,11 +124,14 @@
 #endif
 
 /* SPI PMIC */
-#define CONFIG_FSL_PMIC
+#define CONFIG_PMIC
+#define CONFIG_PMIC_SPI
+#define CONFIG_PMIC_FSL
 #define CONFIG_FSL_PMIC_BUS		0
 #define CONFIG_FSL_PMIC_CS		(0 | 120 << 8)
 #define CONFIG_FSL_PMIC_CLK		25000000
 #define CONFIG_FSL_PMIC_MODE		(SPI_MODE_0 | SPI_CS_HIGH)
+#define CONFIG_FSL_PMIC_BITLEN	32
 #define CONFIG_RTC_MC13783
 #endif
 
-- 
1.7.1

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

* [U-Boot] [PATCH 05/13] I2c: add missing i2c_set_bus_num to mxc_i2c
  2011-10-08 16:35 [U-Boot] switch to generic PMIC driver for i.MX boards Stefano Babic
                   ` (3 preceding siblings ...)
  2011-10-08 16:36 ` [U-Boot] [PATCH V2 04/13] MX5: efikamx/efikasb: " Stefano Babic
@ 2011-10-08 16:36 ` Stefano Babic
  2011-10-10  8:50   ` Heiko Schocher
  2011-10-08 16:36 ` [U-Boot] [PATCH V2 06/13] misc: pmic: addI2C support to pmic_fsl driver Stefano Babic
                   ` (9 subsequent siblings)
  14 siblings, 1 reply; 42+ messages in thread
From: Stefano Babic @ 2011-10-08 16:36 UTC (permalink / raw)
  To: u-boot

The function i2c_set_bus_num() is used on most SOCs.
The driver does not support multiple I2C busses, and
an empty function is added to be compatible with general code
(example: PMIC driver).

Signed-off-by: Stefano Babic <sbabic@denx.de>
Cc: Heiko Schocher <hs@denx.de>
---
 drivers/i2c/mxc_i2c.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c
index 2869d7c..de878ce 100644
--- a/drivers/i2c/mxc_i2c.c
+++ b/drivers/i2c/mxc_i2c.c
@@ -450,4 +450,9 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buf, int len)
 
 	return ret;
 }
+
+int i2c_set_bus_num(unsigned int bus)
+{
+	return 0;
+}
 #endif /* CONFIG_HARD_I2C */
-- 
1.7.1

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

* [U-Boot] [PATCH V2 06/13] misc: pmic: addI2C support to pmic_fsl driver
  2011-10-08 16:35 [U-Boot] switch to generic PMIC driver for i.MX boards Stefano Babic
                   ` (4 preceding siblings ...)
  2011-10-08 16:36 ` [U-Boot] [PATCH 05/13] I2c: add missing i2c_set_bus_num to mxc_i2c Stefano Babic
@ 2011-10-08 16:36 ` Stefano Babic
  2011-10-08 16:36 ` [U-Boot] [PATCH 07/13] MX35: mx35pdk: use new pmic driver Stefano Babic
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 42+ messages in thread
From: Stefano Babic @ 2011-10-08 16:36 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Stefano Babic <sbabic@denx.de>
---

Changes since V1:

- drop wrong assignment for p->interface (Sergei Shtylyov)

 drivers/misc/pmic_fsl.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/pmic_fsl.c b/drivers/misc/pmic_fsl.c
index 13dde47..b6e809a 100644
--- a/drivers/misc/pmic_fsl.c
+++ b/drivers/misc/pmic_fsl.c
@@ -26,6 +26,7 @@
 #include <pmic.h>
 #include <fsl_pmic.h>
 
+#if defined(CONFIG_PMIC_SPI)
 static u32 pmic_spi_prepare_tx(u32 reg, u32 *val, u32 write)
 {
 	if ((val == NULL) && (write))
@@ -33,25 +34,33 @@ static u32 pmic_spi_prepare_tx(u32 reg, u32 *val, u32 write)
 	else
 		return (write << 31) | (reg << 25) | (*val & 0x00FFFFFF);
 }
+#endif
 
 int pmic_init(void)
 {
 	struct pmic *p = get_pmic();
 	static const char name[] = "FSL_PMIC";
 
-	puts("Board PMIC init\n");
-
 	p->name = name;
-	p->interface = PMIC_SPI;
 	p->number_of_regs = PMIC_NUM_OF_REGS;
-	p->bus = CONFIG_FSL_PMIC_BUS;
 
+#if defined(CONFIG_PMIC_SPI)
+	p->interface = PMIC_SPI;
+	p->bus = CONFIG_FSL_PMIC_BUS;
 	p->hw.spi.cs = CONFIG_FSL_PMIC_CS;
 	p->hw.spi.clk = CONFIG_FSL_PMIC_CLK;
 	p->hw.spi.mode = CONFIG_FSL_PMIC_MODE;
 	p->hw.spi.bitlen = CONFIG_FSL_PMIC_BITLEN;
 	p->hw.spi.flags = SPI_XFER_BEGIN | SPI_XFER_END;
 	p->hw.spi.prepare_tx = pmic_spi_prepare_tx;
+#elif defined(CONFIG_PMIC_I2C)
+	p->interface = PMIC_I2C;
+	p->hw.i2c.addr = CONFIG_SYS_FSL_PMIC_I2C_ADDR;
+	p->hw.i2c.tx_num = 3;
+	p->bus = I2C_PMIC;
+#else
+#error "You must select CONFIG_PMIC_SPI or CONFIG_PMIC_I2C"
+#endif
 
 	return 0;
 }
-- 
1.7.1

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

* [U-Boot] [PATCH 07/13] MX35: mx35pdk: use new pmic driver
  2011-10-08 16:35 [U-Boot] switch to generic PMIC driver for i.MX boards Stefano Babic
                   ` (5 preceding siblings ...)
  2011-10-08 16:36 ` [U-Boot] [PATCH V2 06/13] misc: pmic: addI2C support to pmic_fsl driver Stefano Babic
@ 2011-10-08 16:36 ` Stefano Babic
  2011-10-08 16:36 ` [U-Boot] [PATCH V2 08/13] MX5: mx51evk: " Stefano Babic
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 42+ messages in thread
From: Stefano Babic @ 2011-10-08 16:36 UTC (permalink / raw)
  To: u-boot

Switch to new pmic generic driver.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 board/freescale/mx35pdk/mx35pdk.c |   18 ++++++++++++------
 include/configs/mx35pdk.h         |    5 +++--
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/board/freescale/mx35pdk/mx35pdk.c b/board/freescale/mx35pdk/mx35pdk.c
index 9eefe5e..f6da51a 100644
--- a/board/freescale/mx35pdk/mx35pdk.c
+++ b/board/freescale/mx35pdk/mx35pdk.c
@@ -30,6 +30,7 @@
 #include <asm/arch/mx35_pins.h>
 #include <asm/arch/iomux.h>
 #include <i2c.h>
+#include <pmic.h>
 #include <fsl_pmic.h>
 #include <mc9sdz60.h>
 #include <mc13892.h>
@@ -204,9 +205,10 @@ int board_init(void)
 
 static inline int pmic_detect(void)
 {
-	int id;
+	unsigned int id;
+	struct pmic *p = get_pmic();
 
-	id = pmic_reg_read(REG_IDENTIFICATION);
+	pmic_reg_read(p, REG_IDENTIFICATION, &id);
 
 	id = (id >> 6) & 0x7;
 	if (id == 0x7)
@@ -227,15 +229,19 @@ int board_late_init(void)
 {
 	u8 val;
 	u32 pmic_val;
+	struct pmic *p;
 
+	pmic_init();
 	if (pmic_detect()) {
+		p = get_pmic();
 		mxc_request_iomux(MX35_PIN_WATCHDOG_RST, MUX_CONFIG_SION |
 					MUX_CONFIG_ALT1);
 
-		pmic_val = pmic_reg_read(REG_SETTING_0);
-		pmic_reg_write(REG_SETTING_0, pmic_val | VO_1_30V | VO_1_50V);
-		pmic_val = pmic_reg_read(REG_MODE_0);
-		pmic_reg_write(REG_MODE_0, pmic_val | VGEN3EN);
+		pmic_reg_read(p, REG_SETTING_0, &pmic_val);
+		pmic_reg_write(p, REG_SETTING_0,
+			pmic_val | VO_1_30V | VO_1_50V);
+		pmic_reg_read(p, REG_MODE_0, &pmic_val);
+		pmic_reg_write(p, REG_MODE_0, pmic_val | VGEN3EN);
 
 		mxc_request_iomux(MX35_PIN_COMPARE, MUX_CONFIG_GPIO);
 		mxc_iomux_set_input(MUX_IN_GPIO1_IN_5, INPUT_CTL_PATH0);
diff --git a/include/configs/mx35pdk.h b/include/configs/mx35pdk.h
index 4e9022d..946e64b 100644
--- a/include/configs/mx35pdk.h
+++ b/include/configs/mx35pdk.h
@@ -69,8 +69,9 @@
 /*
  * PMIC Configs
  */
-#define CONFIG_FSL_PMIC
-#define CONFIG_FSL_PMIC_I2C
+#define CONFIG_PMIC
+#define CONFIG_PMIC_I2C
+#define CONFIG_PMIC_FSL
 #define CONFIG_SYS_FSL_PMIC_I2C_ADDR	0x08
 
 /*
-- 
1.7.1

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

* [U-Boot] [PATCH V2 08/13] MX5: mx51evk: use new pmic driver
  2011-10-08 16:35 [U-Boot] switch to generic PMIC driver for i.MX boards Stefano Babic
                   ` (6 preceding siblings ...)
  2011-10-08 16:36 ` [U-Boot] [PATCH 07/13] MX35: mx35pdk: use new pmic driver Stefano Babic
@ 2011-10-08 16:36 ` Stefano Babic
  2011-10-08 16:36 ` [U-Boot] [PATCH V2 09/13] MX5: mx53evk: " Stefano Babic
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 42+ messages in thread
From: Stefano Babic @ 2011-10-08 16:36 UTC (permalink / raw)
  To: u-boot

Switch to new pmic generic driver.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
Changes:

 -moved pmic_init into power_init() (Marek Vasut)

 board/freescale/mx51evk/mx51evk.c |   47 ++++++++++++++++++++----------------
 include/configs/mx51evk.h         |    6 ++++-
 2 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/board/freescale/mx51evk/mx51evk.c b/board/freescale/mx51evk/mx51evk.c
index 8da1ee8..73ca513 100644
--- a/board/freescale/mx51evk/mx51evk.c
+++ b/board/freescale/mx51evk/mx51evk.c
@@ -32,6 +32,7 @@
 #include <i2c.h>
 #include <mmc.h>
 #include <fsl_esdhc.h>
+#include <pmic.h>
 #include <fsl_pmic.h>
 #include <mc13892.h>
 
@@ -182,34 +183,38 @@ static void power_init(void)
 {
 	unsigned int val;
 	struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)MXC_CCM_BASE;
+	struct pmic *p;
+
+	pmic_init();
+	p = get_pmic();
 
 	/* Write needed to Power Gate 2 register */
-	val = pmic_reg_read(REG_POWER_MISC);
+	pmic_reg_read(p, REG_POWER_MISC, &val);
 	val &= ~PWGT2SPIEN;
-	pmic_reg_write(REG_POWER_MISC, val);
+	pmic_reg_write(p, REG_POWER_MISC, val);
 
 	/* Externally powered */
-	val = pmic_reg_read(REG_CHARGE);
+	pmic_reg_read(p, REG_CHARGE, &val);
 	val |= ICHRG0 | ICHRG1 | ICHRG2 | ICHRG3 | CHGAUTOB;
-	pmic_reg_write(REG_CHARGE, val);
+	pmic_reg_write(p, REG_CHARGE, val);
 
 	/* power up the system first */
-	pmic_reg_write(REG_POWER_MISC, PWUP);
+	pmic_reg_write(p, REG_POWER_MISC, PWUP);
 
 	/* Set core voltage to 1.1V */
-	val = pmic_reg_read(REG_SW_0);
+	pmic_reg_read(p, REG_SW_0, &val);
 	val = (val & ~SWx_VOLT_MASK) | SWx_1_100V;
-	pmic_reg_write(REG_SW_0, val);
+	pmic_reg_write(p, REG_SW_0, val);
 
 	/* Setup VCC (SW2) to 1.25 */
-	val = pmic_reg_read(REG_SW_1);
+	pmic_reg_read(p, REG_SW_1, &val);
 	val = (val & ~SWx_VOLT_MASK) | SWx_1_250V;
-	pmic_reg_write(REG_SW_1, val);
+	pmic_reg_write(p, REG_SW_1, val);
 
 	/* Setup 1V2_DIG1 (SW3) to 1.25 */
-	val = pmic_reg_read(REG_SW_2);
+	pmic_reg_read(p, REG_SW_2, &val);
 	val = (val & ~SWx_VOLT_MASK) | SWx_1_250V;
-	pmic_reg_write(REG_SW_2, val);
+	pmic_reg_write(p, REG_SW_2, val);
 	udelay(50);
 
 	/* Raise the core frequency to 800MHz */
@@ -217,36 +222,36 @@ static void power_init(void)
 
 	/* Set switchers in Auto in NORMAL mode & STANDBY mode */
 	/* Setup the switcher mode for SW1 & SW2*/
-	val = pmic_reg_read(REG_SW_4);
+	pmic_reg_read(p, REG_SW_4, &val);
 	val = (val & ~((SWMODE_MASK << SWMODE1_SHIFT) |
 		(SWMODE_MASK << SWMODE2_SHIFT)));
 	val |= (SWMODE_AUTO_AUTO << SWMODE1_SHIFT) |
 		(SWMODE_AUTO_AUTO << SWMODE2_SHIFT);
-	pmic_reg_write(REG_SW_4, val);
+	pmic_reg_write(p, REG_SW_4, val);
 
 	/* Setup the switcher mode for SW3 & SW4 */
-	val = pmic_reg_read(REG_SW_5);
+	pmic_reg_read(p, REG_SW_5, &val);
 	val = (val & ~((SWMODE_MASK << SWMODE3_SHIFT) |
 		(SWMODE_MASK << SWMODE4_SHIFT)));
 	val |= (SWMODE_AUTO_AUTO << SWMODE3_SHIFT) |
 		(SWMODE_AUTO_AUTO << SWMODE4_SHIFT);
-	pmic_reg_write(REG_SW_5, val);
+	pmic_reg_write(p, REG_SW_5, val);
 
 	/* Set VDIG to 1.65V, VGEN3 to 1.8V, VCAM to 2.6V */
-	val = pmic_reg_read(REG_SETTING_0);
+	pmic_reg_read(p, REG_SETTING_0, &val);
 	val &= ~(VCAM_MASK | VGEN3_MASK | VDIG_MASK);
 	val |= VDIG_1_65 | VGEN3_1_8 | VCAM_2_6;
-	pmic_reg_write(REG_SETTING_0, val);
+	pmic_reg_write(p, REG_SETTING_0, val);
 
 	/* Set VVIDEO to 2.775V, VAUDIO to 3V, VSD to 3.15V */
-	val = pmic_reg_read(REG_SETTING_1);
+	pmic_reg_read(p, REG_SETTING_1, &val);
 	val &= ~(VVIDEO_MASK | VSD_MASK | VAUDIO_MASK);
 	val |= VSD_3_15 | VAUDIO_3_0 | VVIDEO_2_775;
-	pmic_reg_write(REG_SETTING_1, val);
+	pmic_reg_write(p, REG_SETTING_1, val);
 
 	/* Configure VGEN3 and VCAM regulators to use external PNP */
 	val = VGEN3CONFIG | VCAMCONFIG;
-	pmic_reg_write(REG_MODE_1, val);
+	pmic_reg_write(p, REG_MODE_1, val);
 	udelay(200);
 
 	gpio_direction_output(46, 0);
@@ -257,7 +262,7 @@ static void power_init(void)
 	/* Enable VGEN3, VCAM, VAUDIO, VVIDEO, VSD regulators */
 	val = VGEN3EN | VGEN3CONFIG | VCAMEN | VCAMCONFIG |
 		VVIDEOEN | VAUDIOEN  | VSDEN;
-	pmic_reg_write(REG_MODE_1, val);
+	pmic_reg_write(p, REG_MODE_1, val);
 
 	udelay(500);
 
diff --git a/include/configs/mx51evk.h b/include/configs/mx51evk.h
index d62a4f2..6faaa6c 100644
--- a/include/configs/mx51evk.h
+++ b/include/configs/mx51evk.h
@@ -70,11 +70,15 @@
 
 #define CONFIG_MXC_SPI
 
-#define CONFIG_FSL_PMIC
+/* PMIC Controller */
+#define CONFIG_PMIC
+#define CONFIG_PMIC_SPI
+#define CONFIG_PMIC_FSL
 #define CONFIG_FSL_PMIC_BUS	0
 #define CONFIG_FSL_PMIC_CS	0
 #define CONFIG_FSL_PMIC_CLK	2500000
 #define CONFIG_FSL_PMIC_MODE	(SPI_MODE_0 | SPI_CS_HIGH)
+#define CONFIG_FSL_PMIC_BITLEN	32
 
 /*
  * MMC Configs
-- 
1.7.1

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

* [U-Boot] [PATCH V2 09/13] MX5: mx53evk: use new pmic driver
  2011-10-08 16:35 [U-Boot] switch to generic PMIC driver for i.MX boards Stefano Babic
                   ` (7 preceding siblings ...)
  2011-10-08 16:36 ` [U-Boot] [PATCH V2 08/13] MX5: mx51evk: " Stefano Babic
@ 2011-10-08 16:36 ` Stefano Babic
  2011-10-08 16:36 ` [U-Boot] [PATCH 10/13] MX31: mx31_litekit: " Stefano Babic
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 42+ messages in thread
From: Stefano Babic @ 2011-10-08 16:36 UTC (permalink / raw)
  To: u-boot

Switch to new pmic generic driver.

Signed-off-by: Stefano Babic <sbabic@denx.de>
CC: Jason Liu <jason.hui@linaro.org>
---
Changes:

 -moved pmic_init into power_init() (Marek Vasut)

 board/freescale/mx53evk/mx53evk.c |   17 +++++++++++------
 include/configs/mx53evk.h         |    5 +++--
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/board/freescale/mx53evk/mx53evk.c b/board/freescale/mx53evk/mx53evk.c
index fd821c0..eab9c5f 100644
--- a/board/freescale/mx53evk/mx53evk.c
+++ b/board/freescale/mx53evk/mx53evk.c
@@ -32,6 +32,7 @@
 #include <i2c.h>
 #include <mmc.h>
 #include <fsl_esdhc.h>
+#include <pmic.h>
 #include <fsl_pmic.h>
 #include <asm/gpio.h>
 #include <mc13892.h>
@@ -124,12 +125,16 @@ static void setup_i2c(unsigned int port_number)
 void power_init(void)
 {
 	unsigned int val;
+	struct pmic *p;
+
+	pmic_init();
+	p = get_pmic();
 
 	/* Set VDDA to 1.25V */
-	val = pmic_reg_read(REG_SW_2);
+	pmic_reg_read(p, REG_SW_2, &val);
 	val &= ~SWX_OUT_MASK;
 	val |= SWX_OUT_1_25;
-	pmic_reg_write(REG_SW_2, val);
+	pmic_reg_write(p, REG_SW_2, val);
 
 	/*
 	 * Need increase VCC and VDDA to 1.3V
@@ -137,16 +142,16 @@ void power_init(void)
 	 */
 	if (is_soc_rev(CHIP_REV_2_0) == 0) {
 		/* Set VCC to 1.3V for TO2 */
-		val = pmic_reg_read(REG_SW_1);
+		pmic_reg_read(p, REG_SW_1, &val);
 		val &= ~SWX_OUT_MASK;
 		val |= SWX_OUT_1_30;
-		pmic_reg_write(REG_SW_1, val);
+		pmic_reg_write(p, REG_SW_1, val);
 
 		/* Set VDDA to 1.3V for TO2 */
-		val = pmic_reg_read(REG_SW_2);
+		pmic_reg_read(p, REG_SW_2, &val);
 		val &= ~SWX_OUT_MASK;
 		val |= SWX_OUT_1_30;
-		pmic_reg_write(REG_SW_2, val);
+		pmic_reg_write(p, REG_SW_2, val);
 	}
 }
 
diff --git a/include/configs/mx53evk.h b/include/configs/mx53evk.h
index b127b06..dfe07bf 100644
--- a/include/configs/mx53evk.h
+++ b/include/configs/mx53evk.h
@@ -59,8 +59,9 @@
 #define CONFIG_SYS_I2C_SLAVE            0xfe
 
 /* PMIC Configs */
-#define CONFIG_FSL_PMIC
-#define CONFIG_FSL_PMIC_I2C
+#define CONFIG_PMIC
+#define CONFIG_PMIC_I2C
+#define CONFIG_PMIC_FSL
 #define CONFIG_SYS_FSL_PMIC_I2C_ADDR    8
 
 /* MMC Configs */
-- 
1.7.1

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

* [U-Boot] [PATCH 10/13] MX31: mx31_litekit: use new pmic driver
  2011-10-08 16:35 [U-Boot] switch to generic PMIC driver for i.MX boards Stefano Babic
                   ` (8 preceding siblings ...)
  2011-10-08 16:36 ` [U-Boot] [PATCH V2 09/13] MX5: mx53evk: " Stefano Babic
@ 2011-10-08 16:36 ` Stefano Babic
  2011-10-08 16:36 ` [U-Boot] [PATCH 11/13] MX31: mx31ads: " Stefano Babic
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 42+ messages in thread
From: Stefano Babic @ 2011-10-08 16:36 UTC (permalink / raw)
  To: u-boot

Switch to new pmic generic driver.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 include/configs/imx31_litekit.h |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/include/configs/imx31_litekit.h b/include/configs/imx31_litekit.h
index 5e976bc..65e301e 100644
--- a/include/configs/imx31_litekit.h
+++ b/include/configs/imx31_litekit.h
@@ -72,13 +72,16 @@
 #define CONFIG_DEFAULT_SPI_BUS	1
 #define CONFIG_DEFAULT_SPI_MODE	(SPI_MODE_0 | SPI_CS_HIGH)
 
-#define CONFIG_FSL_PMIC
+/* PMIC Controller */
+#define CONFIG_PMIC
+#define CONFIG_PMIC_SPI
+#define CONFIG_PMIC_FSL
 #define CONFIG_FSL_PMIC_BUS	1
 #define CONFIG_FSL_PMIC_CS	0
 #define CONFIG_FSL_PMIC_CLK	1000000
 #define CONFIG_FSL_PMIC_MODE	(SPI_MODE_0 | SPI_CS_HIGH)
-
-#define CONFIG_RTC_MC13783	1
+#define CONFIG_FSL_PMIC_BITLEN	32
+#define CONFIG_RTC_MC13783
 
 /* allow to overwrite serial and ethaddr */
 #define CONFIG_ENV_OVERWRITE
-- 
1.7.1

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

* [U-Boot] [PATCH 11/13] MX31: mx31ads: use new pmic driver
  2011-10-08 16:35 [U-Boot] switch to generic PMIC driver for i.MX boards Stefano Babic
                   ` (9 preceding siblings ...)
  2011-10-08 16:36 ` [U-Boot] [PATCH 10/13] MX31: mx31_litekit: " Stefano Babic
@ 2011-10-08 16:36 ` Stefano Babic
  2011-10-08 16:36 ` [U-Boot] [PATCH 12/13] MX31: mx31pdk: " Stefano Babic
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 42+ messages in thread
From: Stefano Babic @ 2011-10-08 16:36 UTC (permalink / raw)
  To: u-boot

Switch to new pmic generic driver.

Signed-off-by: Stefano Babic <sbabic@denx.de>
CC: Fabio Estevam <fabio.estevam@freescale.com>
---
 include/configs/mx31ads.h |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/configs/mx31ads.h b/include/configs/mx31ads.h
index 0bea858..fcc5316 100644
--- a/include/configs/mx31ads.h
+++ b/include/configs/mx31ads.h
@@ -69,12 +69,16 @@
 #define CONFIG_DEFAULT_SPI_MODE	(SPI_MODE_0 | SPI_CS_HIGH)
 #define CONFIG_MXC_GPIO
 
-#define CONFIG_FSL_PMIC
+/* PMIC Controller */
+#define CONFIG_PMIC
+#define CONFIG_PMIC_SPI
+#define CONFIG_PMIC_FSL
 #define CONFIG_FSL_PMIC_BUS	1
 #define CONFIG_FSL_PMIC_CS	0
 #define CONFIG_FSL_PMIC_CLK	1000000
 #define CONFIG_FSL_PMIC_MODE	(SPI_MODE_0 | SPI_CS_HIGH)
-#define CONFIG_RTC_MC13783	1
+#define CONFIG_FSL_PMIC_BITLEN	32
+#define CONFIG_RTC_MC13783
 
 /* allow to overwrite serial and ethaddr */
 #define CONFIG_ENV_OVERWRITE
-- 
1.7.1

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

* [U-Boot] [PATCH 12/13] MX31: mx31pdk: use new pmic driver
  2011-10-08 16:35 [U-Boot] switch to generic PMIC driver for i.MX boards Stefano Babic
                   ` (10 preceding siblings ...)
  2011-10-08 16:36 ` [U-Boot] [PATCH 11/13] MX31: mx31ads: " Stefano Babic
@ 2011-10-08 16:36 ` Stefano Babic
  2011-10-08 16:36 ` [U-Boot] [PATCH 13/13] misc: pmic: drop old Freescale's " Stefano Babic
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 42+ messages in thread
From: Stefano Babic @ 2011-10-08 16:36 UTC (permalink / raw)
  To: u-boot

Switch to new pmic generic driver.

Signed-off-by: Stefano Babic <sbabic@denx.de>
CC: Fabio Estevam <fabio.estevam@freescale.com>
---
 include/configs/mx31pdk.h |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/include/configs/mx31pdk.h b/include/configs/mx31pdk.h
index cd156d8..08c06e1 100644
--- a/include/configs/mx31pdk.h
+++ b/include/configs/mx31pdk.h
@@ -70,11 +70,15 @@
 #define CONFIG_DEFAULT_SPI_BUS	1
 #define CONFIG_DEFAULT_SPI_MODE	(SPI_MODE_0 | SPI_CS_HIGH)
 
-#define CONFIG_FSL_PMIC
+/* PMIC Controller */
+#define CONFIG_PMIC
+#define CONFIG_PMIC_SPI
+#define CONFIG_PMIC_FSL
 #define CONFIG_FSL_PMIC_BUS	1
 #define CONFIG_FSL_PMIC_CS	2
 #define CONFIG_FSL_PMIC_CLK	1000000
 #define CONFIG_FSL_PMIC_MODE	(SPI_MODE_0 | SPI_CS_HIGH)
+#define CONFIG_FSL_PMIC_BITLEN	32
 #define CONFIG_RTC_MC13783
 
 /* allow to overwrite serial and ethaddr */
-- 
1.7.1

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

* [U-Boot] [PATCH 13/13] misc: pmic: drop old Freescale's pmic driver
  2011-10-08 16:35 [U-Boot] switch to generic PMIC driver for i.MX boards Stefano Babic
                   ` (11 preceding siblings ...)
  2011-10-08 16:36 ` [U-Boot] [PATCH 12/13] MX31: mx31pdk: " Stefano Babic
@ 2011-10-08 16:36 ` Stefano Babic
  2011-10-19 13:23   ` Helmut Raiger
  2011-10-10  9:35 ` [U-Boot] [PATCH V2 05/13] i2c: Create common default i2c_set_bus_num() function Stefano Babic
  2011-10-10 10:50 ` [U-Boot] [PATCH V3 " Stefano Babic
  14 siblings, 1 reply; 42+ messages in thread
From: Stefano Babic @ 2011-10-08 16:36 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 drivers/misc/Makefile   |    1 -
 drivers/misc/fsl_pmic.c |  235 -----------------------------------------------
 2 files changed, 0 insertions(+), 236 deletions(-)
 delete mode 100644 drivers/misc/fsl_pmic.c

diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index f732a95..a709707 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -28,7 +28,6 @@ LIB	:= $(obj)libmisc.o
 COBJS-$(CONFIG_ALI152X) += ali512x.o
 COBJS-$(CONFIG_DS4510)  += ds4510.o
 COBJS-$(CONFIG_FSL_LAW) += fsl_law.o
-COBJS-$(CONFIG_FSL_PMIC) += fsl_pmic.o
 COBJS-$(CONFIG_GPIO_LED) += gpio_led.o
 COBJS-$(CONFIG_FSL_MC9SDZ60) += mc9sdz60.o
 COBJS-$(CONFIG_NS87308) += ns87308.o
diff --git a/drivers/misc/fsl_pmic.c b/drivers/misc/fsl_pmic.c
deleted file mode 100644
index 23255a5..0000000
--- a/drivers/misc/fsl_pmic.c
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * (C) Copyright 2008-2009 Freescale Semiconductor, Inc.
- *
- * 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 <config.h>
-#include <common.h>
-#include <asm/errno.h>
-#include <linux/types.h>
-#include <fsl_pmic.h>
-
-static int check_param(u32 reg, u32 write)
-{
-	if (reg > 63 || write > 1) {
-		printf("<reg num> = %d is invalid. Should be less then 63\n",
-			reg);
-		return -1;
-	}
-
-	return 0;
-}
-
-#ifdef CONFIG_FSL_PMIC_I2C
-#include <i2c.h>
-
-u32 pmic_reg(u32 reg, u32 val, u32 write)
-{
-	unsigned char buf[4] = { 0 };
-	u32 ret_val = 0;
-
-	if (check_param(reg, write))
-		return -1;
-
-	if (write) {
-		buf[0] = (val >> 16) & 0xff;
-		buf[1] = (val >> 8) & 0xff;
-		buf[2] = (val) & 0xff;
-		if (i2c_write(CONFIG_SYS_FSL_PMIC_I2C_ADDR, reg, 1, buf, 3))
-			return -1;
-	} else {
-		if (i2c_read(CONFIG_SYS_FSL_PMIC_I2C_ADDR, reg, 1, buf, 3))
-			return -1;
-		ret_val = buf[0] << 16 | buf[1] << 8 | buf[2];
-	}
-
-	return ret_val;
-}
-#else /* SPI interface */
-#include <spi.h>
-static struct spi_slave *slave;
-
-struct spi_slave *pmic_spi_probe(void)
-{
-	return spi_setup_slave(CONFIG_FSL_PMIC_BUS,
-		CONFIG_FSL_PMIC_CS,
-		CONFIG_FSL_PMIC_CLK,
-		CONFIG_FSL_PMIC_MODE);
-}
-
-void pmic_spi_free(struct spi_slave *slave)
-{
-	if (slave)
-		spi_free_slave(slave);
-}
-
-u32 pmic_reg(u32 reg, u32 val, u32 write)
-{
-	u32 pmic_tx, pmic_rx;
-	u32 tmp;
-
-	if (!slave) {
-		slave = pmic_spi_probe();
-
-		if (!slave)
-			return -1;
-	}
-
-	if (check_param(reg, write))
-		return -1;
-
-	if (spi_claim_bus(slave))
-		return -1;
-
-	pmic_tx = (write << 31) | (reg << 25) | (val & 0x00FFFFFF);
-
-	tmp = cpu_to_be32(pmic_tx);
-
-	if (spi_xfer(slave, 4 << 3, &tmp, &pmic_rx,
-			SPI_XFER_BEGIN | SPI_XFER_END)) {
-		spi_release_bus(slave);
-		return -1;
-	}
-
-	if (write) {
-		pmic_tx &= ~(1 << 31);
-		tmp = cpu_to_be32(pmic_tx);
-		if (spi_xfer(slave, 4 << 3, &tmp, &pmic_rx,
-			SPI_XFER_BEGIN | SPI_XFER_END)) {
-			spi_release_bus(slave);
-			return -1;
-		}
-	}
-
-	spi_release_bus(slave);
-	return cpu_to_be32(pmic_rx);
-}
-#endif
-
-void pmic_reg_write(u32 reg, u32 value)
-{
-	pmic_reg(reg, value, 1);
-}
-
-u32 pmic_reg_read(u32 reg)
-{
-	return pmic_reg(reg, 0, 0);
-}
-
-void pmic_show_pmic_info(void)
-{
-	u32 rev_id;
-
-	rev_id = pmic_reg_read(REG_IDENTIFICATION);
-	printf("PMIC ID: 0x%08x [Rev: ", rev_id);
-	switch (rev_id & 0x1F) {
-	case 0x1:
-		puts("1.0");
-		break;
-	case 0x9:
-		puts("1.1");
-		break;
-	case 0xA:
-		puts("1.2");
-		break;
-	case 0x10:
-		puts("2.0");
-		break;
-	case 0x11:
-		puts("2.1");
-		break;
-	case 0x18:
-		puts("3.0");
-		break;
-	case 0x19:
-		puts("3.1");
-		break;
-	case 0x1A:
-		puts("3.2");
-		break;
-	case 0x2:
-		puts("3.2A");
-		break;
-	case 0x1B:
-		puts("3.3");
-		break;
-	case 0x1D:
-		puts("3.5");
-		break;
-	default:
-		puts("unknown");
-		break;
-	}
-	puts("]\n");
-}
-
-static void pmic_dump(int numregs)
-{
-	u32 val;
-	int i;
-
-	pmic_show_pmic_info();
-	for (i = 0; i < numregs; i++) {
-		val = pmic_reg_read(i);
-		if (!(i % 8))
-			printf ("\n0x%02x: ", i);
-		printf("%08x ", val);
-	}
-	puts("\n");
-}
-
-int do_pmic(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
-	char *cmd;
-	int nregs;
-	u32 val;
-
-	/*@least two arguments please */
-	if (argc < 2)
-		return cmd_usage(cmdtp);
-
-	cmd = argv[1];
-	if (strcmp(cmd, "dump") == 0) {
-		if (argc < 3)
-			return cmd_usage(cmdtp);
-
-		nregs = simple_strtoul(argv[2], NULL, 16);
-		pmic_dump(nregs);
-		return 0;
-	}
-	if (strcmp(cmd, "write") == 0) {
-		if (argc < 4)
-			return cmd_usage(cmdtp);
-
-		nregs = simple_strtoul(argv[2], NULL, 16);
-		val = simple_strtoul(argv[3], NULL, 16);
-		pmic_reg_write(nregs, val);
-		return 0;
-	}
-	/* No subcommand found */
-	return 1;
-}
-
-U_BOOT_CMD(
-	pmic,	CONFIG_SYS_MAXARGS, 1, do_pmic,
-	"Freescale PMIC (Atlas)",
-	"dump [numregs] - dump registers\n"
-	"pmic write <reg> <value> - write register"
-);
-- 
1.7.1

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

* [U-Boot] [PATCH V2 04/13] MX5: efikamx/efikasb: use new pmic driver
  2011-10-08 16:36 ` [U-Boot] [PATCH V2 04/13] MX5: efikamx/efikasb: " Stefano Babic
@ 2011-10-08 16:57   ` Marek Vasut
  0 siblings, 0 replies; 42+ messages in thread
From: Marek Vasut @ 2011-10-08 16:57 UTC (permalink / raw)
  To: u-boot

On Saturday, October 08, 2011 06:36:00 PM Stefano Babic wrote:
> Switch to new pmic generic driver.
> 
> Signed-off-by: Stefano Babic <sbabic@denx.de>
> CC: Marek Vasut <marek.vasut@gmail.com>
> ---
> 
> Changes:
> 
>  -moved pmic_init into power_init() (Marek Vasut)
> 

Ok,

Acked-by: Marek Vasut <marek.vasut@gmail.com>

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

* [U-Boot] [PATCH 05/13] I2c: add missing i2c_set_bus_num to mxc_i2c
  2011-10-08 16:36 ` [U-Boot] [PATCH 05/13] I2c: add missing i2c_set_bus_num to mxc_i2c Stefano Babic
@ 2011-10-10  8:50   ` Heiko Schocher
  2011-10-10  9:30     ` Stefano Babic
  0 siblings, 1 reply; 42+ messages in thread
From: Heiko Schocher @ 2011-10-10  8:50 UTC (permalink / raw)
  To: u-boot

Hello Stefano,

Stefano Babic wrote:
> The function i2c_set_bus_num() is used on most SOCs.
> The driver does not support multiple I2C busses, and
> an empty function is added to be compatible with general code
> (example: PMIC driver).
> 
> Signed-off-by: Stefano Babic <sbabic@denx.de>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>  drivers/i2c/mxc_i2c.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)

Hmm... it would be better to add a weak function in
u-boot/common/cmd_i2c.c ... as it is done for i2c_set_bus_speed()
and i2c_get_bus_speed() functions.

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* [U-Boot] [PATCH 05/13] I2c: add missing i2c_set_bus_num to mxc_i2c
  2011-10-10  8:50   ` Heiko Schocher
@ 2011-10-10  9:30     ` Stefano Babic
  0 siblings, 0 replies; 42+ messages in thread
From: Stefano Babic @ 2011-10-10  9:30 UTC (permalink / raw)
  To: u-boot

On 10/10/2011 10:50 AM, Heiko Schocher wrote:
> Hello Stefano,
> 
> Stefano Babic wrote:
>> The function i2c_set_bus_num() is used on most SOCs.
>> The driver does not support multiple I2C busses, and
>> an empty function is added to be compatible with general code
>> (example: PMIC driver).
>>
>> Signed-off-by: Stefano Babic <sbabic@denx.de>
>> Cc: Heiko Schocher <hs@denx.de>
>> ---
>>  drivers/i2c/mxc_i2c.c |    5 +++++
>>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> Hmm... it would be better to add a weak function in
> u-boot/common/cmd_i2c.c ... as it is done for i2c_set_bus_speed()
> and i2c_get_bus_speed() functions.

Good idea, I missed it..changed in V2.

Stefano

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

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

* [U-Boot] [PATCH V2 05/13] i2c: Create common default i2c_set_bus_num() function
  2011-10-08 16:35 [U-Boot] switch to generic PMIC driver for i.MX boards Stefano Babic
                   ` (12 preceding siblings ...)
  2011-10-08 16:36 ` [U-Boot] [PATCH 13/13] misc: pmic: drop old Freescale's " Stefano Babic
@ 2011-10-10  9:35 ` Stefano Babic
  2011-10-10 10:33   ` Heiko Schocher
  2011-10-10 17:53   ` Tabi Timur-B04825
  2011-10-10 10:50 ` [U-Boot] [PATCH V3 " Stefano Babic
  14 siblings, 2 replies; 42+ messages in thread
From: Stefano Babic @ 2011-10-10  9:35 UTC (permalink / raw)
  To: u-boot

New default, weak i2c_set_bus_num() function.

Signed-off-by: Stefano Babic <sbabic@denx.de>
Cc: Heiko Schocher <hs@denx.de>
---
Changes since V1:

- add a weak function i2c_set_bus_num() to cmd_i2c.c instead of adding a
dummy function to mxc_i2c.c. (Heiko Schocher)

 common/cmd_i2c.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index 3ea75f7..0f925d1 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -158,6 +158,14 @@ int __def_i2c_set_bus_speed(unsigned int speed)
 int i2c_set_bus_speed(unsigned int)
 	__attribute__((weak, alias("__def_i2c_set_bus_speed")));
 
+int __def_i2c_set_bus_num(unsigned int bus)
+{
+	return 0;
+}
+int i2c_set_bus_num(unsigned int)
+	__attribute__((weak, alias("__def_i2c_set_bus_num")));
+
+
 /*
  * get_alen: small parser helper function to get address length
  * returns the address length
-- 
1.7.1

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

* [U-Boot] [PATCH V2 05/13] i2c: Create common default i2c_set_bus_num() function
  2011-10-10  9:35 ` [U-Boot] [PATCH V2 05/13] i2c: Create common default i2c_set_bus_num() function Stefano Babic
@ 2011-10-10 10:33   ` Heiko Schocher
  2011-10-10 17:53   ` Tabi Timur-B04825
  1 sibling, 0 replies; 42+ messages in thread
From: Heiko Schocher @ 2011-10-10 10:33 UTC (permalink / raw)
  To: u-boot

Hello Stefano,

Stefano Babic wrote:
> New default, weak i2c_set_bus_num() function.
> 
> Signed-off-by: Stefano Babic <sbabic@denx.de>
> Cc: Heiko Schocher <hs@denx.de>
> ---
> Changes since V1:
> 
> - add a weak function i2c_set_bus_num() to cmd_i2c.c instead of adding a
> dummy function to mxc_i2c.c. (Heiko Schocher)
> 
>  common/cmd_i2c.c |    8 ++++++++
>  1 files changed, 8 insertions(+), 0 deletions(-)
> 
> diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
> index 3ea75f7..0f925d1 100644
> --- a/common/cmd_i2c.c
> +++ b/common/cmd_i2c.c
> @@ -158,6 +158,14 @@ int __def_i2c_set_bus_speed(unsigned int speed)
>  int i2c_set_bus_speed(unsigned int)
>  	__attribute__((weak, alias("__def_i2c_set_bus_speed")));
>  
> +int __def_i2c_set_bus_num(unsigned int bus)
> +{
> +	return 0;
> +}
> +int i2c_set_bus_num(unsigned int)
> +	__attribute__((weak, alias("__def_i2c_set_bus_num")));
> +
> +

Please just one new line ;-)

Beside of this, you get my:

Acked-by: Heiko Schocher <hs@denx.de>

>  /*
>   * get_alen: small parser helper function to get address length
>   * returns the address length

Thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* [U-Boot] [PATCH V3 05/13] i2c: Create common default i2c_set_bus_num() function
  2011-10-08 16:35 [U-Boot] switch to generic PMIC driver for i.MX boards Stefano Babic
                   ` (13 preceding siblings ...)
  2011-10-10  9:35 ` [U-Boot] [PATCH V2 05/13] i2c: Create common default i2c_set_bus_num() function Stefano Babic
@ 2011-10-10 10:50 ` Stefano Babic
  2011-10-10 15:19   ` Mike Frysinger
  14 siblings, 1 reply; 42+ messages in thread
From: Stefano Babic @ 2011-10-10 10:50 UTC (permalink / raw)
  To: u-boot

New default, weak i2c_set_bus_num() function.

Signed-off-by: Stefano Babic <sbabic@denx.de>
Cc: Heiko Schocher <hs@denx.de>
---
Changes since V2:

- codestyling: drop newline (Heiko Schocher)

Changes since V1:

- add a weak function i2c_set_bus_num() to cmd_i2c.c instead of adding a
dummy function to mxc_i2c.c. (Heiko Schocher)


 common/cmd_i2c.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index 3ea75f7..8baa541 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -158,6 +158,13 @@ int __def_i2c_set_bus_speed(unsigned int speed)
 int i2c_set_bus_speed(unsigned int)
 	__attribute__((weak, alias("__def_i2c_set_bus_speed")));
 
+int __def_i2c_set_bus_num(unsigned int bus)
+{
+	return 0;
+}
+int i2c_set_bus_num(unsigned int)
+	__attribute__((weak, alias("__def_i2c_set_bus_num")));
+
 /*
  * get_alen: small parser helper function to get address length
  * returns the address length
-- 
1.7.1

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

* [U-Boot] [PATCH V3 05/13] i2c: Create common default i2c_set_bus_num() function
  2011-10-10 10:50 ` [U-Boot] [PATCH V3 " Stefano Babic
@ 2011-10-10 15:19   ` Mike Frysinger
  2011-10-10 15:31     ` Stefano Babic
  0 siblings, 1 reply; 42+ messages in thread
From: Mike Frysinger @ 2011-10-10 15:19 UTC (permalink / raw)
  To: u-boot

On Monday 10 October 2011 06:50:12 Stefano Babic wrote:
> +int __def_i2c_set_bus_num(unsigned int bus)
> +{
> +	return 0;
> +}
> +int i2c_set_bus_num(unsigned int)
> +	__attribute__((weak, alias("__def_i2c_set_bus_num")));

any reason this can't just be:
__weak int i2c_set_bus_num(unsigned int bus)
{
	return 0;
}

i can understand having a default func when it actually does something, but i 
don't see much value in a stub that returns 0
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111010/93d9d00b/attachment.pgp 

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

* [U-Boot] [PATCH V3 05/13] i2c: Create common default i2c_set_bus_num() function
  2011-10-10 15:19   ` Mike Frysinger
@ 2011-10-10 15:31     ` Stefano Babic
  2011-10-10 17:51       ` Mike Frysinger
  0 siblings, 1 reply; 42+ messages in thread
From: Stefano Babic @ 2011-10-10 15:31 UTC (permalink / raw)
  To: u-boot

On 10/10/2011 05:19 PM, Mike Frysinger wrote:
> On Monday 10 October 2011 06:50:12 Stefano Babic wrote:

Hi Mike,

>> +int __def_i2c_set_bus_num(unsigned int bus)
>> +{
>> +	return 0;
>> +}
>> +int i2c_set_bus_num(unsigned int)
>> +	__attribute__((weak, alias("__def_i2c_set_bus_num")));
> 
> any reason this can't just be:
> __weak int i2c_set_bus_num(unsigned int bus)
> {
> 	return 0;
> }
> 
> i can understand having a default func when it actually does something, but i 
> don't see much value in a stub that returns 0

It seems to me that this is the commonly used style in u-boot. The same
happens for the i2c_init_board, some lines before, and in a lot of other
modules:

void __def_i2c_init_board(void)
{
        return;
}
void i2c_init_board(void)
        __attribute__((weak, alias("__def_i2c_init_board")));

Simply grepping in u-boot code, the default function is defined even if
it does nothing,

Regards,
Stefano


-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

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

* [U-Boot] [PATCH V3 05/13] i2c: Create common default i2c_set_bus_num() function
  2011-10-10 15:31     ` Stefano Babic
@ 2011-10-10 17:51       ` Mike Frysinger
  2011-10-11 17:30         ` Stefano Babic
  0 siblings, 1 reply; 42+ messages in thread
From: Mike Frysinger @ 2011-10-10 17:51 UTC (permalink / raw)
  To: u-boot

On Monday 10 October 2011 11:31:39 Stefano Babic wrote:
> On 10/10/2011 05:19 PM, Mike Frysinger wrote:
> > On Monday 10 October 2011 06:50:12 Stefano Babic wrote:
> >> +int __def_i2c_set_bus_num(unsigned int bus)
> >> +{
> >> +	return 0;
> >> +}
> >> +int i2c_set_bus_num(unsigned int)
> >> +	__attribute__((weak, alias("__def_i2c_set_bus_num")));
> > 
> > any reason this can't just be:
> > __weak int i2c_set_bus_num(unsigned int bus)
> > {
> > 
> > 	return 0;
> > 
> > }
> > 
> > i can understand having a default func when it actually does something,
> > but i don't see much value in a stub that returns 0
> 
> It seems to me that this is the commonly used style in u-boot. The same
> happens for the i2c_init_board, some lines before, and in a lot of other
> modules:
> 
> void __def_i2c_init_board(void)
> {
>         return;
> }
> void i2c_init_board(void)
>         __attribute__((weak, alias("__def_i2c_init_board")));
> 
> Simply grepping in u-boot code, the default function is defined even if
> it does nothing,

i believe we have two standards.  i'm not sure which gets used more, or if 
it's just a wash.  i think it makes sense to have an accessible default func 
if it does something useful, but not if it's just a stub.

in the __def/weak style above, unless people use --gc-sections when linking (i 
think we've got many people doing this now, but not all), you end up with dead 
code in the binary.  in the code i proposed, the func gets discarded both when 
using --gc-sections and when not.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111010/836d1287/attachment.pgp 

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

* [U-Boot] [PATCH V2 05/13] i2c: Create common default i2c_set_bus_num() function
  2011-10-10  9:35 ` [U-Boot] [PATCH V2 05/13] i2c: Create common default i2c_set_bus_num() function Stefano Babic
  2011-10-10 10:33   ` Heiko Schocher
@ 2011-10-10 17:53   ` Tabi Timur-B04825
  2011-10-10 18:26     ` Mike Frysinger
  2011-10-11  5:37     ` Heiko Schocher
  1 sibling, 2 replies; 42+ messages in thread
From: Tabi Timur-B04825 @ 2011-10-10 17:53 UTC (permalink / raw)
  To: u-boot

On Mon, Oct 10, 2011 at 4:35 AM, Stefano Babic <sbabic@denx.de> wrote:
> New default, weak i2c_set_bus_num() function.
>
> Signed-off-by: Stefano Babic <sbabic@denx.de>
> Cc: Heiko Schocher <hs@denx.de>

I would prefer to see a new set of I2C functions that take a bus
number as a parameter, so that we can eliminate i2c_set_bus_num() (and
the global variable it modifies) altogether.

-- 
Timur Tabi
Linux kernel developer at Freescale

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

* [U-Boot] [PATCH V2 05/13] i2c: Create common default i2c_set_bus_num() function
  2011-10-10 17:53   ` Tabi Timur-B04825
@ 2011-10-10 18:26     ` Mike Frysinger
  2011-10-10 18:29       ` Timur Tabi
  2011-10-11  7:33       ` Stefano Babic
  2011-10-11  5:37     ` Heiko Schocher
  1 sibling, 2 replies; 42+ messages in thread
From: Mike Frysinger @ 2011-10-10 18:26 UTC (permalink / raw)
  To: u-boot

On Monday 10 October 2011 13:53:48 Tabi Timur-B04825 wrote:
> On Mon, Oct 10, 2011 at 4:35 AM, Stefano Babic <sbabic@denx.de> wrote:
> > New default, weak i2c_set_bus_num() function.
> > 
> > Signed-off-by: Stefano Babic <sbabic@denx.de>
> > Cc: Heiko Schocher <hs@denx.de>
> 
> I would prefer to see a new set of I2C functions that take a bus
> number as a parameter, so that we can eliminate i2c_set_bus_num() (and
> the global variable it modifies) altogether.

i think that'd require a much larger rework of the framework and thus would be 
better to do in addition to Stefano's work rather than in place of ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111010/930bd0a4/attachment.pgp 

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

* [U-Boot] [PATCH V2 05/13] i2c: Create common default i2c_set_bus_num() function
  2011-10-10 18:26     ` Mike Frysinger
@ 2011-10-10 18:29       ` Timur Tabi
  2011-10-11  7:33       ` Stefano Babic
  1 sibling, 0 replies; 42+ messages in thread
From: Timur Tabi @ 2011-10-10 18:29 UTC (permalink / raw)
  To: u-boot

Mike Frysinger wrote:
> i think that'd require a much larger rework of the framework and thus would be 
> better to do in addition to Stefano's work rather than in place of ?

Hmmm... I guess it would be easier to do the rework eventually if
i2c_set_bus_num() is universal, instead of just for PowerPC.

-- 
Timur Tabi
Linux kernel developer at Freescale

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

* [U-Boot] [PATCH V2 05/13] i2c: Create common default i2c_set_bus_num() function
  2011-10-10 17:53   ` Tabi Timur-B04825
  2011-10-10 18:26     ` Mike Frysinger
@ 2011-10-11  5:37     ` Heiko Schocher
  2011-10-11  5:48       ` Wolfgang Denk
  1 sibling, 1 reply; 42+ messages in thread
From: Heiko Schocher @ 2011-10-11  5:37 UTC (permalink / raw)
  To: u-boot

Hello Tabi,

Tabi Timur-B04825 wrote:
> On Mon, Oct 10, 2011 at 4:35 AM, Stefano Babic <sbabic@denx.de> wrote:
>> New default, weak i2c_set_bus_num() function.
>>
>> Signed-off-by: Stefano Babic <sbabic@denx.de>
>> Cc: Heiko Schocher <hs@denx.de>
> 
> I would prefer to see a new set of I2C functions that take a bus
> number as a parameter, so that we can eliminate i2c_set_bus_num() (and
> the global variable it modifies) altogether.

Then please have a look at:

http://git.denx.de/?p=u-boot/u-boot-i2c.git;a=shortlog;h=refs/heads/multibus_v2

It is a complete i2c rework with adding multiadapter/multibus
to the i2c framework (and a i2c_core.c) ... It needs a rebase and tests,
but my last tests (Ok, 6 months ago ... :-( ) on 2 powerpc architectures
and one arm looked good ...

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* [U-Boot] [PATCH V2 05/13] i2c: Create common default i2c_set_bus_num() function
  2011-10-11  5:37     ` Heiko Schocher
@ 2011-10-11  5:48       ` Wolfgang Denk
  2011-10-11  5:51         ` Aaron Williams
  2011-10-11  5:52         ` Heiko Schocher
  0 siblings, 2 replies; 42+ messages in thread
From: Wolfgang Denk @ 2011-10-11  5:48 UTC (permalink / raw)
  To: u-boot

Dear Heiko Schocher,

In message <4E93D634.6080707@denx.de> you wrote:
> 
> Then please have a look at:
> 
> http://git.denx.de/?p=u-boot/u-boot-i2c.git;a=shortlog;h=refs/heads/multibus_v2
> 
> It is a complete i2c rework with adding multiadapter/multibus
> to the i2c framework (and a i2c_core.c) ... It needs a rebase and tests,
> but my last tests (Ok, 6 months ago ... :-( ) on 2 powerpc architectures
> and one arm looked good ...

How about pulling this into mainline right now?  It makes little sense
to watch this bit-rotting even further.  Every interested party had
more than enough time for testing now.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"To IBM, 'open' means there is a modicum  of  interoperability  among
some of their equipment."                            - Harv Masterson

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

* [U-Boot] [PATCH V2 05/13] i2c: Create common default i2c_set_bus_num() function
  2011-10-11  5:48       ` Wolfgang Denk
@ 2011-10-11  5:51         ` Aaron Williams
  2011-10-11  5:52         ` Heiko Schocher
  1 sibling, 0 replies; 42+ messages in thread
From: Aaron Williams @ 2011-10-11  5:51 UTC (permalink / raw)
  To: u-boot

On Monday, October 10, 2011 10:48:07 PM Wolfgang Denk wrote:
> Dear Heiko Schocher,
> 
> In message <4E93D634.6080707@denx.de> you wrote:
> > Then please have a look at:
> > 
> > http://git.denx.de/?p=u-boot/u-boot-i2c.git;a=shortlog;h=refs/heads/multi
> > bus_v2
> > 
> > It is a complete i2c rework with adding multiadapter/multibus
> > to the i2c framework (and a i2c_core.c) ... It needs a rebase and tests,
> > but my last tests (Ok, 6 months ago ... :-( ) on 2 powerpc architectures
> > and one arm looked good ...
> 
> How about pulling this into mainline right now?  It makes little sense
> to watch this bit-rotting even further.  Every interested party had
> more than enough time for testing now.
> 
> Best regards,
> 
> Wolfgang Denk

This will be useful for us. We have a number of boards which use I2C switches 
and muxes plus many of our devices have multiple I2C buses.

-Aaron
-- 
Aaron Williams <Aaron.Williams@cavium.com>
 (408) 943-7198

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

* [U-Boot] [PATCH V2 05/13] i2c: Create common default i2c_set_bus_num() function
  2011-10-11  5:48       ` Wolfgang Denk
  2011-10-11  5:51         ` Aaron Williams
@ 2011-10-11  5:52         ` Heiko Schocher
  1 sibling, 0 replies; 42+ messages in thread
From: Heiko Schocher @ 2011-10-11  5:52 UTC (permalink / raw)
  To: u-boot

Hello Wolfgang,

Wolfgang Denk wrote:
> Dear Heiko Schocher,
> 
> In message <4E93D634.6080707@denx.de> you wrote:
>> Then please have a look at:
>>
>> http://git.denx.de/?p=u-boot/u-boot-i2c.git;a=shortlog;h=refs/heads/multibus_v2
>>
>> It is a complete i2c rework with adding multiadapter/multibus
>> to the i2c framework (and a i2c_core.c) ... It needs a rebase and tests,
>> but my last tests (Ok, 6 months ago ... :-( ) on 2 powerpc architectures
>> and one arm looked good ...
> 
> How about pulling this into mainline right now?  It makes little sense
> to watch this bit-rotting even further.  Every interested party had
> more than enough time for testing now.

Hmm... I had to rebase this and test it ... sorry, didn't found time
to hold this in sync with mainline in the last months ... and after
the rebase I only want to see this in mainline if tests on some
different archs are done (at least powerpc and arm) ...

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* [U-Boot] [PATCH V2 05/13] i2c: Create common default i2c_set_bus_num() function
  2011-10-10 18:26     ` Mike Frysinger
  2011-10-10 18:29       ` Timur Tabi
@ 2011-10-11  7:33       ` Stefano Babic
  1 sibling, 0 replies; 42+ messages in thread
From: Stefano Babic @ 2011-10-11  7:33 UTC (permalink / raw)
  To: u-boot

On 10/10/2011 08:26 PM, Mike Frysinger wrote:
> On Monday 10 October 2011 13:53:48 Tabi Timur-B04825 wrote:
>> On Mon, Oct 10, 2011 at 4:35 AM, Stefano Babic <sbabic@denx.de> wrote:
>>> New default, weak i2c_set_bus_num() function.
>>>
>>> Signed-off-by: Stefano Babic <sbabic@denx.de>
>>> Cc: Heiko Schocher <hs@denx.de>
>>
>> I would prefer to see a new set of I2C functions that take a bus
>> number as a parameter, so that we can eliminate i2c_set_bus_num() (and
>> the global variable it modifies) altogether.
> 
> i think that'd require a much larger rework of the framework and thus would be 
> better to do in addition to Stefano's work rather than in place of ?

Right - this patch is only due to the fact that the mxc_i2c.c has no
i2c_set_bus_num(), while it is present in several SOCs (not only powerpc).

I see now that the pmic patches calls i2c_set_bus_num() instead of the
macro I2C_SET_BUS(), that is protected in case CONFIG_I2C_MULTI_BUS is
not set (I have only now discovered...). Maybe I should drop my patch
and change the pmic to use this macro.

Regards,
Stefano

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

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

* [U-Boot] [PATCH V3 05/13] i2c: Create common default i2c_set_bus_num() function
  2011-10-10 17:51       ` Mike Frysinger
@ 2011-10-11 17:30         ` Stefano Babic
  2011-10-11 17:46           ` Mike Frysinger
  0 siblings, 1 reply; 42+ messages in thread
From: Stefano Babic @ 2011-10-11 17:30 UTC (permalink / raw)
  To: u-boot

On 10/10/2011 07:51 PM, Mike Frysinger wrote:

Hi Mike,

> i believe we have two standards.

Well, two standards means we have  no standard...;-)

>  i'm not sure which gets used more, or if 
> it's just a wash.  i think it makes sense to have an accessible default func 
> if it does something useful, but not if it's just a stub.
> 
> in the __def/weak style above, unless people use --gc-sections when linking (i 
> think we've got many people doing this now, but not all), you end up with dead 
> code in the binary.  in the code i proposed, the func gets discarded both when 
> using --gc-sections and when not.

You are right, but probably it makes no difference. I checked and it
seems that only a few architectute (m68k, sparc and microblaze) do not
set --gc-sections.

After the Heiko's post and our discussion, I think that this patch is
another work-around waiting for the Heiko's patches to go to mainline.
And it becomes a second work-around, because there is already the
I2C_SET_BUS() for boards supporting only one bus. Two work-around are
too much...

I drop this patch and I will make use of I2C_SET_BUS() in pmic. This is
coherent with the actual u-boot code.

Regards,
Stefano

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

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

* [U-Boot] [PATCH V3 05/13] i2c: Create common default i2c_set_bus_num() function
  2011-10-11 17:30         ` Stefano Babic
@ 2011-10-11 17:46           ` Mike Frysinger
  0 siblings, 0 replies; 42+ messages in thread
From: Mike Frysinger @ 2011-10-11 17:46 UTC (permalink / raw)
  To: u-boot

On Tuesday 11 October 2011 13:30:24 Stefano Babic wrote:
> On 10/10/2011 07:51 PM, Mike Frysinger wrote:
> >  i'm not sure which gets used more, or if
> > it's just a wash.  i think it makes sense to have an accessible default
> > func if it does something useful, but not if it's just a stub.
> > 
> > in the __def/weak style above, unless people use --gc-sections when
> > linking (i think we've got many people doing this now, but not all), you
> > end up with dead code in the binary.  in the code i proposed, the func
> > gets discarded both when using --gc-sections and when not.
> 
> You are right, but probably it makes no difference. I checked and it
> seems that only a few architectute (m68k, sparc and microblaze) do not
> set --gc-sections.

i would think the microblaze missing would be an oversight as it's "newer" 
code.  don't know (or honestly, care) how hard it would be to make m68k/sparc 
sane.  but it would be nice to get everyone using gc-sections as we could move 
that into common code and all new arches would start out sane ...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111011/9ca332d2/attachment.pgp 

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

* [U-Boot] [PATCH 13/13] misc: pmic: drop old Freescale's pmic driver
  2011-10-08 16:36 ` [U-Boot] [PATCH 13/13] misc: pmic: drop old Freescale's " Stefano Babic
@ 2011-10-19 13:23   ` Helmut Raiger
  2011-10-19 15:39     ` Stefano Babic
  0 siblings, 1 reply; 42+ messages in thread
From: Helmut Raiger @ 2011-10-19 13:23 UTC (permalink / raw)
  To: u-boot

On 10/08/2011 06:36 PM, Stefano Babic wrote:
> Signed-off-by: Stefano Babic<sbabic@denx.de>
> ---
>   drivers/misc/Makefile   |    1 -
>   drivers/misc/fsl_pmic.c |  235 -----------------------------------------------
>   2 files changed, 0 insertions(+), 236 deletions(-)
>   delete mode 100644 drivers/misc/fsl_pmic.c
>
I just checked PMIC action on our board (i.mx31 and mc13783) and the new 
code is not working here, it even:

TT01> pmic write 20 17
raise: Signal # 8 caught
<reg num> = 32 is invalid. Should be less than 0
TT01> pmic read 20
<reg num> = 32 is invalid. Should be less than 0
PMIC: Register read failed

0x20: 0x00000000

At first glance I found in pmic_fsl.c:

static u32 pmic_spi_prepare_tx(u32 reg, u32 *val, u32 write)
{
     if ((val == NULL) && (write))
         return *val & ~(1 << 31);
     else
         return (write << 31) | (reg << 25) | (*val & 0x00FFFFFF);
}

which must be wrong. NULL is de-referenced in both cases and this error
is even forced by pmic_spi.c:

     if (write) {
         pmic_tx = p->hw.spi.prepare_tx(0, NULL, write);
         pmic_tx &= ~(1 << 31);


Probably val == NULL was meant as escape not to touch the pmic_tx value,
in the original driver it's done that way.
One could fix this by using a static variable in pmic_spi_prepare_tx(), 
but I'm
not sure if this was the intention.

I wonder why it was missed during testing as it seems configuration 
independent.
Helmut



--
Scanned by MailScanner.

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

* [U-Boot] [PATCH 13/13] misc: pmic: drop old Freescale's pmic driver
  2011-10-19 13:23   ` Helmut Raiger
@ 2011-10-19 15:39     ` Stefano Babic
  2011-10-19 16:48       ` [U-Boot] [PATCH] misc: pmic: fix regression in pmic_fsl.c (SPI) Helmut Raiger
  0 siblings, 1 reply; 42+ messages in thread
From: Stefano Babic @ 2011-10-19 15:39 UTC (permalink / raw)
  To: u-boot

On 10/19/2011 03:23 PM, Helmut Raiger wrote:
> On 10/08/2011 06:36 PM, Stefano Babic wrote:
>> Signed-off-by: Stefano Babic<sbabic@denx.de>
>> ---
>>   drivers/misc/Makefile   |    1 -
>>   drivers/misc/fsl_pmic.c |  235
>> -----------------------------------------------
>>   2 files changed, 0 insertions(+), 236 deletions(-)
>>   delete mode 100644 drivers/misc/fsl_pmic.c
>>

Hi Helmut,

> I just checked PMIC action on our board (i.mx31 and mc13783) and the new
> code is not working here, it even:
> 
> TT01> pmic write 20 17
> raise: Signal # 8 caught
> <reg num> = 32 is invalid. Should be less than 0
> TT01> pmic read 20
> <reg num> = 32 is invalid. Should be less than 0
> PMIC: Register read failed
> 
> 0x20: 0x00000000
> 
> At first glance I found in pmic_fsl.c:
> 
> static u32 pmic_spi_prepare_tx(u32 reg, u32 *val, u32 write)
> {
>     if ((val == NULL) && (write))
>         return *val & ~(1 << 31);
>     else
>         return (write << 31) | (reg << 25) | (*val & 0x00FFFFFF);
> }
> 
> which must be wrong. NULL is de-referenced in both cases and this error
> is even forced by pmic_spi.c:

This is wrong - it is checked for NULL and then de-referenced...

> 
>     if (write) {
>         pmic_tx = p->hw.spi.prepare_tx(0, NULL, write);
>         pmic_tx &= ~(1 << 31);
> 
> 
> Probably val == NULL was meant as escape not to touch the pmic_tx value,
> in the original driver it's done that way.

Then there is too much statements. If spi.prepare_tx() should clear the
MSB with ~(1 << 31), why we need the second one :

pmic_tx &= ~(1 << 31);

something went simply wrong...

Because (from the old driver) the second SPI transfer is done to read
back the programmed value, we can maybe use :

     if (write) {
         pmic_tx = p->hw.spi.prepare_tx(reg, &val, 0);

and of course, we should fix the wrong prepare_tx()..

> One could fix this by using a static variable in pmic_spi_prepare_tx(),
> but I'm
> not sure if this was the intention.
> 

Well, it makes no sense - the prepare_tx() should not know the history,
and only rely on the parameters.

> I wonder why it was missed during testing as it seems configuration
> independent.

I wonder, too. I have tested with the 'date' command, that means writing
into the internal RTC registers of the MC13783. I cannot explain what
goes wrong, but of course the code is buggy and must be fixed.

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

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

* [U-Boot] [PATCH] misc: pmic: fix regression in pmic_fsl.c (SPI)
  2011-10-19 15:39     ` Stefano Babic
@ 2011-10-19 16:48       ` Helmut Raiger
  2011-10-19 17:15         ` Stefano Babic
                           ` (2 more replies)
  0 siblings, 3 replies; 42+ messages in thread
From: Helmut Raiger @ 2011-10-19 16:48 UTC (permalink / raw)
  To: u-boot

This fixes write access to PMIC registers, the bug was
introduced partly in commit 64aac65099 and in commit c9fe76dd91.
It was tested on an i.mx31 with a mc13783.

Signed-off-by: Helmut Raiger <helmut.raiger@hale.at>
---
 drivers/misc/pmic_fsl.c |    5 +----
 drivers/misc/pmic_spi.c |    1 -
 2 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/drivers/misc/pmic_fsl.c b/drivers/misc/pmic_fsl.c
index b6e809a..0ff75ed 100644
--- a/drivers/misc/pmic_fsl.c
+++ b/drivers/misc/pmic_fsl.c
@@ -29,10 +29,7 @@
 #if defined(CONFIG_PMIC_SPI)
 static u32 pmic_spi_prepare_tx(u32 reg, u32 *val, u32 write)
 {
-	if ((val == NULL) && (write))
-		return *val & ~(1 << 31);
-	else
-		return (write << 31) | (reg << 25) | (*val & 0x00FFFFFF);
+	return (write << 31) | (reg << 25) | (*val & 0x00FFFFFF);
 }
 #endif
 
diff --git a/drivers/misc/pmic_spi.c b/drivers/misc/pmic_spi.c
index ff35377..e772884 100644
--- a/drivers/misc/pmic_spi.c
+++ b/drivers/misc/pmic_spi.c
@@ -76,7 +76,6 @@ static u32 pmic_reg(struct pmic *p, u32 reg, u32 *val, u32 write)
 	}
 
 	if (write) {
-		pmic_tx = p->hw.spi.prepare_tx(0, NULL, write);
 		pmic_tx &= ~(1 << 31);
 		tmp = cpu_to_be32(pmic_tx);
 		if (spi_xfer(slave, pmic_spi_bitlen, &tmp, &pmic_rx,
-- 
1.7.4.4



--
Scanned by MailScanner.

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

* [U-Boot] [PATCH] misc: pmic: fix regression in pmic_fsl.c (SPI)
  2011-10-19 16:48       ` [U-Boot] [PATCH] misc: pmic: fix regression in pmic_fsl.c (SPI) Helmut Raiger
@ 2011-10-19 17:15         ` Stefano Babic
  2011-10-20  6:41           ` Helmut Raiger
  2011-10-20  6:28         ` [U-Boot] [PATCH V2] " Helmut Raiger
  2011-10-20  6:34         ` [U-Boot] [Resend PATCH " Helmut Raiger
  2 siblings, 1 reply; 42+ messages in thread
From: Stefano Babic @ 2011-10-19 17:15 UTC (permalink / raw)
  To: u-boot

On 10/19/2011 06:48 PM, Helmut Raiger wrote:
> This fixes write access to PMIC registers, the bug was
> introduced partly in commit 64aac65099 and in commit c9fe76dd91.
> It was tested on an i.mx31 with a mc13783.
> 
> Signed-off-by: Helmut Raiger <helmut.raiger@hale.at>
> ---
>  drivers/misc/pmic_fsl.c |    5 +----
>  drivers/misc/pmic_spi.c |    1 -
>  2 files changed, 1 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/misc/pmic_fsl.c b/drivers/misc/pmic_fsl.c
> index b6e809a..0ff75ed 100644

Hi Helmut,

> --- a/drivers/misc/pmic_fsl.c
> +++ b/drivers/misc/pmic_fsl.c
> @@ -29,10 +29,7 @@
>  #if defined(CONFIG_PMIC_SPI)
>  static u32 pmic_spi_prepare_tx(u32 reg, u32 *val, u32 write)
>  {
> -	if ((val == NULL) && (write))
> -		return *val & ~(1 << 31);
> -	else
> -		return (write << 31) | (reg << 25) | (*val & 0x00FFFFFF);
> +	return (write << 31) | (reg << 25) | (*val & 0x00FFFFFF);
>  }
>  #endif
>  
> diff --git a/drivers/misc/pmic_spi.c b/drivers/misc/pmic_spi.c
> index ff35377..e772884 100644
> --- a/drivers/misc/pmic_spi.c
> +++ b/drivers/misc/pmic_spi.c
> @@ -76,7 +76,6 @@ static u32 pmic_reg(struct pmic *p, u32 reg, u32 *val, u32 write)
>  	}
>  
>  	if (write) {
> -		pmic_tx = p->hw.spi.prepare_tx(0, NULL, write);
>  		pmic_tx &= ~(1 << 31);

This fixes the issue with the Freescale PMIC, but...

The new driver introduces a level of abstraction to make easier to
introduce other PMICs that are driven with SPI / I2C. For this reason,
PMIC specific code must be inside the specific driver (pmic_fsl.c) and
not in the general (pmic_core.c and pmic_spi.c). And clearing the MSB is
part of the Freescale's protocol, and for this reason should be moved
inside the prepare function.

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office@denx.de
=====================================================================

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

* [U-Boot] [PATCH V2] misc: pmic: fix regression in pmic_fsl.c (SPI)
  2011-10-19 16:48       ` [U-Boot] [PATCH] misc: pmic: fix regression in pmic_fsl.c (SPI) Helmut Raiger
  2011-10-19 17:15         ` Stefano Babic
@ 2011-10-20  6:28         ` Helmut Raiger
  2011-10-20  6:34         ` [U-Boot] [Resend PATCH " Helmut Raiger
  2 siblings, 0 replies; 42+ messages in thread
From: Helmut Raiger @ 2011-10-20  6:28 UTC (permalink / raw)
  To: u-boot

This fixes write access to PMIC registers, the bug was
introduced partly in commit 64aac65099 and in commit c9fe76dd91.
It was tested on an i.mx31 with a mc13783.

Signed-off-by: Helmut Raiger <helmut.raiger@hale.at>
---
 V2: threw in the wrong readback line in V1

 drivers/misc/pmic_fsl.c |    5 +----
 drivers/misc/pmic_spi.c |    1 -
 2 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/drivers/misc/pmic_fsl.c b/drivers/misc/pmic_fsl.c
index b6e809a..0ff75ed 100644
--- a/drivers/misc/pmic_fsl.c
+++ b/drivers/misc/pmic_fsl.c
@@ -29,10 +29,7 @@
 #if defined(CONFIG_PMIC_SPI)
 static u32 pmic_spi_prepare_tx(u32 reg, u32 *val, u32 write)
 {
-	if ((val == NULL) && (write))
-		return *val & ~(1 << 31);
-	else
-		return (write << 31) | (reg << 25) | (*val & 0x00FFFFFF);
+	return (write << 31) | (reg << 25) | (*val & 0x00FFFFFF);
 }
 #endif
 
diff --git a/drivers/misc/pmic_spi.c b/drivers/misc/pmic_spi.c
index ff35377..e772884 100644
--- a/drivers/misc/pmic_spi.c
+++ b/drivers/misc/pmic_spi.c
@@ -76,7 +76,6 @@ static u32 pmic_reg(struct pmic *p, u32 reg, u32 *val, u32 write)
 	}
 
 	if (write) {
-		pmic_tx = p->hw.spi.prepare_tx(0, NULL, write);
 		pmic_tx &= ~(1 << 31);
 		tmp = cpu_to_be32(pmic_tx);
 		if (spi_xfer(slave, pmic_spi_bitlen, &tmp, &pmic_rx,
-- 
1.7.4.4



--
Scanned by MailScanner.

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

* [U-Boot] [Resend PATCH V2] misc: pmic: fix regression in pmic_fsl.c (SPI)
  2011-10-19 16:48       ` [U-Boot] [PATCH] misc: pmic: fix regression in pmic_fsl.c (SPI) Helmut Raiger
  2011-10-19 17:15         ` Stefano Babic
  2011-10-20  6:28         ` [U-Boot] [PATCH V2] " Helmut Raiger
@ 2011-10-20  6:34         ` Helmut Raiger
  2011-10-20  7:31           ` Stefano Babic
  2011-10-24  7:48           ` Stefano Babic
  2 siblings, 2 replies; 42+ messages in thread
From: Helmut Raiger @ 2011-10-20  6:34 UTC (permalink / raw)
  To: u-boot

This fixes write access to PMIC registers, the bug was
introduced partly in commit 64aac65099 and in commit c9fe76dd91.
It was tested on an i.mx31 with a mc13783.

Signed-off-by: Helmut Raiger <helmut.raiger@hale.at>
---
 V2: threw in the wrong read back line (again and again)

 drivers/misc/pmic_fsl.c |    5 +----
 drivers/misc/pmic_spi.c |    3 +--
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/misc/pmic_fsl.c b/drivers/misc/pmic_fsl.c
index b6e809a..0ff75ed 100644
--- a/drivers/misc/pmic_fsl.c
+++ b/drivers/misc/pmic_fsl.c
@@ -29,10 +29,7 @@
 #if defined(CONFIG_PMIC_SPI)
 static u32 pmic_spi_prepare_tx(u32 reg, u32 *val, u32 write)
 {
-	if ((val == NULL) && (write))
-		return *val & ~(1 << 31);
-	else
-		return (write << 31) | (reg << 25) | (*val & 0x00FFFFFF);
+	return (write << 31) | (reg << 25) | (*val & 0x00FFFFFF);
 }
 #endif
 
diff --git a/drivers/misc/pmic_spi.c b/drivers/misc/pmic_spi.c
index ff35377..5a0dd22 100644
--- a/drivers/misc/pmic_spi.c
+++ b/drivers/misc/pmic_spi.c
@@ -76,8 +76,7 @@ static u32 pmic_reg(struct pmic *p, u32 reg, u32 *val, u32 write)
 	}
 
 	if (write) {
-		pmic_tx = p->hw.spi.prepare_tx(0, NULL, write);
-		pmic_tx &= ~(1 << 31);
+		pmic_tx = p->hw.spi.prepare_tx(reg, val, 0);
 		tmp = cpu_to_be32(pmic_tx);
 		if (spi_xfer(slave, pmic_spi_bitlen, &tmp, &pmic_rx,
 			pmic_spi_flags)) {
-- 
1.7.4.4



--
Scanned by MailScanner.

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

* [U-Boot] [PATCH] misc: pmic: fix regression in pmic_fsl.c (SPI)
  2011-10-19 17:15         ` Stefano Babic
@ 2011-10-20  6:41           ` Helmut Raiger
  0 siblings, 0 replies; 42+ messages in thread
From: Helmut Raiger @ 2011-10-20  6:41 UTC (permalink / raw)
  To: u-boot

On 10/19/2011 07:15 PM, Stefano Babic wrote:
>
> This fixes the issue with the Freescale PMIC, but...
>
> The new driver introduces a level of abstraction to make easier to
> introduce other PMICs that are driven with SPI / I2C. For this reason,
> PMIC specific code must be inside the specific driver (pmic_fsl.c) and
> not in the general (pmic_core.c and pmic_spi.c). And clearing the MSB is
> part of the Freescale's protocol, and for this reason should be moved
> inside the prepare function.
>
> Best regards,
> Stefano Babic
>

Ah yes, I stumbled over git again (and again and again). :-[
See [Resend V2].

Helmut


--
Scanned by MailScanner.

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

* [U-Boot] [Resend PATCH V2] misc: pmic: fix regression in pmic_fsl.c (SPI)
  2011-10-20  6:34         ` [U-Boot] [Resend PATCH " Helmut Raiger
@ 2011-10-20  7:31           ` Stefano Babic
  2011-10-24  7:48           ` Stefano Babic
  1 sibling, 0 replies; 42+ messages in thread
From: Stefano Babic @ 2011-10-20  7:31 UTC (permalink / raw)
  To: u-boot

On 10/20/2011 08:34 AM, Helmut Raiger wrote:
> This fixes write access to PMIC registers, the bug was
> introduced partly in commit 64aac65099 and in commit c9fe76dd91.
> It was tested on an i.mx31 with a mc13783.
> 
> Signed-off-by: Helmut Raiger <helmut.raiger@hale.at>
> ---
>  V2: threw in the wrong read back line (again and again)
> 

Hi Helmut,

>  drivers/misc/pmic_fsl.c |    5 +----
>  drivers/misc/pmic_spi.c |    3 +--
>  2 files changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/misc/pmic_fsl.c b/drivers/misc/pmic_fsl.c
> index b6e809a..0ff75ed 100644
> --- a/drivers/misc/pmic_fsl.c
> +++ b/drivers/misc/pmic_fsl.c
> @@ -29,10 +29,7 @@
>  #if defined(CONFIG_PMIC_SPI)
>  static u32 pmic_spi_prepare_tx(u32 reg, u32 *val, u32 write)
>  {
> -	if ((val == NULL) && (write))
> -		return *val & ~(1 << 31);
> -	else
> -		return (write << 31) | (reg << 25) | (*val & 0x00FFFFFF);
> +	return (write << 31) | (reg << 25) | (*val & 0x00FFFFFF);
>  }
>  #endif
>  
> diff --git a/drivers/misc/pmic_spi.c b/drivers/misc/pmic_spi.c
> index ff35377..5a0dd22 100644
> --- a/drivers/misc/pmic_spi.c
> +++ b/drivers/misc/pmic_spi.c
> @@ -76,8 +76,7 @@ static u32 pmic_reg(struct pmic *p, u32 reg, u32 *val, u32 write)
>  	}
>  
>  	if (write) {
> -		pmic_tx = p->hw.spi.prepare_tx(0, NULL, write);
> -		pmic_tx &= ~(1 << 31);
> +		pmic_tx = p->hw.spi.prepare_tx(reg, val, 0);
>  		tmp = cpu_to_be32(pmic_tx);
>  		if (spi_xfer(slave, pmic_spi_bitlen, &tmp, &pmic_rx,
>  			pmic_spi_flags)) {

Right. I wait just a bit for further comments, then I will push to
u-boot-imx.

Acked-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

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

* [U-Boot] [Resend PATCH V2] misc: pmic: fix regression in pmic_fsl.c (SPI)
  2011-10-20  6:34         ` [U-Boot] [Resend PATCH " Helmut Raiger
  2011-10-20  7:31           ` Stefano Babic
@ 2011-10-24  7:48           ` Stefano Babic
  1 sibling, 0 replies; 42+ messages in thread
From: Stefano Babic @ 2011-10-24  7:48 UTC (permalink / raw)
  To: u-boot

On 10/20/2011 08:34 AM, Helmut Raiger wrote:
> This fixes write access to PMIC registers, the bug was
> introduced partly in commit 64aac65099 and in commit c9fe76dd91.
> It was tested on an i.mx31 with a mc13783.
> 
> Signed-off-by: Helmut Raiger <helmut.raiger@hale.at>
> ---
>  V2: threw in the wrong read back line (again and again)

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

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

end of thread, other threads:[~2011-10-24  7:48 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-08 16:35 [U-Boot] switch to generic PMIC driver for i.MX boards Stefano Babic
2011-10-08 16:35 ` [U-Boot] [PATCH 01/13] MX5: vision2: use new pmic driver Stefano Babic
2011-10-08 16:35 ` [U-Boot] [PATCH 02/13] RTC: Switch mc13783 to generic pmic code Stefano Babic
2011-10-08 16:35 ` [U-Boot] [PATCH 03/13] MX3: qong: use new pmic driver Stefano Babic
2011-10-08 16:36 ` [U-Boot] [PATCH V2 04/13] MX5: efikamx/efikasb: " Stefano Babic
2011-10-08 16:57   ` Marek Vasut
2011-10-08 16:36 ` [U-Boot] [PATCH 05/13] I2c: add missing i2c_set_bus_num to mxc_i2c Stefano Babic
2011-10-10  8:50   ` Heiko Schocher
2011-10-10  9:30     ` Stefano Babic
2011-10-08 16:36 ` [U-Boot] [PATCH V2 06/13] misc: pmic: addI2C support to pmic_fsl driver Stefano Babic
2011-10-08 16:36 ` [U-Boot] [PATCH 07/13] MX35: mx35pdk: use new pmic driver Stefano Babic
2011-10-08 16:36 ` [U-Boot] [PATCH V2 08/13] MX5: mx51evk: " Stefano Babic
2011-10-08 16:36 ` [U-Boot] [PATCH V2 09/13] MX5: mx53evk: " Stefano Babic
2011-10-08 16:36 ` [U-Boot] [PATCH 10/13] MX31: mx31_litekit: " Stefano Babic
2011-10-08 16:36 ` [U-Boot] [PATCH 11/13] MX31: mx31ads: " Stefano Babic
2011-10-08 16:36 ` [U-Boot] [PATCH 12/13] MX31: mx31pdk: " Stefano Babic
2011-10-08 16:36 ` [U-Boot] [PATCH 13/13] misc: pmic: drop old Freescale's " Stefano Babic
2011-10-19 13:23   ` Helmut Raiger
2011-10-19 15:39     ` Stefano Babic
2011-10-19 16:48       ` [U-Boot] [PATCH] misc: pmic: fix regression in pmic_fsl.c (SPI) Helmut Raiger
2011-10-19 17:15         ` Stefano Babic
2011-10-20  6:41           ` Helmut Raiger
2011-10-20  6:28         ` [U-Boot] [PATCH V2] " Helmut Raiger
2011-10-20  6:34         ` [U-Boot] [Resend PATCH " Helmut Raiger
2011-10-20  7:31           ` Stefano Babic
2011-10-24  7:48           ` Stefano Babic
2011-10-10  9:35 ` [U-Boot] [PATCH V2 05/13] i2c: Create common default i2c_set_bus_num() function Stefano Babic
2011-10-10 10:33   ` Heiko Schocher
2011-10-10 17:53   ` Tabi Timur-B04825
2011-10-10 18:26     ` Mike Frysinger
2011-10-10 18:29       ` Timur Tabi
2011-10-11  7:33       ` Stefano Babic
2011-10-11  5:37     ` Heiko Schocher
2011-10-11  5:48       ` Wolfgang Denk
2011-10-11  5:51         ` Aaron Williams
2011-10-11  5:52         ` Heiko Schocher
2011-10-10 10:50 ` [U-Boot] [PATCH V3 " Stefano Babic
2011-10-10 15:19   ` Mike Frysinger
2011-10-10 15:31     ` Stefano Babic
2011-10-10 17:51       ` Mike Frysinger
2011-10-11 17:30         ` Stefano Babic
2011-10-11 17:46           ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox