1*a2b8c7fbSmsaitoh /* $NetBSD: beccvar.h,v 1.4 2012/10/14 14:20:57 msaitoh Exp $ */ 2b1b164a8Sthorpej 3b1b164a8Sthorpej /* 40abb67bbSthorpej * Copyright (c) 2002, 2003 Wasabi Systems, Inc. 5b1b164a8Sthorpej * All rights reserved. 6b1b164a8Sthorpej * 7b1b164a8Sthorpej * Written by Jason R. Thorpe for Wasabi Systems, Inc. 8b1b164a8Sthorpej * 9b1b164a8Sthorpej * Redistribution and use in source and binary forms, with or without 10b1b164a8Sthorpej * modification, are permitted provided that the following conditions 11b1b164a8Sthorpej * are met: 12b1b164a8Sthorpej * 1. Redistributions of source code must retain the above copyright 13b1b164a8Sthorpej * notice, this list of conditions and the following disclaimer. 14b1b164a8Sthorpej * 2. Redistributions in binary form must reproduce the above copyright 15b1b164a8Sthorpej * notice, this list of conditions and the following disclaimer in the 16b1b164a8Sthorpej * documentation and/or other materials provided with the distribution. 17b1b164a8Sthorpej * 3. All advertising materials mentioning features or use of this software 18b1b164a8Sthorpej * must display the following acknowledgement: 19b1b164a8Sthorpej * This product includes software developed for the NetBSD Project by 20b1b164a8Sthorpej * Wasabi Systems, Inc. 21b1b164a8Sthorpej * 4. The name of Wasabi Systems, Inc. may not be used to endorse 22b1b164a8Sthorpej * or promote products derived from this software without specific prior 23b1b164a8Sthorpej * written permission. 24b1b164a8Sthorpej * 25b1b164a8Sthorpej * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 26b1b164a8Sthorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27b1b164a8Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28b1b164a8Sthorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 29b1b164a8Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30b1b164a8Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31b1b164a8Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32b1b164a8Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33b1b164a8Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34b1b164a8Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35b1b164a8Sthorpej * POSSIBILITY OF SUCH DAMAGE. 36b1b164a8Sthorpej */ 37b1b164a8Sthorpej 38b1b164a8Sthorpej #ifndef _BECCVAR_H_ 39b1b164a8Sthorpej #define _BECCVAR_H_ 40b1b164a8Sthorpej 41b1b164a8Sthorpej #include <sys/queue.h> 42b1b164a8Sthorpej #include <dev/pci/pcivar.h> 43b1b164a8Sthorpej 44b1b164a8Sthorpej /* 45b1b164a8Sthorpej * There are roughly 32 interrupt sources. 46b1b164a8Sthorpej */ 47b1b164a8Sthorpej #define NIRQ 32 48b1b164a8Sthorpej 49b1b164a8Sthorpej struct intrhand { 50b1b164a8Sthorpej TAILQ_ENTRY(intrhand) ih_list; /* link on intrq list */ 51b1b164a8Sthorpej int (*ih_func)(void *); /* handler */ 52b1b164a8Sthorpej void *ih_arg; /* arg for handler */ 53b1b164a8Sthorpej int ih_ipl; /* IPL_* */ 54b1b164a8Sthorpej int ih_irq; /* IRQ number */ 55b1b164a8Sthorpej }; 56b1b164a8Sthorpej 57b1b164a8Sthorpej struct intrq { 58b1b164a8Sthorpej TAILQ_HEAD(, intrhand) iq_list; /* handler list */ 59b1b164a8Sthorpej struct evcnt iq_ev; /* event counter */ 60b1b164a8Sthorpej int iq_mask; /* IRQs to mask while handling */ 61b1b164a8Sthorpej int iq_levels; /* IPL_*'s this IRQ has */ 62b1b164a8Sthorpej int iq_ist; /* share type */ 63b1b164a8Sthorpej }; 64b1b164a8Sthorpej 65b1b164a8Sthorpej struct becc_softc { 66*a2b8c7fbSmsaitoh device_t sc_dev; /* generic device glue */ 67b1b164a8Sthorpej 68b1b164a8Sthorpej /* 69b1b164a8Sthorpej * We expect the board-specific front-end to have already mapped 70b1b164a8Sthorpej * the PCI I/O, memory, and configuration spaces. 71b1b164a8Sthorpej */ 72b1b164a8Sthorpej vaddr_t sc_pci_io_base; /* I/O window vaddr */ 73b1b164a8Sthorpej vaddr_t sc_pci_mem_base[2]; /* MEM window vaddr */ 74b1b164a8Sthorpej vaddr_t sc_pci_cfg_base; /* CFG window vaddr */ 75b1b164a8Sthorpej 76b1b164a8Sthorpej /* 77b1b164a8Sthorpej * These define the 2 32M PCI Inbound windows and 1 128M (rev8 & up). 78b1b164a8Sthorpej */ 79b1b164a8Sthorpej struct { 80b1b164a8Sthorpej uint32_t iwin_base; /* PCI address */ 81b1b164a8Sthorpej uint32_t iwin_xlate; /* local address */ 82b1b164a8Sthorpej } sc_iwin[3]; 83b1b164a8Sthorpej 84b1b164a8Sthorpej /* 85b1b164a8Sthorpej * Variables that define the 2 32M PCI Outbound windows and 86b1b164a8Sthorpej * 1 1G (rev8 & up). 87b1b164a8Sthorpej */ 88b1b164a8Sthorpej uint32_t sc_owin_xlate[3]; /* PCI address */ 89b1b164a8Sthorpej 90b1b164a8Sthorpej /* 91b1b164a8Sthorpej * This is the PCI address that the Outbound I/O 92b1b164a8Sthorpej * window maps to. 93b1b164a8Sthorpej */ 94b1b164a8Sthorpej uint32_t sc_ioout_xlate; 95b1b164a8Sthorpej 96b1b164a8Sthorpej /* Bus space, DMA, and PCI tags for the PCI bus. */ 97b1b164a8Sthorpej struct bus_space sc_pci_iot; 98b1b164a8Sthorpej struct bus_space sc_pci_memt; 99b1b164a8Sthorpej struct arm32_bus_dma_tag sc_pci_dmat; 100b1b164a8Sthorpej struct arm32_pci_chipset sc_pci_chipset; 101b1b164a8Sthorpej 102b1b164a8Sthorpej /* DMA window info for PCI DMA. */ 103b1b164a8Sthorpej struct arm32_dma_range sc_pci_dma_range[3]; 104891be168Sthorpej 105891be168Sthorpej /* DMA tag for local DMA. */ 106891be168Sthorpej struct arm32_bus_dma_tag sc_local_dmat; 107891be168Sthorpej }; 108891be168Sthorpej 109891be168Sthorpej struct becc_attach_args { 110891be168Sthorpej bus_dma_tag_t ba_dmat; 111b1b164a8Sthorpej }; 112b1b164a8Sthorpej 113b1b164a8Sthorpej extern int becc_rev; /* Set by early bootstrap code */ 114b1b164a8Sthorpej extern const char *becc_revisions[]; 115b1b164a8Sthorpej extern void (*becc_hardclock_hook)(void); 116b1b164a8Sthorpej 117b1b164a8Sthorpej void becc_calibrate_delay(void); 118b1b164a8Sthorpej 119b1b164a8Sthorpej void becc_icu_init(void); 120b1b164a8Sthorpej void becc_intr_init(void); 121b1b164a8Sthorpej void *becc_intr_establish(int, int, int (*)(void *), void *); 122b1b164a8Sthorpej void becc_intr_disestablish(void *); 123b1b164a8Sthorpej 124b1b164a8Sthorpej void becc_io_bs_init(bus_space_tag_t, void *); 125b1b164a8Sthorpej void becc_mem_bs_init(bus_space_tag_t, void *); 126b1b164a8Sthorpej 127b1b164a8Sthorpej void becc_pci_init(pci_chipset_tag_t, void *); 128b1b164a8Sthorpej 129b1b164a8Sthorpej void becc_attach(struct becc_softc *); 130b1b164a8Sthorpej 131b1b164a8Sthorpej uint32_t becc_pcicore_read(struct becc_softc *, bus_addr_t); 132b1b164a8Sthorpej void becc_pcicore_write(struct becc_softc *, bus_addr_t, uint32_t); 133b1b164a8Sthorpej 134b1b164a8Sthorpej #endif /* _BECCVAR_H_ */ 135