Skip to content

Commit 0f2c7af

Browse files
fabioestevamlinusw
authored andcommitted
gpio: mxc: Convert the driver to DT-only
Since 5.10-rc1 i.MX is a devicetree-only platform, so simplify the code by removing the unused non-DT support. Signed-off-by: Fabio Estevam <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 8b51658 commit 0f2c7af

File tree

1 file changed

+22
-80
lines changed

1 file changed

+22
-80
lines changed

drivers/gpio/gpio-mxc.c

Lines changed: 22 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@
2424
#include <linux/of_device.h>
2525
#include <linux/bug.h>
2626

27-
enum mxc_gpio_hwtype {
28-
IMX1_GPIO, /* runs on i.mx1 */
29-
IMX21_GPIO, /* runs on i.mx21 and i.mx27 */
30-
IMX31_GPIO, /* runs on i.mx31 */
31-
IMX35_GPIO, /* runs on all other i.mx */
32-
};
33-
3427
/* device type dependent stuff */
3528
struct mxc_gpio_hwdata {
3629
unsigned dr_reg;
@@ -68,6 +61,7 @@ struct mxc_gpio_port {
6861
u32 both_edges;
6962
struct mxc_gpio_reg_saved gpio_saved_reg;
7063
bool power_off;
64+
const struct mxc_gpio_hwdata *hwdata;
7165
};
7266

7367
static struct mxc_gpio_hwdata imx1_imx21_gpio_hwdata = {
@@ -115,48 +109,27 @@ static struct mxc_gpio_hwdata imx35_gpio_hwdata = {
115109
.fall_edge = 0x03,
116110
};
117111

118-
static enum mxc_gpio_hwtype mxc_gpio_hwtype;
119-
static struct mxc_gpio_hwdata *mxc_gpio_hwdata;
120-
121-
#define GPIO_DR (mxc_gpio_hwdata->dr_reg)
122-
#define GPIO_GDIR (mxc_gpio_hwdata->gdir_reg)
123-
#define GPIO_PSR (mxc_gpio_hwdata->psr_reg)
124-
#define GPIO_ICR1 (mxc_gpio_hwdata->icr1_reg)
125-
#define GPIO_ICR2 (mxc_gpio_hwdata->icr2_reg)
126-
#define GPIO_IMR (mxc_gpio_hwdata->imr_reg)
127-
#define GPIO_ISR (mxc_gpio_hwdata->isr_reg)
128-
#define GPIO_EDGE_SEL (mxc_gpio_hwdata->edge_sel_reg)
129-
130-
#define GPIO_INT_LOW_LEV (mxc_gpio_hwdata->low_level)
131-
#define GPIO_INT_HIGH_LEV (mxc_gpio_hwdata->high_level)
132-
#define GPIO_INT_RISE_EDGE (mxc_gpio_hwdata->rise_edge)
133-
#define GPIO_INT_FALL_EDGE (mxc_gpio_hwdata->fall_edge)
112+
#define GPIO_DR (port->hwdata->dr_reg)
113+
#define GPIO_GDIR (port->hwdata->gdir_reg)
114+
#define GPIO_PSR (port->hwdata->psr_reg)
115+
#define GPIO_ICR1 (port->hwdata->icr1_reg)
116+
#define GPIO_ICR2 (port->hwdata->icr2_reg)
117+
#define GPIO_IMR (port->hwdata->imr_reg)
118+
#define GPIO_ISR (port->hwdata->isr_reg)
119+
#define GPIO_EDGE_SEL (port->hwdata->edge_sel_reg)
120+
121+
#define GPIO_INT_LOW_LEV (port->hwdata->low_level)
122+
#define GPIO_INT_HIGH_LEV (port->hwdata->high_level)
123+
#define GPIO_INT_RISE_EDGE (port->hwdata->rise_edge)
124+
#define GPIO_INT_FALL_EDGE (port->hwdata->fall_edge)
134125
#define GPIO_INT_BOTH_EDGES 0x4
135126

136-
static const struct platform_device_id mxc_gpio_devtype[] = {
137-
{
138-
.name = "imx1-gpio",
139-
.driver_data = IMX1_GPIO,
140-
}, {
141-
.name = "imx21-gpio",
142-
.driver_data = IMX21_GPIO,
143-
}, {
144-
.name = "imx31-gpio",
145-
.driver_data = IMX31_GPIO,
146-
}, {
147-
.name = "imx35-gpio",
148-
.driver_data = IMX35_GPIO,
149-
}, {
150-
/* sentinel */
151-
}
152-
};
153-
154127
static const struct of_device_id mxc_gpio_dt_ids[] = {
155-
{ .compatible = "fsl,imx1-gpio", .data = &mxc_gpio_devtype[IMX1_GPIO], },
156-
{ .compatible = "fsl,imx21-gpio", .data = &mxc_gpio_devtype[IMX21_GPIO], },
157-
{ .compatible = "fsl,imx31-gpio", .data = &mxc_gpio_devtype[IMX31_GPIO], },
158-
{ .compatible = "fsl,imx35-gpio", .data = &mxc_gpio_devtype[IMX35_GPIO], },
159-
{ .compatible = "fsl,imx7d-gpio", .data = &mxc_gpio_devtype[IMX35_GPIO], },
128+
{ .compatible = "fsl,imx1-gpio", .data = &imx1_imx21_gpio_hwdata },
129+
{ .compatible = "fsl,imx21-gpio", .data = &imx1_imx21_gpio_hwdata },
130+
{ .compatible = "fsl,imx31-gpio", .data = &imx31_gpio_hwdata },
131+
{ .compatible = "fsl,imx35-gpio", .data = &imx35_gpio_hwdata },
132+
{ .compatible = "fsl,imx7d-gpio", .data = &imx35_gpio_hwdata },
160133
{ /* sentinel */ }
161134
};
162135
MODULE_DEVICE_TABLE(of, mxc_gpio_dt_ids);
@@ -372,36 +345,6 @@ static int mxc_gpio_init_gc(struct mxc_gpio_port *port, int irq_base)
372345
return rv;
373346
}
374347

375-
static void mxc_gpio_get_hw(struct platform_device *pdev)
376-
{
377-
const struct of_device_id *of_id =
378-
of_match_device(mxc_gpio_dt_ids, &pdev->dev);
379-
enum mxc_gpio_hwtype hwtype;
380-
381-
if (of_id)
382-
pdev->id_entry = of_id->data;
383-
hwtype = pdev->id_entry->driver_data;
384-
385-
if (mxc_gpio_hwtype) {
386-
/*
387-
* The driver works with a reasonable presupposition,
388-
* that is all gpio ports must be the same type when
389-
* running on one soc.
390-
*/
391-
BUG_ON(mxc_gpio_hwtype != hwtype);
392-
return;
393-
}
394-
395-
if (hwtype == IMX35_GPIO)
396-
mxc_gpio_hwdata = &imx35_gpio_hwdata;
397-
else if (hwtype == IMX31_GPIO)
398-
mxc_gpio_hwdata = &imx31_gpio_hwdata;
399-
else
400-
mxc_gpio_hwdata = &imx1_imx21_gpio_hwdata;
401-
402-
mxc_gpio_hwtype = hwtype;
403-
}
404-
405348
static int mxc_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
406349
{
407350
struct mxc_gpio_port *port = gpiochip_get_data(gc);
@@ -417,14 +360,14 @@ static int mxc_gpio_probe(struct platform_device *pdev)
417360
int irq_base;
418361
int err;
419362

420-
mxc_gpio_get_hw(pdev);
421-
422363
port = devm_kzalloc(&pdev->dev, sizeof(*port), GFP_KERNEL);
423364
if (!port)
424365
return -ENOMEM;
425366

426367
port->dev = &pdev->dev;
427368

369+
port->hwdata = device_get_match_data(&pdev->dev);
370+
428371
port->base = devm_platform_ioremap_resource(pdev, 0);
429372
if (IS_ERR(port->base))
430373
return PTR_ERR(port->base);
@@ -461,7 +404,7 @@ static int mxc_gpio_probe(struct platform_device *pdev)
461404
writel(0, port->base + GPIO_IMR);
462405
writel(~0, port->base + GPIO_ISR);
463406

464-
if (mxc_gpio_hwtype == IMX21_GPIO) {
407+
if (of_device_is_compatible(np, "fsl,imx21-gpio")) {
465408
/*
466409
* Setup one handler for all GPIO interrupts. Actually setting
467410
* the handler is needed only once, but doing it for every port
@@ -596,7 +539,6 @@ static struct platform_driver mxc_gpio_driver = {
596539
.suppress_bind_attrs = true,
597540
},
598541
.probe = mxc_gpio_probe,
599-
.id_table = mxc_gpio_devtype,
600542
};
601543

602544
static int __init gpio_mxc_init(void)

0 commit comments

Comments
 (0)