Add support for PS/2 keyboard on TQM85xx board

Patch by Martin Krause, 07 Nov 2005

Tested on a STK85XX baseboard. Make sure the PS/2 controller
has been programmed. Jumper Settings: X66 1-2, 9-10; X61 2-3
This commit is contained in:
Wolfgang Denk 2006-06-16 16:40:54 +02:00
parent cebd1fcec0
commit bc8bb6d458
5 changed files with 81 additions and 7 deletions

View File

@ -2,6 +2,12 @@
Changes since U-Boot 1.1.4: Changes since U-Boot 1.1.4:
====================================================================== ======================================================================
* Add support for PS/2 keyboard on TQM85xx board
Patch by Martin Krause, 07 Nov 2005
Tested on a STK85XX baseboard. Make sure the PS/2 controller
has been programmed. Jumper Settings: X66 1-2, 9-10; X61 2-3
* Fix TRAB channel switching delay for trab_fkt.bin standalone applikation * Fix TRAB channel switching delay for trab_fkt.bin standalone applikation
In tsc2000_read_channel() the delay after setting the multiplexer In tsc2000_read_channel() the delay after setting the multiplexer
to a temperature channel is increased from 1,5 ms to 10 ms. This to a temperature channel is increased from 1,5 ms to 10 ms. This

View File

@ -27,6 +27,9 @@
* MA 02111-1307 USA * MA 02111-1307 USA
*/ */
#ifdef CONFIG_PS2MULT
void ps2mult_early_init(void);
#endif
#include <common.h> #include <common.h>
#include <pci.h> #include <pci.h>
@ -410,3 +413,14 @@ void pci_init_board (void)
pci_mpc85xx_init (&hose); pci_mpc85xx_init (&hose);
#endif /* CONFIG_PCI */ #endif /* CONFIG_PCI */
} }
#ifdef CONFIG_BOARD_EARLY_INIT_R
int board_early_init_r (void)
{
#ifdef CONFIG_PS2MULT
ps2mult_early_init();
#endif /* CONFIG_PS2MULT */
return (0);
}
#endif /* CONFIG_BOARD_EARLY_INIT_R */

View File

@ -33,7 +33,7 @@
#define KBD_BUFFER_LEN 0x20 /* size of the keyboardbuffer */ #define KBD_BUFFER_LEN 0x20 /* size of the keyboardbuffer */
#ifdef CONFIG_MPC5xxx #if defined(CONFIG_MPC5xxx) || defined(CONFIG_MPC85xx)
int ps2ser_check(void); int ps2ser_check(void);
#endif #endif
@ -75,7 +75,7 @@ static void kbd_put_queue(char data)
/* test if a character is in the queue */ /* test if a character is in the queue */
static int kbd_testc(void) static int kbd_testc(void)
{ {
#ifdef CONFIG_MPC5xxx #if defined(CONFIG_MPC5xxx) || defined(CONFIG_MPC85xx)
/* no ISR is used, so received chars must be polled */ /* no ISR is used, so received chars must be polled */
ps2ser_check(); ps2ser_check();
#endif #endif
@ -90,7 +90,7 @@ static int kbd_getc(void)
{ {
char c; char c;
while(in_pointer==out_pointer) { while(in_pointer==out_pointer) {
#ifdef CONFIG_MPC5xxx #if defined(CONFIG_MPC5xxx) || defined(CONFIG_MPC85xx)
/* no ISR is used, so received chars must be polled */ /* no ISR is used, so received chars must be polled */
ps2ser_check(); ps2ser_check();
#endif #endif

View File

@ -20,6 +20,9 @@
#include <asm/io.h> #include <asm/io.h>
#include <asm/atomic.h> #include <asm/atomic.h>
#include <ps2mult.h> #include <ps2mult.h>
#ifdef CFG_NS16550
#include <ns16550.h>
#endif
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
@ -45,13 +48,24 @@ DECLARE_GLOBAL_DATA_PTR;
#else #else
#error CONFIG_PS2SERIAL must be in 1 ... 6 #error CONFIG_PS2SERIAL must be in 1 ... 6
#endif #endif
#endif /* CONFIG_MPC5xxx */
#elif defined(CONFIG_MPC85xx)
#if CONFIG_PS2SERIAL == 1
#define COM_BASE (CFG_CCSRBAR+0x4500)
#elif CONFIG_PS2SERIAL == 2
#define COM_BASE (CFG_CCSRBAR+0x4600)
#else
#error CONFIG_PS2SERIAL must be in 1 ... 2
#endif
#endif /* CONFIG_MPC5xxx / CONFIG_MPC85xx */
static int ps2ser_getc_hw(void); static int ps2ser_getc_hw(void);
static void ps2ser_interrupt(void *dev_id); static void ps2ser_interrupt(void *dev_id);
extern struct serial_state rs_table[]; /* in serial.c */ extern struct serial_state rs_table[]; /* in serial.c */
#ifndef CONFIG_MPC5xxx #if !defined(CONFIG_MPC5xxx) && !defined(CONFIG_MPC85xx)
static struct serial_state *state; static struct serial_state *state;
#endif #endif
@ -106,7 +120,23 @@ int ps2ser_init(void)
return (0); return (0);
} }
#else /* !CONFIG_MPC5xxx */ #elif defined(CONFIG_MPC85xx)
int ps2ser_init(void)
{
NS16550_t com_port = (NS16550_t)COM_BASE;
com_port->ier = 0x00;
com_port->lcr = LCR_BKSE | LCR_8N1;
com_port->dll = (CFG_NS16550_CLK / 16 / PS2SER_BAUD) & 0xff;
com_port->dlm = ((CFG_NS16550_CLK / 16 / PS2SER_BAUD) >> 8) & 0xff;
com_port->lcr = LCR_8N1;
com_port->mcr = (MCR_DTR | MCR_RTS);
com_port->fcr = (FCR_FIFO_EN | FCR_RXSR | FCR_TXSR);
return (0);
}
#else /* !CONFIG_MPC5xxx && !CONFIG_MPC85xx */
static inline unsigned int ps2ser_in(int offset) static inline unsigned int ps2ser_in(int offset)
{ {
@ -150,12 +180,14 @@ int ps2ser_init(void)
return 0; return 0;
} }
#endif /* CONFIG_MPC5xxx */ #endif /* CONFIG_MPC5xxx / CONFIG_MPC85xx / other */
void ps2ser_putc(int chr) void ps2ser_putc(int chr)
{ {
#ifdef CONFIG_MPC5xxx #ifdef CONFIG_MPC5xxx
volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)PSC_BASE; volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)PSC_BASE;
#elif defined(CONFIG_MPC85xx)
NS16550_t com_port = (NS16550_t)COM_BASE;
#endif #endif
#ifdef DEBUG #ifdef DEBUG
printf(">>>> 0x%02x\n", chr); printf(">>>> 0x%02x\n", chr);
@ -165,6 +197,9 @@ void ps2ser_putc(int chr)
while (!(psc->psc_status & PSC_SR_TXRDY)); while (!(psc->psc_status & PSC_SR_TXRDY));
psc->psc_buffer_8 = chr; psc->psc_buffer_8 = chr;
#elif defined(CONFIG_MPC85xx)
while ((com_port->lsr & LSR_THRE) == 0);
com_port->thr = chr;
#else #else
while (!(ps2ser_in(UART_LSR) & UART_LSR_THRE)); while (!(ps2ser_in(UART_LSR) & UART_LSR_THRE));
@ -176,6 +211,8 @@ static int ps2ser_getc_hw(void)
{ {
#ifdef CONFIG_MPC5xxx #ifdef CONFIG_MPC5xxx
volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)PSC_BASE; volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)PSC_BASE;
#elif defined(CONFIG_MPC85xx)
NS16550_t com_port = (NS16550_t)COM_BASE;
#endif #endif
int res = -1; int res = -1;
@ -183,6 +220,10 @@ static int ps2ser_getc_hw(void)
if (psc->psc_status & PSC_SR_RXRDY) { if (psc->psc_status & PSC_SR_RXRDY) {
res = (psc->psc_buffer_8); res = (psc->psc_buffer_8);
} }
#elif defined(CONFIG_MPC85xx)
if (com_port->lsr & LSR_DR) {
res = com_port->rbr;
}
#else #else
if (ps2ser_in(UART_LSR) & UART_LSR_DR) { if (ps2ser_in(UART_LSR) & UART_LSR_DR) {
res = (ps2ser_in(UART_RX)); res = (ps2ser_in(UART_RX));
@ -238,6 +279,8 @@ static void ps2ser_interrupt(void *dev_id)
{ {
#ifdef CONFIG_MPC5xxx #ifdef CONFIG_MPC5xxx
volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)PSC_BASE; volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)PSC_BASE;
#elif defined(CONFIG_MPC85xx)
NS16550_t com_port = (NS16550_t)COM_BASE;
#endif #endif
int chr; int chr;
int status; int status;
@ -246,6 +289,8 @@ static void ps2ser_interrupt(void *dev_id)
chr = ps2ser_getc_hw(); chr = ps2ser_getc_hw();
#ifdef CONFIG_MPC5xxx #ifdef CONFIG_MPC5xxx
status = psc->psc_status; status = psc->psc_status;
#elif defined(CONFIG_MPC85xx)
status = com_port->lsr;
#else #else
status = ps2ser_in(UART_IIR); status = ps2ser_in(UART_IIR);
#endif #endif
@ -260,6 +305,8 @@ static void ps2ser_interrupt(void *dev_id)
} }
#ifdef CONFIG_MPC5xxx #ifdef CONFIG_MPC5xxx
} while (status & PSC_SR_RXRDY); } while (status & PSC_SR_RXRDY);
#elif defined(CONFIG_MPC85xx)
} while (status & LSR_DR);
#else #else
} while (status & UART_IIR_RDI); } while (status & UART_IIR_RDI);
#endif #endif

View File

@ -177,6 +177,13 @@
#define CFG_BAUDRATE_TABLE \ #define CFG_BAUDRATE_TABLE \
{300, 600, 1200, 2400, 4800, 9600, 19200, 38400,115200} {300, 600, 1200, 2400, 4800, 9600, 19200, 38400,115200}
/* PS/2 Keyboard */
#define CONFIG_PS2KBD /* AT-PS/2 Keyboard */
#define CONFIG_PS2MULT /* .. on PS/2 Multiplexer */
#define CONFIG_PS2SERIAL 2 /* .. on DUART2 */
#define CONFIG_PS2MULT_DELAY (CFG_HZ/2) /* Initial delay */
#define CONFIG_BOARD_EARLY_INIT_R 1
/* Use the HUSH parser */ /* Use the HUSH parser */
#define CFG_HUSH_PARSER #define CFG_HUSH_PARSER
#ifdef CFG_HUSH_PARSER #ifdef CFG_HUSH_PARSER