Commit 496dc9b4 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] H8/300: more cleanup

From: Yoshinori Sato <ysato@users.sourceforge.jp>

- gcc-3.4 warning fix.
- io access address fix.
- cleanup code.
parent b942a885
......@@ -55,9 +55,9 @@ void default_idle(void)
{
while(1) {
if (need_resched()) {
sti();
local_irq_enable();
__asm__("sleep");
cli();
local_irq_disable();
}
schedule();
}
......@@ -112,14 +112,13 @@ EXPORT_SYMBOL(machine_power_off);
void show_regs(struct pt_regs * regs)
{
printk("\n");
printk("PC: %08lx Status: %02x\n",
printk("\nPC: %08lx Status: %02x",
regs->pc, regs->ccr);
printk("ORIG_ER0: %08lx ER0: %08lx ER1: %08lx\n",
printk("\nORIG_ER0: %08lx ER0: %08lx ER1: %08lx",
regs->orig_er0, regs->er0, regs->er1);
printk("ER2: %08lx ER3: %08lx ER4: %08lx ER5: %08lx\n",
printk("\nER2: %08lx ER3: %08lx ER4: %08lx ER5: %08lx",
regs->er2, regs->er3, regs->er4, regs->er5);
printk("ER6' %08lx ",regs->er6);
printk("\nER6' %08lx ",regs->er6);
if (user_mode(regs))
printk("USP: %08lx\n", rdusp());
else
......
......@@ -156,8 +156,14 @@ void show_stack(struct task_struct *task, unsigned long *esp)
printk("\n");
}
void show_trace_task(struct task_struct *tsk)
{
show_stack(tsk,(unsigned long *)tsk->thread.esp0);
}
void dump_stack(void)
{
show_stack(NULL,NULL);
}
EXPORT_SYMBOL(dump_stack);
......@@ -162,7 +162,7 @@ void mem_init(void)
unsigned long end_mem = memory_end; /* DAVIDM - this must not include kernel stack at top */
#ifdef DEBUG
printk("Mem_init: start=%lx, end=%lx\n", start_mem, end_mem);
printk(KERN_DEBUG "Mem_init: start=%lx, end=%lx\n", start_mem, end_mem);
#endif
end_mem &= PAGE_MASK;
......@@ -179,7 +179,7 @@ void mem_init(void)
initk = (&__init_begin - &__init_end) >> 10;
tmp = nr_free_pages() << PAGE_SHIFT;
printk("Memory available: %luk/%luk RAM, %luk/%luk ROM (%dk kernel code, %dk data)\n",
printk(KERN_INFO "Memory available: %luk/%luk RAM, %luk/%luk ROM (%dk kernel code, %dk data)\n",
tmp >> 10,
len >> 10,
(rom_length > 0) ? ((rom_length >> 10) - codek) : 0,
......@@ -223,7 +223,7 @@ free_initmem()
free_page(addr);
totalram_pages++;
}
printk("Freeing unused kernel memory: %ldk freed (0x%x - 0x%x)\n",
printk(KERN_INFO "Freeing unused kernel memory: %ldk freed (0x%x - 0x%x)\n",
(addr - PAGE_ALIGN((long) &__init_begin)) >> 10,
(int)(PAGE_ALIGN((unsigned long)(&__init_begin))),
(int)(addr - PAGE_SIZE));
......
......@@ -25,12 +25,19 @@
#define CMFA 6
#define CMIEA 0x40
#define CCLR_CMA 0x08
#define CLK_DIV8192 0x03
#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192 /* Timer input freq. */
void __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
{
ctrl_outb(H8300_TIMER_COUNT_DATA,TCORA2);
ctrl_outb(0x00,_8TCSR2);
request_irq(40,timer_int,0,"timer",0);
ctrl_outb(0x40|0x08|0x03,_8TCR2);
/* setup 8bit timer ch2 */
ctrl_outb(H8300_TIMER_FREQ / HZ, TCORA2); /* set interval */
ctrl_outb(0x00, _8TCSR2); /* no output */
request_irq(40, timer_int, 0, "timer", 0);
ctrl_outb(CMIEA|CCLR_CMA|CLK_DIV8192, _8TCR2); /* start count */
}
void platform_timer_eoi(void)
......
......@@ -22,22 +22,23 @@
#include <linux/timex.h>
extern int request_irq_boot(unsigned int,
irqreturn_t (*handler)(int, void *, struct pt_regs *),
unsigned long, const char *, void *);
#if defined(CONFIG_H83007) || defined(CONFIG_H83068)
#include <asm/regs306x.h>
#define CMFA 6
#define CMIEA 0x40
#define CCLR_CMA 0x08
#define CLK_DIV8192 0x03
#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192 /* Timer input freq. */
int platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
{
ctrl_outb(H8300_TIMER_COUNT_DATA,TCORA2);
ctrl_outb(0x00,_8TCSR2);
request_irq(40,timer_int,0,"timer",0);
ctrl_outb(0x40|0x08|0x03,_8TCR2);
return 0;
/* setup 8bit timer ch2 */
ctrl_outb(H8300_TIMER_FREQ / HZ, TCORA2); /* set interval */
ctrl_outb(0x00, _8TCSR2); /* no output */
request_irq(40, timer_int, 0, "timer", 0);
ctrl_outb(CMIEA|CCLR_CMA|CLK_DIV8192, _8TCR2); /* start count */
}
void platform_timer_eoi(void)
......@@ -46,7 +47,7 @@ void platform_timer_eoi(void)
}
#endif
#if defined(H8_3002) || defined(CONFIG_H83048)
#if defined(CONFIG_H83002) || defined(CONFIG_H83048)
/* FIXME! */
#define TSTR 0x00ffff60
#define TSNC 0x00ffff61
......@@ -54,6 +55,7 @@ void platform_timer_eoi(void)
#define TFCR 0x00ffff63
#define TOER 0x00ffff90
#define TOCR 0x00ffff91
/* ITU0 */
#define TCR 0x00ffff64
#define TIOR 0x00ffff65
#define TIER 0x00ffff66
......@@ -62,23 +64,28 @@ void platform_timer_eoi(void)
#define GRA 0x00ffff6a
#define GRB 0x00ffff6c
#define CCLR_CMGRA 0x20
#define CLK_DIV8 0x03
#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8 /* Timer input freq. */
int platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
{
*(unsigned short *)GRA= H8300_TIMER_COUNT_DATA;
*(unsigned short *)TCNT=0;
ctrl_outb(0x23,TCR);
ctrl_outb(0x00,TIOR);
request_timer_irq(26,timer_int,0,"timer",0);
ctrl_outb(inb(TIER) | 0x01,TIER);
ctrl_outb(inb(TSNC) & ~0x01,TSNC);
ctrl_outb(inb(TMDR) & ~0x01,TMDR);
ctrl_outb(inb(TSTR) | 0x01,TSTR);
*(unsigned short *)GRA= H8300_TIMER_FREQ / HZ; /* set interval */
*(unsigned short *)TCNT=0; /* clear counter */
ctrl_outb(0x80|CCLR_CMGRA|CLK_DIV8, TCR); /* set ITU0 clock */
ctrl_outb(0x88, TIOR); /* no output */
request_irq(26, timer_int, 0, "timer", 0);
ctrl_outb(0xf9, TIER); /* compare match GRA interrupt */
ctrl_outb(ctrl_inb(TSNC) & ~0x01, TSNC); /* ITU0 async */
ctrl_outb(ctrl_inb(TMDR) & ~0x01, TMDR); /* ITU0 normal mode */
ctrl_outb(ctrl_inb(TSTR) | 0x01, TSTR); /* ITU0 Start */
return 0;
}
void platform_timer_eoi(void)
{
ctrl_outb(inb(TSR) & ~0x01,TSR);
ctrl_outb(ctrl_inb(TSR) & ~0x01,TSR);
}
#endif
......
......@@ -25,12 +25,19 @@
#define CMFA 6
#define CMIEA 0x40
#define CCLR_CMA 0x08
#define CLK_DIV8192 0x03
#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192 /* Timer input freq. */
void __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
{
ctrl_outb(H8300_TIMER_COUNT_DATA,TCORA2);
ctrl_outb(0x00,_8TCSR2);
request_irq(40,timer_int,0,"timer",0);
ctrl_outb(0x40|0x08|0x03,_8TCR2);
/* setup 8bit timer ch2 */
ctrl_outb(H8300_TIMER_FREQ / HZ, TCORA2); /* set interval */
ctrl_outb(0x00, _8TCSR2); /* no output */
request_irq(40, timer_int, 0, "timer", 0);
ctrl_outb(CMIEA|CCLR_CMA|CLK_DIV8192, _8TCR2); /* start count */
}
void platform_timer_eoi(void)
......
......@@ -246,11 +246,13 @@ static unsigned short *getnextpc(struct task_struct *child, unsigned short *pc)
return (unsigned short *)addr;
case relb:
if ((inst = 0x55) || isbranch(child,inst & 0x0f))
(unsigned char *)pc += (signed char)(*fetch_p);
pc = (unsigned short *)((unsigned long)pc +
((signed char)(*fetch_p)));
return pc+1; /* skip myself */
case relw:
if ((inst = 0x5c) || isbranch(child,(*fetch_p & 0xf0) >> 4))
(unsigned char *)pc += (signed short)(*(pc+1));
pc = (unsigned short *)((unsigned long)pc +
((signed short)(*(pc+1))));
return pc+2; /* skip myself */
}
}
......
/*
* linux/arch/h8300/platform/h8s/generic/timer.c
* linux/arch/h8300/platform/h8s/edosk2674/timer.c
*
* Yoshinori Sato <ysato@users.sourceforge.jp>
*
......@@ -23,25 +23,28 @@
#include <asm/irq.h>
#include <asm/regs267x.h>
#define REGS(regs) __REGS(regs)
#define __REGS(regs) #regs
#define CMFA 6
int __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
#define CMIEA 0x40
#define CCLR_CMA 0x08
#define CLK_DIV8192 0x03
#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192 /* Timer input freq. */
void __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
{
unsigned char mstpcrl;
mstpcrl = ctrl_inb(MSTPCRL); /* Enable timer */
mstpcrl &= ~0x01;
ctrl_outb(mstpcrl,MSTPCRL);
ctrl_outb(H8300_TIMER_COUNT_DATA,_8TCORA1);
ctrl_outb(0x00,_8TCSR1);
request_irq(76,timer_int,0,"timer",0);
ctrl_outb(0x40|0x08|0x03,_8TCR1);
return 0;
/* 8bit timer module enabled */
ctrl_outb(ctrl_inb(MSTPCRL) & ~0x01, MSTPCRL);
/* setup 8bit timer ch1 */
ctrl_outb(H8300_TIMER_FREQ / HZ, _8TCORA1); /* set interval */
ctrl_outb(0x00, _8TCSR1); /* no output */
request_irq(76, timer_int, 0, "timer" ,0);
ctrl_outb(CMIEA|CCLR_CMA|CLK_DIV8192, _8TCR1); /* start count */
}
void platform_timer_eoi(void)
{
__asm__("bclr #6,@" REGS(_8TCSR1) ":8");
*(volatile unsigned char *)_8TCSR1 &= ~(1 << CMFA);
}
void platform_gettod(int *year, int *mon, int *day, int *hour,
......
......@@ -23,18 +23,28 @@
#include <asm/irq.h>
#include <asm/regs267x.h>
int platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
#define CMFA 6
#define CMIEA 0x40
#define CCLR_CMA 0x08
#define CLK_DIV8192 0x03
#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192 /* Timer input freq. */
void __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
{
ctrl_outb(H8300_TIMER_COUNT_DATA,_8TCORA1);
ctrl_outb(0x00,_8TCSR1);
request_irq(76,timer_int,0,"timer",0);
ctrl_outb(0x40|0x08|0x03,_8TCR1);
return 0;
/* 8bit timer module enabled */
ctrl_outb(ctrl_inb(MSTPCRL) & ~0x01, MSTPCRL);
/* setup 8bit timer ch1 */
ctrl_outb(H8300_TIMER_FREQ / HZ, _8TCORA1); /* set interval */
ctrl_outb(0x00, _8TCSR1); /* no output */
request_irq(76, timer_int, 0, "timer" ,0);
ctrl_outb(CMIEA|CCLR_CMA|CLK_DIV8192, _8TCR1); /* start count */
}
void platform_timer_eoi(void)
{
__asm__("bclr #6,@0xffffb3:8");
*(volatile unsigned char *)_8TCSR1 &= ~(1 << CMFA);
}
void platform_gettod(int *year, int *mon, int *day, int *hour,
......
......@@ -76,7 +76,7 @@ static inline int h8300_buswidth(unsigned int addr)
return (*(volatile unsigned char *)ABWCR & (1 << ((addr >> 21) & 7))) == 0;
}
static inline void io_outsb(unsigned int addr, void *buf, int len)
static inline void io_outsb(unsigned int addr, const void *buf, int len)
{
volatile unsigned char *ap_b = (volatile unsigned char *) addr;
volatile unsigned short *ap_w = (volatile unsigned short *) addr;
......@@ -91,7 +91,7 @@ static inline void io_outsb(unsigned int addr, void *buf, int len)
}
}
static inline void io_outsw(unsigned int addr, void *buf, int len)
static inline void io_outsw(unsigned int addr, const void *buf, int len)
{
volatile unsigned short *ap = (volatile unsigned short *) addr;
unsigned short *bp = (unsigned short *) buf;
......@@ -99,25 +99,29 @@ static inline void io_outsw(unsigned int addr, void *buf, int len)
*ap = *bp++;
}
static inline void io_outsl(unsigned int addr, void *buf, int len)
static inline void io_outsl(unsigned int addr, const void *buf, int len)
{
volatile unsigned int *ap = (volatile unsigned int *) addr;
unsigned int *bp = (unsigned int *) buf;
unsigned long *bp = (unsigned long *) buf;
while (len--)
*ap = *bp++;
}
static inline void io_insb(unsigned int addr, void *buf, int len)
{
volatile unsigned char *ap;
volatile unsigned char *ap_b;
volatile unsigned short *ap_w;
unsigned char *bp = (unsigned char *) buf;
if(h8300_buswidth(addr))
ap = (volatile unsigned char *)(addr ^ 1);
else
ap = (volatile unsigned char *)addr;
if(h8300_buswidth(addr)) {
ap_w = (volatile unsigned short *)(addr & ~1);
while (len--)
*bp++ = *ap;
*bp++ = *ap_w & 0xff;
} else {
ap_b = (volatile unsigned char *)addr;
while (len--)
*bp++ = *ap_b;
}
}
static inline void io_insw(unsigned int addr, void *buf, int len)
......@@ -131,7 +135,7 @@ static inline void io_insw(unsigned int addr, void *buf, int len)
static inline void io_insl(unsigned int addr, void *buf, int len)
{
volatile unsigned int *ap = (volatile unsigned int *) addr;
unsigned int *bp = (unsigned int *) buf;
unsigned long *bp = (unsigned long *) buf;
while (len--)
*bp++ = *ap;
}
......@@ -145,10 +149,10 @@ static inline void io_insl(unsigned int addr, void *buf, int len)
#define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c))
#define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
#define inb(addr) ((h8300_buswidth(addr))?readb((addr) ^ 1) & 0xff:readb(addr))
#define inb(addr) ((h8300_buswidth(addr))?readw((addr) & ~1) & 0xff:readb(addr))
#define inw(addr) _swapw(readw(addr))
#define inl(addr) _swapl(readl(addr))
#define outb(x,addr) ((void)((h8300_buswidth(addr) && ((addr) & 1))?writew(x,addr):writeb(x,addr)))
#define outb(x,addr) ((void)((h8300_buswidth(addr) && ((addr) & 1))?writew(x,(addr) & ~1):writeb(x,addr)))
#define outw(x,addr) ((void) writew(_swapw(x),addr))
#define outl(x,addr) ((void) writel(_swapl(x),addr))
......
......@@ -96,7 +96,7 @@ static inline void down(struct semaphore * sem)
__asm__ __volatile__(
"stc ccr,r3l\n\t"
"orc #0x80,ccr\n\t"
"mov.l %0, er1\n\t"
"mov.l %2, er1\n\t"
"dec.l #1,er1\n\t"
"mov.l er1,%0\n\t"
"bpl 1f\n\t"
......@@ -107,8 +107,8 @@ static inline void down(struct semaphore * sem)
"1:\n\t"
"ldc r3l,ccr\n"
"2:"
: "+m"(*count)
: "g"(sem)
: "=m"(*count)
: "g"(sem),"m"(*count)
: "cc", "er1", "er2", "er3");
}
......@@ -125,7 +125,7 @@ static inline int down_interruptible(struct semaphore * sem)
__asm__ __volatile__(
"stc ccr,r1l\n\t"
"orc #0x80,ccr\n\t"
"mov.l %1, er2\n\t"
"mov.l %3, er2\n\t"
"dec.l #1,er2\n\t"
"mov.l er2,%1\n\t"
"bpl 1f\n\t"
......@@ -137,8 +137,8 @@ static inline int down_interruptible(struct semaphore * sem)
"ldc r1l,ccr\n\t"
"sub.l %0,%0\n\t"
"2:\n\t"
: "=r" (count),"+m" (*count)
: "g"(sem)
: "=r" (count),"=m" (*count)
: "g"(sem),"m"(*count)
: "cc", "er1", "er2", "er3");
return (int)count;
}
......@@ -155,7 +155,7 @@ static inline int down_trylock(struct semaphore * sem)
__asm__ __volatile__(
"stc ccr,r3l\n\t"
"orc #0x80,ccr\n\t"
"mov.l %0,er2\n\t"
"mov.l %3,er2\n\t"
"dec.l #1,er2\n\t"
"mov.l er2,%0\n\t"
"bpl 1f\n\t"
......@@ -171,8 +171,8 @@ static inline int down_trylock(struct semaphore * sem)
"ldc r3l,ccr\n\t"
"sub.l %1,%1\n"
"2:"
: "+m" (*count),"=r"(count)
: "g"(sem)
: "=m" (*count),"=r"(count)
: "g"(sem),"m"(*count)
: "cc", "er1","er2", "er3");
return (int)count;
}
......@@ -195,7 +195,7 @@ static inline void up(struct semaphore * sem)
__asm__ __volatile__(
"stc ccr,r3l\n\t"
"orc #0x80,ccr\n\t"
"mov.l %0,er1\n\t"
"mov.l %2,er1\n\t"
"inc.l #1,er1\n\t"
"mov.l er1,%0\n\t"
"ldc r3l,ccr\n\t"
......@@ -205,8 +205,8 @@ static inline void up(struct semaphore * sem)
"mov.l %1,er0\n\t"
"jsr @___up\n"
"1:"
: "+m"(*count)
: "g"(sem)
: "=m"(*count)
: "g"(sem),"m"(*count)
: "cc", "er1", "er2", "er3");
}
......
......@@ -6,11 +6,7 @@
#ifndef _ASM_H8300_TIMEX_H
#define _ASM_H8300_TIMEX_H
#define H8300_TIMER_DEFINE
#include <asm/machine-depend.h>
#undef H8300_TIMER_DEFINE
#define CLOCK_TICK_RATE H8300_TIMER_FREQ
#define CLOCK_TICK_RATE CONFIG_CPU_CLOCK*1000/8192 /* Timer input freq. */
#define CLOCK_TICK_FACTOR 20 /* Factor of both 1000000 and CLOCK_TICK_RATE */
#define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment