Index: sys/arch/cobalt/cobalt/bus.c =================================================================== RCS file: /cvsroot/src/sys/arch/cobalt/cobalt/bus.c,v retrieving revision 1.45 diff -u -p -r1.45 bus.c --- sys/arch/cobalt/cobalt/bus.c 29 Jul 2014 21:21:43 -0000 1.45 +++ sys/arch/cobalt/cobalt/bus.c 28 Dec 2016 14:38:58 -0000 @@ -30,370 +30,38 @@ * POSSIBILITY OF SUCH DAMAGE. */ +/* + * Platform-specific I/O support for the cobalt machines + */ + #include __KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.45 2014/07/29 21:21:43 skrll Exp $"); +#include #include #include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include - -/* - * 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. - */ - -#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. - */ - -#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)); \ - } \ -} - -__COBALT_copy_region(1) -__COBALT_copy_region(2) -__COBALT_copy_region(4) - -#if 0 /* Cause a link error for bus_space_copy_region_8 */ -#define bus_space_copy_region_8 \ - !!! bus_space_copy_region_8 unimplemented !!! -#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) -{ - *nbshp = bsh + offset; - return 0; -} +#define CHIP mainbus +#define CHIP_MEM /* defined */ +#define CHIP_ACCESS_SIZE 1 + +#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 + +/* 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 + +/* 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 Index: sys/arch/cobalt/cobalt/interrupt.c =================================================================== RCS file: /cvsroot/src/sys/arch/cobalt/cobalt/interrupt.c,v retrieving revision 1.7 diff -u -p -r1.7 interrupt.c --- sys/arch/cobalt/cobalt/interrupt.c 1 Jul 2011 20:36:42 -0000 1.7 +++ sys/arch/cobalt/cobalt/interrupt.c 28 Dec 2016 14:38:59 -0000 @@ -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: sys/arch/cobalt/cobalt/machdep.c =================================================================== RCS file: /cvsroot/src/sys/arch/cobalt/cobalt/machdep.c,v retrieving revision 1.119 diff -u -p -r1.119 machdep.c --- sys/arch/cobalt/cobalt/machdep.c 22 Dec 2016 14:47:54 -0000 1.119 +++ sys/arch/cobalt/cobalt/machdep.c 28 Dec 2016 14:38:59 -0000 @@ -59,15 +59,16 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v #include #include -#include -#include -#include -#include -#include #include -#include +#include #include #include +#include +#include +#include +#include +#include +#include #include @@ -106,6 +107,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; @@ -128,6 +139,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(). */ @@ -182,6 +197,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: sys/arch/cobalt/cobalt/mainbus.c =================================================================== RCS file: /cvsroot/src/sys/arch/cobalt/cobalt/mainbus.c,v retrieving revision 1.19 diff -u -p -r1.19 mainbus.c --- sys/arch/cobalt/cobalt/mainbus.c 29 Jul 2014 21:21:43 -0000 1.19 +++ sys/arch/cobalt/cobalt/mainbus.c 28 Dec 2016 14:38:59 -0000 @@ -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: sys/arch/cobalt/conf/files.cobalt =================================================================== RCS file: /cvsroot/src/sys/arch/cobalt/conf/files.cobalt,v retrieving revision 1.38 diff -u -p -r1.38 files.cobalt --- sys/arch/cobalt/conf/files.cobalt 29 Jul 2014 21:21:44 -0000 1.38 +++ sys/arch/cobalt/conf/files.cobalt 28 Dec 2016 14:38:59 -0000 @@ -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: sys/arch/cobalt/dev/com_mainbus.c =================================================================== RCS file: /cvsroot/src/sys/arch/cobalt/dev/com_mainbus.c,v retrieving revision 1.20 diff -u -p -r1.20 com_mainbus.c --- sys/arch/cobalt/dev/com_mainbus.c 9 Jun 2015 22:47:59 -0000 1.20 +++ sys/arch/cobalt/dev/com_mainbus.c 28 Dec 2016 14:38:59 -0000 @@ -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: sys/arch/cobalt/dev/gt_io_space.c =================================================================== RCS file: sys/arch/cobalt/dev/gt_io_space.c diff -N sys/arch/cobalt/dev/gt_io_space.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sys/arch/cobalt/dev/gt_io_space.c 28 Dec 2016 14:39:01 -0000 @@ -0,0 +1,63 @@ +/* $NetBSD$ */ + +/* + * 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 +__KERNEL_RCSID(0, "$NetBSD$"); + +#include +#include +#include + +#include + +#define CHIP gt +#define CHIP_IO /* defined */ +#define CHIP_ACCESS_SIZE 1 + +#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 + +/* 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 Index: sys/arch/cobalt/dev/gt_mem_space.c =================================================================== RCS file: sys/arch/cobalt/dev/gt_mem_space.c diff -N sys/arch/cobalt/dev/gt_mem_space.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sys/arch/cobalt/dev/gt_mem_space.c 28 Dec 2016 14:39:01 -0000 @@ -0,0 +1,69 @@ +/* $NetBSD: bus.c,v 1.45 2014/07/29 21:21:43 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 +__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.45 2014/07/29 21:21:43 skrll Exp $"); + +#include +#include +#include + +#include + +#define CHIP gt +#define CHIP_MEM /* defined */ +#define CHIP_ACCESS_SIZE 1 + +#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 + +#define GT_DEF_PCI0_IO_BASE 0x10000000UL +#define GT_DEF_PCI0_IO_SIZE 0x02000000UL +#define GT_DEF_PCI0_MEM0_BASE 0x12000000UL +#define GT_DEF_PCI0_MEM0_SIZE 0x02000000UL +#define GT_DEF_BASE 0x14000000UL + +/* IO region 1 */ +#define CHIP_W1_BUS_START(v) 0x02000000UL +#define CHIP_W1_BUS_END(v) 0x04000000UL +#define CHIP_W1_SYS_START(v) 0x12000000UL +#define CHIP_W1_SYS_END(v) 0x14000000UL + +// void mainbus_bus_mem_init(bus_space_tag_t, void *); + +#include Index: sys/arch/cobalt/dev/gtvar.h =================================================================== RCS file: sys/arch/cobalt/dev/gtvar.h diff -N sys/arch/cobalt/dev/gtvar.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sys/arch/cobalt/dev/gtvar.h 28 Dec 2016 14:39:01 -0000 @@ -0,0 +1,19 @@ +/* $NetBSD$ */ + +#ifndef _GTVAR_H_ +#define _GTVAR_H_ + +#include + +// extern struct extent *loongson_io_ex; +// extern struct extent *loongson_mem_ex; +// extern int ex_mallocsafe; +extern struct mips_bus_space gt_iot; +extern struct mips_bus_space gt_memt; +// extern struct mips_bus_dma_tag bonito_dmat; +// extern struct mips_pci_chipset bonito_pc; + +void gt_bus_io_init(bus_space_tag_t, void *); +void gt_bus_mem_init(bus_space_tag_t, void *); + +#endif /* _GTVAR_H_ */ Index: sys/arch/cobalt/include/bus_defs.h =================================================================== RCS file: /cvsroot/src/sys/arch/cobalt/include/bus_defs.h,v retrieving revision 1.2 diff -u -p -r1.2 bus_defs.h --- sys/arch/cobalt/include/bus_defs.h 29 Jul 2014 21:21:44 -0000 1.2 +++ sys/arch/cobalt/include/bus_defs.h 28 Dec 2016 14:39:01 -0000 @@ -43,24 +43,8 @@ typedef psize_t bus_size_t; #include -/* - * 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 #include #endif /* _COBALT_BUS_DEFS_H_ */ Index: sys/arch/cobalt/include/bus_funcs.h =================================================================== RCS file: /cvsroot/src/sys/arch/cobalt/include/bus_funcs.h,v retrieving revision 1.2 diff -u -p -r1.2 bus_funcs.h --- sys/arch/cobalt/include/bus_funcs.h 29 Jul 2014 21:21:44 -0000 1.2 +++ sys/arch/cobalt/include/bus_funcs.h 28 Dec 2016 14:39:01 -0000 @@ -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 #include #endif /* _COBALT_BUS_FUNCS_H_ */