wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2003 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <command.h> |
Ben Warren | d2358c0 | 2008-08-31 10:16:59 -0700 | [diff] [blame] | 10 | #include <netdev.h> |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 11 | #include <asm/addrspace.h> |
| 12 | #include <asm/inca-ip.h> |
Jean-Christophe PLAGNIOL-VILLARD | 089dbb7 | 2007-11-13 09:11:05 +0100 | [diff] [blame] | 13 | #include <asm/io.h> |
Shinya Kuribayashi | 56be1dd | 2008-03-25 21:30:07 +0900 | [diff] [blame] | 14 | #include <asm/reboot.h> |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 15 | |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 16 | extern uint incaip_get_cpuclk(void); |
| 17 | |
Shinya Kuribayashi | 56be1dd | 2008-03-25 21:30:07 +0900 | [diff] [blame] | 18 | void _machine_restart(void) |
| 19 | { |
| 20 | *INCA_IP_WDT_RST_REQ = 0x3f; |
| 21 | } |
| 22 | |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 23 | static ulong max_sdram_size(void) |
| 24 | { |
| 25 | /* The only supported SDRAM data width is 16bit. |
| 26 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 27 | #define CONFIG_SYS_DW 2 |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 28 | |
| 29 | /* The only supported number of SDRAM banks is 4. |
| 30 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 31 | #define CONFIG_SYS_NB 4 |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 32 | |
| 33 | ulong cfgpb0 = *INCA_IP_SDRAM_MC_CFGPB0; |
| 34 | int cols = cfgpb0 & 0xF; |
| 35 | int rows = (cfgpb0 & 0xF0) >> 4; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 36 | ulong size = (1 << (rows + cols)) * CONFIG_SYS_DW * CONFIG_SYS_NB; |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 37 | |
| 38 | return size; |
| 39 | } |
| 40 | |
Becky Bruce | bd99ae7 | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 41 | phys_size_t initdram(int board_type) |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 42 | { |
| 43 | int rows, cols, best_val = *INCA_IP_SDRAM_MC_CFGPB0; |
| 44 | ulong size, max_size = 0; |
| 45 | ulong our_address; |
| 46 | |
| 47 | asm volatile ("move %0, $25" : "=r" (our_address) :); |
| 48 | |
| 49 | /* Can't probe for RAM size unless we are running from Flash. |
| 50 | */ |
Shinya Kuribayashi | 6c6b261 | 2008-06-05 22:29:00 +0900 | [diff] [blame] | 51 | if (CPHYSADDR(our_address) < CPHYSADDR(PHYS_FLASH_1)) |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 52 | { |
| 53 | return max_sdram_size(); |
| 54 | } |
| 55 | |
| 56 | for (cols = 0x8; cols <= 0xC; cols++) |
| 57 | { |
| 58 | for (rows = 0xB; rows <= 0xD; rows++) |
| 59 | { |
| 60 | *INCA_IP_SDRAM_MC_CFGPB0 = (0x14 << 8) | |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 61 | (rows << 4) | cols; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 62 | size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 63 | max_sdram_size()); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 64 | |
| 65 | if (size > max_size) |
| 66 | { |
| 67 | best_val = *INCA_IP_SDRAM_MC_CFGPB0; |
| 68 | max_size = size; |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | *INCA_IP_SDRAM_MC_CFGPB0 = best_val; |
| 74 | return max_size; |
| 75 | } |
| 76 | |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 77 | int checkboard (void) |
| 78 | { |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 79 | unsigned long chipid = *INCA_IP_WDT_CHIPID; |
| 80 | int part_num; |
| 81 | |
| 82 | puts ("Board: INCA-IP "); |
| 83 | part_num = (chipid >> 12) & 0xffff; |
| 84 | switch (part_num) { |
| 85 | case 0xc0: |
| 86 | printf ("Standard Version, "); |
| 87 | break; |
| 88 | case 0xc1: |
| 89 | printf ("Basic Version, "); |
| 90 | break; |
| 91 | default: |
| 92 | printf ("Unknown Part Number 0x%x ", part_num); |
| 93 | break; |
| 94 | } |
| 95 | |
| 96 | printf ("Chip V1.%ld, ", (chipid >> 28)); |
| 97 | |
| 98 | printf("CPU Speed %d MHz\n", incaip_get_cpuclk()/1000000); |
| 99 | |
Jean-Christophe PLAGNIOL-VILLARD | 089dbb7 | 2007-11-13 09:11:05 +0100 | [diff] [blame] | 100 | set_io_port_base(0); |
| 101 | |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 102 | return 0; |
| 103 | } |
Ben Warren | d2358c0 | 2008-08-31 10:16:59 -0700 | [diff] [blame] | 104 | |
| 105 | #if defined(CONFIG_INCA_IP_SWITCH) |
| 106 | int board_eth_init(bd_t *bis) |
| 107 | { |
| 108 | return inca_switch_initialize(bis); |
| 109 | } |
| 110 | #endif |