blob: 4552a6faa1aff8b47db52ba773ddfe14613dfce6 [file] [log] [blame]
/*
* Copyright (C) 2011-2012 Mindspeed Technologies Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#include <common.h>
#include <asm/hardware.h>
#include <asm-arm/arch-comcerto/exp-bus_c2000.h>
#include <asm-arm/arch-comcerto/bsp.h>
#include <asm/io.h>
#if (CONFIG_COMMANDS & CFG_CMD_NAND)
void SoC_nand_init(void)
{
/* IBR, when booting from NOR, is changing expansion bus CS0 Mem Segment size to 1MiB
instead of the default reset value of 128MiB. Put back the reset default value */
writel(EXP_CS0_SEG_END_VAL, EXP_CS0_SEG_REG);
writel(EXP_CS1_BASE_VAL, EXP_CS1_BASE_REG);
writel(EXP_CS1_SEG_END_VAL, EXP_CS1_SEG_REG);
writel(EXP_CS2_BASE_VAL, EXP_CS2_BASE_REG);
writel(EXP_CS2_SEG_END_VAL, EXP_CS2_SEG_REG);
writel(EXP_CS3_BASE_VAL, EXP_CS3_BASE_REG);
writel(EXP_CS3_SEG_END_VAL, EXP_CS3_SEG_REG);
writel(EXP_CS4_BASE_VAL, EXP_CS4_BASE_REG);
writel(EXP_CS4_SEG_END_VAL, EXP_CS4_SEG_REG);
#ifdef CONFIG_NAND_TYPE_SLC
//SLC NAND on ASIC is 16-bit. Enable 16-bit bus
writel(readl(EXP_CS4_CFG_REG) | 0x2, EXP_CS4_CFG_REG);
#else
//MLC NAND on ASIC is 8-bit. Enable 8-bit bus
writel((readl(EXP_CS4_CFG_REG) & (~0x6)), EXP_CS4_CFG_REG);
#endif
}
/*
* SoC_gpio_cfg - configure GPIO pins as input or output pins
*
* gpio - gpio pin
*
* mode - gpio pin mode
* GPIO_TYPE_OUTPUT = output
* GPIO_TYPE_INPUT = input
*
*/
int SoC_gpio_cfg(int gpio, int mode)
{
if ((gpio < 0) || (gpio > 31))
goto err;
switch (mode) {
case GPIO_TYPE_INPUT:
default:
*(volatile u32 *) COMCERTO_GPIO_OE_REG &= __cpu_to_le32(~(1 << gpio));
break;
case GPIO_TYPE_OUTPUT:
*(volatile u32 *) COMCERTO_GPIO_OE_REG |= __cpu_to_le32(1 << gpio);
break;
}
return 0;
err:
return -1;
}
#endif /* CFG_CMD_NAND */