Skip to content

Commit 9409d8c

Browse files
pandithnandy-shev
authored andcommitted
gpio: elkhartlake: Introduce Intel Elkhart Lake PSE GPIO
This driver adds support for Intel Elkhart Lake PSE GPIO controller, using Intel Tangier as a library driver. Signed-off-by: Pandith N <pandith.n@intel.com> Co-developed-by: Raag Jadav <raag.jadav@intel.com> Signed-off-by: Raag Jadav <raag.jadav@intel.com> Co-developed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
1 parent dc53703 commit 9409d8c

5 files changed

Lines changed: 109 additions & 0 deletions

File tree

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10281,6 +10281,7 @@ M: Andy Shevchenko <andy@kernel.org>
1028110281
L: linux-gpio@vger.kernel.org
1028210282
S: Supported
1028310283
T: git git://git.kernel.org/pub/scm/linux/kernel/git/andy/linux-gpio-intel.git
10284+
F: drivers/gpio/gpio-elkhartlake.c
1028410285
F: drivers/gpio/gpio-ich.c
1028510286
F: drivers/gpio/gpio-merrifield.c
1028610287
F: drivers/gpio/gpio-ml-ioh.c

drivers/gpio/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,7 @@ config GPIO_TANGIER
625625
help
626626
GPIO support for Intel Tangier and compatible platforms.
627627
Currently supported:
628+
- Elkhart Lake
628629
- Merrifield
629630

630631
If built as a module its name will be gpio-tangier.
@@ -1248,6 +1249,17 @@ config HTC_EGPIO
12481249
several HTC phones. It provides basic support for input
12491250
pins, output pins, and IRQs.
12501251

1252+
config GPIO_ELKHARTLAKE
1253+
tristate "Intel Elkhart Lake PSE GPIO support"
1254+
depends on X86 || COMPILE_TEST
1255+
select GPIO_TANGIER
1256+
help
1257+
Select this option to enable GPIO support for Intel Elkhart Lake
1258+
PSE GPIO IP.
1259+
1260+
To compile this driver as a module, choose M here: the module will
1261+
be called gpio-elkhartlake.
1262+
12511263
config GPIO_JANZ_TTL
12521264
tristate "Janz VMOD-TTL Digital IO Module"
12531265
depends on MFD_JANZ_CMODIO

drivers/gpio/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ obj-$(CONFIG_GPIO_DAVINCI) += gpio-davinci.o
5454
obj-$(CONFIG_GPIO_DLN2) += gpio-dln2.o
5555
obj-$(CONFIG_GPIO_DWAPB) += gpio-dwapb.o
5656
obj-$(CONFIG_GPIO_EIC_SPRD) += gpio-eic-sprd.o
57+
obj-$(CONFIG_GPIO_ELKHARTLAKE) += gpio-elkhartlake.o
5758
obj-$(CONFIG_GPIO_EM) += gpio-em.o
5859
obj-$(CONFIG_GPIO_EN7523) += gpio-en7523.o
5960
obj-$(CONFIG_GPIO_EP93XX) += gpio-ep93xx.o

drivers/gpio/gpio-elkhartlake.c

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* Intel Elkhart Lake PSE GPIO driver
4+
*
5+
* Copyright (c) 2023 Intel Corporation.
6+
*
7+
* Authors: Pandith N <pandith.n@intel.com>
8+
* Raag Jadav <raag.jadav@intel.com>
9+
*/
10+
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>
16+
17+
#include "gpio-tangier.h"
18+
19+
/* Each Intel EHL PSE GPIO Controller has 30 GPIO pins */
20+
#define EHL_PSE_NGPIO 30
21+
22+
static int ehl_gpio_probe(struct platform_device *pdev)
23+
{
24+
struct device *dev = &pdev->dev;
25+
struct tng_gpio *priv;
26+
int irq, ret;
27+
28+
irq = platform_get_irq(pdev, 0);
29+
if (irq < 0)
30+
return irq;
31+
32+
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
33+
if (!priv)
34+
return -ENOMEM;
35+
36+
priv->reg_base = devm_platform_ioremap_resource(pdev, 0);
37+
if (IS_ERR(priv->reg_base))
38+
return PTR_ERR(priv->reg_base);
39+
40+
priv->dev = dev;
41+
priv->irq = irq;
42+
43+
priv->info.base = -1;
44+
priv->info.ngpio = EHL_PSE_NGPIO;
45+
46+
priv->wake_regs.gwmr = GWMR_EHL;
47+
priv->wake_regs.gwsr = GWSR_EHL;
48+
priv->wake_regs.gsir = GSIR_EHL;
49+
50+
ret = devm_tng_gpio_probe(dev, priv);
51+
if (ret)
52+
return dev_err_probe(dev, ret, "tng_gpio_probe error\n");
53+
54+
platform_set_drvdata(pdev, priv);
55+
return 0;
56+
}
57+
58+
static int ehl_gpio_suspend(struct device *dev)
59+
{
60+
return tng_gpio_suspend(dev);
61+
}
62+
63+
static int ehl_gpio_resume(struct device *dev)
64+
{
65+
return tng_gpio_resume(dev);
66+
}
67+
68+
static DEFINE_SIMPLE_DEV_PM_OPS(ehl_gpio_pm_ops, ehl_gpio_suspend, ehl_gpio_resume);
69+
70+
static const struct platform_device_id ehl_gpio_ids[] = {
71+
{ "gpio-elkhartlake" },
72+
{ }
73+
};
74+
MODULE_DEVICE_TABLE(platform, ehl_gpio_ids);
75+
76+
static struct platform_driver ehl_gpio_driver = {
77+
.driver = {
78+
.name = "gpio-elkhartlake",
79+
.pm = pm_sleep_ptr(&ehl_gpio_pm_ops),
80+
},
81+
.probe = ehl_gpio_probe,
82+
.id_table = ehl_gpio_ids,
83+
};
84+
module_platform_driver(ehl_gpio_driver);
85+
86+
MODULE_AUTHOR("Pandith N <pandith.n@intel.com>");
87+
MODULE_AUTHOR("Raag Jadav <raag.jadav@intel.com>");
88+
MODULE_DESCRIPTION("Intel Elkhart Lake PSE GPIO driver");
89+
MODULE_LICENSE("GPL");
90+
MODULE_IMPORT_NS(GPIO_TANGIER);

drivers/gpio/gpio-tangier.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ struct device;
2020

2121
struct tng_gpio_context;
2222

23+
/* Elkhart Lake specific wake registers */
24+
#define GWMR_EHL 0x100 /* Wake mask */
25+
#define GWSR_EHL 0x118 /* Wake source */
26+
#define GSIR_EHL 0x130 /* Secure input */
27+
2328
/* Merrifield specific wake registers */
2429
#define GWMR_MRFLD 0x400 /* Wake mask */
2530
#define GWSR_MRFLD 0x418 /* Wake source */

0 commit comments

Comments
 (0)