blob: b75a0e34ddbceb0b596dd2432b997e03fa11a529 [file] [log] [blame]
wdenkc6097192002-11-03 00:24:07 +00001/*
2 * (C) Copyright 2002
3 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
4 * Marius Groeger <mgroeger@sysgo.de>
5 *
David Müller (ELSOFT AG)67a61312011-03-24 22:28:06 +00006 * (C) Copyright 2002, 2010
wdenkc6097192002-11-03 00:24:07 +00007 * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch>
8 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02009 * SPDX-License-Identifier: GPL-2.0+
wdenkc6097192002-11-03 00:24:07 +000010 */
11
12#include <common.h>
Ben Warren3bf5d832009-08-25 13:09:37 -070013#include <netdev.h>
David Müller (ELSOFT AG)67a61312011-03-24 22:28:06 +000014#include <asm/io.h>
kevin.morfitt@fearnside-systems.co.uke0d81312009-11-17 18:30:34 +090015#include <asm/arch/s3c24x0_cpu.h>
wdenkc6097192002-11-03 00:24:07 +000016
Wolfgang Denk6405a152006-03-31 18:32:53 +020017DECLARE_GLOBAL_DATA_PTR;
wdenkc6097192002-11-03 00:24:07 +000018
19#define FCLK_SPEED 1
20
21#if FCLK_SPEED==0 /* Fout = 203MHz, Fin = 12MHz for Audio */
22#define M_MDIV 0xC3
23#define M_PDIV 0x4
24#define M_SDIV 0x1
25#elif FCLK_SPEED==1 /* Fout = 202.8MHz */
26#define M_MDIV 0xA1
27#define M_PDIV 0x3
28#define M_SDIV 0x1
29#endif
30
31#define USB_CLOCK 1
32
33#if USB_CLOCK==0
34#define U_M_MDIV 0xA1
35#define U_M_PDIV 0x3
36#define U_M_SDIV 0x1
37#elif USB_CLOCK==1
38#define U_M_MDIV 0x48
39#define U_M_PDIV 0x3
40#define U_M_SDIV 0x2
41#endif
42
David Müller (ELSOFT AG)67a61312011-03-24 22:28:06 +000043static inline void pll_delay(unsigned long loops)
wdenkc6097192002-11-03 00:24:07 +000044{
45 __asm__ volatile ("1:\n"
46 "subs %0, %1, #1\n"
47 "bne 1b":"=r" (loops):"0" (loops));
48}
49
50/*
51 * Miscellaneous platform dependent initialisations
52 */
53
David Müller (ELSOFT AG)67a61312011-03-24 22:28:06 +000054int board_early_init_f(void)
wdenkc6097192002-11-03 00:24:07 +000055{
kevin.morfitt@fearnside-systems.co.uk1464f4d2009-10-10 13:33:11 +090056 struct s3c24x0_clock_power * const clk_power =
57 s3c24x0_get_base_clock_power();
58 struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
wdenkc6097192002-11-03 00:24:07 +000059
60 /* to reduce PLL lock time, adjust the LOCKTIME register */
David Müller (ELSOFT AG)67a61312011-03-24 22:28:06 +000061 writel(0xFFFFFF, &clk_power->locktime);
wdenkc6097192002-11-03 00:24:07 +000062
63 /* configure MPLL */
David Müller (ELSOFT AG)67a61312011-03-24 22:28:06 +000064 writel((M_MDIV << 12) + (M_PDIV << 4) + M_SDIV,
65 &clk_power->mpllcon);
wdenkc6097192002-11-03 00:24:07 +000066
67 /* some delay between MPLL and UPLL */
David Müller (ELSOFT AG)67a61312011-03-24 22:28:06 +000068 pll_delay(4000);
wdenkc6097192002-11-03 00:24:07 +000069
70 /* configure UPLL */
David Müller (ELSOFT AG)67a61312011-03-24 22:28:06 +000071 writel((U_M_MDIV << 12) + (U_M_PDIV << 4) + U_M_SDIV,
72 &clk_power->upllcon);
wdenkc6097192002-11-03 00:24:07 +000073
74 /* some delay between MPLL and UPLL */
David Müller (ELSOFT AG)67a61312011-03-24 22:28:06 +000075 pll_delay(8000);
wdenkc6097192002-11-03 00:24:07 +000076
77 /* set up the I/O ports */
David Müller (ELSOFT AG)67a61312011-03-24 22:28:06 +000078 writel(0x007FFFFF, &gpio->gpacon);
79 writel(0x00044555, &gpio->gpbcon);
80 writel(0x000007FF, &gpio->gpbup);
81 writel(0xAAAAAAAA, &gpio->gpccon);
82 writel(0x0000FFFF, &gpio->gpcup);
83 writel(0xAAAAAAAA, &gpio->gpdcon);
84 writel(0x0000FFFF, &gpio->gpdup);
85 writel(0xAAAAAAAA, &gpio->gpecon);
86 writel(0x0000FFFF, &gpio->gpeup);
87 writel(0x000055AA, &gpio->gpfcon);
88 writel(0x000000FF, &gpio->gpfup);
89 writel(0xFF95FFBA, &gpio->gpgcon);
90 writel(0x0000FFFF, &gpio->gpgup);
91 writel(0x002AFAAA, &gpio->gphcon);
92 writel(0x000007FF, &gpio->gphup);
wdenkc6097192002-11-03 00:24:07 +000093
David Müller (ELSOFT AG)67a61312011-03-24 22:28:06 +000094 return 0;
95}
96
97int board_init(void)
98{
wdenkc6097192002-11-03 00:24:07 +000099 /* arch number of SMDK2410-Board */
wdenk767fbd42004-10-10 18:41:04 +0000100 gd->bd->bi_arch_number = MACH_TYPE_SMDK2410;
wdenkc6097192002-11-03 00:24:07 +0000101
102 /* adress of boot parameters */
103 gd->bd->bi_boot_params = 0x30000100;
104
105 icache_enable();
106 dcache_enable();
107
108 return 0;
109}
110
David Müller (ELSOFT AG)67a61312011-03-24 22:28:06 +0000111int dram_init(void)
wdenkc6097192002-11-03 00:24:07 +0000112{
David Müller (ELSOFT AG)67a61312011-03-24 22:28:06 +0000113 /* dram_init must store complete ramsize in gd->ram_size */
114 gd->ram_size = PHYS_SDRAM_1_SIZE;
wdenkc6097192002-11-03 00:24:07 +0000115 return 0;
116}
Ben Warren3bf5d832009-08-25 13:09:37 -0700117
118#ifdef CONFIG_CMD_NET
119int board_eth_init(bd_t *bis)
120{
121 int rc = 0;
122#ifdef CONFIG_CS8900
123 rc = cs8900_initialize(0, CONFIG_CS8900_BASE);
124#endif
125 return rc;
126}
127#endif
David Müller (ELSOFT AG)14899222011-03-24 22:28:05 +0000128
129/*
130 * Hardcoded flash setup:
131 * Flash 0 is a non-CFI AMD AM29LV800BB flash.
132 */
133ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
134{
135 info->portwidth = FLASH_CFI_16BIT;
136 info->chipwidth = FLASH_CFI_BY16;
137 info->interface = FLASH_CFI_X16;
138 return 1;
139}