gpio: Enable PCI support for the designware gpio driver

This will enable the possibility to use this driver with Quark X1000.

Change-Id: Ic40b750d608488e97cc7662cad6c6d66dbf428ab
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2015-08-25 17:31:48 +03:00 committed by Anas Nashif
parent e7c8bf43ac
commit eb6ed6bb0d
3 changed files with 73 additions and 0 deletions

View file

@ -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

View file

@ -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);

View file

@ -31,6 +31,11 @@
#include <stdint.h>
#include <gpio.h>
#ifdef CONFIG_PCI
#include <pci/pci.h>
#include <pci/pci_mgr.h>
#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;
};