Browse Source

LS2k add timer irq support.

Change-Id: Ic936813b55057ead1f7f104311d3fdf0bac57520
Signed-off-by: Chong Qiao <qiaochong@loongson.cn>
master
Chong Qiao 3 years ago
parent
commit
87345565ee
  1. 1
      Targets/LS2K/conf/files.LS2K
  2. 77
      Targets/LS2K/dev/irq.c
  3. 3
      Targets/LS2K/include/bonito.h
  4. 27
      Targets/LS2K/ls2k/tgt_machdep.c

1
Targets/LS2K/conf/files.LS2K

@ -44,6 +44,7 @@ file Targets/LS2K/dev/i2c.c i2c
file Targets/LS2K/dev/9022a.c sii9022a needs-flag
file Targets/LS2K/dev/lt8168.c lt8168s needs-flag
file Targets/LS2K/dev/can_test.c can
file Targets/LS2K/dev/irq.c timer_irq needs-flag
device syn: ether, ifnet

77
Targets/LS2K/dev/irq.c

@ -0,0 +1,77 @@
#include <pmon.h>
#include <errno.h>
#include <asm/mipsregs.h>
#include "include/bonito.h"
#define ST0_IM 0x0000ff00
#define CAUSEF_IP7 ( 1 << 15)
#define CAUSEF_IP6 ( 1 << 14)
#define CAUSEF_IP5 ( 1 << 13)
#define CAUSEF_IP4 ( 1 << 12)
#define CAUSEF_IP3 ( 1 << 11)
#define CAUSEF_IP2 ( 1 << 10)
static int wdt_enable()
{
*(volatile int *)0xbbef0038 = 5*125000000;
*(volatile int *)0xbbef0030 = 2;
*(volatile int *)0xbbef0034 = 1;
return 0;
}
static int wdt_disable()
{
*(volatile int *)0xbbef0038 = 5*125000000;
*(volatile int *)0xbbef0034 = 1;
*(volatile int *)0xbbef0030 = 0;
return 0;
}
static int wdt_feed()
{
*(volatile int *)0xbbef0034 = 1;
}
#define IRQ_HZ 4
static int wdt_timeout;
void plat_irq_dispatch(struct trapframe *frame)
{
unsigned int cause = read_c0_cause() & ST0_IM;
unsigned int status = read_c0_status() & ST0_IM;
unsigned int pending = cause & status;
if(pending & CAUSEF_IP7)
{
static int cnt=0;
cnt++;
write_c0_compare(read_c0_count()+400000000/IRQ_HZ);
if(cnt<wdt_timeout*IRQ_HZ)
{
wdt_feed();
}
}
else
{
printf("spurious interrupt\n");
}
}
void init_IRQ()
{
int wdt;
write_c0_compare(400000000/4);
write_c0_count(0);
set_c0_status(0x8001);
wdt = *(unsigned short *)(0xbfc00000+NVRAM_OFFS+WDT_OFFS);
if(wdt==0xffff||wdt==0) wdt_timeout=300;
else wdt_timeout=wdt;
wdt_enable();
}
void uninit_IRQ()
{
clear_c0_status(0x8001);
wdt_disable();
}

3
Targets/LS2K/include/bonito.h

@ -74,8 +74,9 @@ struct pci_config_data {
#endif
#ifdef NVRAM_IN_FLASH
# define NVRAM_SIZE 492 /*modified by tangyt*/
# define NVRAM_SIZE 490 /*modified by tangyt*/
# define NVRAM_SECSIZE 512
# define WDT_OFFS 490
# define ACTIVECOM_OFFS 492 /*added by tangyt*/
# define MASTER_BRIDGE_OFFS 493 /*added by tangyt*/
#ifdef BOOT_FROM_NAND

27
Targets/LS2K/ls2k/tgt_machdep.c

@ -32,6 +32,7 @@
*/
#include <sys/linux/types.h>
#include <include/stdarg.h>
#include "timer_irq.h"
unsigned int mem_size = 0;
#include "../../../pmon/common/smbios/smbios.h"
@ -188,6 +189,7 @@ extern unsigned long long memorysize_high;
extern char MipsException[], MipsExceptionEnd[];
unsigned char hwethadr[6];
unsigned short wdt;
unsigned char ls2kver;
#ifdef LOWPOWER
unsigned int shutdev;
@ -237,6 +239,17 @@ void initmips(unsigned long long raw_memsz)
unsigned int i;
//core1 run wait_for_smp_call function in ram
asm volatile(".set mips64;sd %1,(%0);.set mips0;"::"r"(0xbfe11120),"r"(&wait_for_smp_call));
CPU_ConfigCache();
bcopy(MipsException, (char *)XTLB_MISS_EXC_VEC,
MipsExceptionEnd - MipsException);
bcopy(MipsException, (char *)GEN_EXC_VEC,
MipsExceptionEnd - MipsException);
#ifndef ROM_EXCEPTION
CPU_SetSR(0, SR_BOOT_EXC_VEC);
#endif
#if NTIMER_IRQ
init_IRQ();
#endif
#ifdef CONFIG_UART0_SPLIT
*(volatile int *)0xbfe10428 |= 0xe;
#endif
@ -362,13 +375,9 @@ void initmips(unsigned long long raw_memsz)
/*
* Init PMON and debug
*/
CPU_ConfigCache();
dbginit(NULL);
#ifndef ROM_EXCEPTION
CPU_SetSR(0, SR_BOOT_EXC_VEC);
#endif
{
int spi_read_area(int flashaddr, char *buffer, int size);
int spi_write_area(int flashaddr,char *buffer,int size);
@ -381,10 +390,6 @@ void initmips(unsigned long long raw_memsz)
* Set up exception vectors.
*/
SBD_DISPLAY("BEV1", 0);
bcopy(MipsException, (char *)XTLB_MISS_EXC_VEC,
MipsExceptionEnd - MipsException);
bcopy(MipsException, (char *)GEN_EXC_VEC,
MipsExceptionEnd - MipsException);
SBD_DISPLAY("BEV0", 0);
printf("BEV in SR set to zero.\n");
/*disable spi instruct fetch before enter spi io mode*/
@ -1458,6 +1463,9 @@ void tgt_mapenv(int (*func) __P((char *, char *)))
sprintf(env, "%02x:%02x:%02x:%02x:%02x:%02x", hwethadr[0], hwethadr[1],
hwethadr[2], hwethadr[3], hwethadr[4], hwethadr[5]);
(*func) ("ethaddr", env);
bcopy(&nvram[WDT_OFFS], &wdt, 2);
sprintf(env, "%d", (wdt==0||wdt==0xffff)?300:wdt);
(*func)("wdt", env);
ls2kver = nvram[VER_OFFS] ^ 0x50;
if(ls2kver>1)
ls2kver = ls2k_version();
@ -1773,6 +1781,8 @@ int tgt_setenv(char *name, char *value)
hwethadr[i] = v;
s += 3; /* Don't get to fancy here :-) */
}
} else if (strcmp("wdt", name) == 0) {
wdt = strtoul(value,0,0);
} else {
ep = nvrambuf + 2;
if (*ep != '\0') {
@ -1824,6 +1834,7 @@ int tgt_setenv(char *name, char *value)
bcopy(&em_enable, &nvrambuf[MASTER_BRIDGE_OFFS], 1);
#endif
bcopy(hwethadr, &nvramsecbuf[ETHER_OFFS], 6);
bcopy(&wdt, &nvramsecbuf[WDT_OFFS], 2);
nvramsecbuf[VER_OFFS] = ls2kver | 0x50;
return (1);
}

Loading…
Cancel
Save