Home | History | Annotate | Line # | Download | only in mainbus
pioc.c revision 1.6.2.5
      1  1.6.2.5    skrll /*	$NetBSD: pioc.c,v 1.6.2.5 2005/11/10 13:48:21 skrll 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 OR IMPLIED
     24      1.1  reinoud  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     25      1.1  reinoud  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26      1.1  reinoud  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     27      1.1  reinoud  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     28      1.1  reinoud  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     29      1.1  reinoud  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30      1.1  reinoud  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31      1.1  reinoud  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32      1.1  reinoud  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33      1.1  reinoud  * SUCH DAMAGE.
     34      1.1  reinoud  *
     35      1.1  reinoud  * Peripheral I/O controller - wd, fd, com, lpt Combo chip
     36      1.1  reinoud  *
     37      1.1  reinoud  * Parent device for combo chip I/O drivers
     38      1.1  reinoud  * Currently supports the SMC FDC37GT66[56] controllers.
     39      1.1  reinoud  */
     40      1.1  reinoud 
     41      1.1  reinoud /*#define PIOC_DEBUG*/
     42      1.1  reinoud 
     43  1.6.2.1    skrll #include <sys/cdefs.h>
     44  1.6.2.5    skrll __KERNEL_RCSID(0, "$NetBSD: pioc.c,v 1.6.2.5 2005/11/10 13:48:21 skrll Exp $");
     45  1.6.2.1    skrll 
     46      1.1  reinoud #include <sys/param.h>
     47      1.1  reinoud #include <sys/systm.h>
     48      1.1  reinoud #include <sys/kernel.h>
     49      1.1  reinoud #include <sys/device.h>
     50      1.1  reinoud 
     51      1.1  reinoud #include <machine/bus.h>
     52      1.1  reinoud #include <arm/mainbus/mainbus.h>
     53      1.1  reinoud #include <acorn32/mainbus/piocreg.h>
     54      1.1  reinoud #include <acorn32/mainbus/piocvar.h>
     55      1.1  reinoud 
     56      1.1  reinoud #include "locators.h"
     57      1.1  reinoud 
     58      1.1  reinoud /*
     59      1.1  reinoud  * PIOC device.
     60      1.1  reinoud  *
     61      1.1  reinoud  * This probes and attaches the top level pioc device.
     62      1.1  reinoud  * It then configures any children of the pioc device.
     63      1.1  reinoud  */
     64      1.1  reinoud 
     65      1.1  reinoud /*
     66      1.1  reinoud  * pioc softc structure.
     67      1.1  reinoud  *
     68      1.1  reinoud  * Contains the device node, bus space tag, handle and address along with
     69      1.1  reinoud  * other global information such as id and config registers.
     70      1.1  reinoud  */
     71      1.1  reinoud 
     72      1.1  reinoud struct pioc_softc {
     73      1.1  reinoud 	struct device		sc_dev;			/* device node */
     74      1.1  reinoud 	bus_space_tag_t		sc_iot;			/* bus tag */
     75      1.1  reinoud 	bus_space_handle_t	sc_ioh;			/* bus handle */
     76      1.1  reinoud 	bus_addr_t		sc_iobase;		/* IO base address */
     77      1.1  reinoud  	int			sc_id;			/* chip ID */
     78      1.1  reinoud 	int			sc_config[PIOC_CM_REGS];/* config regs */
     79      1.1  reinoud };
     80      1.1  reinoud 
     81      1.1  reinoud /*
     82      1.1  reinoud  * The pioc device is a parent to the com device.
     83      1.1  reinoud  * This means that it needs to provide a bus space tag for
     84      1.1  reinoud  * a serial console.
     85      1.1  reinoud  *
     86      1.1  reinoud  * XXX - This is not fully tested yet.
     87      1.1  reinoud  */
     88      1.1  reinoud 
     89      1.1  reinoud extern struct bus_space mainbus_bs_tag;
     90      1.1  reinoud bus_space_tag_t comconstag = &mainbus_bs_tag;
     91      1.1  reinoud 
     92      1.1  reinoud /* Prototypes for functions */
     93      1.1  reinoud 
     94      1.1  reinoud static int  piocmatch	 __P((struct device *, struct cfdata *, void *));
     95      1.1  reinoud static void piocattach	 __P((struct device *, struct device *, void *));
     96      1.1  reinoud static int  piocprint	 __P((void *aux, const char *name));
     97      1.1  reinoud #if 0
     98      1.1  reinoud static int  piocsearch	 __P((struct device *, struct cfdata *, void *));
     99      1.1  reinoud #endif
    100  1.6.2.5    skrll static int  piocsubmatch __P((struct device *, struct cfdata *,
    101  1.6.2.5    skrll 			      const int *, void *));
    102      1.1  reinoud static void piocgetid	 __P((bus_space_tag_t iot, bus_space_handle_t ioh,
    103      1.1  reinoud 			      int config_entry, int *id, int *revision));
    104      1.1  reinoud 
    105      1.1  reinoud /* device attach and driver structure */
    106      1.1  reinoud 
    107      1.4  thorpej CFATTACH_DECL(pioc, sizeof(struct pioc_softc),
    108      1.5  thorpej     piocmatch, piocattach, NULL, NULL);
    109      1.1  reinoud 
    110      1.1  reinoud /*
    111      1.1  reinoud  * void piocgetid(bus_space_tag_t iot, bus_space_handle_t ioh,
    112      1.1  reinoud  *                int config_entry, int *id, int *revision)
    113      1.1  reinoud  *
    114      1.1  reinoud  * Enter config mode and return the id and revision
    115      1.1  reinoud  */
    116      1.1  reinoud 
    117      1.1  reinoud static void
    118      1.1  reinoud piocgetid(iot, ioh, config_entry, id, revision)
    119      1.1  reinoud 	bus_space_tag_t iot;
    120      1.1  reinoud 	bus_space_handle_t ioh;
    121      1.1  reinoud 	int config_entry;
    122      1.1  reinoud 	int *id;
    123      1.1  reinoud 	int *revision;
    124      1.1  reinoud {
    125      1.1  reinoud 	/*
    126      1.1  reinoud 	 * Put the chip info configuration mode and read the ID and revision
    127      1.1  reinoud 	 */
    128      1.1  reinoud 	bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, config_entry);
    129      1.1  reinoud 	bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, config_entry);
    130      1.1  reinoud 
    131      1.1  reinoud 	bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, PIOC_CM_CRD);
    132      1.1  reinoud 	*id = bus_space_read_1(iot, ioh, PIOC_CM_DATA_REG);
    133      1.1  reinoud 	bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, PIOC_CM_CRE);
    134      1.1  reinoud 	*revision = bus_space_read_1(iot, ioh, PIOC_CM_DATA_REG);
    135      1.1  reinoud 
    136      1.1  reinoud 	bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, PIOC_CM_EXIT);
    137      1.1  reinoud }
    138      1.1  reinoud 
    139      1.1  reinoud /*
    140      1.1  reinoud  * int piocmatch(struct device *parent, struct cfdata *cf, void *aux)
    141      1.1  reinoud  *
    142      1.1  reinoud  * Put the controller into config mode and probe the ID to see if
    143      1.1  reinoud  * we recognise it.
    144      1.1  reinoud  *
    145      1.1  reinoud  * XXX - INTRUSIVE PROBE
    146      1.1  reinoud  */
    147      1.1  reinoud 
    148      1.1  reinoud static int
    149      1.1  reinoud piocmatch(parent, cf, aux)
    150      1.1  reinoud 	struct device *parent;
    151      1.1  reinoud 	struct cfdata *cf;
    152      1.1  reinoud 	void *aux;
    153      1.1  reinoud {
    154      1.1  reinoud 	struct mainbus_attach_args *mb = aux;
    155      1.1  reinoud 	bus_space_tag_t iot;
    156      1.1  reinoud 	bus_space_handle_t ioh;
    157      1.1  reinoud 	int id, rev;
    158      1.1  reinoud 	int rv = 1;
    159      1.1  reinoud 
    160      1.1  reinoud 	/* We need a base address */
    161      1.1  reinoud 	if (mb->mb_iobase == MAINBUSCF_BASE_DEFAULT)
    162      1.1  reinoud 		return(0);
    163      1.1  reinoud 
    164      1.1  reinoud 	iot = mb->mb_iot;
    165      1.1  reinoud 	if (bus_space_map(iot, mb->mb_iobase, PIOC_SIZE, 0, &ioh))
    166      1.1  reinoud 		return(0);
    167      1.1  reinoud 
    168      1.1  reinoud 	mb->mb_iosize = PIOC_SIZE;
    169      1.1  reinoud 
    170      1.1  reinoud 	piocgetid(iot, ioh, PIOC_CM_ENTER_665, &id, &rev);
    171      1.1  reinoud 	if (id == PIOC_CM_ID_665)
    172      1.1  reinoud 		goto out;
    173      1.1  reinoud 
    174      1.1  reinoud 	piocgetid(iot, ioh, PIOC_CM_ENTER_666, &id, &rev);
    175      1.1  reinoud 	if (id == PIOC_CM_ID_666)
    176      1.1  reinoud 		goto out;
    177      1.1  reinoud 
    178      1.1  reinoud 	rv = 0;
    179      1.1  reinoud 
    180      1.1  reinoud out:
    181      1.1  reinoud 	bus_space_unmap(iot, ioh, PIOC_SIZE);
    182      1.1  reinoud 	return(rv);
    183      1.1  reinoud }
    184      1.1  reinoud 
    185      1.1  reinoud /*
    186      1.1  reinoud  * int piocprint(void *aux, const char *name)
    187      1.1  reinoud  *
    188      1.1  reinoud  * print routine used during child configuration
    189      1.1  reinoud  */
    190      1.1  reinoud 
    191      1.1  reinoud static int
    192      1.1  reinoud piocprint(aux, name)
    193      1.1  reinoud 	void *aux;
    194      1.1  reinoud 	const char *name;
    195      1.1  reinoud {
    196      1.1  reinoud 	struct pioc_attach_args *pa = aux;
    197      1.1  reinoud 
    198      1.1  reinoud 	if (!name) {
    199      1.1  reinoud 		if (pa->pa_offset)
    200      1.6  thorpej 			aprint_normal(" offset 0x%x", pa->pa_offset >> 2);
    201      1.1  reinoud 		if (pa->pa_iosize > 1)
    202      1.6  thorpej 			aprint_normal("-0x%x",
    203      1.6  thorpej 			    ((pa->pa_offset >> 2) + pa->pa_iosize) - 1);
    204      1.1  reinoud 		if (pa->pa_irq != -1)
    205      1.6  thorpej 			aprint_normal(" irq %d", pa->pa_irq);
    206      1.1  reinoud 		if (pa->pa_drq != -1)
    207      1.6  thorpej 			aprint_normal(" drq 0x%08x", pa->pa_drq);
    208      1.1  reinoud 	}
    209      1.1  reinoud 
    210      1.1  reinoud /* XXX print flags */
    211      1.1  reinoud 	return (QUIET);
    212      1.1  reinoud }
    213      1.1  reinoud 
    214      1.1  reinoud #if 0
    215      1.1  reinoud /*
    216      1.1  reinoud  * int piocsearch(struct device *parent, struct cfdata *cf, void *aux)
    217      1.1  reinoud  *
    218      1.1  reinoud  * search function used to probe and attach the child devices.
    219      1.1  reinoud  *
    220      1.1  reinoud  * Note: since the offsets of the devices need to be specified in the
    221      1.1  reinoud  * config file we ignore the FSTAT_STAR.
    222      1.1  reinoud  */
    223      1.1  reinoud 
    224      1.1  reinoud static int
    225  1.6.2.5    skrll piocsearch(parent, cf, ldesc, aux)
    226      1.1  reinoud 	struct device *parent;
    227      1.1  reinoud 	struct cfdata *cf;
    228  1.6.2.5    skrll 	const int *ldesc;
    229      1.1  reinoud 	void *aux;
    230      1.1  reinoud {
    231      1.1  reinoud 	struct pioc_softc *sc = (struct pioc_softc *)parent;
    232      1.1  reinoud 	struct pioc_attach_args pa;
    233      1.1  reinoud 	int tryagain;
    234      1.1  reinoud 
    235      1.1  reinoud 	do {
    236      1.1  reinoud 		pa.pa_name = NULL;
    237      1.1  reinoud 		pa.pa_iobase = sc->sc_iobase;
    238      1.1  reinoud 		pa.pa_iosize = 0;
    239      1.1  reinoud 		pa.pa_iot = sc->sc_iot;
    240      1.1  reinoud 		if (cf->cf_loc[PIOCCF_OFFSET] == PIOCCF_OFFSET_DEFAULT) {
    241      1.1  reinoud 			pa.pa_offset = PIOCCF_OFFSET_DEFAULT;
    242      1.1  reinoud 			pa.pa_drq = PIOCCF_DACK_DEFAULT;
    243      1.1  reinoud 			pa.pa_irq = PIOCCF_IRQ_DEFAULT;
    244      1.1  reinoud 		} else {
    245      1.1  reinoud 			pa.pa_offset = (cf->cf_loc[PIOCCF_OFFSET] << 2);
    246      1.1  reinoud 			pa.pa_drq = cf->cf_loc[PIOCCF_DACK];
    247      1.1  reinoud 			pa.pa_irq = cf->cf_loc[PIOCCF_IRQ];
    248      1.1  reinoud 		}
    249      1.1  reinoud 
    250      1.1  reinoud 		tryagain = 0;
    251      1.2  thorpej 		if (config_match(parent, cf, &pa) > 0) {
    252      1.1  reinoud 			config_attach(parent, cf, &pa, piocprint);
    253      1.1  reinoud /*			tryagain = (cf->cf_fstate == FSTATE_STAR);*/
    254      1.1  reinoud 		}
    255      1.1  reinoud 	} while (tryagain);
    256      1.1  reinoud 
    257      1.1  reinoud 	return (0);
    258      1.1  reinoud }
    259      1.1  reinoud #endif
    260      1.1  reinoud 
    261      1.1  reinoud /*
    262      1.1  reinoud  * int piocsubmatch(struct device *parent, struct cfdata *cf, void *aux)
    263      1.1  reinoud  *
    264      1.1  reinoud  * search function used to probe and attach the child devices.
    265      1.1  reinoud  *
    266      1.1  reinoud  * Note: since the offsets of the devices need to be specified in the
    267      1.1  reinoud  * config file we ignore the FSTAT_STAR.
    268      1.1  reinoud  */
    269      1.1  reinoud 
    270      1.1  reinoud static int
    271  1.6.2.5    skrll piocsubmatch(parent, cf, ldesc, aux)
    272      1.1  reinoud 	struct device *parent;
    273      1.1  reinoud 	struct cfdata *cf;
    274  1.6.2.5    skrll 	const int *ldesc;
    275      1.1  reinoud 	void *aux;
    276      1.1  reinoud {
    277      1.1  reinoud 	struct pioc_attach_args *pa = aux;
    278      1.1  reinoud 	int tryagain;
    279      1.1  reinoud 
    280  1.6.2.4    skrll 	if ((pa->pa_offset >> 2) != cf->cf_loc[PIOCCF_OFFSET])
    281      1.1  reinoud 		return(0);
    282      1.1  reinoud 	do {
    283      1.1  reinoud 		if (pa->pa_drq == -1)
    284  1.6.2.4    skrll 			pa->pa_drq = cf->cf_loc[PIOCCF_DACK];
    285      1.1  reinoud 		if (pa->pa_irq == -1)
    286  1.6.2.4    skrll 			pa->pa_irq = cf->cf_loc[PIOCCF_IRQ];
    287      1.1  reinoud 		tryagain = 0;
    288      1.2  thorpej 		if (config_match(parent, cf, pa) > 0) {
    289      1.1  reinoud 			config_attach(parent, cf, pa, piocprint);
    290      1.1  reinoud /*			tryagain = (cf->cf_fstate == FSTATE_STAR);*/
    291      1.1  reinoud 		}
    292      1.1  reinoud 	} while (tryagain);
    293      1.1  reinoud 
    294      1.1  reinoud 	return (0);
    295      1.1  reinoud }
    296      1.1  reinoud 
    297      1.1  reinoud /*
    298      1.1  reinoud  * void piocattach(struct device *parent, struct device *dev, void *aux)
    299      1.1  reinoud  *
    300      1.1  reinoud  * Identify the PIOC and read the config registers into the softc.
    301      1.1  reinoud  * Search and configure all children
    302      1.1  reinoud  */
    303      1.1  reinoud 
    304      1.1  reinoud static void
    305      1.1  reinoud piocattach(parent, self, aux)
    306      1.1  reinoud 	struct device *parent;
    307      1.1  reinoud 	struct device *self;
    308      1.1  reinoud 	void *aux;
    309      1.1  reinoud {
    310      1.1  reinoud 	struct mainbus_attach_args *mb = aux;
    311      1.1  reinoud 	struct pioc_softc *sc = (struct pioc_softc *)self;
    312      1.1  reinoud 	bus_space_tag_t iot;
    313      1.1  reinoud 	bus_space_handle_t ioh;
    314      1.1  reinoud 	int id, rev;
    315      1.1  reinoud 	int loop;
    316      1.1  reinoud 	struct pioc_attach_args pa;
    317      1.1  reinoud 
    318      1.1  reinoud 	sc->sc_iobase = mb->mb_iobase;
    319      1.1  reinoud 	iot = sc->sc_iot = mb->mb_iot;
    320      1.1  reinoud 
    321      1.1  reinoud 	if (bus_space_map(iot, sc->sc_iobase, PIOC_SIZE, 0, &ioh))
    322      1.1  reinoud 		panic("%s: couldn't map I/O space", self->dv_xname);
    323      1.1  reinoud 	sc->sc_ioh = ioh;
    324      1.1  reinoud 
    325      1.1  reinoud 	piocgetid(iot, ioh, PIOC_CM_ENTER_665, &id, &rev);
    326      1.1  reinoud 	if (id != PIOC_CM_ID_665)
    327      1.1  reinoud 		piocgetid(iot, ioh, PIOC_CM_ENTER_666, &id, &rev);
    328      1.1  reinoud 
    329      1.1  reinoud 	printf("\n%s: ", self->dv_xname);
    330      1.1  reinoud 
    331      1.1  reinoud 	/* Do we recognise it ? */
    332      1.1  reinoud 	switch (id) {
    333      1.1  reinoud 	case PIOC_CM_ID_665:
    334      1.1  reinoud 	case PIOC_CM_ID_666:
    335      1.1  reinoud 		printf("SMC FDC37C6%xGT peripheral controller rev %d\n", id, rev);
    336      1.1  reinoud 		break;
    337      1.1  reinoud 	default:
    338      1.1  reinoud 		printf("Unrecognised peripheral controller id=%2x rev=%2x\n", id, rev);
    339      1.1  reinoud 		return;
    340      1.1  reinoud 	}
    341      1.1  reinoud 
    342      1.1  reinoud 	sc->sc_id = id;
    343      1.1  reinoud 
    344      1.1  reinoud 	/*
    345      1.1  reinoud 	 * Put the chip info configuration mode and save all the registers
    346      1.1  reinoud 	 */
    347      1.1  reinoud 
    348      1.1  reinoud 	switch (id) {
    349      1.1  reinoud 	case PIOC_CM_ID_665:
    350      1.1  reinoud 		bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, PIOC_CM_ENTER_665);
    351      1.1  reinoud 		bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, PIOC_CM_ENTER_665);
    352      1.1  reinoud 		break;
    353      1.1  reinoud 
    354      1.1  reinoud 	case PIOC_CM_ID_666:
    355      1.1  reinoud 		bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, PIOC_CM_ENTER_666);
    356      1.1  reinoud 		bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, PIOC_CM_ENTER_666);
    357      1.1  reinoud 		break;
    358      1.1  reinoud 	}
    359      1.1  reinoud 
    360      1.1  reinoud 	for (loop = 0; loop < PIOC_CM_REGS; ++loop) {
    361      1.1  reinoud 		bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, loop);
    362      1.1  reinoud 		sc->sc_config[loop] = bus_space_read_1(iot, ioh, PIOC_CM_DATA_REG);
    363      1.1  reinoud 	}
    364      1.1  reinoud 
    365      1.1  reinoud 	bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, PIOC_CM_EXIT);
    366      1.1  reinoud 
    367      1.1  reinoud #ifdef PIOC_DEBUG
    368      1.1  reinoud 	printf("%s: ", self->dv_xname);
    369      1.1  reinoud 
    370      1.1  reinoud 	for (loop = 0; loop < PIOC_CM_REGS; ++loop)
    371      1.1  reinoud 		printf("%02x ", sc->sc_config[loop]);
    372      1.1  reinoud 	printf("\n");
    373      1.1  reinoud #endif
    374      1.1  reinoud 
    375      1.1  reinoud 	/*
    376      1.1  reinoud 	 * Ok as yet we cannot do specific config_found() calls
    377      1.1  reinoud 	 * for the children yet. This is because the pioc device does
    378      1.1  reinoud 	 * not know the interrupt numbers to use.
    379      1.1  reinoud 	 * Eventually this information will have to be provided by the
    380      1.1  reinoud 	 * riscpc specific code.
    381  1.6.2.5    skrll 	 * Until then just do a config_search_ia() and pick the info up
    382      1.1  reinoud 	 * from the cfdata.
    383      1.1  reinoud 	 * Note the child devices require some modifications as well.
    384      1.1  reinoud 	 */
    385      1.1  reinoud 
    386      1.1  reinoud 	/*
    387      1.1  reinoud 	 * Ok Now configure the child devices of the pioc device
    388      1.1  reinoud 	 * Use the pioc config registers to determine the addressing
    389      1.1  reinoud 	 * of the children
    390      1.1  reinoud 	 */
    391      1.1  reinoud 
    392      1.1  reinoud 	/*
    393      1.1  reinoud 	 * Start by configuring the IDE controller
    394      1.1  reinoud 	 */
    395      1.1  reinoud 
    396      1.1  reinoud 	if (sc->sc_config[PIOC_CM_CR0] & PIOC_WDC_ENABLE) {
    397      1.1  reinoud 		pa.pa_name = "wdc";
    398      1.1  reinoud 		pa.pa_iobase = sc->sc_iobase;
    399      1.1  reinoud 		pa.pa_iosize = 0;
    400      1.1  reinoud 		pa.pa_iot = iot;
    401      1.1  reinoud 		if (sc->sc_config[PIOC_CM_CR5] & PIOC_WDC_SECONDARY)
    402      1.1  reinoud 			pa.pa_offset = (PIOC_WDC_SECONDARY_OFFSET << 2);
    403      1.1  reinoud 		else
    404      1.1  reinoud 			pa.pa_offset = (PIOC_WDC_PRIMARY_OFFSET << 2);
    405      1.1  reinoud 		pa.pa_drq = -1;
    406      1.1  reinoud 		pa.pa_irq = -1;
    407  1.6.2.5    skrll 		config_found_sm_loc(self, "pioc", NULL, &pa, piocprint,
    408  1.6.2.5    skrll 				    piocsubmatch);
    409      1.1  reinoud 	}
    410      1.1  reinoud 
    411      1.1  reinoud 	/*
    412      1.1  reinoud 	 * Next configure the floppy controller
    413      1.1  reinoud 	 */
    414      1.1  reinoud 
    415      1.1  reinoud 	if (sc->sc_config[PIOC_CM_CR0] & PIOC_FDC_ENABLE) {
    416      1.1  reinoud 		pa.pa_name = "fdc";
    417      1.1  reinoud 		pa.pa_iobase = sc->sc_iobase;
    418      1.1  reinoud 		pa.pa_iosize = 0;
    419      1.1  reinoud 		pa.pa_iot = iot;
    420      1.1  reinoud 		if (sc->sc_config[PIOC_CM_CR5] & PIOC_FDC_SECONDARY)
    421      1.1  reinoud 			pa.pa_offset = (PIOC_FDC_SECONDARY_OFFSET << 2);
    422      1.1  reinoud 		else
    423      1.1  reinoud 			pa.pa_offset = (PIOC_FDC_PRIMARY_OFFSET << 2);
    424      1.1  reinoud 		pa.pa_drq = -1;
    425      1.1  reinoud 		pa.pa_irq = -1;
    426  1.6.2.5    skrll 		config_found_sm_loc(self, "pioc", NULL, &pa, piocprint,
    427  1.6.2.5    skrll 				    piocsubmatch);
    428      1.1  reinoud 	}
    429      1.1  reinoud 
    430      1.1  reinoud 	/*
    431      1.1  reinoud 	 * Next configure the serial ports
    432      1.1  reinoud 	 */
    433      1.1  reinoud 
    434      1.1  reinoud 	/*
    435      1.1  reinoud 	 * XXX - There is a deficiency in the serial configuration
    436      1.1  reinoud 	 * If the PIOC has the serial ports configured for COM3 and COM4
    437      1.1  reinoud 	 * the standard COM3 and COM4 addresses are assumed rather than
    438      1.1  reinoud 	 * examining CR1 to determine the COM3 and COM4 addresses.
    439      1.1  reinoud 	 */
    440      1.1  reinoud 
    441      1.1  reinoud 	if (sc->sc_config[PIOC_CM_CR2] & PIOC_UART1_ENABLE) {
    442      1.1  reinoud 		pa.pa_name = "com";
    443      1.1  reinoud 		pa.pa_iobase = sc->sc_iobase;
    444      1.1  reinoud 		pa.pa_iosize = 0;
    445      1.1  reinoud 		pa.pa_iot = iot;
    446      1.1  reinoud 		switch (sc->sc_config[PIOC_CM_CR2] & PIOC_UART1_ADDR_MASK) {
    447      1.1  reinoud 		case PIOC_UART1_ADDR_COM1:
    448      1.1  reinoud 			pa.pa_offset = (PIOC_COM1_OFFSET << 2);
    449      1.1  reinoud 			break;
    450      1.1  reinoud 		case PIOC_UART1_ADDR_COM2:
    451      1.1  reinoud 			pa.pa_offset = (PIOC_COM2_OFFSET << 2);
    452      1.1  reinoud 			break;
    453      1.1  reinoud 		case PIOC_UART1_ADDR_COM3:
    454      1.1  reinoud 			pa.pa_offset = (PIOC_COM3_OFFSET << 2);
    455      1.1  reinoud 			break;
    456      1.1  reinoud 		case PIOC_UART1_ADDR_COM4:
    457      1.1  reinoud 			pa.pa_offset = (PIOC_COM4_OFFSET << 2);
    458      1.1  reinoud 			break;
    459      1.1  reinoud 		}
    460      1.1  reinoud 		pa.pa_drq = -1;
    461      1.1  reinoud 		pa.pa_irq = -1;
    462  1.6.2.5    skrll 		config_found_sm_loc(self, "pioc", NULL, &pa, piocprint,
    463  1.6.2.5    skrll 				    piocsubmatch);
    464      1.1  reinoud 	}
    465      1.1  reinoud 
    466      1.1  reinoud 	if (sc->sc_config[PIOC_CM_CR2] & PIOC_UART2_ENABLE) {
    467      1.1  reinoud 		pa.pa_name = "com";
    468      1.1  reinoud 		pa.pa_iobase = sc->sc_iobase;
    469      1.1  reinoud 		pa.pa_iosize = 0;
    470      1.1  reinoud 		pa.pa_iot = iot;
    471      1.1  reinoud 		switch (sc->sc_config[PIOC_CM_CR2] & PIOC_UART2_ADDR_MASK) {
    472      1.1  reinoud 		case PIOC_UART2_ADDR_COM1:
    473      1.1  reinoud 			pa.pa_offset = (PIOC_COM1_OFFSET << 2);
    474      1.1  reinoud 			break;
    475      1.1  reinoud 		case PIOC_UART2_ADDR_COM2:
    476      1.1  reinoud 			pa.pa_offset = (PIOC_COM2_OFFSET << 2);
    477      1.1  reinoud 			break;
    478      1.1  reinoud 		case PIOC_UART2_ADDR_COM3:
    479      1.1  reinoud 			pa.pa_offset = (PIOC_COM3_OFFSET << 2);
    480      1.1  reinoud 			break;
    481      1.1  reinoud 		case PIOC_UART2_ADDR_COM4:
    482      1.1  reinoud 			pa.pa_offset = (PIOC_COM4_OFFSET << 2);
    483      1.1  reinoud 			break;
    484      1.1  reinoud 		}
    485      1.1  reinoud 		pa.pa_drq = -1;
    486      1.1  reinoud 		pa.pa_irq = -1;
    487  1.6.2.5    skrll 		config_found_sm_loc(self, "pioc", NULL, &pa, piocprint,
    488  1.6.2.5    skrll 				    piocsubmatch);
    489      1.1  reinoud 	}
    490      1.1  reinoud 
    491      1.1  reinoud 	/*
    492      1.1  reinoud 	 * Next configure the printer port
    493      1.1  reinoud 	 */
    494      1.1  reinoud 
    495      1.1  reinoud 	if ((sc->sc_config[PIOC_CM_CR1] & PIOC_LPT_ADDR_MASK) != PIOC_LPT_ADDR_DISABLE) {
    496      1.1  reinoud 		pa.pa_name = "lpt";
    497      1.1  reinoud 		pa.pa_iobase = sc->sc_iobase;
    498      1.1  reinoud 		pa.pa_iosize = 0;
    499      1.1  reinoud 		pa.pa_iot = iot;
    500      1.1  reinoud 		switch (sc->sc_config[PIOC_CM_CR1] & PIOC_LPT_ADDR_MASK) {
    501      1.1  reinoud 		case PIOC_LPT_ADDR_1:
    502      1.1  reinoud 			pa.pa_offset = (PIOC_LPT1_OFFSET << 2);
    503      1.1  reinoud 			break;
    504      1.1  reinoud 		case PIOC_LPT_ADDR_2:
    505      1.1  reinoud 			pa.pa_offset = (PIOC_LPT2_OFFSET << 2);
    506      1.1  reinoud 			break;
    507      1.1  reinoud 		case PIOC_LPT_ADDR_3:
    508      1.1  reinoud 			pa.pa_offset = (PIOC_LPT3_OFFSET << 2);
    509      1.1  reinoud 			break;
    510      1.1  reinoud 		}
    511      1.1  reinoud 		pa.pa_drq = -1;
    512      1.1  reinoud 		pa.pa_irq = -1;
    513  1.6.2.5    skrll 		config_found_sm_loc(self, "pioc", NULL, &pa, piocprint,
    514  1.6.2.5    skrll 				    piocsubmatch);
    515      1.1  reinoud 	}
    516      1.1  reinoud 
    517      1.1  reinoud #if 0
    518  1.6.2.5    skrll 	config_search_ia(piocsearch, self, "pioc", NULL);
    519      1.1  reinoud #endif
    520      1.1  reinoud }
    521      1.1  reinoud 
    522      1.1  reinoud /* End of pioc.c */
    523