Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/uart/uart_dev_ti8250.c
Show All 33 Lines | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/bus.h> | #include <sys/bus.h> | ||||
#include <sys/conf.h> | #include <sys/conf.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <machine/bus.h> | #include <machine/bus.h> | ||||
#include <arm/ti/ti_prcm.h> | |||||
#include <arm/ti/ti_hwmods.h> | |||||
#include <dev/fdt/fdt_common.h> | #include <dev/fdt/fdt_common.h> | ||||
#include <dev/ofw/ofw_bus.h> | #include <dev/ofw/ofw_bus.h> | ||||
#include <dev/ofw/ofw_bus_subr.h> | #include <dev/ofw/ofw_bus_subr.h> | ||||
#include <dev/uart/uart.h> | #include <dev/uart/uart.h> | ||||
#include <dev/uart/uart_cpu.h> | #include <dev/uart/uart_cpu.h> | ||||
#include <dev/uart/uart_cpu_fdt.h> | #include <dev/uart/uart_cpu_fdt.h> | ||||
#include <dev/uart/uart_bus.h> | #include <dev/uart/uart_bus.h> | ||||
#include <dev/uart/uart_dev_ns8250.h> | #include <dev/uart/uart_dev_ns8250.h> | ||||
#include <arm/ti/ti_sysc.h> | |||||
#include "uart_if.h" | #include "uart_if.h" | ||||
/* | /* | ||||
* High-level UART interface. | * High-level UART interface. | ||||
*/ | */ | ||||
struct ti8250_softc { | struct ti8250_softc { | ||||
struct ns8250_softc ns8250_base; | struct ns8250_softc ns8250_base; | ||||
/*uint32_t mystuff;*/ | /*uint32_t mystuff;*/ | ||||
}; | }; | ||||
#define MDR1_REG 8 | #define MDR1_REG 8 | ||||
#define MDR1_MODE_UART 0 | #define MDR1_MODE_UART 0 | ||||
#define MDR1_MODE_DISABLE 7 | #define MDR1_MODE_DISABLE 7 | ||||
#define SYSCC_REG 15 | #define SYSCC_REG 15 | ||||
#define SYSCC_SOFTRESET (1 << 1) | #define SYSCC_SOFTRESET (1 << 1) | ||||
#define SYSS_REG 16 | #define SYSS_REG 16 | ||||
#define SYSS_STATUS_RESETDONE (1 << 0) | #define SYSS_STATUS_RESETDONE (1 << 0) | ||||
static int | static int | ||||
ti8250_bus_probe(struct uart_softc *sc) | ti8250_bus_probe(struct uart_softc *sc) | ||||
{ | { | ||||
int status; | int status; | ||||
clk_ident_t clkid; | |||||
/* Enable clocks for this device. We can't continue if that fails. */ | if ((status = ti_sysc_clock_enable(device_get_parent(sc->sc_dev))) != 0) | ||||
clkid = ti_hwmods_get_clock(sc->sc_dev); | |||||
if (clkid == INVALID_CLK_IDENT) { | |||||
device_printf(sc->sc_dev, | |||||
"failed to get clock based on hwmods\n"); | |||||
clkid = UART1_CLK + device_get_unit(sc->sc_dev); | |||||
} | |||||
if ((status = ti_prcm_clk_enable(clkid)) != 0) | |||||
return (status); | return (status); | ||||
/* | /* | ||||
* Set the hardware to disabled mode, do a full device reset, then set | * 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, | * it to uart mode. Most devices will be reset-and-disabled already, | ||||
* but you never know what a bootloader might have done. | * 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, MDR1_REG, MDR1_MODE_DISABLE); | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |