1*0a29e87bSrin /* $NetBSD: i80321var.h,v 1.14 2021/08/06 09:01:36 rin Exp $ */ 2f5362116Sthorpej 3f5362116Sthorpej /* 4d322684fSthorpej * Copyright (c) 2002, 2003 Wasabi Systems, Inc. 5f5362116Sthorpej * All rights reserved. 6f5362116Sthorpej * 7f5362116Sthorpej * Written by Jason R. Thorpe for Wasabi Systems, Inc. 8f5362116Sthorpej * 9f5362116Sthorpej * Redistribution and use in source and binary forms, with or without 10f5362116Sthorpej * modification, are permitted provided that the following conditions 11f5362116Sthorpej * are met: 12f5362116Sthorpej * 1. Redistributions of source code must retain the above copyright 13f5362116Sthorpej * notice, this list of conditions and the following disclaimer. 14f5362116Sthorpej * 2. Redistributions in binary form must reproduce the above copyright 15f5362116Sthorpej * notice, this list of conditions and the following disclaimer in the 16f5362116Sthorpej * documentation and/or other materials provided with the distribution. 17f5362116Sthorpej * 3. All advertising materials mentioning features or use of this software 18f5362116Sthorpej * must display the following acknowledgement: 19f5362116Sthorpej * This product includes software developed for the NetBSD Project by 20f5362116Sthorpej * Wasabi Systems, Inc. 21f5362116Sthorpej * 4. The name of Wasabi Systems, Inc. may not be used to endorse 22f5362116Sthorpej * or promote products derived from this software without specific prior 23f5362116Sthorpej * written permission. 24f5362116Sthorpej * 25f5362116Sthorpej * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 26f5362116Sthorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27f5362116Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28f5362116Sthorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 29f5362116Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30f5362116Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31f5362116Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32f5362116Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33f5362116Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34f5362116Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35f5362116Sthorpej * POSSIBILITY OF SUCH DAMAGE. 36f5362116Sthorpej */ 37f5362116Sthorpej 38f5362116Sthorpej #ifndef _ARM_XSCALE_I80321VAR_H_ 39f5362116Sthorpej #define _ARM_XSCALE_I80321VAR_H_ 40f5362116Sthorpej 41f5362116Sthorpej #include <sys/queue.h> 42f5362116Sthorpej #include <dev/pci/pcivar.h> 43f5362116Sthorpej 44f5362116Sthorpej /* 45f5362116Sthorpej * There are roughly 32 interrupt sources. 46f5362116Sthorpej */ 47f5362116Sthorpej #define NIRQ 32 48f5362116Sthorpej 49f5362116Sthorpej struct intrhand { 50f5362116Sthorpej TAILQ_ENTRY(intrhand) ih_list; /* link on intrq list */ 51f5362116Sthorpej int (*ih_func)(void *); /* handler */ 52f5362116Sthorpej void *ih_arg; /* arg for handler */ 53f5362116Sthorpej int ih_ipl; /* IPL_* */ 54f5362116Sthorpej int ih_irq; /* IRQ number */ 55f5362116Sthorpej }; 56f5362116Sthorpej 57f5362116Sthorpej #define IRQNAMESIZE sizeof("iop321 irq 31") 58f5362116Sthorpej 59f5362116Sthorpej struct intrq { 60f5362116Sthorpej TAILQ_HEAD(, intrhand) iq_list; /* handler list */ 61f5362116Sthorpej struct evcnt iq_ev; /* event counter */ 62f5362116Sthorpej int iq_ist; /* share type */ 63f5362116Sthorpej }; 64f5362116Sthorpej 65f5362116Sthorpej struct i80321_softc { 667490f933Smatt device_t sc_dev; /* generic device glue */ 67f5362116Sthorpej 68f5362116Sthorpej int sc_is_host; /* indicates if we're a host or 69f5362116Sthorpej plugged into another host */ 70f5362116Sthorpej 71f5362116Sthorpej /* 72f5362116Sthorpej * This is the bus_space and handle used to access the 73f5362116Sthorpej * i80321 itself. This is filled in by the board-specific 74f5362116Sthorpej * front-end. 75f5362116Sthorpej */ 76f5362116Sthorpej bus_space_tag_t sc_st; 77f5362116Sthorpej bus_space_handle_t sc_sh; 78f5362116Sthorpej 79f5362116Sthorpej /* Handles for the various subregions. */ 80f5362116Sthorpej bus_space_handle_t sc_atu_sh; 81f5362116Sthorpej bus_space_handle_t sc_mcu_sh; 82f5362116Sthorpej 83f5362116Sthorpej /* 84f5362116Sthorpej * We expect the board-specific front-end to have already mapped 85f5362116Sthorpej * the PCI I/O space .. it is only 64K, and I/O mappings tend to 86f5362116Sthorpej * be smaller than a page size, so it's generally more efficient 87f5362116Sthorpej * to map them all into virtual space in one fell swoop. 88f5362116Sthorpej */ 89f5362116Sthorpej vaddr_t sc_iow_vaddr; /* I/O window vaddr */ 90f5362116Sthorpej 91f5362116Sthorpej /* 92f5362116Sthorpej * Variables that define the Inbound windows. The base address of 93f5362116Sthorpej * 0-2 are configured by a host via BARs. The xlate variable 94f5362116Sthorpej * defines the start of the local address space that it maps to. 95f5362116Sthorpej * The size variable defines the byte size. 96f5362116Sthorpej * 97f5362116Sthorpej * The first 3 windows are for incoming PCI memory read/write 98f5362116Sthorpej * cycles from a host. The 4th window, not configured by the 99f5362116Sthorpej * host (as it outside the normal BAR range) is the inbound 100f5362116Sthorpej * window for PCI devices controlled by the i80321. 101f5362116Sthorpej */ 102f5362116Sthorpej struct { 103f5362116Sthorpej uint32_t iwin_base_hi; 104f5362116Sthorpej uint32_t iwin_base_lo; 105f5362116Sthorpej uint32_t iwin_xlate; 106f5362116Sthorpej uint32_t iwin_size; 107f5362116Sthorpej } sc_iwin[4]; 108f5362116Sthorpej 109f5362116Sthorpej /* 110f5362116Sthorpej * Variables that define the Outbound windows. 111f5362116Sthorpej */ 112f5362116Sthorpej struct { 113f5362116Sthorpej uint32_t owin_xlate_lo; 114f5362116Sthorpej uint32_t owin_xlate_hi; 115f5362116Sthorpej } sc_owin[2]; 116f5362116Sthorpej 117f5362116Sthorpej /* 118c9d34b29Sbriggs * This is the PCI address that the Outbound I/O window maps to. 119c9d34b29Sbriggs * The offset is to keep the actual used I/O address away from 0, 120c9d34b29Sbriggs * which can be bad if, say, an i8254x gig-e chip gets mapped there. 121c9d34b29Sbriggs * The 0 value apparently looks like "unconfigured" to the controller 122c9d34b29Sbriggs * and it ignores writes to that region (it doesn't cause a bus fault, 123c9d34b29Sbriggs * it just ignores them--leading to a non-functional controller). The 124c9d34b29Sbriggs * wm(4) driver usually uses memory-mapped regions, but does use the 125c9d34b29Sbriggs * I/O-mapped region for reset operations in order to work around a 126c9d34b29Sbriggs * bug in the chip. 127c9d34b29Sbriggs * Iyonix, while using sc_ioout_xlate 0 needs an offset of 0, too, in 128c9d34b29Sbriggs * order to function properly. These values are both set in the 129c9d34b29Sbriggs * port-specific i80321_mainbus_attach() routine. 130f5362116Sthorpej */ 131f5362116Sthorpej uint32_t sc_ioout_xlate; 132c9d34b29Sbriggs uint32_t sc_ioout_xlate_offset; 133f5362116Sthorpej 134f5362116Sthorpej /* Bus space, DMA, and PCI tags for the PCI bus (private devices). */ 135f5362116Sthorpej struct bus_space sc_pci_iot; 136f5362116Sthorpej struct bus_space sc_pci_memt; 137f5362116Sthorpej struct arm32_bus_dma_tag sc_pci_dmat; 138f5362116Sthorpej struct arm32_pci_chipset sc_pci_chipset; 139f5362116Sthorpej 140dce44763Sthorpej /* DMA window info for PCI DMA. */ 141dce44763Sthorpej struct arm32_dma_range sc_pci_dma_range; 142dce44763Sthorpej 143f5362116Sthorpej /* GPIO state */ 144f5362116Sthorpej uint8_t sc_gpio_dir; /* GPIO pin direction (1 == output) */ 145f5362116Sthorpej uint8_t sc_gpio_val; /* GPIO output pin value */ 146efe71a8aSthorpej 147efe71a8aSthorpej /* DMA tag for local devices. */ 148efe71a8aSthorpej struct arm32_bus_dma_tag sc_local_dmat; 149f5362116Sthorpej }; 150f5362116Sthorpej 1512367c7ffSthorpej /* 1522367c7ffSthorpej * Arguments used to attach IOP built-ins. 1532367c7ffSthorpej */ 1542367c7ffSthorpej struct iopxs_attach_args { 1552367c7ffSthorpej const char *ia_name; /* name of device */ 1562367c7ffSthorpej bus_space_tag_t ia_st; /* space tag */ 1572367c7ffSthorpej bus_space_handle_t ia_sh;/* handle of IOP base */ 1582367c7ffSthorpej bus_dma_tag_t ia_dmat; /* DMA tag */ 1592367c7ffSthorpej bus_addr_t ia_offset; /* offset of device from IOP base */ 1602367c7ffSthorpej bus_size_t ia_size; /* size of sub-device */ 1612367c7ffSthorpej }; 1622367c7ffSthorpej 163f5362116Sthorpej extern struct bus_space i80321_bs_tag; 164f5362116Sthorpej extern struct i80321_softc *i80321_softc; 165825088edSmatt extern const char * const i80321_irqnames[]; 166f5362116Sthorpej 167f5362116Sthorpej extern void (*i80321_hardclock_hook)(void); 168f5362116Sthorpej 169f5362116Sthorpej void i80321_sdram_bounds(bus_space_tag_t, bus_space_handle_t, 170f5362116Sthorpej paddr_t *, psize_t *); 171f5362116Sthorpej 172f5362116Sthorpej void i80321_calibrate_delay(void); 173f5362116Sthorpej 174f5362116Sthorpej void i80321_icu_init(void); 175f5362116Sthorpej void i80321_intr_init(void); 1767490f933Smatt void i80321_intr_evcnt_attach(void); 177f5362116Sthorpej void *i80321_intr_establish(int, int, int (*)(void *), void *); 178f5362116Sthorpej void i80321_intr_disestablish(void *); 179f5362116Sthorpej 180d322684fSthorpej void i80321_gpio_set_direction(uint8_t, uint8_t); 181d322684fSthorpej void i80321_gpio_set_val(uint8_t, uint8_t); 182d322684fSthorpej uint8_t i80321_gpio_get_val(void); 183d322684fSthorpej 184f5362116Sthorpej void i80321_bs_init(bus_space_tag_t, void *); 185f5362116Sthorpej void i80321_io_bs_init(bus_space_tag_t, void *); 186f5362116Sthorpej void i80321_mem_bs_init(bus_space_tag_t, void *); 187f5362116Sthorpej 188460f6b63Sbriggs void i80321_local_dma_init(struct i80321_softc *sc); 189460f6b63Sbriggs 190f5362116Sthorpej void i80321_pci_init(pci_chipset_tag_t, void *); 191f5362116Sthorpej 192f5362116Sthorpej void i80321_attach(struct i80321_softc *); 193f5362116Sthorpej 194f5362116Sthorpej #endif /* _ARM_XSCALE_I80321VAR_H_ */ 195