diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 8162e12e2d..e60aeb25f5 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -8,6 +8,21 @@ menuconfig GPIO help Include GPIO drivers in system config +config GPIO_DW_VENDOR_ID + hex "PCI Vendor ID" + depends on GPIO_DW && PCI + default 0x8086 + +config GPIO_DW_DEVICE_ID + hex "PCI Device ID" + depends on GPIO_DW && PCI + default 0x935 + +config GPIO_DW_CLASS + hex "PCI class" + depends on GPIO_DW && PCI + default 0x00 + config GPIO_DW_0 bool "Designware GPIO block 0" depends on GPIO @@ -26,6 +41,26 @@ config GPIO_DW_0_BASE_ADDR depends on GPIO_DW_0 default 0x00000000 +config GPIO_DW_0_BUS + int "Port 0 PCI Bus" + depends on GPIO_DW_0 && PCI + default 0 + +config GPIO_DW_0_DEV + int "Port 0 PCI Dev" + depends on GPIO_DW_0 && PCI + default 0 + +config GPIO_DW_0_FUNCTION + int "PCI function number" + depends on GPIO_DW_0 && PCI + default 0 + +config GPIO_DW_0_BAR + int "PCI BAR slot" + depends on GPIO_DW_0 && PCI + default 0 + config GPIO_DW_0_BITS int "number of pins controlled" depends on GPIO_DW_0 diff --git a/drivers/gpio/gpio-dw.c b/drivers/gpio/gpio-dw.c index f1badd321c..9064591826 100644 --- a/drivers/gpio/gpio-dw.c +++ b/drivers/gpio/gpio-dw.c @@ -282,11 +282,41 @@ static struct gpio_driver_api api_funcs = { .resume = gpio_resume_port_dw }; +#ifdef CONFIG_PCI +static inline int gpio_dw_setup(struct device *dev) +{ + struct gpio_config_dw *config = dev->config->config_info; + + pci_bus_scan_init(); + + if (!pci_bus_scan(&config->pci_dev)) { + return 0; + } + +#ifdef CONFIG_PCI_ENUMERATION + config->base_addr = config->pci_dev.addr; + config->irq_num = config->pci_dev.irq; +#endif + pci_enable_regs(&config->pci_dev); + + pci_show(&config->pci_dev); + + return 1; +} +#else +#define gpio_dw_setup(_unused_) (1) +#endif /* CONFIG_PCI */ + + int gpio_initialize_dw(struct device *port) { struct gpio_config_dw *config = port->config->config_info; uint32_t base_addr = config->base_addr; + if (!gpio_dw_setup(port)) { + return DEV_NOT_CONFIG; + } + /* interrupts in sync with system clock */ dw_set_bit(base_addr, INT_CLOCK_SYNC, 0, 1); diff --git a/drivers/gpio/gpio-dw.h b/drivers/gpio/gpio-dw.h index c734e3e6b0..7d23861840 100644 --- a/drivers/gpio/gpio-dw.h +++ b/drivers/gpio/gpio-dw.h @@ -31,6 +31,11 @@ #include #include +#ifdef CONFIG_PCI +#include +#include +#endif /* CONFIG_PCI */ + #define CONFIG_GPIO_DW_BITS 32 extern int gpio_initialize_dw(struct device *port); typedef void (*gpio_config_irq_t)(struct device *port); @@ -39,6 +44,9 @@ struct gpio_config_dw { uint32_t base_addr; uint32_t bits; uint32_t irq_num; +#ifdef CONFIG_PCI + struct pci_dev_info pci_dev; +#endif /* CONFIG_PCI */ gpio_config_irq_t config_func; };