Home | History | Annotate | Line # | Download | only in alpha
      1 /* $NetBSD: dec_axppci_33.c,v 1.71 2025/03/09 01:06:41 thorpej Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1995, 1996, 1997 Carnegie-Mellon University.
      5  * All rights reserved.
      6  *
      7  * Author: Chris G. Demetriou
      8  *
      9  * Permission to use, copy, modify and distribute this software and
     10  * its documentation is hereby granted, provided that both the copyright
     11  * notice and this permission notice appear in all copies of the
     12  * software, derivative works or modified versions, and any portions
     13  * thereof, and that both notices appear in supporting documentation.
     14  *
     15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     17  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18  *
     19  * Carnegie Mellon requests users of this software to return to
     20  *
     21  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22  *  School of Computer Science
     23  *  Carnegie Mellon University
     24  *  Pittsburgh PA 15213-3890
     25  *
     26  * any improvements or extensions that they make and grant Carnegie the
     27  * rights to redistribute these changes.
     28  */
     29 /*
     30  * Additional Copyright (c) 1997 by Matthew Jacob for NASA/Ames Research Center
     31  */
     32 
     33 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     34 
     35 __KERNEL_RCSID(0, "$NetBSD: dec_axppci_33.c,v 1.71 2025/03/09 01:06:41 thorpej Exp $");
     36 
     37 #include <sys/param.h>
     38 #include <sys/systm.h>
     39 #include <sys/device.h>
     40 
     41 #include <machine/rpb.h>
     42 #include <machine/autoconf.h>
     43 #include <machine/cpuconf.h>
     44 
     45 #include <dev/pci/pcivar.h>
     46 
     47 #include <alpha/pci/lcareg.h>
     48 #include <alpha/pci/lcavar.h>
     49 
     50 void dec_axppci_33_init(void);
     51 static void dec_axppci_33_cons_init(void);
     52 static void dec_axppci_33_device_register(device_t, void *);
     53 
     54 const struct alpha_variation_table dec_axppci_33_variations[] = {
     55 	{ 0, "Alpha PC AXPpci33 (\"NoName\")" },
     56 	{ 0, NULL },
     57 };
     58 
     59 static struct lca_config *lca_preinit(void);
     60 
     61 static struct lca_config *
     62 lca_preinit(void)
     63 {
     64 	extern struct lca_config lca_configuration;
     65 
     66 	lca_init(&lca_configuration);
     67 	return &lca_configuration;
     68 }
     69 
     70 #define	NSIO_PORT  0x26e	/* Hardware enabled option: 0x398 */
     71 #define	NSIO_BASE  0
     72 #define	NSIO_INDEX NSIO_BASE
     73 #define	NSIO_DATA  1
     74 #define	NSIO_SIZE  2
     75 #define	NSIO_CFG0  0
     76 #define	NSIO_CFG1  1
     77 #define	NSIO_CFG2  2
     78 #define	NSIO_IDE_ENABLE 0x40
     79 
     80 void
     81 dec_axppci_33_init(void)
     82 {
     83 	int cfg0val;
     84 	uint64_t variation;
     85 	bus_space_tag_t iot;
     86 	struct lca_config *lcp;
     87 	bus_space_handle_t nsio;
     88 #define	A33_NSIOBARRIER(type) bus_space_barrier(iot, nsio,\
     89 				NSIO_BASE, NSIO_SIZE, (type))
     90 
     91 	platform.family = "DEC AXPpci";
     92 
     93 	if ((platform.model = alpha_dsr_sysname()) == NULL) {
     94 		variation = hwrpb->rpb_variation & SV_ST_MASK;
     95 		if ((platform.model = alpha_variation_name(variation,
     96 		    dec_axppci_33_variations)) == NULL)
     97 			platform.model = alpha_unknown_sysname();
     98 	}
     99 
    100 	platform.iobus = "lca";
    101 	platform.cons_init = dec_axppci_33_cons_init;
    102 	platform.device_register = dec_axppci_33_device_register;
    103 
    104 	lcp = lca_preinit();
    105 	iot = &lcp->lc_iot;
    106 	if (bus_space_map(iot, NSIO_PORT, NSIO_SIZE, 0, &nsio))
    107 		return;
    108 
    109 	bus_space_write_1(iot, nsio, NSIO_INDEX, NSIO_CFG0);
    110 	A33_NSIOBARRIER(BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE);
    111 	cfg0val = bus_space_read_1(iot, nsio, NSIO_DATA);
    112 
    113 	cfg0val |= NSIO_IDE_ENABLE;
    114 
    115 	bus_space_write_1(iot, nsio, NSIO_INDEX, NSIO_CFG0);
    116 	A33_NSIOBARRIER(BUS_SPACE_BARRIER_WRITE);
    117 	bus_space_write_1(iot, nsio, NSIO_DATA, cfg0val);
    118 	A33_NSIOBARRIER(BUS_SPACE_BARRIER_WRITE);
    119 	bus_space_write_1(iot, nsio, NSIO_DATA, cfg0val);
    120 
    121 	/* Leave nsio mapped to catch any accidental port space collisions  */
    122 
    123 	lca_probe_bcache();
    124 }
    125 
    126 static void
    127 dec_axppci_33_cons_init(void)
    128 {
    129 	struct lca_config *lcp;
    130 
    131 	lcp = lca_preinit();
    132 
    133 	pci_consinit(&lcp->lc_pc, &lcp->lc_iot, &lcp->lc_memt,
    134 	    &lcp->lc_iot, &lcp->lc_memt);
    135 }
    136 
    137 static void
    138 dec_axppci_33_device_register(device_t dev, void *aux)
    139 {
    140 	pci_find_bootdev(NULL, dev, aux);
    141 }
    142