Dirk Eibach | b209a11 | 2009-07-17 14:16:40 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2009 |
| 3 | * Dirk Eibach, Guntermann & Drunck GmbH, eibach@gdsys.de |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
| 25 | #include <command.h> |
| 26 | #include <asm/processor.h> |
| 27 | #include <asm/io.h> |
Stefan Roese | 0988776 | 2010-09-16 14:30:37 +0200 | [diff] [blame] | 28 | #include <asm/ppc4xx-gpio.h> |
Dirk Eibach | b209a11 | 2009-07-17 14:16:40 +0200 | [diff] [blame] | 29 | |
| 30 | enum { |
| 31 | HWTYPE_DLVISION_CPU = 0, |
| 32 | HWTYPE_DLVISION_CON = 1, |
| 33 | }; |
| 34 | |
| 35 | #define HWREV_100 6 |
| 36 | |
| 37 | int board_early_init_f(void) |
| 38 | { |
Stefan Roese | 952e776 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 39 | mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */ |
| 40 | mtdcr(UIC0ER, 0x00000000); /* disable all ints */ |
| 41 | mtdcr(UIC0CR, 0x00000000); /* set all to be non-critical */ |
| 42 | mtdcr(UIC0PR, 0xFFFFFF80); /* set int polarities */ |
| 43 | mtdcr(UIC0TR, 0x10000000); /* set int trigger levels */ |
| 44 | mtdcr(UIC0VCR, 0x00000001); /* set vect base=0,INT0 highest prio */ |
| 45 | mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */ |
Dirk Eibach | b209a11 | 2009-07-17 14:16:40 +0200 | [diff] [blame] | 46 | |
| 47 | /* |
| 48 | * EBC Configuration Register: set ready timeout to 512 ebc-clks |
| 49 | * -> ca. 15 us |
| 50 | */ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 51 | mtebc(EBC0_CFG, 0xa8400000); /* ebc always driven */ |
Dirk Eibach | b209a11 | 2009-07-17 14:16:40 +0200 | [diff] [blame] | 52 | |
| 53 | /* |
| 54 | * setup io-latches |
| 55 | */ |
| 56 | out_le16((void *)CONFIG_SYS_LATCH_BASE, 0x00f0); |
| 57 | out_le16((void *)(CONFIG_SYS_LATCH_BASE + 0x100), 0x0002); |
| 58 | out_le16((void *)(CONFIG_SYS_LATCH_BASE + 0x200), 0x0000); |
| 59 | return 0; |
| 60 | } |
| 61 | |
| 62 | int misc_init_r(void) |
| 63 | { |
| 64 | /* |
| 65 | * set "startup-finished"-gpios |
| 66 | */ |
| 67 | gpio_write_bit(21, 0); |
| 68 | gpio_write_bit(22, 1); |
| 69 | |
| 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | /* |
| 74 | * Check Board Identity: |
| 75 | */ |
| 76 | int checkboard(void) |
| 77 | { |
Wolfgang Denk | f0c0b3a | 2011-05-04 10:32:28 +0000 | [diff] [blame] | 78 | char buf[64]; |
| 79 | int i = getenv_f("serial#", buf, sizeof(buf)); |
Dirk Eibach | b209a11 | 2009-07-17 14:16:40 +0200 | [diff] [blame] | 80 | u8 channel2_msr = in_8((void *)CONFIG_UART_BASE + 0x26); |
| 81 | u8 channel3_msr = in_8((void *)CONFIG_UART_BASE + 0x36); |
| 82 | u8 channel7_msr = in_8((void *)CONFIG_UART_BASE + 0x76); |
| 83 | u8 unit_type; |
| 84 | u8 local_con; |
| 85 | u8 audio; |
| 86 | u8 hardware_version; |
| 87 | |
| 88 | printf("Board: "); |
| 89 | |
| 90 | unit_type = (channel2_msr & 0x80) ? 0x01 : 0x00; |
| 91 | local_con = (channel2_msr & 0x20) ? 0x01 : 0x00; |
| 92 | audio = (channel3_msr & 0x20) ? 0x01 : 0x00; |
| 93 | hardware_version = |
| 94 | ((channel7_msr & 0x20) ? 0x01 : 0x00) |
| 95 | | ((channel7_msr & 0x80) ? 0x02 : 0x00) |
| 96 | | ((channel7_msr & 0x40) ? 0x04 : 0x00); |
| 97 | |
| 98 | switch (unit_type) { |
| 99 | case HWTYPE_DLVISION_CON: |
| 100 | printf("DL-Vision-CON"); |
| 101 | break; |
| 102 | |
| 103 | case HWTYPE_DLVISION_CPU: |
| 104 | printf("DL-Vision-CPU"); |
| 105 | break; |
| 106 | |
| 107 | default: |
| 108 | printf("UnitType %d, unsupported", unit_type); |
| 109 | break; |
| 110 | } |
| 111 | |
Wolfgang Denk | f0c0b3a | 2011-05-04 10:32:28 +0000 | [diff] [blame] | 112 | if (i > 0) { |
Dirk Eibach | b209a11 | 2009-07-17 14:16:40 +0200 | [diff] [blame] | 113 | puts(", serial# "); |
Wolfgang Denk | f0c0b3a | 2011-05-04 10:32:28 +0000 | [diff] [blame] | 114 | puts(buf); |
Dirk Eibach | b209a11 | 2009-07-17 14:16:40 +0200 | [diff] [blame] | 115 | } |
| 116 | puts("\n "); |
| 117 | |
| 118 | switch (hardware_version) { |
| 119 | case HWREV_100: |
| 120 | printf("HW-Ver 1.00"); |
| 121 | break; |
| 122 | |
| 123 | default: |
| 124 | printf("HW-Ver %d, unsupported", |
| 125 | hardware_version); |
| 126 | break; |
| 127 | } |
| 128 | |
| 129 | if (local_con) |
| 130 | printf(", local console"); |
| 131 | |
| 132 | if (audio) |
| 133 | printf(", audio support"); |
| 134 | |
| 135 | puts("\n"); |
| 136 | |
| 137 | return 0; |
| 138 | } |