void __init dt_uart_init(void) { struct dt_device_node *dev; int ret; const char *devpath = opt_dtuart; char *options; if ( !console_has("dtuart") ) return; /* Not for us */ if ( !strcmp(opt_dtuart, "") ) { const struct dt_device_node *chosen = dt_find_node_by_path("/chosen"); if ( chosen ) { const char *stdout; ret = dt_property_read_string(chosen, "stdout-path", &stdout); if ( ret >= 0 ) { printk("Taking dtuart configuration from /chosen/stdout-path\n"); if ( strlcpy(opt_dtuart, stdout, sizeof(opt_dtuart)) >= sizeof(opt_dtuart) ) printk("WARNING: /chosen/stdout-path too long, truncated\n"); } else if ( ret != -EINVAL /* Not present */ ) printk("Failed to read /chosen/stdout-path (%d)\n", ret); } } if ( !strcmp(opt_dtuart, "") ) { printk("No dtuart path configured\n"); return; } options = strchr(opt_dtuart, ':'); if ( options != NULL ) *(options++) = '\0'; else options = ""; printk("Looking for dtuart at \"%s\", options \"%s\"\n", devpath, options); if ( *devpath == '/' ) dev = dt_find_node_by_path(devpath); else dev = dt_find_node_by_alias(devpath); if ( !dev ) { printk("Unable to find device \"%s\"\n", devpath); return; } ret = device_init(dev, DEVICE_SERIAL, options); if ( ret ) printk("Unable to initialize dtuart: %d\n", ret); }
void __init dt_uart_init(void) { struct dt_device_node *dev; int ret; const char *devalias = opt_dtuart; char *options; if ( !console_has("dtuart") || !strcmp(opt_dtuart, "") ) { early_printk("No console\n"); return; } options = strchr(opt_dtuart, ','); if ( options != NULL ) *(options++) = '\0'; else options = ""; early_printk("Looking for UART console %s\n", devalias); dev = dt_find_node_by_alias(devalias); if ( !dev ) { early_printk("Unable to find device \"%s\"\n", devalias); return; } ret = device_init(dev, DEVICE_SERIAL, options); if ( ret ) early_printk("Unable to initialize serial: %d\n", ret); }