1 /* $NetBSD: ibm_machdep.c,v 1.16 2014/03/26 16:01:43 christos Exp $ */ 2 3 /*- 4 * Copyright (c) 2004 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Klaus J. Klein. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #include <sys/param.h> 33 #include <sys/systm.h> 34 35 #include <machine/intr.h> 36 #include <machine/platform.h> 37 38 extern struct genppc_pci_chipset *genppc_pct; 39 40 void pci_intr_fixup_ibm_6015(void); 41 42 void 43 pci_intr_fixup_ibm_6015(void) 44 { 45 struct genppc_pci_chipset_businfo *pbi; 46 prop_dictionary_t dict, sub; 47 prop_number_t intr_num; 48 int i, j; 49 char key[20]; 50 51 /* this works because the 6015 has only 1 PCI bus native */ 52 pbi = SIMPLEQ_FIRST(&genppc_pct->pc_pbi); 53 54 dict = prop_dictionary_create_with_capacity(16); 55 KASSERT(dict != NULL); 56 (void)prop_dictionary_set(pbi->pbi_properties, "prep-pci-intrmap", 57 dict); 58 sub = prop_dictionary_create_with_capacity(4); 59 KASSERT(sub != NULL); 60 61 intr_num = prop_number_create_integer(13); 62 for (j = 0; j < 4; j++) { 63 snprintf(key, sizeof(key), "pin-%c", 'A' + j); 64 prop_dictionary_set(sub, key, intr_num); 65 } 66 prop_object_release(intr_num); 67 prop_dictionary_set(dict, "devfunc-12", sub); 68 prop_object_release(sub); 69 70 /* devices 13-19 all share IRQ 15 */ 71 for (i = 13; i < 20; i++) { 72 sub = prop_dictionary_create_with_capacity(4); 73 intr_num = prop_number_create_integer(15); 74 snprintf(key, sizeof(key), "devfunc-%d", i); 75 for (j = 0; j < 4; j++) { 76 snprintf(key, sizeof(key), "pin-%c", 'A' + j); 77 prop_dictionary_set(sub, key, intr_num); 78 } 79 prop_dictionary_set(dict, key, sub); 80 prop_object_release(intr_num); 81 prop_object_release(sub); 82 } 83 prop_object_release(dict); 84 } 85