Commit 5fb692ca authored by Stefan Roese's avatar Stefan Roese
Browse files

[PATCH] Add support for AMCC Taishan PPC440GX eval board


Signed-off-by: default avatarStefan Roese <sr@denx.de>
parent 1bbbbdd2
......@@ -292,6 +292,7 @@ Stefan Roese <sr@denx.de>
pcs440ep PPC440EP
sequoia PPC440EPx
sycamore PPC405GPr
taishan PPC440GX
walnut PPC405GP
yellowstone PPC440GR
yosemite PPC440EP
......
......@@ -86,9 +86,9 @@ LIST_4xx=" \
ocotea OCRTC ORSG p3p440 \
PCI405 pcs440ep PIP405 PLU405 \
PMC405 PPChameleonEVB sbc405 sequoia \
sequoia_nand VOH405 VOM405 W7OLMC \
W7OLMG walnut WUH405 XPEDITE1K \
yellowstone yosemite yucca \
sequoia_nand taishan VOH405 VOM405 \
W7OLMC W7OLMG walnut WUH405 \
XPEDITE1K yellowstone yosemite yucca \
"
#########################################################################
......
......@@ -1207,6 +1207,9 @@ sycamore_config: unconfig
@echo "Configuring for sycamore board as subset of walnut..."
@$(MKCONFIG) -a walnut ppc ppc4xx walnut amcc
taishan_config: unconfig
@$(MKCONFIG) $(@:_config=) ppc ppc4xx taishan amcc
VOH405_config: unconfig
@$(MKCONFIG) $(@:_config=) ppc ppc4xx voh405 esd
......
#
# (C) Copyright 2007
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
#
# See file CREDITS for list of people who contributed to this
# project.
#
# 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 $(TOPDIR)/config.mk
LIB = $(obj)lib$(BOARD).a
COBJS = $(BOARD).o lcd.o update.o showinfo.o
SOBJS = init.o
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(COBJS))
SOBJS := $(addprefix $(obj),$(SOBJS))
$(LIB): $(OBJS) $(SOBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
clean:
rm -f $(SOBJS) $(OBJS)
distclean: clean
rm -f $(LIB) core *.bak .depend
#########################################################################
# defines $(obj).depend target
include $(SRCTREE)/rules.mk
sinclude $(obj).depend
#########################################################################
#
# (C) Copyright 2004
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
#
# See file CREDITS for list of people who contributed to this
# project.
#
# 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
#
#
# AMCC 440GX Reference Platform (Taishan) board
#
#TEXT_BASE = 0xFFFE0000
ifeq ($(ramsym),1)
TEXT_BASE = 0x07FD0000
else
TEXT_BASE = 0xFFFC0000
endif
PLATFORM_CPPFLAGS += -DCONFIG_440=1
ifeq ($(debug),1)
PLATFORM_CPPFLAGS += -DDEBUG
endif
ifeq ($(dbcr),1)
PLATFORM_CPPFLAGS += -DCFG_INIT_DBCR=0x8cff0000
endif
/*
* (C) Copyright 2007
* Stefan Roese, DENX Software Engineering, sr@denx.de.
*
* See file CREDITS for list of people who contributed to this
* project.
*
* 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 <ppc_asm.tmpl>
#include <config.h>
/* General */
#define TLB_VALID 0x00000200
#define _256M 0x10000000
/* Supported page sizes */
#define SZ_1K 0x00000000
#define SZ_4K 0x00000010
#define SZ_16K 0x00000020
#define SZ_64K 0x00000030
#define SZ_256K 0x00000040
#define SZ_1M 0x00000050
#define SZ_8M 0x00000060
#define SZ_16M 0x00000070
#define SZ_256M 0x00000090
/* Storage attributes */
#define SA_W 0x00000800 /* Write-through */
#define SA_I 0x00000400 /* Caching inhibited */
#define SA_M 0x00000200 /* Memory coherence */
#define SA_G 0x00000100 /* Guarded */
#define SA_E 0x00000080 /* Endian */
/* Access control */
#define AC_X 0x00000024 /* Execute */
#define AC_W 0x00000012 /* Write */
#define AC_R 0x00000009 /* Read */
/* Some handy macros */
#define EPN(e) ((e) & 0xfffffc00)
#define TLB0(epn,sz) ( (EPN((epn)) | (sz) | TLB_VALID ) )
#define TLB1(rpn,erpn) ( ((rpn)&0xfffffc00) | (erpn) )
#define TLB2(a) ( (a)&0x00000fbf )
#define tlbtab_start\
mflr r1 ;\
bl 0f ;
#define tlbtab_end\
.long 0, 0, 0 ; \
0: mflr r0 ; \
mtlr r1 ; \
blr ;
#define tlbentry(epn,sz,rpn,erpn,attr)\
.long TLB0(epn,sz),TLB1(rpn,erpn),TLB2(attr)
/**************************************************************************
* TLB TABLE
*
* This table is used by the cpu boot code to setup the initial tlb
* entries. Rather than make broad assumptions in the cpu source tree,
* this table lets each board set things up however they like.
*
* Pointer to the table is returned in r1
*
*************************************************************************/
.section .bootpg,"ax"
.globl tlbtab
tlbtab:
tlbtab_start
tlbentry( 0xf0000000, SZ_256M, 0xf0000000, 1, AC_R|AC_W|AC_X|SA_G|SA_I)
tlbentry( CFG_PERIPHERAL_BASE, SZ_256M, 0x40000000, 1, AC_R|AC_W|SA_G|SA_I)
tlbentry( CFG_ISRAM_BASE, SZ_256K, 0x80000000, 0, AC_R|AC_W|AC_X )
tlbentry( CFG_SDRAM_BASE, SZ_256M, 0x00000000, 0, AC_R|AC_W|AC_X|SA_G|SA_I )
tlbentry( CFG_PCI_BASE, SZ_256M, 0x00000000, 2, AC_R|AC_W|SA_G|SA_I )
tlbentry( CFG_PCI_MEMBASE, SZ_256M, 0x00000000, 3, AC_R|AC_W|SA_G|SA_I )
tlbtab_end
/*
* (C) Copyright 2007
* Stefan Roese, DENX Software Engineering, sr@denx.de.
*
* See file CREDITS for list of people who contributed to this
* project.
*
* 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 <config.h>
#include <common.h>
#include <command.h>
#include <i2c.h>
#include <miiphy.h>
#ifdef CONFIG_TAISHAN
#define LCD_DELAY_NORMAL_US 100
#define LCD_DELAY_NORMAL_MS 2
#define LCD_CMD_ADDR ((volatile char *)(CFG_EBC2_LCM_BASE))
#define LCD_DATA_ADDR ((volatile char *)(CFG_EBC2_LCM_BASE+1))
#define LCD_BLK_CTRL ((volatile char *)(CFG_EBC1_FPGA_BASE+0x2))
#define mdelay(t) ({unsigned long msec=(t); while (msec--) { udelay(1000);}})
static int g_lcd_init_b = 0;
static char *amcc_logo = " AMCC TAISHAN 440GX EvalBoard";
static char addr_flag = 0x80;
static void lcd_bl_ctrl(char val)
{
char cpld_val;
cpld_val = *LCD_BLK_CTRL;
*LCD_BLK_CTRL = val | cpld_val;
}
static void lcd_putc(char val)
{
int i = 100;
char addr;
while (i--) {
if ((*LCD_CMD_ADDR & 0x80) != 0x80) { /*BF = 1 ? */
udelay(LCD_DELAY_NORMAL_US);
break;
}
udelay(LCD_DELAY_NORMAL_US);
}
if (*LCD_CMD_ADDR & 0x80) {
printf("LCD is busy\n");
return;
}
addr = *LCD_CMD_ADDR;
udelay(LCD_DELAY_NORMAL_US);
if ((addr != 0) && (addr % 0x10 == 0)) {
addr_flag ^= 0x40;
*LCD_CMD_ADDR = addr_flag;
}
udelay(LCD_DELAY_NORMAL_US);
*LCD_DATA_ADDR = val;
udelay(LCD_DELAY_NORMAL_US);
}
static void lcd_puts(char *s)
{
char *p = s;
int i = 100;
while (i--) {
if ((*LCD_CMD_ADDR & 0x80) != 0x80) { /*BF = 1 ? */
udelay(LCD_DELAY_NORMAL_US);
break;
}
udelay(LCD_DELAY_NORMAL_US);
}
if (*LCD_CMD_ADDR & 0x80) {
printf("LCD is busy\n");
return;
}
while (*p)
lcd_putc(*p++);
}
static void lcd_put_logo(void)
{
int i = 100;
char *p = amcc_logo;
while (i--) {
if ((*LCD_CMD_ADDR & 0x80) != 0x80) { /*BF = 1 ? */
udelay(LCD_DELAY_NORMAL_US);
break;
}
udelay(LCD_DELAY_NORMAL_US);
}
if (*LCD_CMD_ADDR & 0x80) {
printf("LCD is busy\n");
return;
}
*LCD_CMD_ADDR = 0x80;
while (*p)
lcd_putc(*p++);
}
int lcd_init(void)
{
if (g_lcd_init_b == 0) {
puts("LCD: ");
mdelay(100); /* Waiting for the LCD initialize */
*LCD_CMD_ADDR = 0x38; /*set function:8-bit,2-line,5x7 font type */
udelay(LCD_DELAY_NORMAL_US);
*LCD_CMD_ADDR = 0x0f; /*set display on,cursor on,blink on */
udelay(LCD_DELAY_NORMAL_US);
*LCD_CMD_ADDR = 0x01; /*display clear */
mdelay(LCD_DELAY_NORMAL_MS);
*LCD_CMD_ADDR = 0x06; /*set entry */
udelay(LCD_DELAY_NORMAL_US);
lcd_bl_ctrl(0x02);
lcd_put_logo();
puts(" ready\n");
g_lcd_init_b = 1;
}
return 0;
}
static int do_lcd_test(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
{
lcd_init();
return 0;
}
static int do_lcd_clear(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
{
*LCD_CMD_ADDR = 0x01;
mdelay(LCD_DELAY_NORMAL_MS);
return 0;
}
static int do_lcd_puts(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
{
if (argc < 2) {
printf("%s", cmdtp->usage);
return 1;
}
lcd_puts(argv[1]);
return 0;
}
static int do_lcd_putc(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
{
if (argc < 2) {
printf("%s", cmdtp->usage);
return 1;
}
lcd_putc((char)argv[1][0]);
return 0;
}
static int do_lcd_cur(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
{
ulong count;
ulong dir;
char cur_addr;
if (argc < 3) {
printf("%s", cmdtp->usage);
return 1;
}
count = simple_strtoul(argv[1], NULL, 16);
if (count > 31) {
printf("unable to shift > 0x20\n");
count = 0;
}
dir = simple_strtoul(argv[2], NULL, 16);
cur_addr = *LCD_CMD_ADDR;
udelay(LCD_DELAY_NORMAL_US);
if (dir == 0x0) {
if (addr_flag == 0x80) {
if (count >= (cur_addr & 0xf)) {
*LCD_CMD_ADDR = 0x80;
udelay(LCD_DELAY_NORMAL_US);
count = 0;
}
} else {
if (count >= ((cur_addr & 0x0f) + 0x0f)) {
*LCD_CMD_ADDR = 0x80;
addr_flag = 0x80;
udelay(LCD_DELAY_NORMAL_US);
count = 0x0;
} else if (count >= (cur_addr & 0xf)) {
count -= cur_addr & 0xf;
*LCD_CMD_ADDR = 0x80 | 0xf;
addr_flag = 0x80;
udelay(LCD_DELAY_NORMAL_US);
}
}
} else {
if (addr_flag == 0x80) {
if (count >= (0x1f - (cur_addr & 0xf))) {
count = 0x0;
addr_flag = 0xc0;
*LCD_CMD_ADDR = 0xc0 | 0xf;
udelay(LCD_DELAY_NORMAL_US);
} else if ((count + (cur_addr & 0xf)) >= 0x0f) {
count = count + (cur_addr & 0xf) - 0x0f;
addr_flag = 0xc0;
*LCD_CMD_ADDR = 0xc0;
udelay(LCD_DELAY_NORMAL_US);
}
} else if ((count + (cur_addr & 0xf)) >= 0x0f) {
count = 0x0;
*LCD_CMD_ADDR = 0xc0 | 0xf;
udelay(LCD_DELAY_NORMAL_US);
}
}
while (count--) {
if (dir == 0) {
*LCD_CMD_ADDR = 0x10;
} else {
*LCD_CMD_ADDR = 0x14;
}
udelay(LCD_DELAY_NORMAL_US);
}
return 0;
}
U_BOOT_CMD(lcd_test, 1, 1, do_lcd_test, "lcd_test - lcd test display\n", NULL);
U_BOOT_CMD(lcd_cls, 1, 1, do_lcd_clear, "lcd_cls - lcd clear display\n", NULL);
U_BOOT_CMD(lcd_puts, 2, 1, do_lcd_puts,
"lcd_puts - display string on lcd\n",
"<string> - <string> to be displayed\n");
U_BOOT_CMD(lcd_putc, 2, 1, do_lcd_putc,
"lcd_putc - display char on lcd\n",
"<char> - <char> to be displayed\n");
U_BOOT_CMD(lcd_cur, 3, 1, do_lcd_cur,
"lcd_cur - shift cursor on lcd\n",
"<count> <dir>- shift cursor on lcd <count> times, direction is <dir> \n"
" <count> - 0~31\n" " <dir> - 0,backward; 1, forward\n");
#if 0 // test-only
void set_phy_loopback_mode(void)
{
char devemac2[32];
char devemac3[32];
sprintf(devemac2, "%s2", CONFIG_EMAC_DEV_NAME);
sprintf(devemac3, "%s3", CONFIG_EMAC_DEV_NAME);
#if 0
unsigned short reg_short;
miiphy_read(devemac2, 0x1, 1, &reg_short);
if (reg_short & 0x04) {
/*
* printf("EMAC2 link up,do nothing\n");
*/
} else {
udelay(1000);
miiphy_write(devemac2, 0x1, 0, 0x6000);
udelay(1000);
miiphy_read(devemac2, 0x1, 0, &reg_short);
if (reg_short != 0x6000) {
printf
("\nEMAC2 error set LOOPBACK mode error,reg2[0]=%x\n",
reg_short);
}
}
miiphy_read(devemac3, 0x3, 1, &reg_short);
if (reg_short & 0x04) {
/*
* printf("EMAC3 link up,do nothing\n");
*/
} else {
udelay(1000);
miiphy_write(devemac3, 0x3, 0, 0x6000);
udelay(1000);
miiphy_read(devemac3, 0x3, 0, &reg_short);
if (reg_short != 0x6000) {
printf
("\nEMAC3 error set LOOPBACK mode error,reg2[0]=%x\n",
reg_short);
}
}
#else
/* Set PHY as LOOPBACK MODE, for Linux emac initializing */
miiphy_write(devemac2, CONFIG_PHY2_ADDR, 0, 0x6000);
udelay(1000);
miiphy_write(devemac3, CONFIG_PHY3_ADDR, 0, 0x6000);
udelay(1000);
#endif
}
void set_phy_normal_mode(void)
{
char devemac2[32];
char devemac3[32];
unsigned short reg_short;
sprintf(devemac2, "%s2", CONFIG_EMAC_DEV_NAME);
sprintf(devemac3, "%s3", CONFIG_EMAC_DEV_NAME);
/* Set phy of EMAC2 */
miiphy_read(devemac2, CONFIG_PHY2_ADDR, 0x16, &reg_short);
reg_short &= ~(0x7);
reg_short |= 0x6; /* RGMII DLL Delay */
miiphy_write(devemac2, CONFIG_PHY2_ADDR, 0x16, reg_short);
miiphy_read(devemac2, CONFIG_PHY2_ADDR, 0x17, &reg_short);
reg_short &= ~(0x40);
miiphy_write(devemac2, CONFIG_PHY2_ADDR, 0x17, reg_short);
miiphy_write(devemac2, CONFIG_PHY2_ADDR, 0x1c, 0x74f0);
/* Set phy of EMAC3 */
miiphy_read(devemac3, CONFIG_PHY3_ADDR, 0x16, &reg_short);
reg_short &= ~(0x7);
reg_short |= 0x6; /* RGMII DLL Delay */
miiphy_write(devemac3, CONFIG_PHY3_ADDR, 0x16, reg_short);
miiphy_read(devemac3, CONFIG_PHY3_ADDR, 0x17, &reg_short);
reg_short &= ~(0x40);
miiphy_write(devemac3, CONFIG_PHY3_ADDR, 0x17, reg_short);
miiphy_write(devemac3, CONFIG_PHY3_ADDR, 0x1c, 0x74f0);
}
#endif
static int do_led_test_off(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
{
volatile unsigned int *GpioOr =
(volatile unsigned int *)(CFG_PERIPHERAL_BASE + 0x700);
*GpioOr |= 0x00300000;
return 0;
}
static int do_led_test_on(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
{
volatile unsigned int *GpioOr =
(volatile unsigned int *)(CFG_PERIPHERAL_BASE + 0x700);
*GpioOr &= ~0x00300000;
return 0;
}
U_BOOT_CMD(ledon, 1, 1, do_led_test_on,
"ledon - led test light on\n", NULL);
U_BOOT_CMD(ledoff, 1, 1, do_led_test_off,
"ledoff - led test light off\n", NULL);
#endif
/*
* (C) Copyright 2007
* Stefan Roese, DENX Software Engineering, sr@denx.de.
*
* See file CREDITS for list of people who contributed to this
* project.
*
* 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 mo