wdenk | 43d9616 | 2003-03-06 00:02:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * Robert Schwebel, Pengutronix, r.schwebel@pengutronix.de |
| 4 | * Kyle Harris, Nexus Technologies, Inc., kharris@nexus-tech.net |
| 5 | * Marius Groeger, Sysgo Real-Time Solutions GmbH, mgroeger@sysgo.de |
| 6 | * |
| 7 | * See file CREDITS for list of people who contributed to this |
| 8 | * project. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public License as |
| 12 | * published by the Free Software Foundation; either version 2 of |
| 13 | * the License, or (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 23 | * MA 02111-1307 USA |
| 24 | */ |
| 25 | |
| 26 | #include <common.h> |
Ben Warren | 7194ab8 | 2009-10-04 22:37:03 -0700 | [diff] [blame] | 27 | #include <netdev.h> |
wdenk | 43d9616 | 2003-03-06 00:02:04 +0000 | [diff] [blame] | 28 | #include <asm/arch/pxa-regs.h> |
wdenk | 47cd00f | 2003-03-06 13:39:27 +0000 | [diff] [blame] | 29 | #include <asm/mach-types.h> |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 30 | #include <asm/io.h> |
wdenk | 43d9616 | 2003-03-06 00:02:04 +0000 | [diff] [blame] | 31 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 32 | DECLARE_GLOBAL_DATA_PTR; |
| 33 | |
wdenk | 43d9616 | 2003-03-06 00:02:04 +0000 | [diff] [blame] | 34 | #ifdef CONFIG_SHOW_BOOT_PROGRESS |
| 35 | # define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg) |
| 36 | #else |
| 37 | # define SHOW_BOOT_PROGRESS(arg) |
| 38 | #endif |
| 39 | |
wdenk | 47cd00f | 2003-03-06 13:39:27 +0000 | [diff] [blame] | 40 | /** |
| 41 | * i2c_init_board - reset i2c bus. When the board is powercycled during a |
| 42 | * bus transfer it might hang; for details see doc/I2C_Edge_Conditions. |
| 43 | * The Innokom board has GPIO70 connected to SCLK which can be toggled |
| 44 | * until all chips think that their current cycles are finished. |
wdenk | 43d9616 | 2003-03-06 00:02:04 +0000 | [diff] [blame] | 45 | */ |
wdenk | dc7c9a1 | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 46 | int i2c_init_board(void) |
wdenk | 47cd00f | 2003-03-06 13:39:27 +0000 | [diff] [blame] | 47 | { |
wdenk | dc7c9a1 | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 48 | int i, icr; |
wdenk | 47cd00f | 2003-03-06 13:39:27 +0000 | [diff] [blame] | 49 | |
wdenk | dc7c9a1 | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 50 | /* disable I2C controller first, otherwhise it thinks we want to */ |
| 51 | /* talk to the slave port... */ |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 52 | icr = readl(ICR); |
| 53 | writel(readl(ICR) & ~(ICR_SCLE | ICR_IUE), ICR); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 54 | |
wdenk | dc7c9a1 | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 55 | /* set gpio pin low _before_ we change direction to output */ |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 56 | writel(GPIO_bit(70), GPCR(70)); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 57 | |
wdenk | dc7c9a1 | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 58 | /* now toggle between output=low and high-impedance */ |
| 59 | for (i = 0; i < 20; i++) { |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 60 | writel(readl(GPDR(70)) | GPIO_bit(70), GPDR(70)); /* output */ |
wdenk | 47cd00f | 2003-03-06 13:39:27 +0000 | [diff] [blame] | 61 | udelay(10); |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 62 | writel(readl(GPDR(70)) & ~GPIO_bit(70), GPDR(70)); /* input */ |
wdenk | 47cd00f | 2003-03-06 13:39:27 +0000 | [diff] [blame] | 63 | udelay(10); |
| 64 | } |
wdenk | dc7c9a1 | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 65 | |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 66 | writel(icr, ICR); |
wdenk | dc7c9a1 | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 67 | |
| 68 | return 0; |
wdenk | 47cd00f | 2003-03-06 13:39:27 +0000 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | |
| 72 | /** |
| 73 | * misc_init_r: - misc initialisation routines |
| 74 | */ |
| 75 | |
| 76 | int misc_init_r(void) |
| 77 | { |
Jean-Christophe PLAGNIOL-VILLARD | 96455bf | 2007-10-19 00:07:39 +0200 | [diff] [blame] | 78 | char *str; |
wdenk | 47cd00f | 2003-03-06 13:39:27 +0000 | [diff] [blame] | 79 | |
| 80 | /* determine if the software update key is pressed during startup */ |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 81 | if (readl(GPLR0) & 0x00000800) { |
wdenk | 47cd00f | 2003-03-06 13:39:27 +0000 | [diff] [blame] | 82 | printf("using bootcmd_normal (sw-update button not pressed)\n"); |
| 83 | str = getenv("bootcmd_normal"); |
| 84 | } else { |
| 85 | printf("using bootcmd_update (sw-update button pressed)\n"); |
| 86 | str = getenv("bootcmd_update"); |
| 87 | } |
| 88 | |
| 89 | setenv("bootcmd",str); |
| 90 | |
| 91 | return 0; |
| 92 | } |
wdenk | 43d9616 | 2003-03-06 00:02:04 +0000 | [diff] [blame] | 93 | |
| 94 | |
| 95 | /** |
| 96 | * board_init: - setup some data structures |
| 97 | * |
| 98 | * @return: 0 in case of success |
| 99 | */ |
| 100 | |
| 101 | int board_init (void) |
| 102 | { |
Marek Vasut | df1ac0e | 2010-10-20 20:52:21 +0200 | [diff] [blame] | 103 | /* We have RAM, disable cache */ |
| 104 | dcache_disable(); |
| 105 | icache_disable(); |
wdenk | 43d9616 | 2003-03-06 00:02:04 +0000 | [diff] [blame] | 106 | |
wdenk | 47cd00f | 2003-03-06 13:39:27 +0000 | [diff] [blame] | 107 | gd->bd->bi_arch_number = MACH_TYPE_INNOKOM; |
wdenk | 43d9616 | 2003-03-06 00:02:04 +0000 | [diff] [blame] | 108 | gd->bd->bi_boot_params = 0xa0000100; |
wdenk | dc7c9a1 | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 109 | gd->bd->bi_baudrate = CONFIG_BAUDRATE; |
| 110 | |
wdenk | 43d9616 | 2003-03-06 00:02:04 +0000 | [diff] [blame] | 111 | return 0; |
| 112 | } |
| 113 | |
Marek Vasut | df1ac0e | 2010-10-20 20:52:21 +0200 | [diff] [blame] | 114 | extern void pxa_dram_init(void); |
| 115 | int dram_init(void) |
wdenk | 43d9616 | 2003-03-06 00:02:04 +0000 | [diff] [blame] | 116 | { |
Marek Vasut | df1ac0e | 2010-10-20 20:52:21 +0200 | [diff] [blame] | 117 | pxa_dram_init(); |
| 118 | gd->ram_size = PHYS_SDRAM_1_SIZE; |
wdenk | 43d9616 | 2003-03-06 00:02:04 +0000 | [diff] [blame] | 119 | return 0; |
| 120 | } |
| 121 | |
Marek Vasut | df1ac0e | 2010-10-20 20:52:21 +0200 | [diff] [blame] | 122 | void dram_init_banksize(void) |
| 123 | { |
| 124 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
| 125 | gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; |
| 126 | } |
wdenk | 43d9616 | 2003-03-06 00:02:04 +0000 | [diff] [blame] | 127 | |
| 128 | /** |
| 129 | * innokom_set_led: - switch LEDs on or off |
| 130 | * |
| 131 | * @param led: LED to switch (0,1,2) |
| 132 | * @param state: switch on (1) or off (0) |
| 133 | */ |
| 134 | |
| 135 | void innokom_set_led(int led, int state) |
| 136 | { |
| 137 | switch(led) { |
| 138 | /* |
| 139 | case 0: if (state==1) { |
| 140 | GPCR0 |= CSB226_USER_LED0; |
| 141 | } else if (state==0) { |
| 142 | GPSR0 |= CSB226_USER_LED0; |
| 143 | } |
| 144 | break; |
| 145 | |
| 146 | case 1: if (state==1) { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 147 | GPCR0 |= CSB226_USER_LED1; |
| 148 | } else if (state==0) { |
| 149 | GPSR0 |= CSB226_USER_LED1; |
| 150 | } |
| 151 | break; |
wdenk | 43d9616 | 2003-03-06 00:02:04 +0000 | [diff] [blame] | 152 | |
| 153 | case 2: if (state==1) { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 154 | GPCR0 |= CSB226_USER_LED2; |
| 155 | } else if (state==0) { |
| 156 | GPSR0 |= CSB226_USER_LED2; |
| 157 | } |
| 158 | break; |
wdenk | 43d9616 | 2003-03-06 00:02:04 +0000 | [diff] [blame] | 159 | */ |
| 160 | } |
| 161 | |
| 162 | return; |
| 163 | } |
| 164 | |
| 165 | |
| 166 | /** |
| 167 | * show_boot_progress: - indicate state of the boot process |
| 168 | * |
| 169 | * @param status: Status number - see README for details. |
| 170 | * |
| 171 | * The CSB226 does only have 3 LEDs, so we switch them on at the most |
| 172 | * important states (1, 5, 15). |
| 173 | */ |
| 174 | |
| 175 | void show_boot_progress (int status) |
| 176 | { |
| 177 | switch(status) { |
| 178 | /* |
| 179 | case 1: csb226_set_led(0,1); break; |
| 180 | case 5: csb226_set_led(1,1); break; |
| 181 | case 15: csb226_set_led(2,1); break; |
| 182 | */ |
| 183 | } |
| 184 | |
| 185 | return; |
| 186 | } |
Ben Warren | 7194ab8 | 2009-10-04 22:37:03 -0700 | [diff] [blame] | 187 | |
| 188 | #ifdef CONFIG_CMD_NET |
| 189 | int board_eth_init(bd_t *bis) |
| 190 | { |
| 191 | int rc = 0; |
| 192 | #ifdef CONFIG_SMC91111 |
| 193 | rc = smc91111_initialize(0, CONFIG_SMC91111_BASE); |
| 194 | #endif |
| 195 | return rc; |
| 196 | } |
| 197 | #endif |