serial support for yosemite
PATCH 1/1 serial support for yosemite
Hi,
this is a revised version of my previous yosemite patch. It adds fully interrrupt-driven operation for both serial ports as well as working kgdb support. It also updates yosemite_defconfig to reflect the code changes.
tk
arch/mips/pmc-sierra/yosemite/dbg_io.c +28 -62
@@ -23,18 +23,22 @@* 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* -* Support for KGDB for the Yosemite board. We make use of single serial -* port to be used for KGDB as well as console. The second serial port -* seems to be having a problem. Single IRQ is allocated for both the -* ports. Hence, the interrupt routing code needs to figure out whether -* the interrupt came from channel A or B. -*/ -#include <linux/config.h> +#include <asm/io.h> + +#include "setup.h" #if defined(CONFIG_KGDB ) -#include <asm/serial.h> + +#if defined(CONFIG_SERIAL_8250 ) &&CONFIG_SERIAL_8250_NR_UARTS >1 +#error Debug port used by serial driver +#endif + +#define TITAN_UART_CLK 3686400 +#define TITAN_SERIAL_BASE_BAUD (TITAN_UART_CLK / 16) +#define TITAN_SERIAL_BASE_0 0xfd000008UL +#define TITAN_SERIAL_BASE_1 0xfd000000UL +/* * Baud rate, Parity, Data and Stop bit settings for the
@@ -71,6 +75,7 @@#define SERIAL_SEND_BUFFER 0x0#define SERIAL_INTR_ENABLE (1 * SERIAL_REG_OFS)#define SERIAL_INTR_ID (2 * SERIAL_REG_OFS) +#define SERIAL_FIFO_CONTROL SERIAL_INTR_ID#define SERIAL_DATA_FORMAT (3 * SERIAL_REG_OFS)#define SERIAL_LINE_CONTROL (3 * SERIAL_REG_OFS)#define SERIAL_MODEM_CONTROL (4 * SERIAL_REG_OFS)
@@ -84,59 +89,26 @@#define SERIAL_DIVISOR_MSB (1 * SERIAL_REG_OFS)/* -* Functions to READ and WRITE to serial port 0 +* Functions to READ and WRITE to serial port */ -#define SERIAL_READ (ofs) (*((volatile unsigned char*) \ - (TITAN_SERIAL_BASE + ofs))) - -#define SERIAL_WRITE (ofs, val) ((*((volatile unsigned char*) \ - (TITAN_SERIAL_BASE + ofs))) = val) +#define SERIAL_READ (ofs) readb(serbase + ofs) +#define SERIAL_WRITE (ofs, val) writeb((val), serbase + ofs) -/* -* Functions to READ and WRITE to serial port 1 -*/ -#define SERIAL_READ_1 (ofs) (*((volatile unsigned char*) \ - (TITAN_SERIAL_BASE_1 + ofs) - -#define SERIAL_WRITE_1 (ofs, val) ((*((volatile unsigned char*) \ - (TITAN_SERIAL_BASE_1 + ofs))) = val) - -/* -* Second serial port initialization -*/ -void init_second_port (void ) -{ -/* Disable Interrupts */ -SERIAL_WRITE_1 (SERIAL_LINE_CONTROL ,0x0 ); -SERIAL_WRITE_1 (SERIAL_INTR_ENABLE ,0x0 ); - - { -unsigned int divisor; - -SERIAL_WRITE_1 (SERIAL_LINE_CONTROL ,0x80 ); - divisor =TITAN_SERIAL_BASE_BAUD /YOSEMITE_BAUD_115200 ; -SERIAL_WRITE_1 (SERIAL_DIVISOR_LSB , divisor &0xff ); - -SERIAL_WRITE_1 (SERIAL_DIVISOR_MSB , - (divisor &0xff00 ) >>8 ); -SERIAL_WRITE_1 (SERIAL_LINE_CONTROL ,0x0 ); - } - -SERIAL_WRITE_1 (SERIAL_DATA_FORMAT ,YOSEMITE_DATA_8BIT | -YOSEMITE_PARITY_NONE |YOSEMITE_STOP_1BIT ); - -/* Enable Interrupts */ -SERIAL_WRITE_1 (SERIAL_INTR_ENABLE ,0xf ); -} +static int initialized =0 ;/* Initialize the serial port for KGDB debugging */ void debugInit (unsigned int baud,unsigned char data,unsigned char parity, -unsigned char stop) +unsigned char stop) { + initialized =1 ; +/* Disable Interrupts */ SERIAL_WRITE (SERIAL_LINE_CONTROL ,0x0 );SERIAL_WRITE (SERIAL_INTR_ENABLE ,0x0 ); +/* Disable FIFOs */ +SERIAL_WRITE (SERIAL_FIFO_CONTROL ,0x00 ); + {unsigned int divisor;
@@ -152,15 +124,11 @@ void debugInit(unsigned int baud, unsignSERIAL_WRITE (SERIAL_DATA_FORMAT , data | parity | stop); } -static int remoteDebugInitialized =0 ; -unsigned char getDebugChar (void ) { -if (!remoteDebugInitialized) { - remoteDebugInitialized =1 ; +if (!initialized) {debugInit (YOSEMITE_BAUD_115200 , -YOSEMITE_DATA_8BIT , -YOSEMITE_PARITY_NONE ,YOSEMITE_STOP_1BIT ); +YOSEMITE_DATA_8BIT ,YOSEMITE_PARITY_NONE ,YOSEMITE_STOP_1BIT ); }while ((SERIAL_READ (SERIAL_LINE_STATUS ) &0x1 ) ==0 );
@@ -169,11 +137,9 @@ unsigned char getDebugChar(void)int putDebugChar (unsigned char byte) { -if (!remoteDebugInitialized) { - remoteDebugInitialized =1 ; +if (!initialized) {debugInit (YOSEMITE_BAUD_115200 , -YOSEMITE_DATA_8BIT , -YOSEMITE_PARITY_NONE ,YOSEMITE_STOP_1BIT ); +YOSEMITE_DATA_8BIT ,YOSEMITE_PARITY_NONE ,YOSEMITE_STOP_1BIT ); }while ((SERIAL_READ (SERIAL_LINE_STATUS ) &0x20 ) ==0 );
arch/mips/pmc-sierra/yosemite/irq.c +0 -13
@@ -110,7 +110,6 @@ asmlinkage void ll_ht_smp_irq_handler(in }#ifdef CONFIG_KGDB -extern void init_second_port (void );extern void breakpoint (void );extern void set_debug_traps (void );#endif
@@ -126,18 +125,6 @@ void __init init_IRQ(void)init_generic_irq ();mips_cpu_irq_init (0 );rm7k_cpu_irq_init (8 ); - -#ifdef CONFIG_KGDB -/* At this point, initialize the second serial port */ -init_second_port (); -printk ("Start kgdb ... \n" ); -set_debug_traps (); -breakpoint (); -#endif - -#ifdef CONFIG_GDB_CONSOLE -register_gdb_console (); -#endif }#ifdef CONFIG_KGDB
arch/mips/pmc-sierra/yosemite/setup.c +36 -7
86 lines not on this page · raw message
arch/mips/pmc-sierra/yosemite/setup.h +3 -0
@@ -28,4 +28,7 @@#define TITAN_ATMEL_24C32_SIZE 32768#define TITAN_ATMEL_24C64_SIZE 65536 +/* UART base */ +extern volatile unsigned char * serbase; +#endif /* __SETUP_H__ */
arch/mips/configs/yosemite_defconfig +7 -2
@@ -352,8 +352,13 @@ CONFIG_SOUND_GAMEPORT=y # CONFIG_SERIAL_8250=y CONFIG_SERIAL_8250_CONSOLE=y -CONFIG_SERIAL_8250_NR_UARTS=4 -# CONFIG_SERIAL_8250_EXTENDED is not set +CONFIG_SERIAL_8250_NR_UARTS=2 +CONFIG_SERIAL_8250_EXTENDED=y +# CONFIG_SERIAL_8250_MANY_PORTS is not set +CONFIG_SERIAL_8250_SHARE_IRQ=y +# CONFIG_SERIAL_8250_DETECT_IRQ is not set +# CONFIG_SERIAL_8250_MULTIPORT is not set +# CONFIG_SERIAL_8250_RSA is not set # # Non-8250 serial port support
Signature · 9 lines
-------------------------------------------------- Thomas Koeller, Software Development Basler Vision Technologies thomas dot koeller at baslerweb dot com http://www.baslerweb.com ==============================
Hi,
some time ago I posted this patch to the list. So far I have not received any response at all. As this is my first attempt at contributing code to linux-mips.org, I am wondering if I did it the right way?
Thomas
Signature · 9 lines
-------------------------------------------------- Thomas Koeller, Software Development Basler Vision Technologies thomas dot koeller at baslerweb dot com http://www.baslerweb.com ==============================
Quoted 4 lines · Thomas Koeller
some time ago I posted this patch to the list. So far I have not received any response at all. As this is my first attempt at contributing code to linux-mips.org, I am wondering if I did it the right way?
I've been on a Linux trip of several weeks.
Ralf