#if defined(CONFIG_H83007) || defined(CONFIG_H83068)
#include <asm/regs306x.h>
+#define CMFA 6
int platform_timer_setup(void (*timer_int)(int, void *, struct pt_regs *))
{
- outb(H8300_TIMER_COUNT_DATA,TMR8CMA2);
- outb(0x00,TMR8TCSR2);
- request_irq_boot(40,timer_int,0,"timer",0);
- outb(0x40|0x08|0x03,TMR8TCNT2);
+ 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;
}
{
*(unsigned short *)GRA= H8300_TIMER_COUNT_DATA;
*(unsigned short *)TCNT=0;
- outb(0x23,TCR);
- outb(0x00,TIOR);
+ ctrl_outb(0x23,TCR);
+ ctrl_outb(0x00,TIOR);
request_timer_irq(26,timer_int,0,"timer",0);
- outb(inb(TIER) | 0x01,TIER);
- outb(inb(TSNC) & ~0x01,TSNC);
- outb(inb(TMDR) & ~0x01,TMDR);
- outb(inb(TSTR) | 0x01,TSTR);
+ ctrl_outb(inb(TIER) | 0x01,TIER);
+ ctrl_outb(inb(TSNC) & ~0x01,TSNC);
+ ctrl_outb(inb(TMDR) & ~0x01,TMDR);
+ ctrl_outb(inb(TSTR) | 0x01,TSTR);
return 0;
}
void platform_timer_eoi(void)
{
- outb(inb(TSR) & ~0x01,TSR);
+ ctrl_outb(inb(TSR) & ~0x01,TSR);
}
#endif
#include <linux/config.h>
#include <asm/virtconvert.h>
+#if defined(CONFIG_H83007) || defined(CONFIG_H83068)
+#include <asm/regs306x.h>
+#elif defined(CONFIG_H8S2678)
+#include <asm/regs2678.h>
+#else
+#error UNKNOWN CPU TYPE
+#endif
+
+
/*
* These are for ISA/PCI shared memory _only_ and should never be used
* on any other type of memory, including Zorro memory. They are meant to
* 020325 Added some #define's for the COBRA5272 board
* (hede)
*/
+
static inline unsigned short _swapw(volatile unsigned short v)
{
return ((v << 8) | (v >> 8));
}
#define readb(addr) \
- ({ unsigned char __v = (*(volatile unsigned char *) (addr & 0x00ffffff)); __v; })
+ ({ unsigned char __v = (*(volatile unsigned char *) ((addr) & 0x00ffffff)); __v; })
#define readw(addr) \
- ({ unsigned short __v = (*(volatile unsigned short *) (addr & 0x00ffffff)); __v; })
+ ({ unsigned short __v = (*(volatile unsigned short *) ((addr) & 0x00ffffff)); __v; })
#define readl(addr) \
- ({ unsigned int __v = (*(volatile unsigned int *) (addr & 0x00ffffff)); __v; })
+ ({ unsigned int __v = (*(volatile unsigned int *) ((addr) & 0x00ffffff)); __v; })
+#define writeb(b,addr) (void)((*(volatile unsigned char *) ((addr) & 0x00ffffff)) = (b))
+#define writew(b,addr) (void)((*(volatile unsigned short *) ((addr) & 0x00ffffff)) = (b))
+#define writel(b,addr) (void)((*(volatile unsigned int *) ((addr) & 0x00ffffff)) = (b))
#define readb_relaxed(addr) readb(addr)
#define readw_relaxed(addr) readw(addr)
#define readl_relaxed(addr) readl(addr)
-#define writeb(b,addr) (void)((*(volatile unsigned char *) (addr & 0x00ffffff)) = (b))
-#define writew(b,addr) (void)((*(volatile unsigned short *) (addr & 0x00ffffff)) = (b))
-#define writel(b,addr) (void)((*(volatile unsigned int *) (addr & 0x00ffffff)) = (b))
-
#define __raw_readb readb
#define __raw_readw readw
#define __raw_readl readl
#define __raw_writew writew
#define __raw_writel writel
+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)
{
- volatile unsigned char *ap = (volatile unsigned char *) addr;
+ volatile unsigned char *ap_b = (volatile unsigned char *) addr;
+ volatile unsigned short *ap_w = (volatile unsigned short *) addr;
unsigned char *bp = (unsigned char *) buf;
- while (len--)
- *ap = *bp++;
+
+ if(h8300_buswidth(addr) && (addr & 1)) {
+ while (len--)
+ *ap_w = *bp++;
+ } else {
+ while (len--)
+ *ap_b = *bp++;
+ }
}
static inline void io_outsw(unsigned int addr, void *buf, int len)
volatile unsigned short *ap = (volatile unsigned short *) addr;
unsigned short *bp = (unsigned short *) buf;
while (len--)
- *ap = _swapw(*bp++);
+ *ap = *bp++;
}
static inline void io_outsl(unsigned int addr, void *buf, int len)
volatile unsigned int *ap = (volatile unsigned int *) addr;
unsigned int *bp = (unsigned int *) buf;
while (len--)
- *ap = _swapl(*bp++);
+ *ap = *bp++;
}
static inline void io_insb(unsigned int addr, void *buf, int len)
{
- volatile unsigned char *ap = (volatile unsigned char *) addr;
+ volatile unsigned char *ap;
unsigned char *bp = (unsigned char *) buf;
+
+ if(h8300_buswidth(addr))
+ ap = (volatile unsigned char *)(addr ^ 1);
+ else
+ ap = (volatile unsigned char *)addr;
while (len--)
*bp++ = *ap;
}
volatile unsigned short *ap = (volatile unsigned short *) addr;
unsigned short *bp = (unsigned short *) buf;
while (len--)
- *bp++ = _swapw(*ap);
+ *bp++ = *ap;
}
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;
while (len--)
- *bp++ = _swapl(*ap);
+ *bp++ = *ap;
}
/*
#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) readb(addr)
-#define inw(addr) readw(addr)
-#define inl(addr) readl(addr)
-#define outb(x,addr) ((void) writeb(x,addr))
-#define outw(x,addr) ((void) writew(x,addr))
-#define outl(x,addr) ((void) writel(x,addr))
+#define inb(addr) ((h8300_buswidth(addr))?readb(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 outw(x,addr) ((void) writew(_swapw(x),addr))
+#define outl(x,addr) ((void) writel(_swapl(x),addr))
#define inb_p(addr) inb(addr)
#define inw_p(addr) inw(addr)
extern void *__ioremap(unsigned long physaddr, unsigned long size, int cacheflag);
extern void __iounmap(void *addr, unsigned long size);
-extern inline void *ioremap(unsigned long physaddr, unsigned long size)
+static inline void *ioremap(unsigned long physaddr, unsigned long size)
{
return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
}
-extern inline void *ioremap_nocache(unsigned long physaddr, unsigned long size)
+static inline void *ioremap_nocache(unsigned long physaddr, unsigned long size)
{
return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
}
-extern inline void *ioremap_writethrough(unsigned long physaddr, unsigned long size)
+static inline void *ioremap_writethrough(unsigned long physaddr, unsigned long size)
{
return __ioremap(physaddr, size, IOMAP_WRITETHROUGH);
}
-extern inline void *ioremap_fullcache(unsigned long physaddr, unsigned long size)
+static inline void *ioremap_fullcache(unsigned long physaddr, unsigned long size)
{
return __ioremap(physaddr, size, IOMAP_FULL_CACHING);
}