From: Madhusudhanan Ravindran <mravindr@xxxxxxxxxxx> pass wlan irq gpio number in run time using DT as mentioned in the TODO list. Signed-off-by: Madhusudhanan Ravindran <mravindr@xxxxxxxxxxx> -- * did not test this code on real hardware. --- drivers/staging/wilc1000/linux_wlan.c | 28 ++++++++++++++++++++-------- drivers/staging/wilc1000/linux_wlan_spi.c | 7 +++++++ drivers/staging/wilc1000/linux_wlan_spi.h | 1 + 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index e92ba59..03ede78 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -492,12 +492,17 @@ static int isr_bh_routine(void *vp) static int init_irq(linux_wlan_t *p_nic) { int ret = 0; + unsigned int gpio; linux_wlan_t *nic = p_nic; /*initialize GPIO and register IRQ num*/ + if (gpio_num > 0) + gpio = gpio_num; + else + gpio = GPIO_NUM; /*GPIO request*/ - if ((gpio_request(GPIO_NUM, "WILC_INTR") == 0) && - (gpio_direction_input(GPIO_NUM) == 0)) { + if ((gpio_request(gpio, "WILC_INTR") == 0) && + (gpio_direction_input(gpio) == 0)) { #if defined(CUSTOMER_PLATFORM) /* TODO : save the registerd irq number to the private wilc context in kernel. @@ -507,11 +512,11 @@ static int init_irq(linux_wlan_t *p_nic) #elif defined (NM73131_0_BOARD) nic->dev_irq_num = IRQ_WILC1000; #elif defined (PANDA_BOARD) - gpio_export(GPIO_NUM, 1); - nic->dev_irq_num = OMAP_GPIO_IRQ(GPIO_NUM); + gpio_export(gpio, 1); + nic->dev_irq_num = OMAP_GPIO_IRQ(gpio); irq_set_irq_type(nic->dev_irq_num, IRQ_TYPE_LEVEL_LOW); #else - nic->dev_irq_num = gpio_to_irq(GPIO_NUM); + nic->dev_irq_num = gpio_to_irq(gpio); #endif } else { ret = -1; @@ -530,12 +535,12 @@ static int init_irq(linux_wlan_t *p_nic) IRQF_TRIGGER_LOW, "WILC_IRQ", nic) < 0)) { #endif - PRINT_ER("Failed to request IRQ for GPIO: %d\n", GPIO_NUM); + PRINT_ER("Failed to request IRQ for GPIO: %d\n", gpio); ret = -1; } else { PRINT_D(INIT_DBG, "IRQ request succeeded IRQ-NUM= %d on GPIO: %d\n", - nic->dev_irq_num, GPIO_NUM); + nic->dev_irq_num, gpio); } return ret; @@ -544,12 +549,19 @@ static int init_irq(linux_wlan_t *p_nic) static void deinit_irq(linux_wlan_t *nic) { + unsigned int gpio; + + if (gpio_num > 0) + gpio = gpio_num; + else + gpio = GPIO_NUM; + #if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO) /* Deintialize IRQ */ if (&nic->dev_irq_num != 0) { free_irq(nic->dev_irq_num, g_linux_wlan); - gpio_free(GPIO_NUM); + gpio_free(gpio); } #endif } diff --git a/drivers/staging/wilc1000/linux_wlan_spi.c b/drivers/staging/wilc1000/linux_wlan_spi.c index 1eee1d5..0bdd5b4 100644 --- a/drivers/staging/wilc1000/linux_wlan_spi.c +++ b/drivers/staging/wilc1000/linux_wlan_spi.c @@ -8,6 +8,8 @@ #include <asm/uaccess.h> #include <linux/device.h> #include <linux/spi/spi.h> +#include <linux/of.h> +#include <linux/of_device.h> #include "linux_wlan_common.h" @@ -41,15 +43,20 @@ static uint32_t SPEED = MIN_SPEED; struct spi_device *wilc_spi_dev; +unsigned int gpio_num = 0; void linux_spi_deinit(void *vp); static int __init wilc_bus_probe(struct spi_device *spi) { + struct device_node *np = spi->dev.of_node; PRINT_D(BUS_DBG, "spiModalias: %s\n", spi->modalias); PRINT_D(BUS_DBG, "spiMax-Speed: %d\n", spi->max_speed_hz); wilc_spi_dev = spi; + if (np) + of_get_property(np, "atmel,wlan_irq_gpio_num", &gpio_num); + printk("Driver Initializing success\n"); return 0; } diff --git a/drivers/staging/wilc1000/linux_wlan_spi.h b/drivers/staging/wilc1000/linux_wlan_spi.h index 0ecad47..218b133 100644 --- a/drivers/staging/wilc1000/linux_wlan_spi.h +++ b/drivers/staging/wilc1000/linux_wlan_spi.h @@ -4,6 +4,7 @@ #include <linux/spi/spi.h> extern struct spi_device *wilc_spi_dev; extern struct spi_driver wilc_bus; +extern unsigned int gpio_num; int linux_spi_init(void *vp); void linux_spi_deinit(void *vp); -- 1.7.9.5 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel