1183840Sraj/*- 2183840Sraj * Copyright (c) 2002, 2003 Wasabi Systems, Inc. 3183840Sraj * All rights reserved. 4183840Sraj * 5183840Sraj * Written by Jason R. Thorpe for Wasabi Systems, Inc. 6183840Sraj * 7183840Sraj * Redistribution and use in source and binary forms, with or without 8183840Sraj * modification, are permitted provided that the following conditions 9183840Sraj * are met: 10183840Sraj * 1. Redistributions of source code must retain the above copyright 11183840Sraj * notice, this list of conditions and the following disclaimer. 12183840Sraj * 2. Redistributions in binary form must reproduce the above copyright 13183840Sraj * notice, this list of conditions and the following disclaimer in the 14183840Sraj * documentation and/or other materials provided with the distribution. 15183840Sraj * 3. All advertising materials mentioning features or use of this software 16183840Sraj * must display the following acknowledgement: 17183840Sraj * This product includes software developed for the NetBSD Project by 18183840Sraj * Wasabi Systems, Inc. 19183840Sraj * 4. The name of Wasabi Systems, Inc. may not be used to endorse 20183840Sraj * or promote products derived from this software without specific prior 21183840Sraj * written permission. 22183840Sraj * 23183840Sraj * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 24183840Sraj * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 25183840Sraj * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 26183840Sraj * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 27183840Sraj * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28183840Sraj * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29183840Sraj * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30183840Sraj * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31183840Sraj * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32183840Sraj * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33183840Sraj * POSSIBILITY OF SUCH DAMAGE. 34183840Sraj * 35183840Sraj * from: FreeBSD: //depot/projects/arm/src/sys/arm/xscale/pxa2x0/pxa2x0var.h, rev 1 36183840Sraj * 37183840Sraj * $FreeBSD$ 38183840Sraj */ 39183840Sraj 40183840Sraj#ifndef _MVVAR_H_ 41183840Sraj#define _MVVAR_H_ 42183840Sraj 43183840Sraj#include <sys/rman.h> 44239277Sgonzo#include <machine/bus.h> 45196531Sraj#include <vm/vm.h> 46196531Sraj#include <vm/pmap.h> 47196531Sraj#include <machine/vm.h> 48183840Sraj 49266084Sian#include <dev/ofw/openfirm.h> 50266084Sian 51185089Sraj#define MV_TYPE_PCI 0 52185089Sraj#define MV_TYPE_PCIE 1 53185089Sraj 54239277Sgonzo#define MV_MODE_ENDPOINT 0 55239277Sgonzo#define MV_MODE_ROOT 1 56239277Sgonzo 57186909Srajstruct gpio_config { 58186909Sraj int gc_gpio; /* GPIO number */ 59186909Sraj uint32_t gc_flags; /* GPIO flags */ 60186909Sraj int gc_output; /* GPIO output value */ 61186909Sraj}; 62186909Sraj 63183840Srajstruct decode_win { 64183840Sraj int target; /* Mbus unit ID */ 65183840Sraj int attr; /* Attributes of the target interface */ 66183840Sraj vm_paddr_t base; /* Physical base addr */ 67183840Sraj uint32_t size; 68239277Sgonzo vm_paddr_t remap; 69183840Sraj}; 70183840Sraj 71186909Srajextern const struct gpio_config mv_gpio_config[]; 72239277Sgonzoextern const struct decode_win *cpu_wins; 73185092Srajextern const struct decode_win *idma_wins; 74186909Srajextern const struct decode_win *xor_wins; 75185092Srajextern int idma_wins_no; 76186909Srajextern int xor_wins_no; 77183840Sraj 78183840Sraj/* Function prototypes */ 79185092Srajint mv_gpio_setup_intrhandler(const char *name, driver_filter_t *filt, 80183840Sraj void (*hand)(void *), void *arg, int pin, int flags, void **cookiep); 81185092Srajvoid mv_gpio_intr_mask(int pin); 82185092Srajvoid mv_gpio_intr_unmask(int pin); 83185092Srajvoid mv_gpio_out(uint32_t pin, uint8_t val, uint8_t enable); 84185092Srajuint8_t mv_gpio_in(uint32_t pin); 85209131Srajint platform_gpio_init(void); 86183840Sraj 87185092Srajint soc_decode_win(void); 88185092Srajvoid soc_id(uint32_t *dev, uint32_t *rev); 89185092Srajvoid soc_dump_decode_win(void); 90183840Srajuint32_t soc_power_ctrl_get(uint32_t mask); 91196532Srajvoid soc_power_ctrl_set(uint32_t mask); 92240488Sgberuint64_t get_sar_value(void); 93183840Sraj 94185089Srajint decode_win_cpu_set(int target, int attr, vm_paddr_t base, uint32_t size, 95239277Sgonzo vm_paddr_t remap); 96183840Srajint decode_win_overlap(int, int, const struct decode_win *); 97183840Srajint win_cpu_can_remap(int); 98239277Sgonzovoid decode_win_pcie_setup(u_long); 99183840Sraj 100250295Sgbervoid ddr_disable(int i); 101185092Srajint ddr_is_active(int i); 102185092Srajuint32_t ddr_base(int i); 103185092Srajuint32_t ddr_size(int i); 104185092Srajuint32_t ddr_attr(int i); 105185092Srajuint32_t ddr_target(int i); 106183840Sraj 107185092Srajuint32_t cpu_extra_feat(void); 108185092Srajuint32_t get_tclk(void); 109239277Sgonzouint32_t get_l2clk(void); 110185092Srajuint32_t read_cpu_ctrl(uint32_t); 111185092Srajvoid write_cpu_ctrl(uint32_t, uint32_t); 112183840Sraj 113240488Sgber#if defined(SOC_MV_ARMADAXP) 114240488Sgberuint32_t read_cpu_mp_clocks(uint32_t reg); 115240488Sgbervoid write_cpu_mp_clocks(uint32_t reg, uint32_t val); 116240488Sgberuint32_t read_cpu_misc(uint32_t reg); 117240488Sgbervoid write_cpu_misc(uint32_t reg, uint32_t val); 118240488Sgber#endif 119240488Sgber 120239277Sgonzoint mv_pcib_bar_win_set(device_t dev, uint32_t base, uint32_t size, 121239277Sgonzo uint32_t remap, int winno, int busno); 122239277Sgonzoint mv_pcib_cpu_win_remap(device_t dev, uint32_t remap, uint32_t size); 123239277Sgonzo 124239277Sgonzovoid mv_mask_endpoint_irq(uintptr_t nb, int unit); 125239277Sgonzovoid mv_unmask_endpoint_irq(uintptr_t nb, int unit); 126239277Sgonzo 127239277Sgonzoint mv_drbl_get_next_irq(int dir, int unit); 128239277Sgonzovoid mv_drbl_mask_all(int unit); 129239277Sgonzovoid mv_drbl_mask_irq(uint32_t irq, int dir, int unit); 130239277Sgonzovoid mv_drbl_unmask_irq(uint32_t irq, int dir, int unit); 131239277Sgonzovoid mv_drbl_set_mask(uint32_t val, int dir, int unit); 132239277Sgonzouint32_t mv_drbl_get_mask(int dir, int unit); 133239277Sgonzovoid mv_drbl_set_cause(uint32_t val, int dir, int unit); 134239277Sgonzouint32_t mv_drbl_get_cause(int dir, int unit); 135239277Sgonzovoid mv_drbl_set_msg(uint32_t val, int mnr, int dir, int unit); 136239277Sgonzouint32_t mv_drbl_get_msg(int mnr, int dir, int unit); 137239277Sgonzo 138240492Sgberint mv_msi_data(int irq, uint64_t *addr, uint32_t *data); 139240492Sgber 140266084Sianstruct arm_devmap_entry; 141266084Sian 142266084Sianint mv_pci_devmap(phandle_t, struct arm_devmap_entry *, vm_offset_t, 143266084Sian vm_offset_t); 144266084Sian 145183840Sraj#endif /* _MVVAR_H_ */ 146