Re: Porting amdgpio driver from OpenBSD
Here it is: https://github.com/brunomaximom/NetBSD-src Sent from ProtonMail, Swiss-based encrypted email. > --- Original Message --- > On segunda-feira, 12 de dezembro de 2022 às 8:59 AM, Taylor R Campbell > riastr...@netbsd.org wrote: > > > > > > Date: Mon, 12 Dec 2022 02:57:27 + > > > From: Bruno Melo bm...@protonmail.com > > > > > > No progress yet. > > > > > > I can see 2 things: > > > First one, I put the following code inside acpi_res_irq function to > > > check how setted is the data passed to SIMPLEQ_FOREACH: > > > [...] > > > > Can you share your current code? > > > > (At this point I would recommend you create a git repository for it -- > > maybe just for the .c/.h file in the driver, maybe a branch in a clone > > of your NetBSD reposoitory if you have any other changes outside the > > driver's .c/.h file.)
Re: Porting amdgpio driver from OpenBSD
No progress yet. I can see 2 things: First one, I put the following code inside acpi_res_irq function to check how setted is the data passed to SIMPLEQ_FOREACH: if (&res->ar_irq != NULL) { printf(" &res->ar_irq != NULL\n"); } else { printf(" &res->ar_irq == NULL\n"); } if ((&res->ar_irq)->sqh_first != NULL) { printf(" (&res->ar_irq)->sqh_first != NULL\n"); } else { printf(" (&res->ar_irq)->sqh_first == NULL\n"); } and what I see is during boot many devices print the messages &res->ar_irq != NULL *and* (&res->ar_irq)->sqh_first != NULL, but ihidev device print printf(" &res->ar_irq != NULL *and* (&res->ar_irq)->sqh_first == NULL. Second one, i put a print placed inside if (ops->fini) of acpi_resource_parse function, and ihidev never runs that print, but runs the print inside the if (ops->init). Any guidance on this? Sent from ProtonMail, Swiss-based encrypted email. --- Original Message --- On sexta-feira, 9 de dezembro de 2022 às 11:39 AM, Bruno Melo wrote: > I'm putting printf everywhere and I identified the struct acpi_resources res > variable is not valid condition to SIMPLEQ_FOREACH(ar, &res->ar_irq, ar_list) > in acpi_res_irq(). Trying to identify why. > > > In acpi_resource_parse() called by ihidev_intr_init() I see the if condition > in if (ops->init) is valid and I can see my printf being printed inside this > if, so the res should be allocated correctly, but when res is passed in > acpi_res_irq() my printf is not printed inside that SIMPLEQ_FOREACH. Stucked > here. I put printf everywhere else and got things printed correctly, except > in SIMPLEQ_FOREACH when ihidev code calls acpi_res_irq(). > > > When I compare the attach functions of the new amdgpio_acpi driver and other > *_acpi code I can't find any relevant difference for this be happening. Any > idea? > > > > Sent from ProtonMail, Swiss-based encrypted email. > > > > > --- Original Message --- > On terça-feira, 6 de dezembro de 2022 às 00:35, Bruno Melo > bm...@protonmail.com wrote: > > > > > I finished the port of OpenBSD driver and now I have these lines at boot > > time: > > > > MEM (PNP0C01) at acpi0 not configured > > VPC0 (VPC2004) at acpi0 not configured > > ITSD (IDEA2004) at acpi0 not configured > > HKDV (LKH2019) at acpi0 not configured > > acpiwmibus at acpiwmi1 not configured > > > > What should I do with them? How to fix them? Anyway to make them > > configurable? > > > > Sent from ProtonMail, Swiss-based encrypted email. > > > > --- Original Message --- > > On segunda-feira, 28 de novembro de 2022 às 11:11 PM, Bruno Melo > > bm...@protonmail.com wrote: > > > > > Hi folks, > > > > > > I'm trying to port amdgpio.c from OpenBSD (/sys/dev/acpi) to NetBSD then > > > I can use my trackpad hopefully. > > > I made some progress. The code is building but not crashing when the > > > system boots (as expected). But now I can see new devices as 'not > > > configured' message they did not exist before. > > > > > > MEM (PNP0C01) at acpi0 not configured > > > VPC0 (VPC2004) at acpi0 not configured > > > ITSD (IDEA2004) at acpi0 not configured > > > HKDV (LKH2019) at acpi0 not configured > > > acpiwmibus at acpiwmi1 not configured > > > > > > and then the crash happens in my bus_space_unmap(). Please, do you have > > > any idea what could be the problem or how i can investigate it? Picture > > > attached and code below: > > > > > > #include > > > > > > #include > > > > > > #include > > > > > > #include > > > > > > #include > > > > > > #include > > > > > > #include > > > > > > #include > > > > > > #include > > > > > > #include > > > > > > #include > > > > > > #include > > > > > > #define LR_GPIO_POLARITY (3L << 1) > > > #define LR_GPIO_ACTHI (0L << 1) > > > #define LR_GPIO_ACTLO (1L << 1) > > > #define LR_GPIO_ACTBOTH (2L << 1) > > > #define LR_GPIO_MODE (1L << 0) > > > #define LR_GPIO_LEVEL (0L << 0) > > > > > > #define AMDGPIO_CONF_LEVEL 0x0100 > > > #define AMDGPIO_CONF_ACTLO 0x0200 > > > #define AMDGPIO_CONF_ACTBOTH 0x0400 > > > #define AMDGPIO_CONF_MASK 0x0600 > > > #define AMDGPIO_CONF_INT_EN 0x0800 > > > #define AMDGPIO_CONF_INT_MASK 0x1000 > > > #define AMDGPIO_CONF_RXSTATE 0x0001 > > > #define AMDGPIO_CONF_TXSTATE 0x0040 > > > #define AMDGPIO_CONF_TXSTATE_EN 0x0080 > > > #define AMDGPIO_CONF_INT_STS 0x1000 > > > #define AMDGPIO_IRQ_MASTER_EOI 0x2000 > > > #define AMDGPIO_IRQ_BITS 46 > > > #define AMDGPIO_IRQ_PINS 4 > > > > > > #define AMDGPIO_IRQ_MASTER 0xfc > > > #define AMDGPIO_IRQ_STS 0x2f8 > > > > > > struct amdgpio_intrhand { > > > int (*ih_func)(void *); > > > void ih_arg; > > > }; > > > > > > struct amdgpio_pincfg { > > > / Modeled after pchgpio but we only have one value to > > > save/restore */ > > > uint32_t pin_cfg; > > > }; > > > > > > struct amdgpio_softc { > > > device_t sc_dev; > > > struct acpi_softc *sc_acpi; > > > ACPI_HANDL
Re: Porting amdgpio driver from OpenBSD
I'm putting printf everywhere and I identified the struct acpi_resources res variable is not valid condition to SIMPLEQ_FOREACH(ar, &res->ar_irq, ar_list) in acpi_res_irq(). Trying to identify why. In acpi_resource_parse() called by ihidev_intr_init() I see the if condition in if (ops->init) is valid and I can see my printf being printed inside this if, so the res should be allocated correctly, but when res is passed in acpi_res_irq() my printf is not printed inside that SIMPLEQ_FOREACH. Stucked here. I put printf everywhere else and got things printed correctly, except in SIMPLEQ_FOREACH when ihidev code calls acpi_res_irq(). When I compare the attach functions of the new amdgpio_acpi driver and other *_acpi code I can't find any relevant difference for this be happening. Any idea? Sent from ProtonMail, Swiss-based encrypted email. --- Original Message --- On terça-feira, 6 de dezembro de 2022 às 00:35, Bruno Melo wrote: > I finished the port of OpenBSD driver and now I have these lines at boot time: > > MEM (PNP0C01) at acpi0 not configured > VPC0 (VPC2004) at acpi0 not configured > ITSD (IDEA2004) at acpi0 not configured > HKDV (LKH2019) at acpi0 not configured > acpiwmibus at acpiwmi1 not configured > > What should I do with them? How to fix them? Anyway to make them configurable? > > Sent from ProtonMail, Swiss-based encrypted email. > > > > > --- Original Message --- > On segunda-feira, 28 de novembro de 2022 às 11:11 PM, Bruno Melo > bm...@protonmail.com wrote: > > > > > Hi folks, > > > > I'm trying to port amdgpio.c from OpenBSD (/sys/dev/acpi) to NetBSD then I > > can use my trackpad hopefully. > > I made some progress. The code is building but not crashing when the system > > boots (as expected). But now I can see new devices as 'not configured' > > message they did not exist before. > > > > MEM (PNP0C01) at acpi0 not configured > > VPC0 (VPC2004) at acpi0 not configured > > ITSD (IDEA2004) at acpi0 not configured > > HKDV (LKH2019) at acpi0 not configured > > acpiwmibus at acpiwmi1 not configured > > > > and then the crash happens in my bus_space_unmap(). Please, do you have any > > idea what could be the problem or how i can investigate it? Picture > > attached and code below: > > > > #include > > > > #include > > > > #include > > > > #include > > > > #include > > > > #include > > > > #include > > > > #include > > > > #include > > > > #include > > > > #include > > > > #include > > > > #define LR_GPIO_POLARITY (3L << 1) > > #define LR_GPIO_ACTHI (0L << 1) > > #define LR_GPIO_ACTLO (1L << 1) > > #define LR_GPIO_ACTBOTH (2L << 1) > > #define LR_GPIO_MODE (1L << 0) > > #define LR_GPIO_LEVEL (0L << 0) > > > > #define AMDGPIO_CONF_LEVEL 0x0100 > > #define AMDGPIO_CONF_ACTLO 0x0200 > > #define AMDGPIO_CONF_ACTBOTH 0x0400 > > #define AMDGPIO_CONF_MASK 0x0600 > > #define AMDGPIO_CONF_INT_EN 0x0800 > > #define AMDGPIO_CONF_INT_MASK 0x1000 > > #define AMDGPIO_CONF_RXSTATE 0x0001 > > #define AMDGPIO_CONF_TXSTATE 0x0040 > > #define AMDGPIO_CONF_TXSTATE_EN 0x0080 > > #define AMDGPIO_CONF_INT_STS 0x1000 > > #define AMDGPIO_IRQ_MASTER_EOI 0x2000 > > #define AMDGPIO_IRQ_BITS 46 > > #define AMDGPIO_IRQ_PINS 4 > > > > #define AMDGPIO_IRQ_MASTER 0xfc > > #define AMDGPIO_IRQ_STS 0x2f8 > > > > struct amdgpio_intrhand { > > int (*ih_func)(void *); > > void ih_arg; > > }; > > > > struct amdgpio_pincfg { > > / Modeled after pchgpio but we only have one value to > > save/restore */ > > uint32_t pin_cfg; > > }; > > > > struct amdgpio_softc { > > device_t sc_dev; > > struct acpi_softc *sc_acpi; > > ACPI_HANDLE sc_handle; > > > > bus_space_tag_t sc_memt; > > bus_space_handle_t sc_memh; > > bus_size_t sc_size; > > void *sc_ih; > > > > int sc_npins; > > int sc_pmf; > > struct amdgpio_pincfg *sc_pin_cfg; > > struct amdgpio_intrhand *sc_pin_ih; > > > > struct gpio_chipset_tag sc_gpio; > > }; > > > > int amdgpio_match(device_t, cfdata_t, void *); > > void amdgpio_attach(device_t, device_t, void *); > > int amdgpio_activate(device_t, int); > > > > CFATTACH_DECL_NEW(amdgpio_acpi, sizeof(struct amdgpio_softc), > > amdgpio_match, amdgpio_attach, NULL, NULL); > > > > static const struct device_compatible_entry compat_data[] = { > > { .compat = "AMDI0030" }, > > { .compat = "AMD0030" }, > > DEVICE_COMPAT_EOL > > }; > > > > int amdgpio_read_pin(void *, int); > > void amdgpio_write_pin(void *, int, int); > > void * amdgpio_intr_establish(void , int, int, int, int ()(void *), void *); > > void amdgpio_intr_enable(void *, int); > > void amdgpio_intr_disable(void *, void *); > > int amdgpio_pin_intr(struct amdgpio_softc *, int); > > int amdgpio_intr(void *); > > void amdgpio_save_pin(struct amdgpio_softc *, int pin); > > bool amdgpio_save(device_t self, const pmf_qual_t *qual); > > void amdgpio_restore_pin(struct amdgpio_softc *, int pin); > > bool amdgpio_restore(device_t self, const pmf_qual_t *qual);
Re: Porting amdgpio driver from OpenBSD
I finished the port of OpenBSD driver and now I have these lines at boot time: MEM (PNP0C01) at acpi0 not configured VPC0 (VPC2004) at acpi0 not configured ITSD (IDEA2004) at acpi0 not configured HKDV (LKH2019) at acpi0 not configured acpiwmibus at acpiwmi1 not configured What should I do with them? How to fix them? Anyway to make them configurable? Sent from ProtonMail, Swiss-based encrypted email. --- Original Message --- On segunda-feira, 28 de novembro de 2022 às 11:11 PM, Bruno Melo wrote: > Hi folks, > > I'm trying to port amdgpio.c from OpenBSD (/sys/dev/acpi) to NetBSD then I > can use my trackpad hopefully. > I made some progress. The code is building but not crashing when the system > boots (as expected). But now I can see new devices as 'not configured' > message they did not exist before. > > MEM (PNP0C01) at acpi0 not configured > VPC0 (VPC2004) at acpi0 not configured > ITSD (IDEA2004) at acpi0 not configured > HKDV (LKH2019) at acpi0 not configured > acpiwmibus at acpiwmi1 not configured > > and then the crash happens in my bus_space_unmap(). Please, do you have any > idea what could be the problem or how i can investigate it? Picture attached > and code below: > > #include > > #include > > #include > > #include > > #include > > #include > > #include > > > #include > > #include > > #include > > #include > > > #include > > > #define LR_GPIO_POLARITY (3L << 1) > #define LR_GPIO_ACTHI (0L << 1) > #define LR_GPIO_ACTLO (1L << 1) > #define LR_GPIO_ACTBOTH (2L << 1) > #define LR_GPIO_MODE (1L << 0) > #define LR_GPIO_LEVEL (0L << 0) > > #define AMDGPIO_CONF_LEVEL 0x0100 > #define AMDGPIO_CONF_ACTLO 0x0200 > #define AMDGPIO_CONF_ACTBOTH 0x0400 > #define AMDGPIO_CONF_MASK 0x0600 > #define AMDGPIO_CONF_INT_EN 0x0800 > #define AMDGPIO_CONF_INT_MASK 0x1000 > #define AMDGPIO_CONF_RXSTATE 0x0001 > #define AMDGPIO_CONF_TXSTATE 0x0040 > #define AMDGPIO_CONF_TXSTATE_EN 0x0080 > #define AMDGPIO_CONF_INT_STS 0x1000 > #define AMDGPIO_IRQ_MASTER_EOI 0x2000 > #define AMDGPIO_IRQ_BITS 46 > #define AMDGPIO_IRQ_PINS 4 > > #define AMDGPIO_IRQ_MASTER 0xfc > #define AMDGPIO_IRQ_STS 0x2f8 > > struct amdgpio_intrhand { > int (*ih_func)(void *); > void ih_arg; > }; > > struct amdgpio_pincfg { > / Modeled after pchgpio but we only have one value to > save/restore */ > uint32_t pin_cfg; > }; > > struct amdgpio_softc { > device_t sc_dev; > struct acpi_softc *sc_acpi; > ACPI_HANDLE sc_handle; > > bus_space_tag_t sc_memt; > bus_space_handle_t sc_memh; > bus_size_t sc_size; > void *sc_ih; > > int sc_npins; > int sc_pmf; > struct amdgpio_pincfg *sc_pin_cfg; > struct amdgpio_intrhand *sc_pin_ih; > > struct gpio_chipset_tag sc_gpio; > }; > > int amdgpio_match(device_t, cfdata_t, void *); > void amdgpio_attach(device_t, device_t, void *); > int amdgpio_activate(device_t, int); > > CFATTACH_DECL_NEW(amdgpio_acpi, sizeof(struct amdgpio_softc), amdgpio_match, > amdgpio_attach, NULL, NULL); > > static const struct device_compatible_entry compat_data[] = { > { .compat = "AMDI0030" }, > { .compat = "AMD0030" }, > DEVICE_COMPAT_EOL > }; > > int amdgpio_read_pin(void *, int); > void amdgpio_write_pin(void *, int, int); > void * amdgpio_intr_establish(void , int, int, int, int ()(void *), void *); > void amdgpio_intr_enable(void *, int); > void amdgpio_intr_disable(void *, void *); > int amdgpio_pin_intr(struct amdgpio_softc *, int); > int amdgpio_intr(void *); > void amdgpio_save_pin(struct amdgpio_softc *, int pin); > bool amdgpio_save(device_t self, const pmf_qual_t *qual); > void amdgpio_restore_pin(struct amdgpio_softc *, int pin); > bool amdgpio_restore(device_t self, const pmf_qual_t *qual); > > int > amdgpio_match(device_t parent, cfdata_t cf, void *aux) > { > struct acpi_attach_args *aa = aux; > > return acpi_compatible_match(aa, compat_data); > } > > void > amdgpio_attach(device_t parent, device_t self, void *aux) > { > struct acpi_attach_args *aa = aux; > struct amdgpio_softc *sc = device_private(self); > struct gpiobus_attach_args gba; > struct acpi_resources res; > struct acpi_mem *mem; > struct acpi_irq *irq; > ACPI_STATUS rv; > int64_t uid; > > sc->sc_dev = self; > > sc->sc_acpi = (struct acpi_softc *)parent; > > //sc->sc_node = aa->aa_node; > > > if (acpi_eval_integer(aa->aa_node->ad_handle, "_UID", &uid)) { > > printf(": can't find uid\n"); > return; > } > > printf(" uid %ld", uid); > > switch (uid) { > case 0: > sc->sc_npins = 184; > > break; > default: > printf("\n"); > return; > } > > //sc->sc_memt = aa->aaa_bst[0]; > > rv = acpi_resource_parse(self, aa->aa_node->ad_handle, "_CRS", > > &res, &acpi_resource_parse_ops_default); > if (ACPI_FAILURE(rv)) > return; > > mem = acpi_res_mem(&res, 0); > if (bus_space_map(aa->aa_memt, mem->ar_base, mem->ar_length, > > 0, &sc->sc_memh)) { > > aprint_error_dev(self, ": can't map registers\n"); > return; > } > > sc->sc_size = mem->ar_length; > > irq = acpi_
Re: Porting amdgpio driver from OpenBSD
I Must sadly inform You that Karl/Charlie died unexpected in August this year. Could you delete his address from Your mailinglist please. Greetings Silke (s.soh...@arcor.de) Karl Lockhoff - char...@mapyha.de > Am 30.11.2022 um 02:17 schrieb Bruno Melo : > > It prints the line > > printf(", %d pins\n", sc->sc_npins); > > That means, its not reaching the cannot establish interrupt error branch and > going right to the sc->sc_gpio.gp_* lines. So I think I am passing wrong > argument to the bus_space_map function, but not sure what is the wrong data. > > > > Sent from ProtonMail, Swiss-based encrypted email. > > > --- Original Message --- > On terça-feira, 29 de novembro de 2022 às 11:35 AM, Taylor R Campbell > wrote: > > >>> Date: Tue, 29 Nov 2022 02:11:15 + >>> From: Bruno Melo bm...@protonmail.com >>> >>> and then the crash happens in my bus_space_unmap(). Please, do you >>> have any idea what could be the problem or how i can investigate it? >>> Picture attached and code below: >> >> >> There's only one call to bus_space_unmap in your driver. It happens >> here: >> >> printf(", %d pins\n", sc->sc_npins); >> >> >> #if NGPIO > 0 >> >> config_found(sc->sc_dev, &gba, gpiobus_print, CFARGS_NONE); >> >> #endif >> >> unmap: >> kmem_free(sc->sc_pin_ih, sc->sc_npins * sizeof(*sc->sc_pin_ih)); >> >> bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_size); >> >> sc->sc_size = 0; >> >> printf(" DOIS"); >> >> There are two ways to reach this: >> >> 1. The error branch when acpi_intr_establish fails, which will first >> print a message (`can't establish interrupt') so you can tell >> whether this happened. >> >> 2. Fall through after config_found. This is the case where everything >> succeeded, so you probably meant to return here instead of falling >> through to cleanup!
Re: Porting amdgpio driver from OpenBSD
It prints the line printf(", %d pins\n", sc->sc_npins); That means, its not reaching the cannot establish interrupt error branch and going right to the sc->sc_gpio.gp_* lines. So I think I am passing wrong argument to the bus_space_map function, but not sure what is the wrong data. Sent from ProtonMail, Swiss-based encrypted email. --- Original Message --- On terça-feira, 29 de novembro de 2022 às 11:35 AM, Taylor R Campbell wrote: > > Date: Tue, 29 Nov 2022 02:11:15 + > > From: Bruno Melo bm...@protonmail.com > > > > and then the crash happens in my bus_space_unmap(). Please, do you > > have any idea what could be the problem or how i can investigate it? > > Picture attached and code below: > > > There's only one call to bus_space_unmap in your driver. It happens > here: > > printf(", %d pins\n", sc->sc_npins); > > > #if NGPIO > 0 > > config_found(sc->sc_dev, &gba, gpiobus_print, CFARGS_NONE); > > #endif > > unmap: > kmem_free(sc->sc_pin_ih, sc->sc_npins * sizeof(*sc->sc_pin_ih)); > > bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_size); > > sc->sc_size = 0; > > printf(" DOIS"); > > There are two ways to reach this: > > 1. The error branch when acpi_intr_establish fails, which will first > print a message (`can't establish interrupt') so you can tell > whether this happened. > > 2. Fall through after config_found. This is the case where everything > succeeded, so you probably meant to return here instead of falling > through to cleanup!
Re: Porting amdgpio driver from OpenBSD
> Date: Tue, 29 Nov 2022 02:11:15 + > From: Bruno Melo > > and then the crash happens in my bus_space_unmap(). Please, do you > have any idea what could be the problem or how i can investigate it? > Picture attached and code below: There's only one call to bus_space_unmap in your driver. It happens here: printf(", %d pins\n", sc->sc_npins); #if NGPIO > 0 config_found(sc->sc_dev, &gba, gpiobus_print, CFARGS_NONE); #endif unmap: kmem_free(sc->sc_pin_ih, sc->sc_npins * sizeof(*sc->sc_pin_ih)); bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_size); sc->sc_size = 0; printf(" DOIS"); There are two ways to reach this: 1. The error branch when acpi_intr_establish fails, which will first print a message (`can't establish interrupt') so you can tell whether this happened. 2. Fall through after config_found. This is the case where everything succeeded, so you probably meant to return here instead of falling through to cleanup!
Re: Porting amdgpio driver from OpenBSD
Hi, Bruno Melo writes: > Hi folks, > > I'm trying to port amdgpio.c from OpenBSD (/sys/dev/acpi) to NetBSD then I > can use my trackpad hopefully. I had tried to port amdgpio from FreeBSD, OpenBSD and igpio(4) of NetBSD to enable my touchpad on HP Envy 13-1052AU laptop. I had found that ACPI support in NetBSD-current does not support GPIO. I had successfully created amdgpio(4) from FreeBSD, OpenBSD and igpio(4) and ACPI interrupts were not triggered correctly. So it causes interrupt storm that is not related to my action with the touchpad. I had filed PR kern/56814, http://gnats.netbsd.org/56814. I hope that my assumption was wrong... Could any kernel developers give us your comments? Thank you. > I made some progress. The code is building but not crashing when the system > boots (as expected). But now I can see new devices as 'not configured' > message they did not exist before. > > MEM (PNP0C01) at acpi0 not configured > VPC0 (VPC2004) at acpi0 not configured > ITSD (IDEA2004) at acpi0 not configured > HKDV (LKH2019) at acpi0 not configured > acpiwmibus at acpiwmi1 not configured > > and then the crash happens in my bus_space_unmap(). Please, do you have any > idea what could be the problem or how i can investigate it? Picture attached > and code below: > > #include > #include > #include > #include > #include > #include > #include > > #include > #include > #include > #include > > #include > > #define LR_GPIO_POLARITY (3L << 1) > #define LR_GPIO_ACTHI (0L << 1) > #define LR_GPIO_ACTLO (1L << 1) > #define LR_GPIO_ACTBOTH (2L << 1) > #define LR_GPIO_MODE (1L << 0) > #define LR_GPIO_LEVEL (0L << 0) > > #define AMDGPIO_CONF_LEVEL0x0100 > #define AMDGPIO_CONF_ACTLO0x0200 > #define AMDGPIO_CONF_ACTBOTH 0x0400 > #define AMDGPIO_CONF_MASK 0x0600 > #define AMDGPIO_CONF_INT_EN 0x0800 > #define AMDGPIO_CONF_INT_MASK 0x1000 > #define AMDGPIO_CONF_RXSTATE 0x0001 > #define AMDGPIO_CONF_TXSTATE 0x0040 > #define AMDGPIO_CONF_TXSTATE_EN 0x0080 > #define AMDGPIO_CONF_INT_STS 0x1000 > #define AMDGPIO_IRQ_MASTER_EOI0x2000 > #define AMDGPIO_IRQ_BITS 46 > #define AMDGPIO_IRQ_PINS 4 > > #define AMDGPIO_IRQ_MASTER0xfc > #define AMDGPIO_IRQ_STS 0x2f8 > > struct amdgpio_intrhand { > int (*ih_func)(void *); > void *ih_arg; > }; > > struct amdgpio_pincfg { > /* Modeled after pchgpio but we only have one value to > save/restore */ > uint32_tpin_cfg; > }; > > struct amdgpio_softc { > device_t sc_dev; > struct acpi_softc *sc_acpi; > ACPI_HANDLE sc_handle; > > bus_space_tag_t sc_memt; > bus_space_handle_t sc_memh; > bus_size_t sc_size; > void *sc_ih; > > int sc_npins; > int sc_pmf; > struct amdgpio_pincfg *sc_pin_cfg; > struct amdgpio_intrhand *sc_pin_ih; > > struct gpio_chipset_tag sc_gpio; > }; > > int amdgpio_match(device_t, cfdata_t, void *); > void amdgpio_attach(device_t, device_t, void *); > int amdgpio_activate(device_t, int); > > CFATTACH_DECL_NEW(amdgpio_acpi, sizeof(struct amdgpio_softc), amdgpio_match, > amdgpio_attach, NULL, NULL); > > static const struct device_compatible_entry compat_data[] = { > { .compat = "AMDI0030" }, > { .compat = "AMD0030" }, > DEVICE_COMPAT_EOL > }; > > int amdgpio_read_pin(void *, int); > void amdgpio_write_pin(void *, int, int); > void * amdgpio_intr_establish(void *, int, int, int, int (*)(void *), void *); > void amdgpio_intr_enable(void *, int); > void amdgpio_intr_disable(void *, void *); > int amdgpio_pin_intr(struct amdgpio_softc *, int); > int amdgpio_intr(void *); > void amdgpio_save_pin(struct amdgpio_softc *, int pin); > bool amdgpio_save(device_t self, const pmf_qual_t *qual); > void amdgpio_restore_pin(struct amdgpio_softc *, int pin); > bool amdgpio_restore(device_t self, const pmf_qual_t *qual); > > int > amdgpio_match(device_t parent, cfdata_t cf, void *aux) > { > struct acpi_attach_args *aa = aux; > > return acpi_compatible_match(aa, compat_data); > } > > void > amdgpio_attach(device_t parent, device_t self, void *aux) > { > struct acpi_attach_args *aa = aux; > struct amdgpio_softc *sc = device_private(self); > struct gpiobus_attach_args gba; > struct acpi_resources res; > struct acpi_mem *mem; > struct acpi_irq *irq; > ACPI_STATUS rv; > int64_t uid; > > sc->sc_dev = self; > sc->sc_acpi = (struct acpi_softc *)parent; > //sc->sc_node = aa->aa_node; > > if (acpi_eval_integer(aa->aa_node->ad_handle, "_UID", &uid)) { > printf(": can't find uid\n"); > return; > } > > printf(" uid %ld", uid); > > switch (uid) { > case 0: