Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 1 | /* |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 2 | * (C) Copyright 2010-2011 |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 3 | * Daniel Gorsulowski <daniel.gorsulowski@esd.eu> |
| 4 | * esd electronic system design gmbh <www.esd.eu> |
| 5 | * |
| 6 | * (C) Copyright 2007-2008 |
Stelian Pop | c9e798d | 2011-11-01 00:00:39 +0100 | [diff] [blame] | 7 | * Stelian Pop <stelian@popies.net> |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 8 | * Lead Tech Design <www.leadtechdesign.com> |
| 9 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 10 | * SPDX-License-Identifier: GPL-2.0+ |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #include <common.h> |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 14 | #include <asm/io.h> |
Andreas Bießmann | ac45bb1 | 2013-11-29 12:13:45 +0100 | [diff] [blame] | 15 | #include <asm/gpio.h> |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 16 | #include <asm/arch/at91sam9_smc.h> |
| 17 | #include <asm/arch/at91_common.h> |
| 18 | #include <asm/arch/at91_pmc.h> |
| 19 | #include <asm/arch/at91_rstc.h> |
Daniel Gorsulowski | 6258b04 | 2010-02-11 14:57:04 +0100 | [diff] [blame] | 20 | #include <asm/arch/at91_matrix.h> |
| 21 | #include <asm/arch/at91_pio.h> |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 22 | #include <asm/arch/clk.h> |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 23 | #include <netdev.h> |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 24 | #ifdef CONFIG_LCD |
| 25 | # include <atmel_lcdc.h> |
| 26 | # include <lcd.h> |
| 27 | # ifdef CONFIG_LCD_INFO |
| 28 | # include <nand.h> |
| 29 | # include <version.h> |
| 30 | # endif |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 31 | #endif |
| 32 | |
| 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
| 35 | /* |
| 36 | * Miscelaneous platform dependent initialisations |
| 37 | */ |
| 38 | |
| 39 | static int hw_rev = -1; /* hardware revision */ |
| 40 | |
| 41 | int get_hw_rev(void) |
| 42 | { |
| 43 | if (hw_rev >= 0) |
| 44 | return hw_rev; |
| 45 | |
Daniel Gorsulowski | 6258b04 | 2010-02-11 14:57:04 +0100 | [diff] [blame] | 46 | hw_rev = at91_get_pio_value(AT91_PIO_PORTB, 19); |
| 47 | hw_rev |= at91_get_pio_value(AT91_PIO_PORTB, 20) << 1; |
| 48 | hw_rev |= at91_get_pio_value(AT91_PIO_PORTB, 21) << 2; |
| 49 | hw_rev |= at91_get_pio_value(AT91_PIO_PORTB, 22) << 3; |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 50 | |
| 51 | if (hw_rev == 15) |
| 52 | hw_rev = 0; |
| 53 | |
| 54 | return hw_rev; |
| 55 | } |
| 56 | |
| 57 | #ifdef CONFIG_CMD_NAND |
| 58 | static void otc570_nand_hw_init(void) |
| 59 | { |
| 60 | unsigned long csa; |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 61 | at91_smc_t *smc = (at91_smc_t *) ATMEL_BASE_SMC0; |
| 62 | at91_matrix_t *matrix = (at91_matrix_t *) ATMEL_BASE_MATRIX; |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 63 | |
| 64 | /* Enable CS3 */ |
Daniel Gorsulowski | 6258b04 | 2010-02-11 14:57:04 +0100 | [diff] [blame] | 65 | csa = readl(&matrix->csa[0]) | AT91_MATRIX_CSA_EBI_CS3A; |
| 66 | writel(csa, &matrix->csa[0]); |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 67 | |
| 68 | /* Configure SMC CS3 for NAND/SmartMedia */ |
Daniel Gorsulowski | c21052b | 2012-01-25 03:19:50 +0000 | [diff] [blame] | 69 | writel(AT91_SMC_SETUP_NWE(1) | AT91_SMC_SETUP_NCS_WR(1) | |
| 70 | AT91_SMC_SETUP_NRD(2) | AT91_SMC_SETUP_NCS_RD(2), |
Daniel Gorsulowski | 6258b04 | 2010-02-11 14:57:04 +0100 | [diff] [blame] | 71 | &smc->cs[3].setup); |
| 72 | |
| 73 | writel(AT91_SMC_PULSE_NWE(3) | AT91_SMC_PULSE_NCS_WR(3) | |
| 74 | AT91_SMC_PULSE_NRD(3) | AT91_SMC_PULSE_NCS_RD(3), |
| 75 | &smc->cs[3].pulse); |
| 76 | |
Daniel Gorsulowski | c21052b | 2012-01-25 03:19:50 +0000 | [diff] [blame] | 77 | writel(AT91_SMC_CYCLE_NWE(6) | AT91_SMC_CYCLE_NRD(6), |
Daniel Gorsulowski | 6258b04 | 2010-02-11 14:57:04 +0100 | [diff] [blame] | 78 | &smc->cs[3].cycle); |
| 79 | writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE | |
| 80 | AT91_SMC_MODE_EXNW_DISABLE | |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 81 | AT91_SMC_MODE_DBW_8 | |
Daniel Gorsulowski | c21052b | 2012-01-25 03:19:50 +0000 | [diff] [blame] | 82 | AT91_SMC_MODE_TDF_CYCLE(12), |
Daniel Gorsulowski | 6258b04 | 2010-02-11 14:57:04 +0100 | [diff] [blame] | 83 | &smc->cs[3].mode); |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 84 | |
| 85 | /* Configure RDY/BSY */ |
Andreas Bießmann | ac45bb1 | 2013-11-29 12:13:45 +0100 | [diff] [blame] | 86 | gpio_direction_input(CONFIG_SYS_NAND_READY_PIN); |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 87 | |
| 88 | /* Enable NandFlash */ |
Andreas Bießmann | ac45bb1 | 2013-11-29 12:13:45 +0100 | [diff] [blame] | 89 | gpio_direction_output(CONFIG_SYS_NAND_ENABLE_PIN, 1); |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 90 | } |
| 91 | #endif /* CONFIG_CMD_NAND */ |
| 92 | |
| 93 | #ifdef CONFIG_MACB |
| 94 | static void otc570_macb_hw_init(void) |
| 95 | { |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 96 | at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC; |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 97 | /* Enable clock */ |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 98 | writel(1 << ATMEL_ID_EMAC, &pmc->pcer); |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 99 | at91_macb_hw_init(); |
| 100 | } |
| 101 | #endif |
| 102 | |
| 103 | /* |
| 104 | * Static memory controller initialization to enable Beckhoff ET1100 EtherCAT |
| 105 | * controller debugging |
| 106 | * The ET1100 is located at physical address 0x70000000 |
| 107 | * Its process memory is located at physical address 0x70001000 |
| 108 | */ |
| 109 | static void otc570_ethercat_hw_init(void) |
| 110 | { |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 111 | at91_smc_t *smc1 = (at91_smc_t *) ATMEL_BASE_SMC1; |
Daniel Gorsulowski | 6258b04 | 2010-02-11 14:57:04 +0100 | [diff] [blame] | 112 | |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 113 | /* Configure SMC EBI1_CS0 for EtherCAT */ |
Daniel Gorsulowski | 6258b04 | 2010-02-11 14:57:04 +0100 | [diff] [blame] | 114 | writel(AT91_SMC_SETUP_NWE(0) | AT91_SMC_SETUP_NCS_WR(0) | |
| 115 | AT91_SMC_SETUP_NRD(0) | AT91_SMC_SETUP_NCS_RD(0), |
| 116 | &smc1->cs[0].setup); |
| 117 | writel(AT91_SMC_PULSE_NWE(4) | AT91_SMC_PULSE_NCS_WR(9) | |
| 118 | AT91_SMC_PULSE_NRD(5) | AT91_SMC_PULSE_NCS_RD(9), |
| 119 | &smc1->cs[0].pulse); |
| 120 | writel(AT91_SMC_CYCLE_NWE(10) | AT91_SMC_CYCLE_NRD(6), |
| 121 | &smc1->cs[0].cycle); |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 122 | /* |
| 123 | * Configure behavior at external wait signal, byte-select mode, 16 bit |
| 124 | * data bus width, none data float wait states and TDF optimization |
| 125 | */ |
Daniel Gorsulowski | 6258b04 | 2010-02-11 14:57:04 +0100 | [diff] [blame] | 126 | writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_EXNW_READY | |
| 127 | AT91_SMC_MODE_DBW_16 | AT91_SMC_MODE_TDF_CYCLE(0) | |
| 128 | AT91_SMC_MODE_TDF, &smc1->cs[0].mode); |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 129 | |
| 130 | /* Configure RDY/BSY */ |
Daniel Gorsulowski | 6258b04 | 2010-02-11 14:57:04 +0100 | [diff] [blame] | 131 | at91_set_b_periph(AT91_PIO_PORTE, 20, 0); /* EBI1_NWAIT */ |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | #ifdef CONFIG_LCD |
| 135 | /* Number of columns and rows, pixel clock in Hz and hsync/vsync polarity */ |
| 136 | vidinfo_t panel_info = { |
| 137 | .vl_col = 640, |
| 138 | .vl_row = 480, |
| 139 | .vl_clk = 25175000, |
| 140 | .vl_sync = ATMEL_LCDC_INVLINE_INVERTED | |
| 141 | ATMEL_LCDC_INVFRAME_INVERTED, |
| 142 | |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 143 | .vl_bpix = LCD_BPP,/* Bits per pixel, 0 = 1bit, 3 = 8bit */ |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 144 | .vl_tft = 1, /* 0 = passive, 1 = TFT */ |
| 145 | .vl_vsync_len = 1, /* Length of vertical sync in NOL */ |
| 146 | .vl_upper_margin = 35, /* Idle lines at the frame start */ |
| 147 | .vl_lower_margin = 5, /* Idle lines at the end of the frame */ |
| 148 | .vl_hsync_len = 5, /* Width of the LCDHSYNC pulse */ |
| 149 | .vl_left_margin = 112, /* Idle cycles at the line beginning */ |
| 150 | .vl_right_margin = 1, /* Idle cycles at the end of the line */ |
| 151 | |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 152 | .mmio = ATMEL_BASE_LCDC, |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 153 | }; |
| 154 | |
| 155 | void lcd_enable(void) |
| 156 | { |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 157 | at91_set_pio_value(AT91_PIO_PORTA, 30, 0); /* power up */ |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | void lcd_disable(void) |
| 161 | { |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 162 | at91_set_pio_value(AT91_PIO_PORTA, 30, 1); /* power down */ |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | static void otc570_lcd_hw_init(void) |
| 166 | { |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 167 | at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC; |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 168 | |
Daniel Gorsulowski | 6258b04 | 2010-02-11 14:57:04 +0100 | [diff] [blame] | 169 | at91_set_a_periph(AT91_PIO_PORTC, 0, 0); /* LCDVSYNC */ |
| 170 | at91_set_a_periph(AT91_PIO_PORTC, 1, 0); /* LCDHSYNC */ |
| 171 | at91_set_a_periph(AT91_PIO_PORTC, 2, 0); /* LCDDOTCK */ |
| 172 | at91_set_a_periph(AT91_PIO_PORTC, 3, 0); /* LCDDEN */ |
| 173 | at91_set_b_periph(AT91_PIO_PORTB, 9, 0); /* LCDCC */ |
| 174 | at91_set_a_periph(AT91_PIO_PORTC, 6, 0); /* LCDD2 */ |
| 175 | at91_set_a_periph(AT91_PIO_PORTC, 7, 0); /* LCDD3 */ |
| 176 | at91_set_a_periph(AT91_PIO_PORTC, 8, 0); /* LCDD4 */ |
| 177 | at91_set_a_periph(AT91_PIO_PORTC, 9, 0); /* LCDD5 */ |
| 178 | at91_set_a_periph(AT91_PIO_PORTC, 10, 0); /* LCDD6 */ |
| 179 | at91_set_a_periph(AT91_PIO_PORTC, 11, 0); /* LCDD7 */ |
| 180 | at91_set_a_periph(AT91_PIO_PORTC, 14, 0); /* LCDD10 */ |
| 181 | at91_set_a_periph(AT91_PIO_PORTC, 15, 0); /* LCDD11 */ |
| 182 | at91_set_a_periph(AT91_PIO_PORTC, 16, 0); /* LCDD12 */ |
| 183 | at91_set_b_periph(AT91_PIO_PORTC, 12, 0); /* LCDD13 */ |
| 184 | at91_set_a_periph(AT91_PIO_PORTC, 18, 0); /* LCDD14 */ |
| 185 | at91_set_a_periph(AT91_PIO_PORTC, 19, 0); /* LCDD15 */ |
| 186 | at91_set_a_periph(AT91_PIO_PORTC, 22, 0); /* LCDD18 */ |
| 187 | at91_set_a_periph(AT91_PIO_PORTC, 23, 0); /* LCDD19 */ |
| 188 | at91_set_a_periph(AT91_PIO_PORTC, 24, 0); /* LCDD20 */ |
| 189 | at91_set_b_periph(AT91_PIO_PORTC, 17, 0); /* LCDD21 */ |
| 190 | at91_set_a_periph(AT91_PIO_PORTC, 26, 0); /* LCDD22 */ |
| 191 | at91_set_a_periph(AT91_PIO_PORTC, 27, 0); /* LCDD23 */ |
| 192 | at91_set_pio_output(AT91_PIO_PORTA, 30, 1); /* PCI */ |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 193 | |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 194 | writel(1 << ATMEL_ID_LCDC, &pmc->pcer); |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | #ifdef CONFIG_LCD_INFO |
| 198 | void lcd_show_board_info(void) |
| 199 | { |
| 200 | ulong dram_size, nand_size; |
| 201 | int i; |
| 202 | char temp[32]; |
| 203 | |
| 204 | dram_size = 0; |
| 205 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) |
| 206 | dram_size += gd->bd->bi_dram[i].size; |
| 207 | nand_size = 0; |
| 208 | for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) |
| 209 | nand_size += nand_info[i].size; |
| 210 | |
| 211 | lcd_printf("\n%s\n", U_BOOT_VERSION); |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 212 | lcd_printf("CPU at %s MHz\n", strmhz(temp, get_cpu_clk_rate())); |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 213 | lcd_printf(" %ld MB SDRAM, %ld MB NAND\n", |
| 214 | dram_size >> 20, |
| 215 | nand_size >> 20 ); |
| 216 | lcd_printf(" Board : esd ARM9 HMI Panel - OTC570\n"); |
| 217 | lcd_printf(" Hardware-revision: 1.%d\n", get_hw_rev()); |
| 218 | lcd_printf(" Mach-type : %lu\n", gd->bd->bi_arch_number); |
| 219 | } |
| 220 | #endif /* CONFIG_LCD_INFO */ |
| 221 | #endif /* CONFIG_LCD */ |
| 222 | |
| 223 | int dram_init(void) |
| 224 | { |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 225 | gd->ram_size = get_ram_size( |
| 226 | (void *)CONFIG_SYS_SDRAM_BASE, |
| 227 | CONFIG_SYS_SDRAM_SIZE); |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 228 | return 0; |
| 229 | } |
| 230 | |
| 231 | int board_eth_init(bd_t *bis) |
| 232 | { |
| 233 | int rc = 0; |
| 234 | #ifdef CONFIG_MACB |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 235 | rc = macb_eth_initialize(0, (void *)ATMEL_BASE_EMAC, 0x00); |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 236 | #endif |
| 237 | return rc; |
| 238 | } |
| 239 | |
| 240 | int checkboard(void) |
| 241 | { |
| 242 | char str[32]; |
| 243 | |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 244 | puts("Board : esd ARM9 HMI Panel - OTC570"); |
Wolfgang Denk | cdb7497 | 2010-07-24 21:55:43 +0200 | [diff] [blame] | 245 | if (getenv_f("serial#", str, sizeof(str)) > 0) { |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 246 | puts(", serial# "); |
| 247 | puts(str); |
| 248 | } |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 249 | printf("\n"); |
| 250 | printf("Hardware-revision: 1.%d\n", get_hw_rev()); |
| 251 | printf("Mach-type : %lu\n", gd->bd->bi_arch_number); |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 252 | return 0; |
| 253 | } |
| 254 | |
| 255 | #ifdef CONFIG_SERIAL_TAG |
| 256 | void get_board_serial(struct tag_serialnr *serialnr) |
| 257 | { |
| 258 | char *str; |
| 259 | |
| 260 | char *serial = getenv("serial#"); |
| 261 | if (serial) { |
| 262 | str = strchr(serial, '_'); |
| 263 | if (str && (strlen(str) >= 4)) { |
| 264 | serialnr->high = (*(str + 1) << 8) | *(str + 2); |
| 265 | serialnr->low = simple_strtoul(str + 3, NULL, 16); |
| 266 | } |
| 267 | } else { |
| 268 | serialnr->high = 0; |
| 269 | serialnr->low = 0; |
| 270 | } |
| 271 | } |
| 272 | #endif |
| 273 | |
| 274 | #ifdef CONFIG_REVISION_TAG |
| 275 | u32 get_board_rev(void) |
| 276 | { |
| 277 | return hw_rev | 0x100; |
| 278 | } |
| 279 | #endif |
| 280 | |
| 281 | #ifdef CONFIG_MISC_INIT_R |
| 282 | int misc_init_r(void) |
| 283 | { |
Daniel Gorsulowski | 6258b04 | 2010-02-11 14:57:04 +0100 | [diff] [blame] | 284 | char str[64]; |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 285 | at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC; |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 286 | |
Daniel Gorsulowski | 6258b04 | 2010-02-11 14:57:04 +0100 | [diff] [blame] | 287 | at91_set_pio_output(AT91_PIO_PORTA, 29, 1); |
| 288 | at91_set_a_periph(AT91_PIO_PORTA, 26, 1); /* TXD0 */ |
| 289 | at91_set_a_periph(AT91_PIO_PORTA, 27, 0); /* RXD0 */ |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 290 | writel(1 << ATMEL_ID_USART0, &pmc->pcer); |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 291 | /* Set USART_MODE = 1 (RS485) */ |
Daniel Gorsulowski | 6258b04 | 2010-02-11 14:57:04 +0100 | [diff] [blame] | 292 | writel(1, 0xFFF8C004); |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 293 | |
| 294 | printf("USART0: "); |
| 295 | |
Wolfgang Denk | cdb7497 | 2010-07-24 21:55:43 +0200 | [diff] [blame] | 296 | if (getenv_f("usart0", str, sizeof(str)) == -1) { |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 297 | printf("No entry - assuming 1-wire\n"); |
| 298 | /* CTS pin, works as mode select pin (0 = 1-wire; 1 = RS485) */ |
Daniel Gorsulowski | 6258b04 | 2010-02-11 14:57:04 +0100 | [diff] [blame] | 299 | at91_set_pio_output(AT91_PIO_PORTA, 29, 0); |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 300 | } else { |
| 301 | if (strcmp(str, "1-wire") == 0) { |
| 302 | printf("%s\n", str); |
Daniel Gorsulowski | 6258b04 | 2010-02-11 14:57:04 +0100 | [diff] [blame] | 303 | at91_set_pio_output(AT91_PIO_PORTA, 29, 0); |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 304 | } else if (strcmp(str, "rs485") == 0) { |
| 305 | printf("%s\n", str); |
Daniel Gorsulowski | 6258b04 | 2010-02-11 14:57:04 +0100 | [diff] [blame] | 306 | at91_set_pio_output(AT91_PIO_PORTA, 29, 1); |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 307 | } else { |
| 308 | printf("Wrong entry - assuming 1-wire "); |
| 309 | printf("(valid values are '1-wire' or 'rs485')\n"); |
Daniel Gorsulowski | 6258b04 | 2010-02-11 14:57:04 +0100 | [diff] [blame] | 310 | at91_set_pio_output(AT91_PIO_PORTA, 29, 0); |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 311 | } |
| 312 | } |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 313 | #ifdef CONFIG_LCD |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 314 | printf("Display memory address: 0x%08lX\n", gd->fb_base); |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 315 | #endif |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 316 | |
| 317 | return 0; |
| 318 | } |
| 319 | #endif /* CONFIG_MISC_INIT_R */ |
| 320 | |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 321 | int board_early_init_f(void) |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 322 | { |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 323 | at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC; |
Daniel Gorsulowski | 6258b04 | 2010-02-11 14:57:04 +0100 | [diff] [blame] | 324 | |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 325 | /* enable all clocks */ |
| 326 | writel((1 << ATMEL_ID_PIOA) | |
| 327 | (1 << ATMEL_ID_PIOB) | |
| 328 | (1 << ATMEL_ID_PIOCDE) | |
| 329 | (1 << ATMEL_ID_TWI) | |
| 330 | (1 << ATMEL_ID_SPI0) | |
| 331 | #ifdef CONFIG_LCD |
| 332 | (1 << ATMEL_ID_LCDC) | |
| 333 | #endif |
| 334 | (1 << ATMEL_ID_UHP), |
Daniel Gorsulowski | 6258b04 | 2010-02-11 14:57:04 +0100 | [diff] [blame] | 335 | &pmc->pcer); |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 336 | |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 337 | at91_seriald_hw_init(); |
| 338 | |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 339 | /* arch number of OTC570-Board */ |
| 340 | gd->bd->bi_arch_number = MACH_TYPE_OTC570; |
| 341 | |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 342 | return 0; |
| 343 | } |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 344 | |
Daniel Gorsulowski | a950c81 | 2011-04-18 04:15:02 +0000 | [diff] [blame] | 345 | int board_init(void) |
| 346 | { |
| 347 | /* initialize ET1100 Controller */ |
| 348 | otc570_ethercat_hw_init(); |
| 349 | |
| 350 | /* adress of boot parameters */ |
| 351 | gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; |
| 352 | |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 353 | #ifdef CONFIG_CMD_NAND |
| 354 | otc570_nand_hw_init(); |
| 355 | #endif |
Daniel Gorsulowski | 44d8025 | 2010-01-25 10:50:41 +0100 | [diff] [blame] | 356 | #ifdef CONFIG_HAS_DATAFLASH |
| 357 | at91_spi0_hw_init(1 << 0); |
| 358 | #endif |
| 359 | #ifdef CONFIG_MACB |
| 360 | otc570_macb_hw_init(); |
| 361 | #endif |
| 362 | #ifdef CONFIG_AT91_CAN |
| 363 | at91_can_hw_init(); |
| 364 | #endif |
| 365 | #ifdef CONFIG_USB_OHCI_NEW |
| 366 | at91_uhp_hw_init(); |
| 367 | #endif |
| 368 | #ifdef CONFIG_LCD |
| 369 | otc570_lcd_hw_init(); |
| 370 | #endif |
| 371 | return 0; |
| 372 | } |