gpio: Fix ngpio in gpio-xilinx driver
If one adds gpio-controller; to the chip in the devicetree, then initialization fails with 'gpiochip_find_base: cannot find free range', because ngpio is 0. This patch fixes the bug. This version includes the suggestions from Linus Walleij. Tested on ml507 board. Signed-off-by: Gernot Vormayr <gvormayr@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:

committed by
Linus Walleij

parent
58a3b92d33
commit
1b4c5a6e6b
@@ -197,6 +197,7 @@ static int xgpio_of_probe(struct device_node *np)
|
|||||||
struct xgpio_instance *chip;
|
struct xgpio_instance *chip;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
const u32 *tree_info;
|
const u32 *tree_info;
|
||||||
|
u32 ngpio;
|
||||||
|
|
||||||
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
|
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
|
||||||
if (!chip)
|
if (!chip)
|
||||||
@@ -211,12 +212,13 @@ static int xgpio_of_probe(struct device_node *np)
|
|||||||
/* Update GPIO direction shadow register with default value */
|
/* Update GPIO direction shadow register with default value */
|
||||||
of_property_read_u32(np, "xlnx,tri-default", &chip->gpio_dir);
|
of_property_read_u32(np, "xlnx,tri-default", &chip->gpio_dir);
|
||||||
|
|
||||||
/* By default assume full GPIO controller */
|
/*
|
||||||
chip->mmchip.gc.ngpio = 32;
|
* Check device node and parent device node for device width
|
||||||
|
* and assume default width of 32
|
||||||
/* Check device node and parent device node for device width */
|
*/
|
||||||
of_property_read_u32(np, "xlnx,gpio-width",
|
if (of_property_read_u32(np, "xlnx,gpio-width", &ngpio))
|
||||||
(u32 *)&chip->mmchip.gc.ngpio);
|
ngpio = 32;
|
||||||
|
chip->mmchip.gc.ngpio = (u16)ngpio;
|
||||||
|
|
||||||
spin_lock_init(&chip->gpio_lock);
|
spin_lock_init(&chip->gpio_lock);
|
||||||
|
|
||||||
@@ -258,12 +260,13 @@ static int xgpio_of_probe(struct device_node *np)
|
|||||||
/* Update GPIO direction shadow register with default value */
|
/* Update GPIO direction shadow register with default value */
|
||||||
of_property_read_u32(np, "xlnx,tri-default-2", &chip->gpio_dir);
|
of_property_read_u32(np, "xlnx,tri-default-2", &chip->gpio_dir);
|
||||||
|
|
||||||
/* By default assume full GPIO controller */
|
/*
|
||||||
chip->mmchip.gc.ngpio = 32;
|
* Check device node and parent device node for device width
|
||||||
|
* and assume default width of 32
|
||||||
/* Check device node and parent device node for device width */
|
*/
|
||||||
of_property_read_u32(np, "xlnx,gpio2-width",
|
if (of_property_read_u32(np, "xlnx,gpio2-width", &ngpio))
|
||||||
(u32 *)&chip->mmchip.gc.ngpio);
|
ngpio = 32;
|
||||||
|
chip->mmchip.gc.ngpio = (u16)ngpio;
|
||||||
|
|
||||||
spin_lock_init(&chip->gpio_lock);
|
spin_lock_init(&chip->gpio_lock);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user