File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 2929#define DEBOUNCE_ENABLE 0x70
3030
3131#define ATCGPIO100_VIRTUAL_IRQ_BASE 0
32+ #define DEFAULT_PIN_NUMBER 16
3233
3334struct 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 ;
You can’t perform that action at this time.
0 commit comments