diff mbox

[U-Boot] ARM: tegra: use a CPU freq that all SKUs can support

Message ID 1398367830-6814-1-git-send-email-swarren@wwwdotorg.org
State Superseded
Delegated to: Tom Warren
Headers show

Commit Message

Stephen Warren April 24, 2014, 7:30 p.m. UTC
From: Stephen Warren <swarren@nvidia.com>

U-Boot on Tegra30 currently selects a main CPU frequency that cannot be
supported at all on some SKUs, and needs higher VDD_CPU/VDD_CORE values
on some others. This can result in unreliable operation of the main CPUs.

Resolve this by switching to a CPU frequency that can be supported by any
SKU. According to the following link, the maximum supported CPU frequency
of the slowest Tegra30 SKU is 600MHz:

repo http://nv-tegra.nvidia.com/gitweb/?p=linux-2.6.git;a=summary
branch l4t/l4t-r16-r2
path arch/arm/mach-tegra/tegra3_dvfs.c
table cpu_dvfs_table[]

According to that same table, the minimum VDD_CPU required to operate at
that frequency across all SKUs is 1.007V. Given the adjustment resolution
of the TPS65911 PMIC that's used on all Tegra30-based boards we support,
we'll end up using 1.0125V instead.

At that VDD_CPU, tegra3_get_core_floor_mv() in that same file dictates
that VDD_CORE must be at least 1.2V on all SKUs. According to
tegra_core_speedo_mv() (in tegra3_speedo.c in the same source tree),
that voltage is safe for all SKUs.

An alternative would be to port much of the code from tegra3_dvfs.c and
tegra3_speedo.c in the kernel tree mentioned above. That's more work
than I want to take on right now.

While all the currently supported boards use the same regulator chip for
VDD_CPU, different types of regulators are used for VDD_CORE. Hence, we
add some small conditional code to select how VDD_CORE is programmed. If
this becomes more complex in the future as new boards are added, or we
end up adding code to detect the SoC SKU and dynamically determine the
allowed frequency and required voltages, we should probably make this a
runtime call into a function provided by the board file and/or relevant
PMIC driver.

Cc: Alban Bedel <alban.bedel@avionic-design.de>
Cc: Marcel Ziswiler <marcel@ziswiler.com>
Cc: Bard Liao <bardliao@realtek.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
Alban, I don't know which regulator is used for VDD_CORE on Tec-NG. If
could you find this out, I can adjust tec-ng.h too. Thanks.
---
 arch/arm/cpu/arm720t/tegra-common/cpu.c | 10 +++++-----
 arch/arm/cpu/arm720t/tegra30/cpu.c      | 23 +++++++++++++++++++++--
 include/configs/beaver.h                |  3 +++
 include/configs/cardhu.h                |  3 +++
 4 files changed, 32 insertions(+), 7 deletions(-)

Comments

Lucas Stach May 7, 2014, 7:57 p.m. UTC | #1
Hi Stephen,

I was just porting this change to barebox and stumbled upon a few errors
here.

Am Donnerstag, den 24.04.2014, 13:30 -0600 schrieb Stephen Warren:
> From: Stephen Warren <swarren@nvidia.com>
> 
[...]
> diff --git a/arch/arm/cpu/arm720t/tegra30/cpu.c b/arch/arm/cpu/arm720t/tegra30/cpu.c
> index 85a945bc7918..0f52e54239e1 100644
> --- a/arch/arm/cpu/arm720t/tegra30/cpu.c
> +++ b/arch/arm/cpu/arm720t/tegra30/cpu.c
> @@ -41,10 +41,18 @@ void tegra_i2c_ll_write_data(uint data, uint config)
>  	writel(config, &reg->cnfg);
>  }
>  
> +#define TPS62366A_I2C_ADDR		0x60

The I2C address for this chip on Beaver is 0xc0, not 0x60. I don't know
about Cardhu.

> +#define TPS62366A_SET1_REG		0x01
> +#define TPS62366A_SET1_DATA		(0x46 | TPS62366A_SET1_REG)

This should be (0x4600 | TPS62366A_SET1_REG).

> +
> +#define TPS62361B_I2C_ADDR		0x60
> +#define TPS62361B_SET3_REG		0x03
> +#define TPS62361B_SET3_DATA		(0x46 | TPS62361B_SET3_REG)
Same here.

Only with those fixed I can verify vdd_core to ramp up to 1,2V on
Beaver. Without the changes vdd_core stays at the default 1,16V.

Regards,
Lucas
Stephen Warren May 7, 2014, 8:13 p.m. UTC | #2
On 05/07/2014 01:57 PM, Lucas Stach wrote:
> Hi Stephen,
> 
> I was just porting this change to barebox and stumbled upon a few errors
> here.

Wow, I suck. Thanks for the heads up. I'll repost a fixed up version soon.

> Am Donnerstag, den 24.04.2014, 13:30 -0600 schrieb Stephen Warren:

>> diff --git a/arch/arm/cpu/arm720t/tegra30/cpu.c b/arch/arm/cpu/arm720t/tegra30/cpu.c

>> +#define TPS62366A_I2C_ADDR		0x60
> 
> The I2C address for this chip on Beaver is 0xc0, not 0x60. I don't know
> about Cardhu.

That's a confusion about 7-bit vs 8-bit I2C addresses.
diff mbox

Patch

diff --git a/arch/arm/cpu/arm720t/tegra-common/cpu.c b/arch/arm/cpu/arm720t/tegra-common/cpu.c
index 168f525ec7c8..c6f3b029a16e 100644
--- a/arch/arm/cpu/arm720t/tegra-common/cpu.c
+++ b/arch/arm/cpu/arm720t/tegra-common/cpu.c
@@ -82,7 +82,7 @@  struct clk_pll_table tegra_pll_x_table[TEGRA_SOC_CNT][CLOCK_OSC_FREQ_COUNT] = {
 		{ .n = 600, .m = 13, .p = 0, .cpcon = 12 }, /* OSC: 26.0 MHz */
 	},
 	/*
-	 * T30: 1.4 GHz
+	 * T30: 600 MHz
 	 *
 	 * Register   Field  Bits   Width
 	 * ------------------------------
@@ -92,10 +92,10 @@  struct clk_pll_table tegra_pll_x_table[TEGRA_SOC_CNT][CLOCK_OSC_FREQ_COUNT] = {
 	 * PLLX_MISC  cpcon  11: 8    4
 	 */
 	{
-		{ .n = 862, .m =  8, .p = 0, .cpcon = 8 }, /* OSC: 13.0 MHz */
-		{ .n = 583, .m =  8, .p = 0, .cpcon = 4 }, /* OSC: 19.2 MHz */
-		{ .n = 700, .m =  6, .p = 0, .cpcon = 8 }, /* OSC: 12.0 MHz */
-		{ .n = 700, .m = 13, .p = 0, .cpcon = 8 }, /* OSC: 26.0 MHz */
+		{ .n = 600, .m = 13, .p = 0, .cpcon = 8 }, /* OSC: 13.0 MHz */
+		{ .n = 500, .m = 16, .p = 0, .cpcon = 8 }, /* OSC: 19.2 MHz */
+		{ .n = 600, .m = 12, .p = 0, .cpcon = 8 }, /* OSC: 12.0 MHz */
+		{ .n = 600, .m = 26, .p = 0, .cpcon = 8 }, /* OSC: 26.0 MHz */
 	},
 	/*
 	 * T114: 700 MHz
diff --git a/arch/arm/cpu/arm720t/tegra30/cpu.c b/arch/arm/cpu/arm720t/tegra30/cpu.c
index 85a945bc7918..0f52e54239e1 100644
--- a/arch/arm/cpu/arm720t/tegra30/cpu.c
+++ b/arch/arm/cpu/arm720t/tegra30/cpu.c
@@ -41,10 +41,18 @@  void tegra_i2c_ll_write_data(uint data, uint config)
 	writel(config, &reg->cnfg);
 }
 
+#define TPS62366A_I2C_ADDR		0x60
+#define TPS62366A_SET1_REG		0x01
+#define TPS62366A_SET1_DATA		(0x46 | TPS62366A_SET1_REG)
+
+#define TPS62361B_I2C_ADDR		0x60
+#define TPS62361B_SET3_REG		0x03
+#define TPS62361B_SET3_DATA		(0x46 | TPS62361B_SET3_REG)
+
 #define TPS65911_I2C_ADDR		0x5A
 #define TPS65911_VDDCTRL_OP_REG		0x28
 #define TPS65911_VDDCTRL_SR_REG		0x27
-#define TPS65911_VDDCTRL_OP_DATA	(0x2300 | TPS65911_VDDCTRL_OP_REG)
+#define TPS65911_VDDCTRL_OP_DATA	(0x2400 | TPS65911_VDDCTRL_OP_REG)
 #define TPS65911_VDDCTRL_SR_DATA	(0x0100 | TPS65911_VDDCTRL_SR_REG)
 #define I2C_SEND_2_BYTES		0x0A02
 
@@ -58,9 +66,20 @@  static void enable_cpu_power_rail(void)
 	reg |= CPUPWRREQ_OE;
 	writel(reg, &pmc->pmc_cntrl);
 
+	/* Set VDD_CORE to 1.200V. */
+#ifdef CONFIG_TEGRA_VDD_CORE_TPS62366A_SET1
+	tegra_i2c_ll_write_addr(TPS62366A_I2C_ADDR, 2);
+	tegra_i2c_ll_write_data(TPS62366A_SET1_DATA, I2C_SEND_2_BYTES);
+#endif
+#ifdef CONFIG_TEGRA_VDD_CORE_TPS62361B_SET3
+	tegra_i2c_ll_write_addr(TPS62361B_I2C_ADDR, 2);
+	tegra_i2c_ll_write_data(TPS62361B_SET3_DATA, I2C_SEND_2_BYTES);
+#endif
+	udelay(1000);
+
 	/*
 	 * Bring up CPU VDD via the TPS65911x PMIC on the DVC I2C bus.
-	 * First set VDD to 1.0V, then enable the VDD regulator.
+	 * First set VDD to 1.0125V, then enable the VDD regulator.
 	 */
 	tegra_i2c_ll_write_addr(TPS65911_I2C_ADDR, 2);
 	tegra_i2c_ll_write_data(TPS65911_VDDCTRL_OP_DATA, I2C_SEND_2_BYTES);
diff --git a/include/configs/beaver.h b/include/configs/beaver.h
index df9a98bca6e2..9ff089e67c36 100644
--- a/include/configs/beaver.h
+++ b/include/configs/beaver.h
@@ -21,6 +21,9 @@ 
 
 #include "tegra30-common.h"
 
+/* VDD core PMIC */
+#define CONFIG_TEGRA_VDD_CORE_TPS62366A_SET1
+
 /* Enable fdt support for Beaver. Flash the image in u-boot-dtb.bin */
 #define CONFIG_DEFAULT_DEVICE_TREE	tegra30-beaver
 #define CONFIG_OF_CONTROL
diff --git a/include/configs/cardhu.h b/include/configs/cardhu.h
index e15b52737b24..59f429cf5784 100644
--- a/include/configs/cardhu.h
+++ b/include/configs/cardhu.h
@@ -21,6 +21,9 @@ 
 
 #include "tegra30-common.h"
 
+/* VDD core PMIC */
+#define CONFIG_TEGRA_VDD_CORE_TPS62361B_SET3
+
 /* Enable fdt support for Cardhu. Flash the image in u-boot-dtb.bin */
 #define CONFIG_DEFAULT_DEVICE_TREE	tegra30-cardhu
 #define CONFIG_OF_CONTROL