To: linus, akpm, jdike@karaya.com Cc: lkml Subject: [PATCH] UML Zorro UML: Add dummy Zorro bus support (for debugging) --- arch/um/Kconfig | 12 +++++ drivers/zorro/Kconfig | 6 ++ drivers/zorro/Makefile | 7 +- drivers/zorro/proc.c | 7 ++ drivers/zorro/zorro-test-driver.c | 81 ++++++++++++++++++++++++++++++++++ drivers/zorro/zorro.c | 89 ++++++++++++++++++++++++++++++++++++++ include/asm-um/zorro.h | 16 ++++++ 7 files changed, 214 insertions(+), 4 deletions(-) --- linux-2.6.0/arch/um/Kconfig 2003-08-09 21:42:43.000000000 +0200 +++ linux-m68k-2.6.0/arch/um/Kconfig 2003-10-26 22:09:05.000000000 +0100 @@ -18,6 +18,16 @@ config PCI bool +config ZORRO + bool "Amiga Zorro (AutoConfig) bus support" + help + This enables support for the Zorro bus in the Amiga. If you have + expansion cards in your Amiga that conform to the Amiga + AutoConfig(tm) specification, say Y, otherwise N. Note that even + expansion cards that do not fit in the Zorro slots but fit in e.g. + the CPU slot may fall in this category, so you have to say Y to let + Linux use these. + config PCMCIA bool @@ -265,6 +275,8 @@ source "init/Kconfig" source "drivers/block/Kconfig" +source "drivers/zorro/Kconfig" + source "arch/um/Kconfig.char" source "drivers/base/Kconfig" --- linux-2.6.0/drivers/zorro/Kconfig 2002-10-31 10:15:46.000000000 +0100 +++ linux-m68k-2.6.0/drivers/zorro/Kconfig 2003-10-26 22:09:06.000000000 +0100 @@ -16,3 +16,9 @@ When in doubt, say Y. +config ZORRO_TEST_DRIVER + bool "Zorro test driver" + depends on ZORRO && USERMODE + ---help--- + This is a test driver to test the Zorro driver framework. When in + doubt, say N. --- linux-2.6.0/drivers/zorro/Makefile 2003-11-06 21:53:50.000000000 +0100 +++ linux-m68k-2.6.0/drivers/zorro/Makefile 2003-11-06 21:51:43.000000000 +0100 @@ -2,10 +2,11 @@ # Makefile for the Zorro bus specific drivers. # -obj-$(CONFIG_ZORRO) += zorro.o zorro-driver.o zorro-sysfs.o names.o -obj-$(CONFIG_PROC_FS) += proc.o +obj-$(CONFIG_ZORRO) += zorro.o zorro-driver.o zorro-sysfs.o names.o +obj-$(CONFIG_PROC_FS) += proc.o +obj-$(CONFIG_ZORRO_TEST_DRIVER) += zorro-test-driver.o -hostprogs-y := gen-devlist +hostprogs-y := gen-devlist # Files generated that shall be removed upon make clean clean-files := devlist.h --- linux-2.6.0/drivers/zorro/proc.c 2003-11-06 21:53:50.000000000 +0100 +++ linux-m68k-2.6.0/drivers/zorro/proc.c 2003-11-06 21:23:51.000000000 +0100 @@ -16,8 +16,13 @@ #include #include #include -#include +#ifdef CONFIG_USERMODE +#define MACH_IS_AMIGA 1 +#define AMIGAHW_PRESENT(x) 1 +#else #include +#include +#endif static loff_t proc_bus_zorro_lseek(struct file *file, loff_t off, int whence) --- linux-2.6.0/drivers/zorro/zorro.c 2003-11-06 21:53:50.000000000 +0100 +++ linux-m68k-2.6.0/drivers/zorro/zorro.c 2003-11-06 21:23:58.000000000 +0100 @@ -16,8 +16,13 @@ #include #include +#ifdef CONFIG_USERMODE +#define MACH_IS_AMIGA 1 +#define AMIGAHW_PRESENT(x) 1 +#else #include #include +#endif #include "zorro.h" @@ -26,8 +31,90 @@ * Zorro Expansion Devices */ +#ifdef CONFIG_USERMODE +/* Virtual Zorro devices */ +u_int zorro_num_autocon = 5; +struct zorro_dev zorro_autocon[ZORRO_NUM_AUTO] = { + /* Software Results Enterprises Golden Gate 2 Bus+ [ISA Bus Bridge] */ + [0] = { + .rom = { + .er_Type = 0xc5, + .er_Product = 0x01, + .er_Manufacturer = 0x0866, + .er_SerialNumber = 0x00000002 + }, + .slotaddr = 0x0020, + .slotsize = 0x0010, + .resource = { + .start = 0x00200000, + .end = 0x002fffff + } + }, + /* Phase 5 CyberVision64-3D [Graphics Card] */ + [1] = { + .rom = { + .er_Type = 0x84, + .er_Product = 0x43, + .er_Manufacturer = 0x2140, + .er_SerialNumber = 0x00000000 + }, + .slotaddr = 0x4000, + .slotsize = 0x1000, + .resource = { + .start = 0x40000000, + .end = 0x4fffffff, + } + }, + /* Commodore West Chester A2232 [Multi I/O] */ + [2] = { + .rom = { + .er_Type = 0xc1, + .er_Product = 0x46, + .er_Manufacturer = 0x0202, + .er_SerialNumber = 0x00000000 + }, + .slotaddr = 0x00e9, + .slotsize = 0x0001, + .resource = { + .start = 0x00e90000, + .end = 0x00e9ffff + } + }, + /* Phase 5 CyberStorm Mk III [Accelerator and SCSI Host Adapter] */ + [3] = { + .rom = { + .er_Type = 0xd2, + .er_Product = 0x64, + .er_Manufacturer = 0x2140, + .er_SerialNumber = 0x0dd50025, + }, + .slotaddr = 0x00f0, + .slotsize = 0x0002, + .resource = { + .start = 0x00f0102c, + .end = 0x00f2102b, + } + }, + /* Village Tronic Ariadne [Ethernet Card and Parallel Ports] */ + [4] = { + .rom = { + .er_Type = 0xc1, + .er_Product = 0xc9, + .er_Manufacturer = 0x0877, + .er_SerialNumber = 0x0100021a, + }, + .slotaddr = 0x00ea, + .slotsize = 0x0001, + .resource = { + .start = 0x00ea0000, + .end = 0x00eaffff, + } + } +}; +#else /* !CONFIG_USERMODE */ u_int zorro_num_autocon = 0; struct zorro_dev zorro_autocon[ZORRO_NUM_AUTO]; +#endif /* !CONFIG_USERMODE */ /* @@ -176,11 +263,13 @@ mark_region(zorro_resource_start(z), zorro_resource_end(z)+1, 1); } +#ifndef CONFIG_USERMODE /* Unmark all used Zorro II memory */ for (i = 0; i < m68k_num_memory; i++) if (m68k_memory[i].addr < 16*1024*1024) mark_region(m68k_memory[i].addr, m68k_memory[i].addr+m68k_memory[i].size, 0); +#endif /* CONFIG_USERMODE */ return 0; } --- linux-2.6.0/drivers/zorro/zorro-test-driver.c 2003-09-07 12:27:17.000000000 +0200 +++ linux-m68k-2.6.0/drivers/zorro/zorro-test-driver.c 2003-10-26 22:09:06.000000000 +0100 @@ -0,0 +1,81 @@ +/* + * Zorro Test Driver + * + * (C) Copyright 2003 by Geert Uytterhoeven (geert@linux-m68k.org) + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of the Linux + * distribution for more details. + */ + +#include + + +static int __devinit zorro_test_init_one(struct zorro_dev *z, + const struct zorro_device_id *ent); +static void __devexit zorro_test_remove_one(struct zorro_dev *z); + + +static struct zorro_device_id zorro_test_zorro_tbl[] = { + { ZORRO_PROD_PHASE5_CYBERVISION64 }, + { ZORRO_PROD_PHASE5_CYBERVISION64_3D }, + { 0 } +}; + +static struct zorro_driver zorro_test_driver = { + .name = "zorro-test", + .id_table = zorro_test_zorro_tbl, + .probe = zorro_test_init_one, + .remove = __devexit_p(zorro_test_remove_one), +}; + +static int __devinit zorro_test_init_one(struct zorro_dev *z, + const struct zorro_device_id *ent) +{ + void *addr; + + printk("Initializing Zorro device 0x%08x\n", z->id); + if (!zorro_request_device(z, "zorro-test")) { + printk(KERN_ERR "zorro-test: cannot reserve MMIO region\n"); + goto err_out_none; + } + + addr = z_ioremap(zorro_resource_start(z), zorro_resource_len(z)); + if (!addr) { + printk(KERN_ERR "zorro-test: cannot remap MMIO region %lx @ %lx\n", + zorro_resource_len(z), zorro_resource_start(z)); + goto err_out_free_mmio_region; + } + + zorro_set_drvdata(z, addr); + printk("Zorro device 0x%08x initialized\n", z->id); + return 0; + +err_out_free_mmio_region: + zorro_release_device(z); +err_out_none: + return -ENODEV; +} + +static void __devexit zorro_test_remove_one(struct zorro_dev *z) +{ + void *addr = zorro_get_drvdata(z); + + printk("Removing Zorro device %p (id = 0x%08x)\n", z, z->id); + z_iounmap(addr); + zorro_release_device(z); +} + +static int __init zorro_test_init_module(void) +{ + return zorro_module_init(&zorro_test_driver); +} + +static void __exit zorro_test_cleanup_module(void) +{ + zorro_unregister_driver(&zorro_test_driver); +} + +module_init(zorro_test_init_module); +module_exit(zorro_test_cleanup_module); + --- linux-2.6.0/include/asm-um/zorro.h 2003-09-07 12:27:17.000000000 +0200 +++ linux-m68k-2.6.0/include/asm-um/zorro.h 2003-10-26 22:09:06.000000000 +0100 @@ -0,0 +1,16 @@ +#ifndef _ASM_UM_ZORRO_H +#define _ASM_UM_ZORRO_H + +#define zTwoBase (0x80000000) +#define ZTWO_VADDR(x) (((unsigned long)(x))+zTwoBase) + +static inline void *z_ioremap(unsigned long physaddr, unsigned long size) +{ + return (void *)physaddr; +} + +static inline void z_iounmap(void *addr) +{ +} + +#endif /* _ASM_UM_ZORRO_H */