Module Name: src Committed By: skrll Date: Sat Jan 20 13:56:09 UTC 2018
Modified Files: src/sys/arch/cobalt/cobalt: bus.c interrupt.c machdep.c mainbus.c src/sys/arch/cobalt/conf: GENERIC files.cobalt src/sys/arch/cobalt/dev: com_mainbus.c gt.c src/sys/arch/cobalt/include: bus_defs.h bus_funcs.h Added Files: src/sys/arch/cobalt/dev: gt_io_space.c gt_mem_space.c gtvar.h Log Message: Switch cobalt to common bus_space. Tested on raq 2 To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/arch/cobalt/cobalt/bus.c cvs rdiff -u -r1.7 -r1.8 src/sys/arch/cobalt/cobalt/interrupt.c cvs rdiff -u -r1.120 -r1.121 src/sys/arch/cobalt/cobalt/machdep.c cvs rdiff -u -r1.19 -r1.20 src/sys/arch/cobalt/cobalt/mainbus.c cvs rdiff -u -r1.154 -r1.155 src/sys/arch/cobalt/conf/GENERIC cvs rdiff -u -r1.38 -r1.39 src/sys/arch/cobalt/conf/files.cobalt cvs rdiff -u -r1.20 -r1.21 src/sys/arch/cobalt/dev/com_mainbus.c cvs rdiff -u -r1.28 -r1.29 src/sys/arch/cobalt/dev/gt.c cvs rdiff -u -r0 -r1.1 src/sys/arch/cobalt/dev/gt_io_space.c \ src/sys/arch/cobalt/dev/gt_mem_space.c src/sys/arch/cobalt/dev/gtvar.h cvs rdiff -u -r1.2 -r1.3 src/sys/arch/cobalt/include/bus_defs.h \ src/sys/arch/cobalt/include/bus_funcs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/cobalt/cobalt/bus.c diff -u src/sys/arch/cobalt/cobalt/bus.c:1.45 src/sys/arch/cobalt/cobalt/bus.c:1.46 --- src/sys/arch/cobalt/cobalt/bus.c:1.45 Tue Jul 29 21:21:43 2014 +++ src/sys/arch/cobalt/cobalt/bus.c Sat Jan 20 13:56:08 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: bus.c,v 1.45 2014/07/29 21:21:43 skrll Exp $ */ +/* $NetBSD: bus.c,v 1.46 2018/01/20 13:56:08 skrll Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -30,370 +30,37 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.45 2014/07/29 21:21:43 skrll Exp $"); - -#include <sys/param.h> -#include <sys/bus.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/device.h> -#include <sys/malloc.h> -#include <sys/proc.h> -#include <sys/mbuf.h> - -#include <dev/bus_dma/bus_dmamem_common.h> - -#include <uvm/uvm_extern.h> - -#include <mips/cache.h> - -/* - * Utility macros; do not use outside this file. - */ -#define __PB_TYPENAME_PREFIX(BITS) ___CONCAT(uint,BITS) -#define __PB_TYPENAME(BITS) ___CONCAT(__PB_TYPENAME_PREFIX(BITS),_t) - -/* - * void bus_space_read_multi_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, - * uintN_t *addr, bus_size_t count); - * - * Read `count' 1, 2, 4, or 8 byte quantities from bus space - * described by tag/handle/offset and copy into buffer provided. - */ - -#define __COBALT_bus_space_read_multi(BYTES,BITS) \ -void __CONCAT(bus_space_read_multi_,BYTES) \ - (bus_space_tag_t, bus_space_handle_t, bus_size_t, \ - __PB_TYPENAME(BITS) *, bus_size_t); \ - \ -void \ -__CONCAT(bus_space_read_multi_,BYTES)( \ - bus_space_tag_t t, \ - bus_space_handle_t h, \ - bus_size_t o, \ - __PB_TYPENAME(BITS) *a, \ - bus_size_t c) \ -{ \ - \ - while (c--) \ - *a++ = __CONCAT(bus_space_read_,BYTES)(t, h, o); \ -} - -__COBALT_bus_space_read_multi(1,8) -__COBALT_bus_space_read_multi(2,16) -__COBALT_bus_space_read_multi(4,32) - -#if 0 /* Cause a link error for bus_space_read_multi_8 */ -#define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!! -#endif - -#undef __COBALT_bus_space_read_multi - /* - * void bus_space_read_region_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, - * uintN_t *addr, bus_size_t count); - * - * Read `count' 1, 2, 4, or 8 byte quantities from bus space - * described by tag/handle and starting at `offset' and copy into - * buffer provided. - */ - -#define __COBALT_bus_space_read_region(BYTES,BITS) \ -void __CONCAT(bus_space_read_region_,BYTES) \ - (bus_space_tag_t, bus_space_handle_t, bus_size_t, \ - __PB_TYPENAME(BITS) *, bus_size_t); \ - \ -void \ -__CONCAT(bus_space_read_region_,BYTES)( \ - bus_space_tag_t t, \ - bus_space_handle_t h, \ - bus_size_t o, \ - __PB_TYPENAME(BITS) *a, \ - bus_size_t c) \ -{ \ - \ - while (c--) { \ - *a++ = __CONCAT(bus_space_read_,BYTES)(t, h, o); \ - o += BYTES; \ - } \ -} - -__COBALT_bus_space_read_region(1,8) -__COBALT_bus_space_read_region(2,16) -__COBALT_bus_space_read_region(4,32) - -#if 0 /* Cause a link error for bus_space_read_region_8 */ -#define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!! -#endif - -#undef __COBALT_bus_space_read_region - -/* - * void bus_space_write_multi_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, - * const uintN_t *addr, bus_size_t count); - * - * Write `count' 1, 2, 4, or 8 byte quantities from the buffer - * provided to bus space described by tag/handle/offset. + * Platform-specific I/O support for the cobalt machines */ -#define __COBALT_bus_space_write_multi(BYTES,BITS) \ -void __CONCAT(bus_space_write_multi_,BYTES) \ - (bus_space_tag_t, bus_space_handle_t, bus_size_t, \ - const __PB_TYPENAME(BITS) *, bus_size_t); \ - \ -void \ -__CONCAT(bus_space_write_multi_,BYTES)( \ - bus_space_tag_t t, \ - bus_space_handle_t h, \ - bus_size_t o, \ - const __PB_TYPENAME(BITS) *a, \ - bus_size_t c) \ -{ \ - \ - while (c--) \ - __CONCAT(bus_space_write_,BYTES)(t, h, o, *a++); \ -} - -__COBALT_bus_space_write_multi(1,8) -__COBALT_bus_space_write_multi(2,16) -__COBALT_bus_space_write_multi(4,32) - -#if 0 /* Cause a link error for bus_space_write_8 */ -#define bus_space_write_multi_8(t, h, o, a, c) \ - !!! bus_space_write_multi_8 unimplimented !!! -#endif - -#undef __COBALT_bus_space_write_multi - -/* - * void bus_space_write_region_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, - * const uintN_t *addr, bus_size_t count); - * - * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided - * to bus space described by tag/handle starting at `offset'. - */ - -#define __COBALT_bus_space_write_region(BYTES,BITS) \ -void __CONCAT(bus_space_write_region_,BYTES) \ - (bus_space_tag_t, bus_space_handle_t, bus_size_t, \ - const __PB_TYPENAME(BITS) *, bus_size_t); \ - \ -void \ -__CONCAT(bus_space_write_region_,BYTES)( \ - bus_space_tag_t t, \ - bus_space_handle_t h, \ - bus_size_t o, \ - const __PB_TYPENAME(BITS) *a, \ - bus_size_t c) \ -{ \ - \ - while (c--) { \ - __CONCAT(bus_space_write_,BYTES)(t, h, o, *a++); \ - o += BYTES; \ - } \ -} - -__COBALT_bus_space_write_region(1,8) -__COBALT_bus_space_write_region(2,16) -__COBALT_bus_space_write_region(4,32) - -#if 0 /* Cause a link error for bus_space_write_region_8 */ -#define bus_space_write_region_8 \ - !!! bus_space_write_region_8 unimplemented !!! -#endif - -#undef __COBALT_bus_space_write_region - -/* - * void bus_space_set_multi_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, uintN_t val, - * bus_size_t count); - * - * Write the 1, 2, 4, or 8 byte value `val' to bus space described - * by tag/handle/offset `count' times. - */ - -#define __COBALT_bus_space_set_multi(BYTES,BITS) \ -void __CONCAT(bus_space_set_multi_,BYTES) \ - (bus_space_tag_t, bus_space_handle_t, bus_size_t, \ - __PB_TYPENAME(BITS), bus_size_t); \ - \ -void \ -__CONCAT(bus_space_set_multi_,BYTES)( \ - bus_space_tag_t t, \ - bus_space_handle_t h, \ - bus_size_t o, \ - __PB_TYPENAME(BITS) v, \ - bus_size_t c) \ -{ \ - \ - while (c--) \ - __CONCAT(bus_space_write_,BYTES)(t, h, o, v); \ -} - -__COBALT_bus_space_set_multi(1,8) -__COBALT_bus_space_set_multi(2,16) -__COBALT_bus_space_set_multi(4,32) - -#if 0 /* Cause a link error for bus_space_set_multi_8 */ -#define bus_space_set_multi_8 \ - !!! bus_space_set_multi_8 unimplemented !!! -#endif - -#undef __COBALT_bus_space_set_multi - -/* - * void bus_space_set_region_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, uintN_t val, - * bus_size_t count); - * - * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described - * by tag/handle starting at `offset'. - */ - -#define __COBALT_bus_space_set_region(BYTES,BITS) \ -void __CONCAT(bus_space_set_region_,BYTES) \ - (bus_space_tag_t, bus_space_handle_t, bus_size_t, \ - __PB_TYPENAME(BITS), bus_size_t); \ - \ -void \ -__CONCAT(bus_space_set_region_,BYTES)( \ - bus_space_tag_t t, \ - bus_space_handle_t h, \ - bus_size_t o, \ - __PB_TYPENAME(BITS) v, \ - bus_size_t c) \ -{ \ - \ - while (c--) { \ - __CONCAT(bus_space_write_,BYTES)(t, h, o, v); \ - o += BYTES; \ - } \ -} - -__COBALT_bus_space_set_region(1,8) -__COBALT_bus_space_set_region(2,16) -__COBALT_bus_space_set_region(4,32) - -#if 0 /* Cause a link error for bus_space_set_region_8 */ -#define bus_space_set_region_8 \ - !!! bus_space_set_region_8 unimplemented !!! -#endif - -#undef __COBALT_bus_space_set_region - -/* - * void bus_space_copy_region_N(bus_space_tag_t tag, - * bus_space_handle_t bsh1, bus_size_t off1, - * bus_space_handle_t bsh2, bus_size_t off2, - * bus_size_t count); - * - * Copy `count' 1, 2, 4, or 8 byte values from bus space starting - * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2. - */ +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.46 2018/01/20 13:56:08 skrll Exp $"); -#define __COBALT_copy_region(BYTES) \ -void __CONCAT(bus_space_copy_region_,BYTES) \ - (bus_space_tag_t, \ - bus_space_handle_t bsh1, bus_size_t off1, \ - bus_space_handle_t bsh2, bus_size_t off2, \ - bus_size_t count); \ - \ -void \ -__CONCAT(bus_space_copy_region_,BYTES)( \ - bus_space_tag_t t, \ - bus_space_handle_t h1, \ - bus_size_t o1, \ - bus_space_handle_t h2, \ - bus_size_t o2, \ - bus_size_t c) \ -{ \ - bus_size_t o; \ - \ - if ((h1 + o1) >= (h2 + o2)) { \ - /* src after dest: copy forward */ \ - for (o = 0; c != 0; c--, o += BYTES) \ - __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \ - __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \ - } else { \ - /* dest after src: copy backwards */ \ - for (o = (c - 1) * BYTES; c != 0; c--, o -= BYTES) \ - __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \ - __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \ - } \ -} +#include <sys/types.h> +#include <sys/param.h> +#include <sys/bus.h> -__COBALT_copy_region(1) -__COBALT_copy_region(2) -__COBALT_copy_region(4) +#define CHIP mainbus +#define CHIP_MEM /* defined */ -#if 0 /* Cause a link error for bus_space_copy_region_8 */ -#define bus_space_copy_region_8 \ - !!! bus_space_copy_region_8 unimplemented !!! +#if 0 +#define CHIP_EX_MALLOC_SAFE(v) (((struct p4032_config *)(v))->ac_mallocsafe) +#define CHIP_EXTENT(v) (((struct p4032_config *)(v))->ac_io_ex) #endif -#undef __COBALT_copy_region - -int -bus_space_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags, - bus_space_handle_t *bshp) -{ - int cacheable = flags & BUS_SPACE_MAP_CACHEABLE; - - if (cacheable) - *bshp = MIPS_PHYS_TO_KSEG0(bpa); - else - *bshp = MIPS_PHYS_TO_KSEG1(bpa); - - /* XXX Evil! */ - if (bpa < 0x10000000) - *bshp += 0x10000000; - - return 0; -} - -int -bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart, bus_addr_t rend, - bus_size_t size, bus_size_t alignment, bus_size_t boundary, int flags, - bus_addr_t *bpap, bus_space_handle_t *bshp) -{ - - panic("bus_space_alloc: not implemented"); -} - -void -bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size) -{ - - panic("bus_space_free: not implemented"); -} - -void -bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size) -{ - - return; -} - -int -bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh, - bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp) -{ +/* IO region 1 */ +#define CHIP_W1_BUS_START(v) 0x10000000UL +#define CHIP_W1_BUS_END(v) 0x10000fffUL +#define CHIP_W1_SYS_START(v) 0x10000000UL +#define CHIP_W1_SYS_END(v) 0x10000fffUL - *nbshp = bsh + offset; - return 0; -} +/* IO region 1 */ +#define CHIP_W2_BUS_START(v) 0x14000000UL +#define CHIP_W2_BUS_END(v) 0x1fffffffUL +#define CHIP_W2_SYS_START(v) 0x14000000UL +#define CHIP_W2_SYS_END(v) 0x1fffffffUL -paddr_t -bus_space_mmap(bus_space_tag_t t, bus_addr_t addr, off_t off, int prot, - int flags) -{ +void mainbus_bus_mem_init(bus_space_tag_t, void *); - /* XXX not implemented */ - return -1; -} +#include <mips/mips/bus_space_alignstride_chipdep.c> Index: src/sys/arch/cobalt/cobalt/interrupt.c diff -u src/sys/arch/cobalt/cobalt/interrupt.c:1.7 src/sys/arch/cobalt/cobalt/interrupt.c:1.8 --- src/sys/arch/cobalt/cobalt/interrupt.c:1.7 Fri Jul 1 20:36:42 2011 +++ src/sys/arch/cobalt/cobalt/interrupt.c Sat Jan 20 13:56:08 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: interrupt.c,v 1.7 2011/07/01 20:36:42 dyoung Exp $ */ +/* $NetBSD: interrupt.c,v 1.8 2018/01/20 13:56:08 skrll Exp $ */ /*- * Copyright (c) 2006 Izumi Tsutsui. All rights reserved. @@ -79,7 +79,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.7 2011/07/01 20:36:42 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.8 2018/01/20 13:56:08 skrll Exp $"); #define __INTR_PRIVATE @@ -169,10 +169,12 @@ intr_init(void) EVCNT_TYPE_INTR, NULL, "mips", cpu_intrtab[i].intr_evname); } + extern struct mips_bus_space cobalt_bs; + /* * Initialize ICU interrupts. */ - icu_bst = 0; /* XXX unused on cobalt */ + icu_bst = &cobalt_bs;; bus_space_map(icu_bst, PCIB_BASE + IO_ICU1, IO_ICUSIZE, 0, &icu1_bsh); bus_space_map(icu_bst, PCIB_BASE + IO_ICU2, IO_ICUSIZE, 0, &icu2_bsh); bus_space_map(icu_bst, PCIB_BASE + IO_ELCR, IO_ELCRSIZE, 0, &elcr_bsh); Index: src/sys/arch/cobalt/cobalt/machdep.c diff -u src/sys/arch/cobalt/cobalt/machdep.c:1.120 src/sys/arch/cobalt/cobalt/machdep.c:1.121 --- src/sys/arch/cobalt/cobalt/machdep.c:1.120 Mon Nov 6 03:47:46 2017 +++ src/sys/arch/cobalt/cobalt/machdep.c Sat Jan 20 13:56:08 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.120 2017/11/06 03:47:46 christos Exp $ */ +/* $NetBSD: machdep.c,v 1.121 2018/01/20 13:56:08 skrll Exp $ */ /*- * Copyright (c) 2006 Izumi Tsutsui. All rights reserved. @@ -50,7 +50,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.120 2017/11/06 03:47:46 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.121 2018/01/20 13:56:08 skrll Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -59,15 +59,16 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v #include <sys/param.h> #include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/proc.h> -#include <sys/reboot.h> -#include <sys/mount.h> -#include <sys/kcore.h> #include <sys/boot_flag.h> -#include <sys/ksyms.h> +#include <sys/bus.h> #include <sys/cpu.h> #include <sys/device.h> +#include <sys/kernel.h> +#include <sys/kcore.h> +#include <sys/ksyms.h> +#include <sys/mount.h> +#include <sys/proc.h> +#include <sys/reboot.h> #include <uvm/uvm_extern.h> @@ -105,6 +106,16 @@ char *root_bstr = NULL; int bootunit = -1; int bootpart = -1; +#if 0 +struct extent *cobalt_io_ex = NULL; +struct extent *cobalt_mem_ex = NULL; +struct mips_bus_space bonito_iot; +struct mips_bus_space bonito_memt; +struct mips_bus_dma_tag bonito_dmat; +struct mips_pci_chipset bonito_pc; +#endif + + int cpuspeed; u_int cobalt_id; @@ -127,6 +138,10 @@ static u_int read_board_id(void); extern char *esym; +struct mips_bus_space cobalt_bs; +void mainbus_bus_mem_init(bus_space_tag_t, void *); + + /* * Do all the stuff that locore normally does before calling main(). */ @@ -181,6 +196,8 @@ mach_init(int32_t memsize32, u_int bim, */ mips_vector_init(NULL, false); + mainbus_bus_mem_init(&cobalt_bs, NULL); + /* Check for valid bootinfo passed from bootstrap */ if (bim == BOOTINFO_MAGIC) { struct btinfo_magic *bi_magic; Index: src/sys/arch/cobalt/cobalt/mainbus.c diff -u src/sys/arch/cobalt/cobalt/mainbus.c:1.19 src/sys/arch/cobalt/cobalt/mainbus.c:1.20 --- src/sys/arch/cobalt/cobalt/mainbus.c:1.19 Tue Jul 29 21:21:43 2014 +++ src/sys/arch/cobalt/cobalt/mainbus.c Sat Jan 20 13:56:08 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: mainbus.c,v 1.19 2014/07/29 21:21:43 skrll Exp $ */ +/* $NetBSD: mainbus.c,v 1.20 2018/01/20 13:56:08 skrll Exp $ */ /* * Copyright (c) 2000 Soren S. Jorvang. All rights reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.19 2014/07/29 21:21:43 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.20 2018/01/20 13:56:08 skrll Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -47,6 +47,8 @@ int mainbus_print(void *, const char *) CFATTACH_DECL_NEW(mainbus, 0, mainbus_match, mainbus_attach, NULL, NULL); +extern struct mips_bus_space cobalt_bs; + static int mainbus_match(device_t parent, cfdata_t cf, void *aux) { @@ -71,7 +73,7 @@ mainbus_search(device_t parent, cfdata_t do { ma->ma_addr = cf->cf_loc[MAINBUSCF_ADDR]; - ma->ma_iot = 0; + ma->ma_iot = &cobalt_bs; ma->ma_level = cf->cf_loc[MAINBUSCF_LEVEL]; ma->ma_irq = cf->cf_loc[MAINBUSCF_IRQ]; if (config_match(parent, cf, ma) > 0) Index: src/sys/arch/cobalt/conf/GENERIC diff -u src/sys/arch/cobalt/conf/GENERIC:1.154 src/sys/arch/cobalt/conf/GENERIC:1.155 --- src/sys/arch/cobalt/conf/GENERIC:1.154 Thu Sep 14 07:58:39 2017 +++ src/sys/arch/cobalt/conf/GENERIC Sat Jan 20 13:56:09 2018 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.154 2017/09/14 07:58:39 mrg Exp $ +# $NetBSD: GENERIC,v 1.155 2018/01/20 13:56:09 skrll Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/cobalt/conf/std.cobalt" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.154 $" +#ident "GENERIC-$Revision: 1.155 $" maxusers 32 @@ -43,7 +43,7 @@ options SYSCTL_INCLUDE_DESCR # Include # Debugging options options DIAGNOSTIC # extra kernel sanity checking -#options DEBUG # extra kernel debugging support +options DEBUG # extra kernel debugging support options DDB # kernel dynamic debugger #options DDB_HISTORY_SIZE=100 # enable history editing in DDB makeoptions DEBUG="-g" # compile full symbol table Index: src/sys/arch/cobalt/conf/files.cobalt diff -u src/sys/arch/cobalt/conf/files.cobalt:1.38 src/sys/arch/cobalt/conf/files.cobalt:1.39 --- src/sys/arch/cobalt/conf/files.cobalt:1.38 Tue Jul 29 21:21:44 2014 +++ src/sys/arch/cobalt/conf/files.cobalt Sat Jan 20 13:56:09 2018 @@ -1,4 +1,4 @@ -# $NetBSD: files.cobalt,v 1.38 2014/07/29 21:21:44 skrll Exp $ +# $NetBSD: files.cobalt,v 1.39 2018/01/20 13:56:09 skrll Exp $ maxpartitions 16 @@ -38,6 +38,8 @@ file arch/cobalt/dev/panel.c panel device gt: pcibus attach gt at mainbus file arch/cobalt/dev/gt.c gt +file arch/cobalt/dev/gt_io_space.c gt +file arch/cobalt/dev/gt_mem_space.c gt file arch/cobalt/cobalt/autoconf.c file arch/cobalt/cobalt/bus.c Index: src/sys/arch/cobalt/dev/com_mainbus.c diff -u src/sys/arch/cobalt/dev/com_mainbus.c:1.20 src/sys/arch/cobalt/dev/com_mainbus.c:1.21 --- src/sys/arch/cobalt/dev/com_mainbus.c:1.20 Tue Jun 9 22:47:59 2015 +++ src/sys/arch/cobalt/dev/com_mainbus.c Sat Jan 20 13:56:09 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: com_mainbus.c,v 1.20 2015/06/09 22:47:59 matt Exp $ */ +/* $NetBSD: com_mainbus.c,v 1.21 2018/01/20 13:56:09 skrll Exp $ */ /* * Copyright (c) 2000 Soren S. Jorvang. All rights reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: com_mainbus.c,v 1.20 2015/06/09 22:47:59 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: com_mainbus.c,v 1.21 2018/01/20 13:56:09 skrll Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -105,10 +105,12 @@ com_mainbus_cnprobe(struct consdev *cn) ? CN_NORMAL : CN_DEAD; } +extern struct mips_bus_space cobalt_bs; + void com_mainbus_cninit(struct consdev *cn) { - comcnattach(0, COM_BASE, 115200, COM_MAINBUS_FREQ, COM_TYPE_NORMAL, + comcnattach(&cobalt_bs, COM_BASE, 115200, COM_MAINBUS_FREQ, COM_TYPE_NORMAL, CONMODE); } Index: src/sys/arch/cobalt/dev/gt.c diff -u src/sys/arch/cobalt/dev/gt.c:1.28 src/sys/arch/cobalt/dev/gt.c:1.29 --- src/sys/arch/cobalt/dev/gt.c:1.28 Fri Jan 27 18:52:52 2012 +++ src/sys/arch/cobalt/dev/gt.c Sat Jan 20 13:56:09 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: gt.c,v 1.28 2012/01/27 18:52:52 para Exp $ */ +/* $NetBSD: gt.c,v 1.29 2018/01/20 13:56:09 skrll Exp $ */ /* * Copyright (c) 2000 Soren S. Jorvang. All rights reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: gt.c,v 1.28 2012/01/27 18:52:52 para Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gt.c,v 1.29 2018/01/20 13:56:09 skrll Exp $"); #include "opt_pci.h" #include "pci.h" @@ -57,6 +57,7 @@ __KERNEL_RCSID(0, "$NetBSD: gt.c,v 1.28 #include <dev/pci/pciconf.h> #endif +#include <cobalt/dev/gtvar.h> #include <cobalt/dev/gtreg.h> struct gt_softc { @@ -77,6 +78,9 @@ static void gt_timer0_init(void *); static long gt_timer0_read(void *); #endif +struct mips_bus_space gt_iot; +struct mips_bus_space gt_memt; + CFATTACH_DECL_NEW(gt, sizeof(struct gt_softc), gt_match, gt_attach, NULL, NULL); @@ -119,6 +123,9 @@ gt_attach(device_t parent, device_t self bus_space_write_4(sc->sc_bst, sc->sc_bsh, GT_PCI_TIMEOUT_RETRY, 0x00 << PCI_RETRYCTR_SHIFT | 0xff << PCI_TIMEOUT1_SHIFT | 0xff); + gt_bus_mem_init(>_memt, NULL); + gt_bus_io_init(>_iot, NULL); + #if NPCI > 0 pc = &sc->sc_pc; pc->pc_bst = sc->sc_bst; @@ -132,6 +139,9 @@ gt_attach(device_t parent, device_t self pci_configure_bus(pc, pc->pc_ioext, pc->pc_memext, NULL, 0, mips_cache_info.mci_dcache_align); #endif + memset(&pba, 0, sizeof(pba)); + pba.pba_memt = >_memt; + pba.pba_iot = >_iot; pba.pba_dmat = &pci_bus_dma_tag; pba.pba_dmat64 = NULL; pba.pba_bus = 0; Index: src/sys/arch/cobalt/include/bus_defs.h diff -u src/sys/arch/cobalt/include/bus_defs.h:1.2 src/sys/arch/cobalt/include/bus_defs.h:1.3 --- src/sys/arch/cobalt/include/bus_defs.h:1.2 Tue Jul 29 21:21:44 2014 +++ src/sys/arch/cobalt/include/bus_defs.h Sat Jan 20 13:56:09 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: bus_defs.h,v 1.2 2014/07/29 21:21:44 skrll Exp $ */ +/* $NetBSD: bus_defs.h,v 1.3 2018/01/20 13:56:09 skrll Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc. @@ -43,24 +43,8 @@ typedef psize_t bus_size_t; #include <mips/locore.h> -/* - * Access methods for bus resources and address space. - */ -typedef int bus_space_tag_t; -typedef u_long bus_space_handle_t; - -#define BUS_SPACE_MAP_CACHEABLE 0x01 -#define BUS_SPACE_MAP_LINEAR 0x02 -#define BUS_SPACE_MAP_PREFETCHABLE 0x04 - -#define __BUS_SPACE_HAS_STREAM_METHODS - -#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */ -#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */ - -#define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t) - #define _MIPS_NEED_BUS_DMA_BOUNCE +#include <mips/bus_space_defs.h> #include <mips/bus_dma_defs.h> #endif /* _COBALT_BUS_DEFS_H_ */ Index: src/sys/arch/cobalt/include/bus_funcs.h diff -u src/sys/arch/cobalt/include/bus_funcs.h:1.2 src/sys/arch/cobalt/include/bus_funcs.h:1.3 --- src/sys/arch/cobalt/include/bus_funcs.h:1.2 Tue Jul 29 21:21:44 2014 +++ src/sys/arch/cobalt/include/bus_funcs.h Sat Jan 20 13:56:09 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: bus_funcs.h,v 1.2 2014/07/29 21:21:44 skrll Exp $ */ +/* $NetBSD: bus_funcs.h,v 1.3 2018/01/20 13:56:09 skrll Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc. @@ -33,140 +33,7 @@ #ifndef _COBALT_BUS_FUNCS_H_ #define _COBALT_BUS_FUNCS_H_ -/* - * uintN_t bus_space_read_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset); - * - * Read a 1, 2, 4, or 8 byte quantity from bus space - * described by tag/handle/offset. - */ - -#define bus_space_read_1(t, h, o) \ - ((void) t, (*(volatile uint8_t *)((h) + (o)))) - -#define bus_space_read_2(t, h, o) \ - ((void) t, (*(volatile uint16_t *)((h) + (o)))) - -#define bus_space_read_4(t, h, o) \ - ((void) t, (*(volatile uint32_t *)((h) + (o)))) - -#if 0 /* Cause a link error for bus_space_read_8 */ -#define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!! -#endif - -/* - * void bus_space_write_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, - * uintN_t value); - * - * Write the 1, 2, 4, or 8 byte value `value' to bus space - * described by tag/handle/offset. - */ - -#define bus_space_write_1(t, h, o, v) \ -do { \ - (void) t; \ - *(volatile uint8_t *)((h) + (o)) = (v); \ -} while (0) - -#define bus_space_write_2(t, h, o, v) \ -do { \ - (void) t; \ - *(volatile uint16_t *)((h) + (o)) = (v); \ -} while (0) - -#define bus_space_write_4(t, h, o, v) \ -do { \ - (void) t; \ - *(volatile uint32_t *)((h) + (o)) = (v); \ -} while (0) - -#if 0 /* Cause a link error for bus_space_write_8 */ -#define bus_space_write_8 !!! bus_space_write_8 not implemented !!! -#endif - -/* - * Operations which handle byte stream data on word access. - * - * These functions are defined to resolve endian mismatch, by either - * - When normal (i.e. stream-less) operations perform byte swap - * to resolve endian mismatch, these functions bypass the byte swap. - * or - * - When bus bridge performs automatic byte swap, these functions - * perform byte swap once more, to cancel the bridge's behavior. - * - * Currently these are just same as normal operations, since all - * supported buses are same endian with CPU (i.e. little-endian). - * - */ -#define bus_space_read_stream_2(tag, bsh, offset) \ - bus_space_read_2(tag, bsh, offset) -#define bus_space_read_stream_4(tag, bsh, offset) \ - bus_space_read_4(tag, bsh, offset) -#define bus_space_read_stream_8(tag, bsh, offset) \ - bus_space_read_8(tag, bsh, offset) -#define bus_space_read_multi_stream_2(tag, bsh, offset, datap, count) \ - bus_space_read_multi_2(tag, bsh, offset, datap, count) -#define bus_space_read_multi_stream_4(tag, bsh, offset, datap, count) \ - bus_space_read_multi_4(tag, bsh, offset, datap, count) -#define bus_space_read_multi_stream_8(tag, bsh, offset, datap, count) \ - bus_space_read_multi_8(tag, bsh, offset, datap, count) -#define bus_space_read_region_stream_2(tag, bsh, offset, datap, count) \ - bus_space_read_region_2(tag, bsh, offset, datap, count) -#define bus_space_read_region_stream_4(tag, bsh, offset, datap, count) \ - bus_space_read_region_4(tag, bsh, offset, datap, count) -#define bus_space_read_region_stream_8(tag, bsh, offset, datap, count) \ - bus_space_read_region_8(tag, bsh, offset, datap, count) -#define bus_space_write_stream_2(tag, bsh, offset, data) \ - bus_space_write_2(tag, bsh, offset, data) -#define bus_space_write_stream_4(tag, bsh, offset, data) \ - bus_space_write_4(tag, bsh, offset, data) -#define bus_space_write_stream_8(tag, bsh, offset, data) \ - bus_space_write_8(tag, bsh, offset, data) -#define bus_space_write_multi_stream_2(tag, bsh, offset, datap, count) \ - bus_space_write_multi_2(tag, bsh, offset, datap, count) -#define bus_space_write_multi_stream_4(tag, bsh, offset, datap, count) \ - bus_space_write_multi_4(tag, bsh, offset, datap, count) -#define bus_space_write_multi_stream_8(tag, bsh, offset, datap, count) \ - bus_space_write_multi_8(tag, bsh, offset, datap, count) -#define bus_space_write_region_stream_2(tag, bsh, offset, datap, count) \ - bus_space_write_region_2(tag, bsh, offset, datap, count) -#define bus_space_write_region_stream_4(tag, bsh, offset, datap, count) \ - bus_space_write_region_4(tag, bsh, offset, datap, count) -#define bus_space_write_region_stream_8(tag, bsh, offset, datap, count) \ - bus_space_write_region_8(tag, bsh, offset, datap, count) -#define bus_space_write_region_stream_2(tag, bsh, offset, datap, count) \ - bus_space_write_region_2(tag, bsh, offset, datap, count) -#define bus_space_write_region_stream_4(tag, bsh, offset, datap, count) \ - bus_space_write_region_4(tag, bsh, offset, datap, count) -#define bus_space_write_region_stream_8(tag, bsh, offset, datap, count) \ - bus_space_write_region_8(tag, bsh, offset, datap, count) -#define bus_space_set_multi_stream_2(tag, bsh, offset, data, count) \ - bus_space_set_multi_2(tag, bsh, offset, data, count) -#define bus_space_set_multi_stream_4(tag, bsh, offset, data, count) \ - bus_space_set_multi_4(tag, bsh, offset, data, count) -#define bus_space_set_multi_stream_8(tag, bsh, offset, data, count) \ - bus_space_set_multi_8(tag, bsh, offset, data, count) -#define bus_space_set_region_stream_2(tag, bsh, offset, data, count) \ - bus_space_set_region_2(tag, bsh, offset, data, count) -#define bus_space_set_region_stream_4(tag, bsh, offset, data, count) \ - bus_space_set_region_4(tag, bsh, offset, data, count) -#define bus_space_set_region_stream_8(tag, bsh, offset, data, count) \ - bus_space_set_region_8(tag, bsh, offset, data, count) - -/* - * Bus read/write barrier methods. - * - * void bus_space_barrier(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, - * bus_size_t len, int flags); - * - * On the MIPS, we just flush the write buffer. - */ -#define bus_space_barrier(t, h, o, l, f) \ - ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f), \ - wbflush())) - +#include <mips/bus_space_funcs.h> #include <mips/bus_dma_funcs.h> #endif /* _COBALT_BUS_FUNCS_H_ */ Added files: Index: src/sys/arch/cobalt/dev/gt_io_space.c diff -u /dev/null src/sys/arch/cobalt/dev/gt_io_space.c:1.1 --- /dev/null Sat Jan 20 13:56:09 2018 +++ src/sys/arch/cobalt/dev/gt_io_space.c Sat Jan 20 13:56:09 2018 @@ -0,0 +1,57 @@ +/* $NetBSD: gt_io_space.c,v 1.1 2018/01/20 13:56:09 skrll Exp $ */ + +/* + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nick Hudson. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Little Endian bus_space(9) support for PCI IO access + * on cobalt machines + */ + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: gt_io_space.c,v 1.1 2018/01/20 13:56:09 skrll Exp $"); + +#include <sys/types.h> +#include <sys/param.h> +#include <sys/bus.h> + +#include <cobalt/dev/gtvar.h> + +#define CHIP gt +#define CHIP_IO /* defined */ + +/* IO region 1 */ +#define CHIP_W1_BUS_START(v) 0x00000000UL +#define CHIP_W1_BUS_END(v) 0x02000000UL +#define CHIP_W1_SYS_START(v) 0x10000000UL +#define CHIP_W1_SYS_END(v) 0x12000000UL + +void mainbus_bus_mem_init(bus_space_tag_t, void *); + +#include <mips/mips/bus_space_alignstride_chipdep.c> Index: src/sys/arch/cobalt/dev/gt_mem_space.c diff -u /dev/null src/sys/arch/cobalt/dev/gt_mem_space.c:1.1 --- /dev/null Sat Jan 20 13:56:09 2018 +++ src/sys/arch/cobalt/dev/gt_mem_space.c Sat Jan 20 13:56:09 2018 @@ -0,0 +1,55 @@ +/* $NetBSD: gt_mem_space.c,v 1.1 2018/01/20 13:56:09 skrll Exp $ */ + +/* + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nick Hudson. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Little Endian bus_space(9) support for PCI MEM access + * on cobalt machines + */ + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: gt_mem_space.c,v 1.1 2018/01/20 13:56:09 skrll Exp $"); + +#include <sys/types.h> +#include <sys/param.h> +#include <sys/bus.h> + +#include <cobalt/dev/gtvar.h> + +#define CHIP gt +#define CHIP_MEM /* defined */ + +/* IO region 1 */ +#define CHIP_W1_BUS_START(v) 0x12000000UL +#define CHIP_W1_BUS_END(v) 0x14000000UL +#define CHIP_W1_SYS_START(v) 0x12000000UL +#define CHIP_W1_SYS_END(v) 0x14000000UL + +#include <mips/mips/bus_space_alignstride_chipdep.c> Index: src/sys/arch/cobalt/dev/gtvar.h diff -u /dev/null src/sys/arch/cobalt/dev/gtvar.h:1.1 --- /dev/null Sat Jan 20 13:56:09 2018 +++ src/sys/arch/cobalt/dev/gtvar.h Sat Jan 20 13:56:09 2018 @@ -0,0 +1,14 @@ +/* $NetBSD: gtvar.h,v 1.1 2018/01/20 13:56:09 skrll Exp $ */ + +#ifndef _GTVAR_H_ +#define _GTVAR_H_ + +#include <machine/bus_defs.h> + +extern struct mips_bus_space gt_iot; +extern struct mips_bus_space gt_memt; + +void gt_bus_io_init(bus_space_tag_t, void *); +void gt_bus_mem_init(bus_space_tag_t, void *); + +#endif /* _GTVAR_H_ */