From f19c666ac15c37f48578733eb953f756f4c89443 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 23 Jul 2002 06:23:29 -0700 Subject: [PATCH] [PATCH] M68k update (part 32) Mac/m68k Nubus updates - Use nubus_{read,write}[bwl]() - Fix /proc/bus/nubus - Fix type and linkage of nubus_init() - Use nubus_{read,write}[bwl]() - Kill some address assignment warnings - Include - nubus_init() is an initcall, hence static --- drivers/net/mac89x0.c | 20 ++++---- drivers/nubus/nubus.c | 17 +++--- drivers/video/macfb.c | 108 +++++++++++++++++++-------------------- include/asm-m68k/nubus.h | 46 +++++++++++++++++ include/linux/nubus.h | 5 +- 5 files changed, 123 insertions(+), 73 deletions(-) create mode 100644 include/asm-m68k/nubus.h diff --git a/drivers/net/mac89x0.c b/drivers/net/mac89x0.c index fd4e4ba33b9b..62510d3be532 100644 --- a/drivers/net/mac89x0.c +++ b/drivers/net/mac89x0.c @@ -144,28 +144,28 @@ static int set_mac_address(struct net_device *dev, void *addr); static int inline readreg_io(struct net_device *dev, int portno) { - writew(swab16(portno), dev->base_addr + ADD_PORT); - return swab16(readw(dev->base_addr + DATA_PORT)); + nubus_writew(swab16(portno), dev->base_addr + ADD_PORT); + return swab16(nubus_readw(dev->base_addr + DATA_PORT)); } static void inline writereg_io(struct net_device *dev, int portno, int value) { - writew(swab16(portno), dev->base_addr + ADD_PORT); - writew(swab16(value), dev->base_addr + DATA_PORT); + nubus_writew(swab16(portno), dev->base_addr + ADD_PORT); + nubus_writew(swab16(value), dev->base_addr + DATA_PORT); } /* These are for reading/writing registers in shared memory */ static int inline readreg(struct net_device *dev, int portno) { - return swab16(readw(dev->mem_start + portno)); + return swab16(nubus_readw(dev->mem_start + portno)); } static void inline writereg(struct net_device *dev, int portno, int value) { - writew(swab16(value), dev->mem_start + portno); + nubus_writew(swab16(value), dev->mem_start + portno); } /* Probe for the CS8900 card in slot E. We won't bother looking @@ -210,8 +210,8 @@ int __init mac89x0_probe(struct net_device *dev) return -ENODEV; } - writew(0, ioaddr + ADD_PORT); - sig = readw(ioaddr + DATA_PORT); + nubus_writew(0, ioaddr + ADD_PORT); + sig = nubus_readw(ioaddr + DATA_PORT); if (sig != swab16(CHIP_EISA_ID_SIG)) return -ENODEV; @@ -450,7 +450,7 @@ static void net_interrupt(int irq, void *dev_id, struct pt_regs * regs) course, if you're on a slow machine, and packets are arriving faster than you can read them off, you're screwed. Hasta la vista, baby! */ - while ((status = swab16(readw(dev->base_addr + ISQ_PORT)))) { + while ((status = swab16(nubus_readw(dev->base_addr + ISQ_PORT)))) { if (net_debug > 4)printk("%s: event=%04x\n", dev->name, status); switch(status & ISQ_EVENT_MASK) { case ISQ_RECEIVER_EVENT: @@ -653,7 +653,7 @@ cleanup_module(void) #endif #ifdef MODULE - writew(0, dev_cs89x0.base_addr + ADD_PORT); + nubus_writew(0, dev_cs89x0.base_addr + ADD_PORT); #endif #ifdef MODULE diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c index 766376671e95..85b4c3e09348 100644 --- a/drivers/nubus/nubus.c +++ b/drivers/nubus/nubus.c @@ -961,18 +961,18 @@ static int sprint_nubus_board(struct nubus_board* board, char* ptr, int len) return strlen(ptr); } -static int nubus_read_proc(char *buf, char **start, off_t off, +static int nubus_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data) { int nprinted, len, begin = 0; - int slot,size; + int size = PAGE_SIZE; struct nubus_board* board; - len = sprintf(buf, "Nubus devices found:\n"); + len = sprintf(page, "Nubus devices found:\n"); /* Walk the list of NuBus boards */ for (board = nubus_boards; board != NULL; board = board->next) { - nprinted = sprint_nubus_board(board, buf + len, size - len); + nprinted = sprint_nubus_board(board, page + len, size - len); if (nprinted < 0) break; len += nprinted; @@ -983,10 +983,10 @@ static int nubus_read_proc(char *buf, char **start, off_t off, if (len+begin >= off+count) break; } - if (slot==16 || len+begin < off) + if (len+begin < off) *eof = 1; off -= begin; - *start = buf + off; + *start = page + off; len -= off; if (len>count) len = count; @@ -1009,10 +1009,10 @@ void __init nubus_scan_bus(void) } } -void __init nubus_init(void) +static int __init nubus_init(void) { if (!MACH_IS_MAC) - return; + return 0; /* Initialize the NuBus interrupts */ if (oss_present) { @@ -1038,6 +1038,7 @@ void __init nubus_init(void) create_proc_read_entry("nubus", 0, NULL, nubus_read_proc, NULL); nubus_proc_init(); #endif + return 0; } subsys_initcall(nubus_init); diff --git a/drivers/video/macfb.c b/drivers/video/macfb.c index a87b21dbca26..fe45dcf01238 100644 --- a/drivers/video/macfb.c +++ b/drivers/video/macfb.c @@ -155,7 +155,7 @@ struct jet_cmap_regs { #define PIXEL_TO_MM(a) (((a)*10)/28) /* width in mm at 72 dpi */ -static char* video_base; +static unsigned long video_base; static int video_size; static char* video_vbase; /* mapped */ @@ -349,15 +349,15 @@ static int valkyrie_setpalette (unsigned int regno, unsigned int red, cli(); /* tell clut which address to fill */ - writeb(regno, &valkyrie_cmap_regs->addr); + nubus_writeb(regno, &valkyrie_cmap_regs->addr); nop(); /* send one color channel at a time */ - writeb(red, &valkyrie_cmap_regs->lut); + nubus_writeb(red, &valkyrie_cmap_regs->lut); nop(); - writeb(green, &valkyrie_cmap_regs->lut); + nubus_writeb(green, &valkyrie_cmap_regs->lut); nop(); - writeb(blue, &valkyrie_cmap_regs->lut); + nubus_writeb(blue, &valkyrie_cmap_regs->lut); restore_flags(flags); @@ -389,25 +389,25 @@ static int dafb_setpalette (unsigned int regno, unsigned int red, int i; /* Stab in the dark trying to reset the CLUT pointer */ - writel(0, &dafb_cmap_regs->reset); + nubus_writel(0, &dafb_cmap_regs->reset); nop(); /* Loop until we get to the register we want */ for (i = 0; i < regno; i++) { - writeb(palette[i].red >> 8, &dafb_cmap_regs->lut); + nubus_writeb(palette[i].red >> 8, &dafb_cmap_regs->lut); nop(); - writeb(palette[i].green >> 8, &dafb_cmap_regs->lut); + nubus_writeb(palette[i].green >> 8, &dafb_cmap_regs->lut); nop(); - writeb(palette[i].blue >> 8, &dafb_cmap_regs->lut); + nubus_writeb(palette[i].blue >> 8, &dafb_cmap_regs->lut); nop(); } } - writeb(red, &dafb_cmap_regs->lut); + nubus_writeb(red, &dafb_cmap_regs->lut); nop(); - writeb(green, &dafb_cmap_regs->lut); + nubus_writeb(green, &dafb_cmap_regs->lut); nop(); - writeb(blue, &dafb_cmap_regs->lut); + nubus_writeb(blue, &dafb_cmap_regs->lut); restore_flags(flags); @@ -439,12 +439,12 @@ static int v8_brazil_setpalette (unsigned int regno, unsigned int red, In 2bpp, the regnos are 0x3f, 0x7f, 0xbf, 0xff */ _regno = (regno<<(8-video_bpp)) | (0xFF>>video_bpp); - writeb(_regno, &v8_brazil_cmap_regs->addr); nop(); + nubus_writeb(_regno, &v8_brazil_cmap_regs->addr); nop(); /* send one color channel at a time */ - writeb(_red, &v8_brazil_cmap_regs->lut); nop(); - writeb(_green, &v8_brazil_cmap_regs->lut); nop(); - writeb(_blue, &v8_brazil_cmap_regs->lut); + nubus_writeb(_red, &v8_brazil_cmap_regs->lut); nop(); + nubus_writeb(_green, &v8_brazil_cmap_regs->lut); nop(); + nubus_writeb(_blue, &v8_brazil_cmap_regs->lut); restore_flags(flags); @@ -473,15 +473,15 @@ static int rbv_setpalette (unsigned int regno, unsigned int red, _regno = regno + (256-(1<cntl); nop(); + nubus_writeb(0xFF, &rbv_cmap_regs->cntl); nop(); /* tell clut which address to use. */ - writeb(_regno, &rbv_cmap_regs->addr); nop(); + nubus_writeb(_regno, &rbv_cmap_regs->addr); nop(); /* send one color channel at a time. */ - writeb(_red, &rbv_cmap_regs->lut); nop(); - writeb(_green, &rbv_cmap_regs->lut); nop(); - writeb(_blue, &rbv_cmap_regs->lut); + nubus_writeb(_red, &rbv_cmap_regs->lut); nop(); + nubus_writeb(_green, &rbv_cmap_regs->lut); nop(); + nubus_writeb(_blue, &rbv_cmap_regs->lut); restore_flags(flags); /* done. */ @@ -505,10 +505,10 @@ static int mdc_setpalette(unsigned int regno, unsigned int red, cli(); /* the nop's are there to order writes. */ - writeb(_regno, &cmap_regs->addr); nop(); - writeb(_red, &cmap_regs->lut); nop(); - writeb(_green, &cmap_regs->lut); nop(); - writeb(_blue, &cmap_regs->lut); + nubus_writeb(_regno, &cmap_regs->addr); nop(); + nubus_writeb(_red, &cmap_regs->lut); nop(); + nubus_writeb(_green, &cmap_regs->lut); nop(); + nubus_writeb(_blue, &cmap_regs->lut); restore_flags(flags); return 0; @@ -530,10 +530,10 @@ static int toby_setpalette(unsigned int regno, unsigned int red, save_flags(flags); cli(); - writeb(_regno, &cmap_regs->addr); nop(); - writeb(_red, &cmap_regs->lut); nop(); - writeb(_green, &cmap_regs->lut); nop(); - writeb(_blue, &cmap_regs->lut); + nubus_writeb(_regno, &cmap_regs->addr); nop(); + nubus_writeb(_red, &cmap_regs->lut); nop(); + nubus_writeb(_green, &cmap_regs->lut); nop(); + nubus_writeb(_blue, &cmap_regs->lut); restore_flags(flags); return 0; @@ -554,10 +554,10 @@ static int jet_setpalette(unsigned int regno, unsigned int red, save_flags(flags); cli(); - writeb(regno, &cmap_regs->addr); nop(); - writeb(_red, &cmap_regs->lut); nop(); - writeb(_green, &cmap_regs->lut); nop(); - writeb(_blue, &cmap_regs->lut); + nubus_writeb(regno, &cmap_regs->addr); nop(); + nubus_writeb(_red, &cmap_regs->lut); nop(); + nubus_writeb(_green, &cmap_regs->lut); nop(); + nubus_writeb(_blue, &cmap_regs->lut); restore_flags(flags); return 0; @@ -593,7 +593,7 @@ static int civic_setpalette (unsigned int regno, unsigned int red, /* * Set the register address */ - writeb(regno, &civic_cmap_regs->addr); nop(); + nubus_writeb(regno, &civic_cmap_regs->addr); nop(); /* * Wait for VBL interrupt here; @@ -602,7 +602,7 @@ static int civic_setpalette (unsigned int regno, unsigned int red, #if 0 { #define CIVIC_VBL_OFFSET 0x120 - volatile unsigned long *vbl = readl(civic_cmap_regs->vbl_addr + CIVIC_VBL_OFFSET); + volatile unsigned long *vbl = nubus_readl(civic_cmap_regs->vbl_addr + CIVIC_VBL_OFFSET); /* do interrupt setup stuff here? */ *vbl = 0L; nop(); /* clear */ *vbl = 1L; nop(); /* set */ @@ -618,42 +618,42 @@ static int civic_setpalette (unsigned int regno, unsigned int red, * Grab a status word and do some checking; * Then finally write the clut! */ - clut_status = readb(&civic_cmap_regs->status2); + clut_status = nubus_readb(&civic_cmap_regs->status2); if ((clut_status & 0x0008) == 0) { #if 0 if ((clut_status & 0x000D) != 0) { - writeb(0x00, &civic_cmap_regs->lut); nop(); - writeb(0x00, &civic_cmap_regs->lut); nop(); + nubus_writeb(0x00, &civic_cmap_regs->lut); nop(); + nubus_writeb(0x00, &civic_cmap_regs->lut); nop(); } #endif - writeb( red, &civic_cmap_regs->lut); nop(); - writeb(green, &civic_cmap_regs->lut); nop(); - writeb( blue, &civic_cmap_regs->lut); nop(); - writeb( 0x00, &civic_cmap_regs->lut); nop(); + nubus_writeb( red, &civic_cmap_regs->lut); nop(); + nubus_writeb(green, &civic_cmap_regs->lut); nop(); + nubus_writeb( blue, &civic_cmap_regs->lut); nop(); + nubus_writeb( 0x00, &civic_cmap_regs->lut); nop(); } else { unsigned char junk; - junk = readb(&civic_cmap_regs->lut); nop(); - junk = readb(&civic_cmap_regs->lut); nop(); - junk = readb(&civic_cmap_regs->lut); nop(); - junk = readb(&civic_cmap_regs->lut); nop(); + junk = nubus_readb(&civic_cmap_regs->lut); nop(); + junk = nubus_readb(&civic_cmap_regs->lut); nop(); + junk = nubus_readb(&civic_cmap_regs->lut); nop(); + junk = nubus_readb(&civic_cmap_regs->lut); nop(); if ((clut_status & 0x000D) != 0) { - writeb(0x00, &civic_cmap_regs->lut); nop(); - writeb(0x00, &civic_cmap_regs->lut); nop(); + nubus_writeb(0x00, &civic_cmap_regs->lut); nop(); + nubus_writeb(0x00, &civic_cmap_regs->lut); nop(); } - writeb( red, &civic_cmap_regs->lut); nop(); - writeb(green, &civic_cmap_regs->lut); nop(); - writeb( blue, &civic_cmap_regs->lut); nop(); - writeb( junk, &civic_cmap_regs->lut); nop(); + nubus_writeb( red, &civic_cmap_regs->lut); nop(); + nubus_writeb(green, &civic_cmap_regs->lut); nop(); + nubus_writeb( blue, &civic_cmap_regs->lut); nop(); + nubus_writeb( junk, &civic_cmap_regs->lut); nop(); } restore_flags(flags); @@ -862,7 +862,7 @@ void __init macfb_init(void) video_linelength = mac_bi_data.videorow; video_size = video_linelength * video_height; /* Note: physical address (since 2.1.127) */ - video_base = (void*) mac_bi_data.videoaddr; + video_base = mac_bi_data.videoaddr; /* This is actually redundant with the initial mappings. However, there are some non-obvious aspects to the way those mappings are set up, so this is in fact the safest @@ -870,7 +870,7 @@ void __init macfb_init(void) Mac */ video_vbase = ioremap(mac_bi_data.videoaddr, video_size); - printk("macfb: framebuffer at 0x%p, mapped to 0x%p, size %dk\n", + printk("macfb: framebuffer at 0x%08lx, mapped to 0x%p, size %dk\n", video_base, video_vbase, video_size/1024); printk("macfb: mode is %dx%dx%d, linelength=%d\n", video_width, video_height, video_bpp, video_linelength); diff --git a/include/asm-m68k/nubus.h b/include/asm-m68k/nubus.h new file mode 100644 index 000000000000..b810d4c3bbe1 --- /dev/null +++ b/include/asm-m68k/nubus.h @@ -0,0 +1,46 @@ +#ifndef _ASM_M68K_NUBUS_H +#define _ASM_M68K_NUBUS_H + +#include + +#define nubus_readb raw_inb +#define nubus_readw raw_inw +#define nubus_readl raw_inl + +#define nubus_writeb raw_outb +#define nubus_writew raw_outw +#define nubus_writel raw_outl + +#define nubus_memset_io(a,b,c) memset((void *)(a),(b),(c)) +#define nubus_memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c)) +#define nubus_memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c)) + +extern inline void *nubus_remap_nocache_ser(unsigned long physaddr, + unsigned long size) +{ + return __ioremap(physaddr, size, IOMAP_NOCACHE_SER); +} + +extern inline void *nubus_remap_nocache_nonser(unsigned long physaddr, + unsigned long size) +{ + return __ioremap(physaddr, size, IOMAP_NOCACHE_NONSER); +} + +extern inline void *nbus_remap_writethrough(unsigned long physaddr, + unsigned long size) +{ + return __ioremap(physaddr, size, IOMAP_WRITETHROUGH); +} + +extern inline void *nubus_remap_fullcache(unsigned long physaddr, + unsigned long size) +{ + return __ioremap(physaddr, size, IOMAP_FULL_CACHING); +} + +#define nubus_unmap iounmap +#define nubus_iounmap iounmap +#define nubus_ioremap nubus_remap_nocache_ser + +#endif /* _ASM_NUBUS_H */ diff --git a/include/linux/nubus.h b/include/linux/nubus.h index 0e0ef4f73d6d..a3fd37b33fdd 100644 --- a/include/linux/nubus.h +++ b/include/linux/nubus.h @@ -12,6 +12,10 @@ #ifndef LINUX_NUBUS_H #define LINUX_NUBUS_H +#ifdef __KERNEL__ +#include +#endif + enum nubus_category { NUBUS_CAT_BOARD = 0x0001, NUBUS_CAT_DISPLAY = 0x0003, @@ -262,7 +266,6 @@ extern struct nubus_dev* nubus_devices; extern struct nubus_board* nubus_boards; /* Generic NuBus interface functions, modelled after the PCI interface */ -extern void nubus_init(void); void nubus_scan_bus(void); extern void nubus_proc_init(void); int get_nubus_list(char *buf); -- 2.39.5