1 1.19 thorpej /* $NetBSD: vidc20.c,v 1.19 2021/08/07 16:18:44 thorpej Exp $ */ 2 1.1 reinoud 3 1.1 reinoud /* 4 1.1 reinoud * Copyright (c) 1997 Mark Brinicombe 5 1.1 reinoud * Copyright (c) 1997 Causality Limited 6 1.1 reinoud * All rights reserved. 7 1.1 reinoud * 8 1.1 reinoud * Redistribution and use in source and binary forms, with or without 9 1.1 reinoud * modification, are permitted provided that the following conditions 10 1.1 reinoud * are met: 11 1.1 reinoud * 1. Redistributions of source code must retain the above copyright 12 1.1 reinoud * notice, this list of conditions and the following disclaimer. 13 1.1 reinoud * 2. Redistributions in binary form must reproduce the above copyright 14 1.1 reinoud * notice, this list of conditions and the following disclaimer in the 15 1.1 reinoud * documentation and/or other materials provided with the distribution. 16 1.1 reinoud * 3. All advertising materials mentioning features or use of this software 17 1.1 reinoud * must display the following acknowledgement: 18 1.1 reinoud * This product includes software developed by Mark Brinicombe 19 1.1 reinoud * 4. The name of the company nor the name of the author may be used to 20 1.1 reinoud * endorse or promote products derived from this software without specific 21 1.1 reinoud * prior written permission. 22 1.1 reinoud * 23 1.1 reinoud * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 24 1.1 reinoud * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 1.1 reinoud * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 1.1 reinoud * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE 27 1.1 reinoud * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 1.1 reinoud * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 1.1 reinoud * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 1.1 reinoud * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 1.1 reinoud * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 1.1 reinoud * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 33 1.1 reinoud * THE POSSIBILITY OF SUCH DAMAGE. 34 1.1 reinoud * 35 1.1 reinoud * RiscBSD kernel project 36 1.1 reinoud * 37 1.1 reinoud * vidc20.c 38 1.1 reinoud * 39 1.1 reinoud * VIDC20 driver 40 1.1 reinoud * 41 1.1 reinoud * Created : 22/02/97 42 1.1 reinoud */ 43 1.1 reinoud 44 1.1 reinoud #include <sys/cdefs.h> 45 1.19 thorpej __KERNEL_RCSID(0, "$NetBSD: vidc20.c,v 1.19 2021/08/07 16:18:44 thorpej Exp $"); 46 1.9 lukem 47 1.1 reinoud #include <sys/types.h> 48 1.1 reinoud #include <sys/param.h> 49 1.1 reinoud #include <sys/systm.h> 50 1.1 reinoud #include <sys/device.h> 51 1.1 reinoud 52 1.16 dyoung #include <sys/bus.h> 53 1.1 reinoud #include <arm/iomd/vidc.h> 54 1.1 reinoud #include <machine/io.h> 55 1.1 reinoud #include <arm/iomd/iomdreg.h> 56 1.1 reinoud #include <arm/iomd/iomdvar.h> 57 1.1 reinoud #include <arm/mainbus/mainbus.h> 58 1.1 reinoud 59 1.1 reinoud #include "locators.h" 60 1.1 reinoud 61 1.1 reinoud struct vidc20_softc { 62 1.17 skrll device_t sc_dev; 63 1.1 reinoud bus_space_tag_t sc_iot; 64 1.1 reinoud }; 65 1.1 reinoud 66 1.17 skrll static int vidcmatch(device_t , cfdata_t , void *); 67 1.17 skrll static void vidcattach(device_t , device_t , void *); 68 1.17 skrll static int vidcsearch(device_t , cfdata_t , const int *, void *); 69 1.1 reinoud 70 1.1 reinoud /* 71 1.4 bjh21 * vidc_base gives the base of the VIDC chip in memory; this is for 72 1.4 bjh21 * the rest isnt busspaceified yet. Initialised with VIDC_BASE for 73 1.4 bjh21 * backwards compatibility. 74 1.1 reinoud */ 75 1.4 bjh21 int *vidc_base = (int *)VIDC_BASE; 76 1.1 reinoud 77 1.1 reinoud 78 1.1 reinoud /* 79 1.14 lukem * vidc_fref is the reference frequency in MHz of the detected VIDC 80 1.4 bjh21 * (dependent on IOMD/IOC) 81 1.1 reinoud * XXX default is RPC600 ? 82 1.1 reinoud */ 83 1.1 reinoud int vidc_fref = 24000000; 84 1.1 reinoud 85 1.1 reinoud 86 1.17 skrll CFATTACH_DECL_NEW(vidc, sizeof (struct vidc20_softc), 87 1.8 thorpej vidcmatch, vidcattach, NULL, NULL); 88 1.1 reinoud 89 1.1 reinoud /* 90 1.1 reinoud * vidcmatch() 91 1.1 reinoud * 92 1.1 reinoud * VIDC20 is a write only device so we cannot probe it 93 1.1 reinoud * We must assume things are ok. 94 1.1 reinoud */ 95 1.1 reinoud static int 96 1.17 skrll vidcmatch(device_t parent, cfdata_t cf, void *aux) 97 1.1 reinoud { 98 1.1 reinoud 99 1.15 bjh21 return 1; 100 1.1 reinoud } 101 1.1 reinoud 102 1.1 reinoud /* 103 1.1 reinoud * vidcsearch() 104 1.1 reinoud * 105 1.1 reinoud * search routine used during the config of children 106 1.1 reinoud */ 107 1.1 reinoud 108 1.1 reinoud static int 109 1.17 skrll vidcsearch(device_t parent, cfdata_t cf, const int *ldesc, void *aux) 110 1.1 reinoud { 111 1.3 bjh21 112 1.18 thorpej if (config_probe(parent, cf, NULL)) 113 1.19 thorpej config_attach(parent, cf, NULL, NULL, CFARGS_NONE); 114 1.1 reinoud 115 1.15 bjh21 return 0; 116 1.1 reinoud } 117 1.1 reinoud 118 1.1 reinoud /* 119 1.1 reinoud * vidcattach() 120 1.1 reinoud * 121 1.1 reinoud * Configure all the child devices of the VIDC 122 1.1 reinoud */ 123 1.1 reinoud static void 124 1.17 skrll vidcattach(device_t parent, device_t self, void *aux) 125 1.1 reinoud { 126 1.17 skrll struct vidc20_softc *sc = device_private(self); 127 1.1 reinoud struct mainbus_attach_args *mb = aux; 128 1.1 reinoud 129 1.17 skrll sc->sc_dev = self; 130 1.1 reinoud sc->sc_iot = mb->mb_iot; 131 1.1 reinoud 132 1.2 bjh21 /* 133 1.2 bjh21 * Since the VIDC is write-only, infer the type of VIDC from the 134 1.2 bjh21 * type of IOMD. 135 1.2 bjh21 */ 136 1.1 reinoud switch (IOMD_ID) { 137 1.1 reinoud case ARM7500_IOC_ID: 138 1.17 skrll aprint_normal(": ARM7500 video and sound macrocell\n"); 139 1.2 bjh21 vidc_fref = 32000000; 140 1.2 bjh21 break; 141 1.1 reinoud case ARM7500FE_IOC_ID: 142 1.17 skrll aprint_normal(": ARM7500FE video and sound macrocell\n"); 143 1.1 reinoud vidc_fref = 32000000; 144 1.1 reinoud break; 145 1.1 reinoud default: /* XXX default? */ 146 1.1 reinoud case RPC600_IOMD_ID: 147 1.17 skrll aprint_normal(": VIDC20\n"); 148 1.1 reinoud vidc_fref = 24000000; 149 1.1 reinoud break; 150 1.15 bjh21 } 151 1.1 reinoud 152 1.18 thorpej config_search(self, NULL, 153 1.19 thorpej CFARGS(.search = vidcsearch)); 154 1.1 reinoud } 155 1.1 reinoud 156 1.1 reinoud /* End of vidc20.c */ 157