9
0
Fork 0

Merge branch 'for-next/console'

This commit is contained in:
Sascha Hauer 2013-10-07 07:59:18 +02:00
commit 574947ef76
34 changed files with 51 additions and 102 deletions

View File

@ -70,9 +70,7 @@ static int fdt_stdout_setup(struct device_node *blob)
goto error;
}
for_each_console(cdev)
if ((cdev->f_active & (CONSOLE_STDIN | CONSOLE_STDOUT)))
break;
cdev = console_get_first_active();
if (cdev)
sprintf(sername, "serial%d", cdev->dev->id);
else

View File

@ -36,11 +36,6 @@ int barebox_register_console(char *name, int stdinfd, int stdoutfd)
strcpy(dev->name, "console");
if (stdinfd >= 0)
data->flags = CONSOLE_STDIN;
if (stdoutfd >= 0)
data->flags |= CONSOLE_STDOUT | CONSOLE_STDERR;
data->stdoutfd = stdoutfd;
data->stdinfd = stdinfd;

View File

@ -23,7 +23,6 @@ int barebox_register_console(char *name_template, int stdinfd, int stdoutfd);
struct linux_console_data {
int stdinfd;
int stdoutfd;
unsigned int flags;
};
extern int sdl_xres;

View File

@ -590,26 +590,6 @@ err_quit:
return size;
}
/**
* @brief returns current used console device
*
* @return console device which is registered with CONSOLE_STDIN and
* CONSOLE_STDOUT
*/
static struct console_device *get_current_console(void)
{
struct console_device *cdev;
/*
* Assumption to have BOTH CONSOLE_STDIN AND STDOUT in the
* same output console
*/
for_each_console(cdev) {
if ((cdev->f_active & (CONSOLE_STDIN | CONSOLE_STDOUT)))
return cdev;
}
return NULL;
}
/**
* @brief provide the loadb(Kermit) or loadY mode support
*
@ -650,7 +630,7 @@ static int do_load_serial_bin(int argc, char *argv[])
}
}
cdev = get_current_console();
cdev = console_get_first_active();
if (NULL == cdev) {
printf("%s:No console device with STDIN and STDOUT\n", argv[0]);
return -ENODEV;

View File

@ -40,26 +40,6 @@
#define DEF_FILE "image.bin"
/**
* @brief returns current used console device
*
* @return console device which is registered with CONSOLE_STDIN and
* CONSOLE_STDOUT
*/
static struct console_device *get_current_console(void)
{
struct console_device *cdev;
/*
* Assumption to have BOTH CONSOLE_STDIN AND STDOUT in the
* same output console
*/
for_each_console(cdev) {
if ((cdev->f_active & (CONSOLE_STDIN | CONSOLE_STDOUT)))
return cdev;
}
return NULL;
}
static int console_change_speed(struct console_device *cdev, int baudrate)
{
int current_baudrate;
@ -134,7 +114,7 @@ static int do_loady(int argc, char *argv[])
if (cname)
cdev = get_named_console(cname);
else
cdev = get_current_console();
cdev = console_get_first_active();
if (!cdev) {
printf("%s:No console device %s with STDIN and STDOUT\n",
argv[0], cname ? cname : "default");
@ -202,7 +182,7 @@ static int do_loadx(int argc, char *argv[])
if (cname)
cdev = get_named_console(cname);
else
cdev = get_current_console();
cdev = console_get_first_active();
if (!cdev) {
printf("%s:No console device %s with STDIN and STDOUT\n",
argv[0], cname ? cname : "default");

View File

@ -63,19 +63,21 @@ static int console_std_set(struct device_d *dev, struct param_d *param,
unsigned int flag = 0, i = 0;
if (val) {
if (strchr(val, 'i') && cdev->f_caps & CONSOLE_STDIN) {
if (strchr(val, 'i') && cdev->getc) {
active[i++] = 'i';
flag |= CONSOLE_STDIN;
}
if (strchr(val, 'o') && cdev->f_caps & CONSOLE_STDOUT) {
active[i++] = 'o';
flag |= CONSOLE_STDOUT;
}
if (cdev->putc) {
if (strchr(val, 'o')) {
active[i++] = 'o';
flag |= CONSOLE_STDOUT;
}
if (strchr(val, 'e') && cdev->f_caps & CONSOLE_STDERR) {
active[i++] = 'e';
flag |= CONSOLE_STDERR;
if (strchr(val, 'e')) {
active[i++] = 'e';
flag |= CONSOLE_STDERR;
}
}
}

View File

@ -108,3 +108,25 @@ int fputc(int fd, char c)
return 0;
}
EXPORT_SYMBOL(fputc);
/*
* @brief returns current used console device
*
* @return console device which is registered with CONSOLE_STDIN and
* CONSOLE_STDOUT
*/
struct console_device *console_get_first_active(void)
{
struct console_device *cdev;
/*
* Assumption to have BOTH CONSOLE_STDIN AND STDOUT in the
* same output console
*/
for_each_console(cdev) {
if ((cdev->f_active & (CONSOLE_STDIN | CONSOLE_STDOUT)))
return cdev;
}
return NULL;
}
EXPORT_SYMBOL(console_get_first_active);

View File

@ -82,6 +82,13 @@ int console_register(struct console_device *newcdev)
console_list.prev = console_list.next = &newcdev->list;
newcdev->list.prev = newcdev->list.next = &console_list;
if (newcdev->setbrg) {
newcdev->baudrate = CONFIG_BAUDRATE;
newcdev->setbrg(newcdev, newcdev->baudrate);
}
newcdev->f_active = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
barebox_banner();
return 0;

View File

@ -95,7 +95,6 @@ static int __init gpio_keys_probe(struct device_d *dev)
cdev = &pdata->cdev;
dev->type_data = cdev;
cdev->dev = dev;
cdev->f_caps = CONSOLE_STDIN;
cdev->tstc = gpio_keys_tstc;
cdev->getc = gpio_keys_getc;

View File

@ -441,7 +441,6 @@ static int __init imx_keypad_probe(struct device_d *dev)
cdev->dev = dev;
cdev->tstc = imx_keypad_tstc;
cdev->getc = imx_keypad_getc;
cdev->f_caps = CONSOLE_STDIN;
cdev->f_active = CONSOLE_STDIN;
console_register(&keypad->cdev);

View File

@ -265,7 +265,6 @@ static int qt1070_probe(struct device_d *dev)
cdev = &data->cdev;
cdev->dev = dev;
cdev->f_caps = CONSOLE_STDIN;
cdev->tstc = qt1070_tstc;
cdev->getc = qt1070_getc;

View File

@ -93,7 +93,6 @@ static int __init twl6030_pwrbtn_probe(struct device_d *dev)
dev->type_data = &idata->cdev;
idata->cdev.dev = dev;
idata->cdev.f_caps = CONSOLE_STDIN;
idata->cdev.tstc = twl6030_pwrbtn_tstc;
idata->cdev.getc = twl6030_pwrbtn_getc;
console_register(&idata->cdev);

View File

@ -163,10 +163,6 @@ int pl011_init_port (struct console_device *cdev)
uart->uartclk = clk_get_rate(uart->clk);
/*
* set baud rate
*/
pl011_setbaudrate(cdev, 115200);
/*
** Set the UART to be 8 bits, 1 stop bit, no parity, fifo enabled.
*/
@ -196,7 +192,6 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
cdev = &uart->uart;
cdev->dev = &dev->dev;
cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
cdev->tstc = pl011_tstc;
cdev->putc = pl011_putc;
cdev->getc = pl011_getc;

View File

@ -133,7 +133,6 @@ static int arm_dcc_probe(struct device_d *dev)
cdev = &arm_dcc_dev;
cdev->dev = dev;
cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
cdev->tstc = arm_dcc_tstc;
cdev->putc = arm_dcc_putc;
cdev->getc = arm_dcc_getc;

View File

@ -379,8 +379,6 @@ static int atmel_serial_init_port(struct console_device *cdev)
writel(USART3_BIT(RSTRX) | USART3_BIT(RSTTX), uart->base + USART3_CR);
atmel_serial_setbaudrate(cdev, 115200);
writel(USART3_BIT(RXEN) | USART3_BIT(TXEN), uart->base + USART3_CR);
writel((USART3_BF(USART_MODE, USART3_USART_MODE_NORMAL)
| USART3_BF(USCLKS, USART3_USCLKS_MCK)
@ -399,7 +397,6 @@ static int atmel_serial_probe(struct device_d *dev)
uart = xzalloc(sizeof(struct atmel_uart_port));
cdev = &uart->uart;
cdev->dev = dev;
cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
cdev->tstc = atmel_serial_tstc;
cdev->putc = atmel_serial_putc;
cdev->getc = atmel_serial_getc;

View File

@ -64,10 +64,12 @@ static int linux_console_probe(struct device_d *dev)
cdev = xzalloc(sizeof(struct console_device));
cdev->dev = dev;
cdev->f_caps = data->flags;
cdev->tstc = linux_console_tstc;
cdev->putc = linux_console_putc;
cdev->getc = linux_console_getc;
if (data->stdinfd >= 0) {
cdev->tstc = linux_console_tstc;
cdev->getc = linux_console_getc;
}
if (data->stdoutfd >= 0)
cdev->putc = linux_console_putc;
console_register(cdev);

View File

@ -86,7 +86,6 @@ static int altera_serial_probe(struct device_d *dev)
priv->regs = dev_request_mem_region(dev, 0);
cdev->dev = dev;
cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
cdev->tstc = altera_serial_tstc;
cdev->putc = altera_serial_putc;
cdev->getc = altera_serial_getc;

View File

@ -91,7 +91,6 @@ static int altera_serial_jtag_probe(struct device_d *dev) {
priv->regs = dev_request_mem_region(dev, 0);
cdev->dev = dev;
cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
cdev->tstc = altera_serial_jtag_tstc;
cdev->putc = altera_serial_jtag_putc;
cdev->getc = altera_serial_jtag_getc;

View File

@ -187,7 +187,6 @@ static int auart_serial_probe(struct device_d *dev)
priv = xzalloc(sizeof *priv);
cdev = &priv->cdev;
cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
cdev->tstc = auart_serial_tstc;
cdev->putc = auart_serial_putc;
cdev->getc = auart_serial_getc;
@ -202,7 +201,6 @@ static int auart_serial_probe(struct device_d *dev)
return PTR_ERR(priv->clk);
auart_serial_init_port(priv);
auart_serial_setbaudrate(cdev, CONFIG_BAUDRATE);
/* Disable RTS/CTS, enable Rx, Tx, UART */
writel(BM_UARTAPP_CTRL2_RTSEN | BM_UARTAPP_CTRL2_CTSEN |

View File

@ -113,7 +113,6 @@ static int blackfin_serial_probe(struct device_d *dev)
cdev = xzalloc(sizeof(struct console_device));
cdev->dev = dev;
cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
cdev->tstc = blackfin_serial_tstc;
cdev->putc = blackfin_serial_putc;
cdev->getc = blackfin_serial_getc;

View File

@ -246,7 +246,6 @@ static int cadence_serial_probe(struct device_d *dev)
}
cdev->dev = dev;
cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
cdev->tstc = cadence_serial_tstc;
cdev->putc = cadence_serial_putc;
cdev->getc = cadence_serial_getc;

View File

@ -58,9 +58,6 @@ static void clps711x_init_port(struct console_device *cdev)
tmp |= UBRLCR_FIFOEN | UBRLCR_WRDLEN8; /* FIFO on, 8N1 mode */
writel(tmp, s->UBRLCR);
/* Set default baudrate on initialization */
clps711x_setbaudrate(cdev, CONFIG_BAUDRATE);
/* Enable the UART */
writel(readl(SYSCON(s)) | SYSCON_UARTEN, SYSCON(s));
}
@ -131,7 +128,6 @@ static int clps711x_probe(struct device_d *dev)
dev->priv = s;
s->cdev.dev = dev;
s->cdev.f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
s->cdev.tstc = clps711x_tstc;
s->cdev.putc = clps711x_putc;
s->cdev.getc = clps711x_getc;

View File

@ -330,7 +330,6 @@ static int imx_serial_probe(struct device_d *dev)
priv->regs = dev_request_mem_region(dev, 0);
cdev->dev = dev;
cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
cdev->tstc = imx_serial_tstc;
cdev->putc = imx_serial_putc;
cdev->getc = imx_serial_getc;
@ -338,7 +337,6 @@ static int imx_serial_probe(struct device_d *dev)
cdev->setbrg = imx_serial_setbaudrate;
imx_serial_init_port(cdev);
imx_serial_setbaudrate(cdev, 115200);
/* Enable UART */
val = readl(priv->regs + UCR1);

View File

@ -149,7 +149,6 @@ static int mpc5xxx_serial_probe(struct device_d *dev)
cdev = xzalloc(sizeof(struct console_device));
dev->priv = dev_request_mem_region(dev, 0);
cdev->dev = dev;
cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
cdev->tstc = mpc5xxx_serial_tstc;
cdev->putc = mpc5xxx_serial_putc;
cdev->getc = mpc5xxx_serial_getc;

View File

@ -138,7 +138,6 @@ static int netx_serial_probe(struct device_d *dev)
cdev = xzalloc(sizeof(struct console_device));
dev->priv = dev_request_mem_region(dev, 0);
cdev->dev = dev;
cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
cdev->tstc = netx_serial_tstc;
cdev->putc = netx_serial_putc;
cdev->getc = netx_serial_getc;

View File

@ -183,8 +183,6 @@ static void ns16550_serial_init_port(struct console_device *cdev)
ns16550_write(cdev, 0x07, mdr1); /* Disable */
#endif
ns16550_setbaudrate(cdev, CONFIG_BAUDRATE);
#ifdef CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS
ns16550_write(cdev, 0x00, mdr1);
#endif
@ -291,7 +289,6 @@ static int ns16550_probe(struct device_d *dev)
cdev = &priv->cdev;
cdev->dev = dev;
cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
cdev->tstc = ns16550_tstc;
cdev->putc = ns16550_putc;
cdev->getc = ns16550_getc;

View File

@ -62,7 +62,6 @@ static int serial_omap4_usbboot_probe(struct device_d *dev)
priv = xzalloc(sizeof(*priv));
priv->cdev.dev = dev;
priv->cdev.f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
priv->cdev.tstc = serial_omap4_usbboot_tstc;
priv->cdev.putc = serial_omap4_usbboot_putc;
priv->cdev.getc = serial_omap4_usbboot_getc;

View File

@ -140,7 +140,6 @@ static int pl010_probe(struct device_d *dev)
cdev = xzalloc(sizeof(struct console_device));
dev->priv = dev_request_mem_region(dev, 0);
cdev->dev = dev;
cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
cdev->tstc = pl010_tstc;
cdev->putc = pl010_putc;
cdev->getc = pl010_getc;

View File

@ -170,7 +170,6 @@ static int pxa_serial_probe(struct device_d *dev)
dev->priv = priv;
cdev->dev = dev;
cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
cdev->tstc = pxa_serial_tstc;
cdev->putc = pxa_serial_putc;
cdev->getc = pxa_serial_getc;

View File

@ -184,7 +184,6 @@ static int s3c_serial_probe(struct device_d *dev)
priv->regs = dev_request_mem_region(dev, 0);
dev->priv = priv;
cdev->dev = dev;
cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
cdev->tstc = s3c_serial_tstc;
cdev->putc = s3c_serial_putc;
cdev->getc = s3c_serial_getc;

View File

@ -153,7 +153,6 @@ static int stm_serial_probe(struct device_d *dev)
cdev = &priv->cdev;
cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
cdev->tstc = stm_serial_tstc;
cdev->putc = stm_serial_putc;
cdev->getc = stm_serial_getc;

View File

@ -478,7 +478,6 @@ int gserial_connect(struct gserial *gser, u8 port_num)
gser->connect(gser);
cdev = &port->cdev;
cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
cdev->tstc = serial_tstc;
cdev->putc = serial_putc;
cdev->getc = serial_getc;

View File

@ -40,7 +40,6 @@ struct console_device {
struct list_head list;
unsigned char f_caps;
unsigned char f_active;
unsigned int baudrate;
@ -54,4 +53,6 @@ extern struct list_head console_list;
#define CFG_PBSIZE (CONFIG_CBSIZE+sizeof(CONFIG_PROMPT)+16)
struct console_device *console_get_first_active(void);
#endif

View File

@ -72,7 +72,6 @@ static int nc_init(void)
}
net_udp_bind(priv->con, priv->port);
priv->cdev.f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
return 0;
}