static void __init atari_init_scc_port()

in atari/debug.c [203:261]


static void __init atari_init_scc_port(int cflag)
{
	static int clksrc_table[9] =
		/* reg 11: 0x50 = BRG, 0x00 = RTxC, 0x28 = TRxC */
		{ 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x00, 0x00 };
	static int brgsrc_table[9] =
		/* reg 14: 0 = RTxC, 2 = PCLK */
		{ 2, 2, 2, 2, 2, 2, 0, 2, 2 };
	static int clkmode_table[9] =
		/* reg 4: 0x40 = x16, 0x80 = x32, 0xc0 = x64 */
		{ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xc0, 0x80 };
	static int div_table[9] =
		/* reg12 (BRG low) */
		{ 208, 138, 103, 50, 24, 11, 1, 0, 0 };

	int baud = cflag & CBAUD;
	int clksrc, clkmode, div, reg3, reg5;

	if (cflag & CBAUDEX)
		baud += B38400;
	if (baud < B1200 || baud > B38400+2)
		baud = B9600;		/* use default 9600bps for non-implemented rates */
	baud -= B1200;			/* tables starts at 1200bps */

	clksrc  = clksrc_table[baud];
	clkmode = clkmode_table[baud];
	div     = div_table[baud];
	if (ATARIHW_PRESENT(TT_MFP) && baud >= 6) {
		/* special treatment for TT, where rates >= 38400 are done via TRxC */
		clksrc = 0x28;		/* TRxC */
		clkmode = baud == 6 ? 0xc0 :
			  baud == 7 ? 0x80 : /* really 76800bps */
				      0x40;  /* really 153600bps */
		div = 0;
	}

	reg3 = (cflag & CSIZE) == CS8 ? 0xc0 : 0x40;
	reg5 = (cflag & CSIZE) == CS8 ? 0x60 : 0x20 | 0x82 /* assert DTR/RTS */;

	(void)atari_scc.cha_b_ctrl;	/* reset reg pointer */
	SCC_WRITE(9, 0xc0);		/* reset */
	LONG_DELAY();			/* extra delay after WR9 access */
	SCC_WRITE(4, (cflag & PARENB) ? ((cflag & PARODD) ? 0x01 : 0x03)
				      : 0 | 0x04 /* 1 stopbit */ | clkmode);
	SCC_WRITE(3, reg3);
	SCC_WRITE(5, reg5);
	SCC_WRITE(9, 0);		/* no interrupts */
	LONG_DELAY();			/* extra delay after WR9 access */
	SCC_WRITE(10, 0);		/* NRZ mode */
	SCC_WRITE(11, clksrc);		/* main clock source */
	SCC_WRITE(12, div);		/* BRG value */
	SCC_WRITE(13, 0);		/* BRG high byte */
	SCC_WRITE(14, brgsrc_table[baud]);
	SCC_WRITE(14, brgsrc_table[baud] | (div ? 1 : 0));
	SCC_WRITE(3, reg3 | 1);
	SCC_WRITE(5, reg5 | 8);

	atari_SCC_reset_done = 1;
}