Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / gpio / gpio-elkhartlake.c
blob887c0fe99d3950df5e8d13fa7f1ef4cb3ce87811
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Intel Elkhart Lake PSE GPIO driver
5 * Copyright (c) 2023 Intel Corporation.
7 * Authors: Pandith N <pandith.n@intel.com>
8 * Raag Jadav <raag.jadav@intel.com>
9 */
11 #include <linux/device.h>
12 #include <linux/err.h>
13 #include <linux/module.h>
14 #include <linux/platform_device.h>
15 #include <linux/pm.h>
17 #include "gpio-tangier.h"
19 /* Each Intel EHL PSE GPIO Controller has 30 GPIO pins */
20 #define EHL_PSE_NGPIO 30
22 static int ehl_gpio_probe(struct platform_device *pdev)
24 struct device *dev = &pdev->dev;
25 struct tng_gpio *priv;
26 int irq, ret;
28 irq = platform_get_irq(pdev, 0);
29 if (irq < 0)
30 return irq;
32 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
33 if (!priv)
34 return -ENOMEM;
36 priv->reg_base = devm_platform_ioremap_resource(pdev, 0);
37 if (IS_ERR(priv->reg_base))
38 return PTR_ERR(priv->reg_base);
40 priv->dev = dev;
41 priv->irq = irq;
43 priv->info.base = -1;
44 priv->info.ngpio = EHL_PSE_NGPIO;
46 priv->wake_regs.gwmr = GWMR_EHL;
47 priv->wake_regs.gwsr = GWSR_EHL;
48 priv->wake_regs.gsir = GSIR_EHL;
50 ret = devm_tng_gpio_probe(dev, priv);
51 if (ret)
52 return dev_err_probe(dev, ret, "tng_gpio_probe error\n");
54 platform_set_drvdata(pdev, priv);
55 return 0;
58 static const struct platform_device_id ehl_gpio_ids[] = {
59 { "gpio-elkhartlake" },
60 { }
62 MODULE_DEVICE_TABLE(platform, ehl_gpio_ids);
64 static struct platform_driver ehl_gpio_driver = {
65 .driver = {
66 .name = "gpio-elkhartlake",
67 .pm = pm_sleep_ptr(&tng_gpio_pm_ops),
69 .probe = ehl_gpio_probe,
70 .id_table = ehl_gpio_ids,
72 module_platform_driver(ehl_gpio_driver);
74 MODULE_AUTHOR("Pandith N <pandith.n@intel.com>");
75 MODULE_AUTHOR("Raag Jadav <raag.jadav@intel.com>");
76 MODULE_DESCRIPTION("Intel Elkhart Lake PSE GPIO driver");
77 MODULE_LICENSE("GPL");
78 MODULE_IMPORT_NS(GPIO_TANGIER);