Skip to contentSkip to conversation

Rework current Tegra support

PATCH Superseded Lucas Stach 4 participants 41 messages Mar 1, 2013 – Mar 10, 2013

Subsystems (3)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover Rework current Tegra support

This patchset converts the current ad-hoc implementation within the Tegra arch into proper barebox drivers. It slightly enhances functionality, but mostly this is a cleanup to provide a good base for further work.

Lucas Stach (7):
tegra: move address map to tegra20-silicon.h
tegra: remove debug_ll
tegra: switch to ARMv7 cpu type
tegra: add blank tegra20 platform init
tegra: add driver for the clock and reset module
tegra: add proper timer driver
tegra: add power management controller driver

 arch/arm/Kconfig                                   |   5 +-
 arch/arm/boards/toshiba-ac100/board.c              |   2 +-
 arch/arm/boards/toshiba-ac100/serial.c             |   2 +-
 arch/arm/mach-tegra/Makefile                       |   6 +-
 arch/arm/mach-tegra/clock.c                        |  56 ----
 arch/arm/mach-tegra/include/mach/clkdev.h          |   7 +
 arch/arm/mach-tegra/include/mach/debug_ll.h        |  42 ---
 arch/arm/mach-tegra/include/mach/iomap.h           | 292 ---------------------
 arch/arm/mach-tegra/include/mach/tegra20-silicon.h | 229 ++++++++++++++++
 arch/arm/mach-tegra/reset.c                        |  39 ---
 arch/arm/mach-tegra/tegra20-car.c                  | 123 +++++++++
 arch/arm/mach-tegra/tegra20-pmc.c                  |  89 +++++++
 arch/arm/mach-tegra/tegra20-timer.c                | 117 +++++++++
 arch/arm/mach-tegra/tegra20.c                      |  38 +++
 14 files changed, 612 insertions(+), 435 deletions(-)
 delete mode 100644 arch/arm/mach-tegra/clock.c
 create mode 100644 arch/arm/mach-tegra/include/mach/clkdev.h
 delete mode 100644 arch/arm/mach-tegra/include/mach/debug_ll.h
 delete mode 100644 arch/arm/mach-tegra/include/mach/iomap.h
 create mode 100644 arch/arm/mach-tegra/include/mach/tegra20-silicon.h
 delete mode 100644 arch/arm/mach-tegra/reset.c
 create mode 100644 arch/arm/mach-tegra/tegra20-car.c
 create mode 100644 arch/arm/mach-tegra/tegra20-pmc.c
 create mode 100644 arch/arm/mach-tegra/tegra20-timer.c
 create mode 100644 arch/arm/mach-tegra/tegra20.c
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 1/7 tegra: move address map to tegra20-silicon.h

The address map is specific to the Tegra20 SoC. Move it to a file with an appropriate name. While at it clarify and fix the definitions.

---
 arch/arm/boards/toshiba-ac100/board.c              |   2 +-
 arch/arm/boards/toshiba-ac100/serial.c             |   2 +-
 arch/arm/mach-tegra/clock.c                        |   2 +-
 arch/arm/mach-tegra/include/mach/debug_ll.h        |   2 +-
 arch/arm/mach-tegra/include/mach/iomap.h           | 292 ---------------------
 arch/arm/mach-tegra/include/mach/tegra20-silicon.h | 229 ++++++++++++++++
 arch/arm/mach-tegra/reset.c                        |   2 +-
 7 files changed, 234 insertions(+), 297 deletions(-)
 delete mode 100644 arch/arm/mach-tegra/include/mach/iomap.h
 create mode 100644 arch/arm/mach-tegra/include/mach/tegra20-silicon.h
arch/arm/boards/toshiba-ac100/board.c +1 -1
index 0eb85c5..af397cc 100644
@@ -21,7 +21,7 @@
 #include <asm/armlinux.h>
 #include <sizes.h>
 #include <usb/ehci.h>
-#include <mach/iomap.h>
+#include <mach/tegra20-silicon.h>
 
 static int ac100_mem_init(void)
 {
arch/arm/boards/toshiba-ac100/serial.c +1 -1
index 880270d..cdd47ab 100644
@@ -21,7 +21,7 @@
 #include <ns16550.h>
 #include <asm/io.h>
 #include <asm/common.h>
-#include <mach/iomap.h>
+#include <mach/tegra20-silicon.h>
 
 static struct NS16550_plat serial_plat = {
 	.clock = 0x75 * 115200 * 16 /* MODE_X_DIV */,
arch/arm/mach-tegra/clock.c +1 -1
index 82065ee..8a7525d 100644
@@ -26,7 +26,7 @@
 #include <linux/clk.h>
 #include <init.h>
 #include <asm/io.h>
-#include <mach/iomap.h>
+#include <mach/tegra20-silicon.h>
 
 static void __iomem *timer_reg_base = (void __iomem *) (TEGRA_TMR1_BASE);
 
arch/arm/mach-tegra/include/mach/debug_ll.h +1 -1
index 290ad58..4a54e44 100644
@@ -22,7 +22,7 @@
 #define __INCLUDE_ARCH_DEBUG_LL_H__
 
 #include <asm/io.h>
-#include <mach/iomap.h>
+#include <mach/tegra20-silicon.h>
 
 #define DEBUG_LL_UART_ADDR	TEGRA_UARTA_BASE
 #define DEBUG_LL_UART_RSHFT	2
arch/arm/mach-tegra/include/mach/iomap.h deleted +0 -292

292 lines not on this page · raw message

arch/arm/mach-tegra/include/mach/tegra20-silicon.h new file +229 -0

229 lines not on this page · raw message

arch/arm/mach-tegra/reset.c +1 -1
index 91f9b3b..73d7ca2 100644
@@ -22,7 +22,7 @@
 
 #include <common.h>
 #include <asm/io.h>
-#include <mach/iomap.h>
+#include <mach/tegra20-silicon.h>
 
 #define PRM_RSTCTRL		TEGRA_PMC_BASE
 
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

Re: [PATCH 1/7] tegra: move address map to tegra20-silicon.h

Quoted 3 lines · Lucas Stach

The address map is specific to the Tegra20 SoC. Move it to a file with an appropriate name. While at it clarify and fix the definitions.

folloow the kernel

Quoted 620 lines
---
 arch/arm/boards/toshiba-ac100/board.c              |   2 +-
 arch/arm/boards/toshiba-ac100/serial.c             |   2 +-
 arch/arm/mach-tegra/clock.c                        |   2 +-
 arch/arm/mach-tegra/include/mach/debug_ll.h        |   2 +-
 arch/arm/mach-tegra/include/mach/iomap.h           | 292 ---------------------
 arch/arm/mach-tegra/include/mach/tegra20-silicon.h | 229 ++++++++++++++++
 arch/arm/mach-tegra/reset.c                        |   2 +-
 7 files changed, 234 insertions(+), 297 deletions(-)
 delete mode 100644 arch/arm/mach-tegra/include/mach/iomap.h
 create mode 100644 arch/arm/mach-tegra/include/mach/tegra20-silicon.h
arch/arm/boards/toshiba-ac100/board.c +1 -1
index 0eb85c5..af397cc 100644
@@ -21,7 +21,7 @@
 #include <asm/armlinux.h>
 #include <sizes.h>
 #include <usb/ehci.h>
-#include <mach/iomap.h>
+#include <mach/tegra20-silicon.h>
 
 static int ac100_mem_init(void)
 {
arch/arm/boards/toshiba-ac100/serial.c +1 -1
index 880270d..cdd47ab 100644
@@ -21,7 +21,7 @@
 #include <ns16550.h>
 #include <asm/io.h>
 #include <asm/common.h>
-#include <mach/iomap.h>
+#include <mach/tegra20-silicon.h>
 
 static struct NS16550_plat serial_plat = {
 	.clock = 0x75 * 115200 * 16 /* MODE_X_DIV */,
arch/arm/mach-tegra/clock.c +1 -1
index 82065ee..8a7525d 100644
@@ -26,7 +26,7 @@
 #include <linux/clk.h>
 #include <init.h>
 #include <asm/io.h>
-#include <mach/iomap.h>
+#include <mach/tegra20-silicon.h>
 
 static void __iomem *timer_reg_base = (void __iomem *) (TEGRA_TMR1_BASE);
 
arch/arm/mach-tegra/include/mach/debug_ll.h +1 -1
index 290ad58..4a54e44 100644
@@ -22,7 +22,7 @@
 #define __INCLUDE_ARCH_DEBUG_LL_H__
 
 #include <asm/io.h>
-#include <mach/iomap.h>
+#include <mach/tegra20-silicon.h>
 
 #define DEBUG_LL_UART_ADDR	TEGRA_UARTA_BASE
 #define DEBUG_LL_UART_RSHFT	2
arch/arm/mach-tegra/include/mach/iomap.h deleted +0 -292
deleted file mode 100644
index ba478e7..0000000
@@ -1,292 +0,0 @@
-/*
- * arch/arm/mach-tegra/include/mach/iomap.h
- *
- * Copyright (C) 2010 Google, Inc.
- *
- * Author:
- *	Colin Cross <[email protected]>
- *	Erik Gilling <[email protected]>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#ifndef __MACH_TEGRA_IOMAP_H
-#define __MACH_TEGRA_IOMAP_H
-
-#include <sizes.h>
-
-#define TEGRA_IRAM_BASE			0x40000000
-#define TEGRA_IRAM_SIZE			SZ_256K
-
-#define TEGRA_HOST1X_BASE		0x50000000
-#define TEGRA_HOST1X_SIZE		0x24000
-
-#define TEGRA_ARM_PERIF_BASE		0x50040000
-#define TEGRA_ARM_PERIF_SIZE		SZ_8K
-
-#define TEGRA_ARM_PL310_BASE		0x50043000
-#define TEGRA_ARM_PL310_SIZE		SZ_4K
-
-#define TEGRA_ARM_INT_DIST_BASE		0x50041000
-#define TEGRA_ARM_INT_DIST_SIZE		SZ_4K
-
-#define TEGRA_MPE_BASE			0x54040000
-#define TEGRA_MPE_SIZE			SZ_256K
-
-#define TEGRA_VI_BASE			0x54080000
-#define TEGRA_VI_SIZE			SZ_256K
-
-#define TEGRA_ISP_BASE			0x54100000
-#define TEGRA_ISP_SIZE			SZ_256K
-
-#define TEGRA_DISPLAY_BASE		0x54200000
-#define TEGRA_DISPLAY_SIZE		SZ_256K
-
-#define TEGRA_DISPLAY2_BASE		0x54240000
-#define TEGRA_DISPLAY2_SIZE		SZ_256K
-
-#define TEGRA_HDMI_BASE			0x54280000
-#define TEGRA_HDMI_SIZE			SZ_256K
-
-#define TEGRA_GART_BASE			0x58000000
-#define TEGRA_GART_SIZE			SZ_32M
-
-#define TEGRA_RES_SEMA_BASE		0x60001000
-#define TEGRA_RES_SEMA_SIZE		SZ_4K
-
-#define TEGRA_HDMI_BASE			0x54280000
-#define TEGRA_HDMI_SIZE			SZ_256K
-
-#define TEGRA_GART_BASE			0x58000000
-#define TEGRA_GART_SIZE			SZ_32M
-
-#define TEGRA_RES_SEMA_BASE		0x60001000
-#define TEGRA_RES_SEMA_SIZE		SZ_4K
-
-#define TEGRA_ARB_SEMA_BASE		0x60002000
-#define TEGRA_ARB_SEMA_SIZE		SZ_4K
-
-#define TEGRA_PRIMARY_ICTLR_BASE	0x60004000
-#define TEGRA_PRIMARY_ICTLR_SIZE	64
-
-#define TEGRA_ARBGNT_ICTLR_BASE		0x60004040
-#define TEGRA_ARBGNT_ICTLR_SIZE		192
-
-#define TEGRA_SECONDARY_ICTLR_BASE	0x60004100
-#define TEGRA_SECONDARY_ICTLR_SIZE	64
-
-#define TEGRA_TERTIARY_ICTLR_BASE	0x60004200
-#define TEGRA_TERTIARY_ICTLR_SIZE	64
-
-#define TEGRA_QUATERNARY_ICTLR_BASE	0x60004300
-#define TEGRA_QUATERNARY_ICTLR_SIZE	64
-
-#define TEGRA_TMR1_BASE			0x60005000
-#define TEGRA_TMR1_SIZE			8
-
-#define TEGRA_TMR2_BASE			0x60005008
-#define TEGRA_TMR2_SIZE			8
-
-#define TEGRA_TMRUS_BASE		0x60005010
-#define TEGRA_TMRUS_SIZE		64
-
-#define TEGRA_TMR3_BASE			0x60005050
-#define TEGRA_TMR3_SIZE			8
-
-#define TEGRA_TMR4_BASE			0x60005058
-#define TEGRA_TMR4_SIZE			8
-
-#define TEGRA_CLK_RESET_BASE		0x60006000
-#define TEGRA_CLK_RESET_SIZE		SZ_4K
-
-#define TEGRA_FLOW_CTRL_BASE		0x60007000
-#define TEGRA_FLOW_CTRL_SIZE		20
-
-#define TEGRA_AHB_DMA_BASE		0x60008000
-#define TEGRA_AHB_DMA_SIZE		SZ_4K
-
-#define TEGRA_AHB_DMA_CH0_BASE		0x60009000
-#define TEGRA_AHB_DMA_CH0_SIZE		32
-
-#define TEGRA_APB_DMA_BASE		0x6000A000
-#define TEGRA_APB_DMA_SIZE		SZ_4K
-
-#define TEGRA_APB_DMA_CH0_BASE		0x6000B000
-#define TEGRA_APB_DMA_CH0_SIZE		32
-
-#define TEGRA_AHB_GIZMO_BASE		0x6000C004
-#define TEGRA_AHB_GIZMO_SIZE		0x10C
-
-#define TEGRA_STATMON_BASE		0x6000C400
-#define TEGRA_STATMON_SIZE		SZ_1K
-
-#define TEGRA_GPIO_BASE			0x6000D000
-#define TEGRA_GPIO_SIZE			SZ_4K
-
-#define TEGRA_EXCEPTION_VECTORS_BASE    0x6000F000
-#define TEGRA_EXCEPTION_VECTORS_SIZE    SZ_4K
-
-#define TEGRA_VDE_BASE		0x6001A000
-#define TEGRA_VDE_SIZE		(SZ_8K + SZ_4K - SZ_256)
-
-#define TEGRA_APB_MISC_BASE		0x70000000
-#define TEGRA_APB_MISC_SIZE		SZ_4K
-
-#define TEGRA_APB_MISC_DAS_BASE		0x70000c00
-#define TEGRA_APB_MISC_DAS_SIZE		SZ_128
-
-#define TEGRA_AC97_BASE			0x70002000
-#define TEGRA_AC97_SIZE			SZ_512
-
-#define TEGRA_SPDIF_BASE		0x70002400
-#define TEGRA_SPDIF_SIZE		SZ_512
-
-#define TEGRA_I2S1_BASE			0x70002800
-#define TEGRA_I2S1_SIZE			SZ_256
-
-#define TEGRA_I2S2_BASE			0x70002A00
-#define TEGRA_I2S2_SIZE			SZ_256
-
-#define TEGRA_UARTA_BASE		0x70006000
-#define TEGRA_UARTA_SIZE		64
-
-#define TEGRA_UARTB_BASE		0x70006040
-#define TEGRA_UARTB_SIZE		64
-
-#define TEGRA_UARTC_BASE		0x70006200
-#define TEGRA_UARTC_SIZE		SZ_256
-
-#define TEGRA_UARTD_BASE		0x70006300
-#define TEGRA_UARTD_SIZE		SZ_256
-
-#define TEGRA_UARTE_BASE		0x70006400
-#define TEGRA_UARTE_SIZE		SZ_256
-
-#define TEGRA_NAND_BASE			0x70008000
-#define TEGRA_NAND_SIZE			SZ_256
-
-#define TEGRA_HSMMC_BASE		0x70008500
-#define TEGRA_HSMMC_SIZE		SZ_256
-
-#define TEGRA_SNOR_BASE			0x70009000
-#define TEGRA_SNOR_SIZE			SZ_4K
-
-#define TEGRA_PWFM_BASE			0x7000A000
-#define TEGRA_PWFM_SIZE			SZ_256
-
-#define TEGRA_PWFM0_BASE		0x7000A000
-#define TEGRA_PWFM0_SIZE		4
-
-#define TEGRA_PWFM1_BASE		0x7000A010
-#define TEGRA_PWFM1_SIZE		4
-
-#define TEGRA_PWFM2_BASE		0x7000A020
-#define TEGRA_PWFM2_SIZE		4
-
-#define TEGRA_PWFM3_BASE		0x7000A030
-#define TEGRA_PWFM3_SIZE		4
-
-#define TEGRA_MIPI_BASE			0x7000B000
-#define TEGRA_MIPI_SIZE			SZ_256
-
-#define TEGRA_I2C_BASE			0x7000C000
-#define TEGRA_I2C_SIZE			SZ_256
-
-#define TEGRA_TWC_BASE			0x7000C100
-#define TEGRA_TWC_SIZE			SZ_256
-
-#define TEGRA_SPI_BASE			0x7000C380
-#define TEGRA_SPI_SIZE			48
-
-#define TEGRA_I2C2_BASE			0x7000C400
-#define TEGRA_I2C2_SIZE			SZ_256
-
-#define TEGRA_I2C3_BASE			0x7000C500
-#define TEGRA_I2C3_SIZE			SZ_256
-
-#define TEGRA_OWR_BASE			0x7000C600
-#define TEGRA_OWR_SIZE			80
-
-#define TEGRA_DVC_BASE			0x7000D000
-#define TEGRA_DVC_SIZE			SZ_512
-
-#define TEGRA_SPI1_BASE			0x7000D400
-#define TEGRA_SPI1_SIZE			SZ_512
-
-#define TEGRA_SPI2_BASE			0x7000D600
-#define TEGRA_SPI2_SIZE			SZ_512
-
-#define TEGRA_SPI3_BASE			0x7000D800
-#define TEGRA_SPI3_SIZE			SZ_512
-
-#define TEGRA_SPI4_BASE			0x7000DA00
-#define TEGRA_SPI4_SIZE			SZ_512
-
-#define TEGRA_RTC_BASE			0x7000E000
-#define TEGRA_RTC_SIZE			SZ_256
-
-#define TEGRA_KBC_BASE			0x7000E200
-#define TEGRA_KBC_SIZE			SZ_256
-
-#define TEGRA_PMC_BASE			0x7000E400
-#define TEGRA_PMC_SIZE			SZ_256
-
-#define TEGRA_MC_BASE			0x7000F000
-#define TEGRA_MC_SIZE			SZ_1K
-
-#define TEGRA_EMC_BASE			0x7000F400
-#define TEGRA_EMC_SIZE			SZ_1K
-
-#define TEGRA_FUSE_BASE			0x7000F800
-#define TEGRA_FUSE_SIZE			SZ_1K
-
-#define TEGRA_KFUSE_BASE		0x7000FC00
-#define TEGRA_KFUSE_SIZE		SZ_1K
-
-#define TEGRA_CSITE_BASE		0x70040000
-#define TEGRA_CSITE_SIZE		SZ_256K
-
-#define TEGRA_USB_BASE			0xC5000000
-#define TEGRA_USB_SIZE			SZ_16K
-
-#define TEGRA_USB2_BASE			0xC5004000
-#define TEGRA_USB2_SIZE			SZ_16K
-
-#define TEGRA_USB3_BASE			0xC5008000
-#define TEGRA_USB3_SIZE			SZ_16K
-
-#define TEGRA_SDMMC1_BASE		0xC8000000
-#define TEGRA_SDMMC1_SIZE		SZ_512
-
-#define TEGRA_SDMMC2_BASE		0xC8000200
-#define TEGRA_SDMMC2_SIZE		SZ_512
-
-#define TEGRA_SDMMC3_BASE		0xC8000400
-#define TEGRA_SDMMC3_SIZE		SZ_512
-
-#define TEGRA_SDMMC4_BASE		0xC8000600
-#define TEGRA_SDMMC4_SIZE		SZ_512
-
-#if defined(CONFIG_TEGRA_DEBUG_UART_NONE)
-# define TEGRA_DEBUG_UART_BASE 0
-#elif defined(CONFIG_TEGRA_DEBUG_UARTA)
-# define TEGRA_DEBUG_UART_BASE TEGRA_UARTA_BASE
-#elif defined(CONFIG_TEGRA_DEBUG_UARTB)
-# define TEGRA_DEBUG_UART_BASE TEGRA_UARTB_BASE
-#elif defined(CONFIG_TEGRA_DEBUG_UARTC)
-# define TEGRA_DEBUG_UART_BASE TEGRA_UARTC_BASE
-#elif defined(CONFIG_TEGRA_DEBUG_UARTD)
-# define TEGRA_DEBUG_UART_BASE TEGRA_UARTD_BASE
-#elif defined(CONFIG_TEGRA_DEBUG_UARTE)
-# define TEGRA_DEBUG_UART_BASE TEGRA_UARTE_BASE
-#endif
-
-#endif
arch/arm/mach-tegra/include/mach/tegra20-silicon.h new file +229 -0
new file mode 100644
index 0000000..d7140fb
@@ -0,0 +1,229 @@
+/*
+ * Copyright (C) 2010 Google, Inc.
+ * Copyright (C) 2012 Lucas Stach <[email protected]>
+ *
+ * Author:
+ *	Colin Cross <[email protected]>
+ *	Erik Gilling <[email protected]>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
+ */
+
+#ifndef __MACH_TEGRA_IOMAP_H
+#define __MACH_TEGRA_IOMAP_H
+
+#include <sizes.h>
+
+#define TEGRA_EMEM_BASE			0x0
+#define TEGRA_EMEM_SIZE			SZ_1G
+
+#define TEGRA_IRAM_BASE			0x40000000
+#define TEGRA_IRAM_SIZE			SZ_256K
+
+#define TEGRA_ARM_PERIPHBASE		0x50040000
+#define TEGRA_ARM_PERIPHSIZE		SZ_8K
+
+#define TEGRA_ARM_INT_DIST_BASE		TEGRA_ARM_PERIPHBASE + 0x1000
+#define TEGRA_ARM_INT_DIST_SIZE		SZ_4K
+
+#define TEGRA_ARM_PL310_BASE		TEGRA_ARM_PERIPHBASE + 0x3000
+#define TEGRA_ARM_PL310_SIZE		SZ_4K
+
+#define TEGRA_HOST1X_BASE		0x50000000
+#define TEGRA_HOST1X_SIZE		SZ_64M
+
+#define TEGRA_MPE_BASE			TEGRA_HOST1X_BASE + 0x40000
+#define TEGRA_MPE_SIZE			SZ_256K
+
+#define TEGRA_VI_BASE			TEGRA_HOST1X_BASE + 0x80000
+#define TEGRA_VI_SIZE			SZ_256K
+
+#define TEGRA_ISP_BASE			TEGRA_HOST1X_BASE + 0x100000
+#define TEGRA_ISP_SIZE			SZ_256K
+
+#define TEGRA_DISPLAY_BASE		TEGRA_HOST1X_BASE + 0x200000
+#define TEGRA_DISPLAY_SIZE		SZ_256K
+
+#define TEGRA_DISPLAY2_BASE		TEGRA_HOST1X_BASE + 0x240000
+#define TEGRA_DISPLAY2_SIZE		SZ_256K
+
+#define TEGRA_HDMI_BASE			TEGRA_HOST1X_BASE + 0x280000
+#define TEGRA_HDMI_SIZE			SZ_256K
+
+#define TEGRA_TVO_BASE			TEGRA_HOST1X_BASE + 0x2C0000
+#define TGERA_TVO_SIZE			SZ_256K
+
+#define TEGRA_DSI_BASE			TEGRA_HOST1X_BASE + 0x300000
+#define TEGRA_DSI_SIZE			SZ_256K
+
+#define TEGRA_GART_BASE			0x58000000
+#define TEGRA_GART_SIZE			SZ_32M
+
+#define TEGRA_PPSB_BASE			0x60000000
+#define TEGRA_PPSB_SIZE			SZ_256M
+
+#define TEGRA_RES_SEMA_BASE		TEGRA_PPSB_BASE + 0x1000
+#define TEGRA_RES_SEMA_SIZE		SZ_4K
+
+#define TEGRA_ARB_SEMA_BASE		TEGRA_PPSB_BASE + 0x2000
+#define TEGRA_ARB_SEMA_SIZE		SZ_4K
+
+#define TEGRA_PRIMARY_ICTLR_BASE	TEGRA_PPSB_BASE + 0x4000
+#define TEGRA_PRIMARY_ICTLR_SIZE	64
+
+#define TEGRA_ARBGNT_ICTLR_BASE		TEGRA_PPSB_BASE + 0x4040
+#define TEGRA_ARBGNT_ICTLR_SIZE		192
+
+#define TEGRA_SECONDARY_ICTLR_BASE	TEGRA_PPSB_BASE + 0x4100
+#define TEGRA_SECONDARY_ICTLR_SIZE	64
+
+#define TEGRA_TERTIARY_ICTLR_BASE	TEGRA_PPSB_BASE + 0x4200
+#define TEGRA_TERTIARY_ICTLR_SIZE	64
+
+#define TEGRA_QUATERNARY_ICTLR_BASE	TEGRA_PPSB_BASE + 0x4300
+#define TEGRA_QUATERNARY_ICTLR_SIZE	64
+
+#define TEGRA_TMR1_BASE			TEGRA_PPSB_BASE + 0x5000
+#define TEGRA_TMR1_SIZE			8
+
+#define TEGRA_TMR2_BASE			TEGRA_PPSB_BASE + 0x5008
+#define TEGRA_TMR2_SIZE			8
+
+#define TEGRA_TMRUS_BASE		TEGRA_PPSB_BASE + 0x5010
+#define TEGRA_TMRUS_SIZE		64
+
+#define TEGRA_TMR3_BASE			TEGRA_PPSB_BASE + 0x5050
+#define TEGRA_TMR3_SIZE			8
+
+#define TEGRA_TMR4_BASE			TEGRA_PPSB_BASE + 0x5058
+#define TEGRA_TMR4_SIZE			8
+
+#define TEGRA_CLK_RESET_BASE		TEGRA_PPSB_BASE + 0x6000
+#define TEGRA_CLK_RESET_SIZE		SZ_4K
+
+#define TEGRA_FLOW_CTRL_BASE		TEGRA_PPSB_BASE + 0x7000
+#define TEGRA_FLOW_CTRL_SIZE		20
+
+#define TEGRA_AHB_DMA_BASE		TEGRA_PPSB_BASE + 0x8000
+#define TEGRA_AHB_DMA_SIZE		SZ_4K
+
+#define TEGRA_GPIO_BASE			TEGRA_PPSB_BASE + 0xD000
+#define TEGRA_GPIO_SIZE			SZ_4K
+
+#define TEGRA_EXCEPTION_VECTORS_BASE	TEGRA_PPSB_BASE + 0xF000
+#define TEGRA_EXCEPTION_VECTORS_SIZE	SZ_4K
+
+#define TEGRA_APB_BASE			0x70000000
+#define TEGRA_APB_SIZE			SZ_256M
+
+#define TEGRA_UARTA_BASE		TEGRA_APB_BASE + 0x6000
+#define TEGRA_UARTA_SIZE		64
+
+#define TEGRA_UARTB_BASE		TEGRA_APB_BASE + 0x6040
+#define TEGRA_UARTB_SIZE		64
+
+#define TEGRA_UARTC_BASE		TEGRA_APB_BASE + 0x6200
+#define TEGRA_UARTC_SIZE		256
+
+#define TEGRA_UARTD_BASE		TEGRA_APB_BASE + 0x6300
+#define TEGRA_UARTD_SIZE		256
+
+#define TEGRA_UARTE_BASE		TEGRA_APB_BASE + 0x6400
+#define TEGRA_UARTE_SIZE		256
+
+#define TEGRA_NAND_BASE			TEGRA_APB_BASE + 0x8000
+#define TEGRA_NAND_SIZE			256
+
+#define TEGRA_SNOR_BASE			TEGRA_APB_BASE + 0x9000
+#define TEGRA_SNOR_SIZE			SZ_4K
+
+#define TEGRA_I2C_BASE			TEGRA_APB_BASE + 0xC000
+#define TEGRA_I2C_SIZE			256
+
+#define TEGRA_TWC_BASE			TEGRA_APB_BASE + 0xC100
+#define TEGRA_TWC_SIZE			256
+
+#define TEGRA_SPI_BASE			TEGRA_APB_BASE + 0xC380
+#define TEGRA_SPI_SIZE			48
+
+#define TEGRA_I2C2_BASE			TEGRA_APB_BASE + 0xC400
+#define TEGRA_I2C2_SIZE			256
+
+#define TEGRA_I2C3_BASE			TEGRA_APB_BASE + 0xC500
+#define TEGRA_I2C3_SIZE			256
+
+#define TEGRA_OWR_BASE			TEGRA_APB_BASE + 0xC600
+#define TEGRA_OWR_SIZE			80
+
+#define TEGRA_DVC_BASE			TEGRA_APB_BASE + 0xD000
+#define TEGRA_DVC_SIZE			512
+
+#define TEGRA_SPI1_BASE			TEGRA_APB_BASE + 0xD400
+#define TEGRA_SPI1_SIZE			512
+
+#define TEGRA_SPI2_BASE			TEGRA_APB_BASE + 0xD600
+#define TEGRA_SPI2_SIZE			512
+
+#define TEGRA_SPI3_BASE			TEGRA_APB_BASE + 0xD800
+#define TEGRA_SPI3_SIZE			512
+
+#define TEGRA_SPI4_BASE			TEGRA_APB_BASE + 0xDA00
+#define TEGRA_SPI4_SIZE			512
+
+#define TEGRA_RTC_BASE			TEGRA_APB_BASE + 0xE000
+#define TEGRA_RTC_SIZE			256
+
+#define TEGRA_KBC_BASE			TEGRA_APB_BASE + 0xE200
+#define TEGRA_KBC_SIZE			256
+
+#define TEGRA_PMC_BASE			TEGRA_APB_BASE + 0xE400
+#define TEGRA_PMC_SIZE			256
+
+#define TEGRA_MC_BASE			TEGRA_APB_BASE + 0xF000
+#define TEGRA_MC_SIZE			SZ_1K
+
+#define TEGRA_EMC_BASE			TEGRA_APB_BASE + 0xF400
+#define TEGRA_EMC_SIZE			SZ_1K
+
+#define TEGRA_FUSE_BASE			TEGRA_APB_BASE + 0xF800
+#define TEGRA_FUSE_SIZE			SZ_1K
+
+#define TEGRA_KFUSE_BASE		TEGRA_APB_BASE + 0xFC00
+#define TEGRA_KFUSE_SIZE		SZ_1K
+
+#define TEGRA_CSITE_BASE		TEGRA_APB_BASE + 0x40000
+#define TEGRA_CSITE_SIZE		SZ_256K
+
+#define TEGRA_AHB_BASE			0xC0000000
+#define TEGRA_AHB_SIZE			SZ_256M
+
+#define TEGRA_USB_BASE			TEGRA_AHB_BASE + 0x5000000
+#define TEGRA_USB_SIZE			SZ_16K
+
+#define TEGRA_USB2_BASE			TEGRA_AHB_BASE + 0x5004000
+#define TEGRA_USB2_SIZE			SZ_16K
+
+#define TEGRA_USB3_BASE			TEGRA_AHB_BASE + 0x5008000
+#define TEGRA_USB3_SIZE			SZ_16K
+
+#define TEGRA_SDMMC1_BASE		TEGRA_AHB_BASE + 0x8000000
+#define TEGRA_SDMMC1_SIZE		512
+
+#define TEGRA_SDMMC2_BASE		TEGRA_AHB_BASE + 0x8000200
+#define TEGRA_SDMMC2_SIZE		512
+
+#define TEGRA_SDMMC3_BASE		TEGRA_AHB_BASE + 0x8000400
+#define TEGRA_SDMMC3_SIZE		512
+
+#define TEGRA_SDMMC4_BASE		TEGRA_AHB_BASE + 0x8000600
+#define TEGRA_SDMMC4_SIZE		512
+
+#endif
arch/arm/mach-tegra/reset.c +1 -1
index 91f9b3b..73d7ca2 100644
@@ -22,7 +22,7 @@
 
 #include <common.h>
 #include <asm/io.h>
-#include <mach/iomap.h>
+#include <mach/tegra20-silicon.h>
 
 #define PRM_RSTCTRL		TEGRA_PMC_BASE
 
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#3 lore raw

Re: [PATCH 1/7] tegra: move address map to tegra20-silicon.h

Am Freitag, den 01.03.2013, 14:17 +0100 schrieb Jean-Christophe PLAGNIOL-VILLARD:

Quoted 6 lines · Lucas Stach
Quoted 3 lines

The address map is specific to the Tegra20 SoC. Move it to a file with an appropriate name. While at it clarify and fix the definitions.

folloow the kernel

The Tegra kernel is fully device tree enabled and doesn't need any of those defines, as the hardware mapping is encoded in the DT. While I'm certainly aiming for the same thing in barebox, it's just not the right thing to do at this state of development.

Quoted 4 lines
Quoted 4 lines

---
[...]

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#4 lore raw

Re: [PATCH 1/7] tegra: move address map to tegra20-silicon.h

Quoted 7 lines · Lucas Stach

Am Freitag, den 01.03.2013, 14:17 +0100 schrieb Jean-Christophe PLAGNIOL-VILLARD:

Quoted 5 lines · Lucas Stach
Quoted 3 lines

The address map is specific to the Tegra20 SoC. Move it to a file with an appropriate name. While at it clarify and fix the definitions.

Quoted 6 lines
Quoted 1 line

folloow the kernel

The Tegra kernel is fully device tree enabled and doesn't need any of those defines, as the hardware mapping is encoded in the DT. While I'm certainly aiming for the same thing in barebox, it's just not the right thing to do at this state of development.

Is there any benefit in the renaming of the iomap.h file to tegra20-silicon.h?

I think no. The name iomap.h is used in the linux kernel so it is natural that just the same file will have the same name it barebox. It is more comfortable for kernel developer see the kernel header files in bootloader with the same kernel name.

Anyway the number of kernel Tegra developers is much more than number of barebox Tegra developers :)))

Quoted 10 lines
Quoted 4 lines
Quoted 4 lines

---
[...]

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Signature · 7 lines
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

PATCH 2/7 tegra: remove debug_ll

In reply to Lucas Stach

Without some kind of initialisation those LL debug functions are mostly useless. We might want them when booting from the AVP, but for this to work they need some serious rework, so move them out of the way for now.

---
 arch/arm/Kconfig                            |  1 -
 arch/arm/mach-tegra/include/mach/debug_ll.h | 42 -----------------------------
 2 files changed, 43 deletions(-)
 delete mode 100644 arch/arm/mach-tegra/include/mach/debug_ll.h
arch/arm/Kconfig +0 -1
index 28332ec..0ae2daa 100644
@@ -108,7 +108,6 @@ config ARCH_VERSATILE
 config ARCH_TEGRA
 	bool "Nvidia Tegra-based boards"
 	select CPU_ARM926T
-	select HAS_DEBUG_LL
 
 endchoice
 
arch/arm/mach-tegra/include/mach/debug_ll.h deleted +0 -42

42 lines not on this page · raw message

Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw

Re: [PATCH 2/7] tegra: remove debug_ll

Quoted 5 lines · Lucas Stach

Without some kind of initialisation those LL debug functions are mostly useless. We might want them when booting from the AVP, but for this to work they need some serious rework, so move them out of the way for now.

NACK

this is usefull for second stage

Quoted 74 lines
---
 arch/arm/Kconfig                            |  1 -
 arch/arm/mach-tegra/include/mach/debug_ll.h | 42 -----------------------------
 2 files changed, 43 deletions(-)
 delete mode 100644 arch/arm/mach-tegra/include/mach/debug_ll.h
arch/arm/Kconfig +0 -1
index 28332ec..0ae2daa 100644
@@ -108,7 +108,6 @@ config ARCH_VERSATILE
 config ARCH_TEGRA
 	bool "Nvidia Tegra-based boards"
 	select CPU_ARM926T
-	select HAS_DEBUG_LL
 
 endchoice
 
arch/arm/mach-tegra/include/mach/debug_ll.h deleted +0 -42
deleted file mode 100644
index 4a54e44..0000000
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2011 Antony Pavlov <[email protected]>
- *
- * This file is part of barebox.
- * 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 version 2
- * as published by the Free Software Foundation.
- *
- * 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.
- *
- */
-
-/** @file
- *  This File contains declaration for early output support
- */
-#ifndef __INCLUDE_ARCH_DEBUG_LL_H__
-#define __INCLUDE_ARCH_DEBUG_LL_H__
-
-#include <asm/io.h>
-#include <mach/tegra20-silicon.h>
-
-#define DEBUG_LL_UART_ADDR	TEGRA_UARTA_BASE
-#define DEBUG_LL_UART_RSHFT	2
-
-#define rbr		(0 << DEBUG_LL_UART_RSHFT)
-#define lsr		(5 << DEBUG_LL_UART_RSHFT)
-#define LSR_THRE	0x20	/* Xmit holding register empty */
-
-static inline void PUTC_LL(char ch)
-{
-	while (!(__raw_readb(DEBUG_LL_UART_ADDR + lsr) & LSR_THRE))
-		;
-
-	__raw_writeb(ch, DEBUG_LL_UART_ADDR + rbr);
-}
-
-#endif /* __INCLUDE_ARCH_DEBUG_LL_H__ */
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#7 lore raw

Re: [PATCH 2/7] tegra: remove debug_ll

In reply to Lucas Stach
Quoted 3 lines · Lucas Stach

Without some kind of initialisation those LL debug functions are mostly useless. We might want them when booting from the AVP, but for this to work they need some serious rework, so move them out of the way for now.

All debug_ll functions also from other architectures assume the uarts to be initialized already, so as Jean-Christophe mentioned, they are for second stage or JTAG where the debugger startup script initialized the uarts

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#8 lore raw

PATCH 3/7 tegra: switch to ARMv7 cpu type

In reply to Lucas Stach

Main barebox is running on the A9 cluster. Use the correct ISA.

---
 arch/arm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/Kconfig +1 -1
index 0ae2daa..1c41e44 100644
@@ -107,7 +107,7 @@ config ARCH_VERSATILE
 
 config ARCH_TEGRA
 	bool "Nvidia Tegra-based boards"
-	select CPU_ARM926T
+	select CPU_V7
 
 endchoice
 
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#9 lore raw

PATCH 4/7 tegra: add blank tegra20 platform init

In reply to Lucas Stach

Devices will get initialised here, as soon as the drivers are added.

---
 arch/arm/mach-tegra/Makefile  |  1 +
 arch/arm/mach-tegra/tegra20.c | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+)
 create mode 100644 arch/arm/mach-tegra/tegra20.c
arch/arm/mach-tegra/Makefile +1 -0
index 11915e5..7777d0a 100644
@@ -1,2 +1,3 @@
 obj-y += clock.o
 obj-y += reset.o
+obj-y += tegra20.o
arch/arm/mach-tegra/tegra20.c new file +26 -0
new file mode 100644
index 0000000..bf99b16
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2013 Lucas Stach <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <common.h>
+#include <init.h>
+#include <mach/tegra20-silicon.h>
+
+static int tegra20_init(void)
+{
+	return 0;
+}
+
+postcore_initcall(tegra20_init);
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#10 lore raw

Re: [PATCH 4/7] tegra: add blank tegra20 platform init

Quoted 1 line · Lucas Stach

Devices will get initialised here, as soon as the drivers are added.

NACK do it at the first time

Quoted 56 lines
---
 arch/arm/mach-tegra/Makefile  |  1 +
 arch/arm/mach-tegra/tegra20.c | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+)
 create mode 100644 arch/arm/mach-tegra/tegra20.c
arch/arm/mach-tegra/Makefile +1 -0
index 11915e5..7777d0a 100644
@@ -1,2 +1,3 @@
 obj-y += clock.o
 obj-y += reset.o
+obj-y += tegra20.o
arch/arm/mach-tegra/tegra20.c new file +26 -0
new file mode 100644
index 0000000..bf99b16
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2013 Lucas Stach <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <common.h>
+#include <init.h>
+#include <mach/tegra20-silicon.h>
+
+static int tegra20_init(void)
+{
+	return 0;
+}
+
+postcore_initcall(tegra20_init);
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#11 lore raw

PATCH 5/7 tegra: add driver for the clock and reset module

In reply to Lucas Stach

Only a basic set of clocks is supported as of now.

---
 arch/arm/Kconfig                          |   2 +
 arch/arm/mach-tegra/Makefile              |   1 +
 arch/arm/mach-tegra/include/mach/clkdev.h |   7 ++
 arch/arm/mach-tegra/tegra20-car.c         | 117 ++++++++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra20.c             |   4 +
 5 files changed, 131 insertions(+)
 create mode 100644 arch/arm/mach-tegra/include/mach/clkdev.h
 create mode 100644 arch/arm/mach-tegra/tegra20-car.c
arch/arm/Kconfig +2 -0
index 1c41e44..a3828e1 100644
@@ -108,6 +108,8 @@ config ARCH_VERSATILE
 config ARCH_TEGRA
 	bool "Nvidia Tegra-based boards"
 	select CPU_V7
+	select COMMON_CLK
+	select CLKDEV_LOOKUP
 
 endchoice
 
arch/arm/mach-tegra/Makefile +1 -0
index 7777d0a..3391528 100644
@@ -1,3 +1,4 @@
 obj-y += clock.o
 obj-y += reset.o
 obj-y += tegra20.o
+obj-y += tegra20-car.o
arch/arm/mach-tegra/include/mach/clkdev.h new file +7 -0
new file mode 100644
index 0000000..04b37a8
@@ -0,0 +1,7 @@
+#ifndef __ASM_MACH_CLKDEV_H
+#define __ASM_MACH_CLKDEV_H
+
+#define __clk_get(clk) ({ 1; })
+#define __clk_put(clk) do { } while (0)
+
+#endif
arch/arm/mach-tegra/tegra20-car.c new file +117 -0

117 lines not on this page · raw message

arch/arm/mach-tegra/tegra20.c +4 -0
index bf99b16..08c6758 100644
@@ -20,6 +20,10 @@
 
 static int tegra20_init(void)
 {
+	add_generic_device("tegra20-car", DEVICE_ID_SINGLE, NULL,
+			   TEGRA_CLK_RESET_BASE, TEGRA_CLK_RESET_SIZE,
+			   IORESOURCE_MEM, NULL);
+
 	return 0;
 }
 
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#12 lore raw

Re: [PATCH 5/7] tegra: add driver for the clock and reset module

Quoted 102 lines · Lucas Stach

Only a basic set of clocks is supported as of now.

---
 arch/arm/Kconfig                          |   2 +
 arch/arm/mach-tegra/Makefile              |   1 +
 arch/arm/mach-tegra/include/mach/clkdev.h |   7 ++
 arch/arm/mach-tegra/tegra20-car.c         | 117 ++++++++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra20.c             |   4 +
 5 files changed, 131 insertions(+)
 create mode 100644 arch/arm/mach-tegra/include/mach/clkdev.h
 create mode 100644 arch/arm/mach-tegra/tegra20-car.c
arch/arm/Kconfig +2 -0
index 1c41e44..a3828e1 100644
@@ -108,6 +108,8 @@ config ARCH_VERSATILE
 config ARCH_TEGRA
 	bool "Nvidia Tegra-based boards"
 	select CPU_V7
+	select COMMON_CLK
+	select CLKDEV_LOOKUP
 
 endchoice
 
arch/arm/mach-tegra/Makefile +1 -0
index 7777d0a..3391528 100644
@@ -1,3 +1,4 @@
 obj-y += clock.o
 obj-y += reset.o
 obj-y += tegra20.o
+obj-y += tegra20-car.o
arch/arm/mach-tegra/include/mach/clkdev.h new file +7 -0
new file mode 100644
index 0000000..04b37a8
@@ -0,0 +1,7 @@
+#ifndef __ASM_MACH_CLKDEV_H
+#define __ASM_MACH_CLKDEV_H
+
+#define __clk_get(clk) ({ 1; })
+#define __clk_put(clk) do { } while (0)
+
+#endif
arch/arm/mach-tegra/tegra20-car.c new file +48 -0
new file mode 100644
index 0000000..95b3051
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved.
+ * Copyright (C) 2013 Lucas Stach <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * @file
+ * @brief Device driver for the Tegra 20 clock and reset (CAR) controller
+ */
+
+#include <common.h>
+#include <init.h>
+#include <io.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+
+/* Register definitions */
+#define OSC_CTRL 0x50
+#define OSC_CTRL_OSC_FREQ_MASK		(3 << 30)
+#define OSC_CTRL_PLL_REF_DIV_MASK	(3 << 28)
+
+static void __iomem *car_base;
+
+enum tegra20_clks {
+	cpu, ac97 = 3, rtc, timer, uarta, gpio = 8, sdmmc2, i2s1 = 11, i2c1,
+	ndflash, sdmmc1, sdmmc4, twc, pwm, i2s2, epp, gr2d = 21, usbd, isp,
+	gr3d, ide, disp2, disp1, host1x, vcp, cache2 = 31, mem, ahbdma, apbdma,
+	kbc = 36, stat_mon, pmc, fuse, kfuse, sbc1, nor, spi, sbc2, xio, sbc3,
+	dvc, dsi, mipi = 50, hdmi, csi, tvdac, i2c2, uartc, emc = 57, usb2,
+	usb3, mpe, vde, bsea, bsev, speedo, uartd, uarte, i2c3, sbc4, sdmmc3,
+	pex, owr, afi, csite, pcie_xclk, avpucq = 75, la, irama = 84, iramb,
+	iramc, iramd, cram2, audio_2x, clk_d, csus = 92, cdev1, cdev2,
+	uartb = 96, vfir, spdif_in, spdif_out, vi, vi_sensor, tvo, cve,
+	osc, clk_32k, clk_m, sclk, cclk, hclk, pclk, blink, pll_a, pll_a_out0,
+	pll_c, pll_c_out1, pll_d, pll_d_out0, pll_e, pll_m, pll_m_out1,
+	pll_p, pll_p_out1, pll_p_out2, pll_p_out3, pll_p_out4, pll_u,

arch/arm/mach-tegra/tegra20-car.c line 58

Quoted 10 lines
arch/arm/mach-tegra/tegra20-car.c new file +10 -0
+	pll_x, audio, pll_ref, twd, clk_max,
+};
+
+static struct clk *clks[clk_max];
+
+static unsigned long get_osc_frequency(void)
+{
+	u32 osc_ctrl = readl(car_base + OSC_CTRL);
+
+	switch (osc_ctrl & OSC_CTRL_OSC_FREQ_MASK) {

OSC_CTRL_OSC_FREQ_MASK is defined as 3 << 30, The result will never be one of the values below.

arch/arm/mach-tegra/tegra20-car.c line 71

Quoted 13 lines
arch/arm/mach-tegra/tegra20-car.c new file +13 -0
+	case 0:
+		return 13000000;
+	case 1:
+		return 19200000;
+	case 2:
+		return 12000000;
+	case 3:
+		return 26000000;
+	default:
+		return 0;
+	}
+}
+

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#13 lore raw

Re: [PATCH 5/7] tegra: add driver for the clock and reset module

Am Freitag, den 01.03.2013, 18:26 +0100 schrieb Sascha Hauer:

Quoted 10 lines

arch/arm/mach-tegra/tegra20-car.c line 58

Quoted 6 lines
arch/arm/mach-tegra/tegra20-car.c new file +6 -0
+
+static unsigned long get_osc_frequency(void)
+{
+	u32 osc_ctrl = readl(car_base + OSC_CTRL);
+
+	switch (osc_ctrl & OSC_CTRL_OSC_FREQ_MASK) {

OSC_CTRL_OSC_FREQ_MASK is defined as 3 << 30, The result will never be one of the values below.

Quoted 14 lines

arch/arm/mach-tegra/tegra20-car.c line 71

Quoted 13 lines
arch/arm/mach-tegra/tegra20-car.c new file +13 -0
+	case 0:
+		return 13000000;
+	case 1:
+		return 19200000;
+	case 2:
+		return 12000000;
+	case 3:
+		return 26000000;
+	default:
+		return 0;
+	}
+}
+

Grr, correct. Thanks for spotting. Just got bitten by my system using a 13MHz crystal.

Regards,
Lucas

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#14 lore raw

PATCH 6/7 tegra: add proper timer driver

In reply to Lucas Stach

Replace the ad-hoc clocksource implementation with a proper driver for the Tegra 20 timer. This driver is able to do the required hardware initialisation itself.

---
 arch/arm/mach-tegra/Makefile        |   2 +-
 arch/arm/mach-tegra/clock.c         |  56 -----------------
 arch/arm/mach-tegra/tegra20-car.c   |   6 ++
 arch/arm/mach-tegra/tegra20-timer.c | 117 ++++++++++++++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra20.c       |   4 ++
 5 files changed, 128 insertions(+), 57 deletions(-)
 delete mode 100644 arch/arm/mach-tegra/clock.c
 create mode 100644 arch/arm/mach-tegra/tegra20-timer.c
arch/arm/mach-tegra/Makefile +1 -1
index 3391528..6aa219c 100644
@@ -1,4 +1,4 @@
-obj-y += clock.o
 obj-y += reset.o
 obj-y += tegra20.o
 obj-y += tegra20-car.o
+obj-y += tegra20-timer.o
arch/arm/mach-tegra/clock.c deleted +0 -56

56 lines not on this page · raw message

arch/arm/mach-tegra/tegra20-car.c +6 -0
index 95b3051..89fa424 100644
@@ -24,7 +24,9 @@
 #include <init.h>
 #include <io.h>
 #include <linux/clk.h>
+#include <linux/clkdev.h>
 #include <linux/err.h>
+#include <mach/tegra20-silicon.h>
 
 /* Register definitions */
 #define OSC_CTRL 0x50
@@ -93,6 +95,10 @@ static int tegra20_car_probe(struct device_d *dev)
 	/* timer is a gate, but as it's enabled by BOOTROM we needn't worry */
 	clks[timer] = clk_fixed_factor("timer", "clk_m", 1, 1);
 
+
+	/* device to clock links */
+	clkdev_add_physbase(clks[timer], TEGRA_TMR1_BASE, NULL);
+
 	return 0;
 }
 
arch/arm/mach-tegra/tegra20-timer.c new file +117 -0

117 lines not on this page · raw message

arch/arm/mach-tegra/tegra20.c +4 -0
index 08c6758..eccc7b8 100644
@@ -24,6 +24,10 @@ static int tegra20_init(void)
 			   TEGRA_CLK_RESET_BASE, TEGRA_CLK_RESET_SIZE,
 			   IORESOURCE_MEM, NULL);
 
+	add_generic_device("tegra20-timer", DEVICE_ID_SINGLE, NULL,
+			   TEGRA_TMR1_BASE, TEGRA_TMR1_SIZE,
+			   IORESOURCE_MEM, NULL);
+
 	return 0;
 }
 
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#15 lore raw

Re: [PATCH 6/7] tegra: add proper timer driver

Quoted 150 lines · Lucas Stach

Replace the ad-hoc clocksource implementation with a proper driver for the Tegra 20 timer. This driver is able to do the required hardware initialisation itself.

---
 arch/arm/mach-tegra/Makefile        |   2 +-
 arch/arm/mach-tegra/clock.c         |  56 -----------------
 arch/arm/mach-tegra/tegra20-car.c   |   6 ++
 arch/arm/mach-tegra/tegra20-timer.c | 117 ++++++++++++++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra20.c       |   4 ++
 5 files changed, 128 insertions(+), 57 deletions(-)
 delete mode 100644 arch/arm/mach-tegra/clock.c
 create mode 100644 arch/arm/mach-tegra/tegra20-timer.c
arch/arm/mach-tegra/Makefile +1 -1
index 3391528..6aa219c 100644
@@ -1,4 +1,4 @@
-obj-y += clock.o
 obj-y += reset.o
 obj-y += tegra20.o
 obj-y += tegra20-car.o
+obj-y += tegra20-timer.o
arch/arm/mach-tegra/clock.c deleted +0 -56
deleted file mode 100644
index 8a7525d..0000000
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2011 Antony Pavlov <[email protected]>
- *
- * This file is part of barebox.
- * 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 version 2
- * as published by the Free Software Foundation.
- *
- * 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.
- *
- */
-
-/**
- * @file
- * @brief Clocksource based on Tegra internal timer
- */
-
-#include <common.h>
-#include <clock.h>
-#include <linux/list.h>
-#include <linux/clk.h>
-#include <init.h>
-#include <asm/io.h>
-#include <mach/tegra20-silicon.h>
-
-static void __iomem *timer_reg_base = (void __iomem *) (TEGRA_TMR1_BASE);
-
-#define timer_writel(value, reg) \
-	__raw_writel(value, (u32)timer_reg_base + (reg))
-#define timer_readl(reg) \
-	__raw_readl((u32)timer_reg_base + (reg))
-
-static uint64_t tegra_clocksource_read(void)
-{
-	return timer_readl(0x10);
-}
-
-static struct clocksource cs = {
-	.read	= tegra_clocksource_read,
-	.mask	= 0xffffffff,
-};
-
-/* FIXME: here we have no initialization. All initialization made by U-Boot */
-static int clocksource_init(void)
-{
-	cs.mult = clocksource_hz2mult(1000000, cs.shift);
-	init_clock(&cs);
-
-	return 0;
-}
-core_initcall(clocksource_init);
arch/arm/mach-tegra/tegra20-car.c +6 -0
index 95b3051..89fa424 100644
@@ -24,7 +24,9 @@
 #include <init.h>
 #include <io.h>
 #include <linux/clk.h>
+#include <linux/clkdev.h>
 #include <linux/err.h>
+#include <mach/tegra20-silicon.h>
 
 /* Register definitions */
 #define OSC_CTRL 0x50
@@ -93,6 +95,10 @@ static int tegra20_car_probe(struct device_d *dev)
 	/* timer is a gate, but as it's enabled by BOOTROM we needn't worry */
 	clks[timer] = clk_fixed_factor("timer", "clk_m", 1, 1);
 
+
+	/* device to clock links */
+	clkdev_add_physbase(clks[timer], TEGRA_TMR1_BASE, NULL);
+
 	return 0;
 }
 
arch/arm/mach-tegra/tegra20-timer.c new file +32 -0
new file mode 100644
index 0000000..62af5d2
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2013 Lucas Stach <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * @file
+ * @brief Device driver for the Tegra 20 timer, which exposes a clocksource.
+ */
+
+#include <common.h>
+#include <clock.h>
+#include <init.h>
+#include <io.h>
+#include <linux/clk.h>
+
+/* register definitions */
+#define TIMERUS_CNTR_1US	0x10
+#define TIMERUS_USEC_CFG	0x14
+
+static void __iomem *timer_base;

arch/arm/mach-tegra/tegra20-timer.c line 42

Quoted 10 lines
arch/arm/mach-tegra/tegra20-timer.c new file +10 -0
+
+static uint64_t tegra20_timer_cs_read(void)
+{
+	return readl(timer_base + TIMERUS_CNTR_1US);
+}
+
+static struct clocksource cs = {
+	.read	= tegra20_timer_cs_read,
+	.mask	= CLOCKSOURCE_MASK(32),
+	.mult	= 1000,

no calculate it

Quoted 34 lines
arch/arm/mach-tegra/tegra20-timer.c new file +34 -0
+};
+
+static int tegra20_timer_probe(struct device_d *dev)
+{
+	struct clk *timer_clk;
+	unsigned long rate;
+
+	/* use only one timer */
+	if (timer_base)
+		return -EBUSY;
+
+	timer_base = dev_request_mem_region(dev, 0);
+	if (!timer_base) {
+		dev_err(dev, "could not get memory region\n");
+		return -ENODEV;
+	}
+
+	timer_clk = clk_get(dev, NULL);
+	if (!timer_clk) {
+		dev_err(dev, "could not get clock\n");
+		return -ENODEV;
+	}
+
+	clk_enable(timer_clk);
+
+	/*
+	 * calibrate timer to run at 1MHz
+	 * TIMERUS_USEC_CFG selects the scale down factor with bits [0:7]
+	 * representing the divisor and bits [8:15] representing the dividend
+	 * each in n+1 form.
+	 */
+	rate = clk_get_rate(timer_clk);
+	switch (rate) {
+	case 12000000:

arch/arm/mach-tegra/tegra20-timer.c line 86

Quoted 10 lines
arch/arm/mach-tegra/tegra20-timer.c new file +10 -0
+		writel(0x000b, timer_base + TIMERUS_USEC_CFG);
+		break;
+	case 13000000:
+		writel(0x000c, timer_base + TIMERUS_USEC_CFG);
+		break;
+	case 19200000:
+		writel(0x045f, timer_base + TIMERUS_USEC_CFG);
+		break;
+	case 26000000:
+		writel(0x0019, timer_base + TIMERUS_USEC_CFG);

you put 4 write NO

just 1

arch/arm/mach-tegra/tegra20-timer.c line 91

Quoted 5 lines
arch/arm/mach-tegra/tegra20-timer.c new file +5 -0
+		break;
+	default:
+		dev_warn(dev, "unknown timer clock rate\n");
+		break;
+	}

here

Quoted 49 lines
arch/arm/mach-tegra/tegra20-timer.c new file +26 -0
+
+	init_clock(&cs);
+
+	return 0;
+}
+
+static __maybe_unused struct of_device_id tegra20_timer_dt_ids[] = {
+	{
+		.compatible = "nvidia,tegra20-timer",
+	}, {
+		/* sentinel */
+	}
+};
+
+static struct driver_d tegra20_timer_driver = {
+	.probe	= tegra20_timer_probe,
+	.name	= "tegra20-timer",
+	.of_compatible = DRV_OF_COMPAT(tegra20_timer_dt_ids),
+};
+
+static int tegra20_timer_init(void)
+{
+	return platform_driver_register(&tegra20_timer_driver);
+}
+
+coredevice_initcall(tegra20_timer_init);
arch/arm/mach-tegra/tegra20.c +4 -0
index 08c6758..eccc7b8 100644
@@ -24,6 +24,10 @@ static int tegra20_init(void)
 			   TEGRA_CLK_RESET_BASE, TEGRA_CLK_RESET_SIZE,
 			   IORESOURCE_MEM, NULL);
 
+	add_generic_device("tegra20-timer", DEVICE_ID_SINGLE, NULL,
+			   TEGRA_TMR1_BASE, TEGRA_TMR1_SIZE,
+			   IORESOURCE_MEM, NULL);
+
 	return 0;
 }
 
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#16 lore raw

Re: [PATCH 6/7] tegra: add proper timer driver

In reply to Lucas Stach
Quoted 20 lines · Lucas Stach

Replace the ad-hoc clocksource implementation with a proper driver for the Tegra 20 timer. This driver is able to do the required hardware initialisation itself.

arch/arm/mach-tegra/tegra20-timer.c new file +16 -0
+
+static int tegra20_timer_probe(struct device_d *dev)
+{
+	struct clk *timer_clk;
+	unsigned long rate;
+
+	/* use only one timer */
+	if (timer_base)
+		return -EBUSY;
+
+	timer_base = dev_request_mem_region(dev, 0);
+	if (!timer_base) {
+		dev_err(dev, "could not get memory region\n");
+		return -ENODEV;
+	}
+

arch/arm/mach-tegra/tegra20-timer.c line 69

Quoted 10 lines
arch/arm/mach-tegra/tegra20-timer.c new file +10 -0
+	timer_clk = clk_get(dev, NULL);
+	if (!timer_clk) {
+		dev_err(dev, "could not get clock\n");
+		return -ENODEV;
+	}
+
+	clk_enable(timer_clk);
+
+	/*
+	 * calibrate timer to run at 1MHz

We don't need the timer to be running at a certain frequency, you can just use clocks_calc_mult_shift to calculate the correct values from whatever frequency.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#17 lore raw

Re: [PATCH 6/7] tegra: add proper timer driver

Am Freitag, den 01.03.2013, 18:23 +0100 schrieb Sascha Hauer:

Quoted 27 lines · Lucas Stach
Quoted 26 lines

Replace the ad-hoc clocksource implementation with a proper driver for the Tegra 20 timer. This driver is able to do the required hardware initialisation itself.

arch/arm/mach-tegra/tegra20-timer.c new file +22 -0
+
+static int tegra20_timer_probe(struct device_d *dev)
+{
+	struct clk *timer_clk;
+	unsigned long rate;
+
+	/* use only one timer */
+	if (timer_base)
+		return -EBUSY;
+
+	timer_base = dev_request_mem_region(dev, 0);
+	if (!timer_base) {
+		dev_err(dev, "could not get memory region\n");
+		return -ENODEV;
+	}
+
+	timer_clk = clk_get(dev, NULL);
+	if (!timer_clk) {
+		dev_err(dev, "could not get clock\n");
+		return -ENODEV;
+	}
+
Quoted 8 lines

arch/arm/mach-tegra/tegra20-timer.c line 69

Quoted 4 lines
arch/arm/mach-tegra/tegra20-timer.c new file +4 -0
+	clk_enable(timer_clk);
+
+	/*
+	 * calibrate timer to run at 1MHz

We don't need the timer to be running at a certain frequency, you can just use clocks_calc_mult_shift to calculate the correct values from whatever frequency.

Other hardware blocks like the flow controller might assume the timer to be running at 1MHz. The timer and time register is named US (like usec) for a reason. It's the officially correct way to initialize this timer (as documented in the Tegra TRM).

Regards,
Lucas

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#18 lore raw

Re: [PATCH 6/7] tegra: add proper timer driver

Quoted 37 lines · Lucas Stach

Am Freitag, den 01.03.2013, 18:23 +0100 schrieb Sascha Hauer:

Quoted 27 lines · Lucas Stach
Quoted 26 lines

Replace the ad-hoc clocksource implementation with a proper driver for the Tegra 20 timer. This driver is able to do the required hardware initialisation itself.

arch/arm/mach-tegra/tegra20-timer.c new file +22 -0
+
+static int tegra20_timer_probe(struct device_d *dev)
+{
+   struct clk *timer_clk;
+   unsigned long rate;
+
+   /* use only one timer */
+   if (timer_base)
+           return -EBUSY;
+
+   timer_base = dev_request_mem_region(dev, 0);
+   if (!timer_base) {
+           dev_err(dev, "could not get memory region\n");
+           return -ENODEV;
+   }
+
+   timer_clk = clk_get(dev, NULL);
+   if (!timer_clk) {
+           dev_err(dev, "could not get clock\n");
+           return -ENODEV;
+   }
+
Quoted 8 lines

arch/arm/mach-tegra/tegra20-timer.c line 69

Quoted 4 lines
arch/arm/mach-tegra/tegra20-timer.c new file +4 -0
+   clk_enable(timer_clk);
+
+   /*
+    * calibrate timer to run at 1MHz

We don't need the timer to be running at a certain frequency, you can just use clocks_calc_mult_shift to calculate the correct values from whatever frequency.

Quoted 4 lines

Other hardware blocks like the flow controller might assume the timer to be running at 1MHz. The timer and time register is named US (like usec) for a reason. It's the officially correct way to initialize this timer (as documented in the Tegra TRM).

IMHO, then Jean-Christophe speaking about 'just use clocks_calc_mult_shift' he mean this part of your arch/arm/mach-tegra/tegra20-timer.c:

+static struct clocksource cs = {

+       .read   = tegra20_timer_cs_read,
+       .mask   = CLOCKSOURCE_MASK(32),
+       .mult   = 1000,

+};

He want to say "please don't use fixed 'mult' value, use clocks_calc_mult_shift to calculate it".

Please try to examine existing clocksources.

The command
grep -R -A 5 "static struct clocksource.*=" arch/arm/
will show you some results like this

arch/arm/mach-imx/clocksource.c:static struct clocksource cs = {

arch/arm/mach-imx/clocksource.c-        .read   = imx_clocksource_read,
arch/arm/mach-imx/clocksource.c-        .mask   = CLOCKSOURCE_MASK(32),
arch/arm/mach-imx/clocksource.c-        .shift  = 10,

arch/arm/mach-imx/clocksource.c-};

or even like that arch/arm/mach-clps711x/clock.c:static struct clocksource cs = {
arch/arm/mach-clps711x/clock.c- .read = clocksource_read,
arch/arm/mach-clps711x/clock.c- .mask = CLOCKSOURCE_MASK(16),
arch/arm/mach-clps711x/clock.c-};

But I can't find any example of 'struct clocksource' definition with fixed 'mult' value.

Signature · 7 lines
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#19 lore raw

Re: [PATCH 6/7] tegra: add proper timer driver

Am Sonntag, den 03.03.2013, 11:07 +0400 schrieb Antony Pavlov:

Quoted 68 lines · Lucas Stach
Quoted 37 lines

Am Freitag, den 01.03.2013, 18:23 +0100 schrieb Sascha Hauer:

Quoted 27 lines · Lucas Stach
Quoted 26 lines

Replace the ad-hoc clocksource implementation with a proper driver for the Tegra 20 timer. This driver is able to do the required hardware initialisation itself.

arch/arm/mach-tegra/tegra20-timer.c new file +22 -0
+
+static int tegra20_timer_probe(struct device_d *dev)
+{
+   struct clk *timer_clk;
+   unsigned long rate;
+
+   /* use only one timer */
+   if (timer_base)
+           return -EBUSY;
+
+   timer_base = dev_request_mem_region(dev, 0);
+   if (!timer_base) {
+           dev_err(dev, "could not get memory region\n");
+           return -ENODEV;
+   }
+
+   timer_clk = clk_get(dev, NULL);
+   if (!timer_clk) {
+           dev_err(dev, "could not get clock\n");
+           return -ENODEV;
+   }
+
Quoted 8 lines

arch/arm/mach-tegra/tegra20-timer.c line 69

Quoted 4 lines
arch/arm/mach-tegra/tegra20-timer.c new file +4 -0
+   clk_enable(timer_clk);
+
+   /*
+    * calibrate timer to run at 1MHz

We don't need the timer to be running at a certain frequency, you can just use clocks_calc_mult_shift to calculate the correct values from whatever frequency.

Quoted 4 lines

Other hardware blocks like the flow controller might assume the timer to be running at 1MHz. The timer and time register is named US (like usec) for a reason. It's the officially correct way to initialize this timer (as documented in the Tegra TRM).

IMHO, then Jean-Christophe speaking about 'just use clocks_calc_mult_shift' he mean this part of your arch/arm/mach-tegra/tegra20-timer.c:

arch/arm/mach-tegra/tegra20-timer.c new file +5 -0
+static struct clocksource cs = {
+       .read   = tegra20_timer_cs_read,
+       .mask   = CLOCKSOURCE_MASK(32),
+       .mult   = 1000,
+};

He want to say "please don't use fixed 'mult' value, use clocks_calc_mult_shift to calculate it".

Please try to examine existing clocksources.

The command
grep -R -A 5 "static struct clocksource.*=" arch/arm/
will show you some results like this

arch/arm/mach-imx/clocksource.c:static struct clocksource cs = {

arch/arm/mach-imx/clocksource.c-        .read   = imx_clocksource_read,
arch/arm/mach-imx/clocksource.c-        .mask   = CLOCKSOURCE_MASK(32),
arch/arm/mach-imx/clocksource.c-        .shift  = 10,

arch/arm/mach-imx/clocksource.c-};

Quoted 9 lines

or even like that arch/arm/mach-clps711x/clock.c:static struct clocksource cs = {
arch/arm/mach-clps711x/clock.c- .read = clocksource_read,
arch/arm/mach-clps711x/clock.c- .mask = CLOCKSOURCE_MASK(16),
arch/arm/mach-clps711x/clock.c-};

But I can't find any example of 'struct clocksource' definition with fixed 'mult' value.

I've looked at other clocksource drivers before implementing the Tegra one and it's right that all other clocksources calculate the mult at runtime. But as the Tegra clocksource is guaranteed to run at 1MHz at every point in time I don't really see any benefit of calculating the mult over just having it as static init data.

Is there anything I'm missing?

Regards,
Lucas

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#20 lore raw

Re: [PATCH 6/7] tegra: add proper timer driver

Quoted 85 lines · Lucas Stach

Am Sonntag, den 03.03.2013, 11:07 +0400 schrieb Antony Pavlov:

Quoted 68 lines · Lucas Stach
Quoted 37 lines

Am Freitag, den 01.03.2013, 18:23 +0100 schrieb Sascha Hauer:

Quoted 27 lines · Lucas Stach
Quoted 26 lines

Replace the ad-hoc clocksource implementation with a proper driver for the Tegra 20 timer. This driver is able to do the required hardware initialisation itself.

arch/arm/mach-tegra/tegra20-timer.c new file +22 -0
+
+static int tegra20_timer_probe(struct device_d *dev)
+{
+   struct clk *timer_clk;
+   unsigned long rate;
+
+   /* use only one timer */
+   if (timer_base)
+           return -EBUSY;
+
+   timer_base = dev_request_mem_region(dev, 0);
+   if (!timer_base) {
+           dev_err(dev, "could not get memory region\n");
+           return -ENODEV;
+   }
+
+   timer_clk = clk_get(dev, NULL);
+   if (!timer_clk) {
+           dev_err(dev, "could not get clock\n");
+           return -ENODEV;
+   }
+
Quoted 8 lines

arch/arm/mach-tegra/tegra20-timer.c line 69

Quoted 4 lines
arch/arm/mach-tegra/tegra20-timer.c new file +4 -0
+   clk_enable(timer_clk);
+
+   /*
+    * calibrate timer to run at 1MHz

We don't need the timer to be running at a certain frequency, you can just use clocks_calc_mult_shift to calculate the correct values from whatever frequency.

Quoted 4 lines

Other hardware blocks like the flow controller might assume the timer to be running at 1MHz. The timer and time register is named US (like usec) for a reason. It's the officially correct way to initialize this timer (as documented in the Tegra TRM).

IMHO, then Jean-Christophe speaking about 'just use clocks_calc_mult_shift' he mean this part of your arch/arm/mach-tegra/tegra20-timer.c:

arch/arm/mach-tegra/tegra20-timer.c new file +5 -0
+static struct clocksource cs = {
+       .read   = tegra20_timer_cs_read,
+       .mask   = CLOCKSOURCE_MASK(32),
+       .mult   = 1000,
+};

He want to say "please don't use fixed 'mult' value, use clocks_calc_mult_shift to calculate it".

Please try to examine existing clocksources.

The command
grep -R -A 5 "static struct clocksource.*=" arch/arm/
will show you some results like this

arch/arm/mach-imx/clocksource.c:static struct clocksource cs = {

arch/arm/mach-imx/clocksource.c-        .read   = imx_clocksource_read,
arch/arm/mach-imx/clocksource.c-        .mask   = CLOCKSOURCE_MASK(32),
arch/arm/mach-imx/clocksource.c-        .shift  = 10,

arch/arm/mach-imx/clocksource.c-};

Quoted 9 lines

or even like that arch/arm/mach-clps711x/clock.c:static struct clocksource cs = {
arch/arm/mach-clps711x/clock.c- .read = clocksource_read,
arch/arm/mach-clps711x/clock.c- .mask = CLOCKSOURCE_MASK(16),
arch/arm/mach-clps711x/clock.c-};

But I can't find any example of 'struct clocksource' definition with fixed 'mult' value.

I've looked at other clocksource drivers before implementing the Tegra one and it's right that all other clocksources calculate the mult at runtime. But as the Tegra clocksource is guaranteed to run at 1MHz at every point in time I don't really see any benefit of calculating the mult over just having it as static init data.

Quoted 1 line

Is there anything I'm missing?

You use your knowlege about the clock rate twice:
* then you actually set up the clock rate;
* then you set up the clocksource device data structure (the values
of the 'shift' and the 'mult' fields).

But there is no any EXPLICIT relation between the clock rate and the 'shift' and 'mult' values; It is not clear and evident that if you change the clock frequency you must change the 'mult' value too. There are a techical means to change clock frequency in spite of the recommended clock frequency is 1 MHz. Don't forget the quote from the book 'Murphy's laws and corollaries':

Anything that can go wrong will go wrong.

In the short-term your tricky realisation looks good, but in the long-term it is a potential source of a problems.

Signature · 7 lines
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#21 lore raw

PATCH 7/7 tegra: add power management controller driver

In reply to Lucas Stach

Currently only implements system wide reset functionality.

---
 arch/arm/mach-tegra/Makefile      |  2 +-
 arch/arm/mach-tegra/reset.c       | 39 -----------------
 arch/arm/mach-tegra/tegra20-pmc.c | 89 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra20.c     |  4 ++
 4 files changed, 94 insertions(+), 40 deletions(-)
 delete mode 100644 arch/arm/mach-tegra/reset.c
 create mode 100644 arch/arm/mach-tegra/tegra20-pmc.c
arch/arm/mach-tegra/Makefile +1 -1
index 6aa219c..bcc0cd4 100644
@@ -1,4 +1,4 @@
-obj-y += reset.o
 obj-y += tegra20.o
 obj-y += tegra20-car.o
+obj-y += tegra20-pmc.o
 obj-y += tegra20-timer.o
arch/arm/mach-tegra/reset.c deleted +0 -39
deleted file mode 100644
index 73d7ca2..0000000
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2011 Antony Pavlov <[email protected]>
- *
- * This file is part of barebox.
- * 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 version 2
- * as published by the Free Software Foundation.
- *
- * 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.
- *
- */
-
-/**
- * @file
- * @brief Resetting an malta board
- */
-
-#include <common.h>
-#include <asm/io.h>
-#include <mach/tegra20-silicon.h>
-
-#define PRM_RSTCTRL		TEGRA_PMC_BASE
-
-void __noreturn reset_cpu(ulong addr)
-{
-	int rstctrl;
-
-	rstctrl = __raw_readl((char *)PRM_RSTCTRL);
-	rstctrl |= 0x10;
-	__raw_writel(rstctrl, (char *)PRM_RSTCTRL);
-
-	unreachable();
-}
-EXPORT_SYMBOL(reset_cpu);
arch/arm/mach-tegra/tegra20-pmc.c new file +89 -0

89 lines not on this page · raw message

arch/arm/mach-tegra/tegra20.c +4 -0
index eccc7b8..54e8819 100644
@@ -28,6 +28,10 @@ static int tegra20_init(void)
 			   TEGRA_TMR1_BASE, TEGRA_TMR1_SIZE,
 			   IORESOURCE_MEM, NULL);
 
+	add_generic_device("tegra20-pmc", DEVICE_ID_SINGLE, NULL,
+			   TEGRA_PMC_BASE, TEGRA_PMC_SIZE,
+			   IORESOURCE_MEM, NULL);
+
 	return 0;
 }
 
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#22 lore raw

Re: [PATCH 7/7] tegra: add power management controller driver

Quoted 3 lines · Lucas Stach

Currently only implements system wide reset functionality.

you work for pengu I expect the proper e-mail here and in the author

Quoted 182 lines
---
 arch/arm/mach-tegra/Makefile      |  2 +-
 arch/arm/mach-tegra/reset.c       | 39 -----------------
 arch/arm/mach-tegra/tegra20-pmc.c | 89 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra20.c     |  4 ++
 4 files changed, 94 insertions(+), 40 deletions(-)
 delete mode 100644 arch/arm/mach-tegra/reset.c
 create mode 100644 arch/arm/mach-tegra/tegra20-pmc.c
arch/arm/mach-tegra/Makefile +1 -1
index 6aa219c..bcc0cd4 100644
@@ -1,4 +1,4 @@
-obj-y += reset.o
 obj-y += tegra20.o
 obj-y += tegra20-car.o
+obj-y += tegra20-pmc.o
 obj-y += tegra20-timer.o
arch/arm/mach-tegra/reset.c deleted +0 -39
deleted file mode 100644
index 73d7ca2..0000000
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2011 Antony Pavlov <[email protected]>
- *
- * This file is part of barebox.
- * 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 version 2
- * as published by the Free Software Foundation.
- *
- * 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.
- *
- */
-
-/**
- * @file
- * @brief Resetting an malta board
- */
-
-#include <common.h>
-#include <asm/io.h>
-#include <mach/tegra20-silicon.h>
-
-#define PRM_RSTCTRL		TEGRA_PMC_BASE
-
-void __noreturn reset_cpu(ulong addr)
-{
-	int rstctrl;
-
-	rstctrl = __raw_readl((char *)PRM_RSTCTRL);
-	rstctrl |= 0x10;
-	__raw_writel(rstctrl, (char *)PRM_RSTCTRL);
-
-	unreachable();
-}
-EXPORT_SYMBOL(reset_cpu);
arch/arm/mach-tegra/tegra20-pmc.c new file +89 -0
new file mode 100644
index 0000000..ed765f5
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2013 Lucas Stach <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * @file
+ * @brief Device driver for the Tegra 20 power management controller.
+ */
+
+#include <common.h>
+#include <init.h>
+#include <io.h>
+
+/* register definitions */
+#define PMC_CNTRL			0x00
+#define PMC_CNTRL_FUSE_OVERRIDE		(1 << 18)
+#define PMC_CNTRL_INTR_POLARITY		(1 << 17)
+#define PMC_CNTRL_CPUPWRREQ_OE		(1 << 16)
+#define PMC_CNTRL_CPUPWRREQ_POLARITY	(1 << 15)
+#define PMC_CNTRL_SIDE_EFFECT_LP0	(1 << 14)
+#define PMC_CNTRL_AOINIT		(1 << 13)
+#define PMC_CNTRL_PWRGATE_DIS		(1 << 12)
+#define PMC_CNTRL_SYSCLK_OE		(1 << 11)
+#define PMC_CNTRL_SYSCLK_POLARITY	(1 << 10)
+#define PMC_CNTRL_PWRREQ_OE		(1 << 9)
+#define PMC_CNTRL_PWRREQ_POLARITY	(1 << 8)
+#define PMC_CNTRL_BLINK_EN		(1 << 7)
+#define PMC_CNTRL_GLITCHDET_DIS		(1 << 6)
+#define PMC_CNTRL_LATCHWAKE_EN		(1 << 5)
+#define PMC_CNTRL_MAIN_RST		(1 << 4)
+#define PMC_CNTRL_KBC_RST		(1 << 3)
+#define PMC_CNTRL_RTC_RST		(1 << 2)
+#define PMC_CNTRL_RTC_CLK_DIS		(1 << 1)
+#define PMC_CNTRL_KBC_CLK_DIS		(1 << 0)
+
+static void __iomem *pmc_base;
+
+/* main SoC reset trigger */
+void __noreturn reset_cpu(ulong addr)
+{
+	writel(PMC_CNTRL_MAIN_RST, pmc_base + PMC_CNTRL);
+
+	unreachable();
+}
+EXPORT_SYMBOL(reset_cpu);
+
+static int tegra20_pmc_probe(struct device_d *dev)
+{
+	pmc_base = dev_request_mem_region(dev, 0);
+	if (!pmc_base) {
+		dev_err(dev, "could not get memory region\n");
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
+static __maybe_unused struct of_device_id tegra20_pmc_dt_ids[] = {
+	{
+		.compatible = "nvidia,tegra20-pmc",
+	}, {
+		/* sentinel */
+	}
+};
+
+static struct driver_d tegra20_pmc_driver = {
+	.probe	= tegra20_pmc_probe,
+	.name	= "tegra20-pmc",
+	.of_compatible = DRV_OF_COMPAT(tegra20_pmc_dt_ids),
+};
+
+static int tegra20_pmc_init(void)
+{
+	return platform_driver_register(&tegra20_pmc_driver);
+}
+
+coredevice_initcall(tegra20_pmc_init);
arch/arm/mach-tegra/tegra20.c +4 -0
index eccc7b8..54e8819 100644
@@ -28,6 +28,10 @@ static int tegra20_init(void)
 			   TEGRA_TMR1_BASE, TEGRA_TMR1_SIZE,
 			   IORESOURCE_MEM, NULL);
 
+	add_generic_device("tegra20-pmc", DEVICE_ID_SINGLE, NULL,
+			   TEGRA_PMC_BASE, TEGRA_PMC_SIZE,
+			   IORESOURCE_MEM, NULL);
+
 	return 0;
 }
 
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#23 lore raw

Re: [PATCH 7/7] tegra: add power management controller driver

Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 3 lines · Lucas Stach

Currently only implements system wide reset functionality.

you work for pengu I expect the proper e-mail here and in the author

If Lucas is doing this at home why shouldn't he use his private address?

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#24 lore raw

Re: [PATCH 7/7] tegra: add power management controller driver

Quoted 8 lines · Sascha Hauer
Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 3 lines · Lucas Stach

Currently only implements system wide reset functionality.

you work for pengu I expect the proper e-mail here and in the author

If Lucas is doing this at home why shouldn't he use his private address?

But he uses Pengutronix e-mail address inside c-files (e.g. see arch/arm/mach-tegra/tegra20-car.c).

Signature · 7 lines
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#25 lore raw

Re: [PATCH 7/7] tegra: add power management controller driver

Am Freitag, den 01.03.2013, 22:00 +0400 schrieb Antony Pavlov:

Quoted 5 lines · Sascha Hauer
Quoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 3 lines · Lucas Stach
Quoted 2 lines

Currently only implements system wide reset functionality.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

you work for pengu I expect the proper e-mail here and in the author

If Lucas is doing this at home why shouldn't he use his private address?

But he uses Pengutronix e-mail address inside c-files (e.g. see arch/arm/mach-tegra/tegra20-car.c).

I know this is a bit schizophrenic. While I work for Pengutronix Tegra is my personal pet project so it get's signed off with my personal mail address, still I would like for mails regarding any barebox stuff to be directed at my pengutronix inbox.

But if it really bothers you I'll change the header for the next revision.

Regards,
Lucas

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#26 lore raw

v2 cover Rework current Tegra support

In reply to Lucas Stach

This patchset converts the current ad-hoc implementation within the Tegra arch into proper barebox drivers. It slightly enhances functionality, but mostly this is a cleanup to provide a good base for further work.

V2 incorporates the review feedback I got so far. Mostly avoiding renaming iomap.h and leaving debug_ll as is.

Lucas Stach (5):
tegra: pull in iomap.h from the Linux kernel
tegra: switch to ARMv7 cpu type
tegra: add driver for the clock and reset module
tegra: add proper timer driver
tegra: add power management controller driver

 arch/arm/Kconfig                          |   4 +-
 arch/arm/mach-tegra/Makefile              |   6 +-
 arch/arm/mach-tegra/clock.c               |  56 -------------
 arch/arm/mach-tegra/include/mach/clkdev.h |   7 ++
 arch/arm/mach-tegra/include/mach/iomap.h  |  64 +++++----------
 arch/arm/mach-tegra/reset.c               |  39 ---------
 arch/arm/mach-tegra/tegra20-car.c         | 126 ++++++++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra20-pmc.c         |  89 +++++++++++++++++++++
 arch/arm/mach-tegra/tegra20-timer.c       | 120 ++++++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra20.c             |  38 +++++++++
 10 files changed, 406 insertions(+), 143 deletions(-)
 delete mode 100644 arch/arm/mach-tegra/clock.c
 create mode 100644 arch/arm/mach-tegra/include/mach/clkdev.h
 delete mode 100644 arch/arm/mach-tegra/reset.c
 create mode 100644 arch/arm/mach-tegra/tegra20-car.c
 create mode 100644 arch/arm/mach-tegra/tegra20-pmc.c
 create mode 100644 arch/arm/mach-tegra/tegra20-timer.c
 create mode 100644 arch/arm/mach-tegra/tegra20.c
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#27 lore raw

PATCH v2 1/5 tegra: pull in iomap.h from the Linux kernel

This updates iomap.h to the latest Linux code.

---
 arch/arm/mach-tegra/include/mach/iomap.h | 64 ++++++++++----------------------
 1 file changed, 19 insertions(+), 45 deletions(-)
arch/arm/mach-tegra/include/mach/iomap.h +19 -45
index ba478e7..6ca6504 100644
@@ -62,47 +62,35 @@
 #define TEGRA_RES_SEMA_BASE		0x60001000
 #define TEGRA_RES_SEMA_SIZE		SZ_4K
 
-#define TEGRA_HDMI_BASE			0x54280000
-#define TEGRA_HDMI_SIZE			SZ_256K
-
-#define TEGRA_GART_BASE			0x58000000
-#define TEGRA_GART_SIZE			SZ_32M
-
-#define TEGRA_RES_SEMA_BASE		0x60001000
-#define TEGRA_RES_SEMA_SIZE		SZ_4K
-
-#define TEGRA_ARB_SEMA_BASE		0x60002000
-#define TEGRA_ARB_SEMA_SIZE		SZ_4K
-
 #define TEGRA_PRIMARY_ICTLR_BASE	0x60004000
-#define TEGRA_PRIMARY_ICTLR_SIZE	64
-
-#define TEGRA_ARBGNT_ICTLR_BASE		0x60004040
-#define TEGRA_ARBGNT_ICTLR_SIZE		192
+#define TEGRA_PRIMARY_ICTLR_SIZE	SZ_64
 
 #define TEGRA_SECONDARY_ICTLR_BASE	0x60004100
-#define TEGRA_SECONDARY_ICTLR_SIZE	64
+#define TEGRA_SECONDARY_ICTLR_SIZE	SZ_64
 
 #define TEGRA_TERTIARY_ICTLR_BASE	0x60004200
-#define TEGRA_TERTIARY_ICTLR_SIZE	64
+#define TEGRA_TERTIARY_ICTLR_SIZE	SZ_64
 
 #define TEGRA_QUATERNARY_ICTLR_BASE	0x60004300
-#define TEGRA_QUATERNARY_ICTLR_SIZE	64
+#define TEGRA_QUATERNARY_ICTLR_SIZE	SZ_64
+
+#define TEGRA_QUINARY_ICTLR_BASE	0x60004400
+#define TEGRA_QUINARY_ICTLR_SIZE	SZ_64
 
 #define TEGRA_TMR1_BASE			0x60005000
-#define TEGRA_TMR1_SIZE			8
+#define TEGRA_TMR1_SIZE			SZ_8
 
 #define TEGRA_TMR2_BASE			0x60005008
-#define TEGRA_TMR2_SIZE			8
+#define TEGRA_TMR2_SIZE			SZ_8
 
 #define TEGRA_TMRUS_BASE		0x60005010
-#define TEGRA_TMRUS_SIZE		64
+#define TEGRA_TMRUS_SIZE		SZ_64
 
 #define TEGRA_TMR3_BASE			0x60005050
-#define TEGRA_TMR3_SIZE			8
+#define TEGRA_TMR3_SIZE			SZ_8
 
 #define TEGRA_TMR4_BASE			0x60005058
-#define TEGRA_TMR4_SIZE			8
+#define TEGRA_TMR4_SIZE			SZ_8
 
 #define TEGRA_CLK_RESET_BASE		0x60006000
 #define TEGRA_CLK_RESET_SIZE		SZ_4K
@@ -125,17 +113,17 @@
 #define TEGRA_AHB_GIZMO_BASE		0x6000C004
 #define TEGRA_AHB_GIZMO_SIZE		0x10C
 
+#define TEGRA_SB_BASE			0x6000C200
+#define TEGRA_SB_SIZE			256
+
 #define TEGRA_STATMON_BASE		0x6000C400
 #define TEGRA_STATMON_SIZE		SZ_1K
 
 #define TEGRA_GPIO_BASE			0x6000D000
 #define TEGRA_GPIO_SIZE			SZ_4K
 
-#define TEGRA_EXCEPTION_VECTORS_BASE    0x6000F000
-#define TEGRA_EXCEPTION_VECTORS_SIZE    SZ_4K
-
-#define TEGRA_VDE_BASE		0x6001A000
-#define TEGRA_VDE_SIZE		(SZ_8K + SZ_4K - SZ_256)
+#define TEGRA_EXCEPTION_VECTORS_BASE	0x6000F000
+#define TEGRA_EXCEPTION_VECTORS_SIZE	SZ_4K
 
 #define TEGRA_APB_MISC_BASE		0x70000000
 #define TEGRA_APB_MISC_SIZE		SZ_4K
@@ -156,10 +144,10 @@
 #define TEGRA_I2S2_SIZE			SZ_256
 
 #define TEGRA_UARTA_BASE		0x70006000
-#define TEGRA_UARTA_SIZE		64
+#define TEGRA_UARTA_SIZE		SZ_64
 
 #define TEGRA_UARTB_BASE		0x70006040
-#define TEGRA_UARTB_SIZE		64
+#define TEGRA_UARTB_SIZE		SZ_64
 
 #define TEGRA_UARTC_BASE		0x70006200
 #define TEGRA_UARTC_SIZE		SZ_256
@@ -275,18 +263,4 @@
 #define TEGRA_SDMMC4_BASE		0xC8000600
 #define TEGRA_SDMMC4_SIZE		SZ_512
 
-#if defined(CONFIG_TEGRA_DEBUG_UART_NONE)
-# define TEGRA_DEBUG_UART_BASE 0
-#elif defined(CONFIG_TEGRA_DEBUG_UARTA)
-# define TEGRA_DEBUG_UART_BASE TEGRA_UARTA_BASE
-#elif defined(CONFIG_TEGRA_DEBUG_UARTB)
-# define TEGRA_DEBUG_UART_BASE TEGRA_UARTB_BASE
-#elif defined(CONFIG_TEGRA_DEBUG_UARTC)
-# define TEGRA_DEBUG_UART_BASE TEGRA_UARTC_BASE
-#elif defined(CONFIG_TEGRA_DEBUG_UARTD)
-# define TEGRA_DEBUG_UART_BASE TEGRA_UARTD_BASE
-#elif defined(CONFIG_TEGRA_DEBUG_UARTE)
-# define TEGRA_DEBUG_UART_BASE TEGRA_UARTE_BASE
-#endif
-
 #endif
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#28 lore raw

PATCH v2 2/5 tegra: switch to ARMv7 cpu type

In reply to Lucas Stach

Main barebox is running on the A9 cluster. Use the correct ISA.

---
 arch/arm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/Kconfig +1 -1
index 7ac134e..5dbf74d 100644
@@ -125,7 +125,7 @@ config ARCH_VEXPRESS
 
 config ARCH_TEGRA
 	bool "Nvidia Tegra-based boards"
-	select CPU_ARM926T
+	select CPU_V7
 	select HAS_DEBUG_LL
 
 endchoice
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#29 lore raw

Re: [PATCH v2 2/5] tegra: switch to ARMv7 cpu type

Hi!

This commit breaks usb ethernet card on my board.

toshiba ac100> / usb
USB: scanning bus for devices...
Bus 001 Device 003: ID 0bdb:190a F3307
Bus 001 Device 004: ID 0bda:58f2 USB Camera Bus 001 Device 005: ID 2001:3c05 DUB-E100
mdio_bus: miibus0: probed
eth0: got preset MAC address: 1C:7E:E5:0F:E1:14 Bus 001 Device 002: ID 0424:2513
Bus 001 Device 001: ID 0000:0000 EHCI Host Controller 5 USB Device(s) found
toshiba ac100> / dhcp
100Mbps full duplex link detected
dhcp failed: error 1
dhcp: error 1
toshiba ac100>

The next branch with Sascha's 'usb: ehci: initialize ehci_data' patch works fine.

Quoted 28 lines · Lucas Stach

Main barebox is running on the A9 cluster. Use the correct ISA.

---
 arch/arm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/Kconfig +1 -2
index 7ac134e..5dbf74d 100644
@@ -125,7 +125,7 @@ config ARCH_VEXPRESS
 
 config ARCH_TEGRA
        bool "Nvidia Tegra-based boards"
-       select CPU_ARM926T
+       select CPU_V7
        select HAS_DEBUG_LL
 
 endchoice
--

1.8.1.2

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Signature · 7 lines
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#30 lore raw

Re: [PATCH v2 2/5] tegra: switch to ARMv7 cpu type

Am Freitag, den 08.03.2013, 10:03 +0400 schrieb Antony Pavlov:

Quoted 4 lines

Hi!

This commit breaks usb ethernet card on my board.

If you are using a GCC >= 4.7 this is most likely the problem that GCC now produces hardware unaligned access instructions on ARMv7 by default. Unfortunately the EHCI spec has placed one of the registers at an unaligned offset. Barebox traps the processor when hitting an unaligned access in hardware.

Thanks for the heads up, I'll make sure we resolve this problem before this patchset goes in.

Regards,
Lucas

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#31 lore raw

Re: [PATCH v2 2/5] tegra: switch to ARMv7 cpu type

Quoted 7 lines · Lucas Stach

Am Freitag, den 08.03.2013, 10:03 +0400 schrieb Antony Pavlov:

Quoted 4 lines

Hi!

This commit breaks usb ethernet card on my board.

If you are using a GCC >= 4.7 this is most likely the problem that GCC now produces hardware unaligned access instructions on ARMv7 by default.

I'm using GCC 4.4.6.

Quoted 10 lines

Unfortunately the EHCI spec has placed one of the registers at an unaligned offset. Barebox traps the processor when hitting an unaligned access in hardware.

Thanks for the heads up, I'll make sure we resolve this problem before this patchset goes in.

Regards,
Lucas

Signature · 7 lines
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#32 lore raw

Re: [PATCH v2 2/5] tegra: switch to ARMv7 cpu type

In reply to Antony Pavlov

Hi Antony,

Quoted 4 lines · Antony Pavlov

Hi!

This commit breaks usb ethernet card on my board.

Quoted 15 lines

toshiba ac100> / usb
USB: scanning bus for devices...
Bus 001 Device 003: ID 0bdb:190a F3307
Bus 001 Device 004: ID 0bda:58f2 USB Camera Bus 001 Device 005: ID 2001:3c05 DUB-E100
mdio_bus: miibus0: probed
eth0: got preset MAC address: 1C:7E:E5:0F:E1:14 Bus 001 Device 002: ID 0424:2513
Bus 001 Device 001: ID 0000:0000 EHCI Host Controller 5 USB Device(s) found
toshiba ac100> / dhcp
100Mbps full duplex link detected
dhcp failed: error 1
dhcp: error 1
toshiba ac100>

Could you try the following?

Sascha

arch/arm/include/asm/barebox-arm-head.h +1 -1
index 9d9b854..c631815 100644
@@ -22,7 +22,7 @@ static inline void arm_cpu_lowlevel_init(void)
 
 #if __LINUX_ARM_ARCH__ >= 6
 	r |= CR_U;
-	r &= CR_A;
+	r &= ~CR_A;
 #else
 	r |= CR_A;
 #endif
Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#33 lore raw

Re: [PATCH v2 2/5] tegra: switch to ARMv7 cpu type

Quoted 23 lines · Sascha Hauer

Hi Antony,

Quoted 4 lines · Antony Pavlov

Hi!

This commit breaks usb ethernet card on my board.

Quoted 15 lines

toshiba ac100> / usb
USB: scanning bus for devices...
Bus 001 Device 003: ID 0bdb:190a F3307
Bus 001 Device 004: ID 0bda:58f2 USB Camera Bus 001 Device 005: ID 2001:3c05 DUB-E100
mdio_bus: miibus0: probed
eth0: got preset MAC address: 1C:7E:E5:0F:E1:14 Bus 001 Device 002: ID 0424:2513
Bus 001 Device 001: ID 0000:0000 EHCI Host Controller 5 USB Device(s) found
toshiba ac100> / dhcp
100Mbps full duplex link detected
dhcp failed: error 1
dhcp: error 1
toshiba ac100>

Quoted 2 lines

Could you try the following?

Alas! This patch did't help.

Quoted 20 lines
arch/arm/include/asm/barebox-arm-head.h +1 -2
index 9d9b854..c631815 100644
@@ -22,7 +22,7 @@ static inline void arm_cpu_lowlevel_init(void)
 
 #if __LINUX_ARM_ARCH__ >= 6
        r |= CR_U;
-       r &= CR_A;
+       r &= ~CR_A;
 #else
        r |= CR_A;
 #endif
 
 
--
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
Signature · 7 lines
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#34 lore raw

PATCH v2 3/5 tegra: add driver for the clock and reset module

In reply to Lucas Stach

Only a basic set of clocks is supported as of now.

---
 arch/arm/Kconfig                          |   2 +
 arch/arm/mach-tegra/Makefile              |   2 +
 arch/arm/mach-tegra/include/mach/clkdev.h |   7 ++
 arch/arm/mach-tegra/tegra20-car.c         | 121 ++++++++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra20.c             |  30 ++++++++
 5 files changed, 162 insertions(+)
 create mode 100644 arch/arm/mach-tegra/include/mach/clkdev.h
 create mode 100644 arch/arm/mach-tegra/tegra20-car.c
 create mode 100644 arch/arm/mach-tegra/tegra20.c
arch/arm/Kconfig +2 -0
index 5dbf74d..9724494 100644
@@ -127,6 +127,8 @@ config ARCH_TEGRA
 	bool "Nvidia Tegra-based boards"
 	select CPU_V7
 	select HAS_DEBUG_LL
+	select COMMON_CLK
+	select CLKDEV_LOOKUP
 
 endchoice
 
arch/arm/mach-tegra/Makefile +2 -0
index 11915e5..3391528 100644
@@ -1,2 +1,4 @@
 obj-y += clock.o
 obj-y += reset.o
+obj-y += tegra20.o
+obj-y += tegra20-car.o
arch/arm/mach-tegra/include/mach/clkdev.h new file +7 -0
new file mode 100644
index 0000000..04b37a8
@@ -0,0 +1,7 @@
+#ifndef __ASM_MACH_CLKDEV_H
+#define __ASM_MACH_CLKDEV_H
+
+#define __clk_get(clk) ({ 1; })
+#define __clk_put(clk) do { } while (0)
+
+#endif
arch/arm/mach-tegra/tegra20-car.c new file +121 -0

121 lines not on this page · raw message

arch/arm/mach-tegra/tegra20.c new file +30 -0
new file mode 100644
index 0000000..3831f1b
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2013 Lucas Stach <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <common.h>
+#include <init.h>
+#include <mach/iomap.h>
+
+static int tegra20_init(void)
+{
+	add_generic_device("tegra20-car", DEVICE_ID_SINGLE, NULL,
+			   TEGRA_CLK_RESET_BASE, TEGRA_CLK_RESET_SIZE,
+			   IORESOURCE_MEM, NULL);
+
+	return 0;
+}
+
+postcore_initcall(tegra20_init);
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#35 lore raw

Re: [PATCH v2 3/5] tegra: add driver for the clock and reset module

Quoted 98 lines · Lucas Stach

Only a basic set of clocks is supported as of now.

---
 arch/arm/Kconfig                          |   2 +
 arch/arm/mach-tegra/Makefile              |   2 +
 arch/arm/mach-tegra/include/mach/clkdev.h |   7 ++
 arch/arm/mach-tegra/tegra20-car.c         | 121 ++++++++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra20.c             |  30 ++++++++
 5 files changed, 162 insertions(+)
 create mode 100644 arch/arm/mach-tegra/include/mach/clkdev.h
 create mode 100644 arch/arm/mach-tegra/tegra20-car.c
 create mode 100644 arch/arm/mach-tegra/tegra20.c
arch/arm/Kconfig +2 -0
index 5dbf74d..9724494 100644
@@ -127,6 +127,8 @@ config ARCH_TEGRA
        bool "Nvidia Tegra-based boards"
        select CPU_V7
        select HAS_DEBUG_LL
+       select COMMON_CLK
+       select CLKDEV_LOOKUP
 
 endchoice
 
arch/arm/mach-tegra/Makefile +2 -0
index 11915e5..3391528 100644
@@ -1,2 +1,4 @@
 obj-y += clock.o
 obj-y += reset.o
+obj-y += tegra20.o
+obj-y += tegra20-car.o
arch/arm/mach-tegra/include/mach/clkdev.h new file +7 -0
new file mode 100644
index 0000000..04b37a8
@@ -0,0 +1,7 @@
+#ifndef __ASM_MACH_CLKDEV_H
+#define __ASM_MACH_CLKDEV_H
+
+#define __clk_get(clk) ({ 1; })
+#define __clk_put(clk) do { } while (0)
+
+#endif
arch/arm/mach-tegra/tegra20-car.c new file +43 -0
new file mode 100644
index 0000000..eec3cc3
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2013 Lucas Stach <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * @file
+ * @brief Device driver for the Tegra 20 clock and reset (CAR) controller
+ */
+
+#include <common.h>
+#include <init.h>
+#include <io.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <mach/iomap.h>
+
+/* Register definitions */
+#define OSC_CTRL 0x50
+#define OSC_CTRL_OSC_FREQ_SHIFT                30
+#define OSC_CTRL_OSC_FREQ_MASK         (3 << OSC_CTRL_OSC_FREQ_SHIFT)
+#define OSC_CTRL_PLL_REF_DIV_SHIFT     28
+#define OSC_CTRL_PLL_REF_DIV_MASK      (3 << OSC_CTRL_PLL_REF_DIV_SHIFT)
+
+static void __iomem *car_base;
+
+enum tegra20_clks {
+       cpu, ac97 = 3, rtc, timer, uarta, gpio = 8, sdmmc2, i2s1 = 11, i2c1,
+       ndflash, sdmmc1, sdmmc4, twc, pwm, i2s2, epp, gr2d = 21, usbd, isp,
+       gr3d, ide, disp2, disp1, host1x, vcp, cache2 = 31, mem, ahbdma, apbdma,
+       kbc = 36, stat_mon, pmc, fuse, kfuse, sbc1, nor, spi, sbc2, xio, sbc3,
+       dvc, dsi, mipi = 50, hdmi, csi, tvdac, i2c2, uartc, emc = 57, usb2,

arch/arm/mach-tegra/tegra20-car.c line 53

Quoted 10 lines
arch/arm/mach-tegra/tegra20-car.c new file +10 -0
+       usb3, mpe, vde, bsea, bsev, speedo, uartd, uarte, i2c3, sbc4, sdmmc3,
+       pex, owr, afi, csite, pcie_xclk, avpucq = 75, la, irama = 84, iramb,
+       iramc, iramd, cram2, audio_2x, clk_d, csus = 92, cdev1, cdev2,
+       uartb = 96, vfir, spdif_in, spdif_out, vi, vi_sensor, tvo, cve,
+       osc, clk_32k, clk_m, sclk, cclk, hclk, pclk, blink, pll_a, pll_a_out0,
+       pll_c, pll_c_out1, pll_d, pll_d_out0, pll_e, pll_m, pll_m_out1,
+       pll_p, pll_p_out1, pll_p_out2, pll_p_out3, pll_p_out4, pll_u,
+       pll_x, audio, pll_ref, twd, clk_max,
+};
+

Please remove unused constants or register appropriate clocks.

Quoted 21 lines
arch/arm/mach-tegra/tegra20-car.c new file +21 -0
+static struct clk *clks[clk_max];
+
+static unsigned long get_osc_frequency(void)
+{
+       u32 osc_ctrl = readl(car_base + OSC_CTRL);
+
+       switch ((osc_ctrl & OSC_CTRL_OSC_FREQ_MASK) >> OSC_CTRL_OSC_FREQ_SHIFT)
+       {
+       case 0:
+               return 13000000;
+       case 1:
+               return 19200000;
+       case 2:
+               return 12000000;
+       case 3:
+               return 26000000;
+       default:
+               return 0;
+       }
+}
+

arch/arm/mach-tegra/tegra20-car.c line 84

Quoted 10 lines
arch/arm/mach-tegra/tegra20-car.c new file +10 -0
+static unsigned int get_pll_ref_div(void)
+{
+       u32 osc_ctrl = readl(car_base + OSC_CTRL);
+
+       return 1U << ((osc_ctrl & OSC_CTRL_PLL_REF_DIV_MASK) >>
+                     OSC_CTRL_PLL_REF_DIV_SHIFT);
+}
+
+static int tegra20_car_probe(struct device_d *dev)
+{

Please check car_base befor use, e.g. see your tegra20_timer_probe() function.

Quoted 81 lines
arch/arm/mach-tegra/tegra20-car.c new file +37 -0
+       car_base = dev_request_mem_region(dev, 0);
+       if (!car_base)
+               return -EBUSY;
+
+       /* primary clocks */
+       clks[clk_m] = clk_fixed("clk_m", get_osc_frequency());
+       clks[clk_32k] = clk_fixed("clk_32k", 32768);
+
+       clks[pll_ref] = clk_fixed_factor("pll_ref", "clk_m", 1,
+                                        get_pll_ref_div());
+
+       /* derived clocks */
+       /* timer is a gate, but as it's enabled by BOOTROM we needn't worry */
+       clks[timer] = clk_fixed_factor("timer", "clk_m", 1, 1);
+
+       return 0;
+}
+
+static __maybe_unused struct of_device_id tegra20_car_dt_ids[] = {
+       {
+               .compatible = "nvidia,tegra20-car",
+       }, {
+               /* sentinel */
+       }
+};
+
+static struct driver_d tegra20_car_driver = {
+       .probe  = tegra20_car_probe,
+       .name   = "tegra20-car",
+       .of_compatible = DRV_OF_COMPAT(tegra20_car_dt_ids),
+};
+
+static int tegra20_car_init(void)
+{
+       return platform_driver_register(&tegra20_car_driver);
+}
+postcore_initcall(tegra20_car_init);
arch/arm/mach-tegra/tegra20.c new file +30 -1
new file mode 100644
index 0000000..3831f1b
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2013 Lucas Stach <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <common.h>
+#include <init.h>
+#include <mach/iomap.h>
+
+static int tegra20_init(void)
+{
+       add_generic_device("tegra20-car", DEVICE_ID_SINGLE, NULL,
+                          TEGRA_CLK_RESET_BASE, TEGRA_CLK_RESET_SIZE,
+                          IORESOURCE_MEM, NULL);
+
+       return 0;
+}
+
+postcore_initcall(tegra20_init);
--

1.8.1.2

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Signature · 7 lines
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#36 lore raw

Re: [PATCH v2 3/5] tegra: add driver for the clock and reset module

Quoted 11 lines · Antony Pavlov
Quoted 11 lines
arch/arm/mach-tegra/tegra20-car.c new file +11 -0
+static void __iomem *car_base;
+
+enum tegra20_clks {
+       cpu, ac97 = 3, rtc, timer, uarta, gpio = 8, sdmmc2, i2s1 = 11, i2c1,
+       ndflash, sdmmc1, sdmmc4, twc, pwm, i2s2, epp, gr2d = 21, usbd, isp,
+       gr3d, ide, disp2, disp1, host1x, vcp, cache2 = 31, mem, ahbdma, apbdma,
+       kbc = 36, stat_mon, pmc, fuse, kfuse, sbc1, nor, spi, sbc2, xio, sbc3,
+       dvc, dsi, mipi = 50, hdmi, csi, tvdac, i2c2, uartc, emc = 57, usb2,
+       usb3, mpe, vde, bsea, bsev, speedo, uartd, uarte, i2c3, sbc4, sdmmc3,
+       pex, owr, afi, csite, pcie_xclk, avpucq = 75, la, irama = 84, iramb,
+       iramc, iramd, cram2, audio_2x, clk_d, csus = 92, cdev1, cdev2,
Quoted 8 lines

arch/arm/mach-tegra/tegra20-car.c line 53

Quoted 7 lines
arch/arm/mach-tegra/tegra20-car.c new file +7 -0
+       uartb = 96, vfir, spdif_in, spdif_out, vi, vi_sensor, tvo, cve,
+       osc, clk_32k, clk_m, sclk, cclk, hclk, pclk, blink, pll_a, pll_a_out0,
+       pll_c, pll_c_out1, pll_d, pll_d_out0, pll_e, pll_m, pll_m_out1,
+       pll_p, pll_p_out1, pll_p_out2, pll_p_out3, pll_p_out4, pll_u,
+       pll_x, audio, pll_ref, twd, clk_max,
+};
+

Please remove unused constants or register appropriate clocks.

Maybe it makes sense to keep them. When they are in sync with the devicetree it means we could derive clocks from the devicetree should we ever want to. However, we could also do this later when we really need it, so I have no objection in either direction.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#37 lore raw

PATCH v2 4/5 tegra: add proper timer driver

In reply to Lucas Stach

Replace the ad-hoc clocksource implementation with a proper driver for the Tegra 20 timer. This driver is able to do the required hardware initialisation itself.

---
 arch/arm/mach-tegra/Makefile        |   2 +-
 arch/arm/mach-tegra/clock.c         |  56 -----------------
 arch/arm/mach-tegra/tegra20-car.c   |   5 ++
 arch/arm/mach-tegra/tegra20-timer.c | 120 ++++++++++++++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra20.c       |   4 ++
 5 files changed, 130 insertions(+), 57 deletions(-)
 delete mode 100644 arch/arm/mach-tegra/clock.c
 create mode 100644 arch/arm/mach-tegra/tegra20-timer.c
arch/arm/mach-tegra/Makefile +1 -1
index 3391528..6aa219c 100644
@@ -1,4 +1,4 @@
-obj-y += clock.o
 obj-y += reset.o
 obj-y += tegra20.o
 obj-y += tegra20-car.o
+obj-y += tegra20-timer.o
arch/arm/mach-tegra/clock.c deleted +0 -56

56 lines not on this page · raw message

arch/arm/mach-tegra/tegra20-car.c +5 -0
index eec3cc3..3ac389f 100644
@@ -23,6 +23,7 @@
 #include <init.h>
 #include <io.h>
 #include <linux/clk.h>
+#include <linux/clkdev.h>
 #include <linux/err.h>
 #include <mach/iomap.h>
 
@@ -97,6 +98,10 @@ static int tegra20_car_probe(struct device_d *dev)
 	/* timer is a gate, but as it's enabled by BOOTROM we needn't worry */
 	clks[timer] = clk_fixed_factor("timer", "clk_m", 1, 1);
 
+
+	/* device to clock links */
+	clkdev_add_physbase(clks[timer], TEGRA_TMR1_BASE, NULL);
+
 	return 0;
 }
 
arch/arm/mach-tegra/tegra20-timer.c new file +120 -0

120 lines not on this page · raw message

arch/arm/mach-tegra/tegra20.c +4 -0
index 3831f1b..c1b3f78 100644
@@ -24,6 +24,10 @@ static int tegra20_init(void)
 			   TEGRA_CLK_RESET_BASE, TEGRA_CLK_RESET_SIZE,
 			   IORESOURCE_MEM, NULL);
 
+	add_generic_device("tegra20-timer", DEVICE_ID_SINGLE, NULL,
+			   TEGRA_TMR1_BASE, TEGRA_TMR1_SIZE,
+			   IORESOURCE_MEM, NULL);
+
 	return 0;
 }
 
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#38 lore raw

Re: [PATCH v2 4/5] tegra: add proper timer driver

Quoted 100 lines · Lucas Stach

Replace the ad-hoc clocksource implementation with a proper driver for the Tegra 20 timer. This driver is able to do the required hardware initialisation itself.

---
 arch/arm/mach-tegra/Makefile        |   2 +-
 arch/arm/mach-tegra/clock.c         |  56 -----------------
 arch/arm/mach-tegra/tegra20-car.c   |   5 ++
 arch/arm/mach-tegra/tegra20-timer.c | 120 ++++++++++++++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra20.c       |   4 ++
 5 files changed, 130 insertions(+), 57 deletions(-)
 delete mode 100644 arch/arm/mach-tegra/clock.c
 create mode 100644 arch/arm/mach-tegra/tegra20-timer.c
arch/arm/mach-tegra/Makefile +1 -1
index 3391528..6aa219c 100644
@@ -1,4 +1,4 @@
-obj-y += clock.o
 obj-y += reset.o
 obj-y += tegra20.o
 obj-y += tegra20-car.o
+obj-y += tegra20-timer.o
arch/arm/mach-tegra/clock.c deleted +0 -56
deleted file mode 100644
index 82065ee..0000000
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2011 Antony Pavlov <[email protected]>
- *
- * This file is part of barebox.
- * 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 version 2
- * as published by the Free Software Foundation.
- *
- * 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.
- *
- */
-
-/**
- * @file
- * @brief Clocksource based on Tegra internal timer
- */
-
-#include <common.h>
-#include <clock.h>
-#include <linux/list.h>
-#include <linux/clk.h>
-#include <init.h>
-#include <asm/io.h>
-#include <mach/iomap.h>
-
-static void __iomem *timer_reg_base = (void __iomem *) (TEGRA_TMR1_BASE);
-
-#define timer_writel(value, reg) \
-       __raw_writel(value, (u32)timer_reg_base + (reg))
-#define timer_readl(reg) \
-       __raw_readl((u32)timer_reg_base + (reg))
-
-static uint64_t tegra_clocksource_read(void)
-{
-       return timer_readl(0x10);
-}
-
-static struct clocksource cs = {
-       .read   = tegra_clocksource_read,
-       .mask   = 0xffffffff,
-};
-
-/* FIXME: here we have no initialization. All initialization made by U-Boot */
-static int clocksource_init(void)
-{
-       cs.mult = clocksource_hz2mult(1000000, cs.shift);
-       init_clock(&cs);
-
-       return 0;
-}
-core_initcall(clocksource_init);
arch/arm/mach-tegra/tegra20-car.c +1 -0
index eec3cc3..3ac389f 100644
@@ -23,6 +23,7 @@
 #include <init.h>
 #include <io.h>
 #include <linux/clk.h>
+#include <linux/clkdev.h>
 #include <linux/err.h>
 #include <mach/iomap.h>
 

arch/arm/mach-tegra/tegra20-car.c static int tegra20_car_probe(struct device_d *dev) · line 101

Quoted 4 lines
arch/arm/mach-tegra/tegra20-car.c +1 -0
@@ -97,6 +98,10 @@ static int tegra20_car_probe(struct device_d *dev)
        /* timer is a gate, but as it's enabled by BOOTROM we needn't worry */
        clks[timer] = clk_fixed_factor("timer", "clk_m", 1, 1);
 
+

Please no extra empty line here.

Quoted 121 lines
arch/arm/mach-tegra/tegra20-car.c +3 -0
+       /* device to clock links */
+       clkdev_add_physbase(clks[timer], TEGRA_TMR1_BASE, NULL);
+
        return 0;
 }
 
arch/arm/mach-tegra/tegra20-timer.c new file +109 -0
new file mode 100644
index 0000000..6c1d302
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2013 Lucas Stach <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * @file
+ * @brief Device driver for the Tegra 20 timer, which exposes a clocksource.
+ */
+
+#include <common.h>
+#include <clock.h>
+#include <init.h>
+#include <io.h>
+#include <linux/clk.h>
+
+/* register definitions */
+#define TIMERUS_CNTR_1US       0x10
+#define TIMERUS_USEC_CFG       0x14
+
+static void __iomem *timer_base;
+
+static uint64_t tegra20_timer_cs_read(void)
+{
+       return readl(timer_base + TIMERUS_CNTR_1US);
+}
+
+static struct clocksource cs = {
+       .read   = tegra20_timer_cs_read,
+       .mask   = CLOCKSOURCE_MASK(32),
+};
+
+static int tegra20_timer_probe(struct device_d *dev)
+{
+       struct clk *timer_clk;
+       unsigned long rate;
+       u32 reg;
+
+       /* use only one timer */
+       if (timer_base)
+               return -EBUSY;
+
+       timer_base = dev_request_mem_region(dev, 0);
+       if (!timer_base) {
+               dev_err(dev, "could not get memory region\n");
+               return -ENODEV;
+       }
+
+       timer_clk = clk_get(dev, NULL);
+       if (!timer_clk) {
+               dev_err(dev, "could not get clock\n");
+               return -ENODEV;
+       }
+
+       clk_enable(timer_clk);
+
+       /*
+        * calibrate timer to run at 1MHz
+        * TIMERUS_USEC_CFG selects the scale down factor with bits [0:7]
+        * representing the divisor and bits [8:15] representing the dividend
+        * each in n+1 form.
+        */
+       rate = clk_get_rate(timer_clk);
+       switch (rate) {
+       case 12000000:
+               reg = 0x000b;
+               break;
+       case 13000000:
+               reg = 0x000c;
+               break;
+       case 19200000:
+               reg = 0x045f;
+               break;
+       case 26000000:
+               reg = 0x0019;
+               break;
+       default:
+               reg = 0;
+               dev_warn(dev, "unknown timer clock rate\n");
+               break;
+       }
+       writel(reg, timer_base + TIMERUS_USEC_CFG);
+
+       cs.mult = clocksource_hz2mult(1000000, cs.shift);
+       init_clock(&cs);
+
+       return 0;
+}
+
+static __maybe_unused struct of_device_id tegra20_timer_dt_ids[] = {
+       {
+               .compatible = "nvidia,tegra20-timer",
+       }, {
+               /* sentinel */
+       }
+};
+
+static struct driver_d tegra20_timer_driver = {

arch/arm/mach-tegra/tegra20-timer.c line 119

Quoted 10 lines
arch/arm/mach-tegra/tegra20-timer.c new file +10 -0
+       .probe  = tegra20_timer_probe,
+       .name   = "tegra20-timer",
+       .of_compatible = DRV_OF_COMPAT(tegra20_timer_dt_ids),
+};
+
+static int tegra20_timer_init(void)
+{
+       return platform_driver_register(&tegra20_timer_driver);
+}
+

In barebox there is a tradition to skip emty line before *_initcall. Try
grep -B1 -RHn "coredevice_initcall" arch/

Quoted 24 lines
arch/arm/mach-tegra/tegra20-timer.c new file +1 -0
+coredevice_initcall(tegra20_timer_init);
arch/arm/mach-tegra/tegra20.c +4 -1
index 3831f1b..c1b3f78 100644
@@ -24,6 +24,10 @@ static int tegra20_init(void)
                           TEGRA_CLK_RESET_BASE, TEGRA_CLK_RESET_SIZE,
                           IORESOURCE_MEM, NULL);
 
+       add_generic_device("tegra20-timer", DEVICE_ID_SINGLE, NULL,
+                          TEGRA_TMR1_BASE, TEGRA_TMR1_SIZE,
+                          IORESOURCE_MEM, NULL);
+
        return 0;
 }
 
--

1.8.1.2

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Signature · 7 lines
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#39 lore raw

PATCH v2 5/5 tegra: add power management controller driver

In reply to Lucas Stach

Currently only implements system wide reset functionality.

---
 arch/arm/mach-tegra/Makefile      |  2 +-
 arch/arm/mach-tegra/reset.c       | 39 -----------------
 arch/arm/mach-tegra/tegra20-pmc.c | 89 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra20.c     |  4 ++
 4 files changed, 94 insertions(+), 40 deletions(-)
 delete mode 100644 arch/arm/mach-tegra/reset.c
 create mode 100644 arch/arm/mach-tegra/tegra20-pmc.c
arch/arm/mach-tegra/Makefile +1 -1
index 6aa219c..bcc0cd4 100644
@@ -1,4 +1,4 @@
-obj-y += reset.o
 obj-y += tegra20.o
 obj-y += tegra20-car.o
+obj-y += tegra20-pmc.o
 obj-y += tegra20-timer.o
arch/arm/mach-tegra/reset.c deleted +0 -39
deleted file mode 100644
index 91f9b3b..0000000
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2011 Antony Pavlov <[email protected]>
- *
- * This file is part of barebox.
- * 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 version 2
- * as published by the Free Software Foundation.
- *
- * 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.
- *
- */
-
-/**
- * @file
- * @brief Resetting an malta board
- */
-
-#include <common.h>
-#include <asm/io.h>
-#include <mach/iomap.h>
-
-#define PRM_RSTCTRL		TEGRA_PMC_BASE
-
-void __noreturn reset_cpu(ulong addr)
-{
-	int rstctrl;
-
-	rstctrl = __raw_readl((char *)PRM_RSTCTRL);
-	rstctrl |= 0x10;
-	__raw_writel(rstctrl, (char *)PRM_RSTCTRL);
-
-	unreachable();
-}
-EXPORT_SYMBOL(reset_cpu);
arch/arm/mach-tegra/tegra20-pmc.c new file +89 -0

89 lines not on this page · raw message

arch/arm/mach-tegra/tegra20.c +4 -0
index c1b3f78..884671a 100644
@@ -28,6 +28,10 @@ static int tegra20_init(void)
 			   TEGRA_TMR1_BASE, TEGRA_TMR1_SIZE,
 			   IORESOURCE_MEM, NULL);
 
+	add_generic_device("tegra20-pmc", DEVICE_ID_SINGLE, NULL,
+			   TEGRA_PMC_BASE, TEGRA_PMC_SIZE,
+			   IORESOURCE_MEM, NULL);
+
 	return 0;
 }
 
Signature · 7 lines
1.8.1.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#40 lore raw

Re: [PATCH v2 5/5] tegra: add power management controller driver

Quoted 1 line · Lucas Stach

Currently only implements system wide reset functionality.

Please split this patch into two patches, one for reset_cpu()-related stuff and one for the rest.

Quoted 184 lines
---
 arch/arm/mach-tegra/Makefile      |  2 +-
 arch/arm/mach-tegra/reset.c       | 39 -----------------
 arch/arm/mach-tegra/tegra20-pmc.c | 89 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra20.c     |  4 ++
 4 files changed, 94 insertions(+), 40 deletions(-)
 delete mode 100644 arch/arm/mach-tegra/reset.c
 create mode 100644 arch/arm/mach-tegra/tegra20-pmc.c
arch/arm/mach-tegra/Makefile +1 -1
index 6aa219c..bcc0cd4 100644
@@ -1,4 +1,4 @@
-obj-y += reset.o
 obj-y += tegra20.o
 obj-y += tegra20-car.o
+obj-y += tegra20-pmc.o
 obj-y += tegra20-timer.o
arch/arm/mach-tegra/reset.c deleted +0 -39
deleted file mode 100644
index 91f9b3b..0000000
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2011 Antony Pavlov <[email protected]>
- *
- * This file is part of barebox.
- * 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 version 2
- * as published by the Free Software Foundation.
- *
- * 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.
- *
- */
-
-/**
- * @file
- * @brief Resetting an malta board
- */
-
-#include <common.h>
-#include <asm/io.h>
-#include <mach/iomap.h>
-
-#define PRM_RSTCTRL            TEGRA_PMC_BASE
-
-void __noreturn reset_cpu(ulong addr)
-{
-       int rstctrl;
-
-       rstctrl = __raw_readl((char *)PRM_RSTCTRL);
-       rstctrl |= 0x10;
-       __raw_writel(rstctrl, (char *)PRM_RSTCTRL);
-
-       unreachable();
-}
-EXPORT_SYMBOL(reset_cpu);
arch/arm/mach-tegra/tegra20-pmc.c new file +89 -0
new file mode 100644
index 0000000..ed765f5
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2013 Lucas Stach <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * @file
+ * @brief Device driver for the Tegra 20 power management controller.
+ */
+
+#include <common.h>
+#include <init.h>
+#include <io.h>
+
+/* register definitions */
+#define PMC_CNTRL                      0x00
+#define PMC_CNTRL_FUSE_OVERRIDE                (1 << 18)
+#define PMC_CNTRL_INTR_POLARITY                (1 << 17)
+#define PMC_CNTRL_CPUPWRREQ_OE         (1 << 16)
+#define PMC_CNTRL_CPUPWRREQ_POLARITY   (1 << 15)
+#define PMC_CNTRL_SIDE_EFFECT_LP0      (1 << 14)
+#define PMC_CNTRL_AOINIT               (1 << 13)
+#define PMC_CNTRL_PWRGATE_DIS          (1 << 12)
+#define PMC_CNTRL_SYSCLK_OE            (1 << 11)
+#define PMC_CNTRL_SYSCLK_POLARITY      (1 << 10)
+#define PMC_CNTRL_PWRREQ_OE            (1 << 9)
+#define PMC_CNTRL_PWRREQ_POLARITY      (1 << 8)
+#define PMC_CNTRL_BLINK_EN             (1 << 7)
+#define PMC_CNTRL_GLITCHDET_DIS                (1 << 6)
+#define PMC_CNTRL_LATCHWAKE_EN         (1 << 5)
+#define PMC_CNTRL_MAIN_RST             (1 << 4)
+#define PMC_CNTRL_KBC_RST              (1 << 3)
+#define PMC_CNTRL_RTC_RST              (1 << 2)
+#define PMC_CNTRL_RTC_CLK_DIS          (1 << 1)
+#define PMC_CNTRL_KBC_CLK_DIS          (1 << 0)
+
+static void __iomem *pmc_base;
+
+/* main SoC reset trigger */
+void __noreturn reset_cpu(ulong addr)
+{
+       writel(PMC_CNTRL_MAIN_RST, pmc_base + PMC_CNTRL);
+
+       unreachable();
+}
+EXPORT_SYMBOL(reset_cpu);
+
+static int tegra20_pmc_probe(struct device_d *dev)
+{
+       pmc_base = dev_request_mem_region(dev, 0);
+       if (!pmc_base) {
+               dev_err(dev, "could not get memory region\n");
+               return -ENODEV;
+       }
+
+       return 0;
+}
+
+static __maybe_unused struct of_device_id tegra20_pmc_dt_ids[] = {
+       {
+               .compatible = "nvidia,tegra20-pmc",
+       }, {
+               /* sentinel */
+       }
+};
+
+static struct driver_d tegra20_pmc_driver = {
+       .probe  = tegra20_pmc_probe,
+       .name   = "tegra20-pmc",
+       .of_compatible = DRV_OF_COMPAT(tegra20_pmc_dt_ids),
+};
+
+static int tegra20_pmc_init(void)
+{
+       return platform_driver_register(&tegra20_pmc_driver);
+}
+
+coredevice_initcall(tegra20_pmc_init);
arch/arm/mach-tegra/tegra20.c +4 -1
index c1b3f78..884671a 100644
@@ -28,6 +28,10 @@ static int tegra20_init(void)
                           TEGRA_TMR1_BASE, TEGRA_TMR1_SIZE,
                           IORESOURCE_MEM, NULL);
 
+       add_generic_device("tegra20-pmc", DEVICE_ID_SINGLE, NULL,
+                          TEGRA_PMC_BASE, TEGRA_PMC_SIZE,
+                          IORESOURCE_MEM, NULL);
+
        return 0;
 }
 
--

1.8.1.2

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Signature · 7 lines
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox