2 * Copyright (C) ST-Ericsson SA 2009
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <asm/types.h>
26 #include <asm/errno.h>
27 #include <asm/arch/db8500_pincfg.h>
28 #include <asm/arch/prcmu.h>
29 #include <asm/arch/hardware.h>
30 #include <asm/arch/sys_proto.h>
32 #include "db8500_pins.h"
35 * Get a global data pointer
37 DECLARE_GLOBAL_DATA_PTR;
40 * Memory controller register
42 #define DMC_BASE_ADDR 0x80156000
43 #define DMC_CTL_97 (DMC_BASE_ADDR + 0x184)
46 * GPIO pin config common for MOP500/HREF boards
48 unsigned long gpio_cfg_common[] = {
62 GPIO145_SSP0_RXD | PIN_PULL_DOWN,
65 /* MMC0 (MicroSD card) */
66 GPIO18_MC0_CMDDIR | PIN_OUTPUT_HIGH,
67 GPIO19_MC0_DAT0DIR | PIN_OUTPUT_HIGH,
68 GPIO20_MC0_DAT2DIR | PIN_OUTPUT_HIGH,
69 GPIO21_MC0_DAT31DIR | PIN_OUTPUT_HIGH,
70 GPIO22_MC0_FBCLK | PIN_INPUT_NOPULL,
71 GPIO23_MC0_CLK | PIN_OUTPUT_LOW,
72 GPIO24_MC0_CMD | PIN_INPUT_PULLUP,
73 GPIO25_MC0_DAT0 | PIN_INPUT_PULLUP,
74 GPIO26_MC0_DAT1 | PIN_INPUT_PULLUP,
75 GPIO27_MC0_DAT2 | PIN_INPUT_PULLUP,
76 GPIO28_MC0_DAT3 | PIN_INPUT_PULLUP,
78 /* MMC4 (On-board eMMC) */
79 GPIO197_MC4_DAT3 | PIN_INPUT_PULLUP,
80 GPIO198_MC4_DAT2 | PIN_INPUT_PULLUP,
81 GPIO199_MC4_DAT1 | PIN_INPUT_PULLUP,
82 GPIO200_MC4_DAT0 | PIN_INPUT_PULLUP,
83 GPIO201_MC4_CMD | PIN_INPUT_PULLUP,
84 GPIO202_MC4_FBCLK | PIN_INPUT_NOPULL,
85 GPIO203_MC4_CLK | PIN_OUTPUT_LOW,
86 GPIO204_MC4_DAT7 | PIN_INPUT_PULLUP,
87 GPIO205_MC4_DAT6 | PIN_INPUT_PULLUP,
88 GPIO206_MC4_DAT5 | PIN_INPUT_PULLUP,
89 GPIO207_MC4_DAT4 | PIN_INPUT_PULLUP,
92 GPIO29_U2_RXD | PIN_INPUT_PULLUP,
93 GPIO30_U2_TXD | PIN_OUTPUT_HIGH,
94 GPIO31_U2_CTSn | PIN_INPUT_PULLUP,
95 GPIO32_U2_RTSn | PIN_OUTPUT_HIGH,
98 * USB, pin 256-267 USB, Is probably already setup correctly from
99 * BootROM/boot stages, but we don't trust that and set it up anyway
115 unsigned long gpio_cfg_snowball[] = {
116 /* MMC0 (MicroSD card) */
117 GPIO217_GPIO | PIN_OUTPUT_HIGH, /* MMC_EN */
118 GPIO218_GPIO | PIN_INPUT_NOPULL, /* MMC_CD */
119 GPIO228_GPIO | PIN_OUTPUT_HIGH, /* SD_SEL */
122 GPIO167_GPIO | PIN_OUTPUT_HIGH, /* RSTn_MLC */
135 GPIO141_GPIO | PIN_OUTPUT_HIGH,
139 * Miscellaneous platform dependent initialisations
145 * Setup board (bd) and board-info (bi).
146 * bi_arch_number: Unique id for this board. It will passed in r1 to
147 * Linux startup code and is the machine_id.
148 * bi_boot_params: Where this board expects params.
150 gd->bd->bi_arch_number = MACH_TYPE_SNOWBALL;
151 gd->bd->bi_boot_params = 0x00000100;
153 /* Configure GPIO pins needed by U-boot */
154 db8500_gpio_config_pins(gpio_cfg_common, ARRAY_SIZE(gpio_cfg_common));
156 db8500_gpio_config_pins(gpio_cfg_snowball,
157 ARRAY_SIZE(gpio_cfg_snowball));
164 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
165 gd->ram_size = gd->bd->bi_dram[0].size =
166 get_ram_size(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_MAX_RAM_SIZE);
171 static int raise_ab8500_gpio16(void)
176 ret = ab8500_read(AB8500_MISC, AB8500_GPIO_SEL2_REG);
181 ret = ab8500_write(AB8500_MISC, AB8500_GPIO_SEL2_REG, ret);
186 ret = ab8500_read(AB8500_MISC, AB8500_GPIO_DIR2_REG);
191 ret = ab8500_write(AB8500_MISC, AB8500_GPIO_DIR2_REG, ret);
196 ret = ab8500_read(AB8500_MISC, AB8500_GPIO_OUT2_REG);
201 ret = ab8500_write(AB8500_MISC, AB8500_GPIO_OUT2_REG, ret);
207 static int raise_ab8500_gpio26(void)
212 ret = ab8500_read(AB8500_MISC, AB8500_GPIO_DIR4_REG);
217 ret = ab8500_write(AB8500_MISC, AB8500_GPIO_DIR4_REG, ret);
222 ret = ab8500_read(AB8500_MISC, AB8500_GPIO_OUT4_REG);
227 ret = ab8500_write(AB8500_MISC, AB8500_GPIO_OUT4_REG, ret);
233 int board_late_init(void)
235 /* enable 3V3 for LAN controller */
236 if (raise_ab8500_gpio26() >= 0) {
237 /* Turn on FSMC device */
238 writel(0x1, 0x8000f000);
239 writel(0x1, 0x8000f008);
241 /* setup FSMC for LAN controler */
242 writel(0x305b, 0x80000000);
244 /* run at the highest possible speed */
245 writel(0x01010210, 0x80000004);
247 printf("error: can't raise GPIO26\n");
249 /* enable 3v6 for GBF chip */
250 if ((raise_ab8500_gpio16() < 0))
251 printf("error: cant' raise GPIO16\n");
254 u8500_mmc_power_init();
255 #endif /* CONFIG_MMC */