Skip to content

Commit 76bc907

Browse files
MrVanBartosz Golaszewski
authored andcommitted
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 <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 2b57563 commit 76bc907

File tree

1 file changed

+40
-7
lines changed

1 file changed

+40
-7
lines changed

drivers/gpio/gpio-vf610.c

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
struct fsl_gpio_soc_data {
2626
/* SoCs has a Port Data Direction Register (PDDR) */
2727
bool have_paddr;
28+
bool have_dual_base;
2829
};
2930

3031
struct vf610_gpio_port {
@@ -60,13 +61,26 @@ struct vf610_gpio_port {
6061
#define PORT_INT_EITHER_EDGE 0xb
6162
#define PORT_INT_LOGIC_ONE 0xc
6263

64+
#define IMX8ULP_GPIO_BASE_OFF 0x40
65+
#define IMX8ULP_BASE_OFF 0x80
66+
67+
static const struct fsl_gpio_soc_data vf610_data = {
68+
.have_dual_base = true,
69+
};
70+
6371
static const struct fsl_gpio_soc_data imx_data = {
6472
.have_paddr = true,
73+
.have_dual_base = true,
74+
};
75+
76+
static const struct fsl_gpio_soc_data imx8ulp_data = {
77+
.have_paddr = true,
6578
};
6679

6780
static const struct of_device_id vf610_gpio_dt_ids[] = {
68-
{ .compatible = "fsl,vf610-gpio", .data = NULL, },
81+
{ .compatible = "fsl,vf610-gpio", .data = &vf610_data },
6982
{ .compatible = "fsl,imx7ulp-gpio", .data = &imx_data, },
83+
{ .compatible = "fsl,imx8ulp-gpio", .data = &imx8ulp_data, },
7084
{ /* sentinel */ }
7185
};
7286

@@ -263,19 +277,38 @@ static int vf610_gpio_probe(struct platform_device *pdev)
263277
struct gpio_irq_chip *girq;
264278
int i;
265279
int ret;
280+
bool dual_base;
266281

267282
port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
268283
if (!port)
269284
return -ENOMEM;
270285

271286
port->sdata = of_device_get_match_data(dev);
272-
port->base = devm_platform_ioremap_resource(pdev, 0);
273-
if (IS_ERR(port->base))
274-
return PTR_ERR(port->base);
275287

276-
port->gpio_base = devm_platform_ioremap_resource(pdev, 1);
277-
if (IS_ERR(port->gpio_base))
278-
return PTR_ERR(port->gpio_base);
288+
dual_base = port->sdata->have_dual_base;
289+
290+
/* support old compatible strings */
291+
if (device_is_compatible(dev, "fsl,imx7ulp-gpio") &&
292+
(device_is_compatible(dev, "fsl,imx93-gpio") ||
293+
(device_is_compatible(dev, "fsl,imx8ulp-gpio"))))
294+
dual_base = true;
295+
296+
if (dual_base) {
297+
port->base = devm_platform_ioremap_resource(pdev, 0);
298+
if (IS_ERR(port->base))
299+
return PTR_ERR(port->base);
300+
301+
port->gpio_base = devm_platform_ioremap_resource(pdev, 1);
302+
if (IS_ERR(port->gpio_base))
303+
return PTR_ERR(port->gpio_base);
304+
} else {
305+
port->base = devm_platform_ioremap_resource(pdev, 0);
306+
if (IS_ERR(port->base))
307+
return PTR_ERR(port->base);
308+
309+
port->gpio_base = port->base + IMX8ULP_GPIO_BASE_OFF;
310+
port->base = port->base + IMX8ULP_BASE_OFF;
311+
}
279312

280313
port->irq = platform_get_irq(pdev, 0);
281314
if (port->irq < 0)

0 commit comments

Comments
 (0)