// SPDX-License-Identifier: LGPL-2.1

#ifndef TOSLIBC_ASM_MACHINE_H
#define TOSLIBC_ASM_MACHINE_H

/* Main clock frequencies */

#define ATARI_STF_PAL_MCLK		32084988 /* CPU 8.021247 MHz */
#define ATARI_STF_NTSC_MCLK		32042400 /* CPU 8.010600 MHz */
#define ATARI_STF_CYCLES_PER_VBL_PAL	  160256 /* 512 cycles * 313 lines */
#define ATARI_STF_CYCLES_PER_VBL_NTSC	  133604 /* 508 cycles * 263 lines */
#define ATARI_STF_CYCLES_PER_VBL_HI	  112224 /* 224 cycles * 501 lines */

#define ATARI_STE_PAL_MCLK		32084988 /* CPU 8.021247 MHz */
#define ATARI_STE_NTSC_MCLK		32215905 /* CPU 8.05397625 MHz */
#define ATARI_STE_EXT_OSC		 8010613 /* OSC U303 */
#define ATARI_STE_CYCLES_PER_VBL_PAL	  160256 /* 512 cycles * 313 lines */
#define ATARI_STE_CYCLES_PER_VBL_NTSC	  133604 /* 508 cycles * 263 lines */
#define ATARI_STE_CYCLES_PER_VBL_HI	  112224 /* 224 cycles * 501 lines */

#define ATARI_MEGA_STE_PAL_MCLK		32084988 /* CPU 16.042494 MHz */
#define ATARI_MEGA_STE_NTSC_MCLK	32215905 /* CPU 16.1079525 MHz */
#define ATARI_MEGA_STE_EXT_OSC		16021226 /* OSC U408 */

#define ATARI_TT_PAL_MCLK		32084988 /* CPU 32.084988 MHz */
#define ATARI_TT_NTSC_MCLK		32215905 /* CPU 32.215905 MHz */

#define ATARI_FALCON_PAL_MCLK		32084988 /* CPU 16.042494 MHz */
#define ATARI_FALCON_NTSC_MCLK		32215905 /* CPU 16.1079525 MHz */
#define ATARI_FALCON_25M_CLK		25175000

#define ATARI_MFP_XTAL			 2457600 /* External clock for the MFP */
#define ATARI_IKBD_CLK			 1000000 /* Clock of the HD6301 IKBD CPU */

/* Derived clock frequencies */

/* Relative ATARI_STE_PAL_MCLK and ATARI_STE_NTSC_MCLK */
#define ATARI_STE_CPU_CLK_DIV		4
#define ATARI_STE_MFP_CLK_DIV		8

/* Relative ATARI_STE_EXT_OSC */
#define ATARI_STE_SND_PSG_CLK_DIV	4	/* 2.00265325 MHz */
#define ATARI_STE_SND_DMA_CLK_DIV	(4*8*5)	/* 50066.33125 Hz */

/* Relative ATARI_STE_SND_PSG_CLK_DIV */
#define ATARI_STE_SND_PSG_MODE8_DIV	8	/* 250.33165625 kHz */

#endif /* TOSLIBC_ASM_MACHINE_H */
