diff --git a/arch/arm/platforms/ti_lm3s6965/Kconfig b/arch/arm/platforms/ti_lm3s6965/Kconfig index 350dd6b3170..f561b164037 100644 --- a/arch/arm/platforms/ti_lm3s6965/Kconfig +++ b/arch/arm/platforms/ti_lm3s6965/Kconfig @@ -122,4 +122,15 @@ config BLUETOOTH_UART_IRQ_PRI endif +if UART_PIPE + +config UART_PIPE_ON_DEV_NAME + default "UART_2" +config UART_PIPE_IRQ + default 33 +config UART_PIPE_IRQ_PRI + default 3 + +endif + endif diff --git a/arch/arm/platforms/ti_lm3s6965/board.h b/arch/arm/platforms/ti_lm3s6965/board.h index fbd548824a0..9a2abb4a046 100644 --- a/arch/arm/platforms/ti_lm3s6965/board.h +++ b/arch/arm/platforms/ti_lm3s6965/board.h @@ -96,11 +96,6 @@ extern struct device * const uart_devs[]; -/* Pipe UART definitions */ -#define CONFIG_UART_PIPE_INDEX 2 -#define CONFIG_UART_PIPE_IRQ IRQ_UART2 -#define CONFIG_UART_PIPE_INT_PRI 3 - #endif /* !_ASMLANGUAGE */ #endif /* _BOARD__H_ */ diff --git a/arch/x86/core/driver_static_irq_stubs.S b/arch/x86/core/driver_static_irq_stubs.S index 9c7039bf209..b92b7ad5177 100644 --- a/arch/x86/core/driver_static_irq_stubs.S +++ b/arch/x86/core/driver_static_irq_stubs.S @@ -37,12 +37,6 @@ by x86 platforms. ioapic_mkstub hpet _timer_int_handler 0 #endif -#if defined(CONFIG_UART_PIPE) -#if defined(CONFIG_IOAPIC) - ioapic_mkstub uart_pipe uart_pipe_isr 0 -#endif /* CONFIG_IOAPIC */ -#endif /* CONFIG_UART_PIPE */ - /* externs (internal APIs) */ GTEXT(_IntEnt) diff --git a/arch/x86/platforms/ia32/Kconfig b/arch/x86/platforms/ia32/Kconfig index 20f84f8f773..f7ee462e9c2 100644 --- a/arch/x86/platforms/ia32/Kconfig +++ b/arch/x86/platforms/ia32/Kconfig @@ -127,4 +127,15 @@ config BLUETOOTH_UART_IRQ_PRI endif +if UART_PIPE + +config UART_PIPE_ON_DEV_NAME + default "UART_1" +config UART_PIPE_IRQ + default 3 +config UART_PIPE_IRQ_PRI + default 3 + +endif + endif diff --git a/arch/x86/platforms/ia32/board.h b/arch/x86/platforms/ia32/board.h index 8e53e738374..bf18a6c1213 100644 --- a/arch/x86/platforms/ia32/board.h +++ b/arch/x86/platforms/ia32/board.h @@ -57,11 +57,6 @@ #ifdef CONFIG_UART_NS16550 -/* Pipe UART definitions */ -#define CONFIG_UART_PIPE_INDEX 1 -#define CONFIG_UART_PIPE_IRQ CONFIG_UART_NS16550_PORT_1_IRQ -#define CONFIG_UART_PIPE_INT_PRI CONFIG_UART_NS16550_PORT_1_IRQ_PRI - #ifndef _ASMLANGUAGE extern struct device * const uart_devs[]; #endif diff --git a/arch/x86/platforms/quark_d2000/Kconfig b/arch/x86/platforms/quark_d2000/Kconfig index 6aa0bb38d3e..7f57c25bf80 100644 --- a/arch/x86/platforms/quark_d2000/Kconfig +++ b/arch/x86/platforms/quark_d2000/Kconfig @@ -129,4 +129,15 @@ config BLUETOOTH_UART_IRQ_PRI endif +if UART_PIPE + +config UART_PIPE_ON_DEV_NAME + default "UART_1" +config UART_PIPE_IRQ + default 38 +config UART_PIPE_IRQ_PRI + default 3 + +endif + endif diff --git a/arch/x86/platforms/quark_se/Kconfig b/arch/x86/platforms/quark_se/Kconfig index 6fd32fdfdba..ddeeba5c540 100644 --- a/arch/x86/platforms/quark_se/Kconfig +++ b/arch/x86/platforms/quark_se/Kconfig @@ -255,4 +255,15 @@ config BLUETOOTH_UART_IRQ_PRI endif +if UART_PIPE + +config UART_PIPE_ON_DEV_NAME + default "UART_1" +config UART_PIPE_IRQ + default 38 +config UART_PIPE_IRQ_PRI + default 3 + +endif + endif #PLATFORM_QUARK_SE_X86 diff --git a/drivers/console/Kconfig b/drivers/console/Kconfig index ffe3b36d982..b52476ba3fb 100644 --- a/drivers/console/Kconfig +++ b/drivers/console/Kconfig @@ -151,4 +151,26 @@ config UART_PIPE data (as contrary to console UART driver) and all aspects of received protocol data are handled by application provided callback. +config UART_PIPE_ON_DEV_NAME + string "Device Name of UART Device for pipe UART" + default "UART_0" + depends on UART_PIPE + help + This option specifies the name of UART device to be used + for pipe UART. + +config UART_PIPE_IRQ + int "IRQ for pipe UART" + depends on UART_PIPE + help + This option specifies the IRQ of UART device to be used + for pipe UART. + +config UART_PIPE_IRQ_PRI + int "IRQ Priority for pipe UART" + depends on UART_PIPE + help + This option specifies the IRQ priority of UART device + to be used for pipe UART. + endif diff --git a/drivers/console/Makefile b/drivers/console/Makefile index db665231a7a..5b9a1de6336 100644 --- a/drivers/console/Makefile +++ b/drivers/console/Makefile @@ -3,4 +3,4 @@ obj-$(CONFIG_UART_CONSOLE) += uart_console.o uart_console_static_irq_stubs.o obj-$(CONFIG_RAM_CONSOLE) += ram_console.o obj-$(CONFIG_IPI_CONSOLE_RECEIVER) += ipi_console_receiver.o obj-$(CONFIG_IPI_CONSOLE_SENDER) += ipi_console_sender.o -obj-$(CONFIG_UART_PIPE) += uart_pipe.o +obj-$(CONFIG_UART_PIPE) += uart_pipe.o uart_console_static_irq_stubs.o diff --git a/drivers/console/uart_console_static_irq_stubs.S b/drivers/console/uart_console_static_irq_stubs.S index 2682697ee2a..12550ce089a 100644 --- a/drivers/console/uart_console_static_irq_stubs.S +++ b/drivers/console/uart_console_static_irq_stubs.S @@ -33,6 +33,12 @@ #endif /* CONFIG_IOAPIC */ #endif /* CONFIG_CONSOLE_HANDLER */ +#if defined(CONFIG_UART_PIPE) +#if defined(CONFIG_IOAPIC) + ioapic_mkstub uart_pipe uart_pipe_isr 0 +#endif /* CONFIG_IOAPIC */ +#endif /* CONFIG_UART_PIPE */ + #undef _ASMLANGUAGE #endif /* CONFIG_X86 */ diff --git a/drivers/console/uart_pipe.c b/drivers/console/uart_pipe.c index 3a3ff16ec8b..b03eb6c5d44 100644 --- a/drivers/console/uart_pipe.c +++ b/drivers/console/uart_pipe.c @@ -29,10 +29,7 @@ #include #include -#if !defined(CONFIG_UART_PIPE_INDEX) || !defined(CONFIG_UART_PIPE_IRQ) -#error One or more required values for this driver are not set. -#else -#define UART (uart_devs[CONFIG_UART_PIPE_INDEX]) +static struct device *uart_pipe_dev; static uint8_t *recv_buf; static size_t recv_buf_len; @@ -43,14 +40,15 @@ void uart_pipe_isr(void *unused) { ARG_UNUSED(unused); - while (uart_irq_update(UART) && uart_irq_is_pending(UART)) { + while (uart_irq_update(uart_pipe_dev) + && uart_irq_is_pending(uart_pipe_dev)) { int rx; - if (!uart_irq_rx_ready(UART)) { + if (!uart_irq_rx_ready(uart_pipe_dev)) { continue; } - rx = uart_fifo_read(UART, recv_buf + recv_off, + rx = uart_fifo_read(uart_pipe_dev, recv_buf + recv_off, recv_buf_len - recv_off); if (!rx) { continue; @@ -67,11 +65,15 @@ void uart_pipe_isr(void *unused) int uart_pipe_send(const uint8_t *data, int len) { - return uart_fifo_fill(UART, data, len); + if (uart_pipe_dev != NULL) { + return uart_fifo_fill(uart_pipe_dev, data, len); + } else { + return 0; + } } IRQ_CONNECT_STATIC(uart_pipe, CONFIG_UART_PIPE_IRQ, - CONFIG_UART_PIPE_INT_PRI, uart_pipe_isr, 0, + CONFIG_UART_PIPE_IRQ_PRI, uart_pipe_isr, 0, UART_IRQ_FLAGS); static void uart_pipe_setup(struct device *uart) @@ -97,6 +99,9 @@ void uart_pipe_register(uint8_t *buf, size_t len, uart_pipe_recv_cb cb) recv_buf_len = len; app_cb = cb; - uart_pipe_setup(UART); + uart_pipe_dev = device_get_binding(CONFIG_UART_PIPE_ON_DEV_NAME); + + if (uart_pipe_dev != NULL) { + uart_pipe_setup(uart_pipe_dev); + } } -#endif