Path: blob/master/arch/mips/pnx833x/stb22x/board.c
15116 views
/*1* board.c: STB225 board support.2*3* Copyright 2008 NXP Semiconductors4* Chris Steel <[email protected]>5* Daniel Laird <[email protected]>6*7* Based on software written by:8* Nikita Youshchenko <[email protected]>, based on PNX8550 code.9*10* This program is free software; you can redistribute it and/or modify11* it under the terms of the GNU General Public License as published by12* the Free Software Foundation; either version 2 of the License, or13* (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 of17* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the18* GNU General Public License for more details.19*20* You should have received a copy of the GNU General Public License21* along with this program; if not, write to the Free Software22* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.23*/24#include <linux/init.h>25#include <asm/bootinfo.h>26#include <linux/mm.h>27#include <pnx833x.h>28#include <gpio.h>2930/* endianess twiddlers */31#define PNX8335_DEBUG0 0x440032#define PNX8335_DEBUG1 0x440433#define PNX8335_DEBUG2 0x440834#define PNX8335_DEBUG3 0x440c35#define PNX8335_DEBUG4 0x441036#define PNX8335_DEBUG5 0x441437#define PNX8335_DEBUG6 0x441838#define PNX8335_DEBUG7 0x441c3940int prom_argc;41char **prom_argv, **prom_envp;4243extern void prom_init_cmdline(void);44extern char *prom_getenv(char *envname);4546const char *get_system_type(void)47{48return "NXP STB22x";49}5051static inline unsigned long env_or_default(char *env, unsigned long dfl)52{53char *str = prom_getenv(env);54return str ? simple_strtol(str, 0, 0) : dfl;55}5657void __init prom_init(void)58{59unsigned long memsize;6061prom_argc = fw_arg0;62prom_argv = (char **)fw_arg1;63prom_envp = (char **)fw_arg2;6465prom_init_cmdline();6667memsize = env_or_default("memsize", 0x02000000);68add_memory_region(0, memsize, BOOT_MEM_RAM);69}7071void __init pnx833x_board_setup(void)72{73pnx833x_gpio_select_function_alt(4);74pnx833x_gpio_select_output(4);75pnx833x_gpio_select_function_alt(5);76pnx833x_gpio_select_input(5);77pnx833x_gpio_select_function_alt(6);78pnx833x_gpio_select_input(6);79pnx833x_gpio_select_function_alt(7);80pnx833x_gpio_select_output(7);8182pnx833x_gpio_select_function_alt(25);83pnx833x_gpio_select_function_alt(26);8485pnx833x_gpio_select_function_alt(27);86pnx833x_gpio_select_function_alt(28);87pnx833x_gpio_select_function_alt(29);88pnx833x_gpio_select_function_alt(30);89pnx833x_gpio_select_function_alt(31);90pnx833x_gpio_select_function_alt(32);91pnx833x_gpio_select_function_alt(33);9293#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)94/* Setup MIU for NAND access on CS0...95*96* (it seems that we must also configure CS1 for reliable operation,97* otherwise the first read ID command will fail if it's read as 4 bytes98* but pass if it's read as 1 word.)99*/100101/* Setup MIU CS0 & CS1 timing */102PNX833X_MIU_SEL0 = 0;103PNX833X_MIU_SEL1 = 0;104PNX833X_MIU_SEL0_TIMING = 0x50003081;105PNX833X_MIU_SEL1_TIMING = 0x50003081;106107/* Setup GPIO 00 for use as MIU CS1 (CS0 is not multiplexed, so does not need this) */108pnx833x_gpio_select_function_alt(0);109110/* Setup GPIO 04 to input NAND read/busy signal */111pnx833x_gpio_select_function_io(4);112pnx833x_gpio_select_input(4);113114/* Setup GPIO 05 to disable NAND write protect */115pnx833x_gpio_select_function_io(5);116pnx833x_gpio_select_output(5);117pnx833x_gpio_write(1, 5);118119#elif defined(CONFIG_MTD_CFI) || defined(CONFIG_MTD_CFI_MODULE)120121/* Set up MIU for 16-bit NOR access on CS0 and CS1... */122123/* Setup MIU CS0 & CS1 timing */124PNX833X_MIU_SEL0 = 1;125PNX833X_MIU_SEL1 = 1;126PNX833X_MIU_SEL0_TIMING = 0x6A08D082;127PNX833X_MIU_SEL1_TIMING = 0x6A08D082;128129/* Setup GPIO 00 for use as MIU CS1 (CS0 is not multiplexed, so does not need this) */130pnx833x_gpio_select_function_alt(0);131#endif132}133134135