-/* $OpenBSD: acpi.c,v 1.402 2021/12/07 10:15:25 kettenis Exp $ */
+/* $OpenBSD: acpi.c,v 1.403 2021/12/16 08:03:17 anton Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
"PNP0303", /* IBM Enhanced Keyboard (101/102-key, PS/2 Mouse) */
"PNP0400", /* Standard LPT Parallel Port */
"PNP0401", /* ECP Parallel Port */
- "PNP0501", /* 16550A-compatible COM Serial Port */
"PNP0700", /* PC-class Floppy Disk Controller */
"PNP0F03", /* Microsoft PS/2-style Mouse */
"PNP0F13", /* PS/2 Mouse */
-/* $OpenBSD: com_acpi.c,v 1.2 2020/05/08 11:18:01 kettenis Exp $ */
+/* $OpenBSD: com_acpi.c,v 1.3 2021/12/16 08:03:17 anton Exp $ */
/*
* Copyright (c) 2018 Mark Kettenis
*
const char *com_hids[] = {
"HISI0031",
+ "PNP0501",
NULL
};
int com_acpi_is_console(struct com_acpi_softc *);
+int com_acpi_is_designware(const char *);
int com_acpi_intr_designware(void *);
int
{
struct com_acpi_softc *sc = (struct com_acpi_softc *)self;
struct acpi_attach_args *aaa = aux;
- uint32_t freq;
+ int (*intrfn)(void *) = comintr;
sc->sc_acpi = (struct acpi_softc *)parent;
sc->sc_node = aaa->aaa_node;
printf(" addr 0x%llx/0x%llx", aaa->aaa_addr[0], aaa->aaa_size[0]);
printf(" irq %d", aaa->aaa_irq[0]);
- freq = acpi_getpropint(sc->sc_node, "clock-frequency", 0);
-
sc->sc.sc_iot = aaa->aaa_bst[0];
sc->sc.sc_iobase = aaa->aaa_addr[0];
- sc->sc.sc_uarttype = COM_UART_16550;
- sc->sc.sc_frequency = freq ? freq : COM_FREQ;
-
- sc->sc.sc_reg_width = acpi_getpropint(sc->sc_node, "reg-io-width", 4);
- sc->sc.sc_reg_shift = acpi_getpropint(sc->sc_node, "reg-shift", 2);
-
- if (com_acpi_is_console(sc)) {
- SET(sc->sc.sc_hwflags, COM_HW_CONSOLE);
- SET(sc->sc.sc_swflags, COM_SW_SOFTCAR);
- comconsfreq = sc->sc.sc_frequency;
- comconsrate = B115200;
+ sc->sc.sc_frequency = acpi_getpropint(sc->sc_node, "clock-frequency",
+ COM_FREQ);
+
+ if (com_acpi_is_designware(aaa->aaa_dev)) {
+ intrfn = com_acpi_intr_designware;
+ sc->sc.sc_uarttype = COM_UART_16550;
+ sc->sc.sc_reg_width = acpi_getpropint(sc->sc_node,
+ "reg-io-width", 4);
+ sc->sc.sc_reg_shift = acpi_getpropint(sc->sc_node,
+ "reg-shift", 2);
+
+ if (com_acpi_is_console(sc)) {
+ SET(sc->sc.sc_hwflags, COM_HW_CONSOLE);
+ SET(sc->sc.sc_swflags, COM_SW_SOFTCAR);
+ comconsfreq = sc->sc.sc_frequency;
+ comconsrate = B115200;
+ }
}
- if (bus_space_map(sc->sc.sc_iot, aaa->aaa_addr[0], aaa->aaa_size[0],
- 0, &sc->sc.sc_ioh)) {
- printf(": can't map registers\n");
- return;
+ if (sc->sc.sc_iobase == comconsaddr) {
+ sc->sc.sc_ioh = comconsioh;
+ } else {
+ if (bus_space_map(sc->sc.sc_iot,
+ aaa->aaa_addr[0], aaa->aaa_size[0], 0, &sc->sc.sc_ioh)) {
+ printf(": can't map registers\n");
+ return;
+ }
}
sc->sc_ih = acpi_intr_establish(aaa->aaa_irq[0], aaa->aaa_irq_flags[0],
- IPL_TTY, com_acpi_intr_designware, sc, sc->sc.sc_dev.dv_xname);
+ IPL_TTY, intrfn, sc, sc->sc.sc_dev.dv_xname);
if (sc->sc_ih == NULL) {
printf(": can't establish interrupt\n");
return;
return 0;
}
+int
+com_acpi_is_designware(const char *hid)
+{
+ return strcmp("HISI0031", hid) == 0;
+}
+
int
com_acpi_intr_designware(void *cookie)
{