patch-2.1.87 linux/arch/m68k/atari/config.c
Next file: linux/arch/m68k/atari/debug.c
Previous file: linux/arch/m68k/atari/atasound.c
Back to the patch index
Back to the overall index
- Lines: 992
- Date:
Thu Feb 12 16:30:12 1998
- Orig file:
v2.1.86/linux/arch/m68k/atari/config.c
- Orig date:
Tue May 13 22:41:02 1997
diff -u --recursive --new-file v2.1.86/linux/arch/m68k/atari/config.c linux/arch/m68k/atari/config.c
@@ -27,35 +27,33 @@
#include <linux/config.h>
#include <linux/types.h>
#include <linux/mm.h>
-#include <linux/mc146818rtc.h>
-#include <linux/kd.h>
-#include <linux/tty.h>
#include <linux/console.h>
-#include <linux/interrupt.h>
#include <linux/init.h>
+#include <linux/delay.h>
#include <asm/bootinfo.h>
#include <asm/setup.h>
#include <asm/atarihw.h>
-#include <asm/atarihdreg.h>
#include <asm/atariints.h>
-
+#include <asm/atari_stram.h>
#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/pgtable.h>
#include <asm/machdep.h>
-#ifdef CONFIG_KGDB
-#include <asm/kgdb.h>
-#endif
-
u_long atari_mch_cookie;
+u_long atari_mch_type = 0;
struct atari_hw_present atari_hw_present;
+u_long atari_switches = 0;
+int atari_dont_touch_floppy_select = 0;
+int atari_rtc_year_offset;
-extern char m68k_debug_device[];
+/* local function prototypes */
+static void atari_reset( void );
+#ifdef CONFIG_ATARI_FLOPPY
+extern void atari_floppy_setup(char *, int *);
+#endif
+static void atari_get_model(char *model);
+static int atari_get_hardware_list(char *buffer);
-static void atari_sched_init(void (*)(int, void *, struct pt_regs *));
/* atari specific keyboard functions */
extern int atari_keyb_init(void);
extern int atari_kbdrate (struct kbd_repeat *);
@@ -68,33 +66,36 @@
extern void atari_enable_irq (unsigned int);
extern void atari_disable_irq (unsigned int);
extern int atari_get_irq_list (char *buf);
-static void atari_get_model(char *model);
-static int atari_get_hardware_list(char *buffer);
-/* atari specific timer functions */
-static unsigned long atari_gettimeoffset (void);
-static void atari_mste_gettod (int *, int *, int *, int *, int *, int *);
-static void atari_gettod (int *, int *, int *, int *, int *, int *);
-static int atari_mste_hwclk (int, struct hwclk_time *);
-static int atari_hwclk (int, struct hwclk_time *);
-static int atari_mste_set_clock_mmss (unsigned long);
-static int atari_set_clock_mmss (unsigned long);
extern void atari_mksound( unsigned int count, unsigned int ticks );
-static void atari_reset( void );
-#ifdef CONFIG_BLK_DEV_FD
-extern int atari_floppy_init (void);
-extern void atari_floppy_setup(char *, int *);
+#ifdef CONFIG_HEARTBEAT
+static void atari_heartbeat( int on );
#endif
extern struct consw fb_con;
-extern struct fb_info *atari_fb_init(long *);
-static void atari_debug_init(void);
-extern void atari_video_setup(char *, int *);
-
-static struct console atari_console_driver;
-
-/* Can be set somewhere, if a SCC master reset has already be done and should
- * not be repeated; used by kgdb */
-int atari_SCC_reset_done = 0;
+/* atari specific timer functions (in time.c) */
+extern void atari_sched_init(void (*)(int, void *, struct pt_regs *));
+extern unsigned long atari_gettimeoffset (void);
+extern void atari_mste_gettod (int *, int *, int *, int *, int *, int *);
+extern void atari_tt_gettod (int *, int *, int *, int *, int *, int *);
+extern int atari_mste_hwclk (int, struct hwclk_time *);
+extern int atari_tt_hwclk (int, struct hwclk_time *);
+extern int atari_mste_set_clock_mmss (unsigned long);
+extern int atari_tt_set_clock_mmss (unsigned long);
+
+/* atari specific debug functions (in debug.c) */
+extern void atari_debug_init(void);
+
+#ifdef CONFIG_MAGIC_SYSRQ
+static char atari_sysrq_xlate[128] =
+ "\000\0331234567890-=\177\t" /* 0x00 - 0x0f */
+ "qwertyuiop[]\r\000as" /* 0x10 - 0x1f */
+ "dfghjkl;'`\000\\zxcv" /* 0x20 - 0x2f */
+ "bnm,./\000\000\000 \000\201\202\203\204\205" /* 0x30 - 0x3f */
+ "\206\207\210\211\212\000\000\000\000\000-\000\000\000+\000"/* 0x40 - 0x4f */
+ "\000\000\000\177\000\000\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */
+ "\000\000\000()/*789456123" /* 0x60 - 0x6f */
+ "0.\r\000\000\000\000\000\000\000\000\000\000\000\000\000"; /* 0x70 - 0x7f */
+#endif
extern void (*kd_mksound)(unsigned int, unsigned int);
@@ -237,18 +238,62 @@
case BI_ATARI_MCH_COOKIE:
atari_mch_cookie = *data;
break;
+ case BI_ATARI_MCH_TYPE:
+ atari_mch_type = *data;
+ break;
default:
unknown = 1;
}
return(unknown);
}
+
+/* Parse the Atari-specific switches= option. */
+__initfunc(void atari_switches_setup( const char *str, unsigned len ))
+{
+ char switches[len+1];
+ char *p;
+ int ovsc_shift;
+
+ /* copy string to local array, strtok works destructively... */
+ strncpy( switches, str, len );
+ switches[len] = 0;
+ atari_switches = 0;
+
+ /* parse the options */
+ for( p = strtok( switches, "," ); p; p = strtok( NULL, "," ) ) {
+ ovsc_shift = 0;
+ if (strncmp( p, "ov_", 3 ) == 0) {
+ p += 3;
+ ovsc_shift = ATARI_SWITCH_OVSC_SHIFT;
+ }
+
+ if (strcmp( p, "ikbd" ) == 0) {
+ /* RTS line of IKBD ACIA */
+ atari_switches |= ATARI_SWITCH_IKBD << ovsc_shift;
+ }
+ else if (strcmp( p, "midi" ) == 0) {
+ /* RTS line of MIDI ACIA */
+ atari_switches |= ATARI_SWITCH_MIDI << ovsc_shift;
+ }
+ else if (strcmp( p, "snd6" ) == 0) {
+ atari_switches |= ATARI_SWITCH_SND6 << ovsc_shift;
+ }
+ else if (strcmp( p, "snd7" ) == 0) {
+ atari_switches |= ATARI_SWITCH_SND7 << ovsc_shift;
+ }
+ }
+}
+
+
/*
* Setup the Atari configuration info
*/
__initfunc(void config_atari(void))
{
+ unsigned short tos_version;
+
memset(&atari_hw_present, 0, sizeof(atari_hw_present));
atari_debug_init();
@@ -267,22 +312,40 @@
mach_get_irq_list = atari_get_irq_list;
mach_gettimeoffset = atari_gettimeoffset;
mach_reset = atari_reset;
-#ifdef CONFIG_BLK_DEV_FD
- mach_floppy_init = atari_floppy_init;
+#ifdef CONFIG_ATARI_FLOPPY
mach_floppy_setup = atari_floppy_setup;
#endif
conswitchp = &fb_con;
- mach_fb_init = atari_fb_init;
mach_max_dma_address = 0xffffff;
- mach_video_setup = atari_video_setup;
kd_mksound = atari_mksound;
+#ifdef CONFIG_MAGIC_SYSRQ
+ mach_sysrq_key = 98; /* HELP */
+ mach_sysrq_shift_state = 8; /* Alt */
+ mach_sysrq_shift_mask = 0xff; /* all modifiers except CapsLock */
+ mach_sysrq_xlate = atari_sysrq_xlate;
+#endif
+#ifdef CONFIG_HEARTBEAT
+ mach_heartbeat = atari_heartbeat;
+#endif
+ /* Set switches as requested by the user */
+ if (atari_switches & ATARI_SWITCH_IKBD)
+ acia.key_ctrl = ACIA_DIV64 | ACIA_D8N1S | ACIA_RHTID;
+ if (atari_switches & ATARI_SWITCH_MIDI)
+ acia.mid_ctrl = ACIA_DIV16 | ACIA_D8N1S | ACIA_RHTID;
+ if (atari_switches & (ATARI_SWITCH_SND6|ATARI_SWITCH_SND7)) {
+ sound_ym.rd_data_reg_sel = 14;
+ sound_ym.wd_data = sound_ym.rd_data_reg_sel |
+ ((atari_switches&ATARI_SWITCH_SND6) ? 0x40 : 0) |
+ ((atari_switches&ATARI_SWITCH_SND7) ? 0x80 : 0);
+ }
+
/* ++bjoern:
* Determine hardware present
*/
printk( "Atari hardware found: " );
- if (is_medusa || is_hades) {
+ if (MACH_IS_MEDUSA || MACH_IS_HADES) {
/* There's no Atari video hardware on the Medusa, but all the
* addresses below generate a DTACK so no bus error occurs! */
}
@@ -324,12 +387,12 @@
ATARIHW_SET(SCSI_DMA);
printk( "TT_SCSI_DMA " );
}
- if (!is_hades && hwreg_present( &st_dma.dma_hi )) {
+ if (!MACH_IS_HADES && hwreg_present( &st_dma.dma_hi )) {
ATARIHW_SET(STND_DMA);
printk( "STND_DMA " );
}
- if (is_medusa || /* The ST-DMA address registers aren't readable
- * on all Medusas, so the test below may fail */
+ if (MACH_IS_MEDUSA || /* The ST-DMA address registers aren't readable
+ * on all Medusas, so the test below may fail */
(hwreg_present( &st_dma.dma_vhi ) &&
(st_dma.dma_vhi = 0x55) && (st_dma.dma_hi = 0xaa) &&
st_dma.dma_vhi == 0x55 && st_dma.dma_hi == 0xaa &&
@@ -346,11 +409,12 @@
ATARIHW_SET(YM_2149);
printk( "YM2149 " );
}
- if (!is_medusa && !is_hades && hwreg_present( &tt_dmasnd.ctrl )) {
+ if (!MACH_IS_MEDUSA && !MACH_IS_HADES &&
+ hwreg_present( &tt_dmasnd.ctrl )) {
ATARIHW_SET(PCM_8BIT);
printk( "PCM " );
}
- if (!is_hades && hwreg_present( &codec.unused5 )) {
+ if (!MACH_IS_HADES && hwreg_present( &codec.unused5 )) {
ATARIHW_SET(CODEC);
printk( "CODEC " );
}
@@ -364,7 +428,7 @@
(tt_scc_dma.dma_ctrl = 0x01, (tt_scc_dma.dma_ctrl & 1) == 1) &&
(tt_scc_dma.dma_ctrl = 0x00, (tt_scc_dma.dma_ctrl & 1) == 0)
#else
- !is_medusa && !is_hades
+ !MACH_IS_MEDUSA && !MACH_IS_HADES
#endif
) {
ATARIHW_SET(SCC_DMA);
@@ -378,7 +442,7 @@
ATARIHW_SET( ST_ESCC );
printk( "ST_ESCC " );
}
- if (is_hades)
+ if (MACH_IS_HADES)
{
ATARIHW_SET( VME );
printk( "VME " );
@@ -393,20 +457,22 @@
ATARIHW_SET(ANALOG_JOY);
printk( "ANALOG_JOY " );
}
- if (!is_hades && hwreg_present( blitter.halftone )) {
+ if (!MACH_IS_HADES && hwreg_present( blitter.halftone )) {
ATARIHW_SET(BLITTER);
printk( "BLITTER " );
}
- if (hwreg_present( (void *)(ATA_HD_BASE+ATA_HD_CMD) )) {
+ if (hwreg_present((void *)0xfff00039)) {
ATARIHW_SET(IDE);
printk( "IDE " );
}
#if 1 /* This maybe wrong */
- if (!is_medusa && !is_hades &&
+ if (!MACH_IS_MEDUSA && !MACH_IS_HADES &&
hwreg_present( &tt_microwire.data ) &&
hwreg_present( &tt_microwire.mask ) &&
(tt_microwire.mask = 0x7ff,
+ udelay(1),
tt_microwire.data = MW_LM1992_PSG_HIGH | MW_LM1992_ADDR,
+ udelay(1),
tt_microwire.data != 0)) {
ATARIHW_SET(MICROWIRE);
while (tt_microwire.mask != 0x7ff) ;
@@ -416,24 +482,24 @@
if (hwreg_present( &tt_rtc.regsel )) {
ATARIHW_SET(TT_CLK);
printk( "TT_CLK " );
- mach_gettod = atari_gettod;
- mach_hwclk = atari_hwclk;
- mach_set_clock_mmss = atari_set_clock_mmss;
+ mach_gettod = atari_tt_gettod;
+ mach_hwclk = atari_tt_hwclk;
+ mach_set_clock_mmss = atari_tt_set_clock_mmss;
}
- if (!is_hades && hwreg_present( &mste_rtc.sec_ones)) {
+ if (!MACH_IS_HADES && hwreg_present( &mste_rtc.sec_ones)) {
ATARIHW_SET(MSTE_CLK);
printk( "MSTE_CLK ");
mach_gettod = atari_mste_gettod;
mach_hwclk = atari_mste_hwclk;
mach_set_clock_mmss = atari_mste_set_clock_mmss;
}
- if (!is_medusa && !is_hades &&
+ if (!MACH_IS_MEDUSA && !MACH_IS_HADES &&
hwreg_present( &dma_wd.fdc_speed ) &&
hwreg_write( &dma_wd.fdc_speed, 0 )) {
ATARIHW_SET(FDCSPEED);
printk( "FDC_SPEED ");
}
- if (!is_hades && !ATARIHW_PRESENT(ST_SCSI)) {
+ if (!MACH_IS_HADES && !ATARIHW_PRESENT(ST_SCSI)) {
ATARIHW_SET(ACSI);
printk( "ACSI " );
}
@@ -491,153 +557,24 @@
: "d0" );
}
-}
-
-__initfunc(static void
-atari_sched_init(void (*timer_routine)(int, void *, struct pt_regs *)))
-{
- /* set Timer C data Register */
- mfp.tim_dt_c = INT_TICKS;
- /* start timer C, div = 1:100 */
- mfp.tim_ct_cd = (mfp.tim_ct_cd & 15) | 0x60;
- /* install interrupt service routine for MFP Timer C */
- request_irq(IRQ_MFP_TIMC, timer_routine, IRQ_TYPE_SLOW,
- "timer", timer_routine);
-}
-
-/* ++andreas: gettimeoffset fixed to check for pending interrupt */
-
-#define TICK_SIZE 10000
-
-/* This is always executed with interrupts disabled. */
-static unsigned long atari_gettimeoffset (void)
-{
- unsigned long ticks, offset = 0;
- /* read MFP timer C current value */
- ticks = mfp.tim_dt_c;
- /* The probability of underflow is less than 2% */
- if (ticks > INT_TICKS - INT_TICKS / 50)
- /* Check for pending timer interrupt */
- if (mfp.int_pn_b & (1 << 5))
- offset = TICK_SIZE;
-
- ticks = INT_TICKS - ticks;
- ticks = ticks * 10000L / INT_TICKS;
-
- return ticks + offset;
-}
-
-
-static void
-mste_read(struct MSTE_RTC *val)
-{
-#define COPY(v) val->v=(mste_rtc.v & 0xf)
- do {
- COPY(sec_ones) ; COPY(sec_tens) ; COPY(min_ones) ;
- COPY(min_tens) ; COPY(hr_ones) ; COPY(hr_tens) ;
- COPY(weekday) ; COPY(day_ones) ; COPY(day_tens) ;
- COPY(mon_ones) ; COPY(mon_tens) ; COPY(year_ones) ;
- COPY(year_tens) ;
- /* prevent from reading the clock while it changed */
- } while (val->sec_ones != (mste_rtc.sec_ones & 0xf));
-#undef COPY
-}
-
-static void
-mste_write(struct MSTE_RTC *val)
-{
-#define COPY(v) mste_rtc.v=val->v
- do {
- COPY(sec_ones) ; COPY(sec_tens) ; COPY(min_ones) ;
- COPY(min_tens) ; COPY(hr_ones) ; COPY(hr_tens) ;
- COPY(weekday) ; COPY(day_ones) ; COPY(day_tens) ;
- COPY(mon_ones) ; COPY(mon_tens) ; COPY(year_ones) ;
- COPY(year_tens) ;
- /* prevent from writing the clock while it changed */
- } while (val->sec_ones != (mste_rtc.sec_ones & 0xf));
-#undef COPY
-}
-
-#define RTC_READ(reg) \
- ({ unsigned char __val; \
- outb(reg,&tt_rtc.regsel); \
- __val = tt_rtc.data; \
- __val; \
- })
-
-#define RTC_WRITE(reg,val) \
- do { \
- outb(reg,&tt_rtc.regsel); \
- tt_rtc.data = (val); \
- } while(0)
-
-
-static void atari_mste_gettod (int *yearp, int *monp, int *dayp,
- int *hourp, int *minp, int *secp)
-{
- int hr24=0, hour;
- struct MSTE_RTC val;
-
- mste_rtc.mode=(mste_rtc.mode | 1);
- hr24=mste_rtc.mon_tens & 1;
- mste_rtc.mode=(mste_rtc.mode & ~1);
-
- mste_read(&val);
- *secp = val.sec_ones + val.sec_tens * 10;
- *minp = val.min_ones + val.min_tens * 10;
- hour = val.hr_ones + val.hr_tens * 10;
- if (!hr24) {
- if (hour == 12 || hour == 12 + 20)
- hour -= 12;
- if (hour >= 20)
- hour += 12 - 20;
- }
- *hourp = hour;
- *dayp = val.day_ones + val.day_tens * 10;
- *monp = val.mon_ones + val.mon_tens * 10;
- *yearp = val.year_ones + val.year_tens * 10 + 80;
-}
-
-
-static void atari_gettod (int *yearp, int *monp, int *dayp,
- int *hourp, int *minp, int *secp)
-{
- unsigned char ctrl;
- unsigned short tos_version;
- int hour, pm;
-
- while (!(RTC_READ(RTC_FREQ_SELECT) & RTC_UIP)) ;
- while (RTC_READ(RTC_FREQ_SELECT) & RTC_UIP) ;
+ /*
+ * On the Hades map the PCI memory, I/O and configuration areas
+ * (0x80000000 - 0xbfffffff).
+ *
+ * Settings: supervisor only, non-cacheable, serialized, read and write.
+ */
- *secp = RTC_READ(RTC_SECONDS);
- *minp = RTC_READ(RTC_MINUTES);
- hour = RTC_READ(RTC_HOURS);
- *dayp = RTC_READ(RTC_DAY_OF_MONTH);
- *monp = RTC_READ(RTC_MONTH);
- *yearp = RTC_READ(RTC_YEAR);
- pm = hour & 0x80;
- hour &= ~0x80;
-
- ctrl = RTC_READ(RTC_CONTROL);
-
- if (!(ctrl & RTC_DM_BINARY)) {
- BCD_TO_BIN(*secp);
- BCD_TO_BIN(*minp);
- BCD_TO_BIN(hour);
- BCD_TO_BIN(*dayp);
- BCD_TO_BIN(*monp);
- BCD_TO_BIN(*yearp);
- }
- if (!(ctrl & RTC_24H)) {
- if (!pm && hour == 12)
- hour = 0;
- else if (pm && hour != 12)
- hour += 12;
+ if (MACH_IS_HADES) {
+ __asm__ __volatile__ ("movel %0,%/d0\n\t"
+ ".chip 68040\n\t"
+ "movec %%d0,%%itt0\n\t"
+ "movec %%d0,%%dtt0\n\t"
+ ".chip 68k\n\t"
+ : /* no outputs */
+ : "g" (0x803fa040)
+ : "d0");
}
- *hourp = hour;
-
- /* Adjust values (let the setup valid) */
/* Fetch tos version at Physical 2 */
/* We my not be able to access this address if the kernel is
@@ -647,403 +584,29 @@
we use the fact that in head.S we have set up a mapping
0xFFxxxxxx -> 0x00xxxxxx, so that the first 16MB is accessible
in the last 16MB of the address space. */
- tos_version = (is_medusa || is_hades) ? 0xfff : *(unsigned short *)0xFF000002;
- *yearp += (tos_version < 0x306) ? 70 : 68;
+ tos_version = (MACH_IS_MEDUSA || MACH_IS_HADES) ?
+ 0xfff : *(unsigned short *)0xff000002;
+ atari_rtc_year_offset = (tos_version < 0x306) ? 70 : 68;
}
-#define HWCLK_POLL_INTERVAL 5
-
-static int atari_mste_hwclk( int op, struct hwclk_time *t )
+#ifdef CONFIG_HEARTBEAT
+static void atari_heartbeat( int on )
{
- int hour, year;
- int hr24=0;
- struct MSTE_RTC val;
-
- mste_rtc.mode=(mste_rtc.mode | 1);
- hr24=mste_rtc.mon_tens & 1;
- mste_rtc.mode=(mste_rtc.mode & ~1);
-
- if (op) {
- /* write: prepare values */
-
- val.sec_ones = t->sec % 10;
- val.sec_tens = t->sec / 10;
- val.min_ones = t->min % 10;
- val.min_tens = t->min / 10;
- hour = t->hour;
- if (!hr24) {
- if (hour > 11)
- hour += 20 - 12;
- if (hour == 0 || hour == 20)
- hour += 12;
- }
- val.hr_ones = hour % 10;
- val.hr_tens = hour / 10;
- val.day_ones = t->day % 10;
- val.day_tens = t->day / 10;
- val.mon_ones = (t->mon+1) % 10;
- val.mon_tens = (t->mon+1) / 10;
- year = t->year - 80;
- val.year_ones = year % 10;
- val.year_tens = year / 10;
- val.weekday = t->wday;
- mste_write(&val);
- mste_rtc.mode=(mste_rtc.mode | 1);
- val.year_ones = (year % 4); /* leap year register */
- mste_rtc.mode=(mste_rtc.mode & ~1);
- }
- else {
- mste_read(&val);
- t->sec = val.sec_ones + val.sec_tens * 10;
- t->min = val.min_ones + val.min_tens * 10;
- hour = val.hr_ones + val.hr_tens * 10;
- if (!hr24) {
- if (hour == 12 || hour == 12 + 20)
- hour -= 12;
- if (hour >= 20)
- hour += 12 - 20;
- }
- t->hour = hour;
- t->day = val.day_ones + val.day_tens * 10;
- t->mon = val.mon_ones + val.mon_tens * 10 - 1;
- t->year = val.year_ones + val.year_tens * 10 + 80;
- t->wday = val.weekday;
- }
- return 0;
-}
+ unsigned char tmp;
+ unsigned long flags;
-static int atari_hwclk( int op, struct hwclk_time *t )
-{
- int sec=0, min=0, hour=0, day=0, mon=0, year=0, wday=0;
- unsigned long flags;
- unsigned short tos_version;
- unsigned char ctrl;
- int pm = 0;
-
- /* Tos version at Physical 2. See above for explanation why we
- cannot use PTOV(2). */
- tos_version = (is_medusa || is_hades) ? 0xfff : *(unsigned short *)0xff000002;
-
- ctrl = RTC_READ(RTC_CONTROL); /* control registers are
- * independent from the UIP */
-
- if (op) {
- /* write: prepare values */
-
- sec = t->sec;
- min = t->min;
- hour = t->hour;
- day = t->day;
- mon = t->mon + 1;
- year = t->year - ((tos_version < 0x306) ? 70 : 68);
- wday = t->wday + (t->wday >= 0);
-
- if (!(ctrl & RTC_24H)) {
- if (hour > 11) {
- pm = 0x80;
- if (hour != 12)
- hour -= 12;
- }
- else if (hour == 0)
- hour = 12;
- }
-
- if (!(ctrl & RTC_DM_BINARY)) {
- BIN_TO_BCD(sec);
- BIN_TO_BCD(min);
- BIN_TO_BCD(hour);
- BIN_TO_BCD(day);
- BIN_TO_BCD(mon);
- BIN_TO_BCD(year);
- if (wday >= 0) BIN_TO_BCD(wday);
- }
- }
+ if (atari_dont_touch_floppy_select)
+ return;
- /* Reading/writing the clock registers is a bit critical due to
- * the regular update cycle of the RTC. While an update is in
- * progress, registers 0..9 shouldn't be touched.
- * The problem is solved like that: If an update is currently in
- * progress (the UIP bit is set), the process sleeps for a while
- * (50ms). This really should be enough, since the update cycle
- * normally needs 2 ms.
- * If the UIP bit reads as 0, we have at least 244 usecs until the
- * update starts. This should be enough... But to be sure,
- * additionally the RTC_SET bit is set to prevent an update cycle.
- */
-
- while( RTC_READ(RTC_FREQ_SELECT) & RTC_UIP ) {
- current->state = TASK_INTERRUPTIBLE;
- current->timeout = jiffies + HWCLK_POLL_INTERVAL;
- schedule();
- }
-
save_flags(flags);
cli();
- RTC_WRITE( RTC_CONTROL, ctrl | RTC_SET );
- if (!op) {
- sec = RTC_READ( RTC_SECONDS );
- min = RTC_READ( RTC_MINUTES );
- hour = RTC_READ( RTC_HOURS );
- day = RTC_READ( RTC_DAY_OF_MONTH );
- mon = RTC_READ( RTC_MONTH );
- year = RTC_READ( RTC_YEAR );
- wday = RTC_READ( RTC_DAY_OF_WEEK );
- }
- else {
- RTC_WRITE( RTC_SECONDS, sec );
- RTC_WRITE( RTC_MINUTES, min );
- RTC_WRITE( RTC_HOURS, hour + pm);
- RTC_WRITE( RTC_DAY_OF_MONTH, day );
- RTC_WRITE( RTC_MONTH, mon );
- RTC_WRITE( RTC_YEAR, year );
- if (wday >= 0) RTC_WRITE( RTC_DAY_OF_WEEK, wday );
- }
- RTC_WRITE( RTC_CONTROL, ctrl & ~RTC_SET );
- restore_flags(flags);
-
- if (!op) {
- /* read: adjust values */
-
- if (hour & 0x80) {
- hour &= ~0x80;
- pm = 1;
- }
-
- if (!(ctrl & RTC_DM_BINARY)) {
- BCD_TO_BIN(sec);
- BCD_TO_BIN(min);
- BCD_TO_BIN(hour);
- BCD_TO_BIN(day);
- BCD_TO_BIN(mon);
- BCD_TO_BIN(year);
- BCD_TO_BIN(wday);
- }
-
- if (!(ctrl & RTC_24H)) {
- if (!pm && hour == 12)
- hour = 0;
- else if (pm && hour != 12)
- hour += 12;
- }
-
- t->sec = sec;
- t->min = min;
- t->hour = hour;
- t->day = day;
- t->mon = mon - 1;
- t->year = year + ((tos_version < 0x306) ? 70 : 68);
- t->wday = wday - 1;
- }
-
- return( 0 );
-}
-
-
-static int atari_mste_set_clock_mmss (unsigned long nowtime)
-{
- short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60;
- struct MSTE_RTC val;
- unsigned char rtc_minutes;
-
- mste_read(&val);
- rtc_minutes= val.min_ones + val.min_tens * 10;
- if ((rtc_minutes < real_minutes
- ? real_minutes - rtc_minutes
- : rtc_minutes - real_minutes) < 30)
- {
- val.sec_ones = real_seconds % 10;
- val.sec_tens = real_seconds / 10;
- val.min_ones = real_minutes % 10;
- val.min_tens = real_minutes / 10;
- mste_write(&val);
- }
- else
- return -1;
- return 0;
-}
-
-static int atari_set_clock_mmss (unsigned long nowtime)
-{
- int retval = 0;
- short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60;
- unsigned char save_control, save_freq_select, rtc_minutes;
-
- save_control = RTC_READ (RTC_CONTROL); /* tell the clock it's being set */
- RTC_WRITE (RTC_CONTROL, save_control | RTC_SET);
-
- save_freq_select = RTC_READ (RTC_FREQ_SELECT); /* stop and reset prescaler */
- RTC_WRITE (RTC_FREQ_SELECT, save_freq_select | RTC_DIV_RESET2);
-
- rtc_minutes = RTC_READ (RTC_MINUTES);
- if (!(save_control & RTC_DM_BINARY))
- BCD_TO_BIN (rtc_minutes);
-
- /* Since we're only adjusting minutes and seconds, don't interfere
- with hour overflow. This avoids messing with unknown time zones
- but requires your RTC not to be off by more than 30 minutes. */
- if ((rtc_minutes < real_minutes
- ? real_minutes - rtc_minutes
- : rtc_minutes - real_minutes) < 30)
- {
- if (!(save_control & RTC_DM_BINARY))
- {
- BIN_TO_BCD (real_seconds);
- BIN_TO_BCD (real_minutes);
- }
- RTC_WRITE (RTC_SECONDS, real_seconds);
- RTC_WRITE (RTC_MINUTES, real_minutes);
- }
- else
- retval = -1;
-
- RTC_WRITE (RTC_FREQ_SELECT, save_freq_select);
- RTC_WRITE (RTC_CONTROL, save_control);
- return retval;
-}
-
-static inline void ata_mfp_out (char c)
-{
- while (!(mfp.trn_stat & 0x80)) /* wait for tx buf empty */
- barrier ();
- mfp.usart_dta = c;
-}
-
-static void atari_mfp_console_write (const char *str, unsigned int count)
-{
- while (count--) {
- if (*str == '\n')
- ata_mfp_out( '\r' );
- ata_mfp_out( *str++ );
- }
-}
-
-static inline void ata_scc_out (char c)
-{
- do {
- MFPDELAY();
- } while (!(scc.cha_b_ctrl & 0x04)); /* wait for tx buf empty */
- MFPDELAY();
- scc.cha_b_data = c;
-}
-
-static void atari_scc_console_write (const char *str, unsigned int count)
-{
- while (count--) {
- if (*str == '\n')
- ata_scc_out( '\r' );
- ata_scc_out( *str++ );
- }
-}
-
-static int ata_par_out (char c)
-{
- extern unsigned long loops_per_sec;
- unsigned char tmp;
- /* This a some-seconds timeout in case no printer is connected */
- unsigned long i = loops_per_sec > 1 ? loops_per_sec : 10000000;
-
- while( (mfp.par_dt_reg & 1) && --i ) /* wait for BUSY == L */
- ;
- if (!i) return( 0 );
-
- sound_ym.rd_data_reg_sel = 15; /* select port B */
- sound_ym.wd_data = c; /* put char onto port */
- sound_ym.rd_data_reg_sel = 14; /* select port A */
+ sound_ym.rd_data_reg_sel = 14; /* Select PSG Port A */
tmp = sound_ym.rd_data_reg_sel;
- sound_ym.wd_data = tmp & ~0x20; /* set strobe L */
- MFPDELAY(); /* wait a bit */
- sound_ym.wd_data = tmp | 0x20; /* set strobe H */
- return( 1 );
-}
-
-static void atari_par_console_write (const char *str, unsigned int count)
-{
- static int printer_present = 1;
-
- if (!printer_present)
- return;
-
- while (count--) {
- if (*str == '\n')
- if (!ata_par_out( '\r' )) {
- printer_present = 0;
- return;
- }
- if (!ata_par_out( *str++ )) {
- printer_present = 0;
- return;
- }
- }
+ sound_ym.wd_data = on ? (tmp & ~0x02) : (tmp | 0x02);
+ restore_flags(flags);
}
-
-
-__initfunc(static void atari_debug_init(void))
-{
-#ifdef CONFIG_KGDB
- /* if the m68k_debug_device is used by the GDB stub, do nothing here */
- if (kgdb_initialized)
- return(NULL);
#endif
- if (!strcmp( m68k_debug_device, "ser" )) {
- /* defaults to ser2 for a Falcon and ser1 otherwise */
- strcpy( m68k_debug_device,
- ((atari_mch_cookie >> 16) == ATARI_MCH_FALCON) ?
- "ser2" : "ser1" );
-
- }
-
- if (!strcmp( m68k_debug_device, "ser1" )) {
- /* ST-MFP Modem1 serial port */
- mfp.trn_stat &= ~0x01; /* disable TX */
- mfp.usart_ctr = 0x88; /* clk 1:16, 8N1 */
- mfp.tim_ct_cd &= 0x70; /* stop timer D */
- mfp.tim_dt_d = 2; /* 9600 bps */
- mfp.tim_ct_cd |= 0x01; /* start timer D, 1:4 */
- mfp.trn_stat |= 0x01; /* enable TX */
- atari_console_driver.write = atari_mfp_console_write;
- }
- else if (!strcmp( m68k_debug_device, "ser2" )) {
- /* SCC Modem2 serial port */
- static unsigned char *p, scc_table[] = {
- 9, 12, /* Reset */
- 4, 0x44, /* x16, 1 stopbit, no parity */
- 3, 0xc0, /* receiver: 8 bpc */
- 5, 0xe2, /* transmitter: 8 bpc, assert dtr/rts */
- 9, 0, /* no interrupts */
- 10, 0, /* NRZ */
- 11, 0x50, /* use baud rate generator */
- 12, 24, 13, 0, /* 9600 baud */
- 14, 2, 14, 3, /* use master clock for BRG, enable */
- 3, 0xc1, /* enable receiver */
- 5, 0xea, /* enable transmitter */
- 0
- };
-
- (void)scc.cha_b_ctrl; /* reset reg pointer */
- for( p = scc_table; *p != 0; ) {
- scc.cha_b_ctrl = *p++;
- MFPDELAY();
- scc.cha_b_ctrl = *p++;
- MFPDELAY();
- }
- atari_console_driver.write = atari_scc_console_write;
- }
- else if (!strcmp( m68k_debug_device, "par" )) {
- /* parallel printer */
- atari_turnoff_irq( IRQ_MFP_BUSY ); /* avoid ints */
- sound_ym.rd_data_reg_sel = 7; /* select mixer control */
- sound_ym.wd_data = 0xff; /* sound off, ports are output */
- sound_ym.rd_data_reg_sel = 15; /* select port B */
- sound_ym.wd_data = 0; /* no char */
- sound_ym.rd_data_reg_sel = 14; /* select port A */
- sound_ym.wd_data = sound_ym.rd_data_reg_sel | 0x20; /* strobe H */
- atari_console_driver.write = atari_par_console_write;
- }
- if (atari_console_driver.write)
- register_console(&atari_console_driver);
-}
-
/* ++roman:
*
* This function does a reset on machines that lack the ability to
@@ -1082,11 +645,16 @@
/* On the Medusa, phys. 0x4 may contain garbage because it's no
ROM. See above for explanation why we cannot use PTOV(4). */
- reset_addr = is_hades ? 0x7fe00030 :
- (is_medusa ? 0xe00030 : *(unsigned long *) 0xff000004);
-
- acia.key_ctrl = ACIA_RESET; /* reset ACIA for switch off OverScan, if it's active */
-
+ reset_addr = MACH_IS_HADES ? 0x7fe00030 :
+ MACH_IS_MEDUSA || MACH_IS_AB40 ? 0xe00030 :
+ *(unsigned long *) 0xff000004;
+
+ /* reset ACIA for switch off OverScan, if it's active */
+ if (atari_switches & ATARI_SWITCH_OVSC_IKBD)
+ acia.key_ctrl = ACIA_RESET;
+ if (atari_switches & ATARI_SWITCH_OVSC_MIDI)
+ acia.mid_ctrl = ACIA_RESET;
+
/* processor independent: turn off interrupts and reset the VBR;
* the caches must be left enabled, else prefetching the final jump
* instruction doesn't work. */
@@ -1126,8 +694,21 @@
"nop\n\t"
".chip 68040\n\t"
"cinva %%bc\n\t"
+ "nop\n\t"
"pflusha\n\t"
+ "nop\n\t"
"movec %%d0,%%tc\n\t"
+ "nop\n\t"
+ /* the following setup of transparent translations is needed on the
+ * Afterburner040 to successfully reboot. Other machines shouldn't
+ * care about a different tt regs setup, they also didn't care in
+ * the past that the regs weren't turned off. */
+ "movel #0xffc000,%%d0\n\t" /* whole insn space cacheable */
+ "movec %%d0,%%itt0\n\t"
+ "movec %%d0,%%itt1\n\t"
+ "orw #0x40,%/d0\n\t" /* whole data space non-cacheable/ser. */
+ "movec %%d0,%%dtt0\n\t"
+ "movec %%d0,%%dtt1\n\t"
".chip 68k\n\t"
"jmp %0@"
: /* no outputs */
@@ -1154,22 +735,24 @@
strcat (model, "ST");
break;
case ATARI_MCH_STE:
- if ((atari_mch_cookie & 0xffff) == 0x10)
+ if (MACH_IS_MSTE)
strcat (model, "Mega STE");
else
strcat (model, "STE");
break;
case ATARI_MCH_TT:
- if (is_medusa)
+ if (MACH_IS_MEDUSA)
/* Medusa has TT _MCH cookie */
strcat (model, "Medusa");
- else if (is_hades)
+ else if (MACH_IS_HADES)
strcat(model, "Hades");
else
strcat (model, "TT");
break;
case ATARI_MCH_FALCON:
strcat (model, "Falcon");
+ if (MACH_IS_AB40)
+ strcat (model, " (with Afterburner040)");
break;
default:
sprintf (model + strlen (model), "(unknown mach cookie 0x%lx)",
@@ -1225,3 +808,10 @@
return(len);
}
+
+/*
+ * Local variables:
+ * c-indent-level: 4
+ * tab-width: 8
+ * End:
+ */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov