Julien May | 5c374c9 | 2008-06-23 13:57:52 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 Miromico AG |
| 3 | * |
| 4 | * Mostly copied form atmel ATNGW100 sources |
| 5 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 6 | * SPDX-License-Identifier: GPL-2.0+ |
Julien May | 5c374c9 | 2008-06-23 13:57:52 +0200 | [diff] [blame] | 7 | */ |
| 8 | |
Julien May | 5c374c9 | 2008-06-23 13:57:52 +0200 | [diff] [blame] | 9 | #include <common.h> |
Ben Warren | 89973f8 | 2008-08-31 22:22:04 -0700 | [diff] [blame] | 10 | #include <netdev.h> |
Julien May | 5c374c9 | 2008-06-23 13:57:52 +0200 | [diff] [blame] | 11 | |
| 12 | #include <asm/io.h> |
| 13 | #include <asm/sdram.h> |
| 14 | #include <asm/arch/clk.h> |
Julien May | 5c374c9 | 2008-06-23 13:57:52 +0200 | [diff] [blame] | 15 | #include <asm/arch/hmatrix.h> |
Andreas Bießmann | 5d73bc7 | 2010-11-04 23:15:30 +0000 | [diff] [blame] | 16 | #include <asm/arch/hardware.h> |
Haavard Skinnemoen | 1f36f73 | 2010-08-12 13:52:54 +0700 | [diff] [blame] | 17 | #include <asm/arch/mmu.h> |
Haavard Skinnemoen | ab0df36 | 2008-08-29 21:09:49 +0200 | [diff] [blame] | 18 | #include <asm/arch/portmux.h> |
Julien May | 5c374c9 | 2008-06-23 13:57:52 +0200 | [diff] [blame] | 19 | |
| 20 | DECLARE_GLOBAL_DATA_PTR; |
| 21 | |
Haavard Skinnemoen | 1f36f73 | 2010-08-12 13:52:54 +0700 | [diff] [blame] | 22 | struct mmu_vm_range mmu_vmr_table[CONFIG_SYS_NR_VM_REGIONS] = { |
| 23 | { |
Andreas Bießmann | e9ed41c | 2015-02-06 23:06:42 +0100 | [diff] [blame] | 24 | .virt_pgno = CONFIG_SYS_FLASH_BASE >> MMU_PAGE_SHIFT, |
| 25 | .nr_pages = CONFIG_SYS_FLASH_SIZE >> MMU_PAGE_SHIFT, |
| 26 | .phys = (CONFIG_SYS_FLASH_BASE >> MMU_PAGE_SHIFT) |
Haavard Skinnemoen | 1f36f73 | 2010-08-12 13:52:54 +0700 | [diff] [blame] | 27 | | MMU_VMR_CACHE_NONE, |
| 28 | }, { |
Andreas Bießmann | e9ed41c | 2015-02-06 23:06:42 +0100 | [diff] [blame] | 29 | .virt_pgno = CONFIG_SYS_SDRAM_BASE >> MMU_PAGE_SHIFT, |
| 30 | .nr_pages = EBI_SDRAM_SIZE >> MMU_PAGE_SHIFT, |
| 31 | .phys = (CONFIG_SYS_SDRAM_BASE >> MMU_PAGE_SHIFT) |
Haavard Skinnemoen | 1f36f73 | 2010-08-12 13:52:54 +0700 | [diff] [blame] | 32 | | MMU_VMR_CACHE_WRBACK, |
| 33 | }, |
| 34 | }; |
| 35 | |
Julien May | 5c374c9 | 2008-06-23 13:57:52 +0200 | [diff] [blame] | 36 | static const struct sdram_config sdram_config = { |
| 37 | .data_bits = SDRAM_DATA_32BIT, |
| 38 | .row_bits = 13, |
| 39 | .col_bits = 9, |
| 40 | .bank_bits = 2, |
| 41 | .cas = 3, |
| 42 | .twr = 2, |
| 43 | .trc = 7, |
| 44 | .trp = 2, |
| 45 | .trcd = 2, |
| 46 | .tras = 5, |
| 47 | .txsr = 5, |
| 48 | /* 7.81 us */ |
| 49 | .refresh_period = (781 * (SDRAMC_BUS_HZ / 1000)) / 100000, |
| 50 | }; |
| 51 | |
Julien May | 5c374c9 | 2008-06-23 13:57:52 +0200 | [diff] [blame] | 52 | #ifdef CONFIG_CMD_NET |
| 53 | int board_eth_init(bd_t *bis) |
| 54 | { |
Andreas Bießmann | f4278b7 | 2010-11-04 23:15:31 +0000 | [diff] [blame] | 55 | return macb_eth_initialize(0, (void *)ATMEL_BASE_MACB0, |
| 56 | bis->bi_phy_id[0]); |
Julien May | 5c374c9 | 2008-06-23 13:57:52 +0200 | [diff] [blame] | 57 | } |
| 58 | #endif |
| 59 | |
| 60 | int board_early_init_f(void) |
| 61 | { |
| 62 | /* Enable SDRAM in the EBI mux */ |
| 63 | hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE)); |
| 64 | |
Haavard Skinnemoen | ab0df36 | 2008-08-29 21:09:49 +0200 | [diff] [blame] | 65 | portmux_enable_ebi(32, 23, 0, PORTMUX_DRIVE_HIGH); |
Andreas Bießmann | 1866786 | 2015-02-06 23:06:43 +0100 | [diff] [blame] | 66 | sdram_init(uncached(EBI_SDRAM_BASE), &sdram_config); |
| 67 | |
Haavard Skinnemoen | ab0df36 | 2008-08-29 21:09:49 +0200 | [diff] [blame] | 68 | portmux_enable_usart1(PORTMUX_DRIVE_MIN); |
Julien May | 5c374c9 | 2008-06-23 13:57:52 +0200 | [diff] [blame] | 69 | |
| 70 | #if defined(CONFIG_MACB) |
Haavard Skinnemoen | ab0df36 | 2008-08-29 21:09:49 +0200 | [diff] [blame] | 71 | portmux_enable_macb0(PORTMUX_MACB_MII, PORTMUX_DRIVE_HIGH); |
Julien May | 5c374c9 | 2008-06-23 13:57:52 +0200 | [diff] [blame] | 72 | #endif |
| 73 | #if defined(CONFIG_MMC) |
Haavard Skinnemoen | ab0df36 | 2008-08-29 21:09:49 +0200 | [diff] [blame] | 74 | portmux_enable_mmci(0, PORTMUX_MMCI_4BIT, PORTMUX_DRIVE_LOW); |
Julien May | 5c374c9 | 2008-06-23 13:57:52 +0200 | [diff] [blame] | 75 | #endif |
| 76 | return 0; |
| 77 | } |
| 78 | |
Haavard Skinnemoen | 25e6854 | 2008-08-31 18:46:35 +0200 | [diff] [blame] | 79 | int board_early_init_r(void) |
Julien May | 5c374c9 | 2008-06-23 13:57:52 +0200 | [diff] [blame] | 80 | { |
| 81 | gd->bd->bi_phy_id[0] = 0x01; |
Haavard Skinnemoen | 25e6854 | 2008-08-31 18:46:35 +0200 | [diff] [blame] | 82 | return 0; |
Julien May | 5c374c9 | 2008-06-23 13:57:52 +0200 | [diff] [blame] | 83 | } |
| 84 | |
Haavard Skinnemoen | 36d375f | 2008-08-31 18:24:24 +0200 | [diff] [blame] | 85 | int board_postclk_init(void) |
Julien May | 5c374c9 | 2008-06-23 13:57:52 +0200 | [diff] [blame] | 86 | { |
| 87 | /* Hammerhead boards uses GCLK3 as 25MHz output to ethernet PHY */ |
Haavard Skinnemoen | abdde2b | 2008-08-31 18:07:35 +0200 | [diff] [blame] | 88 | gclk_enable_output(3, PORTMUX_DRIVE_LOW); |
| 89 | gclk_set_rate(3, GCLK_PARENT_OSC0, 25000000); |
Haavard Skinnemoen | 36d375f | 2008-08-31 18:24:24 +0200 | [diff] [blame] | 90 | return 0; |
Julien May | 5c374c9 | 2008-06-23 13:57:52 +0200 | [diff] [blame] | 91 | } |