Home | History | Annotate | Line # | Download | only in arc
      1 /*	$NetBSD: c_nec_jazz.c,v 1.14 2013/12/16 15:46:57 mrg Exp $	*/
      2 
      3 /*-
      4  * Copyright (C) 2000 Shuichiro URATA.  All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  * 3. The name of the author may not be used to endorse or promote products
     15  *    derived from this software without specific prior written permission.
     16  *
     17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27  */
     28 
     29 /*
     30  * for NEC EISA and NEC PCI platforms
     31  */
     32 
     33 #include <sys/cdefs.h>
     34 __KERNEL_RCSID(0, "$NetBSD: c_nec_jazz.c,v 1.14 2013/12/16 15:46:57 mrg Exp $");
     35 
     36 #include <sys/param.h>
     37 #include <sys/systm.h>
     38 #include <sys/device.h>
     39 
     40 #include <machine/autoconf.h>
     41 #include <machine/pio.h>
     42 #include <machine/platform.h>
     43 
     44 #include <dev/isa/isavar.h>
     45 
     46 #include <arc/arc/timervar.h>
     47 #include <arc/jazz/rd94.h>
     48 #include <arc/jazz/jazziovar.h>
     49 #include <arc/jazz/timer_jazziovar.h>
     50 
     51 /*
     52  * chipset-dependent timer routine.
     53  */
     54 
     55 uint32_t timer_nec_jazz_intr(uint32_t, struct clockframe *);
     56 void timer_nec_jazz_init(int);
     57 
     58 struct timer_jazzio_config timer_nec_jazz_conf = {
     59 	MIPS_INT_MASK_3,
     60 	timer_nec_jazz_intr,
     61 	timer_nec_jazz_init,
     62 };
     63 
     64 /* handle jazzio bus clock interrupt */
     65 uint32_t
     66 timer_nec_jazz_intr(uint32_t mask, struct clockframe *cf)
     67 {
     68 
     69 	(void)in32(RD94_SYS_INTSTAT3);
     70 	last_cp0_count = mips3_cp0_count_read();
     71 	hardclock(cf);
     72 	timer_jazzio_ev.ev_count++;
     73 
     74 	return MIPS_INT_MASK_3;	/* Keep clock interrupts enabled */
     75 }
     76 
     77 void
     78 timer_nec_jazz_init(int interval)
     79 {
     80 
     81 	if (interval <= 0)
     82 		panic("timer_nec_jazz_init: invalid interval %d", interval);
     83 
     84 	out32(RD94_SYS_IT_VALUE, interval - 1);
     85 
     86 	/* Enable periodic clock interrupt */
     87 	out32(RD94_SYS_EXT_IMASK, cpu_int_mask);
     88 }
     89 
     90 /*
     91  * chipset-dependent jazzio bus configuration
     92  */
     93 
     94 struct pica_dev nec_rd94_cpu[] = {
     95 	{{ "timer",	-1, 0, },	(void *)RD94_SYS_IT_VALUE, },
     96 	{{ "dallas_rtc", -1, 0, },	(void *)RD94_SYS_CLOCK, },
     97 	{{ "LPT1",	0, 0, },	(void *)RD94_SYS_PAR1, },
     98 	{{ "I82077",	1, 0, },	(void *)RD94_SYS_FLOPPY, },
     99 	{{ "AD1848",	2, 0, },	(void *)RD94_SYS_SOUND,},
    100 	{{ "SONIC",	3, 0, },	(void *)RD94_SYS_SONIC, },
    101 	{{ "NCRC700",	4, 0, },	(void *)RD94_SYS_SCSI0, },
    102 	{{ "NCRC700",	5, 0, },	(void *)RD94_SYS_SCSI1, },
    103 	{{ "I8742",	6, 0, },	(void *)RD94_SYS_KBD, },
    104 	{{ "pms",	7, 0, },	(void *)RD94_SYS_KBD, }, /* XXX */
    105 	{{ "COM1",	8, 0, },	(void *)RD94_SYS_COM1, },
    106 	{{ "COM2",	9, 0, },	(void *)RD94_SYS_COM2, },
    107 	{{ NULL,	-1, 0, },	NULL, },
    108 };
    109 
    110 void
    111 c_nec_jazz_set_intr(uint32_t mask,
    112      uint32_t (*int_hand)(uint32_t, struct clockframe *), int prio)
    113 {
    114 
    115 	arc_set_intr(mask, int_hand, prio);
    116 
    117 	/* Update external interrupt mask but don't enable clock. */
    118 	out32(RD94_SYS_EXT_IMASK, cpu_int_mask & (~MIPS_INT_MASK_3 >> 10));
    119 }
    120 
    121 /*
    122  * common configuration between NEC EISA and PCI platforms
    123  */
    124 void
    125 c_nec_jazz_init(void)
    126 {
    127 
    128 	/* chipset-dependent timer configuration */
    129 	timer_jazzio_conf = &timer_nec_jazz_conf;
    130 
    131 	/* chipset-dependent jazzio bus configuration */
    132 	jazzio_devconfig = nec_rd94_cpu;
    133 }
    134