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) | d0b375f | 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 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 9 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <common.h> |
Ben Warren | b1c0eaa | 2009-08-25 13:09:37 -0700 | [diff] [blame] | 13 | #include <netdev.h> |
David Müller (ELSOFT AG) | d0b375f | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 14 | #include <asm/io.h> |
kevin.morfitt@fearnside-systems.co.uk | ac67804 | 2009-11-17 18:30:34 +0900 | [diff] [blame] | 15 | #include <asm/arch/s3c24x0_cpu.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 16 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 17 | DECLARE_GLOBAL_DATA_PTR; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 18 | |
| 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) | d0b375f | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 43 | static inline void pll_delay(unsigned long loops) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 44 | { |
| 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) | d0b375f | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 54 | int board_early_init_f(void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 55 | { |
kevin.morfitt@fearnside-systems.co.uk | eb0ae7f | 2009-10-10 13:33:11 +0900 | [diff] [blame] | 56 | struct s3c24x0_clock_power * const clk_power = |
| 57 | s3c24x0_get_base_clock_power(); |
| 58 | struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio(); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 59 | |
| 60 | /* to reduce PLL lock time, adjust the LOCKTIME register */ |
David Müller (ELSOFT AG) | d0b375f | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 61 | writel(0xFFFFFF, &clk_power->locktime); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 62 | |
| 63 | /* configure MPLL */ |
David Müller (ELSOFT AG) | d0b375f | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 64 | writel((M_MDIV << 12) + (M_PDIV << 4) + M_SDIV, |
| 65 | &clk_power->mpllcon); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 66 | |
| 67 | /* some delay between MPLL and UPLL */ |
David Müller (ELSOFT AG) | d0b375f | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 68 | pll_delay(4000); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 69 | |
| 70 | /* configure UPLL */ |
David Müller (ELSOFT AG) | d0b375f | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 71 | writel((U_M_MDIV << 12) + (U_M_PDIV << 4) + U_M_SDIV, |
| 72 | &clk_power->upllcon); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 73 | |
| 74 | /* some delay between MPLL and UPLL */ |
David Müller (ELSOFT AG) | d0b375f | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 75 | pll_delay(8000); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 76 | |
| 77 | /* set up the I/O ports */ |
David Müller (ELSOFT AG) | d0b375f | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 78 | 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); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 93 | |
David Müller (ELSOFT AG) | d0b375f | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 94 | return 0; |
| 95 | } |
| 96 | |
| 97 | int board_init(void) |
| 98 | { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 99 | /* arch number of SMDK2410-Board */ |
wdenk | 731215e | 2004-10-10 18:41:04 +0000 | [diff] [blame] | 100 | gd->bd->bi_arch_number = MACH_TYPE_SMDK2410; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 101 | |
| 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) | d0b375f | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 111 | int dram_init(void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 112 | { |
David Müller (ELSOFT AG) | d0b375f | 2011-03-24 22:28:06 +0000 | [diff] [blame] | 113 | /* dram_init must store complete ramsize in gd->ram_size */ |
| 114 | gd->ram_size = PHYS_SDRAM_1_SIZE; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 115 | return 0; |
| 116 | } |
Ben Warren | b1c0eaa | 2009-08-25 13:09:37 -0700 | [diff] [blame] | 117 | |
| 118 | #ifdef CONFIG_CMD_NET |
| 119 | int 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) | a5ec7f6 | 2011-03-24 22:28:05 +0000 | [diff] [blame] | 128 | |
| 129 | /* |
| 130 | * Hardcoded flash setup: |
| 131 | * Flash 0 is a non-CFI AMD AM29LV800BB flash. |
| 132 | */ |
| 133 | ulong 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 | } |