Example #1
0
static int
ti8250_bus_probe(struct uart_softc *sc)
{
	int status;
	int devid;
	clk_ident_t clkid;
	pcell_t prop;
	phandle_t node;

	/*
	 * Get the device id from FDT.  If it's not there we can't turn on the
	 * right clocks, so bail, unless we're doing unit 0.  We assume that's
	 * the serial console, whose clock isn't controllable anyway, and we
	 * sure don't want to break the console because of a config error.
	 */
	node = ofw_bus_get_node(sc->sc_dev);
	if ((OF_getprop(node, "uart-device-id", &prop, sizeof(prop))) <= 0) {
		device_printf(sc->sc_dev, 
		    "missing uart-device-id attribute in FDT\n");
		if (device_get_unit(sc->sc_dev) != 0)
			return (ENXIO);
		devid = 0;
	} else
		devid = fdt32_to_cpu(prop);

	/* Enable clocks for this device.  We can't continue if that fails.  */
	clkid = UART0_CLK + devid;
	if ((status = ti_prcm_clk_enable(clkid)) != 0)
		return (status);

	/*
	 * Set the hardware to disabled mode, do a full device reset, then set
	 * it to uart mode.  Most devices will be reset-and-disabled already,
	 * but you never know what a bootloader might have done.
	 */
	uart_setreg(&sc->sc_bas, MDR1_REG, MDR1_MODE_DISABLE);
	uart_setreg(&sc->sc_bas, SYSCC_REG, SYSCC_SOFTRESET);
	while (uart_getreg(&sc->sc_bas, SYSS_REG) & SYSS_STATUS_RESETDONE)
		continue;
	uart_setreg(&sc->sc_bas, MDR1_REG, MDR1_MODE_UART);

	status = ns8250_bus_probe(sc); 
	if (status == 0)
		device_set_desc(sc->sc_dev, "TI UART (16550 compatible)");

	return (status);
}
Example #2
0
static int
mtk_ns8250_bus_probe(struct uart_softc *sc)
{       
	int status;
       
	if (!ofw_bus_status_okay(sc->sc_dev))
		return (ENXIO);
        
	if (ofw_bus_search_compatible(sc->sc_dev, compat_data)->ocd_data ==
	    (uintptr_t)NULL)
		return (ENXIO);
        
	sc->sc_bas.rclk = mtk_soc_get_uartclk();
        
	status = ns8250_bus_probe(sc);
	if (status == 0)
		device_set_desc(sc->sc_dev, "MTK UART Controller (ns16550a)");
        
	return (status);
}