Commit 3a574cbe authored by wdenk's avatar wdenk
Browse files

* Patch by Greg Ungerer, 19 May 2005:

  add support for the KS8695P (ARM 922 based) CPU

* Patch by Steven Scholz, 19 May 2005:
  Add support for CONFIG_SERIAL_TAG on ARM boards
parent 7680c140
......@@ -2,6 +2,13 @@
Changes for U-Boot 1.1.3:
======================================================================
* Patches by Greg Ungerer, 19 May 2005:
- add support for the KS8695P (ARM 922 based) CPU
- add support for the OpenGear CM4008, CM4116 and CM4148 boards
* Patch by Steven Scholz, 19 May 2005:
Add support for CONFIG_SERIAL_TAG on ARM boards
* Add PCI support for Sorcery board.
Code cleanup (especially Sorcery / Alaska / Yukon serial driver).
......
......@@ -394,6 +394,10 @@ N: Rune Torgersen
E: <runet@innovsys.com>
D: Support for Motorola MPC8266ADS board
N: Greg Ungerer
E: greg.ungerer@opengear.com
D: Support for ks8695 CPU, and OpenGear cmXXXX boards
N: David Updegraff
E: dave@cray.com
D: Port to Cray L1 board; DHCP vendor extensions
......
......@@ -413,6 +413,12 @@ Andrea Scian <andrea.scian@dave-tech.it>
B2 ARM7TDMI (S3C44B0X)
Greg Ungerer <greg.ungerer@opengear.com>
cm4008 ks8695p
cm4116 ks8695p
cm4148 ks8695p
Alex Zpke <azu@sysgo.de>
lart SA1100
......
#
# (C) Copyright 2000-2005
# 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 = lib$(SOC).a
OBJS = interrupts.o serial.o
SOBJS = lowlevel_init.o
all: .depend $(LIB)
$(LIB): $(OBJS) $(SOBJS)
$(AR) crv $@ $(OBJS) $(SOBJS)
#########################################################################
.depend: Makefile $(OBJS:.o=.c)
$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
sinclude .depend
#########################################################################
/*
* (C) Copyright 2004-2005, Greg Ungerer <greg.ungerer@opengear.com>
*
* 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 <common.h>
#include <asm/arch/platform.h>
/*
* Handy KS8695 register access functions.
*/
#define ks8695_read(a) *((volatile ulong *) (KS8695_IO_BASE + (a)))
#define ks8695_write(a,v) *((volatile ulong *) (KS8695_IO_BASE + (a))) = (v)
int timer_inited;
ulong timer_ticks;
int interrupt_init (void)
{
/* nothing happens here - we don't setup any IRQs */
return (0);
}
/*
* Initial timer set constants. Nothing complicated, just set for a 1ms
* tick.
*/
#define TIMER_INTERVAL (TICKS_PER_uSEC * mSEC_1)
#define TIMER_COUNT (TIMER_INTERVAL / 2)
#define TIMER_PULSE TIMER_COUNT
void reset_timer_masked(void)
{
/* Set the hadware timer for 1ms */
ks8695_write(KS8695_TIMER1, TIMER_COUNT);
ks8695_write(KS8695_TIMER1_PCOUNT, TIMER_PULSE);
ks8695_write(KS8695_TIMER_CTRL, 0x2);
timer_ticks = 0;
timer_inited++;
}
void reset_timer(void)
{
reset_timer_masked();
}
ulong get_timer_masked(void)
{
/* Check for timer wrap */
if (ks8695_read(KS8695_INT_STATUS) & KS8695_INTMASK_TIMERINT1) {
/* Clear interrupt condition */
ks8695_write(KS8695_INT_STATUS, KS8695_INTMASK_TIMERINT1);
timer_ticks++;
}
return timer_ticks;
}
ulong get_timer(ulong base)
{
return (get_timer_masked() - base);
}
void set_timer(ulong t)
{
timer_ticks = t;
}
void udelay(ulong usec)
{
ulong start = get_timer_masked();
ulong end;
if (!timer_inited)
reset_timer();
/* Only 1ms resolution :-( */
end = usec / 1000;
while (get_timer(start) < end)
;
}
void reset_cpu (ulong ignored)
{
ulong tc;
/* Set timer0 to watchdog, and let it timeout */
tc = ks8695_read(KS8695_TIMER_CTRL) & 0x2;
ks8695_write(KS8695_TIMER_CTRL, tc);
ks8695_write(KS8695_TIMER0, ((10 << 8) | 0xff));
ks8695_write(KS8695_TIMER_CTRL, (tc | 0x1));
/* Should only wait here till watchdog resets */
for (;;)
;
}
/*
* lowlevel_init.S - basic hardware initialization for the KS8695 CPU
*
* Copyright (c) 2004-2005, Greg Ungerer <greg.ungerer@opengear.com>
*
* 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 <version.h>
#include <asm/arch/platform.h>
#ifndef CONFIG_SKIP_LOWLEVEL_INIT
/*
*************************************************************************
*
* Handy dandy macros
*
*************************************************************************
*/
/* Delay a bit */
.macro DELAY_FOR cycles, reg0
ldr \reg0, =\cycles
subs \reg0, \reg0, #1
subne pc, pc, #0xc
.endm
/*
*************************************************************************
*
* Some local storage.
*
*************************************************************************
*/
/* Should we boot with an interactive console or not */
.globl serial_console
/*
*************************************************************************
*
* Raw hardware initialization code. The important thing is to get
* SDRAM setup and running. We do some other basic things here too,
* like getting the PLL set for high speed, and init the LEDs.
*
*************************************************************************
*/
.globl lowlevel_init
lowlevel_init:
#if DEBUG
/*
* enable UART for early debug trace
*/
ldr r1, =(KS8695_IO_BASE+KS8695_UART_DIVISOR)
mov r2, #0xd9
str r2, [r1] /* 115200 baud */
ldr r1, =(KS8695_IO_BASE+KS8695_UART_LINE_CTRL)
mov r2, #0x03
str r2, [r1] /* 8 data bits, no parity, 1 stop */
ldr r1, =(KS8695_IO_BASE+KS8695_UART_TX_HOLDING)
mov r2, #0x41
str r2, [r1] /* write 'A' */
#endif
#if DEBUG
ldr r1, =(KS8695_IO_BASE+KS8695_UART_TX_HOLDING)
mov r2, #0x42
str r2, [r1]
#endif
/*
* remap the memory and flash regions. we want to end up with
* ram from address 0, and flash at 32MB.
*/
ldr r1, =(KS8695_IO_BASE+KS8695_MEM_CTRL0)
ldr r2, =0xbfc00040
str r2, [r1] /* large flash map */
ldr pc, =(highflash+0x02000000-0x00f00000) /* jump to high flash address */
highflash:
ldr r2, =0x8fe00040
str r2, [r1] /* remap flash range */
/*
* remap the second select region to the 4MB immediately after
* the first region. This way if you have a larger flash (say 8Mb)
* then you can have it all mapped nicely. Has no effect if you
* only have a 4Mb or smaller flash.
*/
ldr r1, =(KS8695_IO_BASE+KS8695_MEM_CTRL1)
ldr r2, =0x9fe40040
str r2, [r1] /* remap flash2 region, contiguous */
ldr r1, =(KS8695_IO_BASE+KS8695_MEM_GENERAL)
ldr r2, =0x30000005
str r2, [r1] /* enable both flash selects */
#ifdef CONFIG_CM41xx
/*
* map the second flash chip, using the external IO lines.
*/
ldr r1, =(KS8695_IO_BASE+KS8695_IO_CTRL0)
ldr r2, =0xafe80b6d
str r2, [r1] /* remap io0 region, contiguous */
ldr r1, =(KS8695_IO_BASE+KS8695_IO_CTRL1)
ldr r2, =0xbfec0b6d
str r2, [r1] /* remap io1 region, contiguous */
ldr r1, =(KS8695_IO_BASE+KS8695_MEM_GENERAL)
ldr r2, =0x30050005
str r2, [r1] /* enable second flash */
#endif
/*
* before relocating, we have to setup RAM timing
*/
ldr r1, =(KS8695_IO_BASE+KS8695_SDRAM_CTRL0)
#if (PHYS_SDRAM_1_SIZE == 0x02000000)
ldr r2, =0x7fc0000e /* 32MB */
#else
ldr r2, =0x3fc0000e /* 16MB */
#endif
str r2, [r1] /* configure sdram bank0 setup */
ldr r1, =(KS8695_IO_BASE+KS8695_SDRAM_CTRL1)
mov r2, #0
str r2, [r1] /* configure sdram bank1 setup */
ldr r1, =(KS8695_IO_BASE+KS8695_SDRAM_GENERAL)
ldr r2, =0x0000000a
str r2, [r1] /* set RAS/CAS timing */
ldr r1, =(KS8695_IO_BASE+KS8695_SDRAM_BUFFER)
ldr r2, =0x00030000
str r2, [r1] /* send NOP command */
DELAY_FOR 0x100, r0
ldr r2, =0x00010000
str r2, [r1] /* send PRECHARGE-ALL */
DELAY_FOR 0x100, r0
ldr r1, =(KS8695_IO_BASE+KS8695_SDRAM_REFRESH)
ldr r2, =0x00000020
str r2, [r1] /* set for fast refresh */
DELAY_FOR 0x100, r0
ldr r2, =0x00000190
str r2, [r1] /* set normal refresh timing */
ldr r1, =(KS8695_IO_BASE+KS8695_SDRAM_BUFFER)
ldr r2, =0x00020033
str r2, [r1] /* send mode command */
DELAY_FOR 0x100, r0
ldr r2, =0x01f00000
str r2, [r1] /* enable sdram fifos */
/*
* set pll to top speed
*/
ldr r1, =(KS8695_IO_BASE+KS8695_SYSTEN_BUS_CLOCK)
mov r2, #0
str r2, [r1] /* set pll clock to 166MHz */
ldr r1, =(KS8695_IO_BASE+KS8695_SWITCH_CTRL0)
ldr r2, [r1] /* Get switch ctrl0 register */
and r2, r2, #0x0fc00000 /* Mask out LED control bits */
orr r2, r2, #0x01800000 /* Set Link/activity/speed actions */
str r2, [r1]
#ifdef CONFIG_CM4008
ldr r1, =(KS8695_IO_BASE+KS8695_GPIO_MODE)
ldr r2, =0x0000fe30
str r2, [r1] /* enable LED's as outputs */
ldr r1, =(KS8695_IO_BASE+KS8695_GPIO_DATA)
ldr r2, =0x0000fe20
str r2, [r1] /* turn on power LED */
#endif
#if defined(CONFIG_CM4008) || defined(CONFIG_CM41xx)
ldr r2, [r1] /* get current GPIO input data */
tst r2, #0x8 /* check if "erase" depressed */
beq nobutton
mov r2, #0 /* be quiet on boot, no console */
ldr r1, =serial_console
str r2, [r1]
nobutton:
#endif
add lr, lr, #0x02000000 /* flash is now mapped high */
add ip, ip, #0x02000000 /* this is a hack */
mov pc, lr /* all done, return */
#endif /* CONFIG_SKIP_LOWLEVEL_INIT */
/*
* serial.c -- KS8695 serial driver
*
* (C) Copyright 2004, Greg Ungerer <greg.ungerer@opengear.com>
*
* 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/arch/platform.h>
#ifndef CONFIG_SERIAL1
#error "Bad: you didn't configure serial ..."
#endif
/*
* Define the UART hardware register access structure.
*/
struct ks8695uart {
unsigned int RX; /* 0x00 - Receive data (r) */
unsigned int TX; /* 0x04 - Transmit data (w) */
unsigned int FCR; /* 0x08 - Fifo Control (r/w) */
unsigned int LCR; /* 0x0c - Line Control (r/w) */
unsigned int MCR; /* 0x10 - Modem Control (r/w) */
unsigned int LSR; /* 0x14 - Line Status (r/w) */
unsigned int MSR; /* 0x18 - Modem Status (r/w) */
unsigned int BD; /* 0x1c - Baud Rate (r/w) */
unsigned int SR; /* 0x20 - Status (r/w) */
};
#define KS8695_UART_ADDR ((void *) (KS8695_IO_BASE + KS8695_UART_RX_BUFFER))
#define KS8695_UART_CLK 25000000
/*
* Under some circumstances we want to be "quiet" and not issue any
* serial output - though we want u-boot to otherwise work and behave
* the same. By default be noisy.
*/
int serial_console = 1;
void serial_setbrg(void)
{
DECLARE_GLOBAL_DATA_PTR;
volatile struct ks8695uart *uartp = KS8695_UART_ADDR;
/* Set to global baud rate and 8 data bits, no parity, 1 stop bit*/
uartp->BD = KS8695_UART_CLK / gd->baudrate;
uartp->LCR = KS8695_UART_LINEC_WLEN8;
}
int serial_init(void)
{
serial_console = 1;
serial_setbrg();
return 0;
}
void serial_raw_putc(const char c)
{
volatile struct ks8695uart *uartp = KS8695_UART_ADDR;
int i;
for (i = 0; (i < 0x100000); i++) {
if (uartp->LSR & KS8695_UART_LINES_TXFE)
break;
}
uartp->TX = c;
}
void serial_putc(const char c)
{
if (serial_console) {
serial_raw_putc(c);
if (c == '\n')
serial_raw_putc('\r');
}
}
int serial_tstc(void)
{
volatile struct ks8695uart *uartp = KS8695_UART_ADDR;
if (serial_console)
return ((uartp->LSR & KS8695_UART_LINES_RXFE) ? 1 : 0);
return 0;
}
void serial_puts(const char *s)
{
char c;
while ((c = *s++) != 0)
serial_putc(c);
}
int serial_getc(void)
{
volatile struct ks8695uart *uartp = KS8695_UART_ADDR;
while ((uartp->LSR & KS8695_UART_LINES_RXFE) == 0)
;
return (uartp->RX);
}
......@@ -47,7 +47,8 @@ OBJS = 3c589.o 5701rls.o ali512x.o \
status_led.o sym53c8xx.o \
ti_pci1410a.o tigon3.o \
usbdcore.o usbdcore_ep0.o usbdcore_omap1510.o usbtty.o \
videomodes.o w83c553f.o
videomodes.o w83c553f.o \
ks8695eth.o
all: $(LIB)
......
/*
* ks8695eth.c -- KS8695 ethernet driver
*
* (C) Copyright 2004-2005, Greg Ungerer <greg.ungerer@opengear.com>
*
* 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 <malloc.h>
#include <net.h>
#include <asm/io.h>
#include <asm/arch/platform.h>
/****************************************************************************/
/*
* Hardware register access to the KS8695 LAN ethernet port
* (well, it is the 4 port switch really).
*/
#define ks8695_read(a) *((volatile unsigned long *) (KS8695_IO_BASE + (a)))
#define ks8695_write(a,v) *((volatile unsigned long *) (KS8695_IO_BASE + (a))) = (v)
/****************************************************************************/
/*
* Define the descriptor in-memory data structures.
*/
struct ks8695_txdesc {
uint32_t owner;
uint32_t ctrl;
uint32_t addr;
uint32_t next;
};
struct ks8695_rxdesc {
uint32_t status;
uint32_t ctrl;
uint32_t addr;
uint32_t next;
};
/****************************************************************************/
/*
* Allocate local data structures to use for receiving and sending
* packets. Just to keep it all nice and simple.
*/
#define TXDESCS 4
#define RXDESCS 4
#define BUFSIZE 2048
volatile struct ks8695_txdesc ks8695_tx[TXDESCS] __attribute__((aligned(256)));
volatile struct ks8695_rxdesc ks8695_rx[RXDESCS] __attribute__((aligned(256)));
volatile uint8_t ks8695_bufs[BUFSIZE*(TXDESCS+RXDESCS)] __attribute__((aligned(2048)));;
/****************************************************************************/
/*
* Ideally we want to use the MAC address stored in flash.
* But we do some sanity checks in case they are not present
* first.
*/
unsigned char eth_mac[] = {
0x00, 0x13, 0xc6, 0x00, 0x00, 0x00
};
void ks8695_getmac(void)
{
unsigned char *fp;
int i;
/* Check if flash MAC is valid */
fp = (unsigned char *) 0x0201c000;
for (i = 0; (i < 6); i++) {
if ((fp[i] != 0) && (fp[i] != 0xff))