tegra: warmboot (suspend / resume) support
Subsystems (4)
v2 cover tegra: warmboot (suspend / resume) support
This series adds support for warm boot, allowing the device to suspend and resume. U-Boot sets up some 'warm boot' code in a special area such that the SOC can find it on a resume. This code is responsible for setting up memory and clocked and then allowing the OS to continue where it left off.
Also included here is support for the EMC, which allows setting the memory timings correctly in U-Boot for maximum speed operation.
Note: sign-offs are needed from Jimmy Zhang, Wei Ni and Yen Lin.
Changes in v2:
- Add check of undocumented values in hidrev register
- Add debug() output to EMC
- Add new fdtdec_locate_array() function
- Add patch to find DVC bus number
- Check error return from pmu_set_nominal() in debug mode
- Move EMC tables to device tree
- Move structs shared between A9 and AVP into warmboot.h header file
- New patch to add low-level clock functions
- Rely on compiler to optimise out debug_print_vector()
- Remove unused crypto code
- Remove unused crypto code from crypto.c
- Removed check for nominal voltage (not needed as it is done just before)
- Split PMU code into separate TPS6586X driver
- Tidy SDRAM range check in warmboot_prepare_code()
- Tidy whitespace problems
- Use const for sbox arrays
- Use low-level clock functions in warmboot code instead of register access
Jimmy Zhang (3):
tegra: Add EMC support for optimal memory timings
tegra: Add PMU to manage power supplies
tegra: Add EMC settings for Seaboard
Simon Glass (11):
fdt: Add function to locate an array in the device tree
i2c: Add TPS6586X driver
tegra: Move ap20.h header into arch location
tegra: Add functions to access low-level Osc/PLL details
tegra: Add tegra_get_chip_type() to detect SKU
tegra: Set up PMU for Nvidia boards
tegra: Set up warmboot code on Nvidia boards
fdt: tegra: Add EMC node to device tree
tegra: i2c: Add function to find DVC bus
tegra: fdt: Add EMC data for Tegra2 Seaboard
tegra: Enable LP0 on Seaboard
Wei Ni (1):
Tegra2: Turn off power detect in board init
Yen Lin (5):
Add AES crypto library
tegra: Add crypto library for warmboot code
tegra: Add flow, gp_padctl, fuse, sdram headers
tegra: Add warmboot implementation
tegra: Setup PMC scratch info from ap20 setup
arch/arm/cpu/armv7/tegra2/Makefile | 4 +
arch/arm/cpu/armv7/tegra2/ap20.c | 44 ++-
arch/arm/cpu/armv7/tegra2/board.c | 4 +-
arch/arm/cpu/armv7/tegra2/clock.c | 32 +
arch/arm/cpu/armv7/tegra2/crypto.c | 230 ++++++++
arch/arm/cpu/armv7/tegra2/crypto.h | 36 ++
arch/arm/cpu/armv7/tegra2/emc.c | 192 +++++++
arch/arm/cpu/armv7/tegra2/pmu.c | 70 +++
arch/arm/cpu/armv7/tegra2/warmboot.c | 382 +++++++++++++
arch/arm/cpu/armv7/tegra2/warmboot_avp.c | 250 ++++++++
arch/arm/cpu/armv7/tegra2/warmboot_avp.h | 81 +++
arch/arm/dts/tegra20.dtsi | 7 +
.../tegra2 => include/asm/arch-tegra2}/ap20.h | 7 +
arch/arm/include/asm/arch-tegra2/clk_rst.h | 3 +
arch/arm/include/asm/arch-tegra2/clock.h | 22 +
arch/arm/include/asm/arch-tegra2/emc.h | 112 ++++
arch/arm/include/asm/arch-tegra2/flow.h | 36 ++
arch/arm/include/asm/arch-tegra2/fuse.h | 39 ++
arch/arm/include/asm/arch-tegra2/gp_padctrl.h | 73 +++
arch/arm/include/asm/arch-tegra2/pmu.h | 30 +
arch/arm/include/asm/arch-tegra2/sdram_param.h | 148 +++++
arch/arm/include/asm/arch-tegra2/tegra2.h | 25 +
arch/arm/include/asm/arch-tegra2/tegra2_i2c.h | 7 +
arch/arm/include/asm/arch-tegra2/warmboot.h | 150 +++++
board/nvidia/common/Makefile | 1 +
board/nvidia/common/board.c | 38 ++-
board/nvidia/common/emc.c | 53 ++
board/nvidia/common/emc.h | 29 +
board/nvidia/dts/tegra2-seaboard.dts | 73 +++
drivers/i2c/tegra2_i2c.c | 14 +
drivers/power/Makefile | 1 +
drivers/power/tps6586x.c | 293 ++++++++++
include/aes.h | 70 +++
include/configs/seaboard.h | 8 +
include/configs/tegra2-common.h | 17 +
include/fdtdec.h | 21 +
include/tps6586x.h | 68 +++
lib/Makefile | 1 +
lib/aes.c | 598 ++++++++++++++++++++
lib/fdtdec.c | 13 +
40 files changed, 3278 insertions(+), 4 deletions(-)
create mode 100644 arch/arm/cpu/armv7/tegra2/crypto.c
create mode 100644 arch/arm/cpu/armv7/tegra2/crypto.h
create mode 100644 arch/arm/cpu/armv7/tegra2/emc.c
create mode 100644 arch/arm/cpu/armv7/tegra2/pmu.c
create mode 100644 arch/arm/cpu/armv7/tegra2/warmboot.c
create mode 100644 arch/arm/cpu/armv7/tegra2/warmboot_avp.c
create mode 100644 arch/arm/cpu/armv7/tegra2/warmboot_avp.h
rename arch/arm/{cpu/armv7/tegra2 => include/asm/arch-tegra2}/ap20.h (96%)
create mode 100644 arch/arm/include/asm/arch-tegra2/emc.h
create mode 100644 arch/arm/include/asm/arch-tegra2/flow.h
create mode 100644 arch/arm/include/asm/arch-tegra2/fuse.h
create mode 100644 arch/arm/include/asm/arch-tegra2/gp_padctrl.h
create mode 100644 arch/arm/include/asm/arch-tegra2/pmu.h
create mode 100644 arch/arm/include/asm/arch-tegra2/sdram_param.h
create mode 100644 arch/arm/include/asm/arch-tegra2/warmboot.h
create mode 100644 board/nvidia/common/emc.c
create mode 100644 board/nvidia/common/emc.h
create mode 100644 drivers/power/tps6586x.c
create mode 100644 include/aes.h
create mode 100644 include/tps6586x.h
create mode 100644 lib/aes.cSignature · 1 line
1.7.7.3
A message that is not in the archive (sent off-list or not yet received): 1326490535-3461-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org
PATCH v2 1/20 fdt: Add function to locate an array in the device tree
fdtdec_locate_array() locates an integer array but does not copy it. This saves the caller having to allocated wasted space.
Access to array elements should be through the fdt32_to_cpu() macro.
---
Changes in v2:
- Add new fdtdec_locate_array() function
include/fdtdec.h | 19 +++++++++++++++++++ lib/fdtdec.c | 11 +++++++++++ 2 files changed, 30 insertions(+), 0 deletions(-)
include/fdtdec.h +19 -0
@@ -251,6 +251,25 @@ int fdtdec_get_int_array(const void *blob, int node, const char *prop_name, u32 *array, int count);/** +* Look up a property in a node and return a pointer to its contents as a +* unsigned int array of given length. The property must have at least enough +* data for the array ('count' cells). It may have more, but this will be +* ignored. The data is not copied. +* +* Note that you must access elements of the array with fdt32_to_cpu(), +* since the elements will be big endian even on a little endian machine. +* +* @param blob FDT blob +* @param node node to examine +* @param prop_name name of property to find +* @param count number of array elements +* @return pointer to array if found, or NULL if the property is not +* found or there is not enough data +*/ +const u32 *fdtdec_locate_array (const void *blob,int node, +const char *prop_name,int count); + +/** * Look up a boolean property in a node and return it. * * A boolean properly is true if present in the device tree and false if not
lib/fdtdec.c +11 -0
@@ -341,6 +341,17 @@ int fdtdec_get_int_array(const void *blob, int node, const char *prop_name,return err; } +const u32 *fdtdec_locate_array (const void *blob,int node, +const char *prop_name,int count) +{ +const u32 *cell; +int err; + + cell =get_prop_check_min_len (blob, node, prop_name, +sizeof (u32) * count, &err); +return err ?NULL : cell; +} +int fdtdec_get_bool (const void *blob,int node,const char *prop_name) {const s32 *cell;
Signature · 1 line
1.7.7.3
PATCH v2 17/20 fdt: tegra: Add EMC node to device tree
In reply to a message not in the archiveAdd a definition of the memory controller node according to the bindings here:
http://patchwork.ozlabs.org/patch/132928/
---
arch/arm/dts/tegra20.dtsi | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
arch/arm/dts/tegra20.dtsi +7 -0
@@ -203,5 +203,12 @@ clocks = <&periph_clk 59>; // PERIPH_ID_USB3 }; + emc@7000f400 { + #address-cells = < 1 >; + #size-cells = < 0 >; + compatible = "nvidia,tegra20-emc"; + reg = <0x7000f400 0x200>; + }; + };
Signature · 1 line
1.7.7.3
PATCH v2 19/20 tegra: fdt: Add EMC data for Tegra2 Seaboard
In reply to a message not in the archiveThis adds timings for T20 and T25 Seaboards, using the bindings found here:
http://patchwork.ozlabs.org/patch/132928/
We supply both full speed options for normal running, and half speed options for testing / development.
---
board/nvidia/dts/tegra2-seaboard.dts | 73 ++++++++++++++++++++++++++++++++++ 1 files changed, 73 insertions(+), 0 deletions(-)
board/nvidia/dts/tegra2-seaboard.dts +73 -0
@@ -54,4 +54,77 @@ status = "disabled"; }; + emc@7000f400 { + emc-table@166500 { + reg = <166500>; + compatible = "nvidia,tegra20-emc-table"; + clock-frequency = < 166500 >; + nvidia,emc-registers = < 0x0000000a 0x00000021 + 0x00000008 0x00000003 0x00000004 0x00000004 + 0x00000002 0x0000000c 0x00000003 0x00000003 + 0x00000002 0x00000001 0x00000004 0x00000005 + 0x00000004 0x00000009 0x0000000d 0x000004df + 0x00000000 0x00000003 0x00000003 0x00000003 + 0x00000003 0x00000001 0x0000000a 0x000000c8 + 0x00000003 0x00000006 0x00000004 0x0000000f + 0x00000002 0x00000000 0x00000000 0x00000002 + 0x00000000 0x00000000 0x00000083 0xa04004ae + 0x007fd010 0x00000000 0x00000000 0x00000000 + 0x00000000 0x00000000 0x00000000 0x00000000 >; + }; + emc-table@333000 { + reg = <333000>; + compatible = "nvidia,tegra20-emc-table"; + clock-frequency = < 333000 >; + nvidia,emc-registers = < 0x00000014 0x00000041 + 0x0000000f 0x00000005 0x00000004 0x00000005 + 0x00000003 0x0000000c 0x00000005 0x00000005 + 0x00000003 0x00000001 0x00000004 0x00000005 + 0x00000004 0x00000009 0x0000000d 0x000009ff + 0x00000000 0x00000003 0x00000003 0x00000005 + 0x00000005 0x00000001 0x0000000f 0x000000c8 + 0x00000003 0x0000000c 0x00000006 0x0000000f + 0x00000002 0x00000000 0x00000000 0x00000002 + 0x00000000 0x00000000 0x00000083 0xe034048b + 0x007e8010 0x00000000 0x00000000 0x00000000 + 0x00000000 0x00000000 0x00000000 0x00000000>; + }; + + emc-table@190000 { + reg = < 190000 >; + compatible = "nvidia,tegra20-emc-table"; + clock-frequency = < 190000 >; + nvidia,emc-registers = < 0x0000000c 0x00000026 + 0x00000009 0x00000003 0x00000004 0x00000004 + 0x00000002 0x0000000c 0x00000003 0x00000003 + 0x00000002 0x00000001 0x00000004 0x00000005 + 0x00000004 0x00000009 0x0000000d 0x0000059f + 0x00000000 0x00000003 0x00000003 0x00000003 + 0x00000003 0x00000001 0x0000000b 0x000000c8 + 0x00000003 0x00000007 0x00000004 0x0000000f + 0x00000002 0x00000000 0x00000000 0x00000002 + 0x00000000 0x00000000 0x00000083 0xa06204ae + 0x007dc010 0x00000000 0x00000000 0x00000000 + 0x00000000 0x00000000 0x00000000 0x00000000 >; + }; + emc-table@380000 { + reg = < 380000 >; + compatible = "nvidia,tegra20-emc-table"; + clock-frequency = < 380000 >; + nvidia,emc-registers = < 0x00000017 0x0000004b + 0x00000012 0x00000006 0x00000004 0x00000005 + 0x00000003 0x0000000c 0x00000006 0x00000006 + 0x00000003 0x00000001 0x00000004 0x00000005 + 0x00000004 0x00000009 0x0000000d 0x00000b5f + 0x00000000 0x00000003 0x00000003 0x00000006 + 0x00000006 0x00000001 0x00000011 0x000000c8 + 0x00000003 0x0000000e 0x00000007 0x0000000f + 0x00000002 0x00000000 0x00000000 0x00000002 + 0x00000000 0x00000000 0x00000083 0xe044048b + 0x007d8010 0x00000000 0x00000000 0x00000000 + 0x00000000 0x00000000 0x00000000 0x00000000 >; emc-table@190000 { + }; + }; +}; + };
Signature · 1 line
1.7.7.3
Re: [PATCH v2 19/20] tegra: fdt: Add EMC data for Tegra2 Seaboard
Quoted 80 lines · Simon Glass
This adds timings for T20 and T25 Seaboards, using the bindings found here:
http://patchwork.ozlabs.org/patch/132928/
We supply both full speed options for normal running, and half speed options for testing / development.
Signed-off-by Simon Glass <[email protected]>---
board/nvidia/dts/tegra2-seaboard.dts | 73 ++++++++++++++++++++++++++++++++++
1 files changed, 73 insertions(+), 0 deletions(-)board/nvidia/dts/tegra2-seaboard.dts +59
-0@@ -54,4 +54,77 @@ status = "disabled"; }; + emc@7000f400 { + emc-table@166500 { + reg = <166500>; + compatible = "nvidia,tegra20-emc-table"; + clock-frequency = < 166500 >; + nvidia,emc-registers = < 0x0000000a 0x00000021 + 0x00000008 0x00000003 0x00000004 0x00000004 + 0x00000002 0x0000000c 0x00000003 0x00000003 + 0x00000002 0x00000001 0x00000004 0x00000005 + 0x00000004 0x00000009 0x0000000d 0x000004df + 0x00000000 0x00000003 0x00000003 0x00000003 + 0x00000003 0x00000001 0x0000000a 0x000000c8 + 0x00000003 0x00000006 0x00000004 0x0000000f + 0x00000002 0x00000000 0x00000000 0x00000002 + 0x00000000 0x00000000 0x00000083 0xa04004ae + 0x007fd010 0x00000000 0x00000000 0x00000000 + 0x00000000 0x00000000 0x00000000 0x00000000 >; + }; + emc-table@333000 { + reg = <333000>; + compatible = "nvidia,tegra20-emc-table"; + clock-frequency = < 333000 >; + nvidia,emc-registers = < 0x00000014 0x00000041 + 0x0000000f 0x00000005 0x00000004 0x00000005 + 0x00000003 0x0000000c 0x00000005 0x00000005 + 0x00000003 0x00000001 0x00000004 0x00000005 + 0x00000004 0x00000009 0x0000000d 0x000009ff + 0x00000000 0x00000003 0x00000003 0x00000005 + 0x00000005 0x00000001 0x0000000f 0x000000c8 + 0x00000003 0x0000000c 0x00000006 0x0000000f + 0x00000002 0x00000000 0x00000000 0x00000002 + 0x00000000 0x00000000 0x00000083 0xe034048b + 0x007e8010 0x00000000 0x00000000 0x00000000 + 0x00000000 0x00000000 0x00000000 0x00000000>; + }; + + emc-table@190000 { + reg = < 190000 >; + compatible = "nvidia,tegra20-emc-table"; + clock-frequency = < 190000 >; + nvidia,emc-registers = < 0x0000000c 0x00000026 + 0x00000009 0x00000003 0x00000004 0x00000004 + 0x00000002 0x0000000c 0x00000003 0x00000003 + 0x00000002 0x00000001 0x00000004 0x00000005 + 0x00000004 0x00000009 0x0000000d 0x0000059f + 0x00000000 0x00000003 0x00000003 0x00000003 + 0x00000003 0x00000001 0x0000000b 0x000000c8 + 0x00000003 0x00000007 0x00000004 0x0000000f + 0x00000002 0x00000000 0x00000000 0x00000002 + 0x00000000 0x00000000 0x00000083 0xa06204ae + 0x007dc010 0x00000000 0x00000000 0x00000000 + 0x00000000 0x00000000 0x00000000 0x00000000 >; + }; + emc-table@380000 { + reg = < 380000 >; + compatible = "nvidia,tegra20-emc-table"; + clock-frequency = < 380000 >; + nvidia,emc-registers = < 0x00000017 0x0000004b + 0x00000012 0x00000006 0x00000004 0x00000005
board/nvidia/dts/tegra2-seaboard.dts line 125
Quoted 10 lines
board/nvidia/dts/tegra2-seaboard.dts +10
-0+ 0x00000003 0x0000000c 0x00000006 0x00000006 + 0x00000003 0x00000001 0x00000004 0x00000005 + 0x00000004 0x00000009 0x0000000d 0x00000b5f + 0x00000000 0x00000003 0x00000003 0x00000006 + 0x00000006 0x00000001 0x00000011 0x000000c8 + 0x00000003 0x0000000e 0x00000007 0x0000000f + 0x00000002 0x00000000 0x00000000 0x00000002 + 0x00000000 0x00000000 0x00000083 0xe044048b + 0x007d8010 0x00000000 0x00000000 0x00000000 + 0x00000000 0x00000000 0x00000000 0x00000000 >; emc-table@190000 {
Oh dear. I will fix this next revision...
Quoted 8 lines
board/nvidia/dts/tegra2-seaboard.dts +4
-1+ }; + }; +}; + }; --1.7.7.3
PATCH v2 2/20 i2c: Add TPS6586X driver
In reply to Simon GlassThis power management chip supports battery charging and a large number of power supplies. This initial driver only provides the ability to adjust the two synchronous buck converters SM0 and SM1 in a stepwise manner.
---
Changes in v2:
- Split PMU code into separate TPS6586X driver
drivers/power/Makefile | 1 + drivers/power/tps6586x.c | 293 ++++++++++++++++++++++++++++++++++++++++++++++ include/tps6586x.h | 68 +++++++++++ 3 files changed, 362 insertions(+), 0 deletions(-) create mode 100644 drivers/power/tps6586x.c create mode 100644 include/tps6586x.h
drivers/power/Makefile +1 -0
@@ -28,6 +28,7 @@ LIB := $(obj)libpower.o COBJS-$(CONFIG_FTPMU010_POWER) += ftpmu010.o COBJS-$(CONFIG_TWL4030_POWER) += twl4030.o COBJS-$(CONFIG_TWL6030_POWER) += twl6030.o +COBJS-$(CONFIG_TPS6586X_POWER) += tps6586x.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c)
drivers/power/tps6586x.c new file +293 -0
293 lines not on this page · raw message
include/tps6586x.h new file +68 -0
68 lines not on this page · raw message
Signature · 1 line
1.7.7.3
PATCH v2 2/20 i2c: Add TPS6586X driver
Hello Simon,
Quoted 21 lines · Simon Glass
This power management chip supports battery charging and a large number of power supplies. This initial driver only provides the ability to adjust the two synchronous buck converters SM0 and SM1 in a stepwise manner.
Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Split PMU code into separate TPS6586X driverdrivers/power/Makefile | 1 + drivers/power/tps6586x.c | 293 ++++++++++++++++++++++++++++++++++++++++++++++ include/tps6586x.h | 68 +++++++++++ 3 files changed, 362 insertions(+), 0 deletions(-) create mode 100644 drivers/power/tps6586x.c create mode 100644 include/tps6586x.hdrivers/power/Makefile +0
-0
drivers/power/Makefile LIB := $(obj)libpower.o · line 31
Quoted 4 lines
drivers/power/Makefile +1
-0@@ -28,6 +28,7 @@ LIB := $(obj)libpower.o COBJS-$(CONFIG_FTPMU010_POWER) += ftpmu010.o COBJS-$(CONFIG_TWL4030_POWER) += twl4030.o COBJS-$(CONFIG_TWL6030_POWER) += twl6030.o +COBJS-$(CONFIG_TPS6586X_POWER) += tps6586x.o
please hold lists sorted.
Quoted 38 lines
drivers/power/Makefile +0
-0COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c)drivers/power/tps6586x.c new file +30
-0@@ -0,0 +1,293 @@ +/* +* Copyright (c) 2011 The Chromium OS Authors. +* (C) Copyright 2010,2011 NVIDIA Corporation <www.nvidia.com> +* +* 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 <common.h> +#include <tps6586x.h> +#include <asm/io.h> +#include <i2c.h> + +/* +* abs() handles unsigned ints, shorts and chars and returns a signed long.
drivers/power/tps6586x.c line 40
Quoted 10 lines
drivers/power/tps6586x.c new file +10
-0+* TODO: Move this into common? +*/ +#define abs (x) ({ \ + long ret; \ + { \ + typeof((x)) __x = (x); \ + ret = (__x < 0) ? -__x : __x; \ + } \ + ret; \ + })
I thought we have such a define, but couldn't find it ... I vote for moving it to common ...
[...]
Quoted 6 lines
include/tps6586x.h new file +0
-0@@ -0,0 +1,68 @@
[...]
include/tps6586x.h
Quoted 2 lines
include/tps6586x.h new file +2
-0+ +/**
wrong comment style.
include/tps6586x.h line 42
Quoted 8 lines
+ * Enable PWM mode for selected SM0-2
+ *
+ * @param mask Mask of synchronous converter to enable (TPS6586X_PWM_...)
+ * @return 0 if ok, -1 on error
+ */include/tps6586x.h new file +3
-0+int tps6586x_set_pwm_mode (int mask); + +/**
here too, please fix globally.
bye,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH v2 2/20 i2c: Add TPS6586X driver
Hi Heiko,
Quoted 19 lines · Heiko Schocher
Hello Simon,
Quoted 16 lines · Simon Glass
This power management chip supports battery charging and a large number of power supplies. This initial driver only provides the ability to adjust the two synchronous buck converters SM0 and SM1 in a stepwise manner.
Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Split PMU code into separate TPS6586X driver?drivers/power/Makefile ? | ? ?1 + ?drivers/power/tps6586x.c | ?293 ++++++++++++++++++++++++++++++++++++++++++++++ ?include/tps6586x.h ? ? ? | ? 68 +++++++++++?3 files changed, 362 insertions(+), 0 deletions(-) ?create mode 100644
drivers/power/tps6586x.c?create mode 100644include/tps6586x.h
Quoted 11 lines
Quoted 9 lines
drivers/power/Makefile +0
-0@@ -28,6 +28,7 @@ LIB ? ? ? ? := $(obj)libpower.o?COBJS-$(CONFIG_FTPMU010_POWER) ? ? ? += ftpmu010.o ?COBJS-$(CONFIG_TWL4030_POWER) ? ? ? ?+= twl4030.o ?COBJS-$(CONFIG_TWL6030_POWER) ? ? ? ?+= twl6030.o +COBJS-$(CONFIG_TPS6586X_POWER) ? ? ? += tps6586x.o
please hold lists sorted.
Done
Quoted 44 lines
Quoted 44 lines
?COBJS ? ? ? ?:= $(COBJS-y)
?SRCS ? ? ? ? := $(COBJS:.o=.c)drivers/power/tps6586x.c new file +35
-0@@ -0,0 +1,293 @@ +/* +* Copyright (c) 2011 The Chromium OS Authors. +* (C) Copyright 2010,2011 NVIDIA Corporation <www.nvidia.com> +* +* 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 <common.h> +#include <tps6586x.h> +#include <asm/io.h> +#include <i2c.h> + +/* +* abs() handles unsigned ints, shorts and chars and returns a signed long. +* TODO: Move this into common? +*/ +#define abs (x) ({ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ + ? ? ? ? ? ? long ret; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ + ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
Quoted 8 lines
drivers/power/tps6586x.c line 40
Quoted 5 lines
drivers/power/tps6586x.c new file +5
-0+ ? ? ? ? ? ? ? ? ? ? typeof((x)) __x = (x); ? ? ? ? ? ? ? ? ?\ + ? ? ? ? ? ? ? ? ? ? ret = (__x < 0) ? -__x : __x; ? ? ? ? ? \ + ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ + ? ? ? ? ? ? ret; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ + ? ? })I thought we have such a define, but couldn't find it ... I vote for moving it to common ...
OK will do.
Re the comment style, hopefully we are ok with this now.
[snip]
Regards,
Simon
PATCH v2 3/20 Add AES crypto library
In reply to Simon GlassFrom: Yen Lin <[email protected]>
Add support for AES using an implementation form Karl Malbrain. This offers small code size (around 5KB on ARM) and supports 128-bit AES only.
---
Changes in v2:
- Tidy whitespace problems
- Use const for sbox arrays
include/aes.h | 70 +++++++ lib/Makefile | 1 + lib/aes.c | 598 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 669 insertions(+), 0 deletions(-) create mode 100644 include/aes.h create mode 100644 lib/aes.c
include/aes.h new file +70 -0
@@ -0,0 +1,70 @@ +/* +* Copyright (c) 2011 The Chromium OS Authors. +* (C) Copyright 2010 - 2011 NVIDIA Corporation <www.nvidia.com> +* +* 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 +*/ + +#ifndef _AES_REF_H_ +#define _AES_REF_H_ + +/* +* AES encryption library, with small code size, supporting only 128-bit AES +* +* AES is a stream cipher which works a block at a time, with each block +* in this case being AES_KEY_LENGTH bytes. +*/ + +enum { +AES_STATECOLS =4 ,/* columns in the state & expanded key */ +AES_KEYCOLS =4 ,/* columns in a key */ +AES_ROUNDS =10 ,/* rounds in encryption */ + +AES_KEY_LENGTH =128 /8 , +AES_EXPAND_KEY_LENGTH =4 *AES_STATECOLS * (AES_ROUNDS +1 ), +}; + +/** +* Expand a key into a key schedule, which is then used for the other +* operations. +* +* \param key Key, of length AES_KEY_LENGTH bytes +* \param expkey Buffer to place expanded key, AES_EXPAND_KEY_LENGTH +*/ +void aes_expand_key (u8 *key,u8 *expkey); + +/** +* Encrypt a single block of data +* +* in Input data +* expkey Expanded key to use for encryption (from aes_expand_key()) +* out Output data +*/ +void aes_encrypt (u8 *in,u8 *expkey,u8 *out); + +/** +* Decrypt a single block of data +* +* in Input data +* expkey Expanded key to use for decryption (from aes_expand_key()) +* out Output data +*/ +void aes_decrypt (u8 *in,u8 *expkey,u8 *out); + +#endif /* _AES_REF_H_ */
lib/Makefile +1 -0
@@ -27,6 +27,7 @@ LIB = $(obj)libgeneric.o ifndef CONFIG_SPL_BUILD COBJS-$(CONFIG_ADDR_MAP) += addr_map.o +COBJS-$(CONFIG_AES) += aes.o COBJS-$(CONFIG_BZIP2) += bzlib.o COBJS-$(CONFIG_BZIP2) += bzlib_crctable.o COBJS-$(CONFIG_BZIP2) += bzlib_decompress.o
lib/aes.c new file +598 -0
598 lines not on this page · raw message
Signature · 1 line
1.7.7.3
PATCH v2 4/20 tegra: Move ap20.h header into arch location
In reply to Simon GlassWe want to include this from board code, so move the header into an easily-accessible location.
---
arch/arm/cpu/armv7/tegra2/ap20.c | 2 +-
arch/arm/cpu/armv7/tegra2/board.c | 4 ++--
.../tegra2 => include/asm/arch-tegra2}/ap20.h | 0
3 files changed, 3 insertions(+), 3 deletions(-)
rename arch/arm/{cpu/armv7/tegra2 => include/asm/arch-tegra2}/ap20.h (100%)arch/arm/cpu/armv7/tegra2/ap20.c +1 -1
@@ -21,9 +21,9 @@* MA 02111-1307 USA */ -#include "ap20.h" #include <asm/io.h> #include <asm/arch/tegra2.h> +#include <asm/arch/ap20.h> #include <asm/arch/clk_rst.h> #include <asm/arch/clock.h> #include <asm/arch/pmc.h>
arch/arm/cpu/armv7/tegra2/board.c +2 -2
@@ -23,12 +23,12 @@#include <common.h> #include <asm/io.h> -#include "ap20.h" +#include <asm/arch/ap20.h> #include <asm/arch/clock.h> #include <asm/arch/funcmux.h> +#include <asm/arch/pmc.h> #include <asm/arch/sys_proto.h> #include <asm/arch/tegra2.h> -#include <asm/arch/pmc.h> DECLARE_GLOBAL_DATA_PTR ;
arch/arm/include/asm/arch-tegra2/ap20.h renamed from arch/arm/cpu/armv7/tegra2/ap20.h +0 -0
Signature · 1 line
1.7.7.3
PATCH v2 5/20 tegra: Add functions to access low-level Osc/PLL details
In reply to Simon GlassAdd clock_ll_read_pll() to read PLL parameters and clock_get_osc_bypass() to find out if the Oscillator is bypassed. These are needed by warmboot.
---
Changes in v2:
- New patch to add low-level clock functions
arch/arm/cpu/armv7/tegra2/clock.c | 32 ++++++++++++++++++++++++++++ arch/arm/include/asm/arch-tegra2/clk_rst.h | 3 ++ arch/arm/include/asm/arch-tegra2/clock.h | 22 +++++++++++++++++++ 3 files changed, 57 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/tegra2/clock.c +32 -0
@@ -407,6 +407,16 @@ enum clock_osc_freq clock_get_osc_freq(void)return (reg &OSC_FREQ_MASK ) >>OSC_FREQ_SHIFT ; } +int clock_get_osc_bypass (void ) +{ +struct clk_rst_ctlr *clkrst = + (struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE ; +u32 reg; + + reg =readl (&clkrst->crc_osc_ctrl); +return (reg &OSC_XOBP_MASK ) >>OSC_XOBP_SHIFT ; +} +/* Returns a pointer to the registers of the given pll */ static struct clk_pll *get_pll (enum clock_id clkid) {
@@ -417,6 +427,28 @@ static struct clk_pll *get_pll(enum clock_id clkid)return &clkrst->crc_pll[clkid]; } +int clock_ll_read_pll (enum clock_id clkid,u32 *divm,u32 *divn, +u32 *divp,u32 *cpcon,u32 *lfcon) +{ +struct clk_pll *pll =get_pll (clkid); +u32 data; + +assert (clkid !=CLOCK_ID_USB ); + +/* Safety check, adds to code size but is small */ +if (!clock_id_isvalid (clkid) || clkid ==CLOCK_ID_USB ) +return -1 ; + data =readl (&pll->pll_base); + *divm = (data &PLL_DIVM_MASK ) >>PLL_DIVM_SHIFT ; + *divn = (data &PLL_DIVN_MASK ) >>PLL_DIVN_SHIFT ; + *divp = (data &PLL_DIVP_MASK ) >>PLL_DIVP_SHIFT ; + data =readl (&pll->pll_misc); + *cpcon = (data &PLL_CPCON_MASK ) >>PLL_CPCON_SHIFT ; + *lfcon = (data &PLL_LFCON_MASK ) >>PLL_LFCON_SHIFT ; + +return 0 ; +} +unsigned long clock_start_pll (enum clock_id clkid,u32 divm,u32 divn,u32 divp,u32 cpcon,u32 lfcon) {
arch/arm/include/asm/arch-tegra2/clk_rst.h +3 -0
@@ -117,6 +117,7 @@ struct clk_rst_ctlr {#define PLL_CPCON_MASK (15U << PLL_CPCON_SHIFT)#define PLL_LFCON_SHIFT 4 +#define PLL_LFCON_MASK (15U << PLL_LFCON_SHIFT)#define PLLU_VCO_FREQ_SHIFT 20#define PLLU_VCO_FREQ_MASK (1U << PLLU_VCO_FREQ_SHIFT)
@@ -124,6 +125,8 @@ struct clk_rst_ctlr {/* CLK_RST_CONTROLLER_OSC_CTRL_0 */ #define OSC_FREQ_SHIFT 30#define OSC_FREQ_MASK (3U << OSC_FREQ_SHIFT) +#define OSC_XOBP_SHIFT 1 +#define OSC_XOBP_MASK (1U << OSC_XOBP_SHIFT)/* CLK_RST_CONTROLLER_CLK_SOURCE_x_OUT_0 */ #define OUT_CLK_DIVISOR_SHIFT 0
arch/arm/include/asm/arch-tegra2/clock.h +22 -0
@@ -209,6 +209,21 @@ enum clock_osc_freq clock_get_osc_freq(void);unsigned long clock_start_pll (enum clock_id id,u32 divm,u32 divn,u32 divp,u32 cpcon,u32 lfcon); +/** +* Read low-level parameters of a PLL. +* +* @param id clock id to read (note: USB is not supported) +* @param divm returns input divider +* @param divn returns feedback divider +* @param divp returns post divider 2^n +* @param cpcon returns charge pump setup control +* @param lfcon returns loop filter setup control +* +* @returns 0 if ok, -1 on error (invalid clock id) +*/ +int clock_ll_read_pll (enum clock_id clkid,u32 *divm,u32 *divn, +u32 *divp,u32 *cpcon,u32 *lfcon); +/* * Enable a clock *
@@ -355,6 +370,13 @@ unsigned clock_get_rate(enum clock_id clkid);*/ void clock_ll_start_uart (enum periph_id periph_id); +/** +* Checks if the oscillator bypass is enabled (XOBP bit) +* +* @return 1 if bypass is enabled, 0 if not +*/ +int clock_get_osc_bypass (void ); +/* * Checks that clocks are valid and prints a warning if not *
Signature · 1 line
1.7.7.3
PATCH v2 6/20 tegra: Add crypto library for warmboot code
In reply to Simon GlassFrom: Yen Lin <[email protected]>
Provides an interface to aes.c for the warmboot code.
---
Changes in v2:
- Rely on compiler to optimise out debug_print_vector()
- Remove unused crypto code from crypto.c
arch/arm/cpu/armv7/tegra2/crypto.c | 230 ++++++++++++++++++++++++++++++++++++ arch/arm/cpu/armv7/tegra2/crypto.h | 36 ++++++ 2 files changed, 266 insertions(+), 0 deletions(-) create mode 100644 arch/arm/cpu/armv7/tegra2/crypto.c create mode 100644 arch/arm/cpu/armv7/tegra2/crypto.h
arch/arm/cpu/armv7/tegra2/crypto.c new file +230 -0
@@ -0,0 +1,230 @@ +/* +* Copyright (c) 2011 The Chromium OS Authors. +* (C) Copyright 2010 - 2011 NVIDIA Corporation <www.nvidia.com> +* +* 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 <common.h> +#include <asm/errno.h> +#include "crypto.h" +#include "aes.h" + +static u8 zero_key[16 ]; + +#define AES_CMAC_CONST_RB 0x87/* from RFC 4493, Figure 2.2 */ + +enum security_op { +SECURITY_SIGN =1 <<0 ,/* Sign the data */ +SECURITY_ENCRYPT =1 <<1 ,/* Encrypt the data */ +}; + +static void debug_print_vector (char *name,u32 num_bytes,u8 *data) +{ +u32 i; + +debug ("%s [%d] @0x%08x" , name, num_bytes, (u32 )data); +for (i =0 ; i < num_bytes; i++) { +if (i %16 ==0 ) +debug (" = " ); +debug ("%02x" , data[i]); +if ((i+1 ) %16 !=0 ) +debug (" " ); + } +debug ("\n" ); +} + +/** +* Apply chain data to the destination using EOR +* +* Each array is of length AES_AES_KEY_LENGTH. +* +* \param cbc_chain_data Chain data +* \param src Source data +* \param dst Destination data, which is modified here +*/ +static void apply_cbc_chain_data (u8 *cbc_chain_data,u8 *src,u8 *dst) +{ +int i; + +for (i =0 ; i <16 ; i++) + *dst++ = *src++ ^ *cbc_chain_data++; +} + +/** +* Encrypt some data with AES. +* +* \param key_schedule Expanded key to use +* \param src Source data to encrypt +* \param dst Destination buffer +* \param num_aes_blocks Number of AES blocks to encrypt +*/ +static void encrypt_object (u8 *key_schedule,u8 *src,u8 *dst, +u32 num_aes_blocks) +{ +u8 tmp_data[AES_KEY_LENGTH ]; +u8 *cbc_chain_data; +u32 i; + + cbc_chain_data = zero_key;/* Convenient array of 0's for IV */ + +for (i =0 ; i < num_aes_blocks; i++) { +debug ("encrypt_object: block %d of %d\n" , i, num_aes_blocks); +debug_print_vector ("AES Src" ,AES_KEY_LENGTH , src); + +/* Apply the chain data */ +apply_cbc_chain_data (cbc_chain_data, src, tmp_data); +debug_print_vector ("AES Xor" ,AES_KEY_LENGTH , tmp_data); + +/* encrypt the AES block */ +aes_encrypt (tmp_data, key_schedule, dst); +debug_print_vector ("AES Dst" ,AES_KEY_LENGTH , dst); + +/* Update pointers for next loop. */ + cbc_chain_data = dst; + src +=AES_KEY_LENGTH ; + dst +=AES_KEY_LENGTH ; + } +} + +/** +* Shift a vector left by one bit +* +* \param in Input vector +* \param out Output vector +* \param size Length of vector in bytes +*/ +static void left_shift_vector (u8 *in,u8 *out,int size) +{ +int carry =0 ; +int i; + +for (i = size -1 ; i >=0 ; i--) { + out[i] = (in[i] <<1 ) | carry; + carry = in[i] >>7 ;/* get most significant bit */ + } +} + +/** +* Sign a block of data, putting the result into dst. +* +* \param key Input AES key, length AES_KEY_LENGTH +* \param key_schedule Expanded key to use +* \param src Source data of length 'num_aes_blocks' blocks +* \param dst Destination buffer, length AES_KEY_LENGTH +* \param num_aes_blocks Number of AES blocks to encrypt +*/ +static void sign_object (u8 *key,u8 *key_schedule,u8 *src,u8 *dst, +u32 num_aes_blocks) +{ +u8 tmp_data[AES_KEY_LENGTH ]; +u8 left[AES_KEY_LENGTH ]; +u8 k1[AES_KEY_LENGTH ]; +u8 *cbc_chain_data; +unsigned i; + + cbc_chain_data = zero_key;/* Convenient array of 0's for IV */ + +/* compute K1 constant needed by AES-CMAC calculation */ +for (i =0 ; i <AES_KEY_LENGTH ; i++) + tmp_data[i] =0 ; + +encrypt_object (key_schedule, tmp_data, left,1 ); +debug_print_vector ("AES(key, nonce)" ,AES_KEY_LENGTH , left); + +left_shift_vector (left, k1,sizeof (left)); +debug_print_vector ("L" ,AES_KEY_LENGTH , left); + +if ((left[0 ] >>7 ) !=0 )/* get MSB of L */ + k1[AES_KEY_LENGTH -1 ] ^=AES_CMAC_CONST_RB ; +debug_print_vector ("K1" ,AES_KEY_LENGTH , k1); + +/* compute the AES-CMAC value */ +for (i =0 ; i < num_aes_blocks; i++) { +/* Apply the chain data */ +apply_cbc_chain_data (cbc_chain_data, src, tmp_data); + +/* for the final block, XOR K1 into the IV */ +if (i == num_aes_blocks -1 ) +apply_cbc_chain_data (tmp_data, k1, tmp_data); + +/* encrypt the AES block */ +aes_encrypt (tmp_data, key_schedule, dst); + +debug ("sign_obj: block %d of %d\n" , i, num_aes_blocks); +debug_print_vector ("AES-CMAC Src" ,AES_KEY_LENGTH , src); +debug_print_vector ("AES-CMAC Xor" ,AES_KEY_LENGTH , tmp_data); +debug_print_vector ("AES-CMAC Dst" ,AES_KEY_LENGTH , dst); + +/* Update pointers for next loop. */ + cbc_chain_data = dst; + src +=AES_KEY_LENGTH ; + } + +debug_print_vector ("AES-CMAC Hash" ,AES_KEY_LENGTH , dst); +} + +/** +* Encrypt and sign a block of data (depending on security mode). +* +* \param key Input AES key, length AES_KEY_LENGTH +* \param oper Security operations mask to perform (enum security_op) +* \param src Source data +* \param length Size of source data +* \param sig_dst Destination address for signature, AES_KEY_LENGTH bytes +*/ +static int encrypt_and_sign (u8 *key,enum security_op oper,u8 *src, +u32 length,u8 *sig_dst) +{ +u32 num_aes_blocks; +u8 key_schedule[AES_EXPAND_KEY_LENGTH ]; + +debug ("encrypt_and_sign: length = %d\n" , length); +debug_print_vector ("AES key" ,AES_KEY_LENGTH , key); + +/* +* The only need for a key is for signing/checksum purposes, so +* if not encrypting, expand a key of 0s. +*/ +aes_expand_key (oper &SECURITY_ENCRYPT ? key : zero_key, key_schedule); + + num_aes_blocks = (length +AES_KEY_LENGTH -1 ) /AES_KEY_LENGTH ; + +if (oper &SECURITY_ENCRYPT ) { +/* Perform this in place, resulting in src being encrypted. */ +debug ("encrypt_and_sign: begin encryption\n" ); +encrypt_object (key_schedule, src, src, num_aes_blocks); +debug ("encrypt_and_sign: end encryption\n" ); + } + +if (oper &SECURITY_SIGN ) { +/* encrypt the data, overwriting the result in signature. */ +debug ("encrypt_and_sign: begin signing\n" ); +sign_object (key, key_schedule, src, sig_dst, num_aes_blocks); +debug ("encrypt_and_sign: end signing\n" ); + } + +return 0 ; +} + +int sign_data_block (u8 *source,unsigned length,u8 *signature) +{ +return encrypt_and_sign (zero_key,SECURITY_SIGN , source, + length, signature); +}
arch/arm/cpu/armv7/tegra2/crypto.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* Copyright (c) 2011 The Chromium OS Authors. +* (C) Copyright 2010 - 2011 NVIDIA Corporation <www.nvidia.com> +* +* 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 +*/ + +#ifndef _CRYPTO_H_ +#define _CRYPTO_H_ + +/** +* Sign a block of data +* +* \param source Source data +* \param length Size of source data +* \param signature Destination address for signature, AES_KEY_LENGTH bytes +*/ +int sign_data_block (u8 *source,unsigned length,u8 *signature); + +#endif /* #ifndef _CRYPTO_H_ */
Signature · 1 line
1.7.7.3
PATCH v2 7/20 tegra: Add flow, gp_padctl, fuse, sdram headers
In reply to Simon GlassFrom: Yen Lin <[email protected]>
These headers provide access to additional Tegra features.
flow - start/stop CPUs
sdram - parameters for SDRAM
fuse - access to on-chip fuses / security settings gp_padctl - pad control and general purpose registers
---
arch/arm/include/asm/arch-tegra2/flow.h | 36 ++++++ arch/arm/include/asm/arch-tegra2/fuse.h | 39 ++++++ arch/arm/include/asm/arch-tegra2/gp_padctrl.h | 64 ++++++++++ arch/arm/include/asm/arch-tegra2/sdram_param.h | 148 ++++++++++++++++++++++++ arch/arm/include/asm/arch-tegra2/tegra2.h | 1 + 5 files changed, 288 insertions(+), 0 deletions(-) create mode 100644 arch/arm/include/asm/arch-tegra2/flow.h create mode 100644 arch/arm/include/asm/arch-tegra2/fuse.h create mode 100644 arch/arm/include/asm/arch-tegra2/gp_padctrl.h create mode 100644 arch/arm/include/asm/arch-tegra2/sdram_param.h
arch/arm/include/asm/arch-tegra2/flow.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* (C) Copyright 2010, 2011 +* NVIDIA Corporation <www.nvidia.com> +* +* 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 +*/ + +#ifndef _FLOW_H_ +#define _FLOW_H_ + +struct flow_ctlr { +u32 halt_cpu_events; +u32 halt_cop_events; +u32 cpu_csr; +u32 cop_csr; +u32 halt_cpu1_events; +u32 cpu1_csr; +}; + +#endif
arch/arm/include/asm/arch-tegra2/fuse.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* (C) Copyright 2010,2011 +* NVIDIA Corporation <www.nvidia.com> +* +* 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 +*/ + +#ifndef _FUSE_H_ +#define _FUSE_H_ + +/* FUSE registers */ +struct fuse_regs { +u32 reserved0[64 ];/* 0x00 - 0xFC: */ +u32 production_mode;/* 0x100: FUSE_PRODUCTION_MODE */ +u32 reserved1[3 ];/* 0x104 - 0x10c: */ +u32 sku_info;/* 0x110 */ +u32 reserved2[13 ];/* 0x114 - 0x144: */ +u32 fa;/* 0x148: FUSE_FA */ +u32 reserved3[21 ];/* 0x14C - 0x19C: */ +u32 security_mode;/* 0x1A0: FUSE_SECURITY_MODE */ +}; + +#endif /* ifndef _FUSE_H_ */
arch/arm/include/asm/arch-tegra2/gp_padctrl.h new file +64 -0
64 lines not on this page · raw message
arch/arm/include/asm/arch-tegra2/sdram_param.h new file +148 -0
148 lines not on this page · raw message
arch/arm/include/asm/arch-tegra2/tegra2.h +1 -0
@@ -40,6 +40,7 @@#define NV_PA_APB_UARTE_BASE (NV_PA_APB_MISC_BASE + 0x6400)#define TEGRA2_SPI_BASE (NV_PA_APB_MISC_BASE + 0xC380)#define TEGRA2_PMC_BASE (NV_PA_APB_MISC_BASE + 0xE400) +#define TEGRA2_FUSE_BASE (NV_PA_APB_MISC_BASE + 0xF800)#define NV_PA_CSITE_BASE 0x70040000#define TEGRA_USB1_BASE 0xC5000000#define TEGRA_USB3_BASE 0xC5008000
Signature · 1 line
1.7.7.3
PATCH v2 8/20 tegra: Add tegra_get_chip_type() to detect SKU
In reply to Simon GlassWe want to know which type of chip we are running on - the Tegra family has several SKUs. This can be determined by reading a fuse register, so add this function to ap20.
---
Changes in v2:
- Add check of undocumented values in hidrev register
arch/arm/cpu/armv7/tegra2/ap20.c | 36 +++++++++++++++++++++++++ arch/arm/include/asm/arch-tegra2/ap20.h | 7 +++++ arch/arm/include/asm/arch-tegra2/gp_padctrl.h | 9 ++++++ arch/arm/include/asm/arch-tegra2/tegra2.h | 24 ++++++++++++++++ 4 files changed, 76 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/tegra2/ap20.c +36 -0
@@ -26,11 +26,47 @@#include <asm/arch/ap20.h> #include <asm/arch/clk_rst.h> #include <asm/arch/clock.h> +#include <asm/arch/fuse.h> +#include <asm/arch/gp_padctrl.h> #include <asm/arch/pmc.h> #include <asm/arch/pinmux.h> #include <asm/arch/scu.h> #include <common.h> +int tegra_get_chip_type (void ) +{ +struct apb_misc_gp_ctlr *gp; +struct fuse_regs *fuse = (struct fuse_regs *)TEGRA2_FUSE_BASE ; +uint tegra_sku_id, rev; + +/* +* This is undocumented, Chip ID is bits 15:8 of the register +* APB_MISC + 0x804, and has value 0x20 for Tegra20, 0x30 for +* Tegra30 +*/ + gp = (struct apb_misc_gp_ctlr *)TEGRA2_APB_MISC_GP_BASE ; + rev = (readl (&gp->hidrev) &HIDREV_CHIPID_MASK ) >>HIDREV_CHIPID_SHIFT ; + + tegra_sku_id =readl (&fuse->sku_info) &0xff ; + +switch (rev) { +case CHIPID_TEGRA2 : +switch (tegra_sku_id) { +case SKU_ID_T20 : +return TEGRA_SOC_T20 ; +case SKU_ID_T25SE : +case SKU_ID_AP25 : +case SKU_ID_T25 : +case SKU_ID_AP25E : +case SKU_ID_T25E : +return TEGRA_SOC_T25 ; + } +break ; + } +/* unknown sku id */ +return TEGRA_SOC_UNKNOWN ; +} +/* Returns 1 if the current CPU executing is a Cortex-A9, else 0 */ static int ap20_cpu_is_cortexa9 (void ) {
arch/arm/include/asm/arch-tegra2/ap20.h +7 -0
@@ -100,3 +100,10 @@ void tegra2_start(void);/* This is the main entry into U-Boot, used by the Cortex-A9 */ extern void _start (void ); + +/** +* Works out the SOC type used for clocks settings +* +* @return SOC type - see TEGRA_SOC... +*/ +int tegra_get_chip_type (void );
arch/arm/include/asm/arch-tegra2/gp_padctrl.h +9 -0
@@ -61,4 +61,13 @@ struct apb_misc_gp_ctlr { u32 memcomp; /* 0xD4: APB_MISC_GP_MEMCOMPPADCTRL */ }; +/* bit fields definitions for APB_MISC_GP_HIDREV register */ +#define HIDREV_CHIPID_SHIFT 8 +#define HIDREV_CHIPID_MASK (0xff << HIDREV_CHIPID_SHIFT) +#define HIDREV_MAJORPREV_SHIFT 4 +#define HIDREV_MAJORPREV_MASK (0xf << HIDREV_MAJORPREV_SHIFT) + +/* CHIPID field returned from APB_MISC_GP_HIDREV register */ +#define CHIPID_TEGRA2 0x20 +#endif
arch/arm/include/asm/arch-tegra2/tegra2.h +24 -0
@@ -33,6 +33,7 @@#define NV_PA_GPIO_BASE 0x6000D000#define NV_PA_EVP_BASE 0x6000F000#define NV_PA_APB_MISC_BASE 0x70000000 +#define TEGRA2_APB_MISC_GP_BASE (NV_PA_APB_MISC_BASE + 0x0800)#define NV_PA_APB_UARTA_BASE (NV_PA_APB_MISC_BASE + 0x6000)#define NV_PA_APB_UARTB_BASE (NV_PA_APB_MISC_BASE + 0x6040)#define NV_PA_APB_UARTC_BASE (NV_PA_APB_MISC_BASE + 0x6200)
@@ -55,6 +56,29 @@struct timerus {unsigned int cntr_1us; }; + +/* Address@which WB code runs, it must not overlap Bootrom's IRAM usage */ +#define AP20_WB_RUN_ADDRESS 0x40020000 + +/* These are the available SKUs (product types) for Tegra */ +enum { +SKU_ID_T20 =0x8 , +SKU_ID_T25SE =0x14 , +SKU_ID_AP25 =0x17 , +SKU_ID_T25 =0x18 , +SKU_ID_AP25E =0x1b , +SKU_ID_T25E =0x1c , +}; + +/* These are the SOC categories that affect clocking */ +enum { +TEGRA_SOC_T20 , +TEGRA_SOC_T25 , + +TEGRA_SOC_COUNT , +TEGRA_SOC_UNKNOWN =-1 , +}; +#else /* __ASSEMBLY__ */ #define PRM_RSTCTRL TEGRA2_PMC_BASE#endif
Signature · 1 line
1.7.7.3
PATCH v2 8/20 tegra: Add tegra_get_chip_type() to detect SKU
Quoted 5 lines · Simon Glass
We want to know which type of chip we are running on - the Tegra family has several SKUs. This can be determined by reading a fuse register, so add this function to ap20.
Signed-off-by Simon Glass <[email protected]>
Signature · 1 line
nvpublic
PATCH v2 9/20 tegra: Add EMC support for optimal memory timings
In reply to Simon GlassFrom: Jimmy Zhang <[email protected]>
Add support for setting up the memory controller parameters. Boards can set up an appropriate table in the device tree.
---
Changes in v2:
- Add debug() output to EMC
- Move EMC tables to device tree
arch/arm/cpu/armv7/tegra2/Makefile | 1 + arch/arm/cpu/armv7/tegra2/emc.c | 192 ++++++++++++++++++++++++++++++++ arch/arm/include/asm/arch-tegra2/emc.h | 112 +++++++++++++++++++ include/fdtdec.h | 2 + lib/fdtdec.c | 2 + 5 files changed, 309 insertions(+), 0 deletions(-) create mode 100644 arch/arm/cpu/armv7/tegra2/emc.c create mode 100644 arch/arm/include/asm/arch-tegra2/emc.h
arch/arm/cpu/armv7/tegra2/Makefile +1 -0
@@ -34,6 +34,7 @@ LIB = $(obj)lib$(SOC).o SOBJS := lowlevel_init.o COBJS-y := ap20.o board.o clock.o funcmux.o pinmux.o sys_info.o timer.o +COBJS-$(CONFIG_TEGRA_CLOCK_SCALING) += emc.o COBJS-$(CONFIG_USB_EHCI_TEGRA) += usb.o COBJS := $(COBJS-y)
arch/arm/cpu/armv7/tegra2/emc.c new file +192 -0
192 lines not on this page · raw message
arch/arm/include/asm/arch-tegra2/emc.h new file +112 -0
112 lines not on this page · raw message
include/fdtdec.h +2 -0
@@ -60,6 +60,8 @@ enum fdt_compat_id {COMPAT_NVIDIA_TEGRA20_USB ,/* Tegra2 USB port */ COMPAT_NVIDIA_TEGRA20_I2C ,/* Tegra2 i2c */ COMPAT_NVIDIA_TEGRA20_DVC ,/* Tegra2 dvc (really just i2c) */ +COMPAT_NVIDIA_TEGRA20_EMC ,/* Tegra2 memory controller */ +COMPAT_NVIDIA_TEGRA20_EMC_TABLE ,/* Tegra2 memory timing table */ COMPAT_COUNT, };
lib/fdtdec.c +2 -0
@@ -40,6 +40,8 @@ static const char * const compat_names[COMPAT_COUNT] = {COMPAT (NVIDIA_TEGRA20_USB ,"nvidia,tegra20-ehci" ),COMPAT (NVIDIA_TEGRA20_I2C ,"nvidia,tegra20-i2c" ),COMPAT (NVIDIA_TEGRA20_DVC ,"nvidia,tegra20-i2c-dvc" ), +COMPAT (NVIDIA_TEGRA20_EMC ,"nvidia,tegra20-emc" ), + COMPAT(NVIDIA_TEGRA20_EMC_TABLE, "nvidia,tegra20-emc-table"), };const char *fdtdec_get_compatible (enum fdt_compat_id id)
Signature · 1 line
1.7.7.3
PATCH v2 9/20 tegra: Add EMC support for optimal memory timings
Quoted 10 lines · Simon Glass
From: Jimmy Zhang <[email protected]>
Add support for setting up the memory controller parameters. Boards can set up an appropriate table in the device tree.
Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Adddebug()output to EMC
- Move EMC tables to device tree
This patch doesn't fully handle the device tree binding. There are two alternatives:
two-level:
emc {
...
emc-table at 190000 {
compatible = "nvidia,tegra20-emc-table";
...
};
emc-table at 380000 {
compatible = "nvidia,tegra20-emc-table";
...
};
};three-level:
emc {
...
nvidia,use-ram-code;
emc-tables {
nvidia,ram-code = <0>;
emc-table at 190000 {
compatible = "nvidia,tegra20-emc-table";
...
};
emc-table at 380000 {
compatible = "nvidia,tegra20-emc-table";
...
};
};
emc-tables {
nvidia,ram-code = <1>;
emc-table at 190000 {
compatible = "nvidia,tegra20-emc-table";
...
};
emc-table at 380000 {
compatible = "nvidia,tegra20-emc-table";
...
};
};
};Even if we don't fully implement support for both, we should detect the unsupported and flag an explicit error. But, it's pretty easy to support the other format.
BTW, does:
+ node = fdtdec_next_compatible(blob, node,
+ COMPAT_NVIDIA_TEGRA20_EMC_TABLE);
limit itself to searching child nodes?
Signature · 1 line
nvpublic
PATCH v2 9/20 tegra: Add EMC support for optimal memory timings
Hi Stephen,
Quoted 58 lines · Stephen Warren
Quoted 10 lines · Simon Glass
From: Jimmy Zhang <[email protected]>
Add support for setting up the memory controller parameters. Boards can set up an appropriate table in the device tree.
Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Adddebug()output to EMC
- Move EMC tables to device treeThis patch doesn't fully handle the device tree binding. There are two alternatives:
two-level:
emc {
? ?...
? ?emc-table at 190000 {
? ? ? ?compatible = "nvidia,tegra20-emc-table";
? ? ? ?...
? ?};
? ?emc-table at 380000 {
? ? ? ?compatible = "nvidia,tegra20-emc-table";
? ? ? ?...
? ?};
};three-level:
emc {
? ?...
? ?nvidia,use-ram-code;
? ?emc-tables {
? ? ? ?nvidia,ram-code = <0>;
? ? ? ?emc-table at 190000 {
? ? ? ? ? ?compatible = "nvidia,tegra20-emc-table"; ? ? ? ? ? ?...
? ? ? ?};
? ? ? ?emc-table at 380000 {
? ? ? ? ? ?compatible = "nvidia,tegra20-emc-table"; ? ? ? ? ? ?...
? ? ? ?};
? ?};
? ?emc-tables {
? ? ? ?nvidia,ram-code = <1>;
? ? ? ?emc-table at 190000 {
? ? ? ? ? ?compatible = "nvidia,tegra20-emc-table"; ? ? ? ? ? ?...
? ? ? ?};
? ? ? ?emc-table at 380000 {
? ? ? ? ? ?compatible = "nvidia,tegra20-emc-table"; ? ? ? ? ? ?...
? ? ? ?};
? ?};
};
Quoted 3 lines
Even if we don't fully implement support for both, we should detect the unsupported and flag an explicit error. But, it's pretty easy to support the other format.
OK I will look at which way to jump on this.
Quoted 7 lines
BTW, does:
+ ? ? ? ? ? ? ? node = fdtdec_next_compatible(blob, node,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?COMPAT_NVIDIA_TEGRA20_EMC_TABLE);limit itself to searching child nodes?
No; I will add that to the docs.
Regards,
Simon
Quoted 3 lines
--
nvpublic
PATCH v2 9/20 tegra: Add EMC support for optimal memory timings
Quoted 8 lines · Simon Glass
Hi Stephen,
Quoted 5 lines · Stephen Warren
Quoted 4 lines · Simon Glass
From: Jimmy Zhang <[email protected]>
Add support for setting up the memory controller parameters. Boards can set up an appropriate table in the device tree.
...
Quoted 26 lines
Quoted 26 lines
emc { ... nvidia,use-ram-code; emc-tables { nvidia,ram-code = <0>; emc-table at 190000 { compatible = "nvidia,tegra20-emc-table"; ... }; emc-table at 380000 { compatible = "nvidia,tegra20-emc-table"; ... }; }; emc-tables { nvidia,ram-code = <1>; emc-table at 190000 { compatible = "nvidia,tegra20-emc-table"; ... }; emc-table at 380000 { compatible = "nvidia,tegra20-emc-table"; ... }; }; };
...
Quoted 8 lines
Quoted 6 lines
BTW, does:
arch/arm/cpu/armv7/tegra2/emc.c new file +2
-0+ node =fdtdec_next_compatible (blob, node, +COMPAT_NVIDIA_TEGRA20_EMC_TABLE );limit itself to searching child nodes?
No; I will add that to the docs.
OK, in that case, you'll probably want to augment the EMC DT parsing code to validate that the node returned by fdtdec_next_compatible is underneath the same parent node (or perhaps add a new utility function to do this). Otherwise, if you search RAM code 0's node and there's no match, you could end up using a table from under RAM code 1's node.
Signature · 1 line
nvpublic
PATCH v2 9/20 tegra: Add EMC support for optimal memory timings
Hi Stephen,
Quoted 44 lines · Stephen Warren
Quoted 8 lines · Simon Glass
Hi Stephen,
Quoted 5 lines · Stephen Warren
Quoted 4 lines · Simon Glass
From: Jimmy Zhang <[email protected]>
Add support for setting up the memory controller parameters. Boards can set up an appropriate table in the device tree.
...
Quoted 26 lines
Quoted 26 lines
emc {
? ?...
? ?nvidia,use-ram-code;
? ?emc-tables {
? ? ? ?nvidia,ram-code = <0>;
? ? ? ?emc-table at 190000 {
? ? ? ? ? ?compatible = "nvidia,tegra20-emc-table"; ? ? ? ? ? ?...
? ? ? ?};
? ? ? ?emc-table at 380000 {
? ? ? ? ? ?compatible = "nvidia,tegra20-emc-table"; ? ? ? ? ? ?...
? ? ? ?};
? ?};
? ?emc-tables {
? ? ? ?nvidia,ram-code = <1>;
? ? ? ?emc-table at 190000 {
? ? ? ? ? ?compatible = "nvidia,tegra20-emc-table"; ? ? ? ? ? ?...
? ? ? ?};
? ? ? ?emc-table at 380000 {
? ? ? ? ? ?compatible = "nvidia,tegra20-emc-table"; ? ? ? ? ? ?...
? ? ? ?};
? ?};
};...
Quoted 7 lines
Quoted 6 lines
BTW, does:
+ ? ? ? ? ? ? ? node = fdtdec_next_compatible(blob, node,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?COMPAT_NVIDIA_TEGRA20_EMC_TABLE);limit itself to searching child nodes?
Quoted 7 lines
Quoted 1 line
No; I will add that to the docs.
OK, in that case, you'll probably want to augment the EMC DT parsing code to validate that the node returned by
fdtdec_next_compatibleis underneath the same parent node (or perhaps add a new utility function to do this). Otherwise, if you search RAM code 0's node and there's no match, you could end up using a table from under RAM code 1's node.
I forgot to mention that I did this in later versions (v4 and v5).
Regards,
Simon
Quoted 3 lines
--
nvpublic
PATCH v2 10/20 tegra: Add PMU to manage power supplies
In reply to Simon GlassFrom: Jimmy Zhang <[email protected]>
Power supplies must be adjusted in line with clock frequency. This code provides a simple routine to set the voltage to allow operation at maximum frequency.
- Split PMU code into separate TPS6586X driver
---
arch/arm/cpu/armv7/tegra2/Makefile | 1 + arch/arm/cpu/armv7/tegra2/pmu.c | 70 ++++++++++++++++++++++++++++++++ arch/arm/include/asm/arch-tegra2/pmu.h | 30 ++++++++++++++ 3 files changed, 101 insertions(+), 0 deletions(-) create mode 100644 arch/arm/cpu/armv7/tegra2/pmu.c create mode 100644 arch/arm/include/asm/arch-tegra2/pmu.h
arch/arm/cpu/armv7/tegra2/Makefile +1 -0
@@ -35,6 +35,7 @@ LIB = $(obj)lib$(SOC).o SOBJS := lowlevel_init.o COBJS-y := ap20.o board.o clock.o funcmux.o pinmux.o sys_info.o timer.o COBJS-$(CONFIG_TEGRA_CLOCK_SCALING) += emc.o +COBJS-$(CONFIG_TEGRA_PMU) += pmu.o COBJS-$(CONFIG_USB_EHCI_TEGRA) += usb.o COBJS := $(COBJS-y)
arch/arm/cpu/armv7/tegra2/pmu.c new file +70 -0
70 lines not on this page · raw message
arch/arm/include/asm/arch-tegra2/pmu.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* (C) Copyright 2010,2011 +* NVIDIA Corporation <www.nvidia.com> +* +* 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 +*/ + +#ifndef _ARCH_PMU_H_ +#define _ARCH_PMU_H_ + +/* Set core and CPU voltages to nominal levels */ +int pmu_set_nominal (void ); + +#endif /* _ARCH_PMU_H_ */
Signature · 1 line
1.7.7.3
PATCH v2 11/20 tegra: Set up PMU for Nvidia boards
In reply to Simon GlassAdjust PMU to permit maximum frequency operation.
---
Changes in v2:
- Check error return from pmu_set_nominal() in debug mode
board/nvidia/common/board.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
board/nvidia/common/board.c +6 -0
@@ -31,6 +31,8 @@#include <asm/arch/clk_rst.h> #include <asm/arch/clock.h> #include <asm/arch/pinmux.h> +#include <asm/arch/pmc.h> +#include <asm/arch/pmu.h> #include <asm/arch/uart.h> #include <spi.h> #include <asm/arch/usb.h>
@@ -75,6 +77,10 @@ int board_init(void)#error "You must define CONFIG_SYS_I2C_INIT_BOARD to use i2c on Nvidia boards"#endif i2c_init_board (); +# ifdef CONFIG_TEGRA_PMU +if (pmu_set_nominal ()) +debug ("Failed to select nominal voltages\n" ); +# endif #endif #ifdef CONFIG_USB_EHCI_TEGRA
Signature · 1 line
1.7.7.3
PATCH v2 12/20 tegra: Add warmboot implementation
In reply to Simon GlassFrom: Yen Lin <[email protected]>
Add code to set up the warm boot area in the Tegra CPU ready for a resume after suspend.
---
Changes in v2:
- Move structs shared between A9 and AVP into warmboot.h header file
- Remove unused crypto code
- Tidy SDRAM range check in warmboot_prepare_code()
- Use low-level clock functions in warmboot code instead of register access
arch/arm/cpu/armv7/tegra2/Makefile | 2 + arch/arm/cpu/armv7/tegra2/warmboot.c | 382 +++++++++++++++++++++++++++ arch/arm/cpu/armv7/tegra2/warmboot_avp.c | 250 +++++++++++++++++ arch/arm/cpu/armv7/tegra2/warmboot_avp.h | 81 ++++++ arch/arm/include/asm/arch-tegra2/warmboot.h | 150 +++++++++++ 5 files changed, 865 insertions(+), 0 deletions(-) create mode 100644 arch/arm/cpu/armv7/tegra2/warmboot.c create mode 100644 arch/arm/cpu/armv7/tegra2/warmboot_avp.c create mode 100644 arch/arm/cpu/armv7/tegra2/warmboot_avp.h create mode 100644 arch/arm/include/asm/arch-tegra2/warmboot.h
arch/arm/cpu/armv7/tegra2/Makefile +2 -0
@@ -27,6 +27,7 @@ # flags for any startup files it might use. CFLAGS_arch/arm/cpu/armv7/tegra2/ap20.o += -march=armv4t CFLAGS_arch/arm/cpu/armv7/tegra2/clock.o += -march=armv4t +CFLAGS_arch/arm/cpu/armv7/tegra2/warmboot_avp.o += -march=armv4t include $(TOPDIR)/config.mk
@@ -37,6 +38,7 @@ COBJS-y := ap20.o board.o clock.o funcmux.o pinmux.o sys_info.o timer.o COBJS-$(CONFIG_TEGRA_CLOCK_SCALING) += emc.o COBJS-$(CONFIG_TEGRA_PMU) += pmu.o COBJS-$(CONFIG_USB_EHCI_TEGRA) += usb.o +COBJS-$(CONFIG_TEGRA2_LP0) += crypto.o warmboot.o warmboot_avp.o COBJS := $(COBJS-y) SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
arch/arm/cpu/armv7/tegra2/warmboot.c new file +382 -0
382 lines not on this page · raw message
arch/arm/cpu/armv7/tegra2/warmboot_avp.c new file +250 -0
250 lines not on this page · raw message
arch/arm/cpu/armv7/tegra2/warmboot_avp.h new file +81 -0
81 lines not on this page · raw message
arch/arm/include/asm/arch-tegra2/warmboot.h new file +150 -0
150 lines not on this page · raw message
Signature · 1 line
1.7.7.3
PATCH v2 12/20 tegra: Add warmboot implementation
Quoted 6 lines · Simon Glass
From: Yen Lin <[email protected]>
Add code to set up the warm boot area in the Tegra CPU ready for a resume after suspend.
Signed-off-by Simon Glass <[email protected]>
Signature · 1 line
nvpublic
PATCH v2 13/20 tegra: Setup PMC scratch info from ap20 setup
In reply to Simon GlassFrom: Yen Lin <[email protected]>
Save SDRAM parameters into the warmboot scratch registers
---
arch/arm/cpu/armv7/tegra2/ap20.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/tegra2/ap20.c +6 -0
@@ -31,6 +31,7 @@#include <asm/arch/pmc.h> #include <asm/arch/pinmux.h> #include <asm/arch/scu.h> +#include <asm/arch/warmboot.h> #include <common.h> int tegra_get_chip_type (void )
@@ -322,6 +323,11 @@ void init_pmc_scratch(void)/* ODMDATA is for kernel use to determine RAM size, LP config, etc. */ writel (CONFIG_SYS_BOARD_ODMDATA , &pmc->pmc_scratch20); + +#ifdef CONFIG_TEGRA2_LP0 +/* save Sdram params to PMC 2, 4, and 24 for WB0 */ +warmboot_save_sdram_params (); +#endif }void tegra2_start (void )
Signature · 1 line
1.7.7.3
PATCH v2 14/20 tegra: Set up warmboot code on Nvidia boards
In reply to Simon GlassCall the function to put warmboot boot in a suitable place for resume.
---
board/nvidia/common/board.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
board/nvidia/common/board.c +6 -0
@@ -34,6 +34,7 @@#include <asm/arch/pmc.h> #include <asm/arch/pmu.h> #include <asm/arch/uart.h> +#include <asm/arch/warmboot.h> #include <spi.h> #include <asm/arch/usb.h> #include <i2c.h>
@@ -90,6 +91,11 @@ int board_init(void)board_usb_init (gd->fdt_blob);#endif +#ifdef CONFIG_TEGRA2_LP0 +/* prepare the WB code to LP0 location */ +warmboot_prepare_code (TEGRA_LP0_ADDR ,TEGRA_LP0_SIZE ); +#endif +return 0 ; }
Signature · 1 line
1.7.7.3
PATCH v2 15/20 Tegra2: Turn off power detect in board init
In reply to Simon GlassFrom: Wei Ni <[email protected]>
Tegra core power rail has leakage voltage around 0.2V while system in suspend mode. The source of the leakage should be coming from PMC power detect logic for IO rails power detection.
That can be disabled by writing a '0' to PWR_DET_LATCH followed by writing '0' to PWR_DET (APBDEV_PMC_PWR_DET_0).
---
board/nvidia/common/board.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-)
board/nvidia/common/board.c +18 -0
@@ -56,6 +56,21 @@ int timer_init(void) }/* +* Routine: power_det_init +* Description: turn off power detects +*/ +static void power_det_init (void ) +{ +#if defined(CONFIG_TEGRA2 ) +struct pmc_ctlr *const pmc = (struct pmc_ctlr *)TEGRA2_PMC_BASE ; + +/* turn off power detects */ +writel (0 , &pmc->pmc_pwr_det_latch); +writel (0 , &pmc->pmc_pwr_det); +#endif +} + +/* * Routine: board_init * Description: Early hardware init. */
@@ -73,6 +88,9 @@ int board_init(void)#endif /* boot param addr */ gd->bd->bi_boot_params = (NV_PA_SDRAM_BASE +0x100 ); + +power_det_init (); +#ifdef CONFIG_TEGRA2_I2C #ifndef CONFIG_SYS_I2C_INIT_BOARD #error "You must define CONFIG_SYS_I2C_INIT_BOARD to use i2c on Nvidia boards"
Signature · 1 line
1.7.7.3
PATCH v2 16/20 tegra: Add EMC settings for Seaboard
In reply to Simon GlassFrom: Jimmy Zhang <[email protected]>
Set Seaboard to optimal memory settings based on the SOC in use (T20 or T25).
---
Changes in v2:
- Move EMC tables to device tree
- Removed check for nominal voltage (not needed as it is done just before)
board/nvidia/common/Makefile | 1 + board/nvidia/common/board.c | 10 ++++++- board/nvidia/common/emc.c | 53 ++++++++++++++++++++++++++++++++++++++++++ board/nvidia/common/emc.h | 29 +++++++++++++++++++++++ 4 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 board/nvidia/common/emc.c create mode 100644 board/nvidia/common/emc.h
board/nvidia/common/Makefile +1 -0
@@ -27,6 +27,7 @@ LIB = $(obj)lib$(VENDOR).o COBJS-y += board.o COBJS-$(CONFIG_SPI_UART_SWITCH) += uart-spi-switch.o +COBJS-$(CONFIG_TEGRA_CLOCK_SCALING) += emc.o COBJS := $(COBJS-y) SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
board/nvidia/common/board.c +8 -2
@@ -30,6 +30,7 @@#include <asm/arch/board.h> #include <asm/arch/clk_rst.h> #include <asm/arch/clock.h> +#include <asm/arch/emc.h> #include <asm/arch/pinmux.h> #include <asm/arch/pmc.h> #include <asm/arch/pmu.h>
@@ -39,6 +40,7 @@#include <asm/arch/usb.h> #include <i2c.h> #include "board.h" +#include "emc.h" DECLARE_GLOBAL_DATA_PTR ;
@@ -99,8 +101,12 @@ int board_init(void)# ifdef CONFIG_TEGRA_PMU if (pmu_set_nominal ())debug ("Failed to select nominal voltages\n" ); -# endif -#endif +# ifdef CONFIG_TEGRA_CLOCK_SCALING +if (board_emc_init ()) +debug ("Memory controller init failed\n" ); +# endif +# endif /* CONFIG_TEGRA_PMU */ +#endif /* CONFIG_TEGRA2_I2C */ #ifdef CONFIG_USB_EHCI_TEGRA /* For USB GPIO PD0. for now, since we have no pinmux in fdt */
board/nvidia/common/emc.c new file +53 -0
53 lines not on this page · raw message
board/nvidia/common/emc.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* Copyright (c) 2011 The Chromium OS Authors. +* (C) Copyright 2010,2011 NVIDIA Corporation <www.nvidia.com> +* +* 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 +*/ + +#ifndef _NVIDIA_EMC_H_ +#define _NVIDIA_EMC_H_ + +int board_emc_init (void ); + +#endif
Signature · 1 line
1.7.7.3
PATCH v2 18/20 tegra: i2c: Add function to find DVC bus
In reply to Simon GlassAdd tegra_i2c_get_dvc_bus_num() to obtain the I2C bus number of DVC bus. This allows us to talk to the PMU.
---
Changes in v2:
- Add patch to find DVC bus number
arch/arm/include/asm/arch-tegra2/tegra2_i2c.h | 7 +++++++ drivers/i2c/tegra2_i2c.c | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 0 deletions(-)
arch/arm/include/asm/arch-tegra2/tegra2_i2c.h +7 -0
@@ -157,4 +157,11 @@ struct i2c_ctlr {#define I2C_INT_ARBITRATION_LOST_SHIFT 2#define I2C_INT_ARBITRATION_LOST_MASK (1 << I2C_INT_ARBITRATION_LOST_SHIFT) +/** +* Returns the bus number of the DVC controller +* +* @return number of bus, or -1 if there is no DVC active +*/ +int tegra_i2c_get_dvc_bus_num (void ); +#endif
drivers/i2c/tegra2_i2c.c +14 -0
@@ -549,3 +549,17 @@ int i2c_set_bus_num(unsigned int bus) return 0; }#endif + +int tegra_i2c_get_dvc_bus_num (void ) +{ +int i; + +for (i =0 ; i <CONFIG_SYS_MAX_I2C_BUS ; i++) { +struct i2c_bus *bus = &i2c_controllers[i]; + +if (bus->inited && bus->is_dvc) +return i; + } + +return -1 ; +}
Signature · 1 line
1.7.7.3
PATCH v2 18/20 tegra: i2c: Add function to find DVC bus
Hello Simon,
Quoted 11 lines · Simon Glass
Add
tegra_i2c_get_dvc_bus_num()to obtain the I2C bus number of DVC bus. This allows us to talk to the PMU.Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Add patch to find DVC bus numberarch/arm/include/asm/arch-tegra2/tegra2_i2c.h | 7 +++++++ drivers/i2c/tegra2_i2c.c | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 0 deletions(-)
just one minor comment, beside of this:
arch/arm/include/asm/arch-tegra2/tegra2_i2c.h struct i2c_ctlr { · line 160
Quoted 9 lines
arch/arm/include/asm/arch-tegra2/tegra2_i2c.h +1
-0@@ -157,4 +157,11 @@ struct i2c_ctlr {#define I2C_INT_ARBITRATION_LOST_SHIFT 2#define I2C_INT_ARBITRATION_LOST_MASK (1 << I2C_INT_ARBITRATION_LOST_SHIFT) +/**
wrong comment style ...
bye,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH v2 18/20 tegra: i2c: Add function to find DVC bus
Hi Heiko,
Quoted 16 lines · Heiko Schocher
Hello Simon,
Quoted 11 lines · Simon Glass
Add
tegra_i2c_get_dvc_bus_num()to obtain the I2C bus number of DVC bus. This allows us to talk to the PMU.Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Add patch to find DVC bus numberarch/arm/include/asm/arch-tegra2/tegra2_i2c.h | 7 +++++++ drivers/i2c/tegra2_i2c.c | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 0 deletions(-)
Quoted 5 lines
just one minor comment, beside of this:
Acked-by Heiko Schocher <[email protected]>Review
Quoted 1 line
(quoted diff) +0
-0
b/arch/arm/include/asm/arch-tegra2/tegra2_i2c.h
Quoted 6 lines
arch/arm/include/asm/arch-tegra2/tegra2_i2c.h struct i2c_ctlr { · line 158
Quoted 6 lines
index 86f6a01..4816cc7 100644
arch/arm/include/asm/arch-tegra2/tegra2_i2c.h +0
-0@@ -157,4 +157,11 @@ struct i2c_ctlr {#define I2C_INT_ARBITRATION_LOST_SHIFT 2#define I2C_INT_ARBITRATION_LOST_MASK (1 <<
I2C_INT_ARBITRATION_LOST_SHIFT)
Quoted 4 lines
arch/arm/include/asm/arch-tegra2/tegra2_i2c.h struct i2c_ctlr { · line 160
Quoted 2 lines
arch/arm/include/asm/arch-tegra2/tegra2_i2c.h +1
-0+/** wrong comment style ...
I am trying to follow the Doxygen convention. Many editors like this also and display the parameters etc. nicely highlighted. Does yours? Hoping it encourages more function prototype comments in U-Boot and reduce the time I need to spend wading through code to see what a function is supposed to do.
regards,
Simon
Quoted 6 lines
bye,
Heiko
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH v2 18/20 tegra: i2c: Add function to find DVC bus
Hello Simon,
Quoted 30 lines · Simon Glass
Hi Heiko,
Quoted 11 lines · Heiko Schocher
Hello Simon,
Quoted 8 lines · Simon Glass
Add
tegra_i2c_get_dvc_bus_num()to obtain the I2C bus number of DVC bus. This allows us to talk to the PMU.Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Add patch to find DVC bus numberQuoted 8 lines
Quoted 3 lines
arch/arm/include/asm/arch-tegra2/tegra2_i2c.h | 7 +++++++ drivers/i2c/tegra2_i2c.c | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 0 deletions(-)just one minor comment, beside of this:
Acked-by Heiko Schocher <[email protected]>Review
Quoted 1 line
(quoted diff) +0
-0
b/arch/arm/include/asm/arch-tegra2/tegra2_i2c.hQuoted 6 lines
arch/arm/include/asm/arch-tegra2/tegra2_i2c.h struct i2c_ctlr { · line 158
Quoted 6 lines
index 86f6a01..4816cc7 100644
arch/arm/include/asm/arch-tegra2/tegra2_i2c.h +0
-0@@ -157,4 +157,11 @@ struct i2c_ctlr {#define I2C_INT_ARBITRATION_LOST_SHIFT 2#define I2C_INT_ARBITRATION_LOST_MASK (1 <<
I2C_INT_ARBITRATION_LOST_SHIFT)
Quoted 7 lines
Quoted 2 lines
arch/arm/include/asm/arch-tegra2/tegra2_i2c.h struct i2c_ctlr { · line 160
Quoted 1 line
arch/arm/include/asm/arch-tegra2/tegra2_i2c.h +1
-0+/** wrong comment style ...
I am trying to follow the Doxygen convention. Many editors like this also and display the parameters etc. nicely highlighted. Does yours? Hoping it encourages more function prototype comments in U-Boot and reduce the time I need to spend wading through code to see what a function is supposed to do.
added Wolfgang to cc:
Do we want to accept this? If so, it must be documented somewhere!
bye,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH v2 20/20 tegra: Enable LP0 on Seaboard
In reply to Simon GlassThis enables LP0 to support suspend / resume on Seaboard.
---
include/configs/seaboard.h | 8 ++++++++ include/configs/tegra2-common.h | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 0 deletions(-)
include/configs/seaboard.h +8 -0
@@ -25,6 +25,14 @@#define __CONFIG_H#include <asm/sizes.h> + +/* LP0 suspend / resume */ +#define CONFIG_TEGRA2_LP0 +#define CONFIG_AES +#define CONFIG_TEGRA_PMU +#define CONFIG_TPS6586X_POWER +#define CONFIG_TEGRA_CLOCK_SCALING +#include "tegra2-common.h" #define CONFIG_SYS_DCACHE_OFF
include/configs/tegra2-common.h +17 -0
@@ -26,6 +26,14 @@#include <asm/sizes.h> /* +* QUOTE(m) will evaluate to a string version of the value of the macro m +* passed in. The extra level of indirection here is to first evaluate the +* macro m before applying the quoting operator. +*/ +#define QUOTE_ (m) #m +#define QUOTE (m) QUOTE_(m) + +/* * High Level Configuration Options */ #define CONFIG_ARMCORTEXA9 /* This is an ARM V7 CPU core */
@@ -50,6 +58,15 @@#define CONFIG_CMDLINE_TAG /* enable passing of ATAGs */ #define CONFIG_OF_LIBFDT /* enable passing of devicetree */ +#ifdef CONFIG_TEGRA2_LP0 +#define TEGRA_LP0_ADDR 0x1C406000 +#define TEGRA_LP0_SIZE 0x2000 +#define TEGRA_LP0_VEC \ + "lp0_vec=" QUOTE(TEGRA_LP0_SIZE) "@" QUOTE(TEGRA_LP0_ADDR) " " +#else +#define TEGRA_LP0_VEC +#endif +/* Environment */ #define CONFIG_ENV_SIZE 0x2000/* Total Size Environment */
Signature · 1 line
1.7.7.3
PATCH v2 20/20 tegra: Enable LP0 on Seaboard
include/configs/tegra2-common.h line 34
Quoted 10 lines · On Friday 13 January 2012 16:35:35 Simon Glass wrote:
include/configs/tegra2-common.h +6
-0/* +* QUOTE(m) will evaluate to a string version of the value of the macro m +* passed in. The extra level of indirection here is to first evaluate +* the macro m before applying the quoting operator. +*/ +#define QUOTE_ (m) #m +#define QUOTE (m) QUOTE_(m)
we uses to have MK_STR/XMK_STR in common code, but that seems to have gone by the wayside. but arches/boards still have it, so might as well use that naming convention.
-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/20120114/d4b8ba19/attachment.pgp>
PATCH v2 20/20 tegra: Enable LP0 on Seaboard
In reply to Simon GlassQuoted 3 lines · Simon Glass
This enables LP0 to support suspend / resume on Seaboard.
Signed-off-by Simon Glass <[email protected]>
FYI, I've read through all the patches in this series and besides the comments I've already made, I think they're OK. I didn't review some of the changes that weren't Tegra-specific, and didn't do a super-detailed review, but I think it's all OK.
Out of curiosity, have you tested this warm boot within a mainline U-Boot with the ChromeOS kernels? I know we don't support LP modes in mainline kernels yet.
Signature · 1 line
nvpublic
v2 cover tegra: warmboot (suspend / resume) support
In reply to Simon Glassthere are a few patches here where the Author hasn't provided his s-o-b tag, so that'll need fixing ...
-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/20120114/4f575405/attachment.pgp>
v2 cover tegra: warmboot (suspend / resume) support
+Nvidia warmboot authors
Hi Tom,
Quoted 3 lines · Mike Frysinger
there are a few patches here where the Author hasn't provided his s-o-b tag, so that'll need fixing ...
-mike
I am going to post a new v3 series - can you please organise people to replace to each patch they write with their s-o-b tags if they are happy with it?
Regards,
Simon
v2 cover tegra: warmboot (suspend / resume) support
Will do.
Jimmy/Wei/Yen - I'll send you an update when Simon posts v3 to u-boot at lists.denx.de, and you'll have to respond with a review (Acked-by) and Signed-off-by for each part of the patch series you originally authored.
Thanks,
Tom
Quoted 17 lines
-----Original Message-----
From: sjg at google.com [mailto:sjg at google.com] On Behalf Of Simon Glass
Sent: Friday, March 30, 2012 12:24 PM
To: Mike Frysinger
Cc: u-boot at lists.denx.de; Tom Warren; Jimmy Zhang; Yen Lin; Wei Ni
Subject: Re: [U-Boot] [PATCH v2 0/20] tegra: warmboot (suspend / resume) support+Nvidia warmboot authors
Hi Tom,
Quoted 3 lines · Mike Frysinger
there are a few patches here where the Author hasn't provided his s-o-b tag, so that'll need fixing ...
-mike
Quoted 6 lines
I am going to post a new v3 series - can you please organise people to replace to each patch they write with their s-o-b tags if they are happy with it?
Regards,
Simon
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------