Commit 76c47d14 authored by Ran Wang's avatar Ran Wang Committed by Bartosz Golaszewski

gpio: mpc8xxx: Add ACPI support

Current implementation only supports DT, now add ACPI support.
Signed-off-by: default avatarRan Wang <ran.wang_1@nxp.com>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
parent ba134d29
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
* kind, whether express or implied. * kind, whether express or implied.
*/ */
#include <linux/acpi.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
...@@ -18,6 +19,8 @@ ...@@ -18,6 +19,8 @@
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/property.h>
#include <linux/mod_devicetable.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/gpio/driver.h> #include <linux/gpio/driver.h>
...@@ -303,8 +306,8 @@ static int mpc8xxx_probe(struct platform_device *pdev) ...@@ -303,8 +306,8 @@ static int mpc8xxx_probe(struct platform_device *pdev)
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct mpc8xxx_gpio_chip *mpc8xxx_gc; struct mpc8xxx_gpio_chip *mpc8xxx_gc;
struct gpio_chip *gc; struct gpio_chip *gc;
const struct mpc8xxx_gpio_devtype *devtype = const struct mpc8xxx_gpio_devtype *devtype = NULL;
of_device_get_match_data(&pdev->dev); struct fwnode_handle *fwnode;
int ret; int ret;
mpc8xxx_gc = devm_kzalloc(&pdev->dev, sizeof(*mpc8xxx_gc), GFP_KERNEL); mpc8xxx_gc = devm_kzalloc(&pdev->dev, sizeof(*mpc8xxx_gc), GFP_KERNEL);
...@@ -315,14 +318,14 @@ static int mpc8xxx_probe(struct platform_device *pdev) ...@@ -315,14 +318,14 @@ static int mpc8xxx_probe(struct platform_device *pdev)
raw_spin_lock_init(&mpc8xxx_gc->lock); raw_spin_lock_init(&mpc8xxx_gc->lock);
mpc8xxx_gc->regs = of_iomap(np, 0); mpc8xxx_gc->regs = devm_platform_ioremap_resource(pdev, 0);
if (!mpc8xxx_gc->regs) if (IS_ERR(mpc8xxx_gc->regs))
return -ENOMEM; return PTR_ERR(mpc8xxx_gc->regs);
gc = &mpc8xxx_gc->gc; gc = &mpc8xxx_gc->gc;
gc->parent = &pdev->dev; gc->parent = &pdev->dev;
if (of_property_read_bool(np, "little-endian")) { if (device_property_read_bool(&pdev->dev, "little-endian")) {
ret = bgpio_init(gc, &pdev->dev, 4, ret = bgpio_init(gc, &pdev->dev, 4,
mpc8xxx_gc->regs + GPIO_DAT, mpc8xxx_gc->regs + GPIO_DAT,
NULL, NULL, NULL, NULL,
...@@ -345,6 +348,7 @@ static int mpc8xxx_probe(struct platform_device *pdev) ...@@ -345,6 +348,7 @@ static int mpc8xxx_probe(struct platform_device *pdev)
mpc8xxx_gc->direction_output = gc->direction_output; mpc8xxx_gc->direction_output = gc->direction_output;
devtype = device_get_match_data(&pdev->dev);
if (!devtype) if (!devtype)
devtype = &mpc8xxx_gpio_devtype_default; devtype = &mpc8xxx_gpio_devtype_default;
...@@ -369,24 +373,29 @@ static int mpc8xxx_probe(struct platform_device *pdev) ...@@ -369,24 +373,29 @@ static int mpc8xxx_probe(struct platform_device *pdev)
* associated input enable must be set (GPIOxGPIE[IEn]=1) to propagate * associated input enable must be set (GPIOxGPIE[IEn]=1) to propagate
* the port value to the GPIO Data Register. * the port value to the GPIO Data Register.
*/ */
fwnode = dev_fwnode(&pdev->dev);
if (of_device_is_compatible(np, "fsl,qoriq-gpio") || if (of_device_is_compatible(np, "fsl,qoriq-gpio") ||
of_device_is_compatible(np, "fsl,ls1028a-gpio") || of_device_is_compatible(np, "fsl,ls1028a-gpio") ||
of_device_is_compatible(np, "fsl,ls1088a-gpio")) of_device_is_compatible(np, "fsl,ls1088a-gpio") ||
is_acpi_node(fwnode))
gc->write_reg(mpc8xxx_gc->regs + GPIO_IBE, 0xffffffff); gc->write_reg(mpc8xxx_gc->regs + GPIO_IBE, 0xffffffff);
ret = gpiochip_add_data(gc, mpc8xxx_gc); ret = gpiochip_add_data(gc, mpc8xxx_gc);
if (ret) { if (ret) {
pr_err("%pOF: GPIO chip registration failed with status %d\n", dev_err(&pdev->dev,
np, ret); "GPIO chip registration failed with status %d\n", ret);
goto err; goto err;
} }
mpc8xxx_gc->irqn = irq_of_parse_and_map(np, 0); mpc8xxx_gc->irqn = platform_get_irq(pdev, 0);
if (!mpc8xxx_gc->irqn) if (!mpc8xxx_gc->irqn)
return 0; return 0;
mpc8xxx_gc->irq = irq_domain_add_linear(np, MPC8XXX_GPIO_PINS, mpc8xxx_gc->irq = irq_domain_create_linear(fwnode,
&mpc8xxx_gpio_irq_ops, mpc8xxx_gc); MPC8XXX_GPIO_PINS,
&mpc8xxx_gpio_irq_ops,
mpc8xxx_gc);
if (!mpc8xxx_gc->irq) if (!mpc8xxx_gc->irq)
return 0; return 0;
...@@ -399,8 +408,9 @@ static int mpc8xxx_probe(struct platform_device *pdev) ...@@ -399,8 +408,9 @@ static int mpc8xxx_probe(struct platform_device *pdev)
IRQF_SHARED, "gpio-cascade", IRQF_SHARED, "gpio-cascade",
mpc8xxx_gc); mpc8xxx_gc);
if (ret) { if (ret) {
dev_err(&pdev->dev, "%s: failed to devm_request_irq(%d), ret = %d\n", dev_err(&pdev->dev,
np->full_name, mpc8xxx_gc->irqn, ret); "failed to devm_request_irq(%d), ret = %d\n",
mpc8xxx_gc->irqn, ret);
goto err; goto err;
} }
...@@ -425,12 +435,21 @@ static int mpc8xxx_remove(struct platform_device *pdev) ...@@ -425,12 +435,21 @@ static int mpc8xxx_remove(struct platform_device *pdev)
return 0; return 0;
} }
#ifdef CONFIG_ACPI
static const struct acpi_device_id gpio_acpi_ids[] = {
{"NXP0031",},
{ }
};
MODULE_DEVICE_TABLE(acpi, gpio_acpi_ids);
#endif
static struct platform_driver mpc8xxx_plat_driver = { static struct platform_driver mpc8xxx_plat_driver = {
.probe = mpc8xxx_probe, .probe = mpc8xxx_probe,
.remove = mpc8xxx_remove, .remove = mpc8xxx_remove,
.driver = { .driver = {
.name = "gpio-mpc8xxx", .name = "gpio-mpc8xxx",
.of_match_table = mpc8xxx_gpio_ids, .of_match_table = mpc8xxx_gpio_ids,
.acpi_match_table = ACPI_PTR(gpio_acpi_ids),
}, },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment