Ilya Yanok | 509a1ea | 2009-02-10 00:22:31 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * |
| 3 | * (c) 2009 Emcraft Systems, Ilya Yanok <yanok@emcraft.com> |
| 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 | |
| 25 | #include <common.h> |
| 26 | #include <netdev.h> |
| 27 | #include <asm/arch/mx31.h> |
| 28 | #include <asm/arch/mx31-regs.h> |
| 29 | #include "qong_fpga.h" |
| 30 | |
| 31 | DECLARE_GLOBAL_DATA_PTR; |
| 32 | |
| 33 | int dram_init (void) |
| 34 | { |
| 35 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
| 36 | gd->bd->bi_dram[0].size = get_ram_size((volatile void *)PHYS_SDRAM_1, |
| 37 | PHYS_SDRAM_1_SIZE); |
| 38 | |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | int board_init (void) |
| 43 | { |
| 44 | /* Chip selects */ |
| 45 | /* CS0: Nor Flash #0 - it must be init'ed when executing from DDR */ |
| 46 | /* Assumptions: HCLK = 133 MHz, tACC = 130ns */ |
| 47 | __REG(CSCR_U(0)) = ((0 << 31) | /* SP */ |
| 48 | (0 << 30) | /* WP */ |
| 49 | (0 << 28) | /* BCD */ |
| 50 | (0 << 24) | /* BCS */ |
| 51 | (0 << 22) | /* PSZ */ |
| 52 | (0 << 21) | /* PME */ |
| 53 | (0 << 20) | /* SYNC */ |
| 54 | (0 << 16) | /* DOL */ |
| 55 | (3 << 14) | /* CNC */ |
| 56 | (21 << 8) | /* WSC */ |
| 57 | (0 << 7) | /* EW */ |
| 58 | (0 << 4) | /* WWS */ |
| 59 | (6 << 0) /* EDC */ |
| 60 | ); |
| 61 | |
| 62 | __REG(CSCR_L(0)) = ((2 << 28) | /* OEA */ |
| 63 | (1 << 24) | /* OEN */ |
| 64 | (3 << 20) | /* EBWA */ |
| 65 | (3 << 16) | /* EBWN */ |
| 66 | (1 << 12) | /* CSA */ |
| 67 | (1 << 11) | /* EBC */ |
| 68 | (5 << 8) | /* DSZ */ |
| 69 | (1 << 4) | /* CSN */ |
| 70 | (0 << 3) | /* PSR */ |
| 71 | (0 << 2) | /* CRE */ |
| 72 | (0 << 1) | /* WRAP */ |
| 73 | (1 << 0) /* CSEN */ |
| 74 | ); |
| 75 | |
| 76 | __REG(CSCR_A(0)) = ((2 << 28) | /* EBRA */ |
| 77 | (1 << 24) | /* EBRN */ |
| 78 | (2 << 20) | /* RWA */ |
| 79 | (2 << 16) | /* RWN */ |
| 80 | (0 << 15) | /* MUM */ |
| 81 | (0 << 13) | /* LAH */ |
| 82 | (2 << 10) | /* LBN */ |
| 83 | (0 << 8) | /* LBA */ |
| 84 | (0 << 6) | /* DWW */ |
| 85 | (0 << 4) | /* DCT */ |
| 86 | (0 << 3) | /* WWU */ |
| 87 | (0 << 2) | /* AGE */ |
| 88 | (0 << 1) | /* CNC2 */ |
| 89 | (0 << 0) /* FCE */ |
| 90 | ); |
| 91 | |
| 92 | #ifdef CONFIG_QONG_FPGA |
| 93 | /* CS1: FPGA/Network Controller/GPIO */ |
| 94 | /* 16-bit, no DTACK */ |
| 95 | __REG(CSCR_U(1)) = 0x00000A01; |
| 96 | __REG(CSCR_L(1)) = 0x20040501; |
| 97 | __REG(CSCR_A(1)) = 0x04020C00; |
| 98 | |
| 99 | /* setup pins for FPGA */ |
| 100 | mx31_gpio_mux(IOMUX_MODE(0x76, MUX_CTL_GPIO)); |
| 101 | mx31_gpio_mux(IOMUX_MODE(0x7e, MUX_CTL_GPIO)); |
| 102 | mx31_gpio_mux(IOMUX_MODE(0x91, MUX_CTL_OUT_FUNC | MUX_CTL_IN_GPIO)); |
| 103 | mx31_gpio_mux(IOMUX_MODE(0x92, MUX_CTL_GPIO)); |
| 104 | mx31_gpio_mux(IOMUX_MODE(0x93, MUX_CTL_GPIO)); |
| 105 | #endif |
| 106 | |
| 107 | /* setup pins for UART1 */ |
| 108 | mx31_gpio_mux(MUX_RXD1__UART1_RXD_MUX); |
| 109 | mx31_gpio_mux(MUX_TXD1__UART1_TXD_MUX); |
| 110 | mx31_gpio_mux(MUX_RTS1__UART1_RTS_B); |
| 111 | mx31_gpio_mux(MUX_CTS1__UART1_CTS_B); |
| 112 | |
| 113 | /* board id for linux */ |
| 114 | gd->bd->bi_arch_number = MACH_TYPE_QONG; |
| 115 | gd->bd->bi_boot_params = (0x80000100); /* adress of boot parameters */ |
| 116 | |
| 117 | return 0; |
| 118 | } |
| 119 | |
| 120 | int checkboard (void) |
| 121 | { |
| 122 | printf("Board: DAVE/DENX QongEVB-LITE\n"); |
| 123 | return 0; |
| 124 | } |
| 125 | |
| 126 | int misc_init_r (void) |
| 127 | { |
| 128 | #ifdef CONFIG_QONG_FPGA |
| 129 | u32 tmp; |
| 130 | |
| 131 | /* FPGA reset */ |
| 132 | /* rstn = 0 */ |
| 133 | tmp = __REG(GPIO2_BASE + GPIO_DR); |
| 134 | tmp &= (~(1 << QONG_FPGA_RST_PIN)); |
| 135 | __REG(GPIO2_BASE + GPIO_DR) = tmp; |
| 136 | /* set the GPIO as output */ |
| 137 | tmp = __REG(GPIO2_BASE + GPIO_GDIR); |
| 138 | tmp |= (1 << QONG_FPGA_RST_PIN); |
| 139 | __REG(GPIO2_BASE + GPIO_GDIR) = tmp; |
| 140 | /* wait */ |
| 141 | udelay(30); |
| 142 | /* rstn = 1 */ |
| 143 | tmp = __REG(GPIO2_BASE + GPIO_DR); |
| 144 | tmp |= (1 << QONG_FPGA_RST_PIN); |
| 145 | __REG(GPIO2_BASE + GPIO_DR) = tmp; |
| 146 | /* set interrupt pin as input */ |
| 147 | __REG(GPIO2_BASE + GPIO_GDIR) = tmp | (1 << QONG_FPGA_IRQ_PIN); |
| 148 | /* wait while the FPGA starts */ |
| 149 | udelay(300); |
| 150 | |
| 151 | tmp = *(volatile u32*)QONG_FPGA_CTRL_VERSION; |
| 152 | printf("FPGA: "); |
| 153 | printf("version register = %u.%u.%u\n", |
| 154 | (tmp & 0xF000) >> 12, (tmp & 0x0F00) >> 8, tmp & 0x00FF); |
| 155 | #endif |
| 156 | |
| 157 | return 0; |
| 158 | } |
| 159 | |
| 160 | int board_eth_init(bd_t *bis) |
| 161 | { |
| 162 | #if defined(CONFIG_QONG_FPGA) && defined(CONFIG_DNET) |
| 163 | return dnet_eth_initialize(0, (void *)CONFIG_DNET_BASE, -1); |
| 164 | #else |
| 165 | return 0; |
| 166 | #endif |
| 167 | } |
| 168 | |