All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 0/5] sunxi: i2c and pmic support
@ 2014-06-13 20:55 Hans de Goede
  2014-06-13 20:55 ` [U-Boot] [PATCH v2 1/5] mvtwsi: convert to CONFIG_SYS_I2C framework Hans de Goede
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Hans de Goede @ 2014-06-13 20:55 UTC (permalink / raw)
  To: u-boot

Hi Albert, Heiko,

Here is v2 of my standalone i2c and pmic support for sunxi series.

I think it would be best for this series to go upstream through the
u-boot-arm tree, since most changes are sunxi specific.

Note patch 5/5 is an unrelated sunxi bugfix for a bug I found while testing
the i2c + pmic support. 

Changes since v1:
-"mvtwsi: convert to CONFIG_SYS_I2C framework"
 Use CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE when instantiating the
 controller with the U_BOOT_I2C_ADAP_COMPLETE macro
-Add Acked-by tags from Ian / Heiko / Prafulla to all patches

Regards,

Hans

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

* [U-Boot] [PATCH v2 1/5] mvtwsi: convert to CONFIG_SYS_I2C framework
  2014-06-13 20:55 [U-Boot] [PATCH v2 0/5] sunxi: i2c and pmic support Hans de Goede
@ 2014-06-13 20:55 ` Hans de Goede
  2014-07-06 13:28   ` Ian Campbell
  2014-06-13 20:55 ` [U-Boot] [PATCH v2 2/5] sunxi: Add i2c support Hans de Goede
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Hans de Goede @ 2014-06-13 20:55 UTC (permalink / raw)
  To: u-boot

Note this has only been tested on Allwinner sunxi devices (support for which
gets introduced by a later patch).

The kirkwood changes have been compile tested using the wireless_space board
config, the orion5x changes have been compile tested using the edminiv2 board
config.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Heiko Schocher <hs@denx.de>
---
 arch/arm/include/asm/arch-kirkwood/config.h |  3 +-
 drivers/i2c/Makefile                        |  2 +-
 drivers/i2c/mvtwsi.c                        | 70 +++++++++++++----------------
 include/configs/edminiv2.h                  |  3 +-
 4 files changed, 37 insertions(+), 41 deletions(-)

diff --git a/arch/arm/include/asm/arch-kirkwood/config.h b/arch/arm/include/asm/arch-kirkwood/config.h
index 7a688e4..f7bfa0e 100644
--- a/arch/arm/include/asm/arch-kirkwood/config.h
+++ b/arch/arm/include/asm/arch-kirkwood/config.h
@@ -129,7 +129,8 @@
  */
 #ifdef CONFIG_CMD_I2C
 #ifndef CONFIG_SYS_I2C_SOFT
-#define CONFIG_I2C_MVTWSI
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_MVTWSI
 #endif
 #define CONFIG_SYS_I2C_SLAVE		0x0
 #define CONFIG_SYS_I2C_SPEED		100000
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index e33586d..61e9f3c 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -7,7 +7,6 @@
 
 obj-$(CONFIG_BFIN_TWI_I2C) += bfin-twi_i2c.o
 obj-$(CONFIG_DW_I2C) += designware_i2c.o
-obj-$(CONFIG_I2C_MVTWSI) += mvtwsi.o
 obj-$(CONFIG_I2C_MV) += mv_i2c.o
 obj-$(CONFIG_I2C_MXS) += mxs_i2c.o
 obj-$(CONFIG_PCA9564_I2C) += pca9564_i2c.o
@@ -19,6 +18,7 @@ obj-$(CONFIG_SYS_I2C_DAVINCI) += davinci_i2c.o
 obj-$(CONFIG_SYS_I2C_FSL) += fsl_i2c.o
 obj-$(CONFIG_SYS_I2C_FTI2C010) += fti2c010.o
 obj-$(CONFIG_SYS_I2C_KONA) += kona_i2c.o
+obj-$(CONFIG_SYS_I2C_MVTWSI) += mvtwsi.o
 obj-$(CONFIG_SYS_I2C_MXC) += mxc_i2c.o
 obj-$(CONFIG_SYS_I2C_OMAP24XX) += omap24xx_i2c.o
 obj-$(CONFIG_SYS_I2C_OMAP34XX) += omap24xx_i2c.o
diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c
index 5ba0e03..c8b5425 100644
--- a/drivers/i2c/mvtwsi.c
+++ b/drivers/i2c/mvtwsi.c
@@ -220,11 +220,10 @@ static int twsi_stop(int status)
 
 /*
  * Reset controller.
- * Called at end of i2c_init unsuccessful i2c transactions.
  * Controller reset also resets the baud rate and slave address, so
- * re-establish them.
+ * they must be re-established afterwards.
  */
-static void twsi_reset(u8 baud_rate, u8 slave_address)
+static void twsi_reset(struct i2c_adapter *adap)
 {
 	/* ensure controller will be enabled by any twsi*() function */
 	twsi_control_flags = MVTWSI_CONTROL_TWSIEN;
@@ -232,23 +231,17 @@ static void twsi_reset(u8 baud_rate, u8 slave_address)
 	writel(0, &twsi->soft_reset);
 	/* wait 2 ms -- this is what the Marvell LSP does */
 	udelay(20000);
-	/* set baud rate */
-	writel(baud_rate, &twsi->baudrate);
-	/* set slave address even though we don't use it */
-	writel(slave_address, &twsi->slave_address);
-	writel(0, &twsi->xtnd_slave_addr);
-	/* assert STOP but don't care for the result */
-	(void) twsi_stop(0);
 }
 
 /*
  * I2C init called by cmd_i2c when doing 'i2c reset'.
  * Sets baud to the highest possible value not exceeding requested one.
  */
-void i2c_init(int requested_speed, int slaveadd)
+static unsigned int twsi_i2c_set_bus_speed(struct i2c_adapter *adap,
+					   unsigned int requested_speed)
 {
-	int	tmp_speed, highest_speed, n, m;
-	int	baud = 0x44; /* baudrate at controller reset */
+	unsigned int tmp_speed, highest_speed, n, m;
+	unsigned int baud = 0x44; /* baudrate at controller reset */
 
 	/* use actual speed to collect progressively higher values */
 	highest_speed = 0;
@@ -263,8 +256,21 @@ void i2c_init(int requested_speed, int slaveadd)
 			}
 		}
 	}
+	writel(baud, &twsi->baudrate);
+	return 0;
+}
+
+static void twsi_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd)
+{
 	/* reset controller */
-	twsi_reset(baud, slaveadd);
+	twsi_reset(adap);
+	/* set speed */
+	twsi_i2c_set_bus_speed(adap, speed);
+	/* set slave address even though we don't use it */
+	writel(slaveadd, &twsi->slave_address);
+	writel(0, &twsi->xtnd_slave_addr);
+	/* assert STOP but don't care for the result */
+	(void) twsi_stop(0);
 }
 
 /*
@@ -294,7 +300,7 @@ static int i2c_begin(int expected_start_status, u8 addr)
  * I2C probe called by cmd_i2c when doing 'i2c probe'.
  * Begin read, nak data byte, end.
  */
-int i2c_probe(uchar chip)
+static int twsi_i2c_probe(struct i2c_adapter *adap, uchar chip)
 {
 	u8 dummy_byte;
 	int status;
@@ -320,12 +326,13 @@ int i2c_probe(uchar chip)
  * cmd_eeprom, so we have to choose here, and for the moment that'll be
  * a repeated start without a preceding stop.
  */
-int i2c_read(u8 dev, uint addr, int alen, u8 *data, int length)
+static int twsi_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
+			int alen, uchar *data, int length)
 {
 	int status;
 
 	/* begin i2c write to send the address bytes */
-	status = i2c_begin(MVTWSI_STATUS_START, (dev << 1));
+	status = i2c_begin(MVTWSI_STATUS_START, (chip << 1));
 	/* send addr bytes */
 	while ((status == 0) && alen--)
 		status = twsi_send(addr >> (8*alen),
@@ -333,7 +340,7 @@ int i2c_read(u8 dev, uint addr, int alen, u8 *data, int length)
 	/* begin i2c read to receive eeprom data bytes */
 	if (status == 0)
 		status = i2c_begin(
-			MVTWSI_STATUS_REPEATED_START, (dev << 1) | 1);
+			MVTWSI_STATUS_REPEATED_START, (chip << 1) | 1);
 	/* prepare ACK if@least one byte must be received */
 	if (length > 0)
 		twsi_control_flags |= MVTWSI_CONTROL_ACK;
@@ -355,12 +362,13 @@ int i2c_read(u8 dev, uint addr, int alen, u8 *data, int length)
  * I2C write called by cmd_i2c when doing 'i2c write' and by cmd_eeprom.c
  * Begin write, send address byte(s), send data bytes, end.
  */
-int i2c_write(u8 dev, uint addr, int alen, u8 *data, int length)
+static int twsi_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
+			int alen, uchar *data, int length)
 {
 	int status;
 
 	/* begin i2c write to send the eeprom adress bytes then data bytes */
-	status = i2c_begin(MVTWSI_STATUS_START, (dev << 1));
+	status = i2c_begin(MVTWSI_STATUS_START, (chip << 1));
 	/* send addr bytes */
 	while ((status == 0) && alen--)
 		status = twsi_send(addr >> (8*alen),
@@ -374,21 +382,7 @@ int i2c_write(u8 dev, uint addr, int alen, u8 *data, int length)
 	return status;
 }
 
-/*
- * Bus set routine: we only support bus 0.
- */
-int i2c_set_bus_num(unsigned int bus)
-{
-	if (bus > 0) {
-		return -1;
-	}
-	return 0;
-}
-
-/*
- * Bus get routine: hard-return bus 0.
- */
-unsigned int i2c_get_bus_num(void)
-{
-	return 0;
-}
+U_BOOT_I2C_ADAP_COMPLETE(twsi0, twsi_i2c_init, twsi_i2c_probe,
+			 twsi_i2c_read, twsi_i2c_write,
+			 twsi_i2c_set_bus_speed,
+			 CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE, 0)
diff --git a/include/configs/edminiv2.h b/include/configs/edminiv2.h
index 8b9f66a..77717a8 100644
--- a/include/configs/edminiv2.h
+++ b/include/configs/edminiv2.h
@@ -187,7 +187,8 @@
  * I2C related stuff
  */
 #ifdef CONFIG_CMD_I2C
-#define CONFIG_I2C_MVTWSI
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_MVTWSI
 #define CONFIG_I2C_MVTWSI_BASE		ORION5X_TWSI_BASE
 #define CONFIG_SYS_I2C_SLAVE		0x0
 #define CONFIG_SYS_I2C_SPEED		100000
-- 
2.0.0

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

* [U-Boot] [PATCH v2 2/5] sunxi: Add i2c support
  2014-06-13 20:55 [U-Boot] [PATCH v2 0/5] sunxi: i2c and pmic support Hans de Goede
  2014-06-13 20:55 ` [U-Boot] [PATCH v2 1/5] mvtwsi: convert to CONFIG_SYS_I2C framework Hans de Goede
@ 2014-06-13 20:55 ` Hans de Goede
  2014-06-13 20:55 ` [U-Boot] [PATCH v2 3/5] sunxi: Add axp209 pmic support Hans de Goede
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Hans de Goede @ 2014-06-13 20:55 UTC (permalink / raw)
  To: u-boot

Add support for the i2c controller found on all Allwinner sunxi SoCs,
this is the same controller as found on the Marvell orion5x and kirkwood
SoC families, with a slightly different register layout, so this patch uses
the existing mvtwsi code.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
Acked-By: Prafulla Wadaskar <prafulla@marvell.com>
Acked-by: Heiko Schocher <hs@denx.de>
---
 arch/arm/cpu/armv7/sunxi/board.c        |  6 ++++++
 arch/arm/cpu/armv7/sunxi/u-boot-spl.lds |  5 +++++
 arch/arm/include/asm/arch-sunxi/i2c.h   | 15 +++++++++++++++
 board/sunxi/board.c                     |  7 +++++++
 drivers/i2c/mvtwsi.c                    | 18 ++++++++++++++++++
 include/configs/sunxi-common.h          |  8 ++++++++
 6 files changed, 59 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-sunxi/i2c.h

diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c
index 1e506b5..024c8c1 100644
--- a/arch/arm/cpu/armv7/sunxi/board.c
+++ b/arch/arm/cpu/armv7/sunxi/board.c
@@ -11,6 +11,7 @@
  */
 
 #include <common.h>
+#include <i2c.h>
 #include <netdev.h>
 #include <miiphy.h>
 #include <serial.h>
@@ -91,11 +92,16 @@ void s_init(void)
 	clock_init();
 	timer_init();
 	gpio_init();
+	i2c_init_board();
 
 #ifdef CONFIG_SPL_BUILD
 	gd = &gdata;
 	preloader_console_init();
 
+#ifdef CONFIG_SPL_I2C_SUPPORT
+	/* Needed early by sunxi_board_init if PMU is enabled */
+	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
 	sunxi_board_init();
 #endif
 }
diff --git a/arch/arm/cpu/armv7/sunxi/u-boot-spl.lds b/arch/arm/cpu/armv7/sunxi/u-boot-spl.lds
index c1ae227..53f0cbd 100644
--- a/arch/arm/cpu/armv7/sunxi/u-boot-spl.lds
+++ b/arch/arm/cpu/armv7/sunxi/u-boot-spl.lds
@@ -39,6 +39,11 @@ SECTIONS
 	.data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram
 
 	. = ALIGN(4);
+	.u_boot_list : {
+		KEEP(*(SORT(.u_boot_list*)));
+	} > .sram
+
+	. = ALIGN(4);
 	__image_copy_end = .;
 	_end = .;
 
diff --git a/arch/arm/include/asm/arch-sunxi/i2c.h b/arch/arm/include/asm/arch-sunxi/i2c.h
new file mode 100644
index 0000000..dc5406b
--- /dev/null
+++ b/arch/arm/include/asm/arch-sunxi/i2c.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright 2014 - Hans de Goede <hdegoede@redhat.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#ifndef _SUNXI_I2C_H_
+#define _SUNXI_I2C_H_
+
+#include <asm/arch/cpu.h>
+
+#define CONFIG_I2C_MVTWSI_BASE	SUNXI_TWI0_BASE
+/* This is abp0-clk on sun4i/5i/7i / abp1-clk on sun6i/sun8i which is 24MHz */
+#define CONFIG_SYS_TCLK		24000000
+
+#endif
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index b05d0b9..543b809 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -106,6 +106,13 @@ int board_mmc_init(bd_t *bis)
 }
 #endif
 
+void i2c_init_board(void)
+{
+	sunxi_gpio_set_cfgpin(SUNXI_GPB(0), SUNXI_GPB0_TWI0);
+	sunxi_gpio_set_cfgpin(SUNXI_GPB(1), SUNXI_GPB0_TWI0);
+	clock_twi_onoff(0, 1);
+}
+
 #ifdef CONFIG_SPL_BUILD
 void sunxi_board_init(void)
 {
diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c
index c8b5425..ab3ffa0 100644
--- a/drivers/i2c/mvtwsi.c
+++ b/drivers/i2c/mvtwsi.c
@@ -22,6 +22,8 @@
 #include <asm/arch/orion5x.h>
 #elif defined(CONFIG_KIRKWOOD)
 #include <asm/arch/kirkwood.h>
+#elif defined(CONFIG_SUNXI)
+#include <asm/arch/i2c.h>
 #else
 #error Driver mvtwsi not supported by SoC or board
 #endif
@@ -30,6 +32,20 @@
  * TWSI register structure
  */
 
+#ifdef CONFIG_SUNXI
+
+struct  mvtwsi_registers {
+	u32 slave_address;
+	u32 xtnd_slave_addr;
+	u32 data;
+	u32 control;
+	u32 status;
+	u32 baudrate;
+	u32 soft_reset;
+};
+
+#else
+
 struct  mvtwsi_registers {
 	u32 slave_address;
 	u32 data;
@@ -43,6 +59,8 @@ struct  mvtwsi_registers {
 	u32 soft_reset;
 };
 
+#endif
+
 /*
  * Control register fields
  */
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 3f04890..42b0d2e 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -161,6 +161,14 @@
 #undef CONFIG_CMD_NET
 #undef CONFIG_CMD_NFS
 
+/* I2C */
+#define CONFIG_SPL_I2C_SUPPORT
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_MVTWSI
+#define CONFIG_SYS_I2C_SPEED		400000
+#define CONFIG_SYS_I2C_SLAVE		0x7f
+#define CONFIG_CMD_I2C
+
 #ifndef CONFIG_CONS_INDEX
 #define CONFIG_CONS_INDEX              1       /* UART0 */
 #endif
-- 
2.0.0

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

* [U-Boot] [PATCH v2 3/5] sunxi: Add axp209 pmic support
  2014-06-13 20:55 [U-Boot] [PATCH v2 0/5] sunxi: i2c and pmic support Hans de Goede
  2014-06-13 20:55 ` [U-Boot] [PATCH v2 1/5] mvtwsi: convert to CONFIG_SYS_I2C framework Hans de Goede
  2014-06-13 20:55 ` [U-Boot] [PATCH v2 2/5] sunxi: Add i2c support Hans de Goede
@ 2014-06-13 20:55 ` Hans de Goede
  2014-07-16 21:48   ` Ian Campbell
  2014-07-23 18:49   ` Siarhei Siamashka
  2014-06-13 20:55 ` [U-Boot] [PATCH v2 4/5] sunxi: Add axp152 " Hans de Goede
  2014-06-13 20:55 ` [U-Boot] [PATCH v2 5/5] sunxi: Fix reset hang on sun5i Hans de Goede
  4 siblings, 2 replies; 14+ messages in thread
From: Hans de Goede @ 2014-06-13 20:55 UTC (permalink / raw)
  To: u-boot

From: Henrik Nordstrom <henrik@henriknordstrom.net>

Add support for the x-powers axp209 pmic which is found on most A10, A13 and
A20 boards.

And enable AXP209 support for the Cubietruck and Cubieboard boards.

While changing the boards.cfg lines for the Cubietruck, add Ian and me as board
maintainers for the Cubietruck.

Signed-off-by: Henrik Nordstrom <henrik@henriknordstrom.net>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
---
 board/sunxi/board.c            |  22 ++++++
 boards.cfg                     |   6 +-
 drivers/power/Makefile         |   1 +
 drivers/power/axp209.c         | 167 +++++++++++++++++++++++++++++++++++++++++
 include/axp209.h               |  14 ++++
 include/configs/sun4i.h        |   1 +
 include/configs/sun5i.h        |   1 +
 include/configs/sun7i.h        |   1 +
 include/configs/sunxi-common.h |   5 ++
 9 files changed, 215 insertions(+), 3 deletions(-)
 create mode 100644 drivers/power/axp209.c
 create mode 100644 include/axp209.h

diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 543b809..8375711 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -12,6 +12,9 @@
  */
 
 #include <common.h>
+#ifdef CONFIG_AXP209_POWER
+#include <axp209.h>
+#endif
 #include <asm/arch/clock.h>
 #include <asm/arch/dram.h>
 #include <asm/arch/gpio.h>
@@ -116,12 +119,31 @@ void i2c_init_board(void)
 #ifdef CONFIG_SPL_BUILD
 void sunxi_board_init(void)
 {
+	int power_failed = 0;
 	unsigned long ramsize;
 
+#ifdef CONFIG_AXP209_POWER
+	power_failed |= axp209_init();
+	power_failed |= axp209_set_dcdc2(1400);
+	power_failed |= axp209_set_dcdc3(1250);
+	power_failed |= axp209_set_ldo2(3000);
+	power_failed |= axp209_set_ldo3(2800);
+	power_failed |= axp209_set_ldo4(2800);
+#endif
+
 	printf("DRAM:");
 	ramsize = sunxi_dram_init();
 	printf(" %lu MiB\n", ramsize >> 20);
 	if (!ramsize)
 		hang();
+
+	/*
+	 * Only clock up the CPU to full speed if we are reasonably
+	 * assured it's being powered with suitable core voltage
+	 */
+	if (!power_failed)
+		clock_set_pll1(CONFIG_CLK_FULL_SPEED);
+	else
+		printf("Failed to set core voltage! Can't set CPU frequency\n");
 }
 #endif
diff --git a/boards.cfg b/boards.cfg
index 983189e..ec17557 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -375,9 +375,9 @@ Active  arm         armv7          s5pc1xx     samsung         goni
 Active  arm         armv7          s5pc1xx     samsung         smdkc100            smdkc100                              -                                                                                                                                 Minkyu Kang <mk7.kang@samsung.com>
 Active  arm         armv7          socfpga     altera          socfpga             socfpga_cyclone5                      -                                                                                                                                 -
 Active  arm         armv7          sunxi       -               sunxi               A13-OLinuXinoM                        sun5i:A13_OLINUXINOM,SPL,CONS_INDEX=2                                                                                             Hans de Goede <hdegoede@redhat.com>
-Active  arm         armv7          sunxi       -               sunxi               Cubieboard                            sun4i:CUBIEBOARD,SPL,SUNXI_EMAC                                                                                                   Hans de Goede <hdegoede@redhat.com>
-Active  arm         armv7          sunxi       -               sunxi               Cubietruck                            sun7i:CUBIETRUCK,SPL,SUNXI_GMAC,RGMII                                                                                             Ian Campbell <ijc@hellion.org.uk>:Hans de Goede <hdegoede@redhat.com>
-Active  arm         armv7          sunxi       -               sunxi               Cubietruck_FEL                        sun7i:CUBIETRUCK,SPL_FEL,SUNXI_GMAC,RGMII                                                                                         Ian Campbell <ijc@hellion.org.uk>:Hans de Goede <hdegoede@redhat.com>
+Active  arm         armv7          sunxi       -               sunxi               Cubieboard                            sun4i:CUBIEBOARD,SPL,AXP209_POWER,SUNXI_EMAC                                                                                      Hans de Goede <hdegoede@redhat.com>
+Active  arm         armv7          sunxi       -               sunxi               Cubietruck                            sun7i:CUBIETRUCK,SPL,AXP209_POWER,SUNXI_GMAC,RGMII                                                                                Ian Campbell <ijc@hellion.org.uk>:Hans de Goede <hdegoede@redhat.com>
+Active  arm         armv7          sunxi       -               sunxi               Cubietruck_FEL                        sun7i:CUBIETRUCK,SPL_FEL,AXP209_POWER,SUNXI_GMAC,RGMII                                                                            Ian Campbell <ijc@hellion.org.uk>:Hans de Goede <hdegoede@redhat.com>
 Active  arm         armv7          sunxi       -               sunxi               r7-tv-dongle                          sun5i:R7DONGLE,SPL                                                                                                                Hans de Goede <hdegoede@redhat.com>
 Active  arm         armv7          u8500       st-ericsson     snowball            snowball                              -                                                                                                                                 Mathieu Poirier <mathieu.poirier@linaro.org>
 Active  arm         armv7          u8500       st-ericsson     u8500               u8500_href                            -                                                                                                                                 -
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index 53ff97d..063ac8f 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -5,6 +5,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
+obj-$(CONFIG_AXP209_POWER)	+= axp209.o
 obj-$(CONFIG_EXYNOS_TMU)	+= exynos-tmu.o
 obj-$(CONFIG_FTPMU010_POWER)	+= ftpmu010.o
 obj-$(CONFIG_TPS6586X_POWER)	+= tps6586x.o
diff --git a/drivers/power/axp209.c b/drivers/power/axp209.c
new file mode 100644
index 0000000..9798e5b
--- /dev/null
+++ b/drivers/power/axp209.c
@@ -0,0 +1,167 @@
+/*
+ * (C) Copyright 2012
+ * Henrik Nordstrom <henrik@henriknordstrom.net>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <i2c.h>
+#include <axp209.h>
+
+enum axp209_reg {
+	AXP209_POWER_STATUS = 0x00,
+	AXP209_CHIP_VERSION = 0x03,
+	AXP209_DCDC2_VOLTAGE = 0x23,
+	AXP209_DCDC3_VOLTAGE = 0x27,
+	AXP209_LDO24_VOLTAGE = 0x28,
+	AXP209_LDO3_VOLTAGE = 0x29,
+	AXP209_IRQ_STATUS5 = 0x4c,
+	AXP209_SHUTDOWN = 0x32,
+};
+
+#define AXP209_POWER_STATUS_ON_BY_DC	(1 << 0)
+
+#define AXP209_IRQ5_PEK_UP		(1 << 6)
+#define AXP209_IRQ5_PEK_DOWN		(1 << 5)
+
+#define AXP209_POWEROFF			(1 << 7)
+
+static int axp209_write(enum axp209_reg reg, u8 val)
+{
+	return i2c_write(0x34, reg, 1, &val, 1);
+}
+
+static int axp209_read(enum axp209_reg reg, u8 *val)
+{
+	return i2c_read(0x34, reg, 1, val, 1);
+}
+
+static u8 axp209_mvolt_to_cfg(int mvolt, int min, int max, int div)
+{
+	if (mvolt < min)
+		mvolt = min;
+	else if (mvolt > max)
+		mvolt = max;
+
+	return (mvolt - min) / div;
+}
+
+int axp209_set_dcdc2(int mvolt)
+{
+	int rc;
+	u8 cfg, current;
+
+	cfg = axp209_mvolt_to_cfg(mvolt, 700, 2275, 25);
+
+	/* Do we really need to be this gentle? It has built-in voltage slope */
+	while ((rc = axp209_read(AXP209_DCDC2_VOLTAGE, &current)) == 0 &&
+	       current != cfg) {
+		if (current < cfg)
+			current++;
+		else
+			current--;
+
+		rc = axp209_write(AXP209_DCDC2_VOLTAGE, current);
+		if (rc)
+			break;
+	}
+
+	return rc;
+}
+
+int axp209_set_dcdc3(int mvolt)
+{
+	u8 cfg = axp209_mvolt_to_cfg(mvolt, 700, 3500, 25);
+
+	return axp209_write(AXP209_DCDC3_VOLTAGE, cfg);
+}
+
+int axp209_set_ldo2(int mvolt)
+{
+	int rc;
+	u8 cfg, reg;
+
+	cfg = axp209_mvolt_to_cfg(mvolt, 1800, 3300, 100);
+
+	rc = axp209_read(AXP209_LDO24_VOLTAGE, &reg);
+	if (rc)
+		return rc;
+
+	/* LDO2 configuration is in upper 4 bits */
+	reg = (reg & 0x0f) | (cfg << 4);
+	return axp209_write(AXP209_LDO24_VOLTAGE, reg);
+}
+
+int axp209_set_ldo3(int mvolt)
+{
+	u8 cfg;
+
+	if (mvolt == -1)
+		cfg = 0x80;	/* determined by LDO3IN pin */
+	else
+		cfg = axp209_mvolt_to_cfg(mvolt, 700, 2275, 25);
+
+	return axp209_write(AXP209_LDO3_VOLTAGE, cfg);
+}
+
+int axp209_set_ldo4(int mvolt)
+{
+	int rc;
+	static const int vindex[] = {
+		1250, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2500,
+		2700, 2800, 3000, 3100, 3200, 3300
+	};
+	u8 cfg, reg;
+
+	/* Translate mvolt to register cfg value, requested <= selected */
+	for (cfg = 15; vindex[cfg] > mvolt && cfg > 0; cfg--);
+
+	rc = axp209_read(AXP209_LDO24_VOLTAGE, &reg);
+	if (rc)
+		return rc;
+
+	/* LDO4 configuration is in lower 4 bits */
+	reg = (reg & 0xf0) | (cfg << 0);
+	return axp209_write(AXP209_LDO24_VOLTAGE, reg);
+}
+
+int axp209_init(void)
+{
+	u8 ver;
+	int rc;
+
+	rc = axp209_read(AXP209_CHIP_VERSION, &ver);
+	if (rc)
+		return rc;
+
+	/* Low 4 bits is chip version */
+	ver &= 0x0f;
+
+	if (ver != 0x1)
+		return -1;
+
+	return 0;
+}
+
+int axp209_poweron_by_dc(void)
+{
+	u8 v;
+
+	if (axp209_read(AXP209_POWER_STATUS, &v))
+		return 0;
+
+	return (v & AXP209_POWER_STATUS_ON_BY_DC);
+}
+
+int axp209_power_button(void)
+{
+	u8 v;
+
+	if (axp209_read(AXP209_IRQ_STATUS5, &v))
+		return 0;
+
+	axp209_write(AXP209_IRQ_STATUS5, AXP209_IRQ5_PEK_DOWN);
+
+	return v & AXP209_IRQ5_PEK_DOWN;
+}
diff --git a/include/axp209.h b/include/axp209.h
new file mode 100644
index 0000000..21efce6
--- /dev/null
+++ b/include/axp209.h
@@ -0,0 +1,14 @@
+/*
+ * (C) Copyright 2012 Henrik Nordstrom <henrik@henriknordstrom.net>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+extern int axp209_set_dcdc2(int mvolt);
+extern int axp209_set_dcdc3(int mvolt);
+extern int axp209_set_ldo2(int mvolt);
+extern int axp209_set_ldo3(int mvolt);
+extern int axp209_set_ldo4(int mvolt);
+extern int axp209_init(void);
+extern int axp209_poweron_by_dc(void);
+extern int axp209_power_button(void);
diff --git a/include/configs/sun4i.h b/include/configs/sun4i.h
index 6560b65..037f995 100644
--- a/include/configs/sun4i.h
+++ b/include/configs/sun4i.h
@@ -12,6 +12,7 @@
  * A10 specific configuration
  */
 #define CONFIG_SUN4I		/* sun4i SoC generation */
+#define CONFIG_CLK_FULL_SPEED		1008000000
 
 #define CONFIG_SYS_PROMPT		"sun4i# "
 
diff --git a/include/configs/sun5i.h b/include/configs/sun5i.h
index 43f0d67..c6138b7 100644
--- a/include/configs/sun5i.h
+++ b/include/configs/sun5i.h
@@ -12,6 +12,7 @@
  * High Level Configuration Options
  */
 #define CONFIG_SUN5I		/* sun5i SoC generation */
+#define CONFIG_CLK_FULL_SPEED		1008000000
 
 #define CONFIG_SYS_PROMPT		"sun5i# "
 
diff --git a/include/configs/sun7i.h b/include/configs/sun7i.h
index 9b693f7..d9be104 100644
--- a/include/configs/sun7i.h
+++ b/include/configs/sun7i.h
@@ -13,6 +13,7 @@
  * A20 specific configuration
  */
 #define CONFIG_SUN7I		/* sun7i SoC generation */
+#define CONFIG_CLK_FULL_SPEED		912000000
 
 #define CONFIG_SYS_PROMPT		"sun7i# "
 
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 42b0d2e..4083388 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -169,6 +169,11 @@
 #define CONFIG_SYS_I2C_SLAVE		0x7f
 #define CONFIG_CMD_I2C
 
+/* PMU */
+#if defined CONFIG_AXP152_POWER || defined CONFIG_AXP209_POWER || defined CONFIG_AXP221_POWER
+#define CONFIG_SPL_POWER_SUPPORT
+#endif
+
 #ifndef CONFIG_CONS_INDEX
 #define CONFIG_CONS_INDEX              1       /* UART0 */
 #endif
-- 
2.0.0

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

* [U-Boot] [PATCH v2 4/5] sunxi: Add axp152 pmic support
  2014-06-13 20:55 [U-Boot] [PATCH v2 0/5] sunxi: i2c and pmic support Hans de Goede
                   ` (2 preceding siblings ...)
  2014-06-13 20:55 ` [U-Boot] [PATCH v2 3/5] sunxi: Add axp209 pmic support Hans de Goede
@ 2014-06-13 20:55 ` Hans de Goede
  2014-06-13 20:55 ` [U-Boot] [PATCH v2 5/5] sunxi: Fix reset hang on sun5i Hans de Goede
  4 siblings, 0 replies; 14+ messages in thread
From: Hans de Goede @ 2014-06-13 20:55 UTC (permalink / raw)
  To: u-boot

Add support for the x-powers axp152 pmic which is found on most A10s boards
and enable it for the r7-tv-dongle board.

Signed-off-by: Henrik Nordstrom <henrik@henriknordstrom.net>
Signed-off-by: Ian Campbell <ijc@hellion.org.uk>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
---
 board/sunxi/board.c    | 10 ++++++
 boards.cfg             |  2 +-
 drivers/power/Makefile |  1 +
 drivers/power/axp152.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++
 include/axp152.h       | 10 ++++++
 5 files changed, 119 insertions(+), 1 deletion(-)
 create mode 100644 drivers/power/axp152.c
 create mode 100644 include/axp152.h

diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 8375711..8607eb3 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -12,6 +12,9 @@
  */
 
 #include <common.h>
+#ifdef CONFIG_AXP152_POWER
+#include <axp152.h>
+#endif
 #ifdef CONFIG_AXP209_POWER
 #include <axp209.h>
 #endif
@@ -122,6 +125,13 @@ void sunxi_board_init(void)
 	int power_failed = 0;
 	unsigned long ramsize;
 
+#ifdef CONFIG_AXP152_POWER
+	power_failed = axp152_init();
+	power_failed |= axp152_set_dcdc2(1400);
+	power_failed |= axp152_set_dcdc3(1500);
+	power_failed |= axp152_set_dcdc4(1250);
+	power_failed |= axp152_set_ldo2(3000);
+#endif
 #ifdef CONFIG_AXP209_POWER
 	power_failed |= axp209_init();
 	power_failed |= axp209_set_dcdc2(1400);
diff --git a/boards.cfg b/boards.cfg
index ec17557..aaea8f4 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -378,7 +378,7 @@ Active  arm         armv7          sunxi       -               sunxi
 Active  arm         armv7          sunxi       -               sunxi               Cubieboard                            sun4i:CUBIEBOARD,SPL,AXP209_POWER,SUNXI_EMAC                                                                                      Hans de Goede <hdegoede@redhat.com>
 Active  arm         armv7          sunxi       -               sunxi               Cubietruck                            sun7i:CUBIETRUCK,SPL,AXP209_POWER,SUNXI_GMAC,RGMII                                                                                Ian Campbell <ijc@hellion.org.uk>:Hans de Goede <hdegoede@redhat.com>
 Active  arm         armv7          sunxi       -               sunxi               Cubietruck_FEL                        sun7i:CUBIETRUCK,SPL_FEL,AXP209_POWER,SUNXI_GMAC,RGMII                                                                            Ian Campbell <ijc@hellion.org.uk>:Hans de Goede <hdegoede@redhat.com>
-Active  arm         armv7          sunxi       -               sunxi               r7-tv-dongle                          sun5i:R7DONGLE,SPL                                                                                                                Hans de Goede <hdegoede@redhat.com>
+Active  arm         armv7          sunxi       -               sunxi               r7-tv-dongle                          sun5i:R7DONGLE,SPL,AXP152_POWER                                                                                                   Hans de Goede <hdegoede@redhat.com>
 Active  arm         armv7          u8500       st-ericsson     snowball            snowball                              -                                                                                                                                 Mathieu Poirier <mathieu.poirier@linaro.org>
 Active  arm         armv7          u8500       st-ericsson     u8500               u8500_href                            -                                                                                                                                 -
 Active  arm         armv7          vf610       freescale       vf610twr            vf610twr                              vf610twr:IMX_CONFIG=board/freescale/vf610twr/imximage.cfg                                                                         Alison Wang <b18965@freescale.com>
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index 063ac8f..dc64e4d 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -5,6 +5,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
+obj-$(CONFIG_AXP152_POWER)	+= axp152.o
 obj-$(CONFIG_AXP209_POWER)	+= axp209.o
 obj-$(CONFIG_EXYNOS_TMU)	+= exynos-tmu.o
 obj-$(CONFIG_FTPMU010_POWER)	+= ftpmu010.o
diff --git a/drivers/power/axp152.c b/drivers/power/axp152.c
new file mode 100644
index 0000000..fa4ea05
--- /dev/null
+++ b/drivers/power/axp152.c
@@ -0,0 +1,97 @@
+/*
+ * (C) Copyright 2012
+ * Henrik Nordstrom <henrik@henriknordstrom.net>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#include <common.h>
+#include <i2c.h>
+#include <axp152.h>
+
+enum axp152_reg {
+	AXP152_CHIP_VERSION = 0x3,
+	AXP152_DCDC2_VOLTAGE = 0x23,
+	AXP152_DCDC3_VOLTAGE = 0x27,
+	AXP152_DCDC4_VOLTAGE = 0x2B,
+	AXP152_LDO2_VOLTAGE = 0x2A,
+	AXP152_SHUTDOWN = 0x32,
+};
+
+#define AXP152_POWEROFF			(1 << 7)
+
+static int axp152_write(enum axp152_reg reg, u8 val)
+{
+	return i2c_write(0x30, reg, 1, &val, 1);
+}
+
+static int axp152_read(enum axp152_reg reg, u8 *val)
+{
+	return i2c_read(0x30, reg, 1, val, 1);
+}
+
+static u8 axp152_mvolt_to_target(int mvolt, int min, int max, int div)
+{
+	if (mvolt < min)
+		mvolt = min;
+	else if (mvolt > max)
+		mvolt = max;
+
+	return (mvolt - min) / div;
+}
+
+int axp152_set_dcdc2(int mvolt)
+{
+	int rc;
+	u8 current, target;
+
+	target = axp152_mvolt_to_target(mvolt, 700, 2275, 25);
+
+	/* Do we really need to be this gentle? It has built-in voltage slope */
+	while ((rc = axp152_read(AXP152_DCDC2_VOLTAGE, &current)) == 0 &&
+	       current != target) {
+		if (current < target)
+			current++;
+		else
+			current--;
+		rc = axp152_write(AXP152_DCDC2_VOLTAGE, current);
+		if (rc)
+			break;
+	}
+	return rc;
+}
+
+int axp152_set_dcdc3(int mvolt)
+{
+	u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 25);
+
+	return axp152_write(AXP152_DCDC3_VOLTAGE, target);
+}
+
+int axp152_set_dcdc4(int mvolt)
+{
+	u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 25);
+
+	return axp152_write(AXP152_DCDC4_VOLTAGE, target);
+}
+
+int axp152_set_ldo2(int mvolt)
+{
+	u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 100);
+
+	return axp152_write(AXP152_LDO2_VOLTAGE, target);
+}
+
+int axp152_init(void)
+{
+	u8 ver;
+	int rc;
+
+	rc = axp152_read(AXP152_CHIP_VERSION, &ver);
+	if (rc)
+		return rc;
+
+	if (ver != 0x05)
+		return -1;
+
+	return 0;
+}
diff --git a/include/axp152.h b/include/axp152.h
new file mode 100644
index 0000000..3e5ccbd
--- /dev/null
+++ b/include/axp152.h
@@ -0,0 +1,10 @@
+/*
+ * (C) Copyright 2012 Henrik Nordstrom <henrik@henriknordstrom.net>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+int axp152_set_dcdc2(int mvolt);
+int axp152_set_dcdc3(int mvolt);
+int axp152_set_dcdc4(int mvolt);
+int axp152_set_ldo2(int mvolt);
+int axp152_init(void);
-- 
2.0.0

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

* [U-Boot] [PATCH v2 5/5] sunxi: Fix reset hang on sun5i
  2014-06-13 20:55 [U-Boot] [PATCH v2 0/5] sunxi: i2c and pmic support Hans de Goede
                   ` (3 preceding siblings ...)
  2014-06-13 20:55 ` [U-Boot] [PATCH v2 4/5] sunxi: Add axp152 " Hans de Goede
@ 2014-06-13 20:55 ` Hans de Goede
  2014-07-23 18:59   ` Siarhei Siamashka
  4 siblings, 1 reply; 14+ messages in thread
From: Hans de Goede @ 2014-06-13 20:55 UTC (permalink / raw)
  To: u-boot

Do the same as the Linux kernel does, this fixes the SoC hanging on reset
about 50% of the time.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
---
 arch/arm/cpu/armv7/sunxi/board.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c
index 024c8c1..2898833 100644
--- a/arch/arm/cpu/armv7/sunxi/board.c
+++ b/arch/arm/cpu/armv7/sunxi/board.c
@@ -75,7 +75,11 @@ void reset_cpu(ulong addr)
 	/* Set the watchdog for its shortest interval (.5s) and wait */
 	writel(WDT_MODE_RESET_EN | WDT_MODE_EN, &wdog->mode);
 	writel(WDT_CTRL_KEY | WDT_CTRL_RESTART, &wdog->ctl);
-	while (1);
+
+	while (1) {
+		/* sun5i sometimes gets stuck without this */
+		writel(WDT_MODE_RESET_EN | WDT_MODE_EN, &wdog->mode);
+	}
 }
 
 /* do some early init */
-- 
2.0.0

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

* [U-Boot] [PATCH v2 1/5] mvtwsi: convert to CONFIG_SYS_I2C framework
  2014-06-13 20:55 ` [U-Boot] [PATCH v2 1/5] mvtwsi: convert to CONFIG_SYS_I2C framework Hans de Goede
@ 2014-07-06 13:28   ` Ian Campbell
  0 siblings, 0 replies; 14+ messages in thread
From: Ian Campbell @ 2014-07-06 13:28 UTC (permalink / raw)
  To: u-boot

Hi Heiko,

On Fri, 2014-06-13 at 22:55 +0200, Hans de Goede wrote:
> Note this has only been tested on Allwinner sunxi devices (support for which
> gets introduced by a later patch).
> 
> The kirkwood changes have been compile tested using the wireless_space board
> config, the orion5x changes have been compile tested using the edminiv2 board
> config.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> Acked-by: Heiko Schocher <hs@denx.de>

Do you plan to take this via u-boot-i2c.git or would you like us to take
it via the sunxi tree along with the rest of the series?

Cheers,
Ian.

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

* [U-Boot] [PATCH v2 3/5] sunxi: Add axp209 pmic support
  2014-06-13 20:55 ` [U-Boot] [PATCH v2 3/5] sunxi: Add axp209 pmic support Hans de Goede
@ 2014-07-16 21:48   ` Ian Campbell
  2014-07-17 10:37     ` Hans de Goede
  2014-07-23 18:49   ` Siarhei Siamashka
  1 sibling, 1 reply; 14+ messages in thread
From: Ian Campbell @ 2014-07-16 21:48 UTC (permalink / raw)
  To: u-boot

On Fri, 2014-06-13 at 22:55 +0200, Hans de Goede wrote:
> From: Henrik Nordstrom <henrik@henriknordstrom.net>
> 
> Add support for the x-powers axp209 pmic which is found on most A10, A13 and
> A20 boards.
> 
> And enable AXP209 support for the Cubietruck and Cubieboard boards.

Something about this breaks booting on my Cubietruck in FEL mode. I get:

        U-Boot SPL 2014.07-rc4-00122-g624959a (Jul 16 2014 - 22:34:59)
        Error, wrong i2c adapter 0 max 0 possible
        Error, wrong i2c adapter 0 max 0 possible
        
And then nothing.

Non-FEL mode is unaffected.

I've pushed my wip branch to:

        git://gitorious.org/ijc/u-boot.git wip/sunxi-20140716

I was hoping to merge something like this set of patches upstream
shortly.

> While changing the boards.cfg lines for the Cubietruck, add Ian and me as board
> maintainers for the Cubietruck.

You actually factored that bit out in v2...

Ian.

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

* [U-Boot] [PATCH v2 3/5] sunxi: Add axp209 pmic support
  2014-07-16 21:48   ` Ian Campbell
@ 2014-07-17 10:37     ` Hans de Goede
  2014-07-17 19:14       ` Ian Campbell
  0 siblings, 1 reply; 14+ messages in thread
From: Hans de Goede @ 2014-07-17 10:37 UTC (permalink / raw)
  To: u-boot

Hi,

On 07/16/2014 11:48 PM, Ian Campbell wrote:
> On Fri, 2014-06-13 at 22:55 +0200, Hans de Goede wrote:
>> From: Henrik Nordstrom <henrik@henriknordstrom.net>
>>
>> Add support for the x-powers axp209 pmic which is found on most A10, A13 and
>> A20 boards.
>>
>> And enable AXP209 support for the Cubietruck and Cubieboard boards.
> 
> Something about this breaks booting on my Cubietruck in FEL mode. I get:
> 
>         U-Boot SPL 2014.07-rc4-00122-g624959a (Jul 16 2014 - 22:34:59)
>         Error, wrong i2c adapter 0 max 0 possible
>         Error, wrong i2c adapter 0 max 0 possible
>         
> And then nothing.

If you look at the patch adding support for the i2c controller I needed
to make some changes to the link script, I probably forgot to make the
same changes to the fel link script...

> Non-FEL mode is unaffected.
> 
> I've pushed my wip branch to:
> 
>         git://gitorious.org/ijc/u-boot.git wip/sunxi-20140716
> 
> I was hoping to merge something like this set of patches upstream
> shortly.
> 
>> While changing the boards.cfg lines for the Cubietruck, add Ian and me as board
>> maintainers for the Cubietruck.
> 
> You actually factored that bit out in v2...

True, feel free to amend the commit msg, or let me know if you want a v3.

And thanks for looking into merging this into sunxi -next. I was planning to
drop you a mail about coordinating getting this added vs getting your ahci
patches added. I assume you ahci patches are good to go too, or ... ?

Next I want to start adding support for more boards. For starters I would
like to add all boards which also have a dts file in the upstream kernel.
Ideally I would start working on that once you're done with adding this
series + your ahci patches so that we don't get in each others way. Can you
send me a mail when you're done (for a while at least) then I'll try to
get a set of patches for this to the list based on top of your latest work.

Except for sun4i-a10-hackberry.dts and sun4i-a10-inet97fv2.dts I've hardware
to test on for all sun4i, sun5i and sun7i models which have a dts file, not
sure what to do with the 2 I cannot test.

Regards,

Hans

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

* [U-Boot] [PATCH v2 3/5] sunxi: Add axp209 pmic support
  2014-07-17 10:37     ` Hans de Goede
@ 2014-07-17 19:14       ` Ian Campbell
  2014-07-18 10:04         ` Hans de Goede
  0 siblings, 1 reply; 14+ messages in thread
From: Ian Campbell @ 2014-07-17 19:14 UTC (permalink / raw)
  To: u-boot

On Thu, 2014-07-17 at 12:37 +0200, Hans de Goede wrote:
> Hi,
> 
> On 07/16/2014 11:48 PM, Ian Campbell wrote:
> > On Fri, 2014-06-13 at 22:55 +0200, Hans de Goede wrote:
> >> From: Henrik Nordstrom <henrik@henriknordstrom.net>
> >>
> >> Add support for the x-powers axp209 pmic which is found on most A10, A13 and
> >> A20 boards.
> >>
> >> And enable AXP209 support for the Cubietruck and Cubieboard boards.
> > 
> > Something about this breaks booting on my Cubietruck in FEL mode. I get:
> > 
> >         U-Boot SPL 2014.07-rc4-00122-g624959a (Jul 16 2014 - 22:34:59)
> >         Error, wrong i2c adapter 0 max 0 possible
> >         Error, wrong i2c adapter 0 max 0 possible
> >         
> > And then nothing.
> 
> If you look at the patch adding support for the i2c controller I needed
> to make some changes to the link script, I probably forgot to make the
> same changes to the fel link script...

That was indeed it. With your ACK I'd like to fold in this change:

- - a/arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds
+ + b/arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds
@@ -27,6 +27,11 @@ SECTIONS
 	}
 
 	. = ALIGN(4);
+	.u_boot_list : {
+		KEEP(*(SORT(.u_boot_list*)));
+	}
+
+	. = ALIGN(4);
 	. = .;
 
 	. = ALIGN(4);

> >> While changing the boards.cfg lines for the Cubietruck, add Ian and me as board
> >> maintainers for the Cubietruck.
> > 
> > You actually factored that bit out in v2...
> 
> True, feel free to amend the commit msg, or let me know if you want a v3.

I'll amend while I'm there.

> And thanks for looking into merging this into sunxi -next. I was planning to
> drop you a mail about coordinating getting this added vs getting your ahci
> patches added. I assume you ahci patches are good to go too, or ... ?

I've picked up the non-AHCI bits of that series now but not the common
bits which I'm assuming Albert will pick up when he gets back, the
actual driver then depends on those. So I've picked up and intend to
include in the first PR:
[U-Boot,3/6] sunxi: add Cubieboard2 support
[U-Boot,4/6] sunxi: add gpio driver
[U-Boot,5/6] sunxi: use setbits_le32 to enable the DMA clock

These I am expecting to come via Albert (or for him to ask me to merge):
[U-Boot,1/6] AHCI: Increase link timeout to 200ms
[U-Boot,2/6] board_r: run scsi init() on ARM too

and then the last one
[U-Boot,6/6] ahci: provide sunxi SATA driver using AHCI platform framework
either Albert can pick up or it can come in a subsequent PR.

Other than those there are Roman's USB patch which are still under review.

> Next I want to start adding support for more boards. For starters I would
> like to add all boards which also have a dts file in the upstream kernel.
> Ideally I would start working on that once you're done with adding this
> series + your ahci patches so that we don't get in each others way. Can you
> send me a mail when you're done (for a while at least) then I'll try to
> get a set of patches for this to the list based on top of your latest work.

Sure, I'll drop you a line.

> Except for sun4i-a10-hackberry.dts and sun4i-a10-inet97fv2.dts I've hardware
> to test on for all sun4i, sun5i and sun7i models which have a dts file, not
> sure what to do with the 2 I cannot test.

Either leave them out or approach the person who wrote the dts (who
presumably has one, or isthat asking too much) to test?

Ian

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

* [U-Boot] [PATCH v2 3/5] sunxi: Add axp209 pmic support
  2014-07-17 19:14       ` Ian Campbell
@ 2014-07-18 10:04         ` Hans de Goede
  2014-07-18 13:51           ` Ian Campbell
  0 siblings, 1 reply; 14+ messages in thread
From: Hans de Goede @ 2014-07-18 10:04 UTC (permalink / raw)
  To: u-boot

Hi,

On 07/17/2014 09:14 PM, Ian Campbell wrote:
> On Thu, 2014-07-17 at 12:37 +0200, Hans de Goede wrote:
>> Hi,
>>
>> On 07/16/2014 11:48 PM, Ian Campbell wrote:
>>> On Fri, 2014-06-13 at 22:55 +0200, Hans de Goede wrote:
>>>> From: Henrik Nordstrom <henrik@henriknordstrom.net>
>>>>
>>>> Add support for the x-powers axp209 pmic which is found on most A10, A13 and
>>>> A20 boards.
>>>>
>>>> And enable AXP209 support for the Cubietruck and Cubieboard boards.
>>>
>>> Something about this breaks booting on my Cubietruck in FEL mode. I get:
>>>
>>>         U-Boot SPL 2014.07-rc4-00122-g624959a (Jul 16 2014 - 22:34:59)
>>>         Error, wrong i2c adapter 0 max 0 possible
>>>         Error, wrong i2c adapter 0 max 0 possible
>>>         
>>> And then nothing.
>>
>> If you look at the patch adding support for the i2c controller I needed
>> to make some changes to the link script, I probably forgot to make the
>> same changes to the fel link script...
> 
> That was indeed it. With your ACK I'd like to fold in this change:
> 
> - - a/arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds
> + + b/arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds
> @@ -27,6 +27,11 @@ SECTIONS
>  	}
>  
>  	. = ALIGN(4);
> +	.u_boot_list : {
> +		KEEP(*(SORT(.u_boot_list*)));
> +	}
> +
> +	. = ALIGN(4);
>  	. = .;
>  
>  	. = ALIGN(4);
> 

Looks good, ACK.

>>>> While changing the boards.cfg lines for the Cubietruck, add Ian and me as board
>>>> maintainers for the Cubietruck.
>>>
>>> You actually factored that bit out in v2...
>>
>> True, feel free to amend the commit msg, or let me know if you want a v3.
> 
> I'll amend while I'm there.
> 
>> And thanks for looking into merging this into sunxi -next. I was planning to
>> drop you a mail about coordinating getting this added vs getting your ahci
>> patches added. I assume you ahci patches are good to go too, or ... ?
> 
> I've picked up the non-AHCI bits of that series now but not the common
> bits which I'm assuming Albert will pick up when he gets back, the
> actual driver then depends on those. So I've picked up and intend to
> include in the first PR:
> [U-Boot,3/6] sunxi: add Cubieboard2 support
> [U-Boot,4/6] sunxi: add gpio driver
> [U-Boot,5/6] sunxi: use setbits_le32 to enable the DMA clock
> 
> These I am expecting to come via Albert (or for him to ask me to merge):
> [U-Boot,1/6] AHCI: Increase link timeout to 200ms
> [U-Boot,2/6] board_r: run scsi init() on ARM too
> 
> and then the last one
> [U-Boot,6/6] ahci: provide sunxi SATA driver using AHCI platform framework
> either Albert can pick up or it can come in a subsequent PR.

Ok.

> 
> Other than those there are Roman's USB patch which are still under review.
> 
>> Next I want to start adding support for more boards. For starters I would
>> like to add all boards which also have a dts file in the upstream kernel.
>> Ideally I would start working on that once you're done with adding this
>> series + your ahci patches so that we don't get in each others way. Can you
>> send me a mail when you're done (for a while at least) then I'll try to
>> get a set of patches for this to the list based on top of your latest work.
> 
> Sure, I'll drop you a line.
> 
>> Except for sun4i-a10-hackberry.dts and sun4i-a10-inet97fv2.dts I've hardware
>> to test on for all sun4i, sun5i and sun7i models which have a dts file, not
>> sure what to do with the 2 I cannot test.
> 
> Either leave them out or approach the person who wrote the dts (who
> presumably has one, or isthat asking too much) to test?

I can ask some people to test yes, but what do we then put in the MAINTAINER
column of boards.cfg ? I think it would be best to ask people to step us as
board maintainer for these, instead of just test. Do you agree ?

Regards,

Hans

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

* [U-Boot] [PATCH v2 3/5] sunxi: Add axp209 pmic support
  2014-07-18 10:04         ` Hans de Goede
@ 2014-07-18 13:51           ` Ian Campbell
  0 siblings, 0 replies; 14+ messages in thread
From: Ian Campbell @ 2014-07-18 13:51 UTC (permalink / raw)
  To: u-boot

On Fri, 2014-07-18 at 12:04 +0200, Hans de Goede wrote:

> Looks good, ACK.

Thanks, will prep the PR ASAP.

> > Either leave them out or approach the person who wrote the dts (who
> > presumably has one, or isthat asking too much) to test?
> 
> I can ask some people to test yes, but what do we then put in the MAINTAINER
> column of boards.cfg ? I think it would be best to ask people to step us as
> board maintainer for these, instead of just test. Do you agree ?

That seem reasonable to me.

Ian.

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

* [U-Boot] [PATCH v2 3/5] sunxi: Add axp209 pmic support
  2014-06-13 20:55 ` [U-Boot] [PATCH v2 3/5] sunxi: Add axp209 pmic support Hans de Goede
  2014-07-16 21:48   ` Ian Campbell
@ 2014-07-23 18:49   ` Siarhei Siamashka
  1 sibling, 0 replies; 14+ messages in thread
From: Siarhei Siamashka @ 2014-07-23 18:49 UTC (permalink / raw)
  To: u-boot

On Fri, 13 Jun 2014 22:55:50 +0200
Hans de Goede <hdegoede@redhat.com> wrote:

> From: Henrik Nordstrom <henrik@henriknordstrom.net>
> 
> Add support for the x-powers axp209 pmic which is found on most A10, A13 and
> A20 boards.
> 
> And enable AXP209 support for the Cubietruck and Cubieboard boards.
> 
> While changing the boards.cfg lines for the Cubietruck, add Ian and me as board
> maintainers for the Cubietruck.
> 
> Signed-off-by: Henrik Nordstrom <henrik@henriknordstrom.net>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> Acked-by: Ian Campbell <ijc@hellion.org.uk>
> ---
>  board/sunxi/board.c            |  22 ++++++
>  boards.cfg                     |   6 +-
>  drivers/power/Makefile         |   1 +
>  drivers/power/axp209.c         | 167 +++++++++++++++++++++++++++++++++++++++++
>  include/axp209.h               |  14 ++++
>  include/configs/sun4i.h        |   1 +
>  include/configs/sun5i.h        |   1 +
>  include/configs/sun7i.h        |   1 +
>  include/configs/sunxi-common.h |   5 ++
>  9 files changed, 215 insertions(+), 3 deletions(-)
>  create mode 100644 drivers/power/axp209.c
>  create mode 100644 include/axp209.h

The support for AXP209 is needed to provide sufficient dcdc3 voltage
at least for the DRAM controller. The default voltage after reset
(1.2V on the Cubietruck) is too low for operating the DRAM controller
at reasonably high clock speeds. In this sense, the initial Cubietruck
support in u-boot v2014.07 is already buggy, because of the missing
PMIC configuration code. And this explanation in the commit message
would be very nice to have (otherwise one may wonder, why do we even
need the PMIC code in u-boot in the first place?).

The addition of the AXP PMIC support should be perhaps moved to the
beginning of the patch series instead of fixing the voltage problems
after the fact.

And again, this patch is currently rather cherry-picking unfriendly.
So even if I wanted to reorder the patches to trivially address the
problem, the interdependencies via the dreaded 'boards.cfg' get in the
way.

-- 
Best regards,
Siarhei Siamashka

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

* [U-Boot] [PATCH v2 5/5] sunxi: Fix reset hang on sun5i
  2014-06-13 20:55 ` [U-Boot] [PATCH v2 5/5] sunxi: Fix reset hang on sun5i Hans de Goede
@ 2014-07-23 18:59   ` Siarhei Siamashka
  0 siblings, 0 replies; 14+ messages in thread
From: Siarhei Siamashka @ 2014-07-23 18:59 UTC (permalink / raw)
  To: u-boot

On Fri, 13 Jun 2014 22:55:52 +0200
Hans de Goede <hdegoede@redhat.com> wrote:

> Do the same as the Linux kernel does, this fixes the SoC hanging on reset
> about 50% of the time.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> Acked-by: Ian Campbell <ijc@hellion.org.uk>
> ---
>  arch/arm/cpu/armv7/sunxi/board.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c
> index 024c8c1..2898833 100644
> --- a/arch/arm/cpu/armv7/sunxi/board.c
> +++ b/arch/arm/cpu/armv7/sunxi/board.c
> @@ -75,7 +75,11 @@ void reset_cpu(ulong addr)
>  	/* Set the watchdog for its shortest interval (.5s) and wait */
>  	writel(WDT_MODE_RESET_EN | WDT_MODE_EN, &wdog->mode);
>  	writel(WDT_CTRL_KEY | WDT_CTRL_RESTART, &wdog->ctl);
> -	while (1);
> +
> +	while (1) {
> +		/* sun5i sometimes gets stuck without this */
> +		writel(WDT_MODE_RESET_EN | WDT_MODE_EN, &wdog->mode);
> +	}
>  }
>  
>  /* do some early init */

This should be perhaps combined with
   http://patchwork.ozlabs.org/patch/357363/ (probably the best place)
or
   http://patchwork.ozlabs.org/patch/357365/ (ugh, too much code there)

in order to have bug free code after every commit instead of fixing
the problem after the fact.

-- 
Best regards,
Siarhei Siamashka

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

end of thread, other threads:[~2014-07-23 18:59 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-13 20:55 [U-Boot] [PATCH v2 0/5] sunxi: i2c and pmic support Hans de Goede
2014-06-13 20:55 ` [U-Boot] [PATCH v2 1/5] mvtwsi: convert to CONFIG_SYS_I2C framework Hans de Goede
2014-07-06 13:28   ` Ian Campbell
2014-06-13 20:55 ` [U-Boot] [PATCH v2 2/5] sunxi: Add i2c support Hans de Goede
2014-06-13 20:55 ` [U-Boot] [PATCH v2 3/5] sunxi: Add axp209 pmic support Hans de Goede
2014-07-16 21:48   ` Ian Campbell
2014-07-17 10:37     ` Hans de Goede
2014-07-17 19:14       ` Ian Campbell
2014-07-18 10:04         ` Hans de Goede
2014-07-18 13:51           ` Ian Campbell
2014-07-23 18:49   ` Siarhei Siamashka
2014-06-13 20:55 ` [U-Boot] [PATCH v2 4/5] sunxi: Add axp152 " Hans de Goede
2014-06-13 20:55 ` [U-Boot] [PATCH v2 5/5] sunxi: Fix reset hang on sun5i Hans de Goede
2014-07-23 18:59   ` Siarhei Siamashka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.