/*
 * ataints.c -- atari Linux interrupt handling code
 *
 * 5/2/94 Roman Hodek:
 *  Added support for TT interrupts; setup for TT SCU (may someone has
 *  twiddled there and we won't get the right interrupts :-()
 *
 *  Major change: The device-independant code in m68k/ints.c didn't know
 *  about non-autovec ints yet. It hardcoded the number of possible ints to
 *  7 (IRQ1...IRQ7). But the Atari has lots of non-autovec ints! I made the
 *  number of possible ints a constant defined in interrupt.h, which is
 *  47 for the Atari. So we can call add_isr() for all Atari interrupts just
 *  the normal way. Additionally, all vectors >= 48 are initialized to call
 *  trap() instead of inthandler(). This must be changed here, too.
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file README.legal in the main directory of this archive
 * for more details.
 *
 */

#include <linux/types.h>
#include <linux/config.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/traps.h>

#include <asm/system.h>

#include <linux/atarihw.h>
#include <linux/atariints.h>
#include <linux/atari_stdma.h>
#include <linux/bootinfo.h>

/*
 * void atari_init_INTS (void)
 *
 * Parameters:	None
 *
 * Returns:	Nothing
 *
 * This function should be called during kernel startup to initialize
 * the atari IRQ handling routines.
 */


asmlinkage void inthandler(void);
extern void atari_microwire_cmd( int cmd );


extern e_vector	vectors[];


void atari_init_INTS (void)

{	int		i;
	
	/* The device independant code sets all exception vectors >= 48 to 'trap',
	 * not 'inthandler'. On the Atari, vectors 64..111 are used for
	 * non-autovector ints, so we they should jump to the inthandler!
	 */

	for( i = 48; i < 112; ++i )
		vectors[i] = inthandler;

	/* All ints are initialized to do nothing by the device independant code
	   -- no work here */
	
	/* Initialize the MFP(s) */
	
    mfp.vec_adr  = 0x40;	/* Automatic EOI-Mode */
	mfp.int_en_a =		    /* turn off MFP-Ints */
	mfp.int_en_b = 0x00;
	mfp.int_mk_a =			/* no Masking */
	mfp.int_mk_b = 0xff;

	if (boot_info.bi_atari.model == ATARI_TT) {
		tt_mfp.vec_adr  = 0x50;		/* Automatic EOI-Mode */
		tt_mfp.int_en_a =			/* turn off MFP-Ints */
		tt_mfp.int_en_b = 0x00;
		tt_mfp.int_mk_a =			/* no Masking */
		tt_mfp.int_mk_b = 0xff;

		/* For a TT, init the SCU */
		tt_scu.sys_mask = 0x10;		/* enable VBL (for the cursor) and
									 * disable HSYNC interrupts (how
									 * needs them?)  MFP and SCC are
									 * enabled in VME mask
									 */
		tt_scu.vme_mask = 0x60;		/* enable MFP and SCC ints */

		/* Initialize the LM1992 Sound Controller to enable the PSG sound.
		 * This is misplaced here, it should be in a atasound_init(),
		 * that doesn't exist yet.
		 */
		atari_microwire_cmd( MW_LM1992_PSG_HIGH );
	}
	
	stdma_init();

	/* Initialize the PSG: all sounds off, both ports output */
	sound_ym.rd_data_reg_sel = 7;
	sound_ym.wd_data = 0xff;
}


/* dummy mach_add_isr(), we don't need one */

int atari_add_isr( unsigned long source , isrfunc isr , int pri , void *data )

{
	return( 0 );
}
