* [PATCHv3 0/7] Cleaned up version of S5PV210 code @ 2012-05-15 13:20 Alexey Galakhov 2012-05-15 13:20 ` [PATCH 1/7] Make S3C24xx config options available for all S3Cs Alexey Galakhov ` (6 more replies) 0 siblings, 7 replies; 29+ messages in thread From: Alexey Galakhov @ 2012-05-15 13:20 UTC (permalink / raw) To: barebox; +Cc: Alexey Galakhov Hello, I cleaned up the S5PV210/Tiny210 patches as discussed before. Thank you for useful comments. Alexey Galakhov (7): Make S3C24xx config options available for all S3Cs Split S3C generic and S3C24xx specific code Add support for Samsung S5P architecture (S5PV210) S5P boot header and image generator S5P lowlevel clock init S5P DRAM support Add FriendlyArm Tiny210 board (S5PV210) .gitignore | 2 + Makefile | 2 +- arch/arm/Kconfig | 6 + arch/arm/Makefile | 8 + arch/arm/boards/a9m2410/a9m2410.c | 4 +- arch/arm/boards/a9m2410/config.h | 2 +- arch/arm/boards/a9m2410/lowlevel_init.S | 2 +- arch/arm/boards/a9m2440/a9m2440.c | 4 +- arch/arm/boards/a9m2440/config.h | 2 +- arch/arm/boards/a9m2440/lowlevel_init.S | 2 +- arch/arm/boards/mini2440/config.h | 2 +- arch/arm/boards/mini2440/lowlevel_init.S | 2 +- arch/arm/boards/mini2440/mini2440.c | 4 +- arch/arm/boards/tiny210/Makefile | 1 + arch/arm/boards/tiny210/config.h | 21 + arch/arm/boards/tiny210/lowlevel.c | 76 ++ arch/arm/boards/tiny210/tiny210.c | 113 +++ arch/arm/configs/a9m2410_defconfig | 2 +- arch/arm/configs/a9m2440_defconfig | 4 +- arch/arm/configs/mini2440_defconfig | 2 +- arch/arm/configs/tiny210_defconfig | 17 + arch/arm/mach-samsung/Kconfig | 57 +- arch/arm/mach-samsung/Makefile | 7 +- arch/arm/mach-samsung/clocks-s5pcxx.c | 98 +++ arch/arm/mach-samsung/generic.c | 113 --- arch/arm/mach-samsung/gpio-s5pcxx.c | 123 +++ arch/arm/mach-samsung/include/mach/gpio.h | 3 + arch/arm/mach-samsung/include/mach/iomux-s5pcxx.h | 798 ++++++++++++++++++++ arch/arm/mach-samsung/include/mach/s3c-clocks.h | 25 +- arch/arm/mach-samsung/include/mach/s3c-generic.h | 9 +- arch/arm/mach-samsung/include/mach/s3c-iomap.h | 56 +- .../arm/mach-samsung/include/mach/s3c24xx-clocks.h | 24 + arch/arm/mach-samsung/include/mach/s3c24xx-gpio.h | 6 +- arch/arm/mach-samsung/include/mach/s3c24xx-iomap.h | 69 ++ arch/arm/mach-samsung/include/mach/s3c24xx-nand.h | 2 +- arch/arm/mach-samsung/include/mach/s5pcxx-clocks.h | 55 ++ arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h | 52 ++ arch/arm/mach-samsung/lowlevel-init.S | 317 -------- arch/arm/mach-samsung/lowlevel-s3c24x0.S | 317 ++++++++ arch/arm/mach-samsung/lowlevel-s5pcxx.c | 61 ++ arch/arm/mach-samsung/mem-s3c24x0.c | 143 ++++ arch/arm/mach-samsung/mem-s5pcxx.c | 260 +++++++ drivers/mtd/nand/nand_s3c24xx.c | 10 +- scripts/Makefile | 1 + scripts/s5p_cksum.c | 140 ++++ 45 files changed, 2490 insertions(+), 534 deletions(-) create mode 100644 arch/arm/boards/tiny210/Makefile create mode 100644 arch/arm/boards/tiny210/config.h create mode 100644 arch/arm/boards/tiny210/lowlevel.c create mode 100644 arch/arm/boards/tiny210/tiny210.c create mode 100644 arch/arm/configs/tiny210_defconfig create mode 100644 arch/arm/mach-samsung/clocks-s5pcxx.c create mode 100644 arch/arm/mach-samsung/gpio-s5pcxx.c create mode 100644 arch/arm/mach-samsung/include/mach/iomux-s5pcxx.h create mode 100644 arch/arm/mach-samsung/include/mach/s3c24xx-clocks.h create mode 100644 arch/arm/mach-samsung/include/mach/s3c24xx-iomap.h create mode 100644 arch/arm/mach-samsung/include/mach/s5pcxx-clocks.h create mode 100644 arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h delete mode 100644 arch/arm/mach-samsung/lowlevel-init.S create mode 100644 arch/arm/mach-samsung/lowlevel-s3c24x0.S create mode 100644 arch/arm/mach-samsung/lowlevel-s5pcxx.c create mode 100644 arch/arm/mach-samsung/mem-s3c24x0.c create mode 100644 arch/arm/mach-samsung/mem-s5pcxx.c create mode 100644 scripts/s5p_cksum.c -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 1/7] Make S3C24xx config options available for all S3Cs 2012-05-15 13:20 [PATCHv3 0/7] Cleaned up version of S5PV210 code Alexey Galakhov @ 2012-05-15 13:20 ` Alexey Galakhov 2012-05-15 13:20 ` [PATCH 2/7] Split S3C generic and S3C24xx specific code Alexey Galakhov ` (5 subsequent siblings) 6 siblings, 0 replies; 29+ messages in thread From: Alexey Galakhov @ 2012-05-15 13:20 UTC (permalink / raw) To: barebox; +Cc: Alexey Galakhov Signed-off-by: Alexey Galakhov <agalakhov@gmail.com> --- arch/arm/boards/a9m2410/a9m2410.c | 2 +- arch/arm/boards/a9m2410/config.h | 2 +- arch/arm/boards/a9m2410/lowlevel_init.S | 2 +- arch/arm/boards/a9m2440/a9m2440.c | 2 +- arch/arm/boards/a9m2440/config.h | 2 +- arch/arm/boards/a9m2440/lowlevel_init.S | 2 +- arch/arm/boards/mini2440/config.h | 2 +- arch/arm/boards/mini2440/lowlevel_init.S | 2 +- arch/arm/boards/mini2440/mini2440.c | 2 +- arch/arm/configs/a9m2410_defconfig | 2 +- arch/arm/configs/a9m2440_defconfig | 4 +-- arch/arm/configs/mini2440_defconfig | 2 +- arch/arm/mach-samsung/Kconfig | 28 ++++++++++----------- arch/arm/mach-samsung/Makefile | 2 +- arch/arm/mach-samsung/include/mach/s3c-iomap.h | 2 +- arch/arm/mach-samsung/include/mach/s3c24xx-nand.h | 2 +- arch/arm/mach-samsung/lowlevel-init.S | 12 ++++----- drivers/mtd/nand/nand_s3c24xx.c | 10 ++++---- 18 files changed, 41 insertions(+), 41 deletions(-) diff --git a/arch/arm/boards/a9m2410/a9m2410.c b/arch/arm/boards/a9m2410/a9m2410.c index 7c51d58..eaafdbd 100644 --- a/arch/arm/boards/a9m2410/a9m2410.c +++ b/arch/arm/boards/a9m2410/a9m2410.c @@ -136,7 +136,7 @@ static int a9m2410_devices_init(void) device_initcall(a9m2410_devices_init); -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT void __bare_init nand_boot(void) { s3c24x0_nand_load_image((void *)TEXT_BASE, 256 * 1024, 0); diff --git a/arch/arm/boards/a9m2410/config.h b/arch/arm/boards/a9m2410/config.h index 87b05fc..4b8a9a2 100644 --- a/arch/arm/boards/a9m2410/config.h +++ b/arch/arm/boards/a9m2410/config.h @@ -115,7 +115,7 @@ #define A9M2410_TWRPH1 1 /* needed in the generic NAND boot code only */ -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT # define BOARD_DEFAULT_NAND_TIMING CALC_NFCONF_TIMING(A9M2410_TACLS, A9M2410_TWRPH0, A9M2410_TWRPH1) #endif diff --git a/arch/arm/boards/a9m2410/lowlevel_init.S b/arch/arm/boards/a9m2410/lowlevel_init.S index a106d53..0463b26 100644 --- a/arch/arm/boards/a9m2410/lowlevel_init.S +++ b/arch/arm/boards/a9m2410/lowlevel_init.S @@ -28,7 +28,7 @@ board_init_lowlevel: bl s3c24x0_sdram_init -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT mov lr, r10 /* restore the link register */ /* up to here we are running from the internal SRAM area */ b s3c24x0_nand_boot /* does return directly to our caller into SDRAM */ diff --git a/arch/arm/boards/a9m2440/a9m2440.c b/arch/arm/boards/a9m2440/a9m2440.c index fcb8729..1d20248 100644 --- a/arch/arm/boards/a9m2440/a9m2440.c +++ b/arch/arm/boards/a9m2440/a9m2440.c @@ -155,7 +155,7 @@ static int a9m2440_devices_init(void) device_initcall(a9m2440_devices_init); -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT void __bare_init nand_boot(void) { s3c24x0_nand_load_image((void *)TEXT_BASE, 256 * 1024, 0); diff --git a/arch/arm/boards/a9m2440/config.h b/arch/arm/boards/a9m2440/config.h index 43cb6ab..09ad949 100644 --- a/arch/arm/boards/a9m2440/config.h +++ b/arch/arm/boards/a9m2440/config.h @@ -66,7 +66,7 @@ #define A9M2440_TWRPH1 1 /* needed in the generic NAND boot code only */ -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT # define BOARD_DEFAULT_NAND_TIMING CALC_NFCONF_TIMING(A9M2440_TACLS, A9M2440_TWRPH0, A9M2440_TWRPH1) #endif diff --git a/arch/arm/boards/a9m2440/lowlevel_init.S b/arch/arm/boards/a9m2440/lowlevel_init.S index e915a16..305014c 100644 --- a/arch/arm/boards/a9m2440/lowlevel_init.S +++ b/arch/arm/boards/a9m2440/lowlevel_init.S @@ -232,7 +232,7 @@ board_init_lowlevel: bl sdram_init -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT mov lr, r10 /* restore the link register */ /* up to here we are running from the internal SRAM area */ b s3c24x0_nand_boot /* does return directly to our caller into SDRAM */ diff --git a/arch/arm/boards/mini2440/config.h b/arch/arm/boards/mini2440/config.h index 8d36193..674d974 100644 --- a/arch/arm/boards/mini2440/config.h +++ b/arch/arm/boards/mini2440/config.h @@ -66,7 +66,7 @@ #define MINI2440_TWRPH1 1 /* needed in the generic NAND boot code only */ -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT # define BOARD_DEFAULT_NAND_TIMING \ CALC_NFCONF_TIMING(MINI2440_TACLS, MINI2440_TWRPH0, MINI2440_TWRPH1) #endif diff --git a/arch/arm/boards/mini2440/lowlevel_init.S b/arch/arm/boards/mini2440/lowlevel_init.S index 1c8860a..827cf00 100644 --- a/arch/arm/boards/mini2440/lowlevel_init.S +++ b/arch/arm/boards/mini2440/lowlevel_init.S @@ -30,7 +30,7 @@ board_init_lowlevel: bl s3c24x0_sdram_init -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT mov lr, r10 /* restore the link register */ /* up to here we are running from the internal SRAM area */ b s3c24x0_nand_boot /* does return directly to our caller into SDRAM */ diff --git a/arch/arm/boards/mini2440/mini2440.c b/arch/arm/boards/mini2440/mini2440.c index 03e3d6c..3d3b820 100644 --- a/arch/arm/boards/mini2440/mini2440.c +++ b/arch/arm/boards/mini2440/mini2440.c @@ -326,7 +326,7 @@ static int mini2440_devices_init(void) device_initcall(mini2440_devices_init); -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT void __bare_init nand_boot(void) { s3c24x0_nand_load_image((void *)TEXT_BASE, 256 * 1024, 0); diff --git a/arch/arm/configs/a9m2410_defconfig b/arch/arm/configs/a9m2410_defconfig index 57e73c7..1955023 100644 --- a/arch/arm/configs/a9m2410_defconfig +++ b/arch/arm/configs/a9m2410_defconfig @@ -1,5 +1,5 @@ CONFIG_ARCH_S3C24xx=y -CONFIG_S3C24XX_NAND_BOOT=y +CONFIG_S3C_NAND_BOOT=y CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y CONFIG_BROKEN=y CONFIG_EXPERIMENTAL=y diff --git a/arch/arm/configs/a9m2440_defconfig b/arch/arm/configs/a9m2440_defconfig index ae7f523..ebdf64f 100644 --- a/arch/arm/configs/a9m2440_defconfig +++ b/arch/arm/configs/a9m2440_defconfig @@ -1,7 +1,7 @@ CONFIG_ARCH_S3C24xx=y CONFIG_MACH_A9M2440=y -CONFIG_S3C24XX_SDRAM_INIT=y -CONFIG_S3C24XX_NAND_BOOT=y +CONFIG_S3C_SDRAM_INIT=y +CONFIG_S3C_NAND_BOOT=y CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y CONFIG_BROKEN=y CONFIG_EXPERIMENTAL=y diff --git a/arch/arm/configs/mini2440_defconfig b/arch/arm/configs/mini2440_defconfig index 9b35dd5..efe76e4 100644 --- a/arch/arm/configs/mini2440_defconfig +++ b/arch/arm/configs/mini2440_defconfig @@ -1,7 +1,7 @@ CONFIG_ARCH_S3C24xx=y CONFIG_MACH_MINI2440=y CONFIG_MINI2440_VIDEO_N35=y -CONFIG_S3C24XX_NAND_BOOT=y +CONFIG_S3C_NAND_BOOT=y CONFIG_AEABI=y CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y CONFIG_TEXT_BASE=0x33e00000 diff --git a/arch/arm/mach-samsung/Kconfig b/arch/arm/mach-samsung/Kconfig index bc283dc..63c29ef 100644 --- a/arch/arm/mach-samsung/Kconfig +++ b/arch/arm/mach-samsung/Kconfig @@ -30,8 +30,8 @@ config MACH_A9M2410 bool "Digi A9M2410" select CPU_S3C2410 select MACH_HAS_LOWLEVEL_INIT - select S3C24XX_PLL_INIT - select S3C24XX_SDRAM_INIT + select S3C_PLL_INIT + select S3C_SDRAM_INIT help Say Y here if you are using Digi's Connect Core 9M equipped with a Samsung S3C2410 Processor @@ -40,7 +40,7 @@ config MACH_A9M2440 bool "Digi A9M2440" select CPU_S3C2440 select MACH_HAS_LOWLEVEL_INIT - select S3C24XX_PLL_INIT + select S3C_PLL_INIT help Say Y here if you are using Digi's Connect Core 9M equipped with a Samsung S3C2440 Processor @@ -50,8 +50,8 @@ config MACH_MINI2440 select CPU_S3C2440 select MACH_HAS_LOWLEVEL_INIT select MACH_DO_LOWLEVEL_INIT - select S3C24XX_PLL_INIT - select S3C24XX_SDRAM_INIT + select S3C_PLL_INIT + select S3C_SDRAM_INIT select HAS_DM9000 help Say Y here if you are using Mini 2440 dev board equipped @@ -78,29 +78,31 @@ source arch/arm/boards/mini2440/Kconfig endmenu -menu "S3C24X0 Features " +endif + +menu "S3C Features " -config S3C24XX_LOW_LEVEL_INIT +config S3C_LOWLEVEL_INIT bool -config S3C24XX_PLL_INIT +config S3C_PLL_INIT bool prompt "Reconfigure PLL" - select S3C24XX_LOW_LEVEL_INIT + select S3C_LOWLEVEL_INIT help This adds generic code to reconfigure the internal PLL very early after reset. -config S3C24XX_SDRAM_INIT +config S3C_SDRAM_INIT bool prompt "Initialize SDRAM" - select S3C24XX_LOW_LEVEL_INIT + select S3C_LOWLEVEL_INIT help This adds generic code to configure the SDRAM controller after reset. The initialisation will be skipped if the code is already running from SDRAM. -config S3C24XX_NAND_BOOT +config S3C_NAND_BOOT bool prompt "Booting from NAND" select MTD @@ -113,5 +115,3 @@ config S3C24XX_NAND_BOOT endmenu endif - -endif diff --git a/arch/arm/mach-samsung/Makefile b/arch/arm/mach-samsung/Makefile index 2ba5c3f..349ba9b 100644 --- a/arch/arm/mach-samsung/Makefile +++ b/arch/arm/mach-samsung/Makefile @@ -1,3 +1,3 @@ obj-y += s3c-timer.o generic.o obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o s3c24xx-clocks.o -obj-$(CONFIG_S3C24XX_LOW_LEVEL_INIT) += lowlevel-init.o +obj-$(CONFIG_S3C_LOWLEVEL_INIT) += lowlevel-init.o diff --git a/arch/arm/mach-samsung/include/mach/s3c-iomap.h b/arch/arm/mach-samsung/include/mach/s3c-iomap.h index 9e867f8..60d44e3 100644 --- a/arch/arm/mach-samsung/include/mach/s3c-iomap.h +++ b/arch/arm/mach-samsung/include/mach/s3c-iomap.h @@ -54,7 +54,7 @@ * if we are booting from NAND, its internal SRAM occures at * a different address than without this feature */ -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT # define NFC_RAM_AREA 0x00000000 #else # define NFC_RAM_AREA 0x40000000 diff --git a/arch/arm/mach-samsung/include/mach/s3c24xx-nand.h b/arch/arm/mach-samsung/include/mach/s3c24xx-nand.h index 7610b4e..acd78b8 100644 --- a/arch/arm/mach-samsung/include/mach/s3c24xx-nand.h +++ b/arch/arm/mach-samsung/include/mach/s3c24xx-nand.h @@ -18,7 +18,7 @@ * */ -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT extern void s3c24x0_nand_load_image(void*, int, int); #endif diff --git a/arch/arm/mach-samsung/lowlevel-init.S b/arch/arm/mach-samsung/lowlevel-init.S index 31c6196..e9471a5 100644 --- a/arch/arm/mach-samsung/lowlevel-init.S +++ b/arch/arm/mach-samsung/lowlevel-init.S @@ -70,7 +70,7 @@ routine very early in your board_init_lowlevel routine. * Note: Do not use "r10" here in this code */ -#ifdef CONFIG_S3C24XX_PLL_INIT +#ifdef CONFIG_S3C_PLL_INIT .section ".text_bare_init.s3c24x0_pll_init","ax" @@ -146,7 +146,7 @@ shared with all other system on chip components. Most of the time this configuration is to slow for the CPU and to fast for the other components. PLL reprogramming can be done in the machine specific manner very early when -the CONFIG_S3C24XX_PLL_INIT and CONFIG_MACH_HAS_LOWLEVEL_INIT symbols are +the CONFIG_S3C_PLL_INIT and CONFIG_MACH_HAS_LOWLEVEL_INIT symbols are defined. The board must provide a board_init_lowlevel() assembler function in this case and calling the s3c24x0_pll_init() assembler function. @@ -184,7 +184,7 @@ With m = MDIV + 8, p = PDIV + 2 and s = SDIV. /* ----------------------------------------------------------------------- */ -#ifdef CONFIG_S3C24XX_SDRAM_INIT +#ifdef CONFIG_S3C_SDRAM_INIT .section ".text_bare_init.s3c24x0_sdram_init","ax" @@ -225,7 +225,7 @@ SDRAMDATA: The SDRAM controller is very simple and its initialisation requires only a few steps. barebox provides a generic routine to do this step. -Enable CONFIG_S3C24XX_SDRAM_INIT and CONFIG_MACH_HAS_LOWLEVEL_INIT to be able +Enable CONFIG_S3C_SDRAM_INIT and CONFIG_MACH_HAS_LOWLEVEL_INIT to be able to call the generic s3c24x0_sdram_init() assembler function from within the machine specific board_init_lowlevel() assembler function. @@ -245,7 +245,7 @@ Define in the machine specific config.h the following list of symbols: /* ----------------------------------------------------------------------- */ -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT .section ".text_bare_init.s3c24x0_nand_boot","ax" @@ -284,7 +284,7 @@ s3c24x0_nand_boot: @page dev_s3c24xx_nandboot_handling Booting from NAND To be able to boot from NAND memory only, enable the S3C24x0 NAND driver. Also -enable CONFIG_S3C24XX_NAND_BOOT and CONFIG_MACH_HAS_LOWLEVEL_INIT to be +enable CONFIG_S3C_NAND_BOOT and CONFIG_MACH_HAS_LOWLEVEL_INIT to be able to call the s3c24x0_nand_boot() assembler routine from within the machine specific board_init_lowlevel() assembler function. diff --git a/drivers/mtd/nand/nand_s3c24xx.c b/drivers/mtd/nand/nand_s3c24xx.c index dbf2e14..c629701 100644 --- a/drivers/mtd/nand/nand_s3c24xx.c +++ b/drivers/mtd/nand/nand_s3c24xx.c @@ -36,7 +36,7 @@ #include <io.h> #include <asm-generic/errno.h> -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT # define __nand_boot_init __bare_init # ifndef BOARD_DEFAULT_NAND_TIMING # define BOARD_DEFAULT_NAND_TIMING 0x0737 @@ -49,7 +49,7 @@ * Define this symbol for testing purpose. It will add a command to read an * image from the NAND like it the boot strap code will do. */ -#define CONFIG_NAND_S3C24XX_BOOT_DEBUG +#define CONFIG_NAND_S3C_BOOT_DEBUG /* NAND controller's register */ @@ -497,7 +497,7 @@ static struct driver_d s3c24x0_nand_driver = { .probe = s3c24x0_nand_probe, }; -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT static void __nand_boot_init wait_for_completion(void __iomem *host) { @@ -603,7 +603,7 @@ void __nand_boot_init s3c24x0_nand_load_image(void *dest, int size, int page) disable_nand_controller(host); } -#ifdef CONFIG_NAND_S3C24XX_BOOT_DEBUG +#ifdef CONFIG_NAND_S3C_BOOT_DEBUG #include <command.h> static int do_nand_boot_test(int argc, char *argv[]) @@ -636,7 +636,7 @@ BAREBOX_CMD_START(nand_boot_test) BAREBOX_CMD_END #endif -#endif /* CONFIG_S3C24XX_NAND_BOOT */ +#endif /* CONFIG_S3C_NAND_BOOT */ /* * Main initialization routine -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 2/7] Split S3C generic and S3C24xx specific code 2012-05-15 13:20 [PATCHv3 0/7] Cleaned up version of S5PV210 code Alexey Galakhov 2012-05-15 13:20 ` [PATCH 1/7] Make S3C24xx config options available for all S3Cs Alexey Galakhov @ 2012-05-15 13:20 ` Alexey Galakhov 2012-05-17 17:52 ` Sascha Hauer 2012-05-15 13:20 ` [PATCH 3/7] Add support for Samsung S5P architecture (S5PV210) Alexey Galakhov ` (4 subsequent siblings) 6 siblings, 1 reply; 29+ messages in thread From: Alexey Galakhov @ 2012-05-15 13:20 UTC (permalink / raw) To: barebox; +Cc: Alexey Galakhov Signed-off-by: Alexey Galakhov <agalakhov@gmail.com> --- arch/arm/boards/a9m2410/a9m2410.c | 2 +- arch/arm/boards/a9m2440/a9m2440.c | 2 +- arch/arm/boards/mini2440/mini2440.c | 2 +- arch/arm/mach-samsung/Makefile | 5 +- arch/arm/mach-samsung/generic.c | 113 ------- arch/arm/mach-samsung/include/mach/s3c-clocks.h | 22 +- arch/arm/mach-samsung/include/mach/s3c-generic.h | 4 +- arch/arm/mach-samsung/include/mach/s3c-iomap.h | 53 +--- .../arm/mach-samsung/include/mach/s3c24xx-clocks.h | 24 ++ arch/arm/mach-samsung/include/mach/s3c24xx-gpio.h | 6 +- arch/arm/mach-samsung/include/mach/s3c24xx-iomap.h | 69 +++++ arch/arm/mach-samsung/lowlevel-init.S | 317 -------------------- arch/arm/mach-samsung/lowlevel-s3c24x0.S | 317 ++++++++++++++++++++ arch/arm/mach-samsung/mem-s3c24x0.c | 143 +++++++++ 14 files changed, 579 insertions(+), 500 deletions(-) create mode 100644 arch/arm/mach-samsung/include/mach/s3c24xx-clocks.h create mode 100644 arch/arm/mach-samsung/include/mach/s3c24xx-iomap.h delete mode 100644 arch/arm/mach-samsung/lowlevel-init.S create mode 100644 arch/arm/mach-samsung/lowlevel-s3c24x0.S create mode 100644 arch/arm/mach-samsung/mem-s3c24x0.c diff --git a/arch/arm/boards/a9m2410/a9m2410.c b/arch/arm/boards/a9m2410/a9m2410.c index eaafdbd..31ed772 100644 --- a/arch/arm/boards/a9m2410/a9m2410.c +++ b/arch/arm/boards/a9m2410/a9m2410.c @@ -51,7 +51,7 @@ static int a9m2410_mem_init(void) * Note: On this card the second SDRAM page is not used */ s3c24xx_disable_second_sdram_bank(); - size = s3c24xx_get_memory_size(); + size = s3c_get_memory_size(); /* ---------- configure the GPIOs ------------- */ writel(0x007FFFFF, S3C_GPACON); diff --git a/arch/arm/boards/a9m2440/a9m2440.c b/arch/arm/boards/a9m2440/a9m2440.c index 1d20248..a27c748 100644 --- a/arch/arm/boards/a9m2440/a9m2440.c +++ b/arch/arm/boards/a9m2440/a9m2440.c @@ -99,7 +99,7 @@ static int a9m2440_mem_init(void) break; } - arm_add_mem_device("ram0", S3C_SDRAM_BASE, s3c24xx_get_memory_size()); + arm_add_mem_device("ram0", S3C_SDRAM_BASE, s3c_get_memory_size()); return 0; } diff --git a/arch/arm/boards/mini2440/mini2440.c b/arch/arm/boards/mini2440/mini2440.c index 3d3b820..066fd1c 100644 --- a/arch/arm/boards/mini2440/mini2440.c +++ b/arch/arm/boards/mini2440/mini2440.c @@ -268,7 +268,7 @@ static const unsigned pin_usage[] = { static int mini2440_mem_init(void) { - arm_add_mem_device("ram0", S3C_SDRAM_BASE, s3c24xx_get_memory_size()); + arm_add_mem_device("ram0", S3C_SDRAM_BASE, s3c_get_memory_size()); return 0; } diff --git a/arch/arm/mach-samsung/Makefile b/arch/arm/mach-samsung/Makefile index 349ba9b..bde707f 100644 --- a/arch/arm/mach-samsung/Makefile +++ b/arch/arm/mach-samsung/Makefile @@ -1,3 +1,4 @@ obj-y += s3c-timer.o generic.o -obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o s3c24xx-clocks.o -obj-$(CONFIG_S3C_LOWLEVEL_INIT) += lowlevel-init.o +obj-lowlevel-$(CONFIG_ARCH_S3C24xx) += lowlevel-s3c24x0.o +obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o s3c24xx-clocks.o mem-s3c24x0.o +obj-$(CONFIG_S3C_LOWLEVEL_INIT) += $(obj-lowlevel-y) diff --git a/arch/arm/mach-samsung/generic.c b/arch/arm/mach-samsung/generic.c index 7706be2..7095294 100644 --- a/arch/arm/mach-samsung/generic.c +++ b/arch/arm/mach-samsung/generic.c @@ -25,65 +25,9 @@ #include <config.h> #include <common.h> #include <init.h> -#include <clock.h> #include <io.h> -#include <sizes.h> #include <mach/s3c-iomap.h> #include <mach/s3c-generic.h> -#include <mach/s3c-busctl.h> -#include <mach/s3c24xx-gpio.h> - -/** - * Calculate the amount of connected and available memory - * @return Memory size in bytes - */ -uint32_t s3c24xx_get_memory_size(void) -{ - uint32_t reg, size; - - /* - * detect the current memory size - */ - reg = readl(S3C_BANKSIZE); - - switch (reg & 0x7) { - case 0: - size = SZ_32M; - break; - case 1: - size = SZ_64M; - break; - case 2: - size = SZ_128M; - break; - case 4: - size = SZ_2M; - break; - case 5: - size = SZ_4M; - break; - case 6: - size = SZ_8M; - break; - default: - size = SZ_16M; - break; - } - - /* - * Is bank7 also configured for SDRAM usage? - */ - if ((readl(S3C_BANKCON7) & (0x3 << 15)) == (0x3 << 15)) - size <<= 1; /* also count this bank */ - - return size; -} - -void s3c24xx_disable_second_sdram_bank(void) -{ - writel(readl(S3C_BANKCON7) & ~(0x3 << 15), S3C_BANKCON7); - writel(readl(S3C_MISCCR) | (1 << 18), S3C_MISCCR); /* disable its clock */ -} #define S3C_WTCON (S3C_WATCHDOG_BASE) #define S3C_WTDAT (S3C_WATCHDOG_BASE + 0x04) @@ -105,60 +49,3 @@ void __noreturn reset_cpu(unsigned long addr) ; } EXPORT_SYMBOL(reset_cpu); - -/** - -@page dev_s3c24xx_arch Samsung's S3C24xx Platforms in barebox - -@section s3c24xx_boards Boards using S3C24xx Processors - -@li @subpage arch/arm/boards/a9m2410/a9m2410.c -@li @subpage arch/arm/boards/a9m2440/a9m2440.c - -@section s3c24xx_arch Documentation for S3C24xx Architectures Files - -@li @subpage arch/arm/mach-s3c24xx/generic.c - -@section s3c24xx_mem_map SDRAM Memory Map - -SDRAM starts at address 0x3000.0000 up to the available amount of connected -SDRAM memory. Physically this CPU can handle up to 256MiB (two areas with -up to 128MiB each). - -@subsection s3c24xx_mem_generic_map Generic Map -- 0x0000.0000 Start of the internal SRAM when booting from NAND flash memory or CS signal to a NOR flash memory. -- 0x0800.0000 Start of I/O space. -- 0x3000.0000 Start of SDRAM area. - - 0x3000.0100 Start of the TAG list area. - - 0x3000.8000 Start of the linux kernel (physical address). -- 0x4000.0000 Start of internal SRAM, when booting from NOR flash memory -- 0x4800.0000 Start of the internal I/O area - -@section s3c24xx_asm_arm include/asm-arm/arch-s3c24xx directory guidelines -All S3C24xx common headers are located here. - -@note Do not add board specific header files/information here. -*/ - -/** @page dev_s3c24xx_mach Samsung's S3C24xx based platforms - -@par barebox Map - -The location of the @a barebox itself depends on the available amount of -installed SDRAM memory: - -- 0x30fc.0000 Start of @a barebox when 16MiB SDRAM is available -- 0x31fc.0000 Start of @a barebox when 32MiB SDRAM is available -- 0x33fc.0000 Start of @a barebox when 64MiB SDRAM is available - -Adjust the @p CONFIG_TEXT_BASE/CONFIG_ARCH_TEXT_BASE symbol in accordance to -the available memory. - -@note The RAM based filesystem and the stack resides always below the -@a barebox start address. - -@li @subpage dev_s3c24xx_wd_handling -@li @subpage dev_s3c24xx_pll_handling -@li @subpage dev_s3c24xx_sdram_handling -@li @subpage dev_s3c24xx_nandboot_handling -*/ diff --git a/arch/arm/mach-samsung/include/mach/s3c-clocks.h b/arch/arm/mach-samsung/include/mach/s3c-clocks.h index 44b2a6c..b8894f8 100644 --- a/arch/arm/mach-samsung/include/mach/s3c-clocks.h +++ b/arch/arm/mach-samsung/include/mach/s3c-clocks.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2011 Juergen Beisert, Pengutronix + * See file CREDITS for list of people who contributed to this + * project. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -10,22 +11,19 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * */ #ifndef __MACH_S3C_CLOCKS_H -# define __MACH_S3C_CLOCKS_H +#define __MACH_S3C_CLOCKS_H #ifdef CONFIG_ARCH_S3C24xx -# define S3C_LOCKTIME (S3C_CLOCK_POWER_BASE) -# define S3C_MPLLCON (S3C_CLOCK_POWER_BASE + 0x4) -# define S3C_UPLLCON (S3C_CLOCK_POWER_BASE + 0x8) -# define S3C_CLKCON (S3C_CLOCK_POWER_BASE + 0xc) -# define S3C_CLKSLOW (S3C_CLOCK_POWER_BASE + 0x10) -# define S3C_CLKDIVN (S3C_CLOCK_POWER_BASE + 0x14) - -# define S3C_MPLLCON_GET_MDIV(x) ((((x) >> 12) & 0xff) + 8) -# define S3C_MPLLCON_GET_PDIV(x) ((((x) >> 4) & 0x3f) + 2) -# define S3C_MPLLCON_GET_SDIV(x) ((x) & 0x3) +# include <mach/s3c24xx-clocks.h> #endif #endif /* __MACH_S3C_CLOCKS_H */ diff --git a/arch/arm/mach-samsung/include/mach/s3c-generic.h b/arch/arm/mach-samsung/include/mach/s3c-generic.h index 5d3808e..62d2c93 100644 --- a/arch/arm/mach-samsung/include/mach/s3c-generic.h +++ b/arch/arm/mach-samsung/include/mach/s3c-generic.h @@ -33,6 +33,8 @@ uint32_t s3c_get_uclk(void); unsigned s3c_get_uart_clk(unsigned src); -uint32_t s3c24xx_get_memory_size(void); +uint32_t s3c_get_memory_size(void); +#ifdef CONFIG_ARCH_S3C24xx void s3c24xx_disable_second_sdram_bank(void); +#endif diff --git a/arch/arm/mach-samsung/include/mach/s3c-iomap.h b/arch/arm/mach-samsung/include/mach/s3c-iomap.h index 60d44e3..87919cc 100644 --- a/arch/arm/mach-samsung/include/mach/s3c-iomap.h +++ b/arch/arm/mach-samsung/include/mach/s3c-iomap.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2009 Juergen Beisert, Pengutronix + * See file CREDITS for list of people who contributed to this + * project. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -18,52 +19,6 @@ * */ -/* S3C2410 device base addresses */ -#define S3C_MEMCTL_BASE 0x48000000 -#define S3C2410_USB_HOST_BASE 0x49000000 -#define S3C2410_INTERRUPT_BASE 0x4A000000 -#define S3C2410_DMA_BASE 0x4B000000 -#define S3C_CLOCK_POWER_BASE 0x4C000000 -#define S3C2410_LCD_BASE 0x4D000000 -#define S3C24X0_NAND_BASE 0x4E000000 -#define S3C_UART_BASE 0x50000000 -#define S3C_TIMER_BASE 0x51000000 -#define S3C2410_USB_DEVICE_BASE 0x52000140 -#define S3C_WATCHDOG_BASE 0x53000000 -#define S3C2410_I2C_BASE 0x54000000 -#define S3C2410_I2S_BASE 0x55000000 -#define S3C_GPIO_BASE 0x56000000 -#define S3C2410_RTC_BASE 0x57000000 -#define S3C2410_ADC_BASE 0x58000000 -#define S3C2410_SPI_BASE 0x59000000 -#define S3C2410_SDI_BASE 0x5A000000 - -/* external IO space */ -#define S3C_CS0_BASE 0x00000000 -#define S3C_CS1_BASE 0x08000000 -#define S3C_CS2_BASE 0x10000000 -#define S3C_CS3_BASE 0x18000000 -#define S3C_CS4_BASE 0x20000000 -#define S3C_CS5_BASE 0x28000000 -#define S3C_CS6_BASE 0x30000000 - -#define S3C_SDRAM_BASE S3C_CS6_BASE -#define S3C_SDRAM_END (S3C_SDRAM_BASE + 0x10000000) - -/* - * if we are booting from NAND, its internal SRAM occures at - * a different address than without this feature - */ -#ifdef CONFIG_S3C_NAND_BOOT -# define NFC_RAM_AREA 0x00000000 -#else -# define NFC_RAM_AREA 0x40000000 +#ifdef CONFIG_ARCH_S3C24xx +# include <mach/s3c24xx-iomap.h> #endif -#define NFC_RAM_SIZE 4096 - -#define S3C_UART1_BASE (S3C_UART_BASE) -#define S3C_UART1_SIZE 0x4000 -#define S3C_UART2_BASE (S3C_UART_BASE + 0x4000) -#define S3C_UART2_SIZE 0x4000 -#define S3C_UART3_BASE (S3C_UART_BASE + 0x8000) -#define S3C_UART3_SIZE 0x4000 diff --git a/arch/arm/mach-samsung/include/mach/s3c24xx-clocks.h b/arch/arm/mach-samsung/include/mach/s3c24xx-clocks.h new file mode 100644 index 0000000..839dfe3 --- /dev/null +++ b/arch/arm/mach-samsung/include/mach/s3c24xx-clocks.h @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2011 Juergen Beisert, Pengutronix + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +# define S3C_LOCKTIME (S3C_CLOCK_POWER_BASE) +# define S3C_MPLLCON (S3C_CLOCK_POWER_BASE + 0x4) +# define S3C_UPLLCON (S3C_CLOCK_POWER_BASE + 0x8) +# define S3C_CLKCON (S3C_CLOCK_POWER_BASE + 0xc) +# define S3C_CLKSLOW (S3C_CLOCK_POWER_BASE + 0x10) +# define S3C_CLKDIVN (S3C_CLOCK_POWER_BASE + 0x14) + +# define S3C_MPLLCON_GET_MDIV(x) ((((x) >> 12) & 0xff) + 8) +# define S3C_MPLLCON_GET_PDIV(x) ((((x) >> 4) & 0x3f) + 2) +# define S3C_MPLLCON_GET_SDIV(x) ((x) & 0x3) diff --git a/arch/arm/mach-samsung/include/mach/s3c24xx-gpio.h b/arch/arm/mach-samsung/include/mach/s3c24xx-gpio.h index c835974..ffb57fb 100644 --- a/arch/arm/mach-samsung/include/mach/s3c24xx-gpio.h +++ b/arch/arm/mach-samsung/include/mach/s3c24xx-gpio.h @@ -12,8 +12,8 @@ * GNU General Public License for more details. */ -#ifndef __MACH_S3C24XX_GPIO_H -# define __MACH_S3C24XX_GPIO_H +#ifndef __MACH_GPIO_S3C24X0_H +# define __MACH_GPIO_S3C24X0_H #define S3C_GPACON (S3C_GPIO_BASE) #define S3C_GPADAT (S3C_GPIO_BASE + 0x04) @@ -74,4 +74,4 @@ # define S3C_DSC1 (S3C_GPIO_BASE + 0xc8) #endif -#endif /* __MACH_S3C24XX_GPIO_H */ +#endif /* __MACH_GPIO_S3C24X0_H */ diff --git a/arch/arm/mach-samsung/include/mach/s3c24xx-iomap.h b/arch/arm/mach-samsung/include/mach/s3c24xx-iomap.h new file mode 100644 index 0000000..60d44e3 --- /dev/null +++ b/arch/arm/mach-samsung/include/mach/s3c24xx-iomap.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2009 Juergen Beisert, Pengutronix + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + */ + +/* S3C2410 device base addresses */ +#define S3C_MEMCTL_BASE 0x48000000 +#define S3C2410_USB_HOST_BASE 0x49000000 +#define S3C2410_INTERRUPT_BASE 0x4A000000 +#define S3C2410_DMA_BASE 0x4B000000 +#define S3C_CLOCK_POWER_BASE 0x4C000000 +#define S3C2410_LCD_BASE 0x4D000000 +#define S3C24X0_NAND_BASE 0x4E000000 +#define S3C_UART_BASE 0x50000000 +#define S3C_TIMER_BASE 0x51000000 +#define S3C2410_USB_DEVICE_BASE 0x52000140 +#define S3C_WATCHDOG_BASE 0x53000000 +#define S3C2410_I2C_BASE 0x54000000 +#define S3C2410_I2S_BASE 0x55000000 +#define S3C_GPIO_BASE 0x56000000 +#define S3C2410_RTC_BASE 0x57000000 +#define S3C2410_ADC_BASE 0x58000000 +#define S3C2410_SPI_BASE 0x59000000 +#define S3C2410_SDI_BASE 0x5A000000 + +/* external IO space */ +#define S3C_CS0_BASE 0x00000000 +#define S3C_CS1_BASE 0x08000000 +#define S3C_CS2_BASE 0x10000000 +#define S3C_CS3_BASE 0x18000000 +#define S3C_CS4_BASE 0x20000000 +#define S3C_CS5_BASE 0x28000000 +#define S3C_CS6_BASE 0x30000000 + +#define S3C_SDRAM_BASE S3C_CS6_BASE +#define S3C_SDRAM_END (S3C_SDRAM_BASE + 0x10000000) + +/* + * if we are booting from NAND, its internal SRAM occures at + * a different address than without this feature + */ +#ifdef CONFIG_S3C_NAND_BOOT +# define NFC_RAM_AREA 0x00000000 +#else +# define NFC_RAM_AREA 0x40000000 +#endif +#define NFC_RAM_SIZE 4096 + +#define S3C_UART1_BASE (S3C_UART_BASE) +#define S3C_UART1_SIZE 0x4000 +#define S3C_UART2_BASE (S3C_UART_BASE + 0x4000) +#define S3C_UART2_SIZE 0x4000 +#define S3C_UART3_BASE (S3C_UART_BASE + 0x8000) +#define S3C_UART3_SIZE 0x4000 diff --git a/arch/arm/mach-samsung/lowlevel-init.S b/arch/arm/mach-samsung/lowlevel-init.S deleted file mode 100644 index e9471a5..0000000 --- a/arch/arm/mach-samsung/lowlevel-init.S +++ /dev/null @@ -1,317 +0,0 @@ -/* - * (C) Copyright 2009 - * Juergen Beisert <kernel@pengutronix.de> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - */ - -#include <config.h> -#include <mach/s3c-iomap.h> - - .section ".text_bare_init.s3c24x0_disable_wd","ax" - -/* - * Disable the watchdog, else it continues to bark - */ -.globl s3c24x0_disable_wd -s3c24x0_disable_wd: - - ldr r0, =S3C_WATCHDOG_BASE - mov r1, #0x0 - str r1, [r0] - mov pc, lr - -/** -@page dev_s3c24xx_wd_handling Watchdog handling - -The watchdog must be disabled very early, because if it resets the system -it is still active and will continue to reset the system. So, call this -routine very early in your board_init_lowlevel routine. -*/ - -/* - * S3C2410 PLL configuration - * ------------------------- - * - * Basic frequency calculation - * - * m * REFclk s = SDIV - * PLLclk = ------------ p = PDIV + 2 - * p * 2^s m = MDIV + 8 - * - * After reset the PLL of the s3c2410 processor uses: - * - * MPLL UPLL - * MDIV 0x5c 0x28 - * PDIV 0x08 0x08 - * SDIV 0x0 0x0 - * - * 100 * 12MHz 1200MHz - * MPLLclk = ------------- = -------- = 120MHz - * 10 * 2^0 10 - * - * 48 * 12MHz 576MHz - * UPLLclk = ------------- = -------- = 57,6MHz - * 10 * 2^0 10 - * - * Note: Do not use "r10" here in this code - */ - -#ifdef CONFIG_S3C_PLL_INIT - - .section ".text_bare_init.s3c24x0_pll_init","ax" - -.globl s3c24x0_pll_init -s3c24x0_pll_init: - - mov r0, #S3C_CLOCK_POWER_BASE - - /* configure internal clock ratio */ - mov r1, #BOARD_SPECIFIC_CLKDIVN - str r1, [r0, #20] - - /* enable all devices on this chip */ - mov r1, #0xFFFFFFF0 - str r1, [r0, #12] - - /* ??????? */ -#ifdef CONFIG_CPU_S3C2440 - mov r1, #0xFFFFFFFF -#endif -#ifdef CONFIG_CPU_S3C2410 - mov r1, #0x00FFFFFF -#endif - str r1, [r0, #0] - -#ifdef CONFIG_CPU_S3C2440 - /* - * Most of the time HDIVN is not 0, so we must use the - * asynchronous bus mode (refer datasheet "Clock and Power Management") - */ - mrc p15, 0, r1, c1, c0, 0 - orr r1, r1, #0xc0000000 - mcr p15, 0, r1, c1, c0, 0 -#endif - - /* configure UPLL */ - ldr r1, =BOARD_SPECIFIC_UPLL - str r1, [r0, #8] - - nop - nop - nop - nop - nop - nop - nop - nop - - /* configure MPLL */ - ldr r1, =BOARD_SPECIFIC_MPLL - str r1, [r0, #4] - - nop - nop - nop - nop - nop - nop - nop - nop - - mov pc, lr - -#endif - -/** -@page dev_s3c24xx_pll_handling PLL clock handling - -To control the speed of your machine the PLLs must be reconfigured after reset. - -For example the S3C2410 CPU wakes up after reset at 120MHz main PLL speed, -shared with all other system on chip components. Most of the time this -configuration is to slow for the CPU and to fast for the other components. - -PLL reprogramming can be done in the machine specific manner very early when -the CONFIG_S3C_PLL_INIT and CONFIG_MACH_HAS_LOWLEVEL_INIT symbols are -defined. The board must provide a board_init_lowlevel() assembler function in -this case and calling the s3c24x0_pll_init() assembler function. - -If the s3c24x0_pll_init() is called a few further symbols must be defined to -setup the correct values for the machine. - -Define in the machine specific config.h the following symbols: - -- S3C24XX_CLOCK_REFERENCE with the frequency in Hz of your reference crystal. -- BOARD_SPECIFIC_CLKDIVN with the value for the main clock ratio register (CLKDIVN) -- BOARD_SPECIFIC_MPLL with the value for the main PLL setup register -- BOARD_SPECIFIC_UPLL with the value for the USB PLL setup register - -@note Valid values for the PLL settings can be found in the CPU manual. - -@par Background: PLL frequency calculation for the S3C2410 CPU (both PLLs) and S3C2440 (UPLL only) - -@f[ - f_{PLL} = \frac{m * f_{Ref}}{p * 2^s} -@f] - -With m = MDIV + 8, p = PDIV + 2 and s = SDIV. - -@par Background: PLL frequency calculation for the S3C2440 CPU (MPLL only) - -@f[ - f_{PLL} = \frac{2 * m * f_{Ref}}{p * 2^s} -@f] - -With m = MDIV + 8, p = PDIV + 2 and s = SDIV. - -@note This routine can be used for the S3C2410 and the S3C2440 CPU. - -*/ - -/* ----------------------------------------------------------------------- */ - -#ifdef CONFIG_S3C_SDRAM_INIT - - .section ".text_bare_init.s3c24x0_sdram_init","ax" - - .globl s3c24x0_sdram_init -s3c24x0_sdram_init: - - adr r0, SDRAMDATA /* get the current relative address of the table */ - mov r1, #S3C_MEMCTL_BASE - mov r2, #6 /* we *know* it contains 6 entries */ - - ldr r3, [r0], #4 /* write BSWCON first */ - str r3, [r1], #0x1c /* post add register offset for bank6 */ -/* - * Initializing the SDRAM controller is very simple: - * Just write some useful values into the SDRAM controller. - */ -0: ldr r3, [r0], #4 - str r3, [r1], #4 - subs r2, r2, #1 - bne 0b - - mov pc, lr - -SDRAMDATA: - .word BOARD_SPECIFIC_BWSCON - .word BOARD_SPECIFIC_BANKCON6 - .word BOARD_SPECIFIC_BANKCON7 - .word BOARD_SPECIFIC_REFRESH - .word BOARD_SPECIFIC_BANKSIZE - .word BOARD_SPECIFIC_MRSRB6 - .word BOARD_SPECIFIC_MRSRB7 - -#endif - -/** -@page dev_s3c24xx_sdram_handling SDRAM controller initialisation - -The SDRAM controller is very simple and its initialisation requires only a -few steps. barebox provides a generic routine to do this step. - -Enable CONFIG_S3C_SDRAM_INIT and CONFIG_MACH_HAS_LOWLEVEL_INIT to be able -to call the generic s3c24x0_sdram_init() assembler function from within the -machine specific board_init_lowlevel() assembler function. - -To use the s3c24x0_sdram_init() assembler function a few symbols must be -defined to setup correct values for the machine. - -Define in the machine specific config.h the following list of symbols: - -- BOARD_SPECIFIC_BWSCON with the values for SDRAM banks 6 and 7 -- BOARD_SPECIFIC_BANKCON6 with the value for the BANKCON6 register -- BOARD_SPECIFIC_BANKCON7 with the value for the BANKCON7 register -- BOARD_SPECIFIC_REFRESH with the value for the REFRESH register -- BOARD_SPECIFIC_BANKSIZE with the value for the BANKSIZE register -- BOARD_SPECIFIC_MRSRB6 with the value for the MRSRB6 register -- BOARD_SPECIFIC_MRSRB7 with the value for the MRSRB7 register -*/ - -/* ----------------------------------------------------------------------- */ - -#ifdef CONFIG_S3C_NAND_BOOT - - .section ".text_bare_init.s3c24x0_nand_boot","ax" - - .globl s3c24x0_nand_boot -s3c24x0_nand_boot: -/* - * In the case of NOR boot we are running from the same address space. - * Detect this case to handle it correctly. - */ - mov r1, #S3C_MEMCTL_BASE - ldr r3, [r1] - and r3, r3, #0x6 - cmp r3, #0x0 /* check for NAND case */ - beq 2f - mov pc, lr /* NOR case: nothing to do here */ - -2: ldr sp, =TEXT_BASE /* Setup a temporary stack in SDRAM */ -/* - * We still run at a location we are not linked to. But lets still running - * from the internal SRAM, this may speed up the boot - */ - push {lr} - bl nand_boot - pop {lr} -/* - * Adjust the return address to the correct address in SDRAM - */ - ldr r1, =TEXT_BASE - add lr, lr, r1 - - mov pc, lr - -#endif - -/** -@page dev_s3c24xx_nandboot_handling Booting from NAND - -To be able to boot from NAND memory only, enable the S3C24x0 NAND driver. Also -enable CONFIG_S3C_NAND_BOOT and CONFIG_MACH_HAS_LOWLEVEL_INIT to be -able to call the s3c24x0_nand_boot() assembler routine from within the -machine specific board_init_lowlevel() assembler function. - -@note This routine assumes an already working SDRAM controller and -an initialized stack pointer. - -@note Basicly this routine runs from inside the internal SRAM. After load of -the whole barebox image from the NAND flash memory into the SDRAM it adjusts -the link register to the final SDRAM adress and returns. - -@note In the NAND boot mode, ECC is not checked. So, the first x KBytes used -by barebox should have no bit error. - -Due to the fact the code to load the whole barebox from NAND must fit into -the first 4kiB of the barebox image, the shrinked NAND driver is very -minimalistic. Setup the NAND access timing is done in a safe manner, what -means: Slowest possible values are used. If you want to increase the speed you -should define the BOARD_DEFAULT_NAND_TIMING to a valid setting into the -NFCONF register and add it to your board specific config.h. Refer S3C24x0's -datasheet for further details. The macro #CALC_NFCONF_TIMING could help to -calculate the register setting in a hardware independent manner. - -@note The regular NAND driver uses a platform data structure to define the -NAND access timings. - -@note Its still possible to boot this image from NOR memory. If this routine -detects it is running from NOR instead of the internal SRAM it skips any -loading and returns immediately. - -*/ diff --git a/arch/arm/mach-samsung/lowlevel-s3c24x0.S b/arch/arm/mach-samsung/lowlevel-s3c24x0.S new file mode 100644 index 0000000..e9471a5 --- /dev/null +++ b/arch/arm/mach-samsung/lowlevel-s3c24x0.S @@ -0,0 +1,317 @@ +/* + * (C) Copyright 2009 + * Juergen Beisert <kernel@pengutronix.de> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <config.h> +#include <mach/s3c-iomap.h> + + .section ".text_bare_init.s3c24x0_disable_wd","ax" + +/* + * Disable the watchdog, else it continues to bark + */ +.globl s3c24x0_disable_wd +s3c24x0_disable_wd: + + ldr r0, =S3C_WATCHDOG_BASE + mov r1, #0x0 + str r1, [r0] + mov pc, lr + +/** +@page dev_s3c24xx_wd_handling Watchdog handling + +The watchdog must be disabled very early, because if it resets the system +it is still active and will continue to reset the system. So, call this +routine very early in your board_init_lowlevel routine. +*/ + +/* + * S3C2410 PLL configuration + * ------------------------- + * + * Basic frequency calculation + * + * m * REFclk s = SDIV + * PLLclk = ------------ p = PDIV + 2 + * p * 2^s m = MDIV + 8 + * + * After reset the PLL of the s3c2410 processor uses: + * + * MPLL UPLL + * MDIV 0x5c 0x28 + * PDIV 0x08 0x08 + * SDIV 0x0 0x0 + * + * 100 * 12MHz 1200MHz + * MPLLclk = ------------- = -------- = 120MHz + * 10 * 2^0 10 + * + * 48 * 12MHz 576MHz + * UPLLclk = ------------- = -------- = 57,6MHz + * 10 * 2^0 10 + * + * Note: Do not use "r10" here in this code + */ + +#ifdef CONFIG_S3C_PLL_INIT + + .section ".text_bare_init.s3c24x0_pll_init","ax" + +.globl s3c24x0_pll_init +s3c24x0_pll_init: + + mov r0, #S3C_CLOCK_POWER_BASE + + /* configure internal clock ratio */ + mov r1, #BOARD_SPECIFIC_CLKDIVN + str r1, [r0, #20] + + /* enable all devices on this chip */ + mov r1, #0xFFFFFFF0 + str r1, [r0, #12] + + /* ??????? */ +#ifdef CONFIG_CPU_S3C2440 + mov r1, #0xFFFFFFFF +#endif +#ifdef CONFIG_CPU_S3C2410 + mov r1, #0x00FFFFFF +#endif + str r1, [r0, #0] + +#ifdef CONFIG_CPU_S3C2440 + /* + * Most of the time HDIVN is not 0, so we must use the + * asynchronous bus mode (refer datasheet "Clock and Power Management") + */ + mrc p15, 0, r1, c1, c0, 0 + orr r1, r1, #0xc0000000 + mcr p15, 0, r1, c1, c0, 0 +#endif + + /* configure UPLL */ + ldr r1, =BOARD_SPECIFIC_UPLL + str r1, [r0, #8] + + nop + nop + nop + nop + nop + nop + nop + nop + + /* configure MPLL */ + ldr r1, =BOARD_SPECIFIC_MPLL + str r1, [r0, #4] + + nop + nop + nop + nop + nop + nop + nop + nop + + mov pc, lr + +#endif + +/** +@page dev_s3c24xx_pll_handling PLL clock handling + +To control the speed of your machine the PLLs must be reconfigured after reset. + +For example the S3C2410 CPU wakes up after reset at 120MHz main PLL speed, +shared with all other system on chip components. Most of the time this +configuration is to slow for the CPU and to fast for the other components. + +PLL reprogramming can be done in the machine specific manner very early when +the CONFIG_S3C_PLL_INIT and CONFIG_MACH_HAS_LOWLEVEL_INIT symbols are +defined. The board must provide a board_init_lowlevel() assembler function in +this case and calling the s3c24x0_pll_init() assembler function. + +If the s3c24x0_pll_init() is called a few further symbols must be defined to +setup the correct values for the machine. + +Define in the machine specific config.h the following symbols: + +- S3C24XX_CLOCK_REFERENCE with the frequency in Hz of your reference crystal. +- BOARD_SPECIFIC_CLKDIVN with the value for the main clock ratio register (CLKDIVN) +- BOARD_SPECIFIC_MPLL with the value for the main PLL setup register +- BOARD_SPECIFIC_UPLL with the value for the USB PLL setup register + +@note Valid values for the PLL settings can be found in the CPU manual. + +@par Background: PLL frequency calculation for the S3C2410 CPU (both PLLs) and S3C2440 (UPLL only) + +@f[ + f_{PLL} = \frac{m * f_{Ref}}{p * 2^s} +@f] + +With m = MDIV + 8, p = PDIV + 2 and s = SDIV. + +@par Background: PLL frequency calculation for the S3C2440 CPU (MPLL only) + +@f[ + f_{PLL} = \frac{2 * m * f_{Ref}}{p * 2^s} +@f] + +With m = MDIV + 8, p = PDIV + 2 and s = SDIV. + +@note This routine can be used for the S3C2410 and the S3C2440 CPU. + +*/ + +/* ----------------------------------------------------------------------- */ + +#ifdef CONFIG_S3C_SDRAM_INIT + + .section ".text_bare_init.s3c24x0_sdram_init","ax" + + .globl s3c24x0_sdram_init +s3c24x0_sdram_init: + + adr r0, SDRAMDATA /* get the current relative address of the table */ + mov r1, #S3C_MEMCTL_BASE + mov r2, #6 /* we *know* it contains 6 entries */ + + ldr r3, [r0], #4 /* write BSWCON first */ + str r3, [r1], #0x1c /* post add register offset for bank6 */ +/* + * Initializing the SDRAM controller is very simple: + * Just write some useful values into the SDRAM controller. + */ +0: ldr r3, [r0], #4 + str r3, [r1], #4 + subs r2, r2, #1 + bne 0b + + mov pc, lr + +SDRAMDATA: + .word BOARD_SPECIFIC_BWSCON + .word BOARD_SPECIFIC_BANKCON6 + .word BOARD_SPECIFIC_BANKCON7 + .word BOARD_SPECIFIC_REFRESH + .word BOARD_SPECIFIC_BANKSIZE + .word BOARD_SPECIFIC_MRSRB6 + .word BOARD_SPECIFIC_MRSRB7 + +#endif + +/** +@page dev_s3c24xx_sdram_handling SDRAM controller initialisation + +The SDRAM controller is very simple and its initialisation requires only a +few steps. barebox provides a generic routine to do this step. + +Enable CONFIG_S3C_SDRAM_INIT and CONFIG_MACH_HAS_LOWLEVEL_INIT to be able +to call the generic s3c24x0_sdram_init() assembler function from within the +machine specific board_init_lowlevel() assembler function. + +To use the s3c24x0_sdram_init() assembler function a few symbols must be +defined to setup correct values for the machine. + +Define in the machine specific config.h the following list of symbols: + +- BOARD_SPECIFIC_BWSCON with the values for SDRAM banks 6 and 7 +- BOARD_SPECIFIC_BANKCON6 with the value for the BANKCON6 register +- BOARD_SPECIFIC_BANKCON7 with the value for the BANKCON7 register +- BOARD_SPECIFIC_REFRESH with the value for the REFRESH register +- BOARD_SPECIFIC_BANKSIZE with the value for the BANKSIZE register +- BOARD_SPECIFIC_MRSRB6 with the value for the MRSRB6 register +- BOARD_SPECIFIC_MRSRB7 with the value for the MRSRB7 register +*/ + +/* ----------------------------------------------------------------------- */ + +#ifdef CONFIG_S3C_NAND_BOOT + + .section ".text_bare_init.s3c24x0_nand_boot","ax" + + .globl s3c24x0_nand_boot +s3c24x0_nand_boot: +/* + * In the case of NOR boot we are running from the same address space. + * Detect this case to handle it correctly. + */ + mov r1, #S3C_MEMCTL_BASE + ldr r3, [r1] + and r3, r3, #0x6 + cmp r3, #0x0 /* check for NAND case */ + beq 2f + mov pc, lr /* NOR case: nothing to do here */ + +2: ldr sp, =TEXT_BASE /* Setup a temporary stack in SDRAM */ +/* + * We still run at a location we are not linked to. But lets still running + * from the internal SRAM, this may speed up the boot + */ + push {lr} + bl nand_boot + pop {lr} +/* + * Adjust the return address to the correct address in SDRAM + */ + ldr r1, =TEXT_BASE + add lr, lr, r1 + + mov pc, lr + +#endif + +/** +@page dev_s3c24xx_nandboot_handling Booting from NAND + +To be able to boot from NAND memory only, enable the S3C24x0 NAND driver. Also +enable CONFIG_S3C_NAND_BOOT and CONFIG_MACH_HAS_LOWLEVEL_INIT to be +able to call the s3c24x0_nand_boot() assembler routine from within the +machine specific board_init_lowlevel() assembler function. + +@note This routine assumes an already working SDRAM controller and +an initialized stack pointer. + +@note Basicly this routine runs from inside the internal SRAM. After load of +the whole barebox image from the NAND flash memory into the SDRAM it adjusts +the link register to the final SDRAM adress and returns. + +@note In the NAND boot mode, ECC is not checked. So, the first x KBytes used +by barebox should have no bit error. + +Due to the fact the code to load the whole barebox from NAND must fit into +the first 4kiB of the barebox image, the shrinked NAND driver is very +minimalistic. Setup the NAND access timing is done in a safe manner, what +means: Slowest possible values are used. If you want to increase the speed you +should define the BOARD_DEFAULT_NAND_TIMING to a valid setting into the +NFCONF register and add it to your board specific config.h. Refer S3C24x0's +datasheet for further details. The macro #CALC_NFCONF_TIMING could help to +calculate the register setting in a hardware independent manner. + +@note The regular NAND driver uses a platform data structure to define the +NAND access timings. + +@note Its still possible to boot this image from NOR memory. If this routine +detects it is running from NOR instead of the internal SRAM it skips any +loading and returns immediately. + +*/ diff --git a/arch/arm/mach-samsung/mem-s3c24x0.c b/arch/arm/mach-samsung/mem-s3c24x0.c new file mode 100644 index 0000000..6834be4 --- /dev/null +++ b/arch/arm/mach-samsung/mem-s3c24x0.c @@ -0,0 +1,143 @@ +/* + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ +/** + * @file + * @brief Basic clock, sdram and timer handling for S3C24xx CPUs + */ + +#include <config.h> +#include <common.h> +#include <init.h> +#include <clock.h> +#include <io.h> +#include <sizes.h> +#include <mach/s3c-iomap.h> +#include <mach/s3c-generic.h> +#include <mach/s3c-busctl.h> +#include <mach/s3c24xx-gpio.h> + +/** + * Calculate the amount of connected and available memory + * @return Memory size in bytes + */ +uint32_t s3c_get_memory_size(void) +{ + uint32_t reg, size; + + /* + * detect the current memory size + */ + reg = readl(S3C_BANKSIZE); + + switch (reg & 0x7) { + case 0: + size = SZ_32M; + break; + case 1: + size = SZ_64M; + break; + case 2: + size = SZ_128M; + break; + case 4: + size = SZ_2M; + break; + case 5: + size = SZ_4M; + break; + case 6: + size = SZ_8M; + break; + default: + size = SZ_16M; + break; + } + + /* + * Is bank7 also configured for SDRAM usage? + */ + if ((readl(S3C_BANKCON7) & (0x3 << 15)) == (0x3 << 15)) + size <<= 1; /* also count this bank */ + + return size; +} + +void s3c24xx_disable_second_sdram_bank(void) +{ + writel(readl(S3C_BANKCON7) & ~(0x3 << 15), S3C_BANKCON7); + writel(readl(S3C_MISCCR) | (1 << 18), S3C_MISCCR); /* disable its clock */ +} + +/** + +@page dev_s3c24xx_arch Samsung's S3C24xx Platforms in barebox + +@section s3c24xx_boards Boards using S3C24xx Processors + +@li @subpage arch/arm/boards/a9m2410/a9m2410.c +@li @subpage arch/arm/boards/a9m2440/a9m2440.c + +@section s3c24xx_arch Documentation for S3C24xx Architectures Files + +@li @subpage arch/arm/mach-s3c24xx/generic.c + +@section s3c24xx_mem_map SDRAM Memory Map + +SDRAM starts at address 0x3000.0000 up to the available amount of connected +SDRAM memory. Physically this CPU can handle up to 256MiB (two areas with +up to 128MiB each). + +@subsection s3c24xx_mem_generic_map Generic Map +- 0x0000.0000 Start of the internal SRAM when booting from NAND flash memory or CS signal to a NOR flash memory. +- 0x0800.0000 Start of I/O space. +- 0x3000.0000 Start of SDRAM area. + - 0x3000.0100 Start of the TAG list area. + - 0x3000.8000 Start of the linux kernel (physical address). +- 0x4000.0000 Start of internal SRAM, when booting from NOR flash memory +- 0x4800.0000 Start of the internal I/O area + +@section s3c24xx_asm_arm include/asm-arm/arch-s3c24xx directory guidelines +All S3C24xx common headers are located here. + +@note Do not add board specific header files/information here. +*/ + +/** @page dev_s3c24xx_mach Samsung's S3C24xx based platforms + +@par barebox Map + +The location of the @a barebox itself depends on the available amount of +installed SDRAM memory: + +- 0x30fc.0000 Start of @a barebox when 16MiB SDRAM is available +- 0x31fc.0000 Start of @a barebox when 32MiB SDRAM is available +- 0x33fc.0000 Start of @a barebox when 64MiB SDRAM is available + +Adjust the @p CONFIG_TEXT_BASE/CONFIG_ARCH_TEXT_BASE symbol in accordance to +the available memory. + +@note The RAM based filesystem and the stack resides always below the +@a barebox start address. + +@li @subpage dev_s3c24xx_wd_handling +@li @subpage dev_s3c24xx_pll_handling +@li @subpage dev_s3c24xx_sdram_handling +@li @subpage dev_s3c24xx_nandboot_handling +*/ -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/7] Split S3C generic and S3C24xx specific code 2012-05-15 13:20 ` [PATCH 2/7] Split S3C generic and S3C24xx specific code Alexey Galakhov @ 2012-05-17 17:52 ` Sascha Hauer 2012-05-17 18:33 ` Alexey Galakhov 2012-05-18 9:43 ` [PATCHv4 0/7] S5PV210 support (upd.) Alexey Galakhov 0 siblings, 2 replies; 29+ messages in thread From: Sascha Hauer @ 2012-05-17 17:52 UTC (permalink / raw) To: Alexey Galakhov; +Cc: barebox On Tue, May 15, 2012 at 07:20:35PM +0600, Alexey Galakhov wrote: > Signed-off-by: Alexey Galakhov <agalakhov@gmail.com> > --- > diff --git a/arch/arm/boards/a9m2410/a9m2410.c b/arch/arm/boards/a9m2410/a9m2410.c > index eaafdbd..31ed772 100644 > --- a/arch/arm/boards/a9m2410/a9m2410.c > +++ b/arch/arm/boards/a9m2410/a9m2410.c > @@ -51,7 +51,7 @@ static int a9m2410_mem_init(void) > * Note: On this card the second SDRAM page is not used > */ > s3c24xx_disable_second_sdram_bank(); > - size = s3c24xx_get_memory_size(); > + size = s3c_get_memory_size(); Still you convert two different functions to a common name. Once again: Please keep s3c24xx_get_memory_size and add a s5p_get_memory_size function for the s5p SoC. It turned out to be useful when functions (or defines) have a spcific SoC name in them. This way you always know in which context a function is valid. Also it makes it possible to compile in all (in this case memory setup) functions in a single binary. I know that we do not follow this rule very strictly in barebox, but I won't accept patches that change places that do it right already. Sascha -- 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 barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/7] Split S3C generic and S3C24xx specific code 2012-05-17 17:52 ` Sascha Hauer @ 2012-05-17 18:33 ` Alexey Galakhov 2012-05-17 19:49 ` Juergen Beisert 2012-05-18 8:35 ` Sascha Hauer 2012-05-18 9:43 ` [PATCHv4 0/7] S5PV210 support (upd.) Alexey Galakhov 1 sibling, 2 replies; 29+ messages in thread From: Alexey Galakhov @ 2012-05-17 18:33 UTC (permalink / raw) To: Sascha Hauer; +Cc: barebox 2012/5/17 Sascha Hauer <s.hauer@pengutronix.de>: > Still you convert two different functions to a common name. Once again: > Please keep s3c24xx_get_memory_size and add a s5p_get_memory_size > function for the s5p SoC. > It turned out to be useful when functions (or defines) have a spcific > SoC name in them. This way you always know in which context a function > is valid. Also it makes it possible to compile in all (in this case memory > setup) functions in a single binary. > I know that we do not follow this rule very strictly in barebox, but I > won't accept patches that change places that do it right already. Ok. Sorry. BTW, there are functions like s3c_get_pclk(), and they are much worse than get_memory_size regarding their portability. Newer S3Cs have multiple clock domains, so there is more than one PCLK (i.e., MSYS-PCLK and HSYS-PCLK). These functions are declared publilc, not static, in a header file. They all are used in S3C24x0-specific code only. Should they be renamed like s3c24xx_get_pclk() ? Should some of them become static? _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/7] Split S3C generic and S3C24xx specific code 2012-05-17 18:33 ` Alexey Galakhov @ 2012-05-17 19:49 ` Juergen Beisert 2012-05-18 6:49 ` Alexey Galakhov 2012-05-18 8:35 ` Sascha Hauer 1 sibling, 1 reply; 29+ messages in thread From: Juergen Beisert @ 2012-05-17 19:49 UTC (permalink / raw) To: barebox; +Cc: Alexey Galakhov Alexey Galakhov wrote: > 2012/5/17 Sascha Hauer <s.hauer@pengutronix.de>: > > Still you convert two different functions to a common name. Once again: > > Please keep s3c24xx_get_memory_size and add a s5p_get_memory_size > > function for the s5p SoC. > > It turned out to be useful when functions (or defines) have a spcific > > SoC name in them. This way you always know in which context a function > > is valid. Also it makes it possible to compile in all (in this case > > memory setup) functions in a single binary. > > I know that we do not follow this rule very strictly in barebox, but I > > won't accept patches that change places that do it right already. > > Ok. Sorry. > > BTW, there are functions like s3c_get_pclk(), and they are much worse > than get_memory_size regarding their portability. Newer S3Cs have > multiple clock domains, so there is more than one PCLK (i.e., > MSYS-PCLK and HSYS-PCLK). These functions are declared publilc, not > static, in a header file. They all are used in S3C24x0-specific code > only. Should they be renamed like s3c24xx_get_pclk() ? Should some of > them become static? Mostly a matter of taste. But sometimes these functions should use a common name: when they are used by a shared driver. If you call a S3C2440 related function by a S3C2440 related driver or board file, we should use a SoC specific name. When we call a function from a driver used for S3C2440 *and* S3C6410 it should use a non SoC specific name. This is a "should" and I fear my S3C24xx code is not perfect in this way. Regards, Juergen -- Pengutronix e.K. | Juergen Beisert | Linux Solutions for Science and Industry | http://www.pengutronix.de/ | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/7] Split S3C generic and S3C24xx specific code 2012-05-17 19:49 ` Juergen Beisert @ 2012-05-18 6:49 ` Alexey Galakhov 2012-05-18 8:38 ` Sascha Hauer 0 siblings, 1 reply; 29+ messages in thread From: Alexey Galakhov @ 2012-05-18 6:49 UTC (permalink / raw) To: Juergen Beisert; +Cc: barebox > Mostly a matter of taste. But sometimes these functions should use a common > name: when they are used by a shared driver. > If you call a S3C2440 related function by a S3C2440 related driver or board > file, we should use a SoC specific name. When we call a function from a > driver used for S3C2440 *and* S3C6410 it should use a non SoC specific name. > This is a "should" and I fear my S3C24xx code is not perfect in this way. What if... int s3c24xx_get_pclk(void); int s3c64xx_get_pclk_msys(void); int s3c64xx_get_pclk_psys(void); And in some driver: #ifdef ... x = s3c24xx_get_pclk(); #else x = s3c64xx_get_pclk_msys(); #endif In some other driver: #ifdef ... x = s3c24xx_get_pclk(); #else x = s3c64xx_get_pclk_psys(); #endif Ho to do that correctly? Right now I prefer that way: int s3c_get_some_driver_clk(void); defined somewhere in arch/*** Regards. -- Alex _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/7] Split S3C generic and S3C24xx specific code 2012-05-18 6:49 ` Alexey Galakhov @ 2012-05-18 8:38 ` Sascha Hauer 2012-05-18 9:06 ` Alexey Galakhov 0 siblings, 1 reply; 29+ messages in thread From: Sascha Hauer @ 2012-05-18 8:38 UTC (permalink / raw) To: Alexey Galakhov; +Cc: barebox, Juergen Beisert On Fri, May 18, 2012 at 12:49:25PM +0600, Alexey Galakhov wrote: > > Mostly a matter of taste. But sometimes these functions should use a common > > name: when they are used by a shared driver. > > If you call a S3C2440 related function by a S3C2440 related driver or board > > file, we should use a SoC specific name. When we call a function from a > > driver used for S3C2440 *and* S3C6410 it should use a non SoC specific name. > > This is a "should" and I fear my S3C24xx code is not perfect in this way. > > What if... > > int s3c24xx_get_pclk(void); > int s3c64xx_get_pclk_msys(void); > int s3c64xx_get_pclk_psys(void); > > And in some driver: > > #ifdef ... > x = s3c24xx_get_pclk(); > #else > x = s3c64xx_get_pclk_msys(); > #endif > > In some other driver: > > #ifdef ... > x = s3c24xx_get_pclk(); > #else > x = s3c64xx_get_pclk_psys(); > #endif > > Ho to do that correctly? Right now I prefer that way: > > int s3c_get_some_driver_clk(void); > defined somewhere in arch/*** Me too. As said, ideally we would have a clk_get(dev, id), but we don't have this atm. (We have it on Atmel, you could do the same, but I don't ask you to do this if you don't want to) Sascha -- 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 barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/7] Split S3C generic and S3C24xx specific code 2012-05-18 8:38 ` Sascha Hauer @ 2012-05-18 9:06 ` Alexey Galakhov 0 siblings, 0 replies; 29+ messages in thread From: Alexey Galakhov @ 2012-05-18 9:06 UTC (permalink / raw) To: Sascha Hauer; +Cc: barebox, Juergen Beisert On 18.05.2012 14:38, Sascha Hauer wrote: > On Fri, May 18, 2012 at 12:49:25PM +0600, Alexey Galakhov wrote: >> Ho to do that correctly? Right now I prefer that way: >> >> int s3c_get_some_driver_clk(void); >> defined somewhere in arch/*** > > Me too. As said, ideally we would have a clk_get(dev, id), but we don't > have this atm. (We have it on Atmel, you could do the same, but I don't > ask you to do this if you don't want to) > > Sascha Ok. I thought about introducing such an API too, but probably not yet. I think it's better to add 6410 and maybe Exynos first and then refactor. Newer Samsung chips are poorly documented, so it's hard to decide what's common and what's specific. (In fact, there are even errors in datasheets!) I.e., it turned out that s3c24x0_disable_wd() fits s5pv210 perfectly too without any change. (Just writing 0 into the first watchdog register disables the watchdog). This probably should be s3c_disable_watchdog(). I didn't touch it yet since I don't disable WD and I'm not sure about other CPUs. Regards, -- Alex _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 2/7] Split S3C generic and S3C24xx specific code 2012-05-17 18:33 ` Alexey Galakhov 2012-05-17 19:49 ` Juergen Beisert @ 2012-05-18 8:35 ` Sascha Hauer 1 sibling, 0 replies; 29+ messages in thread From: Sascha Hauer @ 2012-05-18 8:35 UTC (permalink / raw) To: Alexey Galakhov; +Cc: barebox On Fri, May 18, 2012 at 12:33:20AM +0600, Alexey Galakhov wrote: > 2012/5/17 Sascha Hauer <s.hauer@pengutronix.de>: > > Still you convert two different functions to a common name. Once again: > > Please keep s3c24xx_get_memory_size and add a s5p_get_memory_size > > function for the s5p SoC. > > It turned out to be useful when functions (or defines) have a spcific > > SoC name in them. This way you always know in which context a function > > is valid. Also it makes it possible to compile in all (in this case memory > > setup) functions in a single binary. > > I know that we do not follow this rule very strictly in barebox, but I > > won't accept patches that change places that do it right already. > > Ok. Sorry. > > BTW, there are functions like s3c_get_pclk(), and they are much worse > than get_memory_size regarding their portability. Newer S3Cs have > multiple clock domains, so there is more than one PCLK (i.e., > MSYS-PCLK and HSYS-PCLK). These functions are declared publilc, not > static, in a header file. They all are used in S3C24x0-specific code > only. Should they be renamed like s3c24xx_get_pclk() ? Should some of > them become static? I think in this case you have to make sure that s3c24xx-clocks.c is not compiled into the binary when s5p is enabled. Ideally we would have some debloated clk framework version from the kernel, but we are not there yet. We have the same situation on i.MX where imx_get_uartclk is implemented in each SoC. This is not very clean, but (still) does its job. I'm not asking you to make your port perfect in this regard, just please don't change things for worse which are already implemented the way they are supposed to be. Sascha -- 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 barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCHv4 0/7] S5PV210 support (upd.) 2012-05-17 17:52 ` Sascha Hauer 2012-05-17 18:33 ` Alexey Galakhov @ 2012-05-18 9:43 ` Alexey Galakhov 2012-05-18 9:43 ` [PATCH 1/7] Make S3C24xx config options available for all S3Cs Alexey Galakhov ` (7 more replies) 1 sibling, 8 replies; 29+ messages in thread From: Alexey Galakhov @ 2012-05-18 9:43 UTC (permalink / raw) To: barebox; +Cc: Alexey Galakhov Removed function renaming (s3c24xx_get_memory_size). Everything else is left untouched and only reflects the above change. Alexey Galakhov (7): Make S3C24xx config options available for all S3Cs Split S3C generic and S3C24xx specific code Add support for Samsung S5P architecture (S5PV210) S5P boot header and image generator S5P lowlevel clock init S5P DRAM support Add FriendlyArm Tiny210 board (S5PV210) .gitignore | 2 + Makefile | 2 +- arch/arm/Kconfig | 6 + arch/arm/Makefile | 8 + arch/arm/boards/a9m2410/a9m2410.c | 2 +- arch/arm/boards/a9m2410/config.h | 2 +- arch/arm/boards/a9m2410/lowlevel_init.S | 2 +- arch/arm/boards/a9m2440/a9m2440.c | 2 +- arch/arm/boards/a9m2440/config.h | 2 +- arch/arm/boards/a9m2440/lowlevel_init.S | 2 +- arch/arm/boards/mini2440/config.h | 2 +- arch/arm/boards/mini2440/lowlevel_init.S | 2 +- arch/arm/boards/mini2440/mini2440.c | 2 +- arch/arm/boards/tiny210/Makefile | 1 + arch/arm/boards/tiny210/config.h | 21 + arch/arm/boards/tiny210/lowlevel.c | 76 ++ arch/arm/boards/tiny210/tiny210.c | 113 +++ arch/arm/configs/a9m2410_defconfig | 2 +- arch/arm/configs/a9m2440_defconfig | 4 +- arch/arm/configs/mini2440_defconfig | 2 +- arch/arm/configs/tiny210_defconfig | 17 + arch/arm/mach-samsung/Kconfig | 57 +- arch/arm/mach-samsung/Makefile | 7 +- arch/arm/mach-samsung/clocks-s5pcxx.c | 98 +++ arch/arm/mach-samsung/generic.c | 113 --- arch/arm/mach-samsung/gpio-s5pcxx.c | 123 +++ arch/arm/mach-samsung/include/mach/gpio.h | 3 + arch/arm/mach-samsung/include/mach/iomux-s5pcxx.h | 798 ++++++++++++++++++++ arch/arm/mach-samsung/include/mach/s3c-clocks.h | 25 +- arch/arm/mach-samsung/include/mach/s3c-generic.h | 9 +- arch/arm/mach-samsung/include/mach/s3c-iomap.h | 56 +- .../arm/mach-samsung/include/mach/s3c24xx-clocks.h | 24 + arch/arm/mach-samsung/include/mach/s3c24xx-gpio.h | 6 +- arch/arm/mach-samsung/include/mach/s3c24xx-iomap.h | 69 ++ arch/arm/mach-samsung/include/mach/s3c24xx-nand.h | 2 +- arch/arm/mach-samsung/include/mach/s5pcxx-clocks.h | 55 ++ arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h | 52 ++ arch/arm/mach-samsung/lowlevel-init.S | 317 -------- arch/arm/mach-samsung/lowlevel-s3c24x0.S | 317 ++++++++ arch/arm/mach-samsung/lowlevel-s5pcxx.c | 61 ++ arch/arm/mach-samsung/mem-s3c24x0.c | 143 ++++ arch/arm/mach-samsung/mem-s5pcxx.c | 260 +++++++ drivers/mtd/nand/nand_s3c24xx.c | 10 +- scripts/Makefile | 1 + scripts/s5p_cksum.c | 140 ++++ 45 files changed, 2487 insertions(+), 531 deletions(-) create mode 100644 arch/arm/boards/tiny210/Makefile create mode 100644 arch/arm/boards/tiny210/config.h create mode 100644 arch/arm/boards/tiny210/lowlevel.c create mode 100644 arch/arm/boards/tiny210/tiny210.c create mode 100644 arch/arm/configs/tiny210_defconfig create mode 100644 arch/arm/mach-samsung/clocks-s5pcxx.c create mode 100644 arch/arm/mach-samsung/gpio-s5pcxx.c create mode 100644 arch/arm/mach-samsung/include/mach/iomux-s5pcxx.h create mode 100644 arch/arm/mach-samsung/include/mach/s3c24xx-clocks.h create mode 100644 arch/arm/mach-samsung/include/mach/s3c24xx-iomap.h create mode 100644 arch/arm/mach-samsung/include/mach/s5pcxx-clocks.h create mode 100644 arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h delete mode 100644 arch/arm/mach-samsung/lowlevel-init.S create mode 100644 arch/arm/mach-samsung/lowlevel-s3c24x0.S create mode 100644 arch/arm/mach-samsung/lowlevel-s5pcxx.c create mode 100644 arch/arm/mach-samsung/mem-s3c24x0.c create mode 100644 arch/arm/mach-samsung/mem-s5pcxx.c create mode 100644 scripts/s5p_cksum.c -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 1/7] Make S3C24xx config options available for all S3Cs 2012-05-18 9:43 ` [PATCHv4 0/7] S5PV210 support (upd.) Alexey Galakhov @ 2012-05-18 9:43 ` Alexey Galakhov 2012-05-18 9:43 ` [PATCHv4 2/7] Split S3C generic and S3C24xx specific code Alexey Galakhov ` (6 subsequent siblings) 7 siblings, 0 replies; 29+ messages in thread From: Alexey Galakhov @ 2012-05-18 9:43 UTC (permalink / raw) To: barebox; +Cc: Alexey Galakhov Signed-off-by: Alexey Galakhov <agalakhov@gmail.com> --- arch/arm/boards/a9m2410/a9m2410.c | 2 +- arch/arm/boards/a9m2410/config.h | 2 +- arch/arm/boards/a9m2410/lowlevel_init.S | 2 +- arch/arm/boards/a9m2440/a9m2440.c | 2 +- arch/arm/boards/a9m2440/config.h | 2 +- arch/arm/boards/a9m2440/lowlevel_init.S | 2 +- arch/arm/boards/mini2440/config.h | 2 +- arch/arm/boards/mini2440/lowlevel_init.S | 2 +- arch/arm/boards/mini2440/mini2440.c | 2 +- arch/arm/configs/a9m2410_defconfig | 2 +- arch/arm/configs/a9m2440_defconfig | 4 +-- arch/arm/configs/mini2440_defconfig | 2 +- arch/arm/mach-samsung/Kconfig | 28 ++++++++++----------- arch/arm/mach-samsung/Makefile | 2 +- arch/arm/mach-samsung/include/mach/s3c-iomap.h | 2 +- arch/arm/mach-samsung/include/mach/s3c24xx-nand.h | 2 +- arch/arm/mach-samsung/lowlevel-init.S | 12 ++++----- drivers/mtd/nand/nand_s3c24xx.c | 10 ++++---- 18 files changed, 41 insertions(+), 41 deletions(-) diff --git a/arch/arm/boards/a9m2410/a9m2410.c b/arch/arm/boards/a9m2410/a9m2410.c index 7c51d58..eaafdbd 100644 --- a/arch/arm/boards/a9m2410/a9m2410.c +++ b/arch/arm/boards/a9m2410/a9m2410.c @@ -136,7 +136,7 @@ static int a9m2410_devices_init(void) device_initcall(a9m2410_devices_init); -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT void __bare_init nand_boot(void) { s3c24x0_nand_load_image((void *)TEXT_BASE, 256 * 1024, 0); diff --git a/arch/arm/boards/a9m2410/config.h b/arch/arm/boards/a9m2410/config.h index 87b05fc..4b8a9a2 100644 --- a/arch/arm/boards/a9m2410/config.h +++ b/arch/arm/boards/a9m2410/config.h @@ -115,7 +115,7 @@ #define A9M2410_TWRPH1 1 /* needed in the generic NAND boot code only */ -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT # define BOARD_DEFAULT_NAND_TIMING CALC_NFCONF_TIMING(A9M2410_TACLS, A9M2410_TWRPH0, A9M2410_TWRPH1) #endif diff --git a/arch/arm/boards/a9m2410/lowlevel_init.S b/arch/arm/boards/a9m2410/lowlevel_init.S index a106d53..0463b26 100644 --- a/arch/arm/boards/a9m2410/lowlevel_init.S +++ b/arch/arm/boards/a9m2410/lowlevel_init.S @@ -28,7 +28,7 @@ board_init_lowlevel: bl s3c24x0_sdram_init -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT mov lr, r10 /* restore the link register */ /* up to here we are running from the internal SRAM area */ b s3c24x0_nand_boot /* does return directly to our caller into SDRAM */ diff --git a/arch/arm/boards/a9m2440/a9m2440.c b/arch/arm/boards/a9m2440/a9m2440.c index fcb8729..1d20248 100644 --- a/arch/arm/boards/a9m2440/a9m2440.c +++ b/arch/arm/boards/a9m2440/a9m2440.c @@ -155,7 +155,7 @@ static int a9m2440_devices_init(void) device_initcall(a9m2440_devices_init); -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT void __bare_init nand_boot(void) { s3c24x0_nand_load_image((void *)TEXT_BASE, 256 * 1024, 0); diff --git a/arch/arm/boards/a9m2440/config.h b/arch/arm/boards/a9m2440/config.h index 43cb6ab..09ad949 100644 --- a/arch/arm/boards/a9m2440/config.h +++ b/arch/arm/boards/a9m2440/config.h @@ -66,7 +66,7 @@ #define A9M2440_TWRPH1 1 /* needed in the generic NAND boot code only */ -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT # define BOARD_DEFAULT_NAND_TIMING CALC_NFCONF_TIMING(A9M2440_TACLS, A9M2440_TWRPH0, A9M2440_TWRPH1) #endif diff --git a/arch/arm/boards/a9m2440/lowlevel_init.S b/arch/arm/boards/a9m2440/lowlevel_init.S index e915a16..305014c 100644 --- a/arch/arm/boards/a9m2440/lowlevel_init.S +++ b/arch/arm/boards/a9m2440/lowlevel_init.S @@ -232,7 +232,7 @@ board_init_lowlevel: bl sdram_init -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT mov lr, r10 /* restore the link register */ /* up to here we are running from the internal SRAM area */ b s3c24x0_nand_boot /* does return directly to our caller into SDRAM */ diff --git a/arch/arm/boards/mini2440/config.h b/arch/arm/boards/mini2440/config.h index 8d36193..674d974 100644 --- a/arch/arm/boards/mini2440/config.h +++ b/arch/arm/boards/mini2440/config.h @@ -66,7 +66,7 @@ #define MINI2440_TWRPH1 1 /* needed in the generic NAND boot code only */ -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT # define BOARD_DEFAULT_NAND_TIMING \ CALC_NFCONF_TIMING(MINI2440_TACLS, MINI2440_TWRPH0, MINI2440_TWRPH1) #endif diff --git a/arch/arm/boards/mini2440/lowlevel_init.S b/arch/arm/boards/mini2440/lowlevel_init.S index 1c8860a..827cf00 100644 --- a/arch/arm/boards/mini2440/lowlevel_init.S +++ b/arch/arm/boards/mini2440/lowlevel_init.S @@ -30,7 +30,7 @@ board_init_lowlevel: bl s3c24x0_sdram_init -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT mov lr, r10 /* restore the link register */ /* up to here we are running from the internal SRAM area */ b s3c24x0_nand_boot /* does return directly to our caller into SDRAM */ diff --git a/arch/arm/boards/mini2440/mini2440.c b/arch/arm/boards/mini2440/mini2440.c index 03e3d6c..3d3b820 100644 --- a/arch/arm/boards/mini2440/mini2440.c +++ b/arch/arm/boards/mini2440/mini2440.c @@ -326,7 +326,7 @@ static int mini2440_devices_init(void) device_initcall(mini2440_devices_init); -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT void __bare_init nand_boot(void) { s3c24x0_nand_load_image((void *)TEXT_BASE, 256 * 1024, 0); diff --git a/arch/arm/configs/a9m2410_defconfig b/arch/arm/configs/a9m2410_defconfig index 57e73c7..1955023 100644 --- a/arch/arm/configs/a9m2410_defconfig +++ b/arch/arm/configs/a9m2410_defconfig @@ -1,5 +1,5 @@ CONFIG_ARCH_S3C24xx=y -CONFIG_S3C24XX_NAND_BOOT=y +CONFIG_S3C_NAND_BOOT=y CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y CONFIG_BROKEN=y CONFIG_EXPERIMENTAL=y diff --git a/arch/arm/configs/a9m2440_defconfig b/arch/arm/configs/a9m2440_defconfig index ae7f523..ebdf64f 100644 --- a/arch/arm/configs/a9m2440_defconfig +++ b/arch/arm/configs/a9m2440_defconfig @@ -1,7 +1,7 @@ CONFIG_ARCH_S3C24xx=y CONFIG_MACH_A9M2440=y -CONFIG_S3C24XX_SDRAM_INIT=y -CONFIG_S3C24XX_NAND_BOOT=y +CONFIG_S3C_SDRAM_INIT=y +CONFIG_S3C_NAND_BOOT=y CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y CONFIG_BROKEN=y CONFIG_EXPERIMENTAL=y diff --git a/arch/arm/configs/mini2440_defconfig b/arch/arm/configs/mini2440_defconfig index 9b35dd5..efe76e4 100644 --- a/arch/arm/configs/mini2440_defconfig +++ b/arch/arm/configs/mini2440_defconfig @@ -1,7 +1,7 @@ CONFIG_ARCH_S3C24xx=y CONFIG_MACH_MINI2440=y CONFIG_MINI2440_VIDEO_N35=y -CONFIG_S3C24XX_NAND_BOOT=y +CONFIG_S3C_NAND_BOOT=y CONFIG_AEABI=y CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y CONFIG_TEXT_BASE=0x33e00000 diff --git a/arch/arm/mach-samsung/Kconfig b/arch/arm/mach-samsung/Kconfig index bc283dc..63c29ef 100644 --- a/arch/arm/mach-samsung/Kconfig +++ b/arch/arm/mach-samsung/Kconfig @@ -30,8 +30,8 @@ config MACH_A9M2410 bool "Digi A9M2410" select CPU_S3C2410 select MACH_HAS_LOWLEVEL_INIT - select S3C24XX_PLL_INIT - select S3C24XX_SDRAM_INIT + select S3C_PLL_INIT + select S3C_SDRAM_INIT help Say Y here if you are using Digi's Connect Core 9M equipped with a Samsung S3C2410 Processor @@ -40,7 +40,7 @@ config MACH_A9M2440 bool "Digi A9M2440" select CPU_S3C2440 select MACH_HAS_LOWLEVEL_INIT - select S3C24XX_PLL_INIT + select S3C_PLL_INIT help Say Y here if you are using Digi's Connect Core 9M equipped with a Samsung S3C2440 Processor @@ -50,8 +50,8 @@ config MACH_MINI2440 select CPU_S3C2440 select MACH_HAS_LOWLEVEL_INIT select MACH_DO_LOWLEVEL_INIT - select S3C24XX_PLL_INIT - select S3C24XX_SDRAM_INIT + select S3C_PLL_INIT + select S3C_SDRAM_INIT select HAS_DM9000 help Say Y here if you are using Mini 2440 dev board equipped @@ -78,29 +78,31 @@ source arch/arm/boards/mini2440/Kconfig endmenu -menu "S3C24X0 Features " +endif + +menu "S3C Features " -config S3C24XX_LOW_LEVEL_INIT +config S3C_LOWLEVEL_INIT bool -config S3C24XX_PLL_INIT +config S3C_PLL_INIT bool prompt "Reconfigure PLL" - select S3C24XX_LOW_LEVEL_INIT + select S3C_LOWLEVEL_INIT help This adds generic code to reconfigure the internal PLL very early after reset. -config S3C24XX_SDRAM_INIT +config S3C_SDRAM_INIT bool prompt "Initialize SDRAM" - select S3C24XX_LOW_LEVEL_INIT + select S3C_LOWLEVEL_INIT help This adds generic code to configure the SDRAM controller after reset. The initialisation will be skipped if the code is already running from SDRAM. -config S3C24XX_NAND_BOOT +config S3C_NAND_BOOT bool prompt "Booting from NAND" select MTD @@ -113,5 +115,3 @@ config S3C24XX_NAND_BOOT endmenu endif - -endif diff --git a/arch/arm/mach-samsung/Makefile b/arch/arm/mach-samsung/Makefile index 2ba5c3f..349ba9b 100644 --- a/arch/arm/mach-samsung/Makefile +++ b/arch/arm/mach-samsung/Makefile @@ -1,3 +1,3 @@ obj-y += s3c-timer.o generic.o obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o s3c24xx-clocks.o -obj-$(CONFIG_S3C24XX_LOW_LEVEL_INIT) += lowlevel-init.o +obj-$(CONFIG_S3C_LOWLEVEL_INIT) += lowlevel-init.o diff --git a/arch/arm/mach-samsung/include/mach/s3c-iomap.h b/arch/arm/mach-samsung/include/mach/s3c-iomap.h index 9e867f8..60d44e3 100644 --- a/arch/arm/mach-samsung/include/mach/s3c-iomap.h +++ b/arch/arm/mach-samsung/include/mach/s3c-iomap.h @@ -54,7 +54,7 @@ * if we are booting from NAND, its internal SRAM occures at * a different address than without this feature */ -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT # define NFC_RAM_AREA 0x00000000 #else # define NFC_RAM_AREA 0x40000000 diff --git a/arch/arm/mach-samsung/include/mach/s3c24xx-nand.h b/arch/arm/mach-samsung/include/mach/s3c24xx-nand.h index 7610b4e..acd78b8 100644 --- a/arch/arm/mach-samsung/include/mach/s3c24xx-nand.h +++ b/arch/arm/mach-samsung/include/mach/s3c24xx-nand.h @@ -18,7 +18,7 @@ * */ -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT extern void s3c24x0_nand_load_image(void*, int, int); #endif diff --git a/arch/arm/mach-samsung/lowlevel-init.S b/arch/arm/mach-samsung/lowlevel-init.S index 31c6196..e9471a5 100644 --- a/arch/arm/mach-samsung/lowlevel-init.S +++ b/arch/arm/mach-samsung/lowlevel-init.S @@ -70,7 +70,7 @@ routine very early in your board_init_lowlevel routine. * Note: Do not use "r10" here in this code */ -#ifdef CONFIG_S3C24XX_PLL_INIT +#ifdef CONFIG_S3C_PLL_INIT .section ".text_bare_init.s3c24x0_pll_init","ax" @@ -146,7 +146,7 @@ shared with all other system on chip components. Most of the time this configuration is to slow for the CPU and to fast for the other components. PLL reprogramming can be done in the machine specific manner very early when -the CONFIG_S3C24XX_PLL_INIT and CONFIG_MACH_HAS_LOWLEVEL_INIT symbols are +the CONFIG_S3C_PLL_INIT and CONFIG_MACH_HAS_LOWLEVEL_INIT symbols are defined. The board must provide a board_init_lowlevel() assembler function in this case and calling the s3c24x0_pll_init() assembler function. @@ -184,7 +184,7 @@ With m = MDIV + 8, p = PDIV + 2 and s = SDIV. /* ----------------------------------------------------------------------- */ -#ifdef CONFIG_S3C24XX_SDRAM_INIT +#ifdef CONFIG_S3C_SDRAM_INIT .section ".text_bare_init.s3c24x0_sdram_init","ax" @@ -225,7 +225,7 @@ SDRAMDATA: The SDRAM controller is very simple and its initialisation requires only a few steps. barebox provides a generic routine to do this step. -Enable CONFIG_S3C24XX_SDRAM_INIT and CONFIG_MACH_HAS_LOWLEVEL_INIT to be able +Enable CONFIG_S3C_SDRAM_INIT and CONFIG_MACH_HAS_LOWLEVEL_INIT to be able to call the generic s3c24x0_sdram_init() assembler function from within the machine specific board_init_lowlevel() assembler function. @@ -245,7 +245,7 @@ Define in the machine specific config.h the following list of symbols: /* ----------------------------------------------------------------------- */ -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT .section ".text_bare_init.s3c24x0_nand_boot","ax" @@ -284,7 +284,7 @@ s3c24x0_nand_boot: @page dev_s3c24xx_nandboot_handling Booting from NAND To be able to boot from NAND memory only, enable the S3C24x0 NAND driver. Also -enable CONFIG_S3C24XX_NAND_BOOT and CONFIG_MACH_HAS_LOWLEVEL_INIT to be +enable CONFIG_S3C_NAND_BOOT and CONFIG_MACH_HAS_LOWLEVEL_INIT to be able to call the s3c24x0_nand_boot() assembler routine from within the machine specific board_init_lowlevel() assembler function. diff --git a/drivers/mtd/nand/nand_s3c24xx.c b/drivers/mtd/nand/nand_s3c24xx.c index dbf2e14..c629701 100644 --- a/drivers/mtd/nand/nand_s3c24xx.c +++ b/drivers/mtd/nand/nand_s3c24xx.c @@ -36,7 +36,7 @@ #include <io.h> #include <asm-generic/errno.h> -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT # define __nand_boot_init __bare_init # ifndef BOARD_DEFAULT_NAND_TIMING # define BOARD_DEFAULT_NAND_TIMING 0x0737 @@ -49,7 +49,7 @@ * Define this symbol for testing purpose. It will add a command to read an * image from the NAND like it the boot strap code will do. */ -#define CONFIG_NAND_S3C24XX_BOOT_DEBUG +#define CONFIG_NAND_S3C_BOOT_DEBUG /* NAND controller's register */ @@ -497,7 +497,7 @@ static struct driver_d s3c24x0_nand_driver = { .probe = s3c24x0_nand_probe, }; -#ifdef CONFIG_S3C24XX_NAND_BOOT +#ifdef CONFIG_S3C_NAND_BOOT static void __nand_boot_init wait_for_completion(void __iomem *host) { @@ -603,7 +603,7 @@ void __nand_boot_init s3c24x0_nand_load_image(void *dest, int size, int page) disable_nand_controller(host); } -#ifdef CONFIG_NAND_S3C24XX_BOOT_DEBUG +#ifdef CONFIG_NAND_S3C_BOOT_DEBUG #include <command.h> static int do_nand_boot_test(int argc, char *argv[]) @@ -636,7 +636,7 @@ BAREBOX_CMD_START(nand_boot_test) BAREBOX_CMD_END #endif -#endif /* CONFIG_S3C24XX_NAND_BOOT */ +#endif /* CONFIG_S3C_NAND_BOOT */ /* * Main initialization routine -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCHv4 2/7] Split S3C generic and S3C24xx specific code 2012-05-18 9:43 ` [PATCHv4 0/7] S5PV210 support (upd.) Alexey Galakhov 2012-05-18 9:43 ` [PATCH 1/7] Make S3C24xx config options available for all S3Cs Alexey Galakhov @ 2012-05-18 9:43 ` Alexey Galakhov 2012-05-18 9:43 ` [PATCH 3/7] Add support for Samsung S5P architecture (S5PV210) Alexey Galakhov ` (5 subsequent siblings) 7 siblings, 0 replies; 29+ messages in thread From: Alexey Galakhov @ 2012-05-18 9:43 UTC (permalink / raw) To: barebox; +Cc: Alexey Galakhov Signed-off-by: Alexey Galakhov <agalakhov@gmail.com> --- arch/arm/mach-samsung/Makefile | 5 +- arch/arm/mach-samsung/generic.c | 113 ------- arch/arm/mach-samsung/include/mach/s3c-clocks.h | 22 +- arch/arm/mach-samsung/include/mach/s3c-generic.h | 3 +- arch/arm/mach-samsung/include/mach/s3c-iomap.h | 53 +--- .../arm/mach-samsung/include/mach/s3c24xx-clocks.h | 24 ++ arch/arm/mach-samsung/include/mach/s3c24xx-gpio.h | 6 +- arch/arm/mach-samsung/include/mach/s3c24xx-iomap.h | 69 +++++ arch/arm/mach-samsung/lowlevel-init.S | 317 -------------------- arch/arm/mach-samsung/lowlevel-s3c24x0.S | 317 ++++++++++++++++++++ arch/arm/mach-samsung/mem-s3c24x0.c | 143 +++++++++ 11 files changed, 575 insertions(+), 497 deletions(-) create mode 100644 arch/arm/mach-samsung/include/mach/s3c24xx-clocks.h create mode 100644 arch/arm/mach-samsung/include/mach/s3c24xx-iomap.h delete mode 100644 arch/arm/mach-samsung/lowlevel-init.S create mode 100644 arch/arm/mach-samsung/lowlevel-s3c24x0.S create mode 100644 arch/arm/mach-samsung/mem-s3c24x0.c diff --git a/arch/arm/mach-samsung/Makefile b/arch/arm/mach-samsung/Makefile index 349ba9b..bde707f 100644 --- a/arch/arm/mach-samsung/Makefile +++ b/arch/arm/mach-samsung/Makefile @@ -1,3 +1,4 @@ obj-y += s3c-timer.o generic.o -obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o s3c24xx-clocks.o -obj-$(CONFIG_S3C_LOWLEVEL_INIT) += lowlevel-init.o +obj-lowlevel-$(CONFIG_ARCH_S3C24xx) += lowlevel-s3c24x0.o +obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o s3c24xx-clocks.o mem-s3c24x0.o +obj-$(CONFIG_S3C_LOWLEVEL_INIT) += $(obj-lowlevel-y) diff --git a/arch/arm/mach-samsung/generic.c b/arch/arm/mach-samsung/generic.c index 7706be2..7095294 100644 --- a/arch/arm/mach-samsung/generic.c +++ b/arch/arm/mach-samsung/generic.c @@ -25,65 +25,9 @@ #include <config.h> #include <common.h> #include <init.h> -#include <clock.h> #include <io.h> -#include <sizes.h> #include <mach/s3c-iomap.h> #include <mach/s3c-generic.h> -#include <mach/s3c-busctl.h> -#include <mach/s3c24xx-gpio.h> - -/** - * Calculate the amount of connected and available memory - * @return Memory size in bytes - */ -uint32_t s3c24xx_get_memory_size(void) -{ - uint32_t reg, size; - - /* - * detect the current memory size - */ - reg = readl(S3C_BANKSIZE); - - switch (reg & 0x7) { - case 0: - size = SZ_32M; - break; - case 1: - size = SZ_64M; - break; - case 2: - size = SZ_128M; - break; - case 4: - size = SZ_2M; - break; - case 5: - size = SZ_4M; - break; - case 6: - size = SZ_8M; - break; - default: - size = SZ_16M; - break; - } - - /* - * Is bank7 also configured for SDRAM usage? - */ - if ((readl(S3C_BANKCON7) & (0x3 << 15)) == (0x3 << 15)) - size <<= 1; /* also count this bank */ - - return size; -} - -void s3c24xx_disable_second_sdram_bank(void) -{ - writel(readl(S3C_BANKCON7) & ~(0x3 << 15), S3C_BANKCON7); - writel(readl(S3C_MISCCR) | (1 << 18), S3C_MISCCR); /* disable its clock */ -} #define S3C_WTCON (S3C_WATCHDOG_BASE) #define S3C_WTDAT (S3C_WATCHDOG_BASE + 0x04) @@ -105,60 +49,3 @@ void __noreturn reset_cpu(unsigned long addr) ; } EXPORT_SYMBOL(reset_cpu); - -/** - -@page dev_s3c24xx_arch Samsung's S3C24xx Platforms in barebox - -@section s3c24xx_boards Boards using S3C24xx Processors - -@li @subpage arch/arm/boards/a9m2410/a9m2410.c -@li @subpage arch/arm/boards/a9m2440/a9m2440.c - -@section s3c24xx_arch Documentation for S3C24xx Architectures Files - -@li @subpage arch/arm/mach-s3c24xx/generic.c - -@section s3c24xx_mem_map SDRAM Memory Map - -SDRAM starts at address 0x3000.0000 up to the available amount of connected -SDRAM memory. Physically this CPU can handle up to 256MiB (two areas with -up to 128MiB each). - -@subsection s3c24xx_mem_generic_map Generic Map -- 0x0000.0000 Start of the internal SRAM when booting from NAND flash memory or CS signal to a NOR flash memory. -- 0x0800.0000 Start of I/O space. -- 0x3000.0000 Start of SDRAM area. - - 0x3000.0100 Start of the TAG list area. - - 0x3000.8000 Start of the linux kernel (physical address). -- 0x4000.0000 Start of internal SRAM, when booting from NOR flash memory -- 0x4800.0000 Start of the internal I/O area - -@section s3c24xx_asm_arm include/asm-arm/arch-s3c24xx directory guidelines -All S3C24xx common headers are located here. - -@note Do not add board specific header files/information here. -*/ - -/** @page dev_s3c24xx_mach Samsung's S3C24xx based platforms - -@par barebox Map - -The location of the @a barebox itself depends on the available amount of -installed SDRAM memory: - -- 0x30fc.0000 Start of @a barebox when 16MiB SDRAM is available -- 0x31fc.0000 Start of @a barebox when 32MiB SDRAM is available -- 0x33fc.0000 Start of @a barebox when 64MiB SDRAM is available - -Adjust the @p CONFIG_TEXT_BASE/CONFIG_ARCH_TEXT_BASE symbol in accordance to -the available memory. - -@note The RAM based filesystem and the stack resides always below the -@a barebox start address. - -@li @subpage dev_s3c24xx_wd_handling -@li @subpage dev_s3c24xx_pll_handling -@li @subpage dev_s3c24xx_sdram_handling -@li @subpage dev_s3c24xx_nandboot_handling -*/ diff --git a/arch/arm/mach-samsung/include/mach/s3c-clocks.h b/arch/arm/mach-samsung/include/mach/s3c-clocks.h index 44b2a6c..b8894f8 100644 --- a/arch/arm/mach-samsung/include/mach/s3c-clocks.h +++ b/arch/arm/mach-samsung/include/mach/s3c-clocks.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2011 Juergen Beisert, Pengutronix + * See file CREDITS for list of people who contributed to this + * project. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -10,22 +11,19 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * */ #ifndef __MACH_S3C_CLOCKS_H -# define __MACH_S3C_CLOCKS_H +#define __MACH_S3C_CLOCKS_H #ifdef CONFIG_ARCH_S3C24xx -# define S3C_LOCKTIME (S3C_CLOCK_POWER_BASE) -# define S3C_MPLLCON (S3C_CLOCK_POWER_BASE + 0x4) -# define S3C_UPLLCON (S3C_CLOCK_POWER_BASE + 0x8) -# define S3C_CLKCON (S3C_CLOCK_POWER_BASE + 0xc) -# define S3C_CLKSLOW (S3C_CLOCK_POWER_BASE + 0x10) -# define S3C_CLKDIVN (S3C_CLOCK_POWER_BASE + 0x14) - -# define S3C_MPLLCON_GET_MDIV(x) ((((x) >> 12) & 0xff) + 8) -# define S3C_MPLLCON_GET_PDIV(x) ((((x) >> 4) & 0x3f) + 2) -# define S3C_MPLLCON_GET_SDIV(x) ((x) & 0x3) +# include <mach/s3c24xx-clocks.h> #endif #endif /* __MACH_S3C_CLOCKS_H */ diff --git a/arch/arm/mach-samsung/include/mach/s3c-generic.h b/arch/arm/mach-samsung/include/mach/s3c-generic.h index 5d3808e..9d40ef8 100644 --- a/arch/arm/mach-samsung/include/mach/s3c-generic.h +++ b/arch/arm/mach-samsung/include/mach/s3c-generic.h @@ -33,6 +33,7 @@ uint32_t s3c_get_uclk(void); unsigned s3c_get_uart_clk(unsigned src); +#ifdef CONFIG_ARCH_S3C24xx uint32_t s3c24xx_get_memory_size(void); - void s3c24xx_disable_second_sdram_bank(void); +#endif diff --git a/arch/arm/mach-samsung/include/mach/s3c-iomap.h b/arch/arm/mach-samsung/include/mach/s3c-iomap.h index 60d44e3..87919cc 100644 --- a/arch/arm/mach-samsung/include/mach/s3c-iomap.h +++ b/arch/arm/mach-samsung/include/mach/s3c-iomap.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2009 Juergen Beisert, Pengutronix + * See file CREDITS for list of people who contributed to this + * project. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -18,52 +19,6 @@ * */ -/* S3C2410 device base addresses */ -#define S3C_MEMCTL_BASE 0x48000000 -#define S3C2410_USB_HOST_BASE 0x49000000 -#define S3C2410_INTERRUPT_BASE 0x4A000000 -#define S3C2410_DMA_BASE 0x4B000000 -#define S3C_CLOCK_POWER_BASE 0x4C000000 -#define S3C2410_LCD_BASE 0x4D000000 -#define S3C24X0_NAND_BASE 0x4E000000 -#define S3C_UART_BASE 0x50000000 -#define S3C_TIMER_BASE 0x51000000 -#define S3C2410_USB_DEVICE_BASE 0x52000140 -#define S3C_WATCHDOG_BASE 0x53000000 -#define S3C2410_I2C_BASE 0x54000000 -#define S3C2410_I2S_BASE 0x55000000 -#define S3C_GPIO_BASE 0x56000000 -#define S3C2410_RTC_BASE 0x57000000 -#define S3C2410_ADC_BASE 0x58000000 -#define S3C2410_SPI_BASE 0x59000000 -#define S3C2410_SDI_BASE 0x5A000000 - -/* external IO space */ -#define S3C_CS0_BASE 0x00000000 -#define S3C_CS1_BASE 0x08000000 -#define S3C_CS2_BASE 0x10000000 -#define S3C_CS3_BASE 0x18000000 -#define S3C_CS4_BASE 0x20000000 -#define S3C_CS5_BASE 0x28000000 -#define S3C_CS6_BASE 0x30000000 - -#define S3C_SDRAM_BASE S3C_CS6_BASE -#define S3C_SDRAM_END (S3C_SDRAM_BASE + 0x10000000) - -/* - * if we are booting from NAND, its internal SRAM occures at - * a different address than without this feature - */ -#ifdef CONFIG_S3C_NAND_BOOT -# define NFC_RAM_AREA 0x00000000 -#else -# define NFC_RAM_AREA 0x40000000 +#ifdef CONFIG_ARCH_S3C24xx +# include <mach/s3c24xx-iomap.h> #endif -#define NFC_RAM_SIZE 4096 - -#define S3C_UART1_BASE (S3C_UART_BASE) -#define S3C_UART1_SIZE 0x4000 -#define S3C_UART2_BASE (S3C_UART_BASE + 0x4000) -#define S3C_UART2_SIZE 0x4000 -#define S3C_UART3_BASE (S3C_UART_BASE + 0x8000) -#define S3C_UART3_SIZE 0x4000 diff --git a/arch/arm/mach-samsung/include/mach/s3c24xx-clocks.h b/arch/arm/mach-samsung/include/mach/s3c24xx-clocks.h new file mode 100644 index 0000000..839dfe3 --- /dev/null +++ b/arch/arm/mach-samsung/include/mach/s3c24xx-clocks.h @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2011 Juergen Beisert, Pengutronix + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +# define S3C_LOCKTIME (S3C_CLOCK_POWER_BASE) +# define S3C_MPLLCON (S3C_CLOCK_POWER_BASE + 0x4) +# define S3C_UPLLCON (S3C_CLOCK_POWER_BASE + 0x8) +# define S3C_CLKCON (S3C_CLOCK_POWER_BASE + 0xc) +# define S3C_CLKSLOW (S3C_CLOCK_POWER_BASE + 0x10) +# define S3C_CLKDIVN (S3C_CLOCK_POWER_BASE + 0x14) + +# define S3C_MPLLCON_GET_MDIV(x) ((((x) >> 12) & 0xff) + 8) +# define S3C_MPLLCON_GET_PDIV(x) ((((x) >> 4) & 0x3f) + 2) +# define S3C_MPLLCON_GET_SDIV(x) ((x) & 0x3) diff --git a/arch/arm/mach-samsung/include/mach/s3c24xx-gpio.h b/arch/arm/mach-samsung/include/mach/s3c24xx-gpio.h index c835974..ffb57fb 100644 --- a/arch/arm/mach-samsung/include/mach/s3c24xx-gpio.h +++ b/arch/arm/mach-samsung/include/mach/s3c24xx-gpio.h @@ -12,8 +12,8 @@ * GNU General Public License for more details. */ -#ifndef __MACH_S3C24XX_GPIO_H -# define __MACH_S3C24XX_GPIO_H +#ifndef __MACH_GPIO_S3C24X0_H +# define __MACH_GPIO_S3C24X0_H #define S3C_GPACON (S3C_GPIO_BASE) #define S3C_GPADAT (S3C_GPIO_BASE + 0x04) @@ -74,4 +74,4 @@ # define S3C_DSC1 (S3C_GPIO_BASE + 0xc8) #endif -#endif /* __MACH_S3C24XX_GPIO_H */ +#endif /* __MACH_GPIO_S3C24X0_H */ diff --git a/arch/arm/mach-samsung/include/mach/s3c24xx-iomap.h b/arch/arm/mach-samsung/include/mach/s3c24xx-iomap.h new file mode 100644 index 0000000..60d44e3 --- /dev/null +++ b/arch/arm/mach-samsung/include/mach/s3c24xx-iomap.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2009 Juergen Beisert, Pengutronix + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + */ + +/* S3C2410 device base addresses */ +#define S3C_MEMCTL_BASE 0x48000000 +#define S3C2410_USB_HOST_BASE 0x49000000 +#define S3C2410_INTERRUPT_BASE 0x4A000000 +#define S3C2410_DMA_BASE 0x4B000000 +#define S3C_CLOCK_POWER_BASE 0x4C000000 +#define S3C2410_LCD_BASE 0x4D000000 +#define S3C24X0_NAND_BASE 0x4E000000 +#define S3C_UART_BASE 0x50000000 +#define S3C_TIMER_BASE 0x51000000 +#define S3C2410_USB_DEVICE_BASE 0x52000140 +#define S3C_WATCHDOG_BASE 0x53000000 +#define S3C2410_I2C_BASE 0x54000000 +#define S3C2410_I2S_BASE 0x55000000 +#define S3C_GPIO_BASE 0x56000000 +#define S3C2410_RTC_BASE 0x57000000 +#define S3C2410_ADC_BASE 0x58000000 +#define S3C2410_SPI_BASE 0x59000000 +#define S3C2410_SDI_BASE 0x5A000000 + +/* external IO space */ +#define S3C_CS0_BASE 0x00000000 +#define S3C_CS1_BASE 0x08000000 +#define S3C_CS2_BASE 0x10000000 +#define S3C_CS3_BASE 0x18000000 +#define S3C_CS4_BASE 0x20000000 +#define S3C_CS5_BASE 0x28000000 +#define S3C_CS6_BASE 0x30000000 + +#define S3C_SDRAM_BASE S3C_CS6_BASE +#define S3C_SDRAM_END (S3C_SDRAM_BASE + 0x10000000) + +/* + * if we are booting from NAND, its internal SRAM occures at + * a different address than without this feature + */ +#ifdef CONFIG_S3C_NAND_BOOT +# define NFC_RAM_AREA 0x00000000 +#else +# define NFC_RAM_AREA 0x40000000 +#endif +#define NFC_RAM_SIZE 4096 + +#define S3C_UART1_BASE (S3C_UART_BASE) +#define S3C_UART1_SIZE 0x4000 +#define S3C_UART2_BASE (S3C_UART_BASE + 0x4000) +#define S3C_UART2_SIZE 0x4000 +#define S3C_UART3_BASE (S3C_UART_BASE + 0x8000) +#define S3C_UART3_SIZE 0x4000 diff --git a/arch/arm/mach-samsung/lowlevel-init.S b/arch/arm/mach-samsung/lowlevel-init.S deleted file mode 100644 index e9471a5..0000000 --- a/arch/arm/mach-samsung/lowlevel-init.S +++ /dev/null @@ -1,317 +0,0 @@ -/* - * (C) Copyright 2009 - * Juergen Beisert <kernel@pengutronix.de> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - */ - -#include <config.h> -#include <mach/s3c-iomap.h> - - .section ".text_bare_init.s3c24x0_disable_wd","ax" - -/* - * Disable the watchdog, else it continues to bark - */ -.globl s3c24x0_disable_wd -s3c24x0_disable_wd: - - ldr r0, =S3C_WATCHDOG_BASE - mov r1, #0x0 - str r1, [r0] - mov pc, lr - -/** -@page dev_s3c24xx_wd_handling Watchdog handling - -The watchdog must be disabled very early, because if it resets the system -it is still active and will continue to reset the system. So, call this -routine very early in your board_init_lowlevel routine. -*/ - -/* - * S3C2410 PLL configuration - * ------------------------- - * - * Basic frequency calculation - * - * m * REFclk s = SDIV - * PLLclk = ------------ p = PDIV + 2 - * p * 2^s m = MDIV + 8 - * - * After reset the PLL of the s3c2410 processor uses: - * - * MPLL UPLL - * MDIV 0x5c 0x28 - * PDIV 0x08 0x08 - * SDIV 0x0 0x0 - * - * 100 * 12MHz 1200MHz - * MPLLclk = ------------- = -------- = 120MHz - * 10 * 2^0 10 - * - * 48 * 12MHz 576MHz - * UPLLclk = ------------- = -------- = 57,6MHz - * 10 * 2^0 10 - * - * Note: Do not use "r10" here in this code - */ - -#ifdef CONFIG_S3C_PLL_INIT - - .section ".text_bare_init.s3c24x0_pll_init","ax" - -.globl s3c24x0_pll_init -s3c24x0_pll_init: - - mov r0, #S3C_CLOCK_POWER_BASE - - /* configure internal clock ratio */ - mov r1, #BOARD_SPECIFIC_CLKDIVN - str r1, [r0, #20] - - /* enable all devices on this chip */ - mov r1, #0xFFFFFFF0 - str r1, [r0, #12] - - /* ??????? */ -#ifdef CONFIG_CPU_S3C2440 - mov r1, #0xFFFFFFFF -#endif -#ifdef CONFIG_CPU_S3C2410 - mov r1, #0x00FFFFFF -#endif - str r1, [r0, #0] - -#ifdef CONFIG_CPU_S3C2440 - /* - * Most of the time HDIVN is not 0, so we must use the - * asynchronous bus mode (refer datasheet "Clock and Power Management") - */ - mrc p15, 0, r1, c1, c0, 0 - orr r1, r1, #0xc0000000 - mcr p15, 0, r1, c1, c0, 0 -#endif - - /* configure UPLL */ - ldr r1, =BOARD_SPECIFIC_UPLL - str r1, [r0, #8] - - nop - nop - nop - nop - nop - nop - nop - nop - - /* configure MPLL */ - ldr r1, =BOARD_SPECIFIC_MPLL - str r1, [r0, #4] - - nop - nop - nop - nop - nop - nop - nop - nop - - mov pc, lr - -#endif - -/** -@page dev_s3c24xx_pll_handling PLL clock handling - -To control the speed of your machine the PLLs must be reconfigured after reset. - -For example the S3C2410 CPU wakes up after reset at 120MHz main PLL speed, -shared with all other system on chip components. Most of the time this -configuration is to slow for the CPU and to fast for the other components. - -PLL reprogramming can be done in the machine specific manner very early when -the CONFIG_S3C_PLL_INIT and CONFIG_MACH_HAS_LOWLEVEL_INIT symbols are -defined. The board must provide a board_init_lowlevel() assembler function in -this case and calling the s3c24x0_pll_init() assembler function. - -If the s3c24x0_pll_init() is called a few further symbols must be defined to -setup the correct values for the machine. - -Define in the machine specific config.h the following symbols: - -- S3C24XX_CLOCK_REFERENCE with the frequency in Hz of your reference crystal. -- BOARD_SPECIFIC_CLKDIVN with the value for the main clock ratio register (CLKDIVN) -- BOARD_SPECIFIC_MPLL with the value for the main PLL setup register -- BOARD_SPECIFIC_UPLL with the value for the USB PLL setup register - -@note Valid values for the PLL settings can be found in the CPU manual. - -@par Background: PLL frequency calculation for the S3C2410 CPU (both PLLs) and S3C2440 (UPLL only) - -@f[ - f_{PLL} = \frac{m * f_{Ref}}{p * 2^s} -@f] - -With m = MDIV + 8, p = PDIV + 2 and s = SDIV. - -@par Background: PLL frequency calculation for the S3C2440 CPU (MPLL only) - -@f[ - f_{PLL} = \frac{2 * m * f_{Ref}}{p * 2^s} -@f] - -With m = MDIV + 8, p = PDIV + 2 and s = SDIV. - -@note This routine can be used for the S3C2410 and the S3C2440 CPU. - -*/ - -/* ----------------------------------------------------------------------- */ - -#ifdef CONFIG_S3C_SDRAM_INIT - - .section ".text_bare_init.s3c24x0_sdram_init","ax" - - .globl s3c24x0_sdram_init -s3c24x0_sdram_init: - - adr r0, SDRAMDATA /* get the current relative address of the table */ - mov r1, #S3C_MEMCTL_BASE - mov r2, #6 /* we *know* it contains 6 entries */ - - ldr r3, [r0], #4 /* write BSWCON first */ - str r3, [r1], #0x1c /* post add register offset for bank6 */ -/* - * Initializing the SDRAM controller is very simple: - * Just write some useful values into the SDRAM controller. - */ -0: ldr r3, [r0], #4 - str r3, [r1], #4 - subs r2, r2, #1 - bne 0b - - mov pc, lr - -SDRAMDATA: - .word BOARD_SPECIFIC_BWSCON - .word BOARD_SPECIFIC_BANKCON6 - .word BOARD_SPECIFIC_BANKCON7 - .word BOARD_SPECIFIC_REFRESH - .word BOARD_SPECIFIC_BANKSIZE - .word BOARD_SPECIFIC_MRSRB6 - .word BOARD_SPECIFIC_MRSRB7 - -#endif - -/** -@page dev_s3c24xx_sdram_handling SDRAM controller initialisation - -The SDRAM controller is very simple and its initialisation requires only a -few steps. barebox provides a generic routine to do this step. - -Enable CONFIG_S3C_SDRAM_INIT and CONFIG_MACH_HAS_LOWLEVEL_INIT to be able -to call the generic s3c24x0_sdram_init() assembler function from within the -machine specific board_init_lowlevel() assembler function. - -To use the s3c24x0_sdram_init() assembler function a few symbols must be -defined to setup correct values for the machine. - -Define in the machine specific config.h the following list of symbols: - -- BOARD_SPECIFIC_BWSCON with the values for SDRAM banks 6 and 7 -- BOARD_SPECIFIC_BANKCON6 with the value for the BANKCON6 register -- BOARD_SPECIFIC_BANKCON7 with the value for the BANKCON7 register -- BOARD_SPECIFIC_REFRESH with the value for the REFRESH register -- BOARD_SPECIFIC_BANKSIZE with the value for the BANKSIZE register -- BOARD_SPECIFIC_MRSRB6 with the value for the MRSRB6 register -- BOARD_SPECIFIC_MRSRB7 with the value for the MRSRB7 register -*/ - -/* ----------------------------------------------------------------------- */ - -#ifdef CONFIG_S3C_NAND_BOOT - - .section ".text_bare_init.s3c24x0_nand_boot","ax" - - .globl s3c24x0_nand_boot -s3c24x0_nand_boot: -/* - * In the case of NOR boot we are running from the same address space. - * Detect this case to handle it correctly. - */ - mov r1, #S3C_MEMCTL_BASE - ldr r3, [r1] - and r3, r3, #0x6 - cmp r3, #0x0 /* check for NAND case */ - beq 2f - mov pc, lr /* NOR case: nothing to do here */ - -2: ldr sp, =TEXT_BASE /* Setup a temporary stack in SDRAM */ -/* - * We still run at a location we are not linked to. But lets still running - * from the internal SRAM, this may speed up the boot - */ - push {lr} - bl nand_boot - pop {lr} -/* - * Adjust the return address to the correct address in SDRAM - */ - ldr r1, =TEXT_BASE - add lr, lr, r1 - - mov pc, lr - -#endif - -/** -@page dev_s3c24xx_nandboot_handling Booting from NAND - -To be able to boot from NAND memory only, enable the S3C24x0 NAND driver. Also -enable CONFIG_S3C_NAND_BOOT and CONFIG_MACH_HAS_LOWLEVEL_INIT to be -able to call the s3c24x0_nand_boot() assembler routine from within the -machine specific board_init_lowlevel() assembler function. - -@note This routine assumes an already working SDRAM controller and -an initialized stack pointer. - -@note Basicly this routine runs from inside the internal SRAM. After load of -the whole barebox image from the NAND flash memory into the SDRAM it adjusts -the link register to the final SDRAM adress and returns. - -@note In the NAND boot mode, ECC is not checked. So, the first x KBytes used -by barebox should have no bit error. - -Due to the fact the code to load the whole barebox from NAND must fit into -the first 4kiB of the barebox image, the shrinked NAND driver is very -minimalistic. Setup the NAND access timing is done in a safe manner, what -means: Slowest possible values are used. If you want to increase the speed you -should define the BOARD_DEFAULT_NAND_TIMING to a valid setting into the -NFCONF register and add it to your board specific config.h. Refer S3C24x0's -datasheet for further details. The macro #CALC_NFCONF_TIMING could help to -calculate the register setting in a hardware independent manner. - -@note The regular NAND driver uses a platform data structure to define the -NAND access timings. - -@note Its still possible to boot this image from NOR memory. If this routine -detects it is running from NOR instead of the internal SRAM it skips any -loading and returns immediately. - -*/ diff --git a/arch/arm/mach-samsung/lowlevel-s3c24x0.S b/arch/arm/mach-samsung/lowlevel-s3c24x0.S new file mode 100644 index 0000000..e9471a5 --- /dev/null +++ b/arch/arm/mach-samsung/lowlevel-s3c24x0.S @@ -0,0 +1,317 @@ +/* + * (C) Copyright 2009 + * Juergen Beisert <kernel@pengutronix.de> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <config.h> +#include <mach/s3c-iomap.h> + + .section ".text_bare_init.s3c24x0_disable_wd","ax" + +/* + * Disable the watchdog, else it continues to bark + */ +.globl s3c24x0_disable_wd +s3c24x0_disable_wd: + + ldr r0, =S3C_WATCHDOG_BASE + mov r1, #0x0 + str r1, [r0] + mov pc, lr + +/** +@page dev_s3c24xx_wd_handling Watchdog handling + +The watchdog must be disabled very early, because if it resets the system +it is still active and will continue to reset the system. So, call this +routine very early in your board_init_lowlevel routine. +*/ + +/* + * S3C2410 PLL configuration + * ------------------------- + * + * Basic frequency calculation + * + * m * REFclk s = SDIV + * PLLclk = ------------ p = PDIV + 2 + * p * 2^s m = MDIV + 8 + * + * After reset the PLL of the s3c2410 processor uses: + * + * MPLL UPLL + * MDIV 0x5c 0x28 + * PDIV 0x08 0x08 + * SDIV 0x0 0x0 + * + * 100 * 12MHz 1200MHz + * MPLLclk = ------------- = -------- = 120MHz + * 10 * 2^0 10 + * + * 48 * 12MHz 576MHz + * UPLLclk = ------------- = -------- = 57,6MHz + * 10 * 2^0 10 + * + * Note: Do not use "r10" here in this code + */ + +#ifdef CONFIG_S3C_PLL_INIT + + .section ".text_bare_init.s3c24x0_pll_init","ax" + +.globl s3c24x0_pll_init +s3c24x0_pll_init: + + mov r0, #S3C_CLOCK_POWER_BASE + + /* configure internal clock ratio */ + mov r1, #BOARD_SPECIFIC_CLKDIVN + str r1, [r0, #20] + + /* enable all devices on this chip */ + mov r1, #0xFFFFFFF0 + str r1, [r0, #12] + + /* ??????? */ +#ifdef CONFIG_CPU_S3C2440 + mov r1, #0xFFFFFFFF +#endif +#ifdef CONFIG_CPU_S3C2410 + mov r1, #0x00FFFFFF +#endif + str r1, [r0, #0] + +#ifdef CONFIG_CPU_S3C2440 + /* + * Most of the time HDIVN is not 0, so we must use the + * asynchronous bus mode (refer datasheet "Clock and Power Management") + */ + mrc p15, 0, r1, c1, c0, 0 + orr r1, r1, #0xc0000000 + mcr p15, 0, r1, c1, c0, 0 +#endif + + /* configure UPLL */ + ldr r1, =BOARD_SPECIFIC_UPLL + str r1, [r0, #8] + + nop + nop + nop + nop + nop + nop + nop + nop + + /* configure MPLL */ + ldr r1, =BOARD_SPECIFIC_MPLL + str r1, [r0, #4] + + nop + nop + nop + nop + nop + nop + nop + nop + + mov pc, lr + +#endif + +/** +@page dev_s3c24xx_pll_handling PLL clock handling + +To control the speed of your machine the PLLs must be reconfigured after reset. + +For example the S3C2410 CPU wakes up after reset at 120MHz main PLL speed, +shared with all other system on chip components. Most of the time this +configuration is to slow for the CPU and to fast for the other components. + +PLL reprogramming can be done in the machine specific manner very early when +the CONFIG_S3C_PLL_INIT and CONFIG_MACH_HAS_LOWLEVEL_INIT symbols are +defined. The board must provide a board_init_lowlevel() assembler function in +this case and calling the s3c24x0_pll_init() assembler function. + +If the s3c24x0_pll_init() is called a few further symbols must be defined to +setup the correct values for the machine. + +Define in the machine specific config.h the following symbols: + +- S3C24XX_CLOCK_REFERENCE with the frequency in Hz of your reference crystal. +- BOARD_SPECIFIC_CLKDIVN with the value for the main clock ratio register (CLKDIVN) +- BOARD_SPECIFIC_MPLL with the value for the main PLL setup register +- BOARD_SPECIFIC_UPLL with the value for the USB PLL setup register + +@note Valid values for the PLL settings can be found in the CPU manual. + +@par Background: PLL frequency calculation for the S3C2410 CPU (both PLLs) and S3C2440 (UPLL only) + +@f[ + f_{PLL} = \frac{m * f_{Ref}}{p * 2^s} +@f] + +With m = MDIV + 8, p = PDIV + 2 and s = SDIV. + +@par Background: PLL frequency calculation for the S3C2440 CPU (MPLL only) + +@f[ + f_{PLL} = \frac{2 * m * f_{Ref}}{p * 2^s} +@f] + +With m = MDIV + 8, p = PDIV + 2 and s = SDIV. + +@note This routine can be used for the S3C2410 and the S3C2440 CPU. + +*/ + +/* ----------------------------------------------------------------------- */ + +#ifdef CONFIG_S3C_SDRAM_INIT + + .section ".text_bare_init.s3c24x0_sdram_init","ax" + + .globl s3c24x0_sdram_init +s3c24x0_sdram_init: + + adr r0, SDRAMDATA /* get the current relative address of the table */ + mov r1, #S3C_MEMCTL_BASE + mov r2, #6 /* we *know* it contains 6 entries */ + + ldr r3, [r0], #4 /* write BSWCON first */ + str r3, [r1], #0x1c /* post add register offset for bank6 */ +/* + * Initializing the SDRAM controller is very simple: + * Just write some useful values into the SDRAM controller. + */ +0: ldr r3, [r0], #4 + str r3, [r1], #4 + subs r2, r2, #1 + bne 0b + + mov pc, lr + +SDRAMDATA: + .word BOARD_SPECIFIC_BWSCON + .word BOARD_SPECIFIC_BANKCON6 + .word BOARD_SPECIFIC_BANKCON7 + .word BOARD_SPECIFIC_REFRESH + .word BOARD_SPECIFIC_BANKSIZE + .word BOARD_SPECIFIC_MRSRB6 + .word BOARD_SPECIFIC_MRSRB7 + +#endif + +/** +@page dev_s3c24xx_sdram_handling SDRAM controller initialisation + +The SDRAM controller is very simple and its initialisation requires only a +few steps. barebox provides a generic routine to do this step. + +Enable CONFIG_S3C_SDRAM_INIT and CONFIG_MACH_HAS_LOWLEVEL_INIT to be able +to call the generic s3c24x0_sdram_init() assembler function from within the +machine specific board_init_lowlevel() assembler function. + +To use the s3c24x0_sdram_init() assembler function a few symbols must be +defined to setup correct values for the machine. + +Define in the machine specific config.h the following list of symbols: + +- BOARD_SPECIFIC_BWSCON with the values for SDRAM banks 6 and 7 +- BOARD_SPECIFIC_BANKCON6 with the value for the BANKCON6 register +- BOARD_SPECIFIC_BANKCON7 with the value for the BANKCON7 register +- BOARD_SPECIFIC_REFRESH with the value for the REFRESH register +- BOARD_SPECIFIC_BANKSIZE with the value for the BANKSIZE register +- BOARD_SPECIFIC_MRSRB6 with the value for the MRSRB6 register +- BOARD_SPECIFIC_MRSRB7 with the value for the MRSRB7 register +*/ + +/* ----------------------------------------------------------------------- */ + +#ifdef CONFIG_S3C_NAND_BOOT + + .section ".text_bare_init.s3c24x0_nand_boot","ax" + + .globl s3c24x0_nand_boot +s3c24x0_nand_boot: +/* + * In the case of NOR boot we are running from the same address space. + * Detect this case to handle it correctly. + */ + mov r1, #S3C_MEMCTL_BASE + ldr r3, [r1] + and r3, r3, #0x6 + cmp r3, #0x0 /* check for NAND case */ + beq 2f + mov pc, lr /* NOR case: nothing to do here */ + +2: ldr sp, =TEXT_BASE /* Setup a temporary stack in SDRAM */ +/* + * We still run at a location we are not linked to. But lets still running + * from the internal SRAM, this may speed up the boot + */ + push {lr} + bl nand_boot + pop {lr} +/* + * Adjust the return address to the correct address in SDRAM + */ + ldr r1, =TEXT_BASE + add lr, lr, r1 + + mov pc, lr + +#endif + +/** +@page dev_s3c24xx_nandboot_handling Booting from NAND + +To be able to boot from NAND memory only, enable the S3C24x0 NAND driver. Also +enable CONFIG_S3C_NAND_BOOT and CONFIG_MACH_HAS_LOWLEVEL_INIT to be +able to call the s3c24x0_nand_boot() assembler routine from within the +machine specific board_init_lowlevel() assembler function. + +@note This routine assumes an already working SDRAM controller and +an initialized stack pointer. + +@note Basicly this routine runs from inside the internal SRAM. After load of +the whole barebox image from the NAND flash memory into the SDRAM it adjusts +the link register to the final SDRAM adress and returns. + +@note In the NAND boot mode, ECC is not checked. So, the first x KBytes used +by barebox should have no bit error. + +Due to the fact the code to load the whole barebox from NAND must fit into +the first 4kiB of the barebox image, the shrinked NAND driver is very +minimalistic. Setup the NAND access timing is done in a safe manner, what +means: Slowest possible values are used. If you want to increase the speed you +should define the BOARD_DEFAULT_NAND_TIMING to a valid setting into the +NFCONF register and add it to your board specific config.h. Refer S3C24x0's +datasheet for further details. The macro #CALC_NFCONF_TIMING could help to +calculate the register setting in a hardware independent manner. + +@note The regular NAND driver uses a platform data structure to define the +NAND access timings. + +@note Its still possible to boot this image from NOR memory. If this routine +detects it is running from NOR instead of the internal SRAM it skips any +loading and returns immediately. + +*/ diff --git a/arch/arm/mach-samsung/mem-s3c24x0.c b/arch/arm/mach-samsung/mem-s3c24x0.c new file mode 100644 index 0000000..6fae72b --- /dev/null +++ b/arch/arm/mach-samsung/mem-s3c24x0.c @@ -0,0 +1,143 @@ +/* + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ +/** + * @file + * @brief Basic clock, sdram and timer handling for S3C24xx CPUs + */ + +#include <config.h> +#include <common.h> +#include <init.h> +#include <clock.h> +#include <io.h> +#include <sizes.h> +#include <mach/s3c-iomap.h> +#include <mach/s3c-generic.h> +#include <mach/s3c-busctl.h> +#include <mach/s3c24xx-gpio.h> + +/** + * Calculate the amount of connected and available memory + * @return Memory size in bytes + */ +uint32_t s3c24xx_get_memory_size(void) +{ + uint32_t reg, size; + + /* + * detect the current memory size + */ + reg = readl(S3C_BANKSIZE); + + switch (reg & 0x7) { + case 0: + size = SZ_32M; + break; + case 1: + size = SZ_64M; + break; + case 2: + size = SZ_128M; + break; + case 4: + size = SZ_2M; + break; + case 5: + size = SZ_4M; + break; + case 6: + size = SZ_8M; + break; + default: + size = SZ_16M; + break; + } + + /* + * Is bank7 also configured for SDRAM usage? + */ + if ((readl(S3C_BANKCON7) & (0x3 << 15)) == (0x3 << 15)) + size <<= 1; /* also count this bank */ + + return size; +} + +void s3c24xx_disable_second_sdram_bank(void) +{ + writel(readl(S3C_BANKCON7) & ~(0x3 << 15), S3C_BANKCON7); + writel(readl(S3C_MISCCR) | (1 << 18), S3C_MISCCR); /* disable its clock */ +} + +/** + +@page dev_s3c24xx_arch Samsung's S3C24xx Platforms in barebox + +@section s3c24xx_boards Boards using S3C24xx Processors + +@li @subpage arch/arm/boards/a9m2410/a9m2410.c +@li @subpage arch/arm/boards/a9m2440/a9m2440.c + +@section s3c24xx_arch Documentation for S3C24xx Architectures Files + +@li @subpage arch/arm/mach-s3c24xx/generic.c + +@section s3c24xx_mem_map SDRAM Memory Map + +SDRAM starts at address 0x3000.0000 up to the available amount of connected +SDRAM memory. Physically this CPU can handle up to 256MiB (two areas with +up to 128MiB each). + +@subsection s3c24xx_mem_generic_map Generic Map +- 0x0000.0000 Start of the internal SRAM when booting from NAND flash memory or CS signal to a NOR flash memory. +- 0x0800.0000 Start of I/O space. +- 0x3000.0000 Start of SDRAM area. + - 0x3000.0100 Start of the TAG list area. + - 0x3000.8000 Start of the linux kernel (physical address). +- 0x4000.0000 Start of internal SRAM, when booting from NOR flash memory +- 0x4800.0000 Start of the internal I/O area + +@section s3c24xx_asm_arm include/asm-arm/arch-s3c24xx directory guidelines +All S3C24xx common headers are located here. + +@note Do not add board specific header files/information here. +*/ + +/** @page dev_s3c24xx_mach Samsung's S3C24xx based platforms + +@par barebox Map + +The location of the @a barebox itself depends on the available amount of +installed SDRAM memory: + +- 0x30fc.0000 Start of @a barebox when 16MiB SDRAM is available +- 0x31fc.0000 Start of @a barebox when 32MiB SDRAM is available +- 0x33fc.0000 Start of @a barebox when 64MiB SDRAM is available + +Adjust the @p CONFIG_TEXT_BASE/CONFIG_ARCH_TEXT_BASE symbol in accordance to +the available memory. + +@note The RAM based filesystem and the stack resides always below the +@a barebox start address. + +@li @subpage dev_s3c24xx_wd_handling +@li @subpage dev_s3c24xx_pll_handling +@li @subpage dev_s3c24xx_sdram_handling +@li @subpage dev_s3c24xx_nandboot_handling +*/ -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 3/7] Add support for Samsung S5P architecture (S5PV210) 2012-05-18 9:43 ` [PATCHv4 0/7] S5PV210 support (upd.) Alexey Galakhov 2012-05-18 9:43 ` [PATCH 1/7] Make S3C24xx config options available for all S3Cs Alexey Galakhov 2012-05-18 9:43 ` [PATCHv4 2/7] Split S3C generic and S3C24xx specific code Alexey Galakhov @ 2012-05-18 9:43 ` Alexey Galakhov 2012-05-18 9:43 ` [PATCH 4/7] S5P boot header and image generator Alexey Galakhov ` (4 subsequent siblings) 7 siblings, 0 replies; 29+ messages in thread From: Alexey Galakhov @ 2012-05-18 9:43 UTC (permalink / raw) To: barebox; +Cc: Alexey Galakhov Signed-off-by: Alexey Galakhov <agalakhov@gmail.com> --- arch/arm/Kconfig | 6 + arch/arm/mach-samsung/Kconfig | 22 + arch/arm/mach-samsung/Makefile | 1 + arch/arm/mach-samsung/clocks-s5pcxx.c | 98 +++ arch/arm/mach-samsung/gpio-s5pcxx.c | 123 +++ arch/arm/mach-samsung/include/mach/gpio.h | 3 + arch/arm/mach-samsung/include/mach/iomux-s5pcxx.h | 798 ++++++++++++++++++++ arch/arm/mach-samsung/include/mach/s3c-clocks.h | 3 + arch/arm/mach-samsung/include/mach/s3c-iomap.h | 3 + arch/arm/mach-samsung/include/mach/s5pcxx-clocks.h | 55 ++ arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h | 49 ++ 11 files changed, 1161 insertions(+) create mode 100644 arch/arm/mach-samsung/clocks-s5pcxx.c create mode 100644 arch/arm/mach-samsung/gpio-s5pcxx.c create mode 100644 arch/arm/mach-samsung/include/mach/iomux-s5pcxx.h create mode 100644 arch/arm/mach-samsung/include/mach/s5pcxx-clocks.h create mode 100644 arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 8a4e1a2..f465084 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -73,6 +73,12 @@ config ARCH_S3C24xx select CPU_ARM920T select GENERIC_GPIO +config ARCH_S5PCxx + bool "Samsung S5PC110, S5PV210" + select ARCH_SAMSUNG + select CPU_V7 + select GENERIC_GPIO + config ARCH_VERSATILE bool "ARM Versatile boards (ARM926EJ-S)" select CPU_ARM926T diff --git a/arch/arm/mach-samsung/Kconfig b/arch/arm/mach-samsung/Kconfig index 63c29ef..65e2acb 100644 --- a/arch/arm/mach-samsung/Kconfig +++ b/arch/arm/mach-samsung/Kconfig @@ -14,6 +14,10 @@ config BOARDINFO default "Digi A9M2440" if MACH_A9M2440 default "Digi A9M2410" if MACH_A9M2410 +config ARCH_BAREBOX_MAX_BARE_INIT_SIZE + hex + default 0x1ff0 if ARCH_S5PCxx + if ARCH_S3C24xx config CPU_S3C2410 @@ -80,6 +84,24 @@ endmenu endif +if ARCH_S5PCxx + +config CPU_S5PC110 + bool + +config CPU_S5PV210 + bool + +choice + + prompt "S5PCxx board type" + + +endchoice + +endif + + menu "S3C Features " config S3C_LOWLEVEL_INIT diff --git a/arch/arm/mach-samsung/Makefile b/arch/arm/mach-samsung/Makefile index bde707f..0b95e14 100644 --- a/arch/arm/mach-samsung/Makefile +++ b/arch/arm/mach-samsung/Makefile @@ -1,4 +1,5 @@ obj-y += s3c-timer.o generic.o obj-lowlevel-$(CONFIG_ARCH_S3C24xx) += lowlevel-s3c24x0.o obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o s3c24xx-clocks.o mem-s3c24x0.o +obj-$(CONFIG_ARCH_S5PCxx) += gpio-s5pcxx.o clocks-s5pcxx.o obj-$(CONFIG_S3C_LOWLEVEL_INIT) += $(obj-lowlevel-y) diff --git a/arch/arm/mach-samsung/clocks-s5pcxx.c b/arch/arm/mach-samsung/clocks-s5pcxx.c new file mode 100644 index 0000000..1f4790b --- /dev/null +++ b/arch/arm/mach-samsung/clocks-s5pcxx.c @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * Copyright (C) 2012 Juergen Beisert, Pengutronix + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <config.h> +#include <common.h> +#include <init.h> +#include <clock.h> +#include <io.h> +#include <mach/s3c-iomap.h> +#include <mach/s3c-generic.h> +#include <mach/s3c-clocks.h> + +static inline uint32_t clkdiv(uint32_t clk, unsigned bit, unsigned mask) +{ + uint32_t ratio = (readl(S5P_CLK_DIV0) >> bit) & mask; + return clk / (ratio + 1); +} + +uint32_t s3c_get_mpllclk(void) +{ + uint32_t m, p, s; + uint32_t reg = readl(S5P_xPLL_CON + S5P_MPLL); + m = (reg >> 16) & 0x3ff; + p = (reg >> 8) & 0x3f; + s = (reg >> 0) & 0x7; + return m * ((S5PCXX_CLOCK_REFERENCE) / (p << s)); +} + +uint32_t s3c_get_apllclk(void) +{ + uint32_t m, p, s; + uint32_t reg = readl(S5P_xPLL_CON + S5P_APLL); + m = (reg >> 16) & 0x3ff; + p = (reg >> 8) & 0x3f; + s = (reg >> 0) & 0x7; + s -= 1; + return m * ((S5PCXX_CLOCK_REFERENCE) / (p << s)); +} + +static uint32_t s5p_get_a2mclk(void) +{ + return clkdiv(s3c_get_apllclk(), 4, 0x7); +} + +static uint32_t s5p_get_moutpsysclk(void) +{ + if (readl(S5P_CLK_SRC0) & (1 << 24)) /* MUX_PSYS */ + return s5p_get_a2mclk(); + else + return s3c_get_mpllclk(); +} + +uint32_t s3c_get_hclk(void) +{ + return clkdiv(s5p_get_moutpsysclk(), 24, 0xf); +} + +uint32_t s3c_get_pclk(void) +{ + return clkdiv(s3c_get_hclk(), 28, 0x7); +} + +/* we are using the internal 'uclk1' as the UART source */ +static unsigned s3c_get_uart_clk_uclk1(void) +{ + unsigned clk = s3c_get_mpllclk(); /* TODO check for EPLL */ + unsigned uartpdiv = ((readl(S5P_CLK_DIV4) >> 16) & 0x3) + 1; /* TODO this is UART0 only */ + return clk / uartpdiv; +} + +unsigned s3c_get_uart_clk(unsigned src) { + return (src & 1) ? s3c_get_uart_clk_uclk1() : s3c_get_pclk(); +} + +int s5pcxx_dump_clocks(void) +{ + printf("refclk: %7d kHz\n", S5PCXX_CLOCK_REFERENCE / 1000); + printf("apll: %7d kHz\n", s3c_get_apllclk() / 1000); + printf("mpll: %7d kHz\n", s3c_get_mpllclk() / 1000); +/* printf("CPU: %7d kHz\n", s3c_get_cpuclk() / 1000); */ + printf("hclk: %7d kHz\n", s3c_get_hclk() / 1000); + printf("pclk: %7d kHz\n", s3c_get_pclk() / 1000); + return 0; +} + +late_initcall(s5pcxx_dump_clocks); diff --git a/arch/arm/mach-samsung/gpio-s5pcxx.c b/arch/arm/mach-samsung/gpio-s5pcxx.c new file mode 100644 index 0000000..604a63f --- /dev/null +++ b/arch/arm/mach-samsung/gpio-s5pcxx.c @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * Copyright (C) 2012 Juergen Beisert, Pengutronix + * + * This codes bases partially on code from the Linux kernel: + * + * Copyright 2008 Openmoko, Inc. + * Copyright 2008 Simtec Electronics + * http://armlinux.simtec.co.uk/ + * Ben Dooks <ben@simtec.co.uk> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <common.h> +#include <errno.h> +#include <io.h> +#include <gpio.h> +#include <mach/s3c-iomap.h> + +#define S3C_GPACON (S3C_GPIO_BASE) +#define S3C_GPADAT (S3C_GPIO_BASE + 0x04) +#define S3C_GPAPUD (S3C_GPIO_BASE + 0x08) + +static inline unsigned group_offset(unsigned group) +{ + return group * 0x20; +} + +void gpio_set_value(unsigned gpio, int value) +{ + unsigned group = GET_GROUP(gpio); + unsigned bit = GET_BIT(gpio); + unsigned offset = group_offset(group); + uint32_t reg; + + reg = readl(S3C_GPADAT + offset); + reg &= ~(1 << bit); + reg |= (!!value) << bit; + writel(reg, S3C_GPADAT + offset); +} + +int gpio_get_value(unsigned gpio) +{ + unsigned group = GET_GROUP(gpio); + unsigned bit = GET_BIT(gpio); + unsigned offset = group_offset(group); + uint32_t reg; + + /* value */ + reg = readl(S3C_GPADAT + offset); + + return !!(reg & (1 << bit)); +} + +int gpio_direction_input(unsigned gpio) +{ + unsigned group = GET_GROUP(gpio); + unsigned bit = GET_BIT(gpio); + unsigned offset = group_offset(group); + uint32_t reg; + + bit <<= 2; + reg = readl(S3C_GPACON + offset) & ~(0xf << bit); + writel(reg, S3C_GPACON + offset); + + return 0; +} + +int gpio_direction_output(unsigned gpio, int value) +{ + unsigned group = GET_GROUP(gpio); + unsigned bit = GET_BIT(gpio); + unsigned offset = group_offset(group); + uint32_t reg; + + gpio_set_value(gpio, value); + + bit <<= 2; + reg = readl(S3C_GPACON + offset) & ~(0xf << bit); + reg |= 0x1 << bit; + writel(reg, S3C_GPACON + offset); + + return 0; +} + + +/* 'gpio_mode' must be one of the 'GP?_*' macros */ +void s3c_gpio_mode(unsigned gpio_mode) +{ + unsigned group = GET_GROUP(gpio_mode); + unsigned bit = GET_BIT(gpio_mode); + unsigned func = GET_FUNC(gpio_mode); + unsigned offset = group_offset(group); + unsigned reg; + + bit <<= 1; + if (PUD_PRESENT(gpio_mode)) { + reg = readl(S3C_GPAPUD + offset); + reg &= ~(PUD_MASK << bit); + reg |= GET_PUD(gpio_mode) << bit; + writel(reg, S3C_GPAPUD + offset); + } + + bit <<= 1; + reg = readl(S3C_GPACON + offset) & ~(0xf << bit); + writel(reg | (func << bit), S3C_GPACON + offset); + + if (func == 1) { /* output? if yes, also set the initial value */ + reg = readl(S3C_GPADAT + offset) & ~(1 << (bit >> 2)); + reg |= GET_GPIOVAL(gpio_mode) << (bit >> 2); + writel(reg, S3C_GPADAT + offset); + } + +} diff --git a/arch/arm/mach-samsung/include/mach/gpio.h b/arch/arm/mach-samsung/include/mach/gpio.h index 3723394..4d7d217 100644 --- a/arch/arm/mach-samsung/include/mach/gpio.h +++ b/arch/arm/mach-samsung/include/mach/gpio.h @@ -16,6 +16,9 @@ #ifdef CONFIG_ARCH_S3C24xx # include <mach/iomux-s3c24x0.h> #endif +#ifdef CONFIG_ARCH_S5PCxx +# include <mach/iomux-s5pcxx.h> +#endif void gpio_set_value(unsigned, int); int gpio_direction_input(unsigned); diff --git a/arch/arm/mach-samsung/include/mach/iomux-s5pcxx.h b/arch/arm/mach-samsung/include/mach/iomux-s5pcxx.h new file mode 100644 index 0000000..0677de4 --- /dev/null +++ b/arch/arm/mach-samsung/include/mach/iomux-s5pcxx.h @@ -0,0 +1,798 @@ +/* + * Copyright (C) 2012 Juergen Beisert + * Copyright (C) 2012 Alexey Galakhov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +/* Tested with S5PV210 */ + +#ifndef __MACH_IOMUX_S5PCXX_H +# define __MACH_IOMUX_S5PCXX_H + +/* 3322222222221111111111 + * 10987654321098765432109876543210 + * ^^^^^^_ Bit offset + * ^^^^^_______ Group Number + * ^^^^____________ Function + * ^________________ initial GPIO out value + * ^_________________ Pull up/down feature present + * ^^__________________ initial pull up/down setting + */ + +#define PIN(group,bit) ((group << 6) + bit) +#define FUNC(x) (((x) & 0xf) << 11) +#define GET_FUNC(x) (((x) >> 11) & 0xf) +#define GET_GROUP(x) (((x) >> 6) & 0x1f) +#define GET_BIT(x) ((x) & 0x3f) +#define GET_GPIOVAL(x) (!!((x) & (1 << 15))) +#define GPIO_OUT (1 << 11) +#define GPIO_IN (0 << 11) +#define GPIO_VAL(x) ((!!(x)) << 15) +#define PUD_MASK 0x3 +#define PUD (1 << 16) +#define PUD_PRESENT(x) (!!((x) & (1 << 16))) +#define DISABLE_PUD (0 << 17) +#define ENABLE_PU (2 << 17) +#define ENABLE_PD (1 << 17) +#define GET_PUD(x) (((x) >> 17) & PUD_MASK) + +/* + * To have a chance for simple GPIO manipulation routines + * define the GPIO numbers with a real simple scheme. + * + * Keep in mind: The 'GPIO_2_NO' creates a value to be used with the real gpio + * routines and *not* for the multiplexer routines! + */ +#define GPIO_2_NO(x,y) (PIN(x,y)) + +/* + * Group A0: GPIO 0...7 + * Used GPIO: 0...7 + * These pins can also act as GPIO outputs + */ +#define GPA00 (PIN(0,0) | PUD) +#define GPA00_GPIO (GPA00 | FUNC(0)) +#define GPA00_RXD0 (GPA00 | FUNC(2)) +#define GPA01 (PIN(0,1) | PUD) +#define GPA01_GPIO (GPA01 | FUNC(0)) +#define GPA01_TXD0 (GPA01 | FUNC(2)) +#define GPA02 (PIN(0,2) | PUD) +#define GPA02_GPIO (GPA02 | FUNC(0)) +#define GPA02_NCTS0 (GPA02 | FUNC(2)) +#define GPA03 (PIN(0,3) | PUD) +#define GPA03_GPIO (GPA03 | FUNC(0)) +#define GPA03_NRTS0 (GPA03 | FUNC(2)) +#define GPA04 (PIN(0,4) | PUD) +#define GPA04_GPIO (GPA04 | FUNC(0)) +#define GPA04_RXD1 (GPA04 | FUNC(2)) +#define GPA05 (PIN(0,5) | PUD) +#define GPA05_GPIO (GPA05 | FUNC(0)) +#define GPA05_TXD1 (GPA05 | FUNC(2)) +#define GPA06 (PIN(0,6) | PUD) +#define GPA06_GPIO (GPA06 | FUNC(0)) +#define GPA06_NCTS1 (GPA06 | FUNC(2)) +#define GPA07 (PIN(0,7) | PUD) +#define GPA07_GPIO (GPA07 | FUNC(0)) +#define GPA07_NRTS1 (GPA07 | FUNC(2)) + +/* + * Group A1: GPIO 0..3 + * Used GPIO: 0..3 + * These pins can also act as GPIO outputs + */ +#define GPA10 (PIN(1,0) | PUD) +#define GPA10_GPIO (GPA10 | FUNC(0)) +#define GPA10_RXD2 (GPA10 | FUNC(2)) +#define GPA10_RXDAUD (GPA0 | FUNC(4)) +#define GPA11 (PIN(1,1) | PUD) +#define GPA11_GPIO (GPA11 | FUNC(0)) +#define GPA11_TXD2 (GPA11 | FUNC(2)) +#define GPA11_TXDAUD (GPA1 | FUNC(4)) +#define GPA12 (PIN(1,2) | PUD) +#define GPA12_GPIO (GPA12 | FUNC(0)) +#define GPA12_RXD3 (GPA12 | FUNC(2)) +#define GPA12_NCTS2 (GPA12 | FUNC(3)) +#define GPA13 (PIN(1,3) | PUD) +#define GPA13_GPIO (GPA13 | FUNC(0)) +#define GPA13_TXD3 (GPA13 | FUNC(2)) +#define GPA13_NRTS2 (GPA13 | FUNC(3)) + + +/* + * Group B: GPIO 0...7 + * Used GPIO: 0...7 + * These pins can also act as GPIO outputs + */ +#define GPB0 (PIN(2,0) | PUD) +#define GPB0_GPIO (GPB0 | FUNC(0)) +#define GPB0_SPI0_CLK (GPB0 | FUNC(2)) +#define GPB1 (PIN(2,1) | PUD) +#define GPB1_GPIO (GPB1 | FUNC(0)) +#define GPB1_SPI0_NCS (GPB1 | FUNC(2)) +#define GPB2 (PIN(2,2) | PUD) +#define GPB2_GPIO (GPB2 | FUNC(0)) +#define GPB2_SPI0_MISO (GPB2 | FUNC(2)) +#define GPB3 (PIN(2,3) | PUD) +#define GPB3_GPIO (GPB3 | FUNC(0)) +#define GPB3_SPI0_MOSI (GPB3 | FUNC(2)) +#define GPB4 (PIN(2,4) | PUD) +#define GPB4_GPIO (GPB4 | FUNC(0)) +#define GPB4_SPI1_CLK (GPB4 | FUNC(2)) +#define GPB5 (PIN(2,5) | PUD) +#define GPB5_GPIO (GPB5 | FUNC(0)) +#define GPB5_SPI1_NCS (GPB5 | FUNC(0)) +#define GPB6 (PIN(2,6) | PUD) +#define GPB6_GPIO (GPB6 | FUNC(0)) +#define GPB6_SPI1_MISO (GPB6 | FUNC(0)) +#define GPB7 (PIN(2,7) | PUD) +#define GPB7_GPIO (GPB7 | FUNC(0)) +#define GPB7_SPI1_MOSI (GPB7 | FUNC(0)) + +/* + * Group C0: GPIO 0...4 + */ +#define GPC00 (PIN(3,0) | PUD) +#define GPC00_GPIO (GPC00 | FUNC(0)) +#define GPC00_I2S1_SCLK (GPC00 | FUNC(2)) +#define GPC00_PCM1_SCLK (GPC00 | FUNC(3)) +#define GPC00_AC97_BITCLK (GPC00 | FUNC(4)) +#define GPC01 (PIN(3,1) | PUD) +#define GPC01_GPIO (GPC01 | FUNC(0)) +#define GPC01_I2S1_CDCLK (GPC01 | FUNC(2)) +#define GPC01_PCM1_EXTCLK (GPC01 | FUNC(3)) +#define GPC01_AC97_NRESET (GPC01 | FUNC(4)) +#define GPC02 (PIN(3,2) | PUD) +#define GPC02_GPIO (GPC02 | FUNC(0)) +#define GPC02_I2S1_LRCK (GPC02 | FUNC(2)) +#define GPC02_PCM1_FSYNC (GPC02 | FUNC(3)) +#define GPC02_AC97_SYNC (GPC02 | FUNC(4)) +#define GPC03 (PIN(3,3) | PUD) +#define GPC03_GPIO (GPC03 | FUNC(0)) +#define GPC03_I2S1_SDI (GPC03 | FUNC(2)) +#define GPC03_PCM1_SIN (GPC03 | FUNC(3)) +#define GPC03_AC97_SDI (GPC03 | FUNC(4)) +#define GPC04 (PIN(3,4) | PUD) +#define GPC04_GPIO (GPC04 | FUNC(0)) +#define GPC04_I2S1_SDO (GPC04 | FUNC(2)) +#define GPC04_PCM1_SOUT (GPC04 | FUNC(3)) +#define GPC04_AC97_SDO (GPC04 | FUNC(4)) + +/* + * Group C1: GPIO 0...4 + */ +#define GPC10 (PIN(4,0) | PUD) +#define GPC10_GPIO (GPC10 | FUNC(0)) +#define GPC10_PCM2_SCLK (GPC10 | FUNC(2)) +#define GPC10_SPDIF_0_OUT (GPC10 | FUNC(3)) +#define GPC10_I2S2_SCLK (GPC10 | FUNC(4)) +#define GPC11 (PIN(4,1) | PUD) +#define GPC11_GPIO (GPC11 | FUNC(0)) +#define GPC11_PCM2_EXTCLK (GPC11 | FUNC(2)) +#define GPC11_SPDIF_EXTCLK (GPC11 | FUNC(3)) +#define GPC11_I2S2_CDCLK (GPC11 | FUNC(4)) +#define GPC12 (PIN(4,2) | PUD) +#define GPC12_GPIO (GPC12 | FUNC(0)) +#define GPC12_PCM2_FSYNC (GPC12 | FUNC(2)) +#define GPC12_LCD_FRM (GPC12 | FUNC(3)) +#define GPC12_I2S2_LRCK (GPC12 | FUNC(4)) +#define GPC13 (PIN(4,3) | PUD) +#define GPC13_GPIO (GPC13 | FUNC(0)) +#define GPC13_PCM2_SIN (GPC13 | FUNC(2)) +#define GPC13_I2S2_SDI (GPC13 | FUNC(4)) +#define GPC14 (PIN(4,4) | PUD) +#define GPC14_GPIO (GPC14 | FUNC(0)) +#define GPC14_PCM2_SOUT (GPC14 | FUNC(2)) +#define GPC14_I2S2_SDO (GPC14 | FUNC(4)) + +/* + * Group D0: GPIO 0...3 + */ +#define GPD00 (PIN(5,0) | PUD) +#define GPD00_GPIO (GPD00 | FUNC(0)) +#define GPD00_TOUT_0 (GPD00 | FUNC(2)) +#define GPD01 (PIN(5,1) | PUD) +#define GPD01_GPIO (GPD01 | FUNC(0)) +#define GPD01_TOUT_1 (GPD01 | FUNC(2)) +#define GPD02 (PIN(5,2) | PUD) +#define GPD02_GPIO (GPD02 | FUNC(0)) +#define GPD02_TOUT_2 (GPD02 | FUNC(2)) +#define GPD03 (PIN(5,3) | PUD) +#define GPD03_GPIO (GPD03 | FUNC(0)) +#define GPD03_TOUT_3 (GPD03 | FUNC(2)) + +/* + * Group D1: GPIO 0...5 + */ +#define GPD10 (PIN(6,0) | PUD) +#define GPD10_GPIO (GPD10 | FUNC(0)) +#define GPD10_I2C0_SDA (GPD10 | FUNC(2)) +#define GPD11 (PIN(6,0) | PUD) +#define GPD11_GPIO (GPD11 | FUNC(0)) +#define GPD11_I2C0_SCL (GPD11 | FUNC(2)) +#define GPD12 (PIN(6,0) | PUD) +#define GPD12_GPIO (GPD12 | FUNC(0)) +#define GPD12_I2C1_SDA (GPD12 | FUNC(2)) +#define GPD13 (PIN(6,0) | PUD) +#define GPD13_GPIO (GPD13 | FUNC(0)) +#define GPD13_I2C1_SCL (GPD13 | FUNC(2)) +#define GPD14 (PIN(6,0) | PUD) +#define GPD14_GPIO (GPD14 | FUNC(0)) +#define GPD14_I2C2_SDA (GPD14 | FUNC(2)) +#define GPD15 (PIN(6,0) | PUD) +#define GPD15_GPIO (GPD15 | FUNC(0)) +#define GPD15_I2C2_SCL (GPD15 | FUNC(2)) + +/* + * Group E0: GPIO 0...7 + */ +#define GPE00 (PIN(7,0) | PUD) +#define GPE00_GPIO (GPE00 | FUNC(0)) +#define GPE00_CAM_A_PCLK (GPE00 | FUNC(2)) +#define GPE01 (PIN(7,1) | PUD) +#define GPE01_GPIO (GPE01 | FUNC(0)) +#define GPE01_CAM_A_VSYNC (GPE01 | FUNC(2)) +#define GPE02 (PIN(7,2) | PUD) +#define GPE02_GPIO (GPE02 | FUNC(0)) +#define GPE02_CAM_A_HREF (GPE02 | FUNC(2)) +#define GPE03 (PIN(7,3) | PUD) +#define GPE03_GPIO (GPE03 | FUNC(0)) +#define GPE03_CAM_A_DATA0 (GPE03 | FUNC(2)) +#define GPE04 (PIN(7,4) | PUD) +#define GPE04_GPIO (GPE04 | FUNC(0)) +#define GPE04_CAM_A_DATA1 (GPE04 | FUNC(2)) +#define GPE05 (PIN(7,5) | PUD) +#define GPE05_GPIO (GPE05 | FUNC(0)) +#define GPE05_CAM_A_DATA2 (GPE05 | FUNC(2)) +#define GPE06 (PIN(7,6) | PUD) +#define GPE06_GPIO (GPE06 | FUNC(0)) +#define GPE06_CAM_A_DATA3 (GPE06 | FUNC(2)) +#define GPE07 (PIN(7,7) | PUD) +#define GPE07_GPIO (GPE07 | FUNC(0)) +#define GPE07_CAM_A_DATA4 (GPE07 | FUNC(2)) + +/* + * Group E1: GPIO 0...4 + */ +#define GPE10 (PIN(8,0) | PUD) +#define GPE10_GPIO (GPE10 | FUNC(0)) +#define GPE10_CAM_A_DATA5 (GPE10 | FUNC(2)) +#define GPE11 (PIN(8,1) | PUD) +#define GPE11_GPIO (GPE11 | FUNC(0)) +#define GPE11_CAM_A_DATA6 (GPE11 | FUNC(2)) +#define GPE12 (PIN(8,2) | PUD) +#define GPE12_GPIO (GPE12 | FUNC(0)) +#define GPE12_CAM_A_DATA7 (GPE12 | FUNC(2)) +#define GPE13 (PIN(8,3) | PUD) +#define GPE13_GPIO (GPE13 | FUNC(0)) +#define GPE13_CAM_A_CLKOUT (GPE13 | FUNC(2)) +#define GPE14 (PIN(8,4) | PUD) +#define GPE14_GPIO (GPE14 | FUNC(0)) +#define GPE14_CAM_A_FIELD (GPE14 | FUNC(2)) + +/* + * Group F0: GPIO 0...7 + */ +#define GPF00 (PIN(9,0) | PUD) +#define GPF00_GPIO (GPF00 | FUNC(0)) +#define GPF00_LCD_HSYNC (GPF00 | FUNC(2)) +#define GPF00_SYS_CS0 (GPF00 | FUNC(3)) +#define GPF00_VEN_HSYNC (GPF00 | FUNC(4)) +#define GPF01 (PIN(9,1) | PUD) +#define GPF01_GPIO (GPF01 | FUNC(0)) +#define GPF01_LCD_VSYNC (GPF01 | FUNC(2)) +#define GPF01_SYS_CS1 (GPF01 | FUNC(3)) +#define GPF01_VEN_VSYNC (GPF01 | FUNC(4)) +#define GPF02 (PIN(9,2) | PUD) +#define GPF02_GPIO (GPF02 | FUNC(0)) +#define GPF02_LCD_VDEN (GPF02 | FUNC(2)) +#define GPF02_SYS_RS (GPF02 | FUNC(3)) +#define GPF02_VEN_HREF (GPF02 | FUNC(4)) +#define GPF03 (PIN(9,3) | PUD) +#define GPF03_GPIO (GPF03 | FUNC(0)) +#define GPF03_LCD_VCLK (GPF03 | FUNC(2)) +#define GPF03_SYS_WE (GPF03 | FUNC(3)) +#define GPF03_V601_CLK (GPF03 | FUNC(4)) +#define GPF04 (PIN(9,4) | PUD) +#define GPF04_GPIO (GPF04 | FUNC(0)) +#define GPF04_LCD_VD0 (GPF04 | FUNC(2)) +#define GPF04_SYS_VS0 (GPF04 | FUNC(3)) +#define GPF04_VEN_DATA0 (GPF04 | FUNC(4)) +#define GPF05 (PIN(9,5) | PUD) +#define GPF05_GPIO (GPF05 | FUNC(0)) +#define GPF05_LCD_VD1 (GPF05 | FUNC(2)) +#define GPF05_SYS_VD1 (GPF05 | FUNC(3)) +#define GPF05_VEN_DATA1 (GPF05 | FUNC(4)) +#define GPF06 (PIN(9,6) | PUD) +#define GPF06_GPIO (GPF06 | FUNC(0)) +#define GPF06_LCD_VD2 (GPF06 | FUNC(2)) +#define GPF06_SYS_VD2 (GPF06 | FUNC(3)) +#define GPF06_VEN_DATA2 (GPF06 | FUNC(4)) +#define GPF07 (PIN(9,7) | PUD) +#define GPF07_GPIO (GPF07 | FUNC(0)) +#define GPF07_LCD_VD3 (GPF07 | FUNC(2)) +#define GPF07_SYS_VD3 (GPF07 | FUNC(3)) +#define GPF07_VEN_DATA3 (GPF07 | FUNC(4)) + +/* + * Group F1: GPIO 0...7 + */ +#define GPF10 (PIN(10,0) | PUD) +#define GPF10_GPIO (GPF10 | FUNC(0)) +#define GPF10_LCD_VD4 (GPF10 | FUNC(2)) +#define GPF10_SYS_VD4 (GPF10 | FUNC(3)) +#define GPF10_VEN_DATA4 (GPF10 | FUNC(4)) +#define GPF11 (PIN(10,1) | PUD) +#define GPF11_GPIO (GPF11 | FUNC(0)) +#define GPF11_LCD_VD5 (GPF11 | FUNC(2)) +#define GPF11_SYS_VD5 (GPF11 | FUNC(3)) +#define GPF11_VEN_DATA5 (GPF11 | FUNC(4)) +#define GPF12 (PIN(10,2) | PUD) +#define GPF12_GPIO (GPF12 | FUNC(0)) +#define GPF12_LCD_VD6 (GPF12 | FUNC(2)) +#define GPF12_SYS_VD6 (GPF12 | FUNC(3)) +#define GPF12_VEN_DATA6 (GPF12 | FUNC(4)) +#define GPF13 (PIN(10,3) | PUD) +#define GPF13_GPIO (GPF13 | FUNC(0)) +#define GPF13_LCD_VD7 (GPF13 | FUNC(2)) +#define GPF13_SYS_VD7 (GPF13 | FUNC(3)) +#define GPF13_VEN_DATA7 (GPF13 | FUNC(4)) +#define GPF14 (PIN(10,4) | PUD) +#define GPF14_GPIO (GPF14 | FUNC(0)) +#define GPF14_LCD_VD8 (GPF14 | FUNC(2)) +#define GPF14_SYS_VD8 (GPF14 | FUNC(3)) +#define GPF14_V656_DATA0 (GPF14 | FUNC(4)) +#define GPF15 (PIN(10,5) | PUD) +#define GPF15_GPIO (GPF15 | FUNC(0)) +#define GPF15_LCD_VD9 (GPF15 | FUNC(2)) +#define GPF15_SYS_VD9 (GPF15 | FUNC(3)) +#define GPF15_V656_DATA1 (GPF15 | FUNC(4)) +#define GPF16 (PIN(10,6) | PUD) +#define GPF16_GPIO (GPF16 | FUNC(0)) +#define GPF16_LCD_VD10 (GPF16 | FUNC(2)) +#define GPF16_SYS_VD10 (GPF16 | FUNC(3)) +#define GPF16_V656_DATA2 (GPF16 | FUNC(4)) +#define GPF17 (PIN(10,7) | PUD) +#define GPF17_GPIO (GPF17 | FUNC(0)) +#define GPF17_LCD_VD11 (GPF17 | FUNC(2)) +#define GPF17_SYS_VD11 (GPF17 | FUNC(3)) +#define GPF17_V656_DATA3 (GPF17 | FUNC(4)) + +/* + * Group F2: GPIO 0...7 + */ +#define GPF20 (PIN(11,0) | PUD) +#define GPF20_GPIO (GPF20 | FUNC(0)) +#define GPF20_LCD_VD_12 (GPF20 | FUNC(2)) +#define GPF20_SYS_VD_12 (GPF20 | FUNC(3)) +#define GPF20_V656_DATA_4 (GPF20 | FUNC(4)) +#define GPF21 (PIN(11,1) | PUD) +#define GPF21_GPIO (GPF21 | FUNC(0)) +#define GPF21_LCD_VD_13 (GPF21 | FUNC(2)) +#define GPF21_SYS_VD_13 (GPF21 | FUNC(3)) +#define GPF21_V656_DATA_5 (GPF21 | FUNC(4)) +#define GPF22 (PIN(11,2) | PUD) +#define GPF22_GPIO (GPF22 | FUNC(0)) +#define GPF22_LCD_VD_14 (GPF22 | FUNC(2)) +#define GPF22_SYS_VD_14 (GPF22 | FUNC(3)) +#define GPF22_V656_DATA_6 (GPF22 | FUNC(4)) +#define GPF23 (PIN(11,3) | PUD) +#define GPF23_GPIO (GPF23 | FUNC(0)) +#define GPF23_LCD_VD_15 (GPF23 | FUNC(2)) +#define GPF23_SYS_VD_15 (GPF23 | FUNC(3)) +#define GPF23_V656_DATA_7 (GPF23 | FUNC(4)) +#define GPF24 (PIN(11,4) | PUD) +#define GPF24_GPIO (GPF24 | FUNC(0)) +#define GPF24_LCD_VD_16 (GPF24 | FUNC(2)) +#define GPF24_SYS_VD_16 (GPF24 | FUNC(3)) +#define GPF25 (PIN(11,5) | PUD) +#define GPF25_GPIO (GPF25 | FUNC(0)) +#define GPF25_LCD_VD_17 (GPF25 | FUNC(2)) +#define GPF25_SYS_VD_17 (GPF25 | FUNC(3)) +#define GPF26 (PIN(11,6) | PUD) +#define GPF26_GPIO (GPF26 | FUNC(0)) +#define GPF26_LCD_VD_18 (GPF26 | FUNC(2)) +#define GPF26_SYS_VD_18 (GPF26 | FUNC(3)) +#define GPF27 (PIN(11,7) | PUD) +#define GPF27_GPIO (GPF27 | FUNC(0)) +#define GPF27_LCD_VD_19 (GPF27 | FUNC(2)) +#define GPF27_SYS_VD_19 (GPF27 | FUNC(3)) + +/* + * Group F3: GPIO 0...5 + */ +#define GPF30 (PIN(12,0) | PUD) +#define GPF30_GPIO (GPF30 | FUNC(0)) +#define GPF30_LCD_VD20 (GPF30 | FUNC(2)) +#define GPF30_SYS_VD20 (GPF30 | FUNC(3)) +#define GPF31 (PIN(12,1) | PUD) +#define GPF31_GPIO (GPF31 | FUNC(0)) +#define GPF31_LCD_VD21 (GPF31 | FUNC(2)) +#define GPF31_SYS_VD21 (GPF31 | FUNC(3)) +#define GPF32 (PIN(12,2) | PUD) +#define GPF32_GPIO (GPF32 | FUNC(0)) +#define GPF32_LCD_VD22 (GPF32 | FUNC(2)) +#define GPF32_SYS_VD22 (GPF32 | FUNC(3)) +#define GPF33 (PIN(12,3) | PUD) +#define GPF33_GPIO (GPF33 | FUNC(0)) +#define GPF33_LCD_VD23 (GPF33 | FUNC(2)) +#define GPF33_SYS_VD23 (GPF33 | FUNC(3)) +#define GPF33_V656_CLK (GPF33 | FUNC(4)) +#define GPF34 (PIN(12,4) | PUD) +#define GPF34_GPIO (GPF34 | FUNC(0)) +#define GPF34_VSYNC_LDI (GPF34 | FUNC(3)) +#define GPF35 (PIN(12,5) | PUD) +#define GPF35_GPIO (GPF35 | FUNC(0)) +#define GPF35_SYS_OE (GPF35 | FUNC(3)) +#define GPF35_VEN_FIELD (GPF35 | FUNC(4)) + +/* + * Group G0: GPIO 0...6 + */ +#define GPG00 (PIN(13,0) | PUD) +#define GPG00_GPIO (GPG00 | FUNC(0)) +#define GPG00_SD0_CLK (GPG00 | FUNC(2)) +#define GPG01 (PIN(13,1) | PUD) +#define GPG01_GPIO (GPG01 | FUNC(0)) +#define GPG01_SD0_CMD (GPG01 | FUNC(2)) +#define GPG02 (PIN(13,2) | PUD) +#define GPG02_GPIO (GPG02 | FUNC(0)) +#define GPG02_SD0_NCD (GPG02 | FUNC(2)) +#define GPG03 (PIN(13,3) | PUD) +#define GPG03_GPIO (GPG03 | FUNC(0)) +#define GPG03_SD0_DATA0 (GPG03 | FUNC(2)) +#define GPG04 (PIN(13,4) | PUD) +#define GPG04_GPIO (GPG04 | FUNC(0)) +#define GPG04_SD0_DATA1 (GPG04 | FUNC(2)) +#define GPG05 (PIN(13,5) | PUD) +#define GPG05_GPIO (GPG05 | FUNC(0)) +#define GPG05_SD0_DATA2 (GPG05 | FUNC(2)) +#define GPG06 (PIN(13,6) | PUD) +#define GPG06_GPIO (GPG06 | FUNC(0)) +#define GPG06_SD0_DATA3 (GPG06 | FUNC(2)) + +/* + * Group G1: GPIO 0...6 + */ +#define GPG10 (PIN(14,0) | PUD) +#define GPG10_GPIO (GPG10 | FUNC(0)) +#define GPG10_SD1_CLK (GPG10 | FUNC(2)) +#define GPG11 (PIN(14,1) | PUD) +#define GPG11_GPIO (GPG11 | FUNC(0)) +#define GPG11_SD1_CMD (GPG11 | FUNC(2)) +#define GPG12 (PIN(14,2) | PUD) +#define GPG12_GPIO (GPG12 | FUNC(0)) +#define GPG12_SD1_NCD (GPG12 | FUNC(2)) +#define GPG13 (PIN(14,3) | PUD) +#define GPG13_GPIO (GPG13 | FUNC(0)) +#define GPG13_SD1_DATA0 (GPG13 | FUNC(2)) +#define GPG13_SD0_DATA4 (GPG13 | FUNC(3)) +#define GPG14 (PIN(14,4) | PUD) +#define GPG14_GPIO (GPG14 | FUNC(0)) +#define GPG14_SD1_DATA1 (GPG14 | FUNC(2)) +#define GPG14_SD0_DATA5 (GPG14 | FUNC(3)) +#define GPG15 (PIN(14,5) | PUD) +#define GPG15_GPIO (GPG15 | FUNC(0)) +#define GPG15_SD1_DATA2 (GPG15 | FUNC(2)) +#define GPG15_SD0_DATA6 (GPG15 | FUNC(3)) +#define GPG16 (PIN(14,6) | PUD) +#define GPG16_GPIO (GPG16 | FUNC(0)) +#define GPG16_SD1_DATA3 (GPG16 | FUNC(2)) +#define GPG16_SD0_DATA7 (GPG16 | FUNC(3)) + +/* + * Group G2: GPIO 0...6 + */ +#define GPG20 (PIN(15,0) | PUD) +#define GPG20_GPIO (GPG20 | FUNC(0)) +#define GPG20_SD2_CLK (GPG20 | FUNC(2)) +#define GPG21 (PIN(15,1) | PUD) +#define GPG21_GPIO (GPG21 | FUNC(0)) +#define GPG21_SD2_CMD (GPG21 | FUNC(2)) +#define GPG22 (PIN(15,2) | PUD) +#define GPG22_GPIO (GPG22 | FUNC(0)) +#define GPG22_SD2_NCD (GPG22 | FUNC(2)) +#define GPG23 (PIN(15,3) | PUD) +#define GPG23_GPIO (GPG23 | FUNC(0)) +#define GPG23_SD2_DATA0 (GPG23 | FUNC(2)) +#define GPG24 (PIN(15,4) | PUD) +#define GPG24_GPIO (GPG24 | FUNC(0)) +#define GPG24_SD2_DATA1 (GPG24 | FUNC(2)) +#define GPG25 (PIN(15,5) | PUD) +#define GPG25_GPIO (GPG25 | FUNC(0)) +#define GPG25_SD2_DATA2 (GPG25 | FUNC(2)) +#define GPG26 (PIN(15,6) | PUD) +#define GPG26_GPIO (GPG26 | FUNC(0)) +#define GPG26_SD2_DATA3 (GPG26 | FUNC(2)) + +/* + * Group G3: GPIO 0...6 + */ +#define GPG30 (PIN(16,0) | PUD) +#define GPG30_GPIO (GPG30 | FUNC(0)) +#define GPG30_SD3_CLK (GPG30 | FUNC(2)) +#define GPG31 (PIN(16,1) | PUD) +#define GPG31_GPIO (GPG31 | FUNC(0)) +#define GPG31_SD3_CMD (GPG31 | FUNC(2)) +#define GPG32 (PIN(16,2) | PUD) +#define GPG32_GPIO (GPG32 | FUNC(0)) +#define GPG32_SD3_NCD (GPG32 | FUNC(2)) +#define GPG33 (PIN(16,3) | PUD) +#define GPG33_GPIO (GPG33 | FUNC(0)) +#define GPG33_SD3_DATA0 (GPG33 | FUNC(2)) +#define GPG33_SD2_DATA4 (GPG33 | FUNC(3)) +#define GPG34 (PIN(16,4) | PUD) +#define GPG34_GPIO (GPG34 | FUNC(0)) +#define GPG34_SD3_DATA1 (GPG34 | FUNC(2)) +#define GPG34_SD2_DATA5 (GPG34 | FUNC(3)) +#define GPG35 (PIN(16,5) | PUD) +#define GPG35_GPIO (GPG35 | FUNC(0)) +#define GPG35_SD3_DATA2 (GPG35 | FUNC(2)) +#define GPG35_SD2_DATA6 (GPG35 | FUNC(3)) +#define GPG36 (PIN(16,6) | PUD) +#define GPG36_GPIO (GPG36 | FUNC(0)) +#define GPG36_SD3_DATA3 (GPG36 | FUNC(2)) +#define GPG36_SD2_DATA7 (GPG36 | FUNC(3)) + +/* + * Group I - no GPIO + */ +#define GPI0 (PIN(17,0) | PUD) +#define GPI0_I2S0_SCLK (GPI0 | FUNC(2)) +#define GPI0_PCM0_SCLK (GPI0 | FUNC(3)) +#define GPI1 (PIN(17,1) | PUD) +#define GPI1_I2S0_CDCLK (GPI1 | FUNC(2)) +#define GPI1_PCM0_EXTCLK (GPI1 | FUNC(3)) +#define GPI2 (PIN(17,2) | PUD) +#define GPI2_I2S0_LRCK (GPI2 | FUNC(2)) +#define GPI2_PCM0_FSYNC (GPI2 | FUNC(3)) +#define GPI3 (PIN(17,3) | PUD) +#define GPI3_I2S0_SDI (GPI3 | FUNC(2)) +#define GPI3_PCM0_SIN (GPI3 | FUNC(3)) +#define GPI4 (PIN(17,4) | PUD) +#define GPI4_I2S0_SDO0 (GPI4 | FUNC(2)) +#define GPI4_PCM0_SOUT (GPI4 | FUNC(3)) +#define GPI5 (PIN(17,5) | PUD) +#define GPI5_I2S0_SDO1 (GPI5 | FUNC(2)) +#define GPI6 (PIN(17,6) | PUD) +#define GPI6_I2S0_SDO2 (GPI6 | FUNC(2)) + +/* + * Group J0: GPIO 0...7 + */ +#define GPJ00 (PIN(18,0) | PUD) +#define GPJ00_GPIO (GPJ00 | FUNC(0)) +#define GPJ00_MSM_ADDR0 (GPJ00 | FUNC(2)) +#define GPJ00_CAM_B_DATA0 (GPJ00 | FUNC(3)) +#define GPJ00_CF_ADDR0 (GPJ00 | FUNC(4)) +#define GPJ00_MIPI_BYTE_CLK (GPJ00 | FUNC(5)) +#define GPJ01 (PIN(18,1) | PUD) +#define GPJ01_GPIO (GPJ01 | FUNC(0)) +#define GPJ01_MSM_ADDR1 (GPJ01 | FUNC(2)) +#define GPJ01_CAM_B_DATA1 (GPJ01 | FUNC(3)) +#define GPJ01_CF_ADDR1 (GPJ01 | FUNC(4)) +#define GPJ01_MIPI_ESC_CLK (GPJ01 | FUNC(5)) +#define GPJ02 (PIN(18,2) | PUD) +#define GPJ02_GPIO (GPJ02 | FUNC(0)) +#define GPJ02_MSM_ADDR2 (GPJ02 | FUNC(2)) +#define GPJ02_CAM_B_DATA2 (GPJ02 | FUNC(3)) +#define GPJ02_CF_ADDR2 (GPJ02 | FUNC(4)) +#define GPJ02_TS_CLK (GPJ02 | FUNC(5)) +#define GPJ03 (PIN(18,3) | PUD) +#define GPJ03_GPIO (GPJ03 | FUNC(0)) +#define GPJ03_MSM_ADDR3 (GPJ03 | FUNC(2)) +#define GPJ03_CAM_B_DATA3 (GPJ03 | FUNC(3)) +#define GPJ03_CF_IORDY (GPJ03 | FUNC(4)) +#define GPJ03_TS_SYNC (GPJ03 | FUNC(5)) +#define GPJ04 (PIN(18,4) | PUD) +#define GPJ04_GPIO (GPJ04 | FUNC(0)) +#define GPJ04_MSM_ADDR4 (GPJ04 | FUNC(2)) +#define GPJ04_CAM_B_DATA4 (GPJ04 | FUNC(3)) +#define GPJ04_CF_INTRQ (GPJ04 | FUNC(4)) +#define GPJ04_TS_VAL (GPJ04 | FUNC(5)) +#define GPJ05 (PIN(18,5) | PUD) +#define GPJ05_GPIO (GPJ05 | FUNC(0)) +#define GPJ05_MSM_ADDR5 (GPJ05 | FUNC(2)) +#define GPJ05_CAM_B_DATA5 (GPJ05 | FUNC(3)) +#define GPJ05_CF_DMARQ (GPJ05 | FUNC(4)) +#define GPJ05_TS_DATA (GPJ05 | FUNC(5)) +#define GPJ06 (PIN(18,6) | PUD) +#define GPJ06_GPIO (GPJ06 | FUNC(0)) +#define GPJ06_MSM_ADDR6 (GPJ06 | FUNC(2)) +#define GPJ06_CAM_B_DATA6 (GPJ06 | FUNC(3)) +#define GPJ06_CF_NDRESET (GPJ06 | FUNC(4)) +#define GPJ06_TS_ERROR (GPJ06 | FUNC(5)) +#define GPJ07 (PIN(18,7) | PUD) +#define GPJ07_GPIO (GPJ07 | FUNC(0)) +#define GPJ07_MSM_ADDR7 (GPJ07 | FUNC(2)) +#define GPJ07_CAM_B_DATA7 (GPJ07 | FUNC(3)) +#define GPJ07_CF_NDMACK (GPJ07 | FUNC(4)) +#define GPJ07_MHL_D0 (GPJ07 | FUNC(5)) + +/* + * Group J1: GPIO 0...5 + */ +#define GPJ10 (PIN(19,0) | PUD) +#define GPJ10_GPIO (GPJ10 | FUNC(0)) +#define GPJ10_MSM_ADDR8 (GPJ10 | FUNC(2)) +#define GPJ10_CAM_B_PCLK (GPJ10 | FUNC(3)) +#define GPJ10_SROM_ADDR_16to220 (GPJ10 | FUNC(4)) +#define GPJ10_MHL_D1 (GPJ10 | FUNC(5)) +#define GPJ11 (PIN(19,1) | PUD) +#define GPJ11_GPIO (GPJ11 | FUNC(0)) +#define GPJ11_MSM_ADDR9 (GPJ11 | FUNC(2)) +#define GPJ11_CAM_B_VSYNC (GPJ11 | FUNC(3)) +#define GPJ11_SROM_ADDR_16to221 (GPJ11 | FUNC(4)) +#define GPJ11_MHL_D2 (GPJ11 | FUNC(5)) +#define GPJ12 (PIN(19,2) | PUD) +#define GPJ12_GPIO (GPJ12 | FUNC(0)) +#define GPJ12_MSM_ADDR10 (GPJ12 | FUNC(2)) +#define GPJ12_CAM_B_HREF (GPJ12 | FUNC(3)) +#define GPJ12_SROM_ADDR_16to222 (GPJ12 | FUNC(4)) +#define GPJ12_MHL_D3 (GPJ12 | FUNC(5)) +#define GPJ13 (PIN(19,3) | PUD) +#define GPJ13_GPIO (GPJ13 | FUNC(0)) +#define GPJ13_MSM_ADDR11 (GPJ13 | FUNC(2)) +#define GPJ13_CAM_B_FIELD (GPJ13 | FUNC(3)) +#define GPJ13_SROM_ADDR_16to223 (GPJ13 | FUNC(4)) +#define GPJ13_MHL_D4 (GPJ13 | FUNC(5)) +#define GPJ14 (PIN(19,4) | PUD) +#define GPJ14_GPIO (GPJ14 | FUNC(0)) +#define GPJ14_MSM_ADDR12 (GPJ14 | FUNC(2)) +#define GPJ14_CAM_B_CLKOUT (GPJ14 | FUNC(3)) +#define GPJ14_SROM_ADDR_16to224 (GPJ14 | FUNC(4)) +#define GPJ14_MHL_D5 (GPJ14 | FUNC(5)) +#define GPJ15 (PIN(19,5) | PUD) +#define GPJ15_GPIO (GPJ15 | FUNC(0)) +#define GPJ15_MSM_ADDR13 (GPJ15 | FUNC(2)) +#define GPJ15_KP_COL0 (GPJ15 | FUNC(3)) +#define GPJ15_SROM_ADDR_16to225 (GPJ15 | FUNC(4)) +#define GPJ15_MHL_D6 (GPJ15 | FUNC(5)) + +/* + * Group J2: GPIO 0...7 + */ +#define GPJ20 (PIN(20,0) | PUD) +#define GPJ20_GPIO (GPJ20 | FUNC(0)) +#define GPJ20_MSM_DATA0 (GPJ20 | FUNC(2)) +#define GPJ20_KP_COL1 (GPJ20 | FUNC(3)) +#define GPJ20_CF_DATA0 (GPJ20 | FUNC(4)) +#define GPJ20_MHL_D7 (GPJ20 | FUNC(5)) +#define GPJ21 (PIN(20,1) | PUD) +#define GPJ21_GPIO (GPJ21 | FUNC(0)) +#define GPJ21_MSM_DATA1 (GPJ21 | FUNC(2)) +#define GPJ21_KP_COL2 (GPJ21 | FUNC(3)) +#define GPJ21_CF_DATA1 (GPJ21 | FUNC(4)) +#define GPJ21_MHL_D8 (GPJ21 | FUNC(5)) +#define GPJ22 (PIN(20,2) | PUD) +#define GPJ22_GPIO (GPJ22 | FUNC(0)) +#define GPJ22_MSM_DATA2 (GPJ22 | FUNC(2)) +#define GPJ22_KP_COL3 (GPJ22 | FUNC(3)) +#define GPJ22_CF_DATA2 (GPJ22 | FUNC(4)) +#define GPJ22_MHL_D9 (GPJ22 | FUNC(5)) +#define GPJ23 (PIN(20,3) | PUD) +#define GPJ23_GPIO (GPJ23 | FUNC(0)) +#define GPJ23_MSM_DATA3 (GPJ23 | FUNC(2)) +#define GPJ23_KP_COL4 (GPJ23 | FUNC(3)) +#define GPJ23_CF_DATA3 (GPJ23 | FUNC(4)) +#define GPJ23_MHL_D10 (GPJ23 | FUNC(5)) +#define GPJ24 (PIN(20,4) | PUD) +#define GPJ24_GPIO (GPJ24 | FUNC(0)) +#define GPJ24_MSM_DATA4 (GPJ24 | FUNC(2)) +#define GPJ24_KP_COL5 (GPJ24 | FUNC(3)) +#define GPJ24_CF_DATA4 (GPJ24 | FUNC(4)) +#define GPJ24_MHL_D11 (GPJ24 | FUNC(5)) +#define GPJ25 (PIN(20,5) | PUD) +#define GPJ25_GPIO (GPJ25 | FUNC(0)) +#define GPJ25_MSM_DATA5 (GPJ25 | FUNC(2)) +#define GPJ25_KP_COL6 (GPJ25 | FUNC(3)) +#define GPJ25_CF_DATA5 (GPJ25 | FUNC(4)) +#define GPJ25_MHL_D12 (GPJ25 | FUNC(5)) +#define GPJ26 (PIN(20,6) | PUD) +#define GPJ26_GPIO (GPJ26 | FUNC(0)) +#define GPJ26_MSM_DATA6 (GPJ26 | FUNC(2)) +#define GPJ26_KP_COL7 (GPJ26 | FUNC(3)) +#define GPJ26_CF_DATA6 (GPJ26 | FUNC(4)) +#define GPJ26_MHL_D13 (GPJ26 | FUNC(5)) +#define GPJ27 (PIN(20,7) | PUD) +#define GPJ27_GPIO (GPJ27 | FUNC(0)) +#define GPJ27_MSM_DATA7 (GPJ27 | FUNC(2)) +#define GPJ27_KP_ROW0 (GPJ27 | FUNC(3)) +#define GPJ27_CF_DATA7 (GPJ27 | FUNC(4)) +#define GPJ27_MHL_D14 (GPJ27 | FUNC(5)) + +/* + * Group J3: GPIO 0...7 + */ +#define GPJ30 (PIN(21,0) | PUD) +#define GPJ30_GPIO (GPJ30 | FUNC(0)) +#define GPJ30_MSM_DATA8 (GPJ30 | FUNC(2)) +#define GPJ30_KP_ROW1 (GPJ30 | FUNC(3)) +#define GPJ30_CF_DATA8 (GPJ30 | FUNC(4)) +#define GPJ30_MHL_D15 (GPJ30 | FUNC(5)) +#define GPJ31 (PIN(21,1) | PUD) +#define GPJ31_GPIO (GPJ31 | FUNC(0)) +#define GPJ31_MSM_DATA9 (GPJ31 | FUNC(2)) +#define GPJ31_KP_ROW2 (GPJ31 | FUNC(3)) +#define GPJ31_CF_DATA9 (GPJ31 | FUNC(4)) +#define GPJ31_MHL_D16 (GPJ31 | FUNC(5)) +#define GPJ32 (PIN(21,2) | PUD) +#define GPJ32_GPIO (GPJ32 | FUNC(0)) +#define GPJ32_MSM_DATA10 (GPJ32 | FUNC(2)) +#define GPJ32_KP_ROW3 (GPJ32 | FUNC(3)) +#define GPJ32_CF_DATA10 (GPJ32 | FUNC(4)) +#define GPJ32_MHL_D17 (GPJ32 | FUNC(5)) +#define GPJ33 (PIN(21,3) | PUD) +#define GPJ33_GPIO (GPJ33 | FUNC(0)) +#define GPJ33_MSM_DATA11 (GPJ33 | FUNC(2)) +#define GPJ33_KP_ROW4 (GPJ33 | FUNC(3)) +#define GPJ33_CF_DATA11 (GPJ33 | FUNC(4)) +#define GPJ33_MHL_D18 (GPJ33 | FUNC(5)) +#define GPJ34 (PIN(21,4) | PUD) +#define GPJ34_GPIO (GPJ34 | FUNC(0)) +#define GPJ34_MSM_DATA12 (GPJ34 | FUNC(2)) +#define GPJ34_KP_ROW5 (GPJ34 | FUNC(3)) +#define GPJ34_CF_DATA12 (GPJ34 | FUNC(4)) +#define GPJ34_MHL_D19 (GPJ34 | FUNC(5)) +#define GPJ35 (PIN(21,5) | PUD) +#define GPJ35_GPIO (GPJ35 | FUNC(0)) +#define GPJ35_MSM_DATA13 (GPJ35 | FUNC(2)) +#define GPJ35_KP_ROW6 (GPJ35 | FUNC(3)) +#define GPJ35_CF_DATA13 (GPJ35 | FUNC(4)) +#define GPJ35_MHL_D20 (GPJ35 | FUNC(5)) +#define GPJ36 (PIN(21,6) | PUD) +#define GPJ36_GPIO (GPJ36 | FUNC(0)) +#define GPJ36_MSM_DATA14 (GPJ36 | FUNC(2)) +#define GPJ36_KP_ROW7 (GPJ36 | FUNC(3)) +#define GPJ36_CF_DATA14 (GPJ36 | FUNC(4)) +#define GPJ36_MHL_D21 (GPJ36 | FUNC(5)) +#define GPJ37 (PIN(21,7) | PUD) +#define GPJ37_GPIO (GPJ37 | FUNC(0)) +#define GPJ37_MSM_DATA15 (GPJ37 | FUNC(2)) +#define GPJ37_KP_ROW8 (GPJ37 | FUNC(3)) +#define GPJ37_CF_DATA15 (GPJ37 | FUNC(4)) +#define GPJ37_MHL_D22 (GPJ37 | FUNC(5)) + +/* + * Group J4: GPIO 0...4 + */ +#define GPJ40 (PIN(22,0) | PUD) +#define GPJ40_GPIO (GPJ40 | FUNC(0)) +#define GPJ40_MSM_NCS (GPJ40 | FUNC(2)) +#define GPJ40_KP_ROW9 (GPJ40 | FUNC(3)) +#define GPJ40_CF_NCS0 (GPJ40 | FUNC(4)) +#define GPJ40_MHL_D23 (GPJ40 | FUNC(5)) +#define GPJ41 (PIN(22,1) | PUD) +#define GPJ41_GPIO (GPJ41 | FUNC(0)) +#define GPJ41_MSM_NWE (GPJ41 | FUNC(2)) +#define GPJ41_KP_ROW10 (GPJ41 | FUNC(3)) +#define GPJ41_CF_NCS1 (GPJ41 | FUNC(4)) +#define GPJ41_MHL_IDCK (GPJ41 | FUNC(5)) +#define GPJ42 (PIN(22,2) | PUD) +#define GPJ42_GPIO (GPJ42 | FUNC(0)) +#define GPJ42_MSM_NR (GPJ42 | FUNC(2)) +#define GPJ42_KP_ROW11 (GPJ42 | FUNC(3)) +#define GPJ42_CF_IORN (GPJ42 | FUNC(4)) +#define GPJ42_MHL_IDCK (GPJ42 | FUNC(5)) +#define GPJ43 (PIN(22,3) | PUD) +#define GPJ43_GPIO (GPJ43 | FUNC(0)) +#define GPJ43_MSM_NIRQ (GPJ43 | FUNC(2)) +#define GPJ43_KP_ROW12 (GPJ43 | FUNC(3)) +#define GPJ43_CF_IOWN (GPJ43 | FUNC(4)) +#define GPJ43_MHL_VSYNC (GPJ43 | FUNC(5)) +#define GPJ44 (PIN(22,4) | PUD) +#define GPJ44_GPIO (GPJ44 | FUNC(0)) +#define GPJ44_MSM_ADVN (GPJ44 | FUNC(2)) +#define GPJ44_KP_ROW13 (GPJ44 | FUNC(3)) +#define GPJ44_SROM_ADDR_16to226 (GPJ44 | FUNC(4)) +#define GPJ44_MHL_DE (GPJ44 | FUNC(5)) + +#endif /* __MACH_IOMUX_S5PCXX_H */ diff --git a/arch/arm/mach-samsung/include/mach/s3c-clocks.h b/arch/arm/mach-samsung/include/mach/s3c-clocks.h index b8894f8..f577306 100644 --- a/arch/arm/mach-samsung/include/mach/s3c-clocks.h +++ b/arch/arm/mach-samsung/include/mach/s3c-clocks.h @@ -25,5 +25,8 @@ #ifdef CONFIG_ARCH_S3C24xx # include <mach/s3c24xx-clocks.h> #endif +#ifdef CONFIG_ARCH_S5PCxx +# include <mach/s5pcxx-clocks.h> +#endif #endif /* __MACH_S3C_CLOCKS_H */ diff --git a/arch/arm/mach-samsung/include/mach/s3c-iomap.h b/arch/arm/mach-samsung/include/mach/s3c-iomap.h index 87919cc..d34ace4 100644 --- a/arch/arm/mach-samsung/include/mach/s3c-iomap.h +++ b/arch/arm/mach-samsung/include/mach/s3c-iomap.h @@ -22,3 +22,6 @@ #ifdef CONFIG_ARCH_S3C24xx # include <mach/s3c24xx-iomap.h> #endif +#ifdef CONFIG_ARCH_S5PCxx +# include <mach/s5pcxx-iomap.h> +#endif diff --git a/arch/arm/mach-samsung/include/mach/s5pcxx-clocks.h b/arch/arm/mach-samsung/include/mach/s5pcxx-clocks.h new file mode 100644 index 0000000..f9d49c5 --- /dev/null +++ b/arch/arm/mach-samsung/include/mach/s5pcxx-clocks.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +# define S5P_APLL 0x00 +# define S5P_MPLL 0x08 +# define S5P_EPLL 0x10 +# define S5P_VPLL 0x20 +# define S5P_xPLL_LOCK (S5P_CLOCK_POWER_BASE) +# define S5P_xPLL_CON (S5P_CLOCK_POWER_BASE + 0x100) +# define S5P_xPLL_CON0 (S5P_xPLL_CON) +# define S5P_xPLL_CON1 (S5P_xPLL_CON + 0x4) + +# define S5P_xPLLCON_GET_MDIV(x) (((x) >> 16) & 0x3ff) +# define S5P_xPLLCON_GET_PDIV(x) (((x) >> 8) & 0x3f) +# define S5P_xPLLCON_GET_SDIV(x) ((x) & 0x3) + +# define S5P_CLK_SRC0 (S5P_CLOCK_POWER_BASE + 0x200) +# define S5P_CLK_SRC1 (S5P_CLOCK_POWER_BASE + 0x204) +# define S5P_CLK_SRC2 (S5P_CLOCK_POWER_BASE + 0x208) +# define S5P_CLK_SRC3 (S5P_CLOCK_POWER_BASE + 0x20C) +# define S5P_CLK_SRC4 (S5P_CLOCK_POWER_BASE + 0x210) +# define S5P_CLK_SRC5 (S5P_CLOCK_POWER_BASE + 0x214) +# define S5P_CLK_SRC6 (S5P_CLOCK_BASE + 0x218) + +# define S5P_CLK_DIV0 (S5P_CLOCK_POWER_BASE + 0x300) +# define S5P_CLK_DIV1 (S5P_CLOCK_POWER_BASE + 0x304) +# define S5P_CLK_DIV2 (S5P_CLOCK_POWER_BASE + 0x308) +# define S5P_CLK_DIV3 (S5P_CLOCK_POWER_BASE + 0x30C) +# define S5P_CLK_DIV4 (S5P_CLOCK_POWER_BASE + 0x310) +# define S5P_CLK_DIV5 (S5P_CLOCK_POWER_BASE + 0x314) +# define S5P_CLK_DIV6 (S5P_CLOCK_POWER_BASE + 0x318) +# define S5P_CLK_DIV7 (S5P_CLOCK_POWER_BASE + 0x31C) + +# define S5P_CLK_GATE_SCLK (S5P_CLOCK_POWER_BASE + 0x444) +# define S5P_CLK_GATE_IP0 (S5P_CLOCK_POWER_BASE + 0x460) +# define S5P_CLK_GATE_IP1 (S5P_CLOCK_POWER_BASE + 0x464) +# define S5P_CLK_GATE_IP2 (S5P_CLOCK_POWER_BASE + 0x468) +# define S5P_CLK_GATE_IP3 (S5P_CLOCK_POWER_BASE + 0x46C) +# define S5P_CLK_GATE_IP4 (S5P_CLOCK_POWER_BASE + 0x470) +# define S5P_CLK_GATE_BLOCK (S5P_CLOCK_POWER_BASE + 0x480) +# define S5P_CLK_GATE_IP5 (S5P_CLOCK_POWER_BASE + 0x484) + +# define S5P_OTHERS (S5P_CLOCK_POWER_BASE + 0xE000) +# define S5P_USB_PHY_CONTROL (S5P_CLOCK_POWER_BASE + 0xE80C) diff --git a/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h b/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h new file mode 100644 index 0000000..cb05527 --- /dev/null +++ b/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + */ + +/* S5PV210 device base addresses */ + +#define S5P_CLOCK_POWER_BASE 0xE0100000 +#define S3C_GPIO_BASE 0xE0200000 +#define S3C_TIMER_BASE 0xE2500000 +#define S3C_WATCHDOG_BASE 0xE2700000 +#define S3C_UART_BASE 0xE2900000 +#define S3C_USB_HOST_BASE 0xEC200000 +#define S3C_NAND_BASE 0xB0E00000 + +/* external IO space */ +#define S3C_CS0_BASE 0x80000000 +#define S3C_CS1_BASE 0x88000000 +#define S3C_CS2_BASE 0x90000000 +#define S3C_CS3_BASE 0x98000000 +#define S3C_CS4_BASE 0xA0000000 +#define S3C_CS5_BASE 0xA8000000 + +#define S3C_SDRAM_BASE 0x20000000 +#define S3C_SDRAM_END (S3C_SDRAM_BASE + 0x60000000) + +#define S3C_UART1_BASE (S3C_UART_BASE) +#define S3C_UART1_SIZE 0x400 +#define S3C_UART2_BASE (S3C_UART_BASE + 0x400) +#define S3C_UART2_SIZE 0x400 +#define S3C_UART3_BASE (S3C_UART_BASE + 0x800) +#define S3C_UART3_SIZE 0x400 +#define S3C_UART_HAS_UBRDIVSLOT +#define S3C_UART_HAS_UINTM -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 4/7] S5P boot header and image generator 2012-05-18 9:43 ` [PATCHv4 0/7] S5PV210 support (upd.) Alexey Galakhov ` (2 preceding siblings ...) 2012-05-18 9:43 ` [PATCH 3/7] Add support for Samsung S5P architecture (S5PV210) Alexey Galakhov @ 2012-05-18 9:43 ` Alexey Galakhov 2012-05-18 9:43 ` [PATCHv4 5/7] S5P lowlevel clock init Alexey Galakhov ` (3 subsequent siblings) 7 siblings, 0 replies; 29+ messages in thread From: Alexey Galakhov @ 2012-05-18 9:43 UTC (permalink / raw) To: barebox; +Cc: Alexey Galakhov Signed-off-by: Alexey Galakhov <agalakhov@gmail.com> --- .gitignore | 2 + Makefile | 2 +- arch/arm/Makefile | 7 +++ scripts/Makefile | 1 + scripts/s5p_cksum.c | 140 +++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 scripts/s5p_cksum.c diff --git a/.gitignore b/.gitignore index 8e208e0..df0ed2c 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,7 @@ barebox.S barebox.bin barebox.srec barebox.netx +barebox.s5p barebox.map System.map Module.symvers @@ -63,3 +64,4 @@ cscope.* # patches *.patch scripts/gen_netx_image +scripts/s5p_cksum diff --git a/Makefile b/Makefile index 44b7dbd..91ded1b 100644 --- a/Makefile +++ b/Makefile @@ -1003,7 +1003,7 @@ CLEAN_DIRS += $(MODVERDIR) CLEAN_FILES += barebox System.map include/generated/barebox_default_env.h \ .tmp_version .tmp_barebox* barebox.bin barebox.map barebox.S \ .tmp_kallsyms* barebox_default_env* barebox.ldr \ - Doxyfile.version barebox.srec + Doxyfile.version barebox.srec barebox.s5p # Directories & files removed with 'make mrproper' MRPROPER_DIRS += include/config include2 usr/include diff --git a/arch/arm/Makefile b/arch/arm/Makefile index d0bfd71..40291aa 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -164,6 +164,13 @@ ifeq ($(machine-y),netx) KBUILD_IMAGE := barebox.netx endif +barebox.s5p: barebox.bin + $(Q)scripts/s5p_cksum barebox.bin barebox.s5p + +ifeq ($(CONFIG_ARCH_S5PCxx),y) +KBUILD_IMAGE := barebox.s5p +endif + MLO: barebox.bin @echo " IFT " $@ $(Q)scripts/omap_signGP barebox.bin $(TEXT_BASE) 1 diff --git a/scripts/Makefile b/scripts/Makefile index cb049fd..784d205 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -10,6 +10,7 @@ hostprogs-y += mkimage hostprogs-y += bareboxenv hostprogs-$(CONFIG_ARCH_NETX) += gen_netx_image hostprogs-$(CONFIG_ARCH_OMAP) += omap_signGP +hostprogs-$(CONFIG_ARCH_S5PCxx) += s5p_cksum always := $(hostprogs-y) $(hostprogs-m) diff --git a/scripts/s5p_cksum.c b/scripts/s5p_cksum.c new file mode 100644 index 0000000..7142532 --- /dev/null +++ b/scripts/s5p_cksum.c @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include <stddef.h> +#include <errno.h> + +#define DEFAULT_BUF_SIZE 8192 + +static int usage(const char* me) +{ + printf("Usage: %s <input> <output> [<bufsize]\n", me); + return 1; +} + +static void put32(uint8_t *ptr, uint32_t value) +{ + ptr[0] = value & 0xFF; + ptr[1] = (value >> 8) & 0xFF; + ptr[2] = (value >> 16) & 0xFF; + ptr[3] = (value >> 24) & 0xFF; +} + +static size_t safe_fread(void *buf, size_t len, FILE* file) +{ + size_t rd = fread(buf, 1, len, file); + if (! rd) { + if (ferror(file)) + fprintf(stderr, "Error reading file: %s\n", strerror(errno)); + else + fprintf(stderr, "Unexpected end of file\n"); + } + return rd; +} + +static size_t safe_fwrite(const void *buf, size_t len, FILE* file) +{ + size_t wr = fwrite(buf, 1, len, file); + if (wr != len) { + fprintf(stderr, "Error writing file: %s\n", strerror(errno)); + return 0; + } + return wr; +} + +static int process(FILE *input, FILE *output, uint8_t *buf, unsigned bufsize) +{ + size_t rd; + unsigned i; + uint32_t cksum; + /* Read first chunk */ + rd = safe_fread(buf + 16, bufsize - 16, input); + if (! rd) + return 4; + /* Calculate header */ + put32(buf + 0, bufsize); + cksum = 0; + for (i = 16; i < bufsize; ++i) + cksum += (uint32_t)buf[i]; + put32(buf + 8, cksum); + if (! safe_fwrite(buf, bufsize, output)) + return 4; + /* Copy the rest of file */ + while (! feof(input)) { + rd = safe_fread(buf, bufsize, input); + if (! rd) + return 4; + if (! safe_fwrite(buf, rd, output)) + return 4; + } + return 0; +} + +static int work(const char* me, const char *infile, const char *outfile, unsigned bufsize) +{ + uint8_t *buf; + FILE *input; + FILE *output; + int ret; + if (bufsize < 512 || bufsize > 65536) + return usage(me); + buf = calloc(1, bufsize); + if (! buf) { + fprintf(stderr, "Unable to allocate %u bytes of memory\n", bufsize); + return 2; + } + input = fopen(infile, "r"); + if (! input) { + fprintf(stderr, "Cannot open `%s' for reading\n", infile); + free(buf); + return 3; + } + output = fopen(outfile, "w"); + if (! output) { + fprintf(stderr, "Cannot open `%s' for writing\n", outfile); + fclose(input); + free(buf); + return 3; + } + + ret = process(input, output, buf, bufsize); + + fclose(output); + fclose(input); + free(buf); + return ret; +} + +int main(int argc, char** argv) +{ + switch (argc) { + case 3: + return work(argv[0], argv[1], argv[2], DEFAULT_BUF_SIZE); + case 4: + return work(argv[0], argv[1], argv[2], atoi(argv[3])); + default: + return usage(argv[0]); + } +} -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCHv4 5/7] S5P lowlevel clock init 2012-05-18 9:43 ` [PATCHv4 0/7] S5PV210 support (upd.) Alexey Galakhov ` (3 preceding siblings ...) 2012-05-18 9:43 ` [PATCH 4/7] S5P boot header and image generator Alexey Galakhov @ 2012-05-18 9:43 ` Alexey Galakhov 2012-05-18 9:43 ` [PATCHv4 6/7] S5P DRAM support Alexey Galakhov ` (2 subsequent siblings) 7 siblings, 0 replies; 29+ messages in thread From: Alexey Galakhov @ 2012-05-18 9:43 UTC (permalink / raw) To: barebox; +Cc: Alexey Galakhov Signed-off-by: Alexey Galakhov <agalakhov@gmail.com> --- arch/arm/mach-samsung/Makefile | 1 + arch/arm/mach-samsung/include/mach/s3c-generic.h | 4 ++ arch/arm/mach-samsung/lowlevel-s5pcxx.c | 61 ++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 arch/arm/mach-samsung/lowlevel-s5pcxx.c diff --git a/arch/arm/mach-samsung/Makefile b/arch/arm/mach-samsung/Makefile index 0b95e14..d7344c8 100644 --- a/arch/arm/mach-samsung/Makefile +++ b/arch/arm/mach-samsung/Makefile @@ -1,5 +1,6 @@ obj-y += s3c-timer.o generic.o obj-lowlevel-$(CONFIG_ARCH_S3C24xx) += lowlevel-s3c24x0.o +obj-lowlevel-$(CONFIG_ARCH_S5PCxx) += lowlevel-s5pcxx.o obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o s3c24xx-clocks.o mem-s3c24x0.o obj-$(CONFIG_ARCH_S5PCxx) += gpio-s5pcxx.o clocks-s5pcxx.o obj-$(CONFIG_S3C_LOWLEVEL_INIT) += $(obj-lowlevel-y) diff --git a/arch/arm/mach-samsung/include/mach/s3c-generic.h b/arch/arm/mach-samsung/include/mach/s3c-generic.h index 9d40ef8..11b083d 100644 --- a/arch/arm/mach-samsung/include/mach/s3c-generic.h +++ b/arch/arm/mach-samsung/include/mach/s3c-generic.h @@ -37,3 +37,7 @@ unsigned s3c_get_uart_clk(unsigned src); uint32_t s3c24xx_get_memory_size(void); void s3c24xx_disable_second_sdram_bank(void); #endif + +#ifdef CONFIG_ARCH_S5PCxx +void s5p_init_pll(void); +#endif diff --git a/arch/arm/mach-samsung/lowlevel-s5pcxx.c b/arch/arm/mach-samsung/lowlevel-s5pcxx.c new file mode 100644 index 0000000..15afa47 --- /dev/null +++ b/arch/arm/mach-samsung/lowlevel-s5pcxx.c @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * + * Based on code from u-boot found somewhere on the web + * that seems to originate from Samsung + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <config.h> +#include <common.h> +#include <io.h> +#include <init.h> +#include <mach/s3c-iomap.h> +#include <mach/s3c-clocks.h> +#include <mach/s3c-generic.h> + +#ifdef CONFIG_S3C_PLL_INIT +void __bare_init s5p_init_pll(void) +{ + uint32_t reg; + int i; + + /* Set Mux to FIN */ + writel(0, S5P_CLK_SRC0); + + writel(BOARD_APLL_LOCKTIME, S5P_xPLL_LOCK + S5P_APLL); + + /* Disable PLL */ + writel(0, S5P_xPLL_CON + S5P_APLL); + writel(0, S5P_xPLL_CON + S5P_MPLL); + + /* Set up dividers */ + reg = readl(S5P_CLK_DIV0); + reg &= ~(BOARD_CLK_DIV0_MASK); + reg |= (BOARD_CLK_DIV0_VAL); + writel(reg, S5P_CLK_DIV0); + + /* Set up PLLs */ + writel(BOARD_APLL_VAL, S5P_xPLL_CON + S5P_APLL); + writel(BOARD_MPLL_VAL, S5P_xPLL_CON + S5P_MPLL); + writel(BOARD_EPLL_VAL, S5P_xPLL_CON + S5P_EPLL); + writel(BOARD_VPLL_VAL, S5P_xPLL_CON + S5P_VPLL); + + /* Wait for sync */ + for (i = 0; i < 0x10000; ++i) + barrier(); + + reg = readl(S5P_CLK_SRC0); + reg |= 0x1111; /* switch MUX to PLL outputs */ + writel(reg, S5P_CLK_SRC0); +} +#endif /* CONFIG_S3C_PLL_INIT */ -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCHv4 6/7] S5P DRAM support 2012-05-18 9:43 ` [PATCHv4 0/7] S5PV210 support (upd.) Alexey Galakhov ` (4 preceding siblings ...) 2012-05-18 9:43 ` [PATCHv4 5/7] S5P lowlevel clock init Alexey Galakhov @ 2012-05-18 9:43 ` Alexey Galakhov 2012-05-21 20:02 ` Sascha Hauer 2012-05-18 9:43 ` [PATCHv4 7/7] Add FriendlyArm Tiny210 board (S5PV210) Alexey Galakhov 2012-05-21 20:00 ` [PATCHv4 0/7] S5PV210 support (upd.) Sascha Hauer 7 siblings, 1 reply; 29+ messages in thread From: Alexey Galakhov @ 2012-05-18 9:43 UTC (permalink / raw) To: barebox; +Cc: Alexey Galakhov Signed-off-by: Alexey Galakhov <agalakhov@gmail.com> --- arch/arm/mach-samsung/Makefile | 2 +- arch/arm/mach-samsung/include/mach/s3c-generic.h | 2 + arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h | 3 + arch/arm/mach-samsung/mem-s5pcxx.c | 260 +++++++++++++++++++++ 4 files changed, 266 insertions(+), 1 deletion(-) create mode 100644 arch/arm/mach-samsung/mem-s5pcxx.c diff --git a/arch/arm/mach-samsung/Makefile b/arch/arm/mach-samsung/Makefile index d7344c8..6020587 100644 --- a/arch/arm/mach-samsung/Makefile +++ b/arch/arm/mach-samsung/Makefile @@ -2,5 +2,5 @@ obj-y += s3c-timer.o generic.o obj-lowlevel-$(CONFIG_ARCH_S3C24xx) += lowlevel-s3c24x0.o obj-lowlevel-$(CONFIG_ARCH_S5PCxx) += lowlevel-s5pcxx.o obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o s3c24xx-clocks.o mem-s3c24x0.o -obj-$(CONFIG_ARCH_S5PCxx) += gpio-s5pcxx.o clocks-s5pcxx.o +obj-$(CONFIG_ARCH_S5PCxx) += gpio-s5pcxx.o clocks-s5pcxx.o mem-s5pcxx.o obj-$(CONFIG_S3C_LOWLEVEL_INIT) += $(obj-lowlevel-y) diff --git a/arch/arm/mach-samsung/include/mach/s3c-generic.h b/arch/arm/mach-samsung/include/mach/s3c-generic.h index 11b083d..c26b82e 100644 --- a/arch/arm/mach-samsung/include/mach/s3c-generic.h +++ b/arch/arm/mach-samsung/include/mach/s3c-generic.h @@ -40,4 +40,6 @@ void s3c24xx_disable_second_sdram_bank(void); #ifdef CONFIG_ARCH_S5PCxx void s5p_init_pll(void); +void s5p_init_dram_bank(uint32_t base, uint32_t mc0, uint32_t mc1); +uint32_t s5p_get_memory_size(void); #endif diff --git a/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h b/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h index cb05527..248f868 100644 --- a/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h +++ b/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h @@ -47,3 +47,6 @@ #define S3C_UART3_SIZE 0x400 #define S3C_UART_HAS_UBRDIVSLOT #define S3C_UART_HAS_UINTM + +#define S5P_DMC0_BASE 0xF0000000 +#define S5P_DMC1_BASE 0xF1400000 diff --git a/arch/arm/mach-samsung/mem-s5pcxx.c b/arch/arm/mach-samsung/mem-s5pcxx.c new file mode 100644 index 0000000..2f13d12 --- /dev/null +++ b/arch/arm/mach-samsung/mem-s5pcxx.c @@ -0,0 +1,260 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * + * Based on code from u-boot found somewhere on the web + * that seems to originate from Samsung + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <config.h> +#include <common.h> +#include <io.h> +#include <init.h> +#include <mach/s3c-generic.h> +#include <mach/s3c-iomap.h> + +#define S5P_DMC_CONCONTROL 0x00 +#define S5P_DMC_MEMCONTROL 0x04 +#define S5P_DMC_MEMCONFIG0 0x08 +#define S5P_DMC_MEMCONFIG1 0x0C +#define S5P_DMC_DIRECTCMD 0x10 +#define S5P_DMC_PRECHCONFIG 0x14 +#define S5P_DMC_PHYCONTROL0 0x18 +#define S5P_DMC_PHYCONTROL1 0x1C +#define S5P_DMC_PWRDNCONFIG 0x28 +#define S5P_DMC_TIMINGAREF 0x30 +#define S5P_DMC_TIMINGROW 0x34 +#define S5P_DMC_TIMINGDATA 0x38 +#define S5P_DMC_TIMINGPOWER 0x3C +#define S5P_DMC_PHYSTATUS 0x40 + +/* DRAM commands */ +#define CMD(x) ((x) << 24) +#define BANK(x) ((x) << 16) +#define CHIP(x) ((x) << 20) +#define ADDR(x) (x) + +/** + * MR definition: + * 1 11 + * 2 1098 7654 3210 + * | | ^^^- burst length, 010=4, 011=8 + * | | ^- burst type 0=sequnential, 1=interleaved + * | ^^^-- CAS latency + * | ^----- test, 0=normal, 1=test + * |^---- DLL reset, 1=yes + * ^^^----- WR, 1=2, 2=3 etc. + * ^------- PD, 0=fast exit, 1=low power + * + * EMR1 definition: + * 1 11 + * 2 1098 7654 3210 + * | ^- DLL, 0=enable + * | ^-- output strength, 0=full, 1=reduced + * |^.. .^--- Rtt, 00=off, 01=75, 10=150, 11=50 Ohm + * | ^^ ^-- Posted CAS# AL, 0-6 + * ^^ ^------ OCD: 000=OCD exit, 111=enable defaults + * ^------ DQS#, 0=enable, 1=disable + * ^------- RDQS enable, 0=no, 1=yes + * ^-------- outputs, 0=enabled, 1=disabled + * + * EMR2 definition: + * bit 7 + * 1 1 + * 2 1098 7654 3210 + * ^-- SRT, 0=1x (0-85 deg.C), 1=2x (>85 deg.C) + * all other bits = 0 + * + * EMR3 definition: all bits 0 + */ + +#define MRS CMD(0x0) +#define PALL CMD(0x1) +#define PRE CMD(0x2) +#define DPD CMD(0x3) +#define REFS CMD(0x4) +#define REFA CMD(0x5) +#define CKEL CMD(0x6) +#define NOP CMD(0x7) +#define REFSX CMD(0x8) +#define MRR CMD(0x9) + +#define EMRS1 (MRS | BANK(1)) +#define EMRS2 (MRS | BANK(2)) +#define EMRS3 (MRS | BANK(3)) + +/* Burst is (1 << S5P_DRAM_BURST), i.e. S5P_DRAM_BURST=2 for burst 4 */ +#ifndef S5P_DRAM_BURST +/* (LP)DDR2 supports burst 4 only, make it default */ +# define S5P_DRAM_BURST 2 +#endif + +/** + * Initialization sequences for different kinds of DRAM + */ +#define dcmd(x) writel((x) | CHIP(chip), base + S5P_DMC_DIRECTCMD) + +/* TODO: LPDDR and LPDDR2 */ + +#ifdef S5P_DRAM_DDR2 +static void __bare_init init_seq(uint32_t base, unsigned chip) +{ + const uint32_t emr = 0x400; /* DQS disable */ + const uint32_t mr = (((S5P_DRAM_WR) - 1) << 9) + | ((S5P_DRAM_CAS) << 4) + | (S5P_DRAM_BURST); + dcmd(NOP); + /* FIXME wait here? */ + dcmd(PALL); dcmd(EMRS2); dcmd(EMRS3); + dcmd(EMRS1 | ADDR(emr)); /* DQS disable */ + dcmd(MRS | ADDR(mr | 0x100)); /* DLL reset */ + dcmd(PALL); dcmd(REFA); dcmd(REFA); + dcmd(MRS | ADDR(mr)); /* DLL no reset */ + dcmd(EMRS1 | ADDR(emr | 0x380)); /* OCD defaults */ + dcmd(EMRS1 | ADDR(emr)); /* OCD exit */ +} +#endif + +#undef dcmd + + +static inline void __bare_init start_dll(uint32_t base) +{ + uint32_t pc0 = 0x00101000; /* the only legal initial value */ + uint32_t lv; + /* Init DLL */ + writel(pc0, base + S5P_DMC_PHYCONTROL0); +#ifdef S5P_DRAM_DDR2 + /* refcount 8, 180 deg. shift */ + writel(0x00000086, base + S5P_DMC_PHYCONTROL1); +#else + /* refcount 8, 90 deg. shift */ + writel(0x00000085, base + S5P_DMC_PHYCONTROL1); +#endif + /* DLL on */ + pc0 |= 0x2; + writel(pc0, base + S5P_DMC_PHYCONTROL0); + /* DLL start */ + pc0 |= 0x1; + writel(pc0, base + S5P_DMC_PHYCONTROL0); + + /* Find lock val */ + do { + lv = readl(base + S5P_DMC_PHYSTATUS); + } while ((lv & 0x7) != 0x7); + + lv >>= 6; + lv &= 0xff; /* ctrl_lock_value[9:2] - coarse */ + pc0 |= (lv << 24); /* ctrl_force */ + writel(pc0, base + S5P_DMC_PHYCONTROL0); /* force value locking */ +} + + + +void __bare_init s5p_init_dram_bank(uint32_t base, uint32_t mc0, uint32_t mc1) +{ +#ifdef S5P_DRAM_LPDDR + uint32_t reg = 0x100; +#endif +#ifdef S5P_DRAM_LPDDR2 + uint32_t reg = 0x200; +#endif +#ifdef S5P_DRAM_DDR2 + uint32_t reg = 0x400; +#endif + reg |= (S5P_DRAM_BURST) << 20; +#ifdef S5P_DRAM_16BIT + reg |= 0x1000; +#else /* 32-bit */ + reg |= 0x2000; +#endif + if (mc1) + reg |= 0x10000; /* two chips */ + + start_dll(base); + writel(reg, base + S5P_DMC_MEMCONTROL); + + /* Set up memory layout */ + writel(mc0, base + S5P_DMC_MEMCONFIG0); + if (mc1) + writel(mc1, base + S5P_DMC_MEMCONFIG1); + /* Open page precharge policy - reasonable defaults */ + writel(0xFF000000, base + S5P_DMC_PRECHCONFIG); + /* Set up timings */ + writel(DMC_TIMING_AREF, base + S5P_DMC_TIMINGAREF); + writel(DMC_TIMING_ROW, base + S5P_DMC_TIMINGROW); + writel(DMC_TIMING_DATA, base + S5P_DMC_TIMINGDATA); + writel(DMC_TIMING_PWR, base + S5P_DMC_TIMINGPOWER); + + /* Start-Up Commands */ + init_seq(base, 0); + if (mc1) + init_seq(base, 1); + + /* Reasonable defaults and auto-refresh on */ + writel(0x0FFF1070, base + S5P_DMC_CONCONTROL); + /* Reasonable defaults */ + writel(0xFFFF00FF, base + S5P_DMC_PWRDNCONFIG); +} + + +#define BANK_ENABLED(base) (readl((base) + S5P_DMC_PHYCONTROL0) & 1) +#define NUM_EXTRA_CHIPS(base) ((readl((base) + S5P_DMC_MEMCONTROL) >> 16) & 0xF) + +#define BANK_START(x) ((x) & 0xFF000000) +#define BANK_END(x) (BANK_START(x) | ~(((x) & 0x00FF0000) << 8)) +#define BANK_LEN(x) (BANK_END(x) - BANK_START(x) + 1) + +static inline void sortswap(uint32_t *x, uint32_t *y) +{ + if (*y < *x) { + *x ^= *y; + *y ^= *x; + *x ^= *y; + } +} + +uint32_t s5p_get_memory_size(void) +{ + int i; + uint32_t len; + uint32_t mc[4] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; + /* Read MEMCONFIG registers */ + if (BANK_ENABLED(S5P_DMC0_BASE)) { + mc[0] = readl(S5P_DMC0_BASE + S5P_DMC_MEMCONFIG0); + if (NUM_EXTRA_CHIPS(S5P_DMC0_BASE) > 0) + mc[1] = readl(S5P_DMC0_BASE + S5P_DMC_MEMCONFIG1); + } + if (BANK_ENABLED(S5P_DMC1_BASE)) { + mc[2] = readl(S5P_DMC1_BASE + S5P_DMC_MEMCONFIG0); + if (NUM_EXTRA_CHIPS(S5P_DMC1_BASE) > 0) + mc[3] = readl(S5P_DMC1_BASE + S5P_DMC_MEMCONFIG1); + } + /* Sort using a sorting network */ + sortswap(mc + 0, mc + 2); + sortswap(mc + 1, mc + 3); + sortswap(mc + 0, mc + 1); + sortswap(mc + 2, mc + 3); + sortswap(mc + 1, mc + 2); + /* Is at least one chip enabled? */ + if (mc[0] == 0xFFFFFFFF) + return 0; + /* Determine maximum continuous region at start */ + len = BANK_LEN(mc[0]); + for (i = 1; i < 4; ++i) { + if (BANK_START(mc[i]) == BANK_END(mc[i - 1]) + 1) + len += BANK_LEN(mc[i]); + else + break; + } + return len; +} -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCHv4 6/7] S5P DRAM support 2012-05-18 9:43 ` [PATCHv4 6/7] S5P DRAM support Alexey Galakhov @ 2012-05-21 20:02 ` Sascha Hauer 2012-05-22 9:17 ` Alexey Galakhov 0 siblings, 1 reply; 29+ messages in thread From: Sascha Hauer @ 2012-05-21 20:02 UTC (permalink / raw) To: Alexey Galakhov; +Cc: barebox On Fri, May 18, 2012 at 03:43:30PM +0600, Alexey Galakhov wrote: > +void __bare_init s5p_init_dram_bank(uint32_t base, uint32_t mc0, uint32_t mc1) > +{ > +#ifdef S5P_DRAM_LPDDR > + uint32_t reg = 0x100; > +#endif > +#ifdef S5P_DRAM_LPDDR2 > + uint32_t reg = 0x200; > +#endif > +#ifdef S5P_DRAM_DDR2 > + uint32_t reg = 0x400; > +#endif > + reg |= (S5P_DRAM_BURST) << 20; > +#ifdef S5P_DRAM_16BIT > + reg |= 0x1000; > +#else /* 32-bit */ > + reg |= 0x2000; > +#endif Since this function is called from board specific code, can we pass in the DDR/DDR2 16BIT/32BIT settings as arguments to this function and get rid of these ifdefs? Sascha -- 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 barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCHv4 6/7] S5P DRAM support 2012-05-21 20:02 ` Sascha Hauer @ 2012-05-22 9:17 ` Alexey Galakhov 2012-05-22 18:29 ` Sascha Hauer 0 siblings, 1 reply; 29+ messages in thread From: Alexey Galakhov @ 2012-05-22 9:17 UTC (permalink / raw) To: Sascha Hauer; +Cc: barebox On 22.05.2012 02:02, Sascha Hauer wrote: > On Fri, May 18, 2012 at 03:43:30PM +0600, Alexey Galakhov wrote: >> +void __bare_init s5p_init_dram_bank(uint32_t base, uint32_t mc0, uint32_t mc1) >> +{ >> +#ifdef S5P_DRAM_LPDDR >> + uint32_t reg = 0x100; >> +#endif >> +#ifdef S5P_DRAM_LPDDR2 >> + uint32_t reg = 0x200; >> +#endif >> +#ifdef S5P_DRAM_DDR2 >> + uint32_t reg = 0x400; >> +#endif >> + reg |= (S5P_DRAM_BURST) << 20; >> +#ifdef S5P_DRAM_16BIT >> + reg |= 0x1000; >> +#else /* 32-bit */ >> + reg |= 0x2000; >> +#endif > > Since this function is called from board specific code, can we pass in > the DDR/DDR2 16BIT/32BIT settings as arguments to this function and > get rid of these ifdefs? > > Sascha Thank you for the question. Most likely not. According to the datasheet, LPDDR/LPDDR2/DDR2 initialization sequence is completely different. It is in init_seq() function. Since I have no LPDDR(2) hardware to test, I coded the DDR2 version only. A runtime switch like that: switch(mode) { case LPDDR: lpddr_init_seq(); break; case LPDDR2: lpddr2_init_seq(); break; case DDR2: ddr2_init_seq(); break; } is too expensive for S5PV210's __bare_init which is very limited in space. Thus it is better to have only one function compiled in. Of course, it is possible to get rid of #ifdefs in s5p_init_dram_bank() but #ifdef is still needed for init_seq(). Ot is there any better solution? Regards, -- Alex _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCHv4 6/7] S5P DRAM support 2012-05-22 9:17 ` Alexey Galakhov @ 2012-05-22 18:29 ` Sascha Hauer 2012-05-22 19:12 ` Alexey Galakhov 0 siblings, 1 reply; 29+ messages in thread From: Sascha Hauer @ 2012-05-22 18:29 UTC (permalink / raw) To: Alexey Galakhov; +Cc: barebox On Tue, May 22, 2012 at 03:17:32PM +0600, Alexey Galakhov wrote: > On 22.05.2012 02:02, Sascha Hauer wrote: > > On Fri, May 18, 2012 at 03:43:30PM +0600, Alexey Galakhov wrote: > >> +void __bare_init s5p_init_dram_bank(uint32_t base, uint32_t mc0, uint32_t mc1) > >> +{ > >> +#ifdef S5P_DRAM_LPDDR > >> + uint32_t reg = 0x100; > >> +#endif > >> +#ifdef S5P_DRAM_LPDDR2 > >> + uint32_t reg = 0x200; > >> +#endif > >> +#ifdef S5P_DRAM_DDR2 > >> + uint32_t reg = 0x400; > >> +#endif > >> + reg |= (S5P_DRAM_BURST) << 20; > >> +#ifdef S5P_DRAM_16BIT > >> + reg |= 0x1000; > >> +#else /* 32-bit */ > >> + reg |= 0x2000; > >> +#endif > > > > Since this function is called from board specific code, can we pass in > > the DDR/DDR2 16BIT/32BIT settings as arguments to this function and > > get rid of these ifdefs? > > > > Sascha > > Thank you for the question. Most likely not. > > According to the datasheet, LPDDR/LPDDR2/DDR2 initialization sequence is > completely different. It is in init_seq() function. Since I have no > LPDDR(2) hardware to test, I coded the DDR2 version only. A runtime > switch like that: > > switch(mode) { > case LPDDR: > lpddr_init_seq(); > break; > case LPDDR2: > lpddr2_init_seq(); > break; > case DDR2: > ddr2_init_seq(); > break; > } > > is too expensive for S5PV210's __bare_init which is very limited in > space. Thus it is better to have only one function compiled in. I see. In this case you could provide a s5p_init_dram_bank_ddr2 which does the setup for ddr2 ram. The linker will then throw away any other eventually compiled in s5p_init_dram_bank_* function. Code common to all sdram setup functions could still be shared without overhead. Sascha -- 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 barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCHv4 6/7] S5P DRAM support 2012-05-22 18:29 ` Sascha Hauer @ 2012-05-22 19:12 ` Alexey Galakhov 0 siblings, 0 replies; 29+ messages in thread From: Alexey Galakhov @ 2012-05-22 19:12 UTC (permalink / raw) To: Sascha Hauer; +Cc: barebox > I see. In this case you could provide a s5p_init_dram_bank_ddr2 which > does the setup for ddr2 ram. The linker will then throw away any other > eventually compiled in s5p_init_dram_bank_* function. Code common to > all sdram setup functions could still be shared without overhead. > > Sascha Sounds good. Since all s5p_init_dram_bank_* share some common routines that should be quite easy. I'll do that. Regards, Alex _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCHv4 7/7] Add FriendlyArm Tiny210 board (S5PV210) 2012-05-18 9:43 ` [PATCHv4 0/7] S5PV210 support (upd.) Alexey Galakhov ` (5 preceding siblings ...) 2012-05-18 9:43 ` [PATCHv4 6/7] S5P DRAM support Alexey Galakhov @ 2012-05-18 9:43 ` Alexey Galakhov 2012-05-21 20:00 ` [PATCHv4 0/7] S5PV210 support (upd.) Sascha Hauer 7 siblings, 0 replies; 29+ messages in thread From: Alexey Galakhov @ 2012-05-18 9:43 UTC (permalink / raw) To: barebox; +Cc: Alexey Galakhov Signed-off-by: Alexey Galakhov <agalakhov@gmail.com> --- arch/arm/Makefile | 1 + arch/arm/boards/tiny210/Makefile | 1 + arch/arm/boards/tiny210/config.h | 21 +++++++ arch/arm/boards/tiny210/lowlevel.c | 76 ++++++++++++++++++++++++ arch/arm/boards/tiny210/tiny210.c | 113 ++++++++++++++++++++++++++++++++++++ arch/arm/configs/tiny210_defconfig | 17 ++++++ arch/arm/mach-samsung/Kconfig | 7 +++ 7 files changed, 236 insertions(+) create mode 100644 arch/arm/boards/tiny210/Makefile create mode 100644 arch/arm/boards/tiny210/config.h create mode 100644 arch/arm/boards/tiny210/lowlevel.c create mode 100644 arch/arm/boards/tiny210/tiny210.c create mode 100644 arch/arm/configs/tiny210_defconfig diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 40291aa..fc29aca 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -133,6 +133,7 @@ board-$(CONFIG_MACH_TX25) := karo-tx25 board-$(CONFIG_MACH_TQMA53) := tqma53 board-$(CONFIG_MACH_TX51) := karo-tx51 board-$(CONFIG_MACH_MX6Q_ARM2) := freescale-mx6-arm2 +board-$(CONFIG_MACH_TINY210) := tiny210 machdirs := $(patsubst %,arch/arm/mach-%/,$(machine-y)) diff --git a/arch/arm/boards/tiny210/Makefile b/arch/arm/boards/tiny210/Makefile new file mode 100644 index 0000000..9c38e60 --- /dev/null +++ b/arch/arm/boards/tiny210/Makefile @@ -0,0 +1 @@ +obj-y += tiny210.o lowlevel.o diff --git a/arch/arm/boards/tiny210/config.h b/arch/arm/boards/tiny210/config.h new file mode 100644 index 0000000..5b0a3e6 --- /dev/null +++ b/arch/arm/boards/tiny210/config.h @@ -0,0 +1,21 @@ +#define S5PCXX_CLOCK_REFERENCE 24000000 + +#define set_pll(mdiv, pdiv, sdiv) (1<<31 | mdiv<<16 | pdiv<<8 | sdiv) + +#define BOARD_APLL_VAL set_pll(0x7d, 0x3, 0x1) +#define BOARD_MPLL_VAL set_pll(0x29b, 0xc, 0x1) +#define BOARD_EPLL_VAL set_pll(0x60, 0x6, 0x2) +#define BOARD_VPLL_VAL set_pll(0x6c, 0x6, 0x3) + +#define BOARD_CLK_DIV0_MASK 0xFFFFFFFF +#define BOARD_CLK_DIV0_VAL 0x14131440 +#define BOARD_APLL_LOCKTIME 0x2cf + +#define S5P_DRAM_DDR2 + +#define S5P_DRAM_WR 3 +#define S5P_DRAM_CAS 4 +#define DMC_TIMING_AREF 0x00000618 +#define DMC_TIMING_ROW 0x2B34438A +#define DMC_TIMING_DATA 0x24240000 +#define DMC_TIMING_PWR 0x0BDC0343 diff --git a/arch/arm/boards/tiny210/lowlevel.c b/arch/arm/boards/tiny210/lowlevel.c new file mode 100644 index 0000000..7dbdc69 --- /dev/null +++ b/arch/arm/boards/tiny210/lowlevel.c @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <config.h> +#include <common.h> +#include <init.h> +#include <io.h> +#include <asm/barebox-arm.h> +#include <asm/sections.h> +#include <mach/s3c-iomap.h> +#include <mach/s3c-clocks.h> +#include <mach/s3c-generic.h> + +/* + * iROM boot from MMC + * TODO: replace this by native boot + */ + +#define ADDR_V210_SDMMC_BASE 0xD0037488 +#define ADDR_CopySDMMCtoMem 0xD0037F98 + +#define RR(x) (*(volatile uint32_t*)(x)) + +int __bare_init s5p_irom_load_mmc(void *dest, uint32_t start_block, uint16_t block_count) +{ + typedef uint32_t (*func_t) (int32_t, uint32_t, uint16_t, uint32_t*, int8_t); + uint32_t chbase = RR(ADDR_V210_SDMMC_BASE); + func_t func = (func_t)RR(ADDR_CopySDMMCtoMem); + int chan = (chbase - 0xEB000000) >> 20; + if (chan != 0 && chan != 2) + return 0; + return func(chan, start_block, block_count, (uint32_t*)dest, 0) ? 1 : 0; +} + + +void __bare_init board_init_lowlevel(void) +{ + uint32_t r; + +#ifdef CONFIG_S3C_PLL_INIT + s5p_init_pll(); +#endif + + if (get_pc() < 0xD0000000) /* Are we running from iRAM? */ + return; /* No, we don't. */ + +#ifdef CONFIG_S3C_SDRAM_INIT + s5p_init_dram_bank(S5P_DMC0_BASE, 0x20E00323, 0); +#endif + + if (! s5p_irom_load_mmc((void*)TEXT_BASE - 16, 1, (barebox_image_size + 16 + 511) / 512)) + while (1) { } /* hang */ + + /* Jump to SDRAM */ + r = (unsigned)TEXT_BASE; + __asm__ __volatile__("mov pc, %0" : : "r"(r)); + while (1) { } /* hang */ +} diff --git a/arch/arm/boards/tiny210/tiny210.c b/arch/arm/boards/tiny210/tiny210.c new file mode 100644 index 0000000..1277649 --- /dev/null +++ b/arch/arm/boards/tiny210/tiny210.c @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * Based on Mini6410 code by Juergen Beisert + * + * Copyright (C) 2012 Juergen Beisert, Pengutronix + * + * In some ways inspired by code + * + * (C) Copyright 2002 + * Sysgo Real-Time Solutions, GmbH <www.elinos.com> + * Marius Groeger <mgroeger@sysgo.de> + * + * (C) Copyright 2002 + * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <common.h> +#include <driver.h> +#include <init.h> +#include <sizes.h> +#include <generated/mach-types.h> +#include <dm9000.h> +#include <gpio.h> +#include <led.h> +#include <io.h> +#include <nand.h> +#include <asm/armlinux.h> +#include <mach/s3c-iomap.h> +#include <mach/s3c-clocks.h> +#include <mach/s3c-generic.h> + + +static const unsigned pin_usage[] = { + /* TODO */ +}; + +static struct gpio_led leds[] = { + { + .gpio = GPJ20, + .led = { + .name = "led1", + } + }, { + .gpio = GPJ21, + .led = { + .name = "led2", + } + }, { + .gpio = GPJ22, + .led = { + .name = "led3", + } + }, { + .gpio = GPJ23, + .led = { + .name = "led4", + } + } +}; + +static int tiny210_mem_init(void) +{ + arm_add_mem_device("ram0", S3C_SDRAM_BASE, s5p_get_memory_size()); + return 0; +} +mem_initcall(tiny210_mem_init); + +static int tiny210_console_init(void) +{ + /* + * configure the UART1 right now, as barebox will + * start to send data immediately + */ + s3c_gpio_mode(GPA00_RXD0 | ENABLE_PU); + s3c_gpio_mode(GPA01_TXD0); + s3c_gpio_mode(GPA02_NCTS0 | ENABLE_PU); + s3c_gpio_mode(GPA03_NRTS0); + + add_generic_device("s3c_serial", -1, NULL, + S3C_UART1_BASE, S3C_UART1_SIZE, + IORESOURCE_MEM, NULL); + return 0; +} +console_initcall(tiny210_console_init); + +static int tiny210_devices_init(void) +{ + int i; + for (i = 0; i < ARRAY_SIZE(pin_usage); i++) + s3c_gpio_mode(pin_usage[i]); + + for (i = 0; i < ARRAY_SIZE(leds); i++) { + leds[i].active_low = 1; + gpio_direction_output(leds[i].gpio, leds[i].active_low); + led_gpio_register(&leds[i]); + } + + armlinux_set_bootparams((void*)S3C_SDRAM_BASE + 0x100); + armlinux_set_architecture(MACH_TYPE_MINI210); + + return 0; +} +device_initcall(tiny210_devices_init); diff --git a/arch/arm/configs/tiny210_defconfig b/arch/arm/configs/tiny210_defconfig new file mode 100644 index 0000000..e9708bf --- /dev/null +++ b/arch/arm/configs/tiny210_defconfig @@ -0,0 +1,17 @@ +CONFIG_ARCH_S5PCxx=y +CONFIG_CPU_V7=y +CONFIG_CPU_32v7=y +CONFIG_BOARDINFO="Tiny 210" +CONFIG_ARCH_BAREBOX_MAX_BARE_INIT_SIZE=0x1ff0 +CONFIG_ARCH_SAMSUNG=y +CONFIG_CPU_S5PV210=y +CONFIG_MACH_TINY210=y +CONFIG_S3C_LOWLEVEL_INIT=y +CONFIG_S3C_PLL_INIT=y +CONFIG_S3C_SDRAM_INIT=y +CONFIG_CMD_LED=y +CONFIG_CMD_LED_TRIGGER=y +CONFIG_DRIVER_SERIAL_S3C=y +CONFIG_LED=y +CONFIG_LED_GPIO=y +CONFIG_LED_TRIGGERS=y diff --git a/arch/arm/mach-samsung/Kconfig b/arch/arm/mach-samsung/Kconfig index 65e2acb..a123854 100644 --- a/arch/arm/mach-samsung/Kconfig +++ b/arch/arm/mach-samsung/Kconfig @@ -8,11 +8,13 @@ config ARCH_TEXT_BASE default 0x31fc0000 if MACH_MINI2440 default 0x31fc0000 if MACH_A9M2440 default 0x31fc0000 if MACH_A9M2410 + default 0x23e00000 if MACH_TINY210 config BOARDINFO default "Mini 2440" if MACH_MINI2440 default "Digi A9M2440" if MACH_A9M2440 default "Digi A9M2410" if MACH_A9M2410 + default "Tiny 210" if MACH_TINY210 config ARCH_BAREBOX_MAX_BARE_INIT_SIZE hex @@ -96,6 +98,11 @@ choice prompt "S5PCxx board type" +config MACH_TINY210 + bool "Tiny 210" + select CPU_S5PV210 + select MACH_HAS_LOWLEVEL_INIT + select MACH_DO_LOWLEVEL_INIT endchoice -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCHv4 0/7] S5PV210 support (upd.) 2012-05-18 9:43 ` [PATCHv4 0/7] S5PV210 support (upd.) Alexey Galakhov ` (6 preceding siblings ...) 2012-05-18 9:43 ` [PATCHv4 7/7] Add FriendlyArm Tiny210 board (S5PV210) Alexey Galakhov @ 2012-05-21 20:00 ` Sascha Hauer 2012-05-22 9:18 ` Alexey Galakhov 7 siblings, 1 reply; 29+ messages in thread From: Sascha Hauer @ 2012-05-21 20:00 UTC (permalink / raw) To: Alexey Galakhov; +Cc: barebox Hi Alexey, Finally applied this series up to 5/7, see comment there. Thanks Sascha On Fri, May 18, 2012 at 03:43:24PM +0600, Alexey Galakhov wrote: > Removed function renaming (s3c24xx_get_memory_size). > Everything else is left untouched and only reflects the > above change. > > Alexey Galakhov (7): > Make S3C24xx config options available for all S3Cs > Split S3C generic and S3C24xx specific code > Add support for Samsung S5P architecture (S5PV210) > S5P boot header and image generator > S5P lowlevel clock init > S5P DRAM support > Add FriendlyArm Tiny210 board (S5PV210) > > .gitignore | 2 + > Makefile | 2 +- > arch/arm/Kconfig | 6 + > arch/arm/Makefile | 8 + > arch/arm/boards/a9m2410/a9m2410.c | 2 +- > arch/arm/boards/a9m2410/config.h | 2 +- > arch/arm/boards/a9m2410/lowlevel_init.S | 2 +- > arch/arm/boards/a9m2440/a9m2440.c | 2 +- > arch/arm/boards/a9m2440/config.h | 2 +- > arch/arm/boards/a9m2440/lowlevel_init.S | 2 +- > arch/arm/boards/mini2440/config.h | 2 +- > arch/arm/boards/mini2440/lowlevel_init.S | 2 +- > arch/arm/boards/mini2440/mini2440.c | 2 +- > arch/arm/boards/tiny210/Makefile | 1 + > arch/arm/boards/tiny210/config.h | 21 + > arch/arm/boards/tiny210/lowlevel.c | 76 ++ > arch/arm/boards/tiny210/tiny210.c | 113 +++ > arch/arm/configs/a9m2410_defconfig | 2 +- > arch/arm/configs/a9m2440_defconfig | 4 +- > arch/arm/configs/mini2440_defconfig | 2 +- > arch/arm/configs/tiny210_defconfig | 17 + > arch/arm/mach-samsung/Kconfig | 57 +- > arch/arm/mach-samsung/Makefile | 7 +- > arch/arm/mach-samsung/clocks-s5pcxx.c | 98 +++ > arch/arm/mach-samsung/generic.c | 113 --- > arch/arm/mach-samsung/gpio-s5pcxx.c | 123 +++ > arch/arm/mach-samsung/include/mach/gpio.h | 3 + > arch/arm/mach-samsung/include/mach/iomux-s5pcxx.h | 798 ++++++++++++++++++++ > arch/arm/mach-samsung/include/mach/s3c-clocks.h | 25 +- > arch/arm/mach-samsung/include/mach/s3c-generic.h | 9 +- > arch/arm/mach-samsung/include/mach/s3c-iomap.h | 56 +- > .../arm/mach-samsung/include/mach/s3c24xx-clocks.h | 24 + > arch/arm/mach-samsung/include/mach/s3c24xx-gpio.h | 6 +- > arch/arm/mach-samsung/include/mach/s3c24xx-iomap.h | 69 ++ > arch/arm/mach-samsung/include/mach/s3c24xx-nand.h | 2 +- > arch/arm/mach-samsung/include/mach/s5pcxx-clocks.h | 55 ++ > arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h | 52 ++ > arch/arm/mach-samsung/lowlevel-init.S | 317 -------- > arch/arm/mach-samsung/lowlevel-s3c24x0.S | 317 ++++++++ > arch/arm/mach-samsung/lowlevel-s5pcxx.c | 61 ++ > arch/arm/mach-samsung/mem-s3c24x0.c | 143 ++++ > arch/arm/mach-samsung/mem-s5pcxx.c | 260 +++++++ > drivers/mtd/nand/nand_s3c24xx.c | 10 +- > scripts/Makefile | 1 + > scripts/s5p_cksum.c | 140 ++++ > 45 files changed, 2487 insertions(+), 531 deletions(-) > create mode 100644 arch/arm/boards/tiny210/Makefile > create mode 100644 arch/arm/boards/tiny210/config.h > create mode 100644 arch/arm/boards/tiny210/lowlevel.c > create mode 100644 arch/arm/boards/tiny210/tiny210.c > create mode 100644 arch/arm/configs/tiny210_defconfig > create mode 100644 arch/arm/mach-samsung/clocks-s5pcxx.c > create mode 100644 arch/arm/mach-samsung/gpio-s5pcxx.c > create mode 100644 arch/arm/mach-samsung/include/mach/iomux-s5pcxx.h > create mode 100644 arch/arm/mach-samsung/include/mach/s3c24xx-clocks.h > create mode 100644 arch/arm/mach-samsung/include/mach/s3c24xx-iomap.h > create mode 100644 arch/arm/mach-samsung/include/mach/s5pcxx-clocks.h > create mode 100644 arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h > delete mode 100644 arch/arm/mach-samsung/lowlevel-init.S > create mode 100644 arch/arm/mach-samsung/lowlevel-s3c24x0.S > create mode 100644 arch/arm/mach-samsung/lowlevel-s5pcxx.c > create mode 100644 arch/arm/mach-samsung/mem-s3c24x0.c > create mode 100644 arch/arm/mach-samsung/mem-s5pcxx.c > create mode 100644 scripts/s5p_cksum.c > > -- > 1.7.10 > > > _______________________________________________ > barebox mailing list > barebox@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/barebox > -- 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 barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCHv4 0/7] S5PV210 support (upd.) 2012-05-21 20:00 ` [PATCHv4 0/7] S5PV210 support (upd.) Sascha Hauer @ 2012-05-22 9:18 ` Alexey Galakhov 0 siblings, 0 replies; 29+ messages in thread From: Alexey Galakhov @ 2012-05-22 9:18 UTC (permalink / raw) To: Sascha Hauer; +Cc: barebox On 22.05.2012 02:00, Sascha Hauer wrote: > Hi Alexey, > > Finally applied this series up to 5/7, see comment there. Thank you! Alex _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 3/7] Add support for Samsung S5P architecture (S5PV210) 2012-05-15 13:20 [PATCHv3 0/7] Cleaned up version of S5PV210 code Alexey Galakhov 2012-05-15 13:20 ` [PATCH 1/7] Make S3C24xx config options available for all S3Cs Alexey Galakhov 2012-05-15 13:20 ` [PATCH 2/7] Split S3C generic and S3C24xx specific code Alexey Galakhov @ 2012-05-15 13:20 ` Alexey Galakhov 2012-05-15 13:20 ` [PATCH 4/7] S5P boot header and image generator Alexey Galakhov ` (3 subsequent siblings) 6 siblings, 0 replies; 29+ messages in thread From: Alexey Galakhov @ 2012-05-15 13:20 UTC (permalink / raw) To: barebox; +Cc: Alexey Galakhov Signed-off-by: Alexey Galakhov <agalakhov@gmail.com> --- arch/arm/Kconfig | 6 + arch/arm/mach-samsung/Kconfig | 22 + arch/arm/mach-samsung/Makefile | 1 + arch/arm/mach-samsung/clocks-s5pcxx.c | 98 +++ arch/arm/mach-samsung/gpio-s5pcxx.c | 123 +++ arch/arm/mach-samsung/include/mach/gpio.h | 3 + arch/arm/mach-samsung/include/mach/iomux-s5pcxx.h | 798 ++++++++++++++++++++ arch/arm/mach-samsung/include/mach/s3c-clocks.h | 3 + arch/arm/mach-samsung/include/mach/s3c-iomap.h | 3 + arch/arm/mach-samsung/include/mach/s5pcxx-clocks.h | 55 ++ arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h | 49 ++ 11 files changed, 1161 insertions(+) create mode 100644 arch/arm/mach-samsung/clocks-s5pcxx.c create mode 100644 arch/arm/mach-samsung/gpio-s5pcxx.c create mode 100644 arch/arm/mach-samsung/include/mach/iomux-s5pcxx.h create mode 100644 arch/arm/mach-samsung/include/mach/s5pcxx-clocks.h create mode 100644 arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 8a4e1a2..f465084 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -73,6 +73,12 @@ config ARCH_S3C24xx select CPU_ARM920T select GENERIC_GPIO +config ARCH_S5PCxx + bool "Samsung S5PC110, S5PV210" + select ARCH_SAMSUNG + select CPU_V7 + select GENERIC_GPIO + config ARCH_VERSATILE bool "ARM Versatile boards (ARM926EJ-S)" select CPU_ARM926T diff --git a/arch/arm/mach-samsung/Kconfig b/arch/arm/mach-samsung/Kconfig index 63c29ef..65e2acb 100644 --- a/arch/arm/mach-samsung/Kconfig +++ b/arch/arm/mach-samsung/Kconfig @@ -14,6 +14,10 @@ config BOARDINFO default "Digi A9M2440" if MACH_A9M2440 default "Digi A9M2410" if MACH_A9M2410 +config ARCH_BAREBOX_MAX_BARE_INIT_SIZE + hex + default 0x1ff0 if ARCH_S5PCxx + if ARCH_S3C24xx config CPU_S3C2410 @@ -80,6 +84,24 @@ endmenu endif +if ARCH_S5PCxx + +config CPU_S5PC110 + bool + +config CPU_S5PV210 + bool + +choice + + prompt "S5PCxx board type" + + +endchoice + +endif + + menu "S3C Features " config S3C_LOWLEVEL_INIT diff --git a/arch/arm/mach-samsung/Makefile b/arch/arm/mach-samsung/Makefile index bde707f..0b95e14 100644 --- a/arch/arm/mach-samsung/Makefile +++ b/arch/arm/mach-samsung/Makefile @@ -1,4 +1,5 @@ obj-y += s3c-timer.o generic.o obj-lowlevel-$(CONFIG_ARCH_S3C24xx) += lowlevel-s3c24x0.o obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o s3c24xx-clocks.o mem-s3c24x0.o +obj-$(CONFIG_ARCH_S5PCxx) += gpio-s5pcxx.o clocks-s5pcxx.o obj-$(CONFIG_S3C_LOWLEVEL_INIT) += $(obj-lowlevel-y) diff --git a/arch/arm/mach-samsung/clocks-s5pcxx.c b/arch/arm/mach-samsung/clocks-s5pcxx.c new file mode 100644 index 0000000..1f4790b --- /dev/null +++ b/arch/arm/mach-samsung/clocks-s5pcxx.c @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * Copyright (C) 2012 Juergen Beisert, Pengutronix + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <config.h> +#include <common.h> +#include <init.h> +#include <clock.h> +#include <io.h> +#include <mach/s3c-iomap.h> +#include <mach/s3c-generic.h> +#include <mach/s3c-clocks.h> + +static inline uint32_t clkdiv(uint32_t clk, unsigned bit, unsigned mask) +{ + uint32_t ratio = (readl(S5P_CLK_DIV0) >> bit) & mask; + return clk / (ratio + 1); +} + +uint32_t s3c_get_mpllclk(void) +{ + uint32_t m, p, s; + uint32_t reg = readl(S5P_xPLL_CON + S5P_MPLL); + m = (reg >> 16) & 0x3ff; + p = (reg >> 8) & 0x3f; + s = (reg >> 0) & 0x7; + return m * ((S5PCXX_CLOCK_REFERENCE) / (p << s)); +} + +uint32_t s3c_get_apllclk(void) +{ + uint32_t m, p, s; + uint32_t reg = readl(S5P_xPLL_CON + S5P_APLL); + m = (reg >> 16) & 0x3ff; + p = (reg >> 8) & 0x3f; + s = (reg >> 0) & 0x7; + s -= 1; + return m * ((S5PCXX_CLOCK_REFERENCE) / (p << s)); +} + +static uint32_t s5p_get_a2mclk(void) +{ + return clkdiv(s3c_get_apllclk(), 4, 0x7); +} + +static uint32_t s5p_get_moutpsysclk(void) +{ + if (readl(S5P_CLK_SRC0) & (1 << 24)) /* MUX_PSYS */ + return s5p_get_a2mclk(); + else + return s3c_get_mpllclk(); +} + +uint32_t s3c_get_hclk(void) +{ + return clkdiv(s5p_get_moutpsysclk(), 24, 0xf); +} + +uint32_t s3c_get_pclk(void) +{ + return clkdiv(s3c_get_hclk(), 28, 0x7); +} + +/* we are using the internal 'uclk1' as the UART source */ +static unsigned s3c_get_uart_clk_uclk1(void) +{ + unsigned clk = s3c_get_mpllclk(); /* TODO check for EPLL */ + unsigned uartpdiv = ((readl(S5P_CLK_DIV4) >> 16) & 0x3) + 1; /* TODO this is UART0 only */ + return clk / uartpdiv; +} + +unsigned s3c_get_uart_clk(unsigned src) { + return (src & 1) ? s3c_get_uart_clk_uclk1() : s3c_get_pclk(); +} + +int s5pcxx_dump_clocks(void) +{ + printf("refclk: %7d kHz\n", S5PCXX_CLOCK_REFERENCE / 1000); + printf("apll: %7d kHz\n", s3c_get_apllclk() / 1000); + printf("mpll: %7d kHz\n", s3c_get_mpllclk() / 1000); +/* printf("CPU: %7d kHz\n", s3c_get_cpuclk() / 1000); */ + printf("hclk: %7d kHz\n", s3c_get_hclk() / 1000); + printf("pclk: %7d kHz\n", s3c_get_pclk() / 1000); + return 0; +} + +late_initcall(s5pcxx_dump_clocks); diff --git a/arch/arm/mach-samsung/gpio-s5pcxx.c b/arch/arm/mach-samsung/gpio-s5pcxx.c new file mode 100644 index 0000000..604a63f --- /dev/null +++ b/arch/arm/mach-samsung/gpio-s5pcxx.c @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * Copyright (C) 2012 Juergen Beisert, Pengutronix + * + * This codes bases partially on code from the Linux kernel: + * + * Copyright 2008 Openmoko, Inc. + * Copyright 2008 Simtec Electronics + * http://armlinux.simtec.co.uk/ + * Ben Dooks <ben@simtec.co.uk> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <common.h> +#include <errno.h> +#include <io.h> +#include <gpio.h> +#include <mach/s3c-iomap.h> + +#define S3C_GPACON (S3C_GPIO_BASE) +#define S3C_GPADAT (S3C_GPIO_BASE + 0x04) +#define S3C_GPAPUD (S3C_GPIO_BASE + 0x08) + +static inline unsigned group_offset(unsigned group) +{ + return group * 0x20; +} + +void gpio_set_value(unsigned gpio, int value) +{ + unsigned group = GET_GROUP(gpio); + unsigned bit = GET_BIT(gpio); + unsigned offset = group_offset(group); + uint32_t reg; + + reg = readl(S3C_GPADAT + offset); + reg &= ~(1 << bit); + reg |= (!!value) << bit; + writel(reg, S3C_GPADAT + offset); +} + +int gpio_get_value(unsigned gpio) +{ + unsigned group = GET_GROUP(gpio); + unsigned bit = GET_BIT(gpio); + unsigned offset = group_offset(group); + uint32_t reg; + + /* value */ + reg = readl(S3C_GPADAT + offset); + + return !!(reg & (1 << bit)); +} + +int gpio_direction_input(unsigned gpio) +{ + unsigned group = GET_GROUP(gpio); + unsigned bit = GET_BIT(gpio); + unsigned offset = group_offset(group); + uint32_t reg; + + bit <<= 2; + reg = readl(S3C_GPACON + offset) & ~(0xf << bit); + writel(reg, S3C_GPACON + offset); + + return 0; +} + +int gpio_direction_output(unsigned gpio, int value) +{ + unsigned group = GET_GROUP(gpio); + unsigned bit = GET_BIT(gpio); + unsigned offset = group_offset(group); + uint32_t reg; + + gpio_set_value(gpio, value); + + bit <<= 2; + reg = readl(S3C_GPACON + offset) & ~(0xf << bit); + reg |= 0x1 << bit; + writel(reg, S3C_GPACON + offset); + + return 0; +} + + +/* 'gpio_mode' must be one of the 'GP?_*' macros */ +void s3c_gpio_mode(unsigned gpio_mode) +{ + unsigned group = GET_GROUP(gpio_mode); + unsigned bit = GET_BIT(gpio_mode); + unsigned func = GET_FUNC(gpio_mode); + unsigned offset = group_offset(group); + unsigned reg; + + bit <<= 1; + if (PUD_PRESENT(gpio_mode)) { + reg = readl(S3C_GPAPUD + offset); + reg &= ~(PUD_MASK << bit); + reg |= GET_PUD(gpio_mode) << bit; + writel(reg, S3C_GPAPUD + offset); + } + + bit <<= 1; + reg = readl(S3C_GPACON + offset) & ~(0xf << bit); + writel(reg | (func << bit), S3C_GPACON + offset); + + if (func == 1) { /* output? if yes, also set the initial value */ + reg = readl(S3C_GPADAT + offset) & ~(1 << (bit >> 2)); + reg |= GET_GPIOVAL(gpio_mode) << (bit >> 2); + writel(reg, S3C_GPADAT + offset); + } + +} diff --git a/arch/arm/mach-samsung/include/mach/gpio.h b/arch/arm/mach-samsung/include/mach/gpio.h index 3723394..4d7d217 100644 --- a/arch/arm/mach-samsung/include/mach/gpio.h +++ b/arch/arm/mach-samsung/include/mach/gpio.h @@ -16,6 +16,9 @@ #ifdef CONFIG_ARCH_S3C24xx # include <mach/iomux-s3c24x0.h> #endif +#ifdef CONFIG_ARCH_S5PCxx +# include <mach/iomux-s5pcxx.h> +#endif void gpio_set_value(unsigned, int); int gpio_direction_input(unsigned); diff --git a/arch/arm/mach-samsung/include/mach/iomux-s5pcxx.h b/arch/arm/mach-samsung/include/mach/iomux-s5pcxx.h new file mode 100644 index 0000000..0677de4 --- /dev/null +++ b/arch/arm/mach-samsung/include/mach/iomux-s5pcxx.h @@ -0,0 +1,798 @@ +/* + * Copyright (C) 2012 Juergen Beisert + * Copyright (C) 2012 Alexey Galakhov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +/* Tested with S5PV210 */ + +#ifndef __MACH_IOMUX_S5PCXX_H +# define __MACH_IOMUX_S5PCXX_H + +/* 3322222222221111111111 + * 10987654321098765432109876543210 + * ^^^^^^_ Bit offset + * ^^^^^_______ Group Number + * ^^^^____________ Function + * ^________________ initial GPIO out value + * ^_________________ Pull up/down feature present + * ^^__________________ initial pull up/down setting + */ + +#define PIN(group,bit) ((group << 6) + bit) +#define FUNC(x) (((x) & 0xf) << 11) +#define GET_FUNC(x) (((x) >> 11) & 0xf) +#define GET_GROUP(x) (((x) >> 6) & 0x1f) +#define GET_BIT(x) ((x) & 0x3f) +#define GET_GPIOVAL(x) (!!((x) & (1 << 15))) +#define GPIO_OUT (1 << 11) +#define GPIO_IN (0 << 11) +#define GPIO_VAL(x) ((!!(x)) << 15) +#define PUD_MASK 0x3 +#define PUD (1 << 16) +#define PUD_PRESENT(x) (!!((x) & (1 << 16))) +#define DISABLE_PUD (0 << 17) +#define ENABLE_PU (2 << 17) +#define ENABLE_PD (1 << 17) +#define GET_PUD(x) (((x) >> 17) & PUD_MASK) + +/* + * To have a chance for simple GPIO manipulation routines + * define the GPIO numbers with a real simple scheme. + * + * Keep in mind: The 'GPIO_2_NO' creates a value to be used with the real gpio + * routines and *not* for the multiplexer routines! + */ +#define GPIO_2_NO(x,y) (PIN(x,y)) + +/* + * Group A0: GPIO 0...7 + * Used GPIO: 0...7 + * These pins can also act as GPIO outputs + */ +#define GPA00 (PIN(0,0) | PUD) +#define GPA00_GPIO (GPA00 | FUNC(0)) +#define GPA00_RXD0 (GPA00 | FUNC(2)) +#define GPA01 (PIN(0,1) | PUD) +#define GPA01_GPIO (GPA01 | FUNC(0)) +#define GPA01_TXD0 (GPA01 | FUNC(2)) +#define GPA02 (PIN(0,2) | PUD) +#define GPA02_GPIO (GPA02 | FUNC(0)) +#define GPA02_NCTS0 (GPA02 | FUNC(2)) +#define GPA03 (PIN(0,3) | PUD) +#define GPA03_GPIO (GPA03 | FUNC(0)) +#define GPA03_NRTS0 (GPA03 | FUNC(2)) +#define GPA04 (PIN(0,4) | PUD) +#define GPA04_GPIO (GPA04 | FUNC(0)) +#define GPA04_RXD1 (GPA04 | FUNC(2)) +#define GPA05 (PIN(0,5) | PUD) +#define GPA05_GPIO (GPA05 | FUNC(0)) +#define GPA05_TXD1 (GPA05 | FUNC(2)) +#define GPA06 (PIN(0,6) | PUD) +#define GPA06_GPIO (GPA06 | FUNC(0)) +#define GPA06_NCTS1 (GPA06 | FUNC(2)) +#define GPA07 (PIN(0,7) | PUD) +#define GPA07_GPIO (GPA07 | FUNC(0)) +#define GPA07_NRTS1 (GPA07 | FUNC(2)) + +/* + * Group A1: GPIO 0..3 + * Used GPIO: 0..3 + * These pins can also act as GPIO outputs + */ +#define GPA10 (PIN(1,0) | PUD) +#define GPA10_GPIO (GPA10 | FUNC(0)) +#define GPA10_RXD2 (GPA10 | FUNC(2)) +#define GPA10_RXDAUD (GPA0 | FUNC(4)) +#define GPA11 (PIN(1,1) | PUD) +#define GPA11_GPIO (GPA11 | FUNC(0)) +#define GPA11_TXD2 (GPA11 | FUNC(2)) +#define GPA11_TXDAUD (GPA1 | FUNC(4)) +#define GPA12 (PIN(1,2) | PUD) +#define GPA12_GPIO (GPA12 | FUNC(0)) +#define GPA12_RXD3 (GPA12 | FUNC(2)) +#define GPA12_NCTS2 (GPA12 | FUNC(3)) +#define GPA13 (PIN(1,3) | PUD) +#define GPA13_GPIO (GPA13 | FUNC(0)) +#define GPA13_TXD3 (GPA13 | FUNC(2)) +#define GPA13_NRTS2 (GPA13 | FUNC(3)) + + +/* + * Group B: GPIO 0...7 + * Used GPIO: 0...7 + * These pins can also act as GPIO outputs + */ +#define GPB0 (PIN(2,0) | PUD) +#define GPB0_GPIO (GPB0 | FUNC(0)) +#define GPB0_SPI0_CLK (GPB0 | FUNC(2)) +#define GPB1 (PIN(2,1) | PUD) +#define GPB1_GPIO (GPB1 | FUNC(0)) +#define GPB1_SPI0_NCS (GPB1 | FUNC(2)) +#define GPB2 (PIN(2,2) | PUD) +#define GPB2_GPIO (GPB2 | FUNC(0)) +#define GPB2_SPI0_MISO (GPB2 | FUNC(2)) +#define GPB3 (PIN(2,3) | PUD) +#define GPB3_GPIO (GPB3 | FUNC(0)) +#define GPB3_SPI0_MOSI (GPB3 | FUNC(2)) +#define GPB4 (PIN(2,4) | PUD) +#define GPB4_GPIO (GPB4 | FUNC(0)) +#define GPB4_SPI1_CLK (GPB4 | FUNC(2)) +#define GPB5 (PIN(2,5) | PUD) +#define GPB5_GPIO (GPB5 | FUNC(0)) +#define GPB5_SPI1_NCS (GPB5 | FUNC(0)) +#define GPB6 (PIN(2,6) | PUD) +#define GPB6_GPIO (GPB6 | FUNC(0)) +#define GPB6_SPI1_MISO (GPB6 | FUNC(0)) +#define GPB7 (PIN(2,7) | PUD) +#define GPB7_GPIO (GPB7 | FUNC(0)) +#define GPB7_SPI1_MOSI (GPB7 | FUNC(0)) + +/* + * Group C0: GPIO 0...4 + */ +#define GPC00 (PIN(3,0) | PUD) +#define GPC00_GPIO (GPC00 | FUNC(0)) +#define GPC00_I2S1_SCLK (GPC00 | FUNC(2)) +#define GPC00_PCM1_SCLK (GPC00 | FUNC(3)) +#define GPC00_AC97_BITCLK (GPC00 | FUNC(4)) +#define GPC01 (PIN(3,1) | PUD) +#define GPC01_GPIO (GPC01 | FUNC(0)) +#define GPC01_I2S1_CDCLK (GPC01 | FUNC(2)) +#define GPC01_PCM1_EXTCLK (GPC01 | FUNC(3)) +#define GPC01_AC97_NRESET (GPC01 | FUNC(4)) +#define GPC02 (PIN(3,2) | PUD) +#define GPC02_GPIO (GPC02 | FUNC(0)) +#define GPC02_I2S1_LRCK (GPC02 | FUNC(2)) +#define GPC02_PCM1_FSYNC (GPC02 | FUNC(3)) +#define GPC02_AC97_SYNC (GPC02 | FUNC(4)) +#define GPC03 (PIN(3,3) | PUD) +#define GPC03_GPIO (GPC03 | FUNC(0)) +#define GPC03_I2S1_SDI (GPC03 | FUNC(2)) +#define GPC03_PCM1_SIN (GPC03 | FUNC(3)) +#define GPC03_AC97_SDI (GPC03 | FUNC(4)) +#define GPC04 (PIN(3,4) | PUD) +#define GPC04_GPIO (GPC04 | FUNC(0)) +#define GPC04_I2S1_SDO (GPC04 | FUNC(2)) +#define GPC04_PCM1_SOUT (GPC04 | FUNC(3)) +#define GPC04_AC97_SDO (GPC04 | FUNC(4)) + +/* + * Group C1: GPIO 0...4 + */ +#define GPC10 (PIN(4,0) | PUD) +#define GPC10_GPIO (GPC10 | FUNC(0)) +#define GPC10_PCM2_SCLK (GPC10 | FUNC(2)) +#define GPC10_SPDIF_0_OUT (GPC10 | FUNC(3)) +#define GPC10_I2S2_SCLK (GPC10 | FUNC(4)) +#define GPC11 (PIN(4,1) | PUD) +#define GPC11_GPIO (GPC11 | FUNC(0)) +#define GPC11_PCM2_EXTCLK (GPC11 | FUNC(2)) +#define GPC11_SPDIF_EXTCLK (GPC11 | FUNC(3)) +#define GPC11_I2S2_CDCLK (GPC11 | FUNC(4)) +#define GPC12 (PIN(4,2) | PUD) +#define GPC12_GPIO (GPC12 | FUNC(0)) +#define GPC12_PCM2_FSYNC (GPC12 | FUNC(2)) +#define GPC12_LCD_FRM (GPC12 | FUNC(3)) +#define GPC12_I2S2_LRCK (GPC12 | FUNC(4)) +#define GPC13 (PIN(4,3) | PUD) +#define GPC13_GPIO (GPC13 | FUNC(0)) +#define GPC13_PCM2_SIN (GPC13 | FUNC(2)) +#define GPC13_I2S2_SDI (GPC13 | FUNC(4)) +#define GPC14 (PIN(4,4) | PUD) +#define GPC14_GPIO (GPC14 | FUNC(0)) +#define GPC14_PCM2_SOUT (GPC14 | FUNC(2)) +#define GPC14_I2S2_SDO (GPC14 | FUNC(4)) + +/* + * Group D0: GPIO 0...3 + */ +#define GPD00 (PIN(5,0) | PUD) +#define GPD00_GPIO (GPD00 | FUNC(0)) +#define GPD00_TOUT_0 (GPD00 | FUNC(2)) +#define GPD01 (PIN(5,1) | PUD) +#define GPD01_GPIO (GPD01 | FUNC(0)) +#define GPD01_TOUT_1 (GPD01 | FUNC(2)) +#define GPD02 (PIN(5,2) | PUD) +#define GPD02_GPIO (GPD02 | FUNC(0)) +#define GPD02_TOUT_2 (GPD02 | FUNC(2)) +#define GPD03 (PIN(5,3) | PUD) +#define GPD03_GPIO (GPD03 | FUNC(0)) +#define GPD03_TOUT_3 (GPD03 | FUNC(2)) + +/* + * Group D1: GPIO 0...5 + */ +#define GPD10 (PIN(6,0) | PUD) +#define GPD10_GPIO (GPD10 | FUNC(0)) +#define GPD10_I2C0_SDA (GPD10 | FUNC(2)) +#define GPD11 (PIN(6,0) | PUD) +#define GPD11_GPIO (GPD11 | FUNC(0)) +#define GPD11_I2C0_SCL (GPD11 | FUNC(2)) +#define GPD12 (PIN(6,0) | PUD) +#define GPD12_GPIO (GPD12 | FUNC(0)) +#define GPD12_I2C1_SDA (GPD12 | FUNC(2)) +#define GPD13 (PIN(6,0) | PUD) +#define GPD13_GPIO (GPD13 | FUNC(0)) +#define GPD13_I2C1_SCL (GPD13 | FUNC(2)) +#define GPD14 (PIN(6,0) | PUD) +#define GPD14_GPIO (GPD14 | FUNC(0)) +#define GPD14_I2C2_SDA (GPD14 | FUNC(2)) +#define GPD15 (PIN(6,0) | PUD) +#define GPD15_GPIO (GPD15 | FUNC(0)) +#define GPD15_I2C2_SCL (GPD15 | FUNC(2)) + +/* + * Group E0: GPIO 0...7 + */ +#define GPE00 (PIN(7,0) | PUD) +#define GPE00_GPIO (GPE00 | FUNC(0)) +#define GPE00_CAM_A_PCLK (GPE00 | FUNC(2)) +#define GPE01 (PIN(7,1) | PUD) +#define GPE01_GPIO (GPE01 | FUNC(0)) +#define GPE01_CAM_A_VSYNC (GPE01 | FUNC(2)) +#define GPE02 (PIN(7,2) | PUD) +#define GPE02_GPIO (GPE02 | FUNC(0)) +#define GPE02_CAM_A_HREF (GPE02 | FUNC(2)) +#define GPE03 (PIN(7,3) | PUD) +#define GPE03_GPIO (GPE03 | FUNC(0)) +#define GPE03_CAM_A_DATA0 (GPE03 | FUNC(2)) +#define GPE04 (PIN(7,4) | PUD) +#define GPE04_GPIO (GPE04 | FUNC(0)) +#define GPE04_CAM_A_DATA1 (GPE04 | FUNC(2)) +#define GPE05 (PIN(7,5) | PUD) +#define GPE05_GPIO (GPE05 | FUNC(0)) +#define GPE05_CAM_A_DATA2 (GPE05 | FUNC(2)) +#define GPE06 (PIN(7,6) | PUD) +#define GPE06_GPIO (GPE06 | FUNC(0)) +#define GPE06_CAM_A_DATA3 (GPE06 | FUNC(2)) +#define GPE07 (PIN(7,7) | PUD) +#define GPE07_GPIO (GPE07 | FUNC(0)) +#define GPE07_CAM_A_DATA4 (GPE07 | FUNC(2)) + +/* + * Group E1: GPIO 0...4 + */ +#define GPE10 (PIN(8,0) | PUD) +#define GPE10_GPIO (GPE10 | FUNC(0)) +#define GPE10_CAM_A_DATA5 (GPE10 | FUNC(2)) +#define GPE11 (PIN(8,1) | PUD) +#define GPE11_GPIO (GPE11 | FUNC(0)) +#define GPE11_CAM_A_DATA6 (GPE11 | FUNC(2)) +#define GPE12 (PIN(8,2) | PUD) +#define GPE12_GPIO (GPE12 | FUNC(0)) +#define GPE12_CAM_A_DATA7 (GPE12 | FUNC(2)) +#define GPE13 (PIN(8,3) | PUD) +#define GPE13_GPIO (GPE13 | FUNC(0)) +#define GPE13_CAM_A_CLKOUT (GPE13 | FUNC(2)) +#define GPE14 (PIN(8,4) | PUD) +#define GPE14_GPIO (GPE14 | FUNC(0)) +#define GPE14_CAM_A_FIELD (GPE14 | FUNC(2)) + +/* + * Group F0: GPIO 0...7 + */ +#define GPF00 (PIN(9,0) | PUD) +#define GPF00_GPIO (GPF00 | FUNC(0)) +#define GPF00_LCD_HSYNC (GPF00 | FUNC(2)) +#define GPF00_SYS_CS0 (GPF00 | FUNC(3)) +#define GPF00_VEN_HSYNC (GPF00 | FUNC(4)) +#define GPF01 (PIN(9,1) | PUD) +#define GPF01_GPIO (GPF01 | FUNC(0)) +#define GPF01_LCD_VSYNC (GPF01 | FUNC(2)) +#define GPF01_SYS_CS1 (GPF01 | FUNC(3)) +#define GPF01_VEN_VSYNC (GPF01 | FUNC(4)) +#define GPF02 (PIN(9,2) | PUD) +#define GPF02_GPIO (GPF02 | FUNC(0)) +#define GPF02_LCD_VDEN (GPF02 | FUNC(2)) +#define GPF02_SYS_RS (GPF02 | FUNC(3)) +#define GPF02_VEN_HREF (GPF02 | FUNC(4)) +#define GPF03 (PIN(9,3) | PUD) +#define GPF03_GPIO (GPF03 | FUNC(0)) +#define GPF03_LCD_VCLK (GPF03 | FUNC(2)) +#define GPF03_SYS_WE (GPF03 | FUNC(3)) +#define GPF03_V601_CLK (GPF03 | FUNC(4)) +#define GPF04 (PIN(9,4) | PUD) +#define GPF04_GPIO (GPF04 | FUNC(0)) +#define GPF04_LCD_VD0 (GPF04 | FUNC(2)) +#define GPF04_SYS_VS0 (GPF04 | FUNC(3)) +#define GPF04_VEN_DATA0 (GPF04 | FUNC(4)) +#define GPF05 (PIN(9,5) | PUD) +#define GPF05_GPIO (GPF05 | FUNC(0)) +#define GPF05_LCD_VD1 (GPF05 | FUNC(2)) +#define GPF05_SYS_VD1 (GPF05 | FUNC(3)) +#define GPF05_VEN_DATA1 (GPF05 | FUNC(4)) +#define GPF06 (PIN(9,6) | PUD) +#define GPF06_GPIO (GPF06 | FUNC(0)) +#define GPF06_LCD_VD2 (GPF06 | FUNC(2)) +#define GPF06_SYS_VD2 (GPF06 | FUNC(3)) +#define GPF06_VEN_DATA2 (GPF06 | FUNC(4)) +#define GPF07 (PIN(9,7) | PUD) +#define GPF07_GPIO (GPF07 | FUNC(0)) +#define GPF07_LCD_VD3 (GPF07 | FUNC(2)) +#define GPF07_SYS_VD3 (GPF07 | FUNC(3)) +#define GPF07_VEN_DATA3 (GPF07 | FUNC(4)) + +/* + * Group F1: GPIO 0...7 + */ +#define GPF10 (PIN(10,0) | PUD) +#define GPF10_GPIO (GPF10 | FUNC(0)) +#define GPF10_LCD_VD4 (GPF10 | FUNC(2)) +#define GPF10_SYS_VD4 (GPF10 | FUNC(3)) +#define GPF10_VEN_DATA4 (GPF10 | FUNC(4)) +#define GPF11 (PIN(10,1) | PUD) +#define GPF11_GPIO (GPF11 | FUNC(0)) +#define GPF11_LCD_VD5 (GPF11 | FUNC(2)) +#define GPF11_SYS_VD5 (GPF11 | FUNC(3)) +#define GPF11_VEN_DATA5 (GPF11 | FUNC(4)) +#define GPF12 (PIN(10,2) | PUD) +#define GPF12_GPIO (GPF12 | FUNC(0)) +#define GPF12_LCD_VD6 (GPF12 | FUNC(2)) +#define GPF12_SYS_VD6 (GPF12 | FUNC(3)) +#define GPF12_VEN_DATA6 (GPF12 | FUNC(4)) +#define GPF13 (PIN(10,3) | PUD) +#define GPF13_GPIO (GPF13 | FUNC(0)) +#define GPF13_LCD_VD7 (GPF13 | FUNC(2)) +#define GPF13_SYS_VD7 (GPF13 | FUNC(3)) +#define GPF13_VEN_DATA7 (GPF13 | FUNC(4)) +#define GPF14 (PIN(10,4) | PUD) +#define GPF14_GPIO (GPF14 | FUNC(0)) +#define GPF14_LCD_VD8 (GPF14 | FUNC(2)) +#define GPF14_SYS_VD8 (GPF14 | FUNC(3)) +#define GPF14_V656_DATA0 (GPF14 | FUNC(4)) +#define GPF15 (PIN(10,5) | PUD) +#define GPF15_GPIO (GPF15 | FUNC(0)) +#define GPF15_LCD_VD9 (GPF15 | FUNC(2)) +#define GPF15_SYS_VD9 (GPF15 | FUNC(3)) +#define GPF15_V656_DATA1 (GPF15 | FUNC(4)) +#define GPF16 (PIN(10,6) | PUD) +#define GPF16_GPIO (GPF16 | FUNC(0)) +#define GPF16_LCD_VD10 (GPF16 | FUNC(2)) +#define GPF16_SYS_VD10 (GPF16 | FUNC(3)) +#define GPF16_V656_DATA2 (GPF16 | FUNC(4)) +#define GPF17 (PIN(10,7) | PUD) +#define GPF17_GPIO (GPF17 | FUNC(0)) +#define GPF17_LCD_VD11 (GPF17 | FUNC(2)) +#define GPF17_SYS_VD11 (GPF17 | FUNC(3)) +#define GPF17_V656_DATA3 (GPF17 | FUNC(4)) + +/* + * Group F2: GPIO 0...7 + */ +#define GPF20 (PIN(11,0) | PUD) +#define GPF20_GPIO (GPF20 | FUNC(0)) +#define GPF20_LCD_VD_12 (GPF20 | FUNC(2)) +#define GPF20_SYS_VD_12 (GPF20 | FUNC(3)) +#define GPF20_V656_DATA_4 (GPF20 | FUNC(4)) +#define GPF21 (PIN(11,1) | PUD) +#define GPF21_GPIO (GPF21 | FUNC(0)) +#define GPF21_LCD_VD_13 (GPF21 | FUNC(2)) +#define GPF21_SYS_VD_13 (GPF21 | FUNC(3)) +#define GPF21_V656_DATA_5 (GPF21 | FUNC(4)) +#define GPF22 (PIN(11,2) | PUD) +#define GPF22_GPIO (GPF22 | FUNC(0)) +#define GPF22_LCD_VD_14 (GPF22 | FUNC(2)) +#define GPF22_SYS_VD_14 (GPF22 | FUNC(3)) +#define GPF22_V656_DATA_6 (GPF22 | FUNC(4)) +#define GPF23 (PIN(11,3) | PUD) +#define GPF23_GPIO (GPF23 | FUNC(0)) +#define GPF23_LCD_VD_15 (GPF23 | FUNC(2)) +#define GPF23_SYS_VD_15 (GPF23 | FUNC(3)) +#define GPF23_V656_DATA_7 (GPF23 | FUNC(4)) +#define GPF24 (PIN(11,4) | PUD) +#define GPF24_GPIO (GPF24 | FUNC(0)) +#define GPF24_LCD_VD_16 (GPF24 | FUNC(2)) +#define GPF24_SYS_VD_16 (GPF24 | FUNC(3)) +#define GPF25 (PIN(11,5) | PUD) +#define GPF25_GPIO (GPF25 | FUNC(0)) +#define GPF25_LCD_VD_17 (GPF25 | FUNC(2)) +#define GPF25_SYS_VD_17 (GPF25 | FUNC(3)) +#define GPF26 (PIN(11,6) | PUD) +#define GPF26_GPIO (GPF26 | FUNC(0)) +#define GPF26_LCD_VD_18 (GPF26 | FUNC(2)) +#define GPF26_SYS_VD_18 (GPF26 | FUNC(3)) +#define GPF27 (PIN(11,7) | PUD) +#define GPF27_GPIO (GPF27 | FUNC(0)) +#define GPF27_LCD_VD_19 (GPF27 | FUNC(2)) +#define GPF27_SYS_VD_19 (GPF27 | FUNC(3)) + +/* + * Group F3: GPIO 0...5 + */ +#define GPF30 (PIN(12,0) | PUD) +#define GPF30_GPIO (GPF30 | FUNC(0)) +#define GPF30_LCD_VD20 (GPF30 | FUNC(2)) +#define GPF30_SYS_VD20 (GPF30 | FUNC(3)) +#define GPF31 (PIN(12,1) | PUD) +#define GPF31_GPIO (GPF31 | FUNC(0)) +#define GPF31_LCD_VD21 (GPF31 | FUNC(2)) +#define GPF31_SYS_VD21 (GPF31 | FUNC(3)) +#define GPF32 (PIN(12,2) | PUD) +#define GPF32_GPIO (GPF32 | FUNC(0)) +#define GPF32_LCD_VD22 (GPF32 | FUNC(2)) +#define GPF32_SYS_VD22 (GPF32 | FUNC(3)) +#define GPF33 (PIN(12,3) | PUD) +#define GPF33_GPIO (GPF33 | FUNC(0)) +#define GPF33_LCD_VD23 (GPF33 | FUNC(2)) +#define GPF33_SYS_VD23 (GPF33 | FUNC(3)) +#define GPF33_V656_CLK (GPF33 | FUNC(4)) +#define GPF34 (PIN(12,4) | PUD) +#define GPF34_GPIO (GPF34 | FUNC(0)) +#define GPF34_VSYNC_LDI (GPF34 | FUNC(3)) +#define GPF35 (PIN(12,5) | PUD) +#define GPF35_GPIO (GPF35 | FUNC(0)) +#define GPF35_SYS_OE (GPF35 | FUNC(3)) +#define GPF35_VEN_FIELD (GPF35 | FUNC(4)) + +/* + * Group G0: GPIO 0...6 + */ +#define GPG00 (PIN(13,0) | PUD) +#define GPG00_GPIO (GPG00 | FUNC(0)) +#define GPG00_SD0_CLK (GPG00 | FUNC(2)) +#define GPG01 (PIN(13,1) | PUD) +#define GPG01_GPIO (GPG01 | FUNC(0)) +#define GPG01_SD0_CMD (GPG01 | FUNC(2)) +#define GPG02 (PIN(13,2) | PUD) +#define GPG02_GPIO (GPG02 | FUNC(0)) +#define GPG02_SD0_NCD (GPG02 | FUNC(2)) +#define GPG03 (PIN(13,3) | PUD) +#define GPG03_GPIO (GPG03 | FUNC(0)) +#define GPG03_SD0_DATA0 (GPG03 | FUNC(2)) +#define GPG04 (PIN(13,4) | PUD) +#define GPG04_GPIO (GPG04 | FUNC(0)) +#define GPG04_SD0_DATA1 (GPG04 | FUNC(2)) +#define GPG05 (PIN(13,5) | PUD) +#define GPG05_GPIO (GPG05 | FUNC(0)) +#define GPG05_SD0_DATA2 (GPG05 | FUNC(2)) +#define GPG06 (PIN(13,6) | PUD) +#define GPG06_GPIO (GPG06 | FUNC(0)) +#define GPG06_SD0_DATA3 (GPG06 | FUNC(2)) + +/* + * Group G1: GPIO 0...6 + */ +#define GPG10 (PIN(14,0) | PUD) +#define GPG10_GPIO (GPG10 | FUNC(0)) +#define GPG10_SD1_CLK (GPG10 | FUNC(2)) +#define GPG11 (PIN(14,1) | PUD) +#define GPG11_GPIO (GPG11 | FUNC(0)) +#define GPG11_SD1_CMD (GPG11 | FUNC(2)) +#define GPG12 (PIN(14,2) | PUD) +#define GPG12_GPIO (GPG12 | FUNC(0)) +#define GPG12_SD1_NCD (GPG12 | FUNC(2)) +#define GPG13 (PIN(14,3) | PUD) +#define GPG13_GPIO (GPG13 | FUNC(0)) +#define GPG13_SD1_DATA0 (GPG13 | FUNC(2)) +#define GPG13_SD0_DATA4 (GPG13 | FUNC(3)) +#define GPG14 (PIN(14,4) | PUD) +#define GPG14_GPIO (GPG14 | FUNC(0)) +#define GPG14_SD1_DATA1 (GPG14 | FUNC(2)) +#define GPG14_SD0_DATA5 (GPG14 | FUNC(3)) +#define GPG15 (PIN(14,5) | PUD) +#define GPG15_GPIO (GPG15 | FUNC(0)) +#define GPG15_SD1_DATA2 (GPG15 | FUNC(2)) +#define GPG15_SD0_DATA6 (GPG15 | FUNC(3)) +#define GPG16 (PIN(14,6) | PUD) +#define GPG16_GPIO (GPG16 | FUNC(0)) +#define GPG16_SD1_DATA3 (GPG16 | FUNC(2)) +#define GPG16_SD0_DATA7 (GPG16 | FUNC(3)) + +/* + * Group G2: GPIO 0...6 + */ +#define GPG20 (PIN(15,0) | PUD) +#define GPG20_GPIO (GPG20 | FUNC(0)) +#define GPG20_SD2_CLK (GPG20 | FUNC(2)) +#define GPG21 (PIN(15,1) | PUD) +#define GPG21_GPIO (GPG21 | FUNC(0)) +#define GPG21_SD2_CMD (GPG21 | FUNC(2)) +#define GPG22 (PIN(15,2) | PUD) +#define GPG22_GPIO (GPG22 | FUNC(0)) +#define GPG22_SD2_NCD (GPG22 | FUNC(2)) +#define GPG23 (PIN(15,3) | PUD) +#define GPG23_GPIO (GPG23 | FUNC(0)) +#define GPG23_SD2_DATA0 (GPG23 | FUNC(2)) +#define GPG24 (PIN(15,4) | PUD) +#define GPG24_GPIO (GPG24 | FUNC(0)) +#define GPG24_SD2_DATA1 (GPG24 | FUNC(2)) +#define GPG25 (PIN(15,5) | PUD) +#define GPG25_GPIO (GPG25 | FUNC(0)) +#define GPG25_SD2_DATA2 (GPG25 | FUNC(2)) +#define GPG26 (PIN(15,6) | PUD) +#define GPG26_GPIO (GPG26 | FUNC(0)) +#define GPG26_SD2_DATA3 (GPG26 | FUNC(2)) + +/* + * Group G3: GPIO 0...6 + */ +#define GPG30 (PIN(16,0) | PUD) +#define GPG30_GPIO (GPG30 | FUNC(0)) +#define GPG30_SD3_CLK (GPG30 | FUNC(2)) +#define GPG31 (PIN(16,1) | PUD) +#define GPG31_GPIO (GPG31 | FUNC(0)) +#define GPG31_SD3_CMD (GPG31 | FUNC(2)) +#define GPG32 (PIN(16,2) | PUD) +#define GPG32_GPIO (GPG32 | FUNC(0)) +#define GPG32_SD3_NCD (GPG32 | FUNC(2)) +#define GPG33 (PIN(16,3) | PUD) +#define GPG33_GPIO (GPG33 | FUNC(0)) +#define GPG33_SD3_DATA0 (GPG33 | FUNC(2)) +#define GPG33_SD2_DATA4 (GPG33 | FUNC(3)) +#define GPG34 (PIN(16,4) | PUD) +#define GPG34_GPIO (GPG34 | FUNC(0)) +#define GPG34_SD3_DATA1 (GPG34 | FUNC(2)) +#define GPG34_SD2_DATA5 (GPG34 | FUNC(3)) +#define GPG35 (PIN(16,5) | PUD) +#define GPG35_GPIO (GPG35 | FUNC(0)) +#define GPG35_SD3_DATA2 (GPG35 | FUNC(2)) +#define GPG35_SD2_DATA6 (GPG35 | FUNC(3)) +#define GPG36 (PIN(16,6) | PUD) +#define GPG36_GPIO (GPG36 | FUNC(0)) +#define GPG36_SD3_DATA3 (GPG36 | FUNC(2)) +#define GPG36_SD2_DATA7 (GPG36 | FUNC(3)) + +/* + * Group I - no GPIO + */ +#define GPI0 (PIN(17,0) | PUD) +#define GPI0_I2S0_SCLK (GPI0 | FUNC(2)) +#define GPI0_PCM0_SCLK (GPI0 | FUNC(3)) +#define GPI1 (PIN(17,1) | PUD) +#define GPI1_I2S0_CDCLK (GPI1 | FUNC(2)) +#define GPI1_PCM0_EXTCLK (GPI1 | FUNC(3)) +#define GPI2 (PIN(17,2) | PUD) +#define GPI2_I2S0_LRCK (GPI2 | FUNC(2)) +#define GPI2_PCM0_FSYNC (GPI2 | FUNC(3)) +#define GPI3 (PIN(17,3) | PUD) +#define GPI3_I2S0_SDI (GPI3 | FUNC(2)) +#define GPI3_PCM0_SIN (GPI3 | FUNC(3)) +#define GPI4 (PIN(17,4) | PUD) +#define GPI4_I2S0_SDO0 (GPI4 | FUNC(2)) +#define GPI4_PCM0_SOUT (GPI4 | FUNC(3)) +#define GPI5 (PIN(17,5) | PUD) +#define GPI5_I2S0_SDO1 (GPI5 | FUNC(2)) +#define GPI6 (PIN(17,6) | PUD) +#define GPI6_I2S0_SDO2 (GPI6 | FUNC(2)) + +/* + * Group J0: GPIO 0...7 + */ +#define GPJ00 (PIN(18,0) | PUD) +#define GPJ00_GPIO (GPJ00 | FUNC(0)) +#define GPJ00_MSM_ADDR0 (GPJ00 | FUNC(2)) +#define GPJ00_CAM_B_DATA0 (GPJ00 | FUNC(3)) +#define GPJ00_CF_ADDR0 (GPJ00 | FUNC(4)) +#define GPJ00_MIPI_BYTE_CLK (GPJ00 | FUNC(5)) +#define GPJ01 (PIN(18,1) | PUD) +#define GPJ01_GPIO (GPJ01 | FUNC(0)) +#define GPJ01_MSM_ADDR1 (GPJ01 | FUNC(2)) +#define GPJ01_CAM_B_DATA1 (GPJ01 | FUNC(3)) +#define GPJ01_CF_ADDR1 (GPJ01 | FUNC(4)) +#define GPJ01_MIPI_ESC_CLK (GPJ01 | FUNC(5)) +#define GPJ02 (PIN(18,2) | PUD) +#define GPJ02_GPIO (GPJ02 | FUNC(0)) +#define GPJ02_MSM_ADDR2 (GPJ02 | FUNC(2)) +#define GPJ02_CAM_B_DATA2 (GPJ02 | FUNC(3)) +#define GPJ02_CF_ADDR2 (GPJ02 | FUNC(4)) +#define GPJ02_TS_CLK (GPJ02 | FUNC(5)) +#define GPJ03 (PIN(18,3) | PUD) +#define GPJ03_GPIO (GPJ03 | FUNC(0)) +#define GPJ03_MSM_ADDR3 (GPJ03 | FUNC(2)) +#define GPJ03_CAM_B_DATA3 (GPJ03 | FUNC(3)) +#define GPJ03_CF_IORDY (GPJ03 | FUNC(4)) +#define GPJ03_TS_SYNC (GPJ03 | FUNC(5)) +#define GPJ04 (PIN(18,4) | PUD) +#define GPJ04_GPIO (GPJ04 | FUNC(0)) +#define GPJ04_MSM_ADDR4 (GPJ04 | FUNC(2)) +#define GPJ04_CAM_B_DATA4 (GPJ04 | FUNC(3)) +#define GPJ04_CF_INTRQ (GPJ04 | FUNC(4)) +#define GPJ04_TS_VAL (GPJ04 | FUNC(5)) +#define GPJ05 (PIN(18,5) | PUD) +#define GPJ05_GPIO (GPJ05 | FUNC(0)) +#define GPJ05_MSM_ADDR5 (GPJ05 | FUNC(2)) +#define GPJ05_CAM_B_DATA5 (GPJ05 | FUNC(3)) +#define GPJ05_CF_DMARQ (GPJ05 | FUNC(4)) +#define GPJ05_TS_DATA (GPJ05 | FUNC(5)) +#define GPJ06 (PIN(18,6) | PUD) +#define GPJ06_GPIO (GPJ06 | FUNC(0)) +#define GPJ06_MSM_ADDR6 (GPJ06 | FUNC(2)) +#define GPJ06_CAM_B_DATA6 (GPJ06 | FUNC(3)) +#define GPJ06_CF_NDRESET (GPJ06 | FUNC(4)) +#define GPJ06_TS_ERROR (GPJ06 | FUNC(5)) +#define GPJ07 (PIN(18,7) | PUD) +#define GPJ07_GPIO (GPJ07 | FUNC(0)) +#define GPJ07_MSM_ADDR7 (GPJ07 | FUNC(2)) +#define GPJ07_CAM_B_DATA7 (GPJ07 | FUNC(3)) +#define GPJ07_CF_NDMACK (GPJ07 | FUNC(4)) +#define GPJ07_MHL_D0 (GPJ07 | FUNC(5)) + +/* + * Group J1: GPIO 0...5 + */ +#define GPJ10 (PIN(19,0) | PUD) +#define GPJ10_GPIO (GPJ10 | FUNC(0)) +#define GPJ10_MSM_ADDR8 (GPJ10 | FUNC(2)) +#define GPJ10_CAM_B_PCLK (GPJ10 | FUNC(3)) +#define GPJ10_SROM_ADDR_16to220 (GPJ10 | FUNC(4)) +#define GPJ10_MHL_D1 (GPJ10 | FUNC(5)) +#define GPJ11 (PIN(19,1) | PUD) +#define GPJ11_GPIO (GPJ11 | FUNC(0)) +#define GPJ11_MSM_ADDR9 (GPJ11 | FUNC(2)) +#define GPJ11_CAM_B_VSYNC (GPJ11 | FUNC(3)) +#define GPJ11_SROM_ADDR_16to221 (GPJ11 | FUNC(4)) +#define GPJ11_MHL_D2 (GPJ11 | FUNC(5)) +#define GPJ12 (PIN(19,2) | PUD) +#define GPJ12_GPIO (GPJ12 | FUNC(0)) +#define GPJ12_MSM_ADDR10 (GPJ12 | FUNC(2)) +#define GPJ12_CAM_B_HREF (GPJ12 | FUNC(3)) +#define GPJ12_SROM_ADDR_16to222 (GPJ12 | FUNC(4)) +#define GPJ12_MHL_D3 (GPJ12 | FUNC(5)) +#define GPJ13 (PIN(19,3) | PUD) +#define GPJ13_GPIO (GPJ13 | FUNC(0)) +#define GPJ13_MSM_ADDR11 (GPJ13 | FUNC(2)) +#define GPJ13_CAM_B_FIELD (GPJ13 | FUNC(3)) +#define GPJ13_SROM_ADDR_16to223 (GPJ13 | FUNC(4)) +#define GPJ13_MHL_D4 (GPJ13 | FUNC(5)) +#define GPJ14 (PIN(19,4) | PUD) +#define GPJ14_GPIO (GPJ14 | FUNC(0)) +#define GPJ14_MSM_ADDR12 (GPJ14 | FUNC(2)) +#define GPJ14_CAM_B_CLKOUT (GPJ14 | FUNC(3)) +#define GPJ14_SROM_ADDR_16to224 (GPJ14 | FUNC(4)) +#define GPJ14_MHL_D5 (GPJ14 | FUNC(5)) +#define GPJ15 (PIN(19,5) | PUD) +#define GPJ15_GPIO (GPJ15 | FUNC(0)) +#define GPJ15_MSM_ADDR13 (GPJ15 | FUNC(2)) +#define GPJ15_KP_COL0 (GPJ15 | FUNC(3)) +#define GPJ15_SROM_ADDR_16to225 (GPJ15 | FUNC(4)) +#define GPJ15_MHL_D6 (GPJ15 | FUNC(5)) + +/* + * Group J2: GPIO 0...7 + */ +#define GPJ20 (PIN(20,0) | PUD) +#define GPJ20_GPIO (GPJ20 | FUNC(0)) +#define GPJ20_MSM_DATA0 (GPJ20 | FUNC(2)) +#define GPJ20_KP_COL1 (GPJ20 | FUNC(3)) +#define GPJ20_CF_DATA0 (GPJ20 | FUNC(4)) +#define GPJ20_MHL_D7 (GPJ20 | FUNC(5)) +#define GPJ21 (PIN(20,1) | PUD) +#define GPJ21_GPIO (GPJ21 | FUNC(0)) +#define GPJ21_MSM_DATA1 (GPJ21 | FUNC(2)) +#define GPJ21_KP_COL2 (GPJ21 | FUNC(3)) +#define GPJ21_CF_DATA1 (GPJ21 | FUNC(4)) +#define GPJ21_MHL_D8 (GPJ21 | FUNC(5)) +#define GPJ22 (PIN(20,2) | PUD) +#define GPJ22_GPIO (GPJ22 | FUNC(0)) +#define GPJ22_MSM_DATA2 (GPJ22 | FUNC(2)) +#define GPJ22_KP_COL3 (GPJ22 | FUNC(3)) +#define GPJ22_CF_DATA2 (GPJ22 | FUNC(4)) +#define GPJ22_MHL_D9 (GPJ22 | FUNC(5)) +#define GPJ23 (PIN(20,3) | PUD) +#define GPJ23_GPIO (GPJ23 | FUNC(0)) +#define GPJ23_MSM_DATA3 (GPJ23 | FUNC(2)) +#define GPJ23_KP_COL4 (GPJ23 | FUNC(3)) +#define GPJ23_CF_DATA3 (GPJ23 | FUNC(4)) +#define GPJ23_MHL_D10 (GPJ23 | FUNC(5)) +#define GPJ24 (PIN(20,4) | PUD) +#define GPJ24_GPIO (GPJ24 | FUNC(0)) +#define GPJ24_MSM_DATA4 (GPJ24 | FUNC(2)) +#define GPJ24_KP_COL5 (GPJ24 | FUNC(3)) +#define GPJ24_CF_DATA4 (GPJ24 | FUNC(4)) +#define GPJ24_MHL_D11 (GPJ24 | FUNC(5)) +#define GPJ25 (PIN(20,5) | PUD) +#define GPJ25_GPIO (GPJ25 | FUNC(0)) +#define GPJ25_MSM_DATA5 (GPJ25 | FUNC(2)) +#define GPJ25_KP_COL6 (GPJ25 | FUNC(3)) +#define GPJ25_CF_DATA5 (GPJ25 | FUNC(4)) +#define GPJ25_MHL_D12 (GPJ25 | FUNC(5)) +#define GPJ26 (PIN(20,6) | PUD) +#define GPJ26_GPIO (GPJ26 | FUNC(0)) +#define GPJ26_MSM_DATA6 (GPJ26 | FUNC(2)) +#define GPJ26_KP_COL7 (GPJ26 | FUNC(3)) +#define GPJ26_CF_DATA6 (GPJ26 | FUNC(4)) +#define GPJ26_MHL_D13 (GPJ26 | FUNC(5)) +#define GPJ27 (PIN(20,7) | PUD) +#define GPJ27_GPIO (GPJ27 | FUNC(0)) +#define GPJ27_MSM_DATA7 (GPJ27 | FUNC(2)) +#define GPJ27_KP_ROW0 (GPJ27 | FUNC(3)) +#define GPJ27_CF_DATA7 (GPJ27 | FUNC(4)) +#define GPJ27_MHL_D14 (GPJ27 | FUNC(5)) + +/* + * Group J3: GPIO 0...7 + */ +#define GPJ30 (PIN(21,0) | PUD) +#define GPJ30_GPIO (GPJ30 | FUNC(0)) +#define GPJ30_MSM_DATA8 (GPJ30 | FUNC(2)) +#define GPJ30_KP_ROW1 (GPJ30 | FUNC(3)) +#define GPJ30_CF_DATA8 (GPJ30 | FUNC(4)) +#define GPJ30_MHL_D15 (GPJ30 | FUNC(5)) +#define GPJ31 (PIN(21,1) | PUD) +#define GPJ31_GPIO (GPJ31 | FUNC(0)) +#define GPJ31_MSM_DATA9 (GPJ31 | FUNC(2)) +#define GPJ31_KP_ROW2 (GPJ31 | FUNC(3)) +#define GPJ31_CF_DATA9 (GPJ31 | FUNC(4)) +#define GPJ31_MHL_D16 (GPJ31 | FUNC(5)) +#define GPJ32 (PIN(21,2) | PUD) +#define GPJ32_GPIO (GPJ32 | FUNC(0)) +#define GPJ32_MSM_DATA10 (GPJ32 | FUNC(2)) +#define GPJ32_KP_ROW3 (GPJ32 | FUNC(3)) +#define GPJ32_CF_DATA10 (GPJ32 | FUNC(4)) +#define GPJ32_MHL_D17 (GPJ32 | FUNC(5)) +#define GPJ33 (PIN(21,3) | PUD) +#define GPJ33_GPIO (GPJ33 | FUNC(0)) +#define GPJ33_MSM_DATA11 (GPJ33 | FUNC(2)) +#define GPJ33_KP_ROW4 (GPJ33 | FUNC(3)) +#define GPJ33_CF_DATA11 (GPJ33 | FUNC(4)) +#define GPJ33_MHL_D18 (GPJ33 | FUNC(5)) +#define GPJ34 (PIN(21,4) | PUD) +#define GPJ34_GPIO (GPJ34 | FUNC(0)) +#define GPJ34_MSM_DATA12 (GPJ34 | FUNC(2)) +#define GPJ34_KP_ROW5 (GPJ34 | FUNC(3)) +#define GPJ34_CF_DATA12 (GPJ34 | FUNC(4)) +#define GPJ34_MHL_D19 (GPJ34 | FUNC(5)) +#define GPJ35 (PIN(21,5) | PUD) +#define GPJ35_GPIO (GPJ35 | FUNC(0)) +#define GPJ35_MSM_DATA13 (GPJ35 | FUNC(2)) +#define GPJ35_KP_ROW6 (GPJ35 | FUNC(3)) +#define GPJ35_CF_DATA13 (GPJ35 | FUNC(4)) +#define GPJ35_MHL_D20 (GPJ35 | FUNC(5)) +#define GPJ36 (PIN(21,6) | PUD) +#define GPJ36_GPIO (GPJ36 | FUNC(0)) +#define GPJ36_MSM_DATA14 (GPJ36 | FUNC(2)) +#define GPJ36_KP_ROW7 (GPJ36 | FUNC(3)) +#define GPJ36_CF_DATA14 (GPJ36 | FUNC(4)) +#define GPJ36_MHL_D21 (GPJ36 | FUNC(5)) +#define GPJ37 (PIN(21,7) | PUD) +#define GPJ37_GPIO (GPJ37 | FUNC(0)) +#define GPJ37_MSM_DATA15 (GPJ37 | FUNC(2)) +#define GPJ37_KP_ROW8 (GPJ37 | FUNC(3)) +#define GPJ37_CF_DATA15 (GPJ37 | FUNC(4)) +#define GPJ37_MHL_D22 (GPJ37 | FUNC(5)) + +/* + * Group J4: GPIO 0...4 + */ +#define GPJ40 (PIN(22,0) | PUD) +#define GPJ40_GPIO (GPJ40 | FUNC(0)) +#define GPJ40_MSM_NCS (GPJ40 | FUNC(2)) +#define GPJ40_KP_ROW9 (GPJ40 | FUNC(3)) +#define GPJ40_CF_NCS0 (GPJ40 | FUNC(4)) +#define GPJ40_MHL_D23 (GPJ40 | FUNC(5)) +#define GPJ41 (PIN(22,1) | PUD) +#define GPJ41_GPIO (GPJ41 | FUNC(0)) +#define GPJ41_MSM_NWE (GPJ41 | FUNC(2)) +#define GPJ41_KP_ROW10 (GPJ41 | FUNC(3)) +#define GPJ41_CF_NCS1 (GPJ41 | FUNC(4)) +#define GPJ41_MHL_IDCK (GPJ41 | FUNC(5)) +#define GPJ42 (PIN(22,2) | PUD) +#define GPJ42_GPIO (GPJ42 | FUNC(0)) +#define GPJ42_MSM_NR (GPJ42 | FUNC(2)) +#define GPJ42_KP_ROW11 (GPJ42 | FUNC(3)) +#define GPJ42_CF_IORN (GPJ42 | FUNC(4)) +#define GPJ42_MHL_IDCK (GPJ42 | FUNC(5)) +#define GPJ43 (PIN(22,3) | PUD) +#define GPJ43_GPIO (GPJ43 | FUNC(0)) +#define GPJ43_MSM_NIRQ (GPJ43 | FUNC(2)) +#define GPJ43_KP_ROW12 (GPJ43 | FUNC(3)) +#define GPJ43_CF_IOWN (GPJ43 | FUNC(4)) +#define GPJ43_MHL_VSYNC (GPJ43 | FUNC(5)) +#define GPJ44 (PIN(22,4) | PUD) +#define GPJ44_GPIO (GPJ44 | FUNC(0)) +#define GPJ44_MSM_ADVN (GPJ44 | FUNC(2)) +#define GPJ44_KP_ROW13 (GPJ44 | FUNC(3)) +#define GPJ44_SROM_ADDR_16to226 (GPJ44 | FUNC(4)) +#define GPJ44_MHL_DE (GPJ44 | FUNC(5)) + +#endif /* __MACH_IOMUX_S5PCXX_H */ diff --git a/arch/arm/mach-samsung/include/mach/s3c-clocks.h b/arch/arm/mach-samsung/include/mach/s3c-clocks.h index b8894f8..f577306 100644 --- a/arch/arm/mach-samsung/include/mach/s3c-clocks.h +++ b/arch/arm/mach-samsung/include/mach/s3c-clocks.h @@ -25,5 +25,8 @@ #ifdef CONFIG_ARCH_S3C24xx # include <mach/s3c24xx-clocks.h> #endif +#ifdef CONFIG_ARCH_S5PCxx +# include <mach/s5pcxx-clocks.h> +#endif #endif /* __MACH_S3C_CLOCKS_H */ diff --git a/arch/arm/mach-samsung/include/mach/s3c-iomap.h b/arch/arm/mach-samsung/include/mach/s3c-iomap.h index 87919cc..d34ace4 100644 --- a/arch/arm/mach-samsung/include/mach/s3c-iomap.h +++ b/arch/arm/mach-samsung/include/mach/s3c-iomap.h @@ -22,3 +22,6 @@ #ifdef CONFIG_ARCH_S3C24xx # include <mach/s3c24xx-iomap.h> #endif +#ifdef CONFIG_ARCH_S5PCxx +# include <mach/s5pcxx-iomap.h> +#endif diff --git a/arch/arm/mach-samsung/include/mach/s5pcxx-clocks.h b/arch/arm/mach-samsung/include/mach/s5pcxx-clocks.h new file mode 100644 index 0000000..f9d49c5 --- /dev/null +++ b/arch/arm/mach-samsung/include/mach/s5pcxx-clocks.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +# define S5P_APLL 0x00 +# define S5P_MPLL 0x08 +# define S5P_EPLL 0x10 +# define S5P_VPLL 0x20 +# define S5P_xPLL_LOCK (S5P_CLOCK_POWER_BASE) +# define S5P_xPLL_CON (S5P_CLOCK_POWER_BASE + 0x100) +# define S5P_xPLL_CON0 (S5P_xPLL_CON) +# define S5P_xPLL_CON1 (S5P_xPLL_CON + 0x4) + +# define S5P_xPLLCON_GET_MDIV(x) (((x) >> 16) & 0x3ff) +# define S5P_xPLLCON_GET_PDIV(x) (((x) >> 8) & 0x3f) +# define S5P_xPLLCON_GET_SDIV(x) ((x) & 0x3) + +# define S5P_CLK_SRC0 (S5P_CLOCK_POWER_BASE + 0x200) +# define S5P_CLK_SRC1 (S5P_CLOCK_POWER_BASE + 0x204) +# define S5P_CLK_SRC2 (S5P_CLOCK_POWER_BASE + 0x208) +# define S5P_CLK_SRC3 (S5P_CLOCK_POWER_BASE + 0x20C) +# define S5P_CLK_SRC4 (S5P_CLOCK_POWER_BASE + 0x210) +# define S5P_CLK_SRC5 (S5P_CLOCK_POWER_BASE + 0x214) +# define S5P_CLK_SRC6 (S5P_CLOCK_BASE + 0x218) + +# define S5P_CLK_DIV0 (S5P_CLOCK_POWER_BASE + 0x300) +# define S5P_CLK_DIV1 (S5P_CLOCK_POWER_BASE + 0x304) +# define S5P_CLK_DIV2 (S5P_CLOCK_POWER_BASE + 0x308) +# define S5P_CLK_DIV3 (S5P_CLOCK_POWER_BASE + 0x30C) +# define S5P_CLK_DIV4 (S5P_CLOCK_POWER_BASE + 0x310) +# define S5P_CLK_DIV5 (S5P_CLOCK_POWER_BASE + 0x314) +# define S5P_CLK_DIV6 (S5P_CLOCK_POWER_BASE + 0x318) +# define S5P_CLK_DIV7 (S5P_CLOCK_POWER_BASE + 0x31C) + +# define S5P_CLK_GATE_SCLK (S5P_CLOCK_POWER_BASE + 0x444) +# define S5P_CLK_GATE_IP0 (S5P_CLOCK_POWER_BASE + 0x460) +# define S5P_CLK_GATE_IP1 (S5P_CLOCK_POWER_BASE + 0x464) +# define S5P_CLK_GATE_IP2 (S5P_CLOCK_POWER_BASE + 0x468) +# define S5P_CLK_GATE_IP3 (S5P_CLOCK_POWER_BASE + 0x46C) +# define S5P_CLK_GATE_IP4 (S5P_CLOCK_POWER_BASE + 0x470) +# define S5P_CLK_GATE_BLOCK (S5P_CLOCK_POWER_BASE + 0x480) +# define S5P_CLK_GATE_IP5 (S5P_CLOCK_POWER_BASE + 0x484) + +# define S5P_OTHERS (S5P_CLOCK_POWER_BASE + 0xE000) +# define S5P_USB_PHY_CONTROL (S5P_CLOCK_POWER_BASE + 0xE80C) diff --git a/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h b/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h new file mode 100644 index 0000000..cb05527 --- /dev/null +++ b/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + */ + +/* S5PV210 device base addresses */ + +#define S5P_CLOCK_POWER_BASE 0xE0100000 +#define S3C_GPIO_BASE 0xE0200000 +#define S3C_TIMER_BASE 0xE2500000 +#define S3C_WATCHDOG_BASE 0xE2700000 +#define S3C_UART_BASE 0xE2900000 +#define S3C_USB_HOST_BASE 0xEC200000 +#define S3C_NAND_BASE 0xB0E00000 + +/* external IO space */ +#define S3C_CS0_BASE 0x80000000 +#define S3C_CS1_BASE 0x88000000 +#define S3C_CS2_BASE 0x90000000 +#define S3C_CS3_BASE 0x98000000 +#define S3C_CS4_BASE 0xA0000000 +#define S3C_CS5_BASE 0xA8000000 + +#define S3C_SDRAM_BASE 0x20000000 +#define S3C_SDRAM_END (S3C_SDRAM_BASE + 0x60000000) + +#define S3C_UART1_BASE (S3C_UART_BASE) +#define S3C_UART1_SIZE 0x400 +#define S3C_UART2_BASE (S3C_UART_BASE + 0x400) +#define S3C_UART2_SIZE 0x400 +#define S3C_UART3_BASE (S3C_UART_BASE + 0x800) +#define S3C_UART3_SIZE 0x400 +#define S3C_UART_HAS_UBRDIVSLOT +#define S3C_UART_HAS_UINTM -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 4/7] S5P boot header and image generator 2012-05-15 13:20 [PATCHv3 0/7] Cleaned up version of S5PV210 code Alexey Galakhov ` (2 preceding siblings ...) 2012-05-15 13:20 ` [PATCH 3/7] Add support for Samsung S5P architecture (S5PV210) Alexey Galakhov @ 2012-05-15 13:20 ` Alexey Galakhov 2012-05-15 13:20 ` [PATCH 5/7] S5P lowlevel clock init Alexey Galakhov ` (2 subsequent siblings) 6 siblings, 0 replies; 29+ messages in thread From: Alexey Galakhov @ 2012-05-15 13:20 UTC (permalink / raw) To: barebox; +Cc: Alexey Galakhov Signed-off-by: Alexey Galakhov <agalakhov@gmail.com> --- .gitignore | 2 + Makefile | 2 +- arch/arm/Makefile | 7 +++ scripts/Makefile | 1 + scripts/s5p_cksum.c | 140 +++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 scripts/s5p_cksum.c diff --git a/.gitignore b/.gitignore index 8e208e0..df0ed2c 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,7 @@ barebox.S barebox.bin barebox.srec barebox.netx +barebox.s5p barebox.map System.map Module.symvers @@ -63,3 +64,4 @@ cscope.* # patches *.patch scripts/gen_netx_image +scripts/s5p_cksum diff --git a/Makefile b/Makefile index 44b7dbd..91ded1b 100644 --- a/Makefile +++ b/Makefile @@ -1003,7 +1003,7 @@ CLEAN_DIRS += $(MODVERDIR) CLEAN_FILES += barebox System.map include/generated/barebox_default_env.h \ .tmp_version .tmp_barebox* barebox.bin barebox.map barebox.S \ .tmp_kallsyms* barebox_default_env* barebox.ldr \ - Doxyfile.version barebox.srec + Doxyfile.version barebox.srec barebox.s5p # Directories & files removed with 'make mrproper' MRPROPER_DIRS += include/config include2 usr/include diff --git a/arch/arm/Makefile b/arch/arm/Makefile index d0bfd71..40291aa 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -164,6 +164,13 @@ ifeq ($(machine-y),netx) KBUILD_IMAGE := barebox.netx endif +barebox.s5p: barebox.bin + $(Q)scripts/s5p_cksum barebox.bin barebox.s5p + +ifeq ($(CONFIG_ARCH_S5PCxx),y) +KBUILD_IMAGE := barebox.s5p +endif + MLO: barebox.bin @echo " IFT " $@ $(Q)scripts/omap_signGP barebox.bin $(TEXT_BASE) 1 diff --git a/scripts/Makefile b/scripts/Makefile index cb049fd..784d205 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -10,6 +10,7 @@ hostprogs-y += mkimage hostprogs-y += bareboxenv hostprogs-$(CONFIG_ARCH_NETX) += gen_netx_image hostprogs-$(CONFIG_ARCH_OMAP) += omap_signGP +hostprogs-$(CONFIG_ARCH_S5PCxx) += s5p_cksum always := $(hostprogs-y) $(hostprogs-m) diff --git a/scripts/s5p_cksum.c b/scripts/s5p_cksum.c new file mode 100644 index 0000000..7142532 --- /dev/null +++ b/scripts/s5p_cksum.c @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include <stddef.h> +#include <errno.h> + +#define DEFAULT_BUF_SIZE 8192 + +static int usage(const char* me) +{ + printf("Usage: %s <input> <output> [<bufsize]\n", me); + return 1; +} + +static void put32(uint8_t *ptr, uint32_t value) +{ + ptr[0] = value & 0xFF; + ptr[1] = (value >> 8) & 0xFF; + ptr[2] = (value >> 16) & 0xFF; + ptr[3] = (value >> 24) & 0xFF; +} + +static size_t safe_fread(void *buf, size_t len, FILE* file) +{ + size_t rd = fread(buf, 1, len, file); + if (! rd) { + if (ferror(file)) + fprintf(stderr, "Error reading file: %s\n", strerror(errno)); + else + fprintf(stderr, "Unexpected end of file\n"); + } + return rd; +} + +static size_t safe_fwrite(const void *buf, size_t len, FILE* file) +{ + size_t wr = fwrite(buf, 1, len, file); + if (wr != len) { + fprintf(stderr, "Error writing file: %s\n", strerror(errno)); + return 0; + } + return wr; +} + +static int process(FILE *input, FILE *output, uint8_t *buf, unsigned bufsize) +{ + size_t rd; + unsigned i; + uint32_t cksum; + /* Read first chunk */ + rd = safe_fread(buf + 16, bufsize - 16, input); + if (! rd) + return 4; + /* Calculate header */ + put32(buf + 0, bufsize); + cksum = 0; + for (i = 16; i < bufsize; ++i) + cksum += (uint32_t)buf[i]; + put32(buf + 8, cksum); + if (! safe_fwrite(buf, bufsize, output)) + return 4; + /* Copy the rest of file */ + while (! feof(input)) { + rd = safe_fread(buf, bufsize, input); + if (! rd) + return 4; + if (! safe_fwrite(buf, rd, output)) + return 4; + } + return 0; +} + +static int work(const char* me, const char *infile, const char *outfile, unsigned bufsize) +{ + uint8_t *buf; + FILE *input; + FILE *output; + int ret; + if (bufsize < 512 || bufsize > 65536) + return usage(me); + buf = calloc(1, bufsize); + if (! buf) { + fprintf(stderr, "Unable to allocate %u bytes of memory\n", bufsize); + return 2; + } + input = fopen(infile, "r"); + if (! input) { + fprintf(stderr, "Cannot open `%s' for reading\n", infile); + free(buf); + return 3; + } + output = fopen(outfile, "w"); + if (! output) { + fprintf(stderr, "Cannot open `%s' for writing\n", outfile); + fclose(input); + free(buf); + return 3; + } + + ret = process(input, output, buf, bufsize); + + fclose(output); + fclose(input); + free(buf); + return ret; +} + +int main(int argc, char** argv) +{ + switch (argc) { + case 3: + return work(argv[0], argv[1], argv[2], DEFAULT_BUF_SIZE); + case 4: + return work(argv[0], argv[1], argv[2], atoi(argv[3])); + default: + return usage(argv[0]); + } +} -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 5/7] S5P lowlevel clock init 2012-05-15 13:20 [PATCHv3 0/7] Cleaned up version of S5PV210 code Alexey Galakhov ` (3 preceding siblings ...) 2012-05-15 13:20 ` [PATCH 4/7] S5P boot header and image generator Alexey Galakhov @ 2012-05-15 13:20 ` Alexey Galakhov 2012-05-15 13:20 ` [PATCH 6/7] S5P DRAM support Alexey Galakhov 2012-05-15 13:20 ` [PATCH 7/7] Add FriendlyArm Tiny210 board (S5PV210) Alexey Galakhov 6 siblings, 0 replies; 29+ messages in thread From: Alexey Galakhov @ 2012-05-15 13:20 UTC (permalink / raw) To: barebox; +Cc: Alexey Galakhov Signed-off-by: Alexey Galakhov <agalakhov@gmail.com> --- arch/arm/mach-samsung/Makefile | 1 + arch/arm/mach-samsung/include/mach/s3c-generic.h | 4 ++ arch/arm/mach-samsung/lowlevel-s5pcxx.c | 61 ++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 arch/arm/mach-samsung/lowlevel-s5pcxx.c diff --git a/arch/arm/mach-samsung/Makefile b/arch/arm/mach-samsung/Makefile index 0b95e14..d7344c8 100644 --- a/arch/arm/mach-samsung/Makefile +++ b/arch/arm/mach-samsung/Makefile @@ -1,5 +1,6 @@ obj-y += s3c-timer.o generic.o obj-lowlevel-$(CONFIG_ARCH_S3C24xx) += lowlevel-s3c24x0.o +obj-lowlevel-$(CONFIG_ARCH_S5PCxx) += lowlevel-s5pcxx.o obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o s3c24xx-clocks.o mem-s3c24x0.o obj-$(CONFIG_ARCH_S5PCxx) += gpio-s5pcxx.o clocks-s5pcxx.o obj-$(CONFIG_S3C_LOWLEVEL_INIT) += $(obj-lowlevel-y) diff --git a/arch/arm/mach-samsung/include/mach/s3c-generic.h b/arch/arm/mach-samsung/include/mach/s3c-generic.h index 62d2c93..578aae1 100644 --- a/arch/arm/mach-samsung/include/mach/s3c-generic.h +++ b/arch/arm/mach-samsung/include/mach/s3c-generic.h @@ -38,3 +38,7 @@ uint32_t s3c_get_memory_size(void); #ifdef CONFIG_ARCH_S3C24xx void s3c24xx_disable_second_sdram_bank(void); #endif + +#ifdef CONFIG_ARCH_S5PCxx +void s5p_init_pll(void); +#endif diff --git a/arch/arm/mach-samsung/lowlevel-s5pcxx.c b/arch/arm/mach-samsung/lowlevel-s5pcxx.c new file mode 100644 index 0000000..15afa47 --- /dev/null +++ b/arch/arm/mach-samsung/lowlevel-s5pcxx.c @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * + * Based on code from u-boot found somewhere on the web + * that seems to originate from Samsung + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <config.h> +#include <common.h> +#include <io.h> +#include <init.h> +#include <mach/s3c-iomap.h> +#include <mach/s3c-clocks.h> +#include <mach/s3c-generic.h> + +#ifdef CONFIG_S3C_PLL_INIT +void __bare_init s5p_init_pll(void) +{ + uint32_t reg; + int i; + + /* Set Mux to FIN */ + writel(0, S5P_CLK_SRC0); + + writel(BOARD_APLL_LOCKTIME, S5P_xPLL_LOCK + S5P_APLL); + + /* Disable PLL */ + writel(0, S5P_xPLL_CON + S5P_APLL); + writel(0, S5P_xPLL_CON + S5P_MPLL); + + /* Set up dividers */ + reg = readl(S5P_CLK_DIV0); + reg &= ~(BOARD_CLK_DIV0_MASK); + reg |= (BOARD_CLK_DIV0_VAL); + writel(reg, S5P_CLK_DIV0); + + /* Set up PLLs */ + writel(BOARD_APLL_VAL, S5P_xPLL_CON + S5P_APLL); + writel(BOARD_MPLL_VAL, S5P_xPLL_CON + S5P_MPLL); + writel(BOARD_EPLL_VAL, S5P_xPLL_CON + S5P_EPLL); + writel(BOARD_VPLL_VAL, S5P_xPLL_CON + S5P_VPLL); + + /* Wait for sync */ + for (i = 0; i < 0x10000; ++i) + barrier(); + + reg = readl(S5P_CLK_SRC0); + reg |= 0x1111; /* switch MUX to PLL outputs */ + writel(reg, S5P_CLK_SRC0); +} +#endif /* CONFIG_S3C_PLL_INIT */ -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 6/7] S5P DRAM support 2012-05-15 13:20 [PATCHv3 0/7] Cleaned up version of S5PV210 code Alexey Galakhov ` (4 preceding siblings ...) 2012-05-15 13:20 ` [PATCH 5/7] S5P lowlevel clock init Alexey Galakhov @ 2012-05-15 13:20 ` Alexey Galakhov 2012-05-15 13:20 ` [PATCH 7/7] Add FriendlyArm Tiny210 board (S5PV210) Alexey Galakhov 6 siblings, 0 replies; 29+ messages in thread From: Alexey Galakhov @ 2012-05-15 13:20 UTC (permalink / raw) To: barebox; +Cc: Alexey Galakhov Signed-off-by: Alexey Galakhov <agalakhov@gmail.com> --- arch/arm/mach-samsung/Makefile | 2 +- arch/arm/mach-samsung/include/mach/s3c-generic.h | 1 + arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h | 3 + arch/arm/mach-samsung/mem-s5pcxx.c | 260 +++++++++++++++++++++ 4 files changed, 265 insertions(+), 1 deletion(-) create mode 100644 arch/arm/mach-samsung/mem-s5pcxx.c diff --git a/arch/arm/mach-samsung/Makefile b/arch/arm/mach-samsung/Makefile index d7344c8..6020587 100644 --- a/arch/arm/mach-samsung/Makefile +++ b/arch/arm/mach-samsung/Makefile @@ -2,5 +2,5 @@ obj-y += s3c-timer.o generic.o obj-lowlevel-$(CONFIG_ARCH_S3C24xx) += lowlevel-s3c24x0.o obj-lowlevel-$(CONFIG_ARCH_S5PCxx) += lowlevel-s5pcxx.o obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o s3c24xx-clocks.o mem-s3c24x0.o -obj-$(CONFIG_ARCH_S5PCxx) += gpio-s5pcxx.o clocks-s5pcxx.o +obj-$(CONFIG_ARCH_S5PCxx) += gpio-s5pcxx.o clocks-s5pcxx.o mem-s5pcxx.o obj-$(CONFIG_S3C_LOWLEVEL_INIT) += $(obj-lowlevel-y) diff --git a/arch/arm/mach-samsung/include/mach/s3c-generic.h b/arch/arm/mach-samsung/include/mach/s3c-generic.h index 578aae1..9a5a642 100644 --- a/arch/arm/mach-samsung/include/mach/s3c-generic.h +++ b/arch/arm/mach-samsung/include/mach/s3c-generic.h @@ -41,4 +41,5 @@ void s3c24xx_disable_second_sdram_bank(void); #ifdef CONFIG_ARCH_S5PCxx void s5p_init_pll(void); +void s5p_init_dram_bank(uint32_t base, uint32_t mc0, uint32_t mc1); #endif diff --git a/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h b/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h index cb05527..248f868 100644 --- a/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h +++ b/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h @@ -47,3 +47,6 @@ #define S3C_UART3_SIZE 0x400 #define S3C_UART_HAS_UBRDIVSLOT #define S3C_UART_HAS_UINTM + +#define S5P_DMC0_BASE 0xF0000000 +#define S5P_DMC1_BASE 0xF1400000 diff --git a/arch/arm/mach-samsung/mem-s5pcxx.c b/arch/arm/mach-samsung/mem-s5pcxx.c new file mode 100644 index 0000000..f3d325a --- /dev/null +++ b/arch/arm/mach-samsung/mem-s5pcxx.c @@ -0,0 +1,260 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * + * Based on code from u-boot found somewhere on the web + * that seems to originate from Samsung + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <config.h> +#include <common.h> +#include <io.h> +#include <init.h> +#include <mach/s3c-generic.h> +#include <mach/s3c-iomap.h> + +#define S5P_DMC_CONCONTROL 0x00 +#define S5P_DMC_MEMCONTROL 0x04 +#define S5P_DMC_MEMCONFIG0 0x08 +#define S5P_DMC_MEMCONFIG1 0x0C +#define S5P_DMC_DIRECTCMD 0x10 +#define S5P_DMC_PRECHCONFIG 0x14 +#define S5P_DMC_PHYCONTROL0 0x18 +#define S5P_DMC_PHYCONTROL1 0x1C +#define S5P_DMC_PWRDNCONFIG 0x28 +#define S5P_DMC_TIMINGAREF 0x30 +#define S5P_DMC_TIMINGROW 0x34 +#define S5P_DMC_TIMINGDATA 0x38 +#define S5P_DMC_TIMINGPOWER 0x3C +#define S5P_DMC_PHYSTATUS 0x40 + +/* DRAM commands */ +#define CMD(x) ((x) << 24) +#define BANK(x) ((x) << 16) +#define CHIP(x) ((x) << 20) +#define ADDR(x) (x) + +/** + * MR definition: + * 1 11 + * 2 1098 7654 3210 + * | | ^^^- burst length, 010=4, 011=8 + * | | ^- burst type 0=sequnential, 1=interleaved + * | ^^^-- CAS latency + * | ^----- test, 0=normal, 1=test + * |^---- DLL reset, 1=yes + * ^^^----- WR, 1=2, 2=3 etc. + * ^------- PD, 0=fast exit, 1=low power + * + * EMR1 definition: + * 1 11 + * 2 1098 7654 3210 + * | ^- DLL, 0=enable + * | ^-- output strength, 0=full, 1=reduced + * |^.. .^--- Rtt, 00=off, 01=75, 10=150, 11=50 Ohm + * | ^^ ^-- Posted CAS# AL, 0-6 + * ^^ ^------ OCD: 000=OCD exit, 111=enable defaults + * ^------ DQS#, 0=enable, 1=disable + * ^------- RDQS enable, 0=no, 1=yes + * ^-------- outputs, 0=enabled, 1=disabled + * + * EMR2 definition: + * bit 7 + * 1 1 + * 2 1098 7654 3210 + * ^-- SRT, 0=1x (0-85 deg.C), 1=2x (>85 deg.C) + * all other bits = 0 + * + * EMR3 definition: all bits 0 + */ + +#define MRS CMD(0x0) +#define PALL CMD(0x1) +#define PRE CMD(0x2) +#define DPD CMD(0x3) +#define REFS CMD(0x4) +#define REFA CMD(0x5) +#define CKEL CMD(0x6) +#define NOP CMD(0x7) +#define REFSX CMD(0x8) +#define MRR CMD(0x9) + +#define EMRS1 (MRS | BANK(1)) +#define EMRS2 (MRS | BANK(2)) +#define EMRS3 (MRS | BANK(3)) + +/* Burst is (1 << S5P_DRAM_BURST), i.e. S5P_DRAM_BURST=2 for burst 4 */ +#ifndef S5P_DRAM_BURST +/* (LP)DDR2 supports burst 4 only, make it default */ +# define S5P_DRAM_BURST 2 +#endif + +/** + * Initialization sequences for different kinds of DRAM + */ +#define dcmd(x) writel((x) | CHIP(chip), base + S5P_DMC_DIRECTCMD) + +/* TODO: LPDDR and LPDDR2 */ + +#ifdef S5P_DRAM_DDR2 +static void __bare_init init_seq(uint32_t base, unsigned chip) +{ + const uint32_t emr = 0x400; /* DQS disable */ + const uint32_t mr = (((S5P_DRAM_WR) - 1) << 9) + | ((S5P_DRAM_CAS) << 4) + | (S5P_DRAM_BURST); + dcmd(NOP); + /* FIXME wait here? */ + dcmd(PALL); dcmd(EMRS2); dcmd(EMRS3); + dcmd(EMRS1 | ADDR(emr)); /* DQS disable */ + dcmd(MRS | ADDR(mr | 0x100)); /* DLL reset */ + dcmd(PALL); dcmd(REFA); dcmd(REFA); + dcmd(MRS | ADDR(mr)); /* DLL no reset */ + dcmd(EMRS1 | ADDR(emr | 0x380)); /* OCD defaults */ + dcmd(EMRS1 | ADDR(emr)); /* OCD exit */ +} +#endif + +#undef dcmd + + +static inline void __bare_init start_dll(uint32_t base) +{ + uint32_t pc0 = 0x00101000; /* the only legal initial value */ + uint32_t lv; + /* Init DLL */ + writel(pc0, base + S5P_DMC_PHYCONTROL0); +#ifdef S5P_DRAM_DDR2 + /* refcount 8, 180 deg. shift */ + writel(0x00000086, base + S5P_DMC_PHYCONTROL1); +#else + /* refcount 8, 90 deg. shift */ + writel(0x00000085, base + S5P_DMC_PHYCONTROL1); +#endif + /* DLL on */ + pc0 |= 0x2; + writel(pc0, base + S5P_DMC_PHYCONTROL0); + /* DLL start */ + pc0 |= 0x1; + writel(pc0, base + S5P_DMC_PHYCONTROL0); + + /* Find lock val */ + do { + lv = readl(base + S5P_DMC_PHYSTATUS); + } while ((lv & 0x7) != 0x7); + + lv >>= 6; + lv &= 0xff; /* ctrl_lock_value[9:2] - coarse */ + pc0 |= (lv << 24); /* ctrl_force */ + writel(pc0, base + S5P_DMC_PHYCONTROL0); /* force value locking */ +} + + + +void __bare_init s5p_init_dram_bank(uint32_t base, uint32_t mc0, uint32_t mc1) +{ +#ifdef S5P_DRAM_LPDDR + uint32_t reg = 0x100; +#endif +#ifdef S5P_DRAM_LPDDR2 + uint32_t reg = 0x200; +#endif +#ifdef S5P_DRAM_DDR2 + uint32_t reg = 0x400; +#endif + reg |= (S5P_DRAM_BURST) << 20; +#ifdef S5P_DRAM_16BIT + reg |= 0x1000; +#else /* 32-bit */ + reg |= 0x2000; +#endif + if (mc1) + reg |= 0x10000; /* two chips */ + + start_dll(base); + writel(reg, base + S5P_DMC_MEMCONTROL); + + /* Set up memory layout */ + writel(mc0, base + S5P_DMC_MEMCONFIG0); + if (mc1) + writel(mc1, base + S5P_DMC_MEMCONFIG1); + /* Open page precharge policy - reasonable defaults */ + writel(0xFF000000, base + S5P_DMC_PRECHCONFIG); + /* Set up timings */ + writel(DMC_TIMING_AREF, base + S5P_DMC_TIMINGAREF); + writel(DMC_TIMING_ROW, base + S5P_DMC_TIMINGROW); + writel(DMC_TIMING_DATA, base + S5P_DMC_TIMINGDATA); + writel(DMC_TIMING_PWR, base + S5P_DMC_TIMINGPOWER); + + /* Start-Up Commands */ + init_seq(base, 0); + if (mc1) + init_seq(base, 1); + + /* Reasonable defaults and auto-refresh on */ + writel(0x0FFF1070, base + S5P_DMC_CONCONTROL); + /* Reasonable defaults */ + writel(0xFFFF00FF, base + S5P_DMC_PWRDNCONFIG); +} + + +#define BANK_ENABLED(base) (readl((base) + S5P_DMC_PHYCONTROL0) & 1) +#define NUM_EXTRA_CHIPS(base) ((readl((base) + S5P_DMC_MEMCONTROL) >> 16) & 0xF) + +#define BANK_START(x) ((x) & 0xFF000000) +#define BANK_END(x) (BANK_START(x) | ~(((x) & 0x00FF0000) << 8)) +#define BANK_LEN(x) (BANK_END(x) - BANK_START(x) + 1) + +static inline void sortswap(uint32_t *x, uint32_t *y) +{ + if (*y < *x) { + *x ^= *y; + *y ^= *x; + *x ^= *y; + } +} + +uint32_t s3c_get_memory_size(void) +{ + int i; + uint32_t len; + uint32_t mc[4] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; + /* Read MEMCONFIG registers */ + if (BANK_ENABLED(S5P_DMC0_BASE)) { + mc[0] = readl(S5P_DMC0_BASE + S5P_DMC_MEMCONFIG0); + if (NUM_EXTRA_CHIPS(S5P_DMC0_BASE) > 0) + mc[1] = readl(S5P_DMC0_BASE + S5P_DMC_MEMCONFIG1); + } + if (BANK_ENABLED(S5P_DMC1_BASE)) { + mc[2] = readl(S5P_DMC1_BASE + S5P_DMC_MEMCONFIG0); + if (NUM_EXTRA_CHIPS(S5P_DMC1_BASE) > 0) + mc[3] = readl(S5P_DMC1_BASE + S5P_DMC_MEMCONFIG1); + } + /* Sort using a sorting network */ + sortswap(mc + 0, mc + 2); + sortswap(mc + 1, mc + 3); + sortswap(mc + 0, mc + 1); + sortswap(mc + 2, mc + 3); + sortswap(mc + 1, mc + 2); + /* Is at least one chip enabled? */ + if (mc[0] == 0xFFFFFFFF) + return 0; + /* Determine maximum continuous region at start */ + len = BANK_LEN(mc[0]); + for (i = 1; i < 4; ++i) { + if (BANK_START(mc[i]) == BANK_END(mc[i - 1]) + 1) + len += BANK_LEN(mc[i]); + else + break; + } + return len; +} -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 7/7] Add FriendlyArm Tiny210 board (S5PV210) 2012-05-15 13:20 [PATCHv3 0/7] Cleaned up version of S5PV210 code Alexey Galakhov ` (5 preceding siblings ...) 2012-05-15 13:20 ` [PATCH 6/7] S5P DRAM support Alexey Galakhov @ 2012-05-15 13:20 ` Alexey Galakhov 6 siblings, 0 replies; 29+ messages in thread From: Alexey Galakhov @ 2012-05-15 13:20 UTC (permalink / raw) To: barebox; +Cc: Alexey Galakhov Signed-off-by: Alexey Galakhov <agalakhov@gmail.com> --- arch/arm/Makefile | 1 + arch/arm/boards/tiny210/Makefile | 1 + arch/arm/boards/tiny210/config.h | 21 +++++++ arch/arm/boards/tiny210/lowlevel.c | 76 ++++++++++++++++++++++++ arch/arm/boards/tiny210/tiny210.c | 113 ++++++++++++++++++++++++++++++++++++ arch/arm/configs/tiny210_defconfig | 17 ++++++ arch/arm/mach-samsung/Kconfig | 7 +++ 7 files changed, 236 insertions(+) create mode 100644 arch/arm/boards/tiny210/Makefile create mode 100644 arch/arm/boards/tiny210/config.h create mode 100644 arch/arm/boards/tiny210/lowlevel.c create mode 100644 arch/arm/boards/tiny210/tiny210.c create mode 100644 arch/arm/configs/tiny210_defconfig diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 40291aa..fc29aca 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -133,6 +133,7 @@ board-$(CONFIG_MACH_TX25) := karo-tx25 board-$(CONFIG_MACH_TQMA53) := tqma53 board-$(CONFIG_MACH_TX51) := karo-tx51 board-$(CONFIG_MACH_MX6Q_ARM2) := freescale-mx6-arm2 +board-$(CONFIG_MACH_TINY210) := tiny210 machdirs := $(patsubst %,arch/arm/mach-%/,$(machine-y)) diff --git a/arch/arm/boards/tiny210/Makefile b/arch/arm/boards/tiny210/Makefile new file mode 100644 index 0000000..9c38e60 --- /dev/null +++ b/arch/arm/boards/tiny210/Makefile @@ -0,0 +1 @@ +obj-y += tiny210.o lowlevel.o diff --git a/arch/arm/boards/tiny210/config.h b/arch/arm/boards/tiny210/config.h new file mode 100644 index 0000000..5b0a3e6 --- /dev/null +++ b/arch/arm/boards/tiny210/config.h @@ -0,0 +1,21 @@ +#define S5PCXX_CLOCK_REFERENCE 24000000 + +#define set_pll(mdiv, pdiv, sdiv) (1<<31 | mdiv<<16 | pdiv<<8 | sdiv) + +#define BOARD_APLL_VAL set_pll(0x7d, 0x3, 0x1) +#define BOARD_MPLL_VAL set_pll(0x29b, 0xc, 0x1) +#define BOARD_EPLL_VAL set_pll(0x60, 0x6, 0x2) +#define BOARD_VPLL_VAL set_pll(0x6c, 0x6, 0x3) + +#define BOARD_CLK_DIV0_MASK 0xFFFFFFFF +#define BOARD_CLK_DIV0_VAL 0x14131440 +#define BOARD_APLL_LOCKTIME 0x2cf + +#define S5P_DRAM_DDR2 + +#define S5P_DRAM_WR 3 +#define S5P_DRAM_CAS 4 +#define DMC_TIMING_AREF 0x00000618 +#define DMC_TIMING_ROW 0x2B34438A +#define DMC_TIMING_DATA 0x24240000 +#define DMC_TIMING_PWR 0x0BDC0343 diff --git a/arch/arm/boards/tiny210/lowlevel.c b/arch/arm/boards/tiny210/lowlevel.c new file mode 100644 index 0000000..7dbdc69 --- /dev/null +++ b/arch/arm/boards/tiny210/lowlevel.c @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <config.h> +#include <common.h> +#include <init.h> +#include <io.h> +#include <asm/barebox-arm.h> +#include <asm/sections.h> +#include <mach/s3c-iomap.h> +#include <mach/s3c-clocks.h> +#include <mach/s3c-generic.h> + +/* + * iROM boot from MMC + * TODO: replace this by native boot + */ + +#define ADDR_V210_SDMMC_BASE 0xD0037488 +#define ADDR_CopySDMMCtoMem 0xD0037F98 + +#define RR(x) (*(volatile uint32_t*)(x)) + +int __bare_init s5p_irom_load_mmc(void *dest, uint32_t start_block, uint16_t block_count) +{ + typedef uint32_t (*func_t) (int32_t, uint32_t, uint16_t, uint32_t*, int8_t); + uint32_t chbase = RR(ADDR_V210_SDMMC_BASE); + func_t func = (func_t)RR(ADDR_CopySDMMCtoMem); + int chan = (chbase - 0xEB000000) >> 20; + if (chan != 0 && chan != 2) + return 0; + return func(chan, start_block, block_count, (uint32_t*)dest, 0) ? 1 : 0; +} + + +void __bare_init board_init_lowlevel(void) +{ + uint32_t r; + +#ifdef CONFIG_S3C_PLL_INIT + s5p_init_pll(); +#endif + + if (get_pc() < 0xD0000000) /* Are we running from iRAM? */ + return; /* No, we don't. */ + +#ifdef CONFIG_S3C_SDRAM_INIT + s5p_init_dram_bank(S5P_DMC0_BASE, 0x20E00323, 0); +#endif + + if (! s5p_irom_load_mmc((void*)TEXT_BASE - 16, 1, (barebox_image_size + 16 + 511) / 512)) + while (1) { } /* hang */ + + /* Jump to SDRAM */ + r = (unsigned)TEXT_BASE; + __asm__ __volatile__("mov pc, %0" : : "r"(r)); + while (1) { } /* hang */ +} diff --git a/arch/arm/boards/tiny210/tiny210.c b/arch/arm/boards/tiny210/tiny210.c new file mode 100644 index 0000000..f3a5d33 --- /dev/null +++ b/arch/arm/boards/tiny210/tiny210.c @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2012 Alexey Galakhov + * Based on Mini6410 code by Juergen Beisert + * + * Copyright (C) 2012 Juergen Beisert, Pengutronix + * + * In some ways inspired by code + * + * (C) Copyright 2002 + * Sysgo Real-Time Solutions, GmbH <www.elinos.com> + * Marius Groeger <mgroeger@sysgo.de> + * + * (C) Copyright 2002 + * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <common.h> +#include <driver.h> +#include <init.h> +#include <sizes.h> +#include <generated/mach-types.h> +#include <dm9000.h> +#include <gpio.h> +#include <led.h> +#include <io.h> +#include <nand.h> +#include <asm/armlinux.h> +#include <mach/s3c-iomap.h> +#include <mach/s3c-clocks.h> +#include <mach/s3c-generic.h> + + +static const unsigned pin_usage[] = { + /* TODO */ +}; + +static struct gpio_led leds[] = { + { + .gpio = GPJ20, + .led = { + .name = "led1", + } + }, { + .gpio = GPJ21, + .led = { + .name = "led2", + } + }, { + .gpio = GPJ22, + .led = { + .name = "led3", + } + }, { + .gpio = GPJ23, + .led = { + .name = "led4", + } + } +}; + +static int tiny210_mem_init(void) +{ + arm_add_mem_device("ram0", S3C_SDRAM_BASE, s3c_get_memory_size()); + return 0; +} +mem_initcall(tiny210_mem_init); + +static int tiny210_console_init(void) +{ + /* + * configure the UART1 right now, as barebox will + * start to send data immediately + */ + s3c_gpio_mode(GPA00_RXD0 | ENABLE_PU); + s3c_gpio_mode(GPA01_TXD0); + s3c_gpio_mode(GPA02_NCTS0 | ENABLE_PU); + s3c_gpio_mode(GPA03_NRTS0); + + add_generic_device("s3c_serial", -1, NULL, + S3C_UART1_BASE, S3C_UART1_SIZE, + IORESOURCE_MEM, NULL); + return 0; +} +console_initcall(tiny210_console_init); + +static int tiny210_devices_init(void) +{ + int i; + for (i = 0; i < ARRAY_SIZE(pin_usage); i++) + s3c_gpio_mode(pin_usage[i]); + + for (i = 0; i < ARRAY_SIZE(leds); i++) { + leds[i].active_low = 1; + gpio_direction_output(leds[i].gpio, leds[i].active_low); + led_gpio_register(&leds[i]); + } + + armlinux_set_bootparams((void*)S3C_SDRAM_BASE + 0x100); + armlinux_set_architecture(MACH_TYPE_MINI210); + + return 0; +} +device_initcall(tiny210_devices_init); diff --git a/arch/arm/configs/tiny210_defconfig b/arch/arm/configs/tiny210_defconfig new file mode 100644 index 0000000..e9708bf --- /dev/null +++ b/arch/arm/configs/tiny210_defconfig @@ -0,0 +1,17 @@ +CONFIG_ARCH_S5PCxx=y +CONFIG_CPU_V7=y +CONFIG_CPU_32v7=y +CONFIG_BOARDINFO="Tiny 210" +CONFIG_ARCH_BAREBOX_MAX_BARE_INIT_SIZE=0x1ff0 +CONFIG_ARCH_SAMSUNG=y +CONFIG_CPU_S5PV210=y +CONFIG_MACH_TINY210=y +CONFIG_S3C_LOWLEVEL_INIT=y +CONFIG_S3C_PLL_INIT=y +CONFIG_S3C_SDRAM_INIT=y +CONFIG_CMD_LED=y +CONFIG_CMD_LED_TRIGGER=y +CONFIG_DRIVER_SERIAL_S3C=y +CONFIG_LED=y +CONFIG_LED_GPIO=y +CONFIG_LED_TRIGGERS=y diff --git a/arch/arm/mach-samsung/Kconfig b/arch/arm/mach-samsung/Kconfig index 65e2acb..a123854 100644 --- a/arch/arm/mach-samsung/Kconfig +++ b/arch/arm/mach-samsung/Kconfig @@ -8,11 +8,13 @@ config ARCH_TEXT_BASE default 0x31fc0000 if MACH_MINI2440 default 0x31fc0000 if MACH_A9M2440 default 0x31fc0000 if MACH_A9M2410 + default 0x23e00000 if MACH_TINY210 config BOARDINFO default "Mini 2440" if MACH_MINI2440 default "Digi A9M2440" if MACH_A9M2440 default "Digi A9M2410" if MACH_A9M2410 + default "Tiny 210" if MACH_TINY210 config ARCH_BAREBOX_MAX_BARE_INIT_SIZE hex @@ -96,6 +98,11 @@ choice prompt "S5PCxx board type" +config MACH_TINY210 + bool "Tiny 210" + select CPU_S5PV210 + select MACH_HAS_LOWLEVEL_INIT + select MACH_DO_LOWLEVEL_INIT endchoice -- 1.7.10 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2012-05-22 19:12 UTC | newest] Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-05-15 13:20 [PATCHv3 0/7] Cleaned up version of S5PV210 code Alexey Galakhov 2012-05-15 13:20 ` [PATCH 1/7] Make S3C24xx config options available for all S3Cs Alexey Galakhov 2012-05-15 13:20 ` [PATCH 2/7] Split S3C generic and S3C24xx specific code Alexey Galakhov 2012-05-17 17:52 ` Sascha Hauer 2012-05-17 18:33 ` Alexey Galakhov 2012-05-17 19:49 ` Juergen Beisert 2012-05-18 6:49 ` Alexey Galakhov 2012-05-18 8:38 ` Sascha Hauer 2012-05-18 9:06 ` Alexey Galakhov 2012-05-18 8:35 ` Sascha Hauer 2012-05-18 9:43 ` [PATCHv4 0/7] S5PV210 support (upd.) Alexey Galakhov 2012-05-18 9:43 ` [PATCH 1/7] Make S3C24xx config options available for all S3Cs Alexey Galakhov 2012-05-18 9:43 ` [PATCHv4 2/7] Split S3C generic and S3C24xx specific code Alexey Galakhov 2012-05-18 9:43 ` [PATCH 3/7] Add support for Samsung S5P architecture (S5PV210) Alexey Galakhov 2012-05-18 9:43 ` [PATCH 4/7] S5P boot header and image generator Alexey Galakhov 2012-05-18 9:43 ` [PATCHv4 5/7] S5P lowlevel clock init Alexey Galakhov 2012-05-18 9:43 ` [PATCHv4 6/7] S5P DRAM support Alexey Galakhov 2012-05-21 20:02 ` Sascha Hauer 2012-05-22 9:17 ` Alexey Galakhov 2012-05-22 18:29 ` Sascha Hauer 2012-05-22 19:12 ` Alexey Galakhov 2012-05-18 9:43 ` [PATCHv4 7/7] Add FriendlyArm Tiny210 board (S5PV210) Alexey Galakhov 2012-05-21 20:00 ` [PATCHv4 0/7] S5PV210 support (upd.) Sascha Hauer 2012-05-22 9:18 ` Alexey Galakhov 2012-05-15 13:20 ` [PATCH 3/7] Add support for Samsung S5P architecture (S5PV210) Alexey Galakhov 2012-05-15 13:20 ` [PATCH 4/7] S5P boot header and image generator Alexey Galakhov 2012-05-15 13:20 ` [PATCH 5/7] S5P lowlevel clock init Alexey Galakhov 2012-05-15 13:20 ` [PATCH 6/7] S5P DRAM support Alexey Galakhov 2012-05-15 13:20 ` [PATCH 7/7] Add FriendlyArm Tiny210 board (S5PV210) Alexey Galakhov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox