uart_pipe: use device name instead of index

Use device name to find the UART device for uart_pipe usage,
instead of relying on an arbitrary index.

Change-Id: I36aaa4ed8f0b4905e4e741ca1464947e59f30869
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2015-12-01 08:42:20 -08:00 committed by Anas Nashif
commit 5cdd4584fe
11 changed files with 89 additions and 28 deletions

View file

@ -122,4 +122,15 @@ config BLUETOOTH_UART_IRQ_PRI
endif 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 endif

View file

@ -96,11 +96,6 @@
extern struct device * const uart_devs[]; 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 /* !_ASMLANGUAGE */
#endif /* _BOARD__H_ */ #endif /* _BOARD__H_ */

View file

@ -37,12 +37,6 @@ by x86 platforms.
ioapic_mkstub hpet _timer_int_handler 0 ioapic_mkstub hpet _timer_int_handler 0
#endif #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) */ /* externs (internal APIs) */
GTEXT(_IntEnt) GTEXT(_IntEnt)

View file

@ -127,4 +127,15 @@ config BLUETOOTH_UART_IRQ_PRI
endif 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 endif

View file

@ -57,11 +57,6 @@
#ifdef CONFIG_UART_NS16550 #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 #ifndef _ASMLANGUAGE
extern struct device * const uart_devs[]; extern struct device * const uart_devs[];
#endif #endif

View file

@ -129,4 +129,15 @@ config BLUETOOTH_UART_IRQ_PRI
endif 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 endif

View file

@ -255,4 +255,15 @@ config BLUETOOTH_UART_IRQ_PRI
endif 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 endif #PLATFORM_QUARK_SE_X86

View file

@ -151,4 +151,26 @@ config UART_PIPE
data (as contrary to console UART driver) and all aspects of received data (as contrary to console UART driver) and all aspects of received
protocol data are handled by application provided callback. 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 endif

View file

@ -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_RAM_CONSOLE) += ram_console.o
obj-$(CONFIG_IPI_CONSOLE_RECEIVER) += ipi_console_receiver.o obj-$(CONFIG_IPI_CONSOLE_RECEIVER) += ipi_console_receiver.o
obj-$(CONFIG_IPI_CONSOLE_SENDER) += ipi_console_sender.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

View file

@ -33,6 +33,12 @@
#endif /* CONFIG_IOAPIC */ #endif /* CONFIG_IOAPIC */
#endif /* CONFIG_CONSOLE_HANDLER */ #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 #undef _ASMLANGUAGE
#endif /* CONFIG_X86 */ #endif /* CONFIG_X86 */

View file

@ -29,10 +29,7 @@
#include <console/uart_pipe.h> #include <console/uart_pipe.h>
#include <misc/printk.h> #include <misc/printk.h>
#if !defined(CONFIG_UART_PIPE_INDEX) || !defined(CONFIG_UART_PIPE_IRQ) static struct device *uart_pipe_dev;
#error One or more required values for this driver are not set.
#else
#define UART (uart_devs[CONFIG_UART_PIPE_INDEX])
static uint8_t *recv_buf; static uint8_t *recv_buf;
static size_t recv_buf_len; static size_t recv_buf_len;
@ -43,14 +40,15 @@ void uart_pipe_isr(void *unused)
{ {
ARG_UNUSED(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; int rx;
if (!uart_irq_rx_ready(UART)) { if (!uart_irq_rx_ready(uart_pipe_dev)) {
continue; 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); recv_buf_len - recv_off);
if (!rx) { if (!rx) {
continue; continue;
@ -67,11 +65,15 @@ void uart_pipe_isr(void *unused)
int uart_pipe_send(const uint8_t *data, int len) 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, 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); UART_IRQ_FLAGS);
static void uart_pipe_setup(struct device *uart) 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; recv_buf_len = len;
app_cb = cb; 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