tegra: pull in iomap.h from the Linux kernel
Subsystems (5)
PATCH v4 1/13 tegra: pull in iomap.h from the Linux kernel
This synchronizes the Tegra iomap.h with the latest Linux kernel 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
@@ -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
PATCH v4 2/13 tegra: switch to proper CPU type
Tegras main CPUs are all ARMv7.
--- arch/arm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/Kconfig +1 -1
@@ -137,7 +137,7 @@ config ARCH_VEXPRESS config ARCH_TEGRA bool "Nvidia Tegra-based boards" - select CPU_ARM926T + select CPU_V7 select HAS_DEBUG_LL config ARCH_ZYNQ
Signature · 7 lines
1.8.1.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 3/13 tegra: unify spelling in Kconfig with Linux kernel
In reply to Lucas Stach--- arch/arm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/Kconfig +1 -1
@@ -136,7 +136,7 @@ config ARCH_VEXPRESS select COMMON_CLK config ARCH_TEGRA - bool "Nvidia Tegra-based boards" + bool "NVIDIA Tegra" select CPU_V7 select HAS_DEBUG_LL
Signature · 7 lines
1.8.1.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 4/13 tegra: introduce Tegra 20 SoC type
In reply to Lucas StachTegra isn't a single architecture, but a collection of more or less similar chip families. Introduce the same conf define as used in the Linux kernel to differentiate between those families.
Currently we are only supporting the Tegra20 chip type.
--- arch/arm/mach-tegra/Kconfig | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
arch/arm/mach-tegra/Kconfig +17 -1
@@ -1,11 +1,23 @@ if ARCH_TEGRA +choice + prompt "Tegra processor type" + +config ARCH_TEGRA_2x_SOC + bool "Tegra 20" + +endchoice + +# --------------------------------------------------------- + +if ARCH_TEGRA_2x_SOC + config ARCH_TEXT_BASE hex default 0x31fc0000 choice - prompt "Tegra Board Type" + prompt "Tegra 20 Board Type" config MACH_TOSHIBA_AC100 bool "Toshiba AC100"
@@ -16,4 +28,8 @@ endchoice source arch/arm/boards/toshiba-ac100/Kconfig +endif #ARCH_TEGRA_2x_SOC + +# --------------------------------------------------------- + endif
Signature · 7 lines
1.8.1.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 5/13 tegra: move default textbase
In reply to Lucas StachAll available opensource tools and published BCT configurations use 0x10800 as the default textbase on Tegra 20.
--- arch/arm/mach-tegra/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-tegra/Kconfig +1 -1
@@ -14,7 +14,7 @@ if ARCH_TEGRA_2x_SOC config ARCH_TEXT_BASE hex - default 0x31fc0000 + default 0x00108000 choice prompt "Tegra 20 Board Type"
Signature · 7 lines
1.8.1.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 6/13 tegra: switch to DT only
In reply to Lucas StachWe will follow the Linux kernel and go devicetree only for Tegra. This doesn't prevent specific code for certain boards, but always requires a valid DTB for all boards.
Also regenerate the AC100 defconfig to reflect this change.
---
v4: unbrick ac100 defconfig
--- arch/arm/Kconfig | 3 +++ arch/arm/configs/toshiba_ac100_defconfig | 6 ++++-- arch/arm/dts/tegra20-paz00.dts | 12 ++++++++++++ arch/arm/dts/tegra20.dtsi | 5 +++++ 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 arch/arm/dts/tegra20-paz00.dts create mode 100644 arch/arm/dts/tegra20.dtsi
arch/arm/Kconfig +3 -0
@@ -139,6 +139,9 @@ config ARCH_TEGRA bool "NVIDIA Tegra" select CPU_V7 select HAS_DEBUG_LL + select BUILTIN_DTB + select OFDEVICE + select OFTREE config ARCH_ZYNQ bool "Xilinx Zynq-based boards"
arch/arm/configs/toshiba_ac100_defconfig +4 -2
@@ -1,3 +1,4 @@ +CONFIG_BUILTIN_DTB_NAME="tegra20-paz00" CONFIG_ARCH_TEGRA=y CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y CONFIG_TEXT_BASE=0x01000000
@@ -14,6 +15,7 @@ CONFIG_ENABLE_DEVICE_NOISE=y CONFIG_CMD_SLEEP=y # CONFIG_CMD_TRUE is not set # CONFIG_CMD_FALSE is not set +CONFIG_CMD_TFTP=y CONFIG_CMD_LOADB=y CONFIG_CMD_LOADY=y CONFIG_CMD_LOADS=y
@@ -23,11 +25,10 @@ CONFIG_CMD_SHA1SUM=y CONFIG_CMD_BOOTM_SHOW_TYPE=y CONFIG_CMD_RESET=y CONFIG_CMD_GO=y +CONFIG_CMD_OFTREE=y CONFIG_NET=y CONFIG_NET_DHCP=y CONFIG_NET_PING=y -CONFIG_CMD_TFTP=y -CONFIG_FS_TFTP=y CONFIG_NET_NETCONSOLE=y CONFIG_DRIVER_SERIAL_NS16550=y CONFIG_NET_USB=y
@@ -36,4 +37,5 @@ CONFIG_NET_USB_ASIX=y CONFIG_USB=y CONFIG_USB_EHCI=y CONFIG_USB_STORAGE=y +CONFIG_FS_TFTP=y CONFIG_FS_FAT=y
arch/arm/dts/tegra20-paz00.dts new file +12 -0
@@ -0,0 +1,12 @@ +/dts-v1/; + +/include/ "tegra20.dtsi" + +/ { + model = "Toshiba AC100 / Dynabook AZ"; + compatible = "compal,paz00", "nvidia,tegra20"; + + memory { + reg = <0x00000000 0x20000000>; + }; +};
arch/arm/dts/tegra20.dtsi new file +5 -0
@@ -0,0 +1,5 @@ +/include/ "skeleton.dtsi" + +/ { + compatible = "nvidia,tegra20"; +};
Signature · 7 lines
1.8.1.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 7/13 tegra: add driver for the clock and reset module
In reply to Lucas StachOnly a basic set of clocks is supported. This is a temporary solution and will go away as soon as the port of the Tegra common clock code from the Linux kernel is ready to go.
--- arch/arm/Kconfig | 2 + arch/arm/dts/tegra20.dtsi | 6 ++ arch/arm/mach-tegra/Makefile | 1 + arch/arm/mach-tegra/include/mach/clkdev.h | 7 ++ arch/arm/mach-tegra/include/mach/tegra20-car.h | 22 +++++ arch/arm/mach-tegra/tegra20-car.c | 117 +++++++++++++++++++++++++ 6 files changed, 155 insertions(+) create mode 100644 arch/arm/mach-tegra/include/mach/clkdev.h create mode 100644 arch/arm/mach-tegra/include/mach/tegra20-car.h create mode 100644 arch/arm/mach-tegra/tegra20-car.c
arch/arm/Kconfig +2 -0
@@ -140,6 +140,8 @@ config ARCH_TEGRA select CPU_V7 select HAS_DEBUG_LL select BUILTIN_DTB + select COMMON_CLK + select CLKDEV_LOOKUP select OFDEVICE select OFTREE
arch/arm/dts/tegra20.dtsi +6 -0
@@ -2,4 +2,10 @@ / { compatible = "nvidia,tegra20"; + + tegra_car: clock { + compatible = "nvidia,tegra20-car"; + reg = <0x60006000 0x1000>; + #clock-cells = <1>; + }; };
arch/arm/mach-tegra/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-y += clock.o obj-y += reset.o +obj-y += tegra20-car.o
arch/arm/mach-tegra/include/mach/clkdev.h new file +7 -0
@@ -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/include/mach/tegra20-car.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* 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/>. +*/ + +/* Register definitions */ +#define CRC_OSC_CTRL 0x050 +#define CRC_OSC_CTRL_OSC_FREQ_SHIFT 30 +#define CRC_OSC_CTRL_OSC_FREQ_MASK (0x3 << CRC_OSC_CTRL_OSC_FREQ_SHIFT) +#define CRC_OSC_CTRL_PLL_REF_DIV_SHIFT 28 +#define CRC_OSC_CTRL_PLL_REF_DIV_MASK (0x3 << CRC_OSC_CTRL_PLL_REF_DIV_SHIFT)
arch/arm/mach-tegra/tegra20-car.c new file +117 -0
117 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
PATCH v4 8/13 tegra: add T20 timer driver
In reply to Lucas StachReplace 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/dts/tegra20.dtsi | 9 +++ arch/arm/mach-tegra/Makefile | 2 +- arch/arm/mach-tegra/clock.c | 56 ----------------- arch/arm/mach-tegra/tegra20-car.c | 4 ++ arch/arm/mach-tegra/tegra20-timer.c | 119 ++++++++++++++++++++++++++++++++++++ 5 files changed, 133 insertions(+), 57 deletions(-) delete mode 100644 arch/arm/mach-tegra/clock.c create mode 100644 arch/arm/mach-tegra/tegra20-timer.c
arch/arm/dts/tegra20.dtsi +9 -0
@@ -3,6 +3,15 @@ / { compatible = "nvidia,tegra20"; + timer@60005000 { + compatible = "nvidia,tegra20-timer"; + reg = <0x60005000 0x60>; + interrupts = <0 0 0x04 + 0 1 0x04 + 0 41 0x04 + 0 42 0x04>; + }; + tegra_car: clock { compatible = "nvidia,tegra20-car"; reg = <0x60006000 0x1000>;
arch/arm/mach-tegra/Makefile +1 -1
@@ -1,3 +1,3 @@ -obj-y += clock.o obj-y += reset.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 +4 -0
@@ -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>
@@ -93,6 +94,9 @@ 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 +119 -0
119 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
PATCH v4 9/13 tegra: add T20 power management controller driver
In reply to Lucas StachCurrently only implements system wide reset functionality.
--- arch/arm/dts/tegra20.dtsi | 5 ++ arch/arm/mach-tegra/Makefile | 2 +- arch/arm/mach-tegra/include/mach/tegra20-pmc.h | 37 ++++++++++++++ arch/arm/mach-tegra/reset.c | 39 --------------- arch/arm/mach-tegra/tegra20-pmc.c | 68 ++++++++++++++++++++++++++ 5 files changed, 111 insertions(+), 40 deletions(-) create mode 100644 arch/arm/mach-tegra/include/mach/tegra20-pmc.h delete mode 100644 arch/arm/mach-tegra/reset.c create mode 100644 arch/arm/mach-tegra/tegra20-pmc.c
arch/arm/dts/tegra20.dtsi +5 -0
@@ -17,4 +17,9 @@ reg = <0x60006000 0x1000>; #clock-cells = <1>; }; + + pmc { + compatible = "nvidia,tegra20-pmc"; + reg = <0x7000e400 0x400>; + }; };
arch/arm/mach-tegra/Makefile +1 -1
@@ -1,3 +1,3 @@ -obj-y += reset.o obj-y += tegra20-car.o +obj-y += tegra20-pmc.o obj-y += tegra20-timer.o
arch/arm/mach-tegra/include/mach/tegra20-pmc.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* 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/>. +*/ + +/* register definitions */ +#define PMC_CNTRL 0x000 +#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)
arch/arm/mach-tegra/reset.c deleted +0 -39
@@ -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 +68 -0
68 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
PATCH v4 10/13 tegra: add common lowlevel startup
In reply to Lucas StachAll Tegra20 boards have a common startup sequence. Also there is an agreement on how to find out about the installed amount of RAM and other information needed by early startup. So as there is really no need to do any lowlevel stuff per board, we can just do it at the ARCH level.
This also enables the first stage loading of barebox by detecting the currently running CPU and booting the main CPU cluster if neccesary.
--- arch/arm/boards/toshiba-ac100/Makefile | 1 - arch/arm/boards/toshiba-ac100/lowlevel.c | 10 -- arch/arm/mach-tegra/Makefile | 3 + arch/arm/mach-tegra/include/mach/iomap.h | 3 + arch/arm/mach-tegra/include/mach/lowlevel.h | 113 ++++++++++++ arch/arm/mach-tegra/include/mach/tegra20-car.h | 157 +++++++++++++++++ arch/arm/mach-tegra/include/mach/tegra20-pmc.h | 30 ++++ arch/arm/mach-tegra/tegra_avp_init.c | 228 +++++++++++++++++++++++++ arch/arm/mach-tegra/tegra_maincomplex_init.c | 46 +++++ 9 files changed, 580 insertions(+), 11 deletions(-) delete mode 100644 arch/arm/boards/toshiba-ac100/lowlevel.c create mode 100644 arch/arm/mach-tegra/include/mach/lowlevel.h create mode 100644 arch/arm/mach-tegra/tegra_avp_init.c create mode 100644 arch/arm/mach-tegra/tegra_maincomplex_init.c
arch/arm/boards/toshiba-ac100/Makefile +0 -1
@@ -1,3 +1,2 @@ obj-y += board.o obj-$(CONFIG_DRIVER_SERIAL_NS16550) += serial.o -lwl-y += lowlevel.o
arch/arm/boards/toshiba-ac100/lowlevel.c deleted +0 -10
@@ -1,10 +0,0 @@ -#include <common.h> -#include <sizes.h> -#include <asm/barebox-arm-head.h> -#include <asm/barebox-arm.h> - -void __naked barebox_arm_reset_vector (void ) -{ -arm_cpu_lowlevel_init (); -barebox_arm_entry (0x0 ,SZ_512M ,0 ); -}
arch/arm/mach-tegra/Makefile +3 -0
@@ -1,3 +1,6 @@ +CFLAGS_tegra_avp_init.o := -mcpu=arm7tdmi -march=armv4t +lwl-y += tegra_avp_init.o +lwl-y += tegra_maincomplex_init.o obj-y += tegra20-car.o obj-y += tegra20-pmc.o obj-y += tegra20-timer.o
arch/arm/mach-tegra/include/mach/iomap.h +3 -0
@@ -59,6 +59,9 @@#define TEGRA_GART_BASE 0x58000000#define TEGRA_GART_SIZE SZ_32M +#define TEGRA_UP_TAG_BASE 0x60000000 +#define TEGRA_UP_TAG_SIZE SZ_4K +#define TEGRA_RES_SEMA_BASE 0x60001000#define TEGRA_RES_SEMA_SIZE SZ_4K
arch/arm/mach-tegra/include/mach/lowlevel.h new file +113 -0
113 lines not on this page · raw message
arch/arm/mach-tegra/include/mach/tegra20-car.h +157 -0
165 lines not on this page · raw message
arch/arm/mach-tegra/include/mach/tegra20-pmc.h +30 -0
@@ -35,3 +35,33 @@#define PMC_CNTRL_RTC_RST (1 << 2)#define PMC_CNTRL_RTC_CLK_DIS (1 << 1)#define PMC_CNTRL_KBC_CLK_DIS (1 << 0) + +#define PMC_PWRGATE_TOGGLE 0x030 +#define PMC_PWRGATE_TOGGLE_PARTID_SHIFT 0 +#define PMC_PWRGATE_TOGGLE_PARTID_MASK (0x3 << PMC_PWRGATE_TOGGLE_PARTID_SHIFT) +#define PMC_PWRGATE_TOGGLE_PARTID_CPU 0 +#define PMC_PWRGATE_TOGGLE_PARTID_TD 1 +#define PMC_PWRGATE_TOGGLE_PARTID_VE 2 +#define PMC_PWRGATE_TOGGLE_PARTID_PCX 3 +#define PMC_PWRGATE_TOGGLE_PARTID_VDE 4 +#define PMC_PWRGATE_TOGGLE_PARTID_L2C 5 +#define PMC_PWRGATE_TOGGLE_PARTID_MPE 6 +#define PMC_PWRGATE_TOGGLE_START (1 << 8) + +#define PMC_REMOVE_CLAMPING_CMD 0x034 +#define PMC_REMOVE_CLAMPING_CMD_MPE (1 << 6) +#define PMC_REMOVE_CLAMPING_CMD_L2C (1 << 5) +#define PMC_REMOVE_CLAMPING_CMD_PCX (1 << 4) +#define PMC_REMOVE_CLAMPING_CMD_VDE (1 << 3) +#define PMC_REMOVE_CLAMPING_CMD_VE (1 << 2) +#define PMC_REMOVE_CLAMPING_CMD_TD (1 << 1) +#define PMC_REMOVE_CLAMPING_CMD_CPU (1 << 0) + +#define PMC_PWRGATE_STATUS 0x038 +#define PMC_PWRGATE_STATUS_MPE (1 << 6) +#define PMC_PWRGATE_STATUS_L2C (1 << 5) +#define PMC_PWRGATE_STATUS_VDE (1 << 4) +#define PMC_PWRGATE_STATUS_PCX (1 << 3) +#define PMC_PWRGATE_STATUS_VE (1 << 2) +#define PMC_PWRGATE_STATUS_TD (1 << 1) +#define PMC_PWRGATE_STATUS_CPU (1 << 0)
arch/arm/mach-tegra/tegra_avp_init.c new file +228 -0
228 lines not on this page · raw message
arch/arm/mach-tegra/tegra_maincomplex_init.c new file +46 -0
46 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
PATCH v4 11/13 tegra: add generic debug UART support
In reply to Lucas StachODMdata tells us which UART to use for debugging purposes. This is agreed upon in both the upstream Linux kernel and U-Boot, so do it the same way in barebox.
---
v4:
- fix rebase error
- provide Kconfig option to ovveride ODMdata
--- arch/arm/boards/toshiba-ac100/Makefile | 1 - arch/arm/boards/toshiba-ac100/serial.c | 39 -------------------- arch/arm/configs/toshiba_ac100_defconfig | 1 + arch/arm/mach-tegra/Kconfig | 33 +++++++++++++++++ arch/arm/mach-tegra/Makefile | 1 + arch/arm/mach-tegra/include/mach/lowlevel.h | 34 +++++++++++++++++ arch/arm/mach-tegra/tegra20.c | 57 +++++++++++++++++++++++++++++ 7 files changed, 126 insertions(+), 40 deletions(-) delete mode 100644 arch/arm/boards/toshiba-ac100/serial.c create mode 100644 arch/arm/mach-tegra/tegra20.c
arch/arm/boards/toshiba-ac100/Makefile +0 -1
@@ -1,2 +1 @@ obj-y += board.o -obj-$(CONFIG_DRIVER_SERIAL_NS16550) += serial.o
arch/arm/boards/toshiba-ac100/serial.c deleted +0 -39
@@ -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. -*/ - -#include <common.h> -#include <types.h> -#include <driver.h> -#include <init.h> -#include <ns16550.h> -#include <asm/io.h> -#include <asm/common.h> -#include <mach/iomap.h> - -static struct NS16550_plat serial_plat = { - .clock =0x75 *115200 *16 /* MODE_X_DIV */ , - .shift =2 , -}; - -static int ac100_serial_console_init (void ) -{ -/* Register the serial port */ -add_ns16550_device (DEVICE_ID_DYNAMIC ,TEGRA_UARTA_BASE ,8 << serial_plat.shift, -IORESOURCE_MEM_8BIT , &serial_plat); - -return 0 ; -} -console_initcall (ac100_serial_console_init);
arch/arm/configs/toshiba_ac100_defconfig +1 -0
@@ -1,5 +1,6 @@ CONFIG_BUILTIN_DTB_NAME="tegra20-paz00" CONFIG_ARCH_TEGRA=y +CONFIG_TEGRA_UART_A=y CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y CONFIG_TEXT_BASE=0x01000000 CONFIG_BROKEN=y
arch/arm/mach-tegra/Kconfig +33 -0
@@ -8,6 +8,39 @@ config ARCH_TEGRA_2x_SOC endchoice +choice + prompt "Tegra debug UART" + help + This is the first serial console that gets activated by barebox. + Normally each board vendor should program a valid debug UART into + the ODMdata section of the boot configuration table, so it's a + reasonably good bet to use that. + If you know your ODMdata is broken, or you don't wish to activate + any serial console at all you can override the default here. + +config TEGRA_UART_ODMDATA + bool "ODMdata defined UART" + +config TEGRA_UART_A + bool "UART A" + +config TEGRA_UART_B + bool "UART B" + +config TEGRA_UART_C + bool "UART C" + +config TEGRA_UART_D + bool "UART D" + +config TEGRA_UART_E + bool "UART E" + +config TEGRA_UART_NONE + bool "None" + +endchoice + # --------------------------------------------------------- if ARCH_TEGRA_2x_SOC
arch/arm/mach-tegra/Makefile +1 -0
@@ -1,6 +1,7 @@ CFLAGS_tegra_avp_init.o := -mcpu=arm7tdmi -march=armv4t lwl-y += tegra_avp_init.o lwl-y += tegra_maincomplex_init.o +obj-y += tegra20.o obj-y += tegra20-car.o obj-y += tegra20-pmc.o obj-y += tegra20-timer.o
arch/arm/mach-tegra/include/mach/lowlevel.h +34 -0
@@ -35,6 +35,10 @@#define T20_ODMDATA_RAMSIZE_SHIFT 28#define T20_ODMDATA_RAMSIZE_MASK (3 << T20_ODMDATA_RAMSIZE_SHIFT) +#define T20_ODMDATA_UARTTYPE_SHIFT 18 +#define T20_ODMDATA_UARTTYPE_MASK (3 << T20_ODMDATA_UARTTYPE_SHIFT) +#define T20_ODMDATA_UARTID_SHIFT 15 +#define T20_ODMDATA_UARTID_MASK (7 << T20_ODMDATA_UARTID_SHIFT)static inline u32 tegra_get_odmdata (void ) {
@@ -109,5 +113,35 @@ static inline uint32_t tegra20_get_ramsize(void) } } +static long uart_id_to_base[] = { +TEGRA_UARTA_BASE , +TEGRA_UARTB_BASE , +TEGRA_UARTC_BASE , +TEGRA_UARTD_BASE , +TEGRA_UARTE_BASE , +}; + +static inline long tegra20_get_debuguart_base (void ) +{ +u32 odmdata; +int id; + + odmdata =tegra_get_odmdata (); + +/* +* Get type, we accept both "2" and "3", as they both demark a UART, +* depending on the board type. +*/ +if (!(((odmdata &T20_ODMDATA_UARTTYPE_MASK ) >> +T20_ODMDATA_UARTTYPE_SHIFT ) &0x2 )) +return 0 ; + + id = (odmdata &T20_ODMDATA_UARTID_MASK ) >>T20_ODMDATA_UARTID_SHIFT ; +if (id >ARRAY_SIZE (uart_id_to_base)) +return 0 ; + +return uart_id_to_base[id]; +} +/* reset vector for the main CPU complex */ void tegra_maincomplex_entry (void );
arch/arm/mach-tegra/tegra20.c new file +57 -0
57 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
Re: [PATCH v4 11/13] tegra: add generic debug UART support
Quoted 220 lines · On Wed, 10 Apr 2013 11:14:53 +0200 Lucas Stach <[email protected]> wrote:
ODMdata tells us which UART to use for debugging purposes. This is agreed upon in both the upstream Linux kernel and U-Boot, so do it the same way in barebox.
Signed-off-by Lucas Stach <[email protected]>---
v4:
- fix rebase error
- provideKconfigoption to ovveride ODMdata--- arch/arm/boards/toshiba-ac100/Makefile | 1 - arch/arm/boards/toshiba-ac100/serial.c | 39 -------------------- arch/arm/configs/toshiba_ac100_defconfig | 1 + arch/arm/mach-tegra/Kconfig | 33 +++++++++++++++++ arch/arm/mach-tegra/Makefile | 1 + arch/arm/mach-tegra/include/mach/lowlevel.h | 34 +++++++++++++++++ arch/arm/mach-tegra/tegra20.c | 57 +++++++++++++++++++++++++++++ 7 files changed, 126 insertions(+), 40 deletions(-) delete mode 100644 arch/arm/boards/toshiba-ac100/serial.c create mode 100644 arch/arm/mach-tegra/tegra20.carch/arm/boards/toshiba-ac100/Makefile +0
-1@@ -1,2 +1 @@ obj-y += board.o -obj-$(CONFIG_DRIVER_SERIAL_NS16550) += serial.oarch/arm/boards/toshiba-ac100/serial.c deleted +0
-39@@ -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. -*/ - -#include <common.h> -#include <types.h> -#include <driver.h> -#include <init.h> -#include <ns16550.h> -#include <asm/io.h> -#include <asm/common.h> -#include <mach/iomap.h> - -static struct NS16550_plat serial_plat = { - .clock =0x75 *115200 *16 /* MODE_X_DIV */ , - .shift =2 , -}; - -static int ac100_serial_console_init (void ) -{ -/* Register the serial port */ -add_ns16550_device (DEVICE_ID_DYNAMIC ,TEGRA_UARTA_BASE ,8 << serial_plat.shift, -IORESOURCE_MEM_8BIT , &serial_plat); - -return 0 ; -} -console_initcall (ac100_serial_console_init);arch/arm/configs/toshiba_ac100_defconfig +1
-0@@ -1,5 +1,6 @@ CONFIG_BUILTIN_DTB_NAME="tegra20-paz00" CONFIG_ARCH_TEGRA=y +CONFIG_TEGRA_UART_A=y CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y CONFIG_TEXT_BASE=0x01000000 CONFIG_BROKEN=yarch/arm/mach-tegra/Kconfig +33
-0@@ -8,6 +8,39 @@ config ARCH_TEGRA_2x_SOC endchoice +choice + prompt "Tegra debug UART" + help + This is the first serial console that gets activated by barebox. + Normally each board vendor should program a valid debug UART into + the ODMdata section of the boot configuration table, so it's a + reasonably good bet to use that. + If you know your ODMdata is broken, or you don't wish to activate + any serial console at all you can override the default here. + +config TEGRA_UART_ODMDATA + bool "ODMdata defined UART" + +config TEGRA_UART_A + bool "UART A" + +config TEGRA_UART_B + bool "UART B" + +config TEGRA_UART_C + bool "UART C" + +config TEGRA_UART_D + bool "UART D" + +config TEGRA_UART_E + bool "UART E" + +config TEGRA_UART_NONE + bool "None" + +endchoice + # --------------------------------------------------------- if ARCH_TEGRA_2x_SOCarch/arm/mach-tegra/Makefile +1
-0@@ -1,6 +1,7 @@ CFLAGS_tegra_avp_init.o := -mcpu=arm7tdmi -march=armv4t lwl-y += tegra_avp_init.o lwl-y += tegra_maincomplex_init.o +obj-y += tegra20.o obj-y += tegra20-car.o obj-y += tegra20-pmc.o obj-y += tegra20-timer.oarch/arm/mach-tegra/include/mach/lowlevel.h +34
-0@@ -35,6 +35,10 @@#define T20_ODMDATA_RAMSIZE_SHIFT 28#define T20_ODMDATA_RAMSIZE_MASK (3 << T20_ODMDATA_RAMSIZE_SHIFT) +#define T20_ODMDATA_UARTTYPE_SHIFT 18 +#define T20_ODMDATA_UARTTYPE_MASK (3 << T20_ODMDATA_UARTTYPE_SHIFT) +#define T20_ODMDATA_UARTID_SHIFT 15 +#define T20_ODMDATA_UARTID_MASK (7 << T20_ODMDATA_UARTID_SHIFT)static inline u32 tegra_get_odmdata (void ) {@@ -109,5 +113,35 @@ static inline uint32_t tegra20_get_ramsize(void) } } +static long uart_id_to_base[] = { +TEGRA_UARTA_BASE , +TEGRA_UARTB_BASE , +TEGRA_UARTC_BASE , +TEGRA_UARTD_BASE , +TEGRA_UARTE_BASE , +}; + +static inline long tegra20_get_debuguart_base (void ) +{ +u32 odmdata; +int id; + + odmdata =tegra_get_odmdata (); + +/* +* Get type, we accept both "2" and "3", as they both demark a UART, +* depending on the board type. +*/ +if (!(((odmdata &T20_ODMDATA_UARTTYPE_MASK ) >> +T20_ODMDATA_UARTTYPE_SHIFT ) &0x2 )) +return 0 ; + + id = (odmdata &T20_ODMDATA_UARTID_MASK ) >>T20_ODMDATA_UARTID_SHIFT ; +if (id >ARRAY_SIZE (uart_id_to_base)) +return 0 ; + +return uart_id_to_base[id]; +} +/* reset vector for the main CPU complex */ void tegra_maincomplex_entry (void );arch/arm/mach-tegra/tegra20.c new file +23
-0@@ -0,0 +1,57 @@ +/* +* 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 <ns16550.h> +#include <mach/iomap.h> +#include <mach/lowlevel.h> + +static struct NS16550_plat debug_uart = {
arch/arm/mach-tegra/tegra20.c line 33
Quoted 10 lines
arch/arm/mach-tegra/tegra20.c new file +10
-0+ .clock = 216000000, /* pll_p rate */ + .shift = 2, +}; + +static int tegra20_add_debug_console (void ) +{ +unsigned long base =0 ; + +/* figure out which UART to use */ +#if defined(CONFIG_TEGRA_UART_NONE )
There is a practice to avoid preprocessor directives in the .c-files for checking CONFIG_* options.
Use the IS_ENABLED() macro instead.
Quoted 27 lines
arch/arm/mach-tegra/tegra20.c new file +24
-0+return 0 ; +#elif defined(CONFIG_TEGRA_UART_ODMDATA ) + base =tegra20_get_debuguart_base (); +#elif defined(CONFIG_TEGRA_UART_A ) + base =TEGRA_UARTA_BASE ; +#elif defined(CONFIG_TEGRA_UART_B ) + base =TEGRA_UARTB_BASE ; +#elif defined(CONFIG_TEGRA_UART_C ) + base =TEGRA_UARTC_BASE ; +#elif defined(CONFIG_TEGRA_UART_D ) + base =TEGRA_UARTD_BASE ; +#elif defined(CONFIG_TEGRA_UART_E ) + base =TEGRA_UARTE_BASE ; +#endif + +if (!base) +return -ENODEV ; + +add_ns16550_device (DEVICE_ID_DYNAMIC , base,8 << debug_uart.shift, +IORESOURCE_MEM_8BIT , &debug_uart); + +return 0 ; +} +console_initcall (tegra20_add_debug_console);Signature · 1 line
1.8.1.2
Signature · 8 lines
-- Best regards, Antony Pavlov _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 12/13 tegra: add generic meminit
In reply to Lucas StachODMdata tells us how much RAM is installed, so no need to define this at the board level.
--- arch/arm/boards/toshiba-ac100/board.c | 8 -------- arch/arm/mach-tegra/tegra20.c | 9 +++++++++ 2 files changed, 9 insertions(+), 8 deletions(-)
arch/arm/boards/toshiba-ac100/board.c +0 -8
@@ -23,14 +23,6 @@#include <usb/ehci.h> #include <mach/iomap.h> -static int ac100_mem_init (void ) -{ -arm_add_mem_device ("ram0" ,0x0 ,SZ_512M ); - -return 0 ; -} -mem_initcall (ac100_mem_init); -static struct ehci_platform_data ehci_pdata = { .flags =EHCI_HAS_TT , };
arch/arm/mach-tegra/tegra20.c +9 -0
@@ -17,6 +17,7 @@#include <common.h> #include <init.h> #include <ns16550.h> +#include <asm/memory.h> #include <mach/iomap.h> #include <mach/lowlevel.h>
@@ -55,3 +56,11 @@ static int tegra20_add_debug_console(void)return 0 ; }console_initcall (tegra20_add_debug_console); + +static int tegra20_mem_init (void ) +{ +arm_add_mem_device ("ram0" ,0x0 ,tegra20_get_ramsize ()); + +return 0 ; +} +mem_initcall (tegra20_mem_init);
Signature · 7 lines
1.8.1.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 13/13 tegra: add GPIO controller driver
In reply to Lucas StachTaken from the Linux kernel, simplified and reworked to match barebox.
---
v4: remove Tegra 30 parts for now
--- arch/arm/Kconfig | 2 + arch/arm/dts/tegra20.dtsi | 16 +++ arch/arm/mach-tegra/include/mach/gpio.h | 1 + drivers/gpio/Kconfig | 7 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-tegra.c | 214 ++++++++++++++++++++++++++++++++ 6 files changed, 241 insertions(+) create mode 100644 arch/arm/mach-tegra/include/mach/gpio.h create mode 100644 drivers/gpio/gpio-tegra.c
arch/arm/Kconfig +2 -0
@@ -142,6 +142,8 @@ config ARCH_TEGRA select BUILTIN_DTB select COMMON_CLK select CLKDEV_LOOKUP + select GPIOLIB + select GPIO_TEGRA select OFDEVICE select OFTREE
arch/arm/dts/tegra20.dtsi +16 -0
@@ -18,6 +18,22 @@ #clock-cells = <1>; }; + gpio: gpio { + compatible = "nvidia,tegra20-gpio"; + reg = <0x6000d000 0x1000>; + interrupts = <0 32 0x04 + 0 33 0x04 + 0 34 0x04 + 0 35 0x04 + 0 55 0x04 + 0 87 0x04 + 0 89 0x04>; + #gpio-cells = <2>; + gpio-controller; + #interrupt-cells = <2>; + interrupt-controller; + }; + pmc { compatible = "nvidia,tegra20-pmc"; reg = <0x7000e400 0x400>;
arch/arm/mach-tegra/include/mach/gpio.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/gpio.h>
drivers/gpio/Kconfig +7 -0
@@ -36,6 +36,13 @@ config GPIO_PL061 config GPIO_STMPE depends on MFD_STMPE bool "STMPE GPIO Expander" + +config GPIO_TEGRA + bool "GPIO support for the Tegra SoCs" + depends on ARCH_TEGRA + help + Say yes here to include the driver for the GPIO controller found on the + Tegra line of SoCs. endmenu endif
drivers/gpio/Makefile +1 -0
@@ -4,3 +4,4 @@ obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o obj-$(CONFIG_GPIO_PL061) += gpio-pl061.o obj-$(CONFIG_GPIO_STMPE) += gpio-stmpe.o +obj-$(CONFIG_GPIO_TEGRA) += gpio-tegra.o
drivers/gpio/gpio-tegra.c new file +214 -0
214 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
Re: [PATCH v4 13/13] tegra: add GPIO controller driver
Quoted 139 lines · On Wed, 10 Apr 2013 11:14:55 +0200 Lucas Stach <[email protected]> wrote:
Taken from the Linux kernel, simplified and reworked to match barebox.
Signed-off-by Lucas Stach <[email protected]>---
v4: remove Tegra 30 parts for now--- arch/arm/Kconfig | 2 + arch/arm/dts/tegra20.dtsi | 16 +++ arch/arm/mach-tegra/include/mach/gpio.h | 1 + drivers/gpio/Kconfig | 7 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-tegra.c | 214 ++++++++++++++++++++++++++++++++ 6 files changed, 241 insertions(+) create mode 100644 arch/arm/mach-tegra/include/mach/gpio.h create mode 100644 drivers/gpio/gpio-tegra.carch/arm/Kconfig +2
-0@@ -142,6 +142,8 @@ config ARCH_TEGRA select BUILTIN_DTB select COMMON_CLK select CLKDEV_LOOKUP + select GPIOLIB + select GPIO_TEGRA select OFDEVICE select OFTREEarch/arm/dts/tegra20.dtsi +16
-0@@ -18,6 +18,22 @@ #clock-cells = <1>; }; + gpio: gpio { + compatible = "nvidia,tegra20-gpio"; + reg = <0x6000d000 0x1000>; + interrupts = <0 32 0x04 + 0 33 0x04 + 0 34 0x04 + 0 35 0x04 + 0 55 0x04 + 0 87 0x04 + 0 89 0x04>; + #gpio-cells = <2>; + gpio-controller; + #interrupt-cells = <2>; + interrupt-controller; + }; + pmc { compatible = "nvidia,tegra20-pmc"; reg = <0x7000e400 0x400>;arch/arm/mach-tegra/include/mach/gpio.h new file +1
-0@@ -0,0 +1 @@ +#include <asm-generic/gpio.h> drivers/gpio/Kconfig +7
-0@@ -36,6 +36,13 @@ config GPIO_PL061 config GPIO_STMPE depends on MFD_STMPE bool "STMPE GPIO Expander" + +config GPIO_TEGRA + bool "GPIO support for the Tegra SoCs" + depends on ARCH_TEGRA + help + Say yes here to include the driver for the GPIO controller found on the + Tegra line of SoCs. endmenu endifdrivers/gpio/Makefile +1
-0@@ -4,3 +4,4 @@ obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o obj-$(CONFIG_GPIO_PL061) += gpio-pl061.o obj-$(CONFIG_GPIO_STMPE) += gpio-stmpe.o +obj-$(CONFIG_GPIO_TEGRA) += gpio-tegra.odrivers/gpio/gpio-tegra.c new file +43
-0@@ -0,0 +1,214 @@ +/* * +* Copyright (C) 2010 Erik Gilling <[email protected]>, Google, Inc +* 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 <gpio.h> +#include <init.h> +#include <io.h> +#include <linux/err.h> + +#define GPIO_BANK (x) ((x) >> 5) +#define GPIO_PORT (x) (((x) >> 3) & 0x3) +#define GPIO_BIT (x) ((x) & 0x7) + +#define GPIO_REG (x) (GPIO_BANK(x) * config->bank_stride + \ + GPIO_PORT(x) * 4) + +#define GPIO_CNF (x) (GPIO_REG(x) + 0x00) +#define GPIO_OE (x) (GPIO_REG(x) + 0x10) +#define GPIO_OUT (x) (GPIO_REG(x) + 0x20) +#define GPIO_IN (x) (GPIO_REG(x) + 0x30) +#define GPIO_INT_ENB (x) (GPIO_REG(x) + 0x50) + +#define GPIO_MSK_CNF (x) (GPIO_REG(x) + config->upper_offset + 0x00) +#define GPIO_MSK_OE (x) (GPIO_REG(x) + config->upper_offset + 0x10) +#define GPIO_MSK_OUT (x) (GPIO_REG(x) + config->upper_offset + 0X20) + +struct tegra_gpio_bank { +int bank; +int irq;
drivers/gpio/gpio-tegra.c line 53
Quoted 10 lines
drivers/gpio/gpio-tegra.c new file +10
-0+}; + +struct tegra_gpio_soc_config { +u32 bank_stride; +u32 upper_offset; +u32 bank_count; +}; + +static void __iomem *gpio_base; +static struct tegra_gpio_soc_config *config;
The scripts/checkpatch.pl reports about formatting error here:
WARNING: please, no space before tabs
#175: FILE: drivers/gpio/gpio-tegra.c:53:
+static ^Istruct tegra_gpio_soc_config *config;$
Quoted 164 lines
drivers/gpio/gpio-tegra.c new file +161
-0+ +static inline void tegra_gpio_writel (u32 val,u32 reg) +{ +writel (val, gpio_base + reg); +} + +static inline u32 tegra_gpio_readl (u32 reg) +{ +return readl (gpio_base + reg); +} + +static int tegra_gpio_compose (int bank,int port,int bit) +{ +return (bank <<5 ) | ((port &0x3 ) <<3 ) | (bit &0x7 ); +} + +static void tegra_gpio_mask_write (u32 reg,int gpio,int value) +{ +u32 val; + + val =0x100 <<GPIO_BIT (gpio); +if (value) + val |=1 <<GPIO_BIT (gpio); +tegra_gpio_writel (val, reg); +} + +static void tegra_gpio_enable (int gpio) +{ +tegra_gpio_mask_write (GPIO_MSK_CNF (gpio), gpio,1 ); +} + +static void tegra_gpio_disable (int gpio) +{ +tegra_gpio_mask_write (GPIO_MSK_CNF (gpio), gpio,0 ); +} + +static int tegra_gpio_request (struct gpio_chip *chip,unsigned offset) +{ +return 0 ; +} + +static void tegra_gpio_free (struct gpio_chip *chip,unsigned offset) +{ +tegra_gpio_disable (offset); +} + +static void tegra_gpio_set (struct gpio_chip *chip,unsigned offset,int value) +{ +tegra_gpio_mask_write (GPIO_MSK_OUT (offset), offset, value); +} + +static int tegra_gpio_get (struct gpio_chip *chip,unsigned offset) +{ +/* If gpio is in output mode then read from the out value */ +if ((tegra_gpio_readl (GPIO_OE (offset)) >>GPIO_BIT (offset)) &1 ) { +printf ("GPIO output mode\n" ); +return (tegra_gpio_readl (GPIO_OUT (offset)) >> +GPIO_BIT (offset)) &0x1 ; + } + +printf ("GPIO input mode\n" ); +return (tegra_gpio_readl (GPIO_IN (offset)) >>GPIO_BIT (offset)) &0x1 ; +} + +static int tegra_gpio_direction_input (struct gpio_chip *chip,unsigned offset) +{ +tegra_gpio_mask_write (GPIO_MSK_OE (offset), offset,0 ); +tegra_gpio_enable (offset); +return 0 ; +} + +static int tegra_gpio_direction_output (struct gpio_chip *chip,unsigned offset, +int value) +{ +tegra_gpio_set (chip, offset, value); +tegra_gpio_mask_write (GPIO_MSK_OE (offset), offset,1 ); +tegra_gpio_enable (offset); +return 0 ; +} + +static struct gpio_ops tegra_gpio_ops = { + .request = tegra_gpio_request, + .free = tegra_gpio_free, + .direction_input = tegra_gpio_direction_input, + .direction_output = tegra_gpio_direction_output, + .get = tegra_gpio_get, + .set = tegra_gpio_set, +}; + +static struct gpio_chip tegra_gpio_chip = { + .ops = &tegra_gpio_ops, + .base =0 , +}; + +static int tegra_gpio_probe (struct device_d *dev) +{ +int i, j, ret; + + ret =dev_get_drvdata (dev, (unsigned long *)&config); +if (ret) { +dev_err (dev,"dev_get_drvdata failed: %d\n" , ret); +return ret; + } + + gpio_base =dev_request_mem_region (dev,0 ); +if (!gpio_base) { +dev_err (dev,"could not get memory region\n" ); +return -ENODEV ; + } + +for (i =0 ; i < config->bank_count; i++) { +for (j =0 ; j <4 ; j++) { +int gpio =tegra_gpio_compose (i, j,0 ); +tegra_gpio_writel (0x00 ,GPIO_INT_ENB (gpio)); + } + } + + tegra_gpio_chip.ngpio = config->bank_count *32 ; + tegra_gpio_chip.dev = dev; + +gpiochip_add (&tegra_gpio_chip); + +return 0 ; +} + +static struct tegra_gpio_soc_config tegra20_gpio_config = { + .bank_stride =0x80 , + .upper_offset =0x800 , + .bank_count =7 , +}; + +static struct platform_device_id tegra_gpio_ids[] = { + { + .name ="tegra20-gpio" , + .driver_data = (unsigned long )&tegra20_gpio_config, + }, { +/* sentinel */ + }, +}; + +static __maybe_unused struct of_device_id tegra_gpio_dt_ids[] = { + { + .compatible ="nvidia,tegra20-gpio" , + .data = (unsigned long )&tegra20_gpio_config + }, { +/* sentinel */ + }, +}; + +static struct driver_d tegra_gpio_driver = { + .name ="tegra-gpio" , + .id_table = tegra_gpio_ids, + .of_compatible =DRV_OF_COMPAT (tegra_gpio_dt_ids), + .probe = tegra_gpio_probe, +}; + +static int __init tegra_gpio_init (void ) +{ +return platform_driver_register (&tegra_gpio_driver); +} +coredevice_initcall (tegra_gpio_init);Signature · 1 line
1.8.1.2
Signature · 8 lines
-- Best regards, Antony Pavlov _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox