wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /* |
| 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) | 67a6131 | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 6 | * (C) Copyright 2002, 2010 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 7 | * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch> |
| 8 | * |
| 9 | * See file CREDITS for list of people who contributed to this |
| 10 | * project. |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License as |
| 14 | * published by the Free Software Foundation; either version 2 of |
| 15 | * the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 25 | * MA 02111-1307 USA |
| 26 | */ |
| 27 | |
| 28 | #include <common.h> |
Ben Warren | 3bf5d83 | 2009-08-25 13:09:37 -0700 | [diff] [blame] | 29 | #include <netdev.h> |
David Müller (ELSOFT AG) | 67a6131 | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 30 | #include <asm/io.h> |
kevin.morfitt@fearnside-systems.co.uk | e0d8131 | 2009-11-17 18:30:34 +0900 | [diff] [blame] | 31 | #include <asm/arch/s3c24x0_cpu.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 32 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 33 | DECLARE_GLOBAL_DATA_PTR; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 34 | |
| 35 | #define FCLK_SPEED 1 |
| 36 | |
| 37 | #if FCLK_SPEED==0 /* Fout = 203MHz, Fin = 12MHz for Audio */ |
| 38 | #define M_MDIV 0xC3 |
| 39 | #define M_PDIV 0x4 |
| 40 | #define M_SDIV 0x1 |
| 41 | #elif FCLK_SPEED==1 /* Fout = 202.8MHz */ |
| 42 | #define M_MDIV 0xA1 |
| 43 | #define M_PDIV 0x3 |
| 44 | #define M_SDIV 0x1 |
| 45 | #endif |
| 46 | |
| 47 | #define USB_CLOCK 1 |
| 48 | |
| 49 | #if USB_CLOCK==0 |
| 50 | #define U_M_MDIV 0xA1 |
| 51 | #define U_M_PDIV 0x3 |
| 52 | #define U_M_SDIV 0x1 |
| 53 | #elif USB_CLOCK==1 |
| 54 | #define U_M_MDIV 0x48 |
| 55 | #define U_M_PDIV 0x3 |
| 56 | #define U_M_SDIV 0x2 |
| 57 | #endif |
| 58 | |
David Müller (ELSOFT AG) | 67a6131 | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 59 | static inline void pll_delay(unsigned long loops) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 60 | { |
| 61 | __asm__ volatile ("1:\n" |
| 62 | "subs %0, %1, #1\n" |
| 63 | "bne 1b":"=r" (loops):"0" (loops)); |
| 64 | } |
| 65 | |
| 66 | /* |
| 67 | * Miscellaneous platform dependent initialisations |
| 68 | */ |
| 69 | |
David Müller (ELSOFT AG) | 67a6131 | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 70 | int board_early_init_f(void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 71 | { |
kevin.morfitt@fearnside-systems.co.uk | 1464f4d | 2009-10-10 13:33:11 +0900 | [diff] [blame] | 72 | struct s3c24x0_clock_power * const clk_power = |
| 73 | s3c24x0_get_base_clock_power(); |
| 74 | struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio(); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 75 | |
| 76 | /* to reduce PLL lock time, adjust the LOCKTIME register */ |
David Müller (ELSOFT AG) | 67a6131 | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 77 | writel(0xFFFFFF, &clk_power->locktime); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 78 | |
| 79 | /* configure MPLL */ |
David Müller (ELSOFT AG) | 67a6131 | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 80 | writel((M_MDIV << 12) + (M_PDIV << 4) + M_SDIV, |
| 81 | &clk_power->mpllcon); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 82 | |
| 83 | /* some delay between MPLL and UPLL */ |
David Müller (ELSOFT AG) | 67a6131 | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 84 | pll_delay(4000); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 85 | |
| 86 | /* configure UPLL */ |
David Müller (ELSOFT AG) | 67a6131 | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 87 | writel((U_M_MDIV << 12) + (U_M_PDIV << 4) + U_M_SDIV, |
| 88 | &clk_power->upllcon); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 89 | |
| 90 | /* some delay between MPLL and UPLL */ |
David Müller (ELSOFT AG) | 67a6131 | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 91 | pll_delay(8000); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 92 | |
| 93 | /* set up the I/O ports */ |
David Müller (ELSOFT AG) | 67a6131 | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 94 | writel(0x007FFFFF, &gpio->gpacon); |
| 95 | writel(0x00044555, &gpio->gpbcon); |
| 96 | writel(0x000007FF, &gpio->gpbup); |
| 97 | writel(0xAAAAAAAA, &gpio->gpccon); |
| 98 | writel(0x0000FFFF, &gpio->gpcup); |
| 99 | writel(0xAAAAAAAA, &gpio->gpdcon); |
| 100 | writel(0x0000FFFF, &gpio->gpdup); |
| 101 | writel(0xAAAAAAAA, &gpio->gpecon); |
| 102 | writel(0x0000FFFF, &gpio->gpeup); |
| 103 | writel(0x000055AA, &gpio->gpfcon); |
| 104 | writel(0x000000FF, &gpio->gpfup); |
| 105 | writel(0xFF95FFBA, &gpio->gpgcon); |
| 106 | writel(0x0000FFFF, &gpio->gpgup); |
| 107 | writel(0x002AFAAA, &gpio->gphcon); |
| 108 | writel(0x000007FF, &gpio->gphup); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 109 | |
David Müller (ELSOFT AG) | 67a6131 | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 110 | return 0; |
| 111 | } |
| 112 | |
| 113 | int board_init(void) |
| 114 | { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 115 | /* arch number of SMDK2410-Board */ |
wdenk | 767fbd4 | 2004-10-10 18:41:04 +0000 | [diff] [blame] | 116 | gd->bd->bi_arch_number = MACH_TYPE_SMDK2410; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 117 | |
| 118 | /* adress of boot parameters */ |
| 119 | gd->bd->bi_boot_params = 0x30000100; |
| 120 | |
| 121 | icache_enable(); |
| 122 | dcache_enable(); |
| 123 | |
| 124 | return 0; |
| 125 | } |
| 126 | |
David Müller (ELSOFT AG) | 67a6131 | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 127 | int dram_init(void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 128 | { |
David Müller (ELSOFT AG) | 67a6131 | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 129 | /* dram_init must store complete ramsize in gd->ram_size */ |
| 130 | gd->ram_size = PHYS_SDRAM_1_SIZE; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 131 | return 0; |
| 132 | } |
Ben Warren | 3bf5d83 | 2009-08-25 13:09:37 -0700 | [diff] [blame] | 133 | |
| 134 | #ifdef CONFIG_CMD_NET |
| 135 | int board_eth_init(bd_t *bis) |
| 136 | { |
| 137 | int rc = 0; |
| 138 | #ifdef CONFIG_CS8900 |
| 139 | rc = cs8900_initialize(0, CONFIG_CS8900_BASE); |
| 140 | #endif |
| 141 | return rc; |
| 142 | } |
| 143 | #endif |
David Müller (ELSOFT AG) | 1489922 | 2011-03-24 22:28:05 +0000 | [diff] [blame] | 144 | |
| 145 | /* |
| 146 | * Hardcoded flash setup: |
| 147 | * Flash 0 is a non-CFI AMD AM29LV800BB flash. |
| 148 | */ |
| 149 | ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info) |
| 150 | { |
| 151 | info->portwidth = FLASH_CFI_16BIT; |
| 152 | info->chipwidth = FLASH_CFI_BY16; |
| 153 | info->interface = FLASH_CFI_X16; |
| 154 | return 1; |
| 155 | } |