Skip to content

Commit 0da0277

Browse files
CL Chin-Long WangCharlesWu465
authored andcommitted
gpio: andes: atcgpio100: Support for the ngpios variable can be obtained from DTS.
1. Support for the ngpios variable can be obtained from DTS. 2. Start the virtual IRQ at 0. Signed-off-by: CL Wang <[email protected]>
1 parent 59ff4d4 commit 0da0277

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

drivers/gpio/gpio-atcgpio100.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#define DEBOUNCE_ENABLE 0x70
3030

3131
#define ATCGPIO100_VIRTUAL_IRQ_BASE 0
32+
#define DEFAULT_PIN_NUMBER 16
3233

3334
struct atcgpio_priv {
3435
struct gpio_chip gc;
@@ -222,6 +223,8 @@ static int atcgpio100_gpio_probe(struct platform_device *pdev)
222223
struct atcgpio_priv *priv;
223224
struct gpio_chip *gc;
224225
struct gpio_irq_chip *girq;
226+
struct device_node *node;
227+
u32 ngpios;
225228

226229
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
227230
if (!priv)
@@ -254,6 +257,15 @@ static int atcgpio100_gpio_probe(struct platform_device *pdev)
254257
"Failed to read ID register, ATCGPIO100 is not supported.\n");
255258
return -ENXIO;
256259
}
260+
261+
node = pdev->dev.of_node;
262+
if (!node)
263+
return -EINVAL;
264+
265+
ret = of_property_read_u32(node, "ngpios", &ngpios);
266+
if (ret)
267+
ngpios = DEFAULT_PIN_NUMBER;
268+
257269
/* disable interrupt */
258270
GPIO_WRITEL(0x00000000UL, INT_ENABLE, priv->base);
259271
/* clear interrupt */
@@ -267,7 +279,7 @@ static int atcgpio100_gpio_probe(struct platform_device *pdev)
267279
gc->parent = &pdev->dev;
268280
gc->label = "atcgpio100";
269281
gc->base = 0;
270-
gc->ngpio = 16;
282+
gc->ngpio = ngpios;
271283
gc->direction_output = atcgpio_dir_out;
272284
gc->direction_input = atcgpio_dir_in;
273285
gc->set = atcgpio_set;

0 commit comments

Comments
 (0)