Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

gpio: vf610: add i.MX8ULP of_device_id entry

i.MX8ULP/93 GPIO supports similar feature as i.MX7ULP GPIO, but i.MX8ULP is
actually not hardware compatible with i.MX7ULP. i.MX8ULP only has one
register base, not two bases. i.MX8ULP and i.MX93 actually has two
interrupts for each gpio controller, one for Trustzone non-secure world,
one for secure world.

Although the Linux Kernel driver gpio-vf610.c could work with
fsl,imx7ulp-gpio compatible, it is based on some tricks did in device tree
with some offset added to base address.

Add a new of_device_id entry for i.MX8ULP. But to make the driver could
also support old bindings, check the compatible string first, before
check the device data.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

authored by

Peng Fan and committed by
Bartosz Golaszewski
76bc907b 2b575631

+40 -7
+40 -7
drivers/gpio/gpio-vf610.c
··· 25 25 struct fsl_gpio_soc_data { 26 26 /* SoCs has a Port Data Direction Register (PDDR) */ 27 27 bool have_paddr; 28 + bool have_dual_base; 28 29 }; 29 30 30 31 struct vf610_gpio_port { ··· 61 60 #define PORT_INT_EITHER_EDGE 0xb 62 61 #define PORT_INT_LOGIC_ONE 0xc 63 62 63 + #define IMX8ULP_GPIO_BASE_OFF 0x40 64 + #define IMX8ULP_BASE_OFF 0x80 65 + 66 + static const struct fsl_gpio_soc_data vf610_data = { 67 + .have_dual_base = true, 68 + }; 69 + 64 70 static const struct fsl_gpio_soc_data imx_data = { 71 + .have_paddr = true, 72 + .have_dual_base = true, 73 + }; 74 + 75 + static const struct fsl_gpio_soc_data imx8ulp_data = { 65 76 .have_paddr = true, 66 77 }; 67 78 68 79 static const struct of_device_id vf610_gpio_dt_ids[] = { 69 - { .compatible = "fsl,vf610-gpio", .data = NULL, }, 80 + { .compatible = "fsl,vf610-gpio", .data = &vf610_data }, 70 81 { .compatible = "fsl,imx7ulp-gpio", .data = &imx_data, }, 82 + { .compatible = "fsl,imx8ulp-gpio", .data = &imx8ulp_data, }, 71 83 { /* sentinel */ } 72 84 }; 73 85 ··· 277 263 struct gpio_irq_chip *girq; 278 264 int i; 279 265 int ret; 266 + bool dual_base; 280 267 281 268 port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL); 282 269 if (!port) 283 270 return -ENOMEM; 284 271 285 272 port->sdata = of_device_get_match_data(dev); 286 - port->base = devm_platform_ioremap_resource(pdev, 0); 287 - if (IS_ERR(port->base)) 288 - return PTR_ERR(port->base); 289 273 290 - port->gpio_base = devm_platform_ioremap_resource(pdev, 1); 291 - if (IS_ERR(port->gpio_base)) 292 - return PTR_ERR(port->gpio_base); 274 + dual_base = port->sdata->have_dual_base; 275 + 276 + /* support old compatible strings */ 277 + if (device_is_compatible(dev, "fsl,imx7ulp-gpio") && 278 + (device_is_compatible(dev, "fsl,imx93-gpio") || 279 + (device_is_compatible(dev, "fsl,imx8ulp-gpio")))) 280 + dual_base = true; 281 + 282 + if (dual_base) { 283 + port->base = devm_platform_ioremap_resource(pdev, 0); 284 + if (IS_ERR(port->base)) 285 + return PTR_ERR(port->base); 286 + 287 + port->gpio_base = devm_platform_ioremap_resource(pdev, 1); 288 + if (IS_ERR(port->gpio_base)) 289 + return PTR_ERR(port->gpio_base); 290 + } else { 291 + port->base = devm_platform_ioremap_resource(pdev, 0); 292 + if (IS_ERR(port->base)) 293 + return PTR_ERR(port->base); 294 + 295 + port->gpio_base = port->base + IMX8ULP_GPIO_BASE_OFF; 296 + port->base = port->base + IMX8ULP_BASE_OFF; 297 + } 293 298 294 299 port->irq = platform_get_irq(pdev, 0); 295 300 if (port->irq < 0)