Skip to contentSkip to conversation

gpio: Add support for Intel SoC PMIC (Crystal Cove)

PATCH Superseded Zhu, Lejun 3 participants 4 messages May 22, 2014 – May 29, 2014

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Zhu, Lejun

author
#0 lore raw

PATCH v3 1/1 gpio: Add support for Intel SoC PMIC (Crystal Cove)

Devices based on Intel SoC products such as Baytrail have a Power Management IC. In the PMIC there are subsystems for voltage regulation, A/D conversion, GPIO and PWMs. The PMIC in Baytrail-T platform is called Crystal Cove.

This patch adds support for the GPIO function in Crystal Cove.

v2:
- Use IRQ chip helper to provide irqdomain.
- Implement .remove and can now build as a module.
- Various fix for unreadable or ugly code pieces. v3:
- More fix in irq_handler and probe.

---
 drivers/gpio/Kconfig            |  13 ++
 drivers/gpio/Makefile           |   1 +
 drivers/gpio/gpio-crystalcove.c | 347 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 361 insertions(+)
 create mode 100644 drivers/gpio/gpio-crystalcove.c
drivers/gpio/Kconfig +13 -0
index a86c49a..fed08d9d 100644
@@ -440,6 +440,19 @@ config GPIO_ARIZONA
 	help
 	  Support for GPIOs on Wolfson Arizona class devices.
 
+config GPIO_CRYSTAL_COVE
+	tristate "GPIO support for Crystal Cove PMIC"
+	depends on INTEL_SOC_PMIC
+	select GPIOLIB_IRQCHIP
+	help
+	  Support for GPIO pins on Crystal Cove PMIC.
+
+	  Say Yes if you have a Intel SoC based tablet with Crystal Cove PMIC
+	  inside.
+
+	  This driver can also be built as a module. If so, the module will be
+	  called gpio-crystalcove.
+
 config GPIO_LP3943
 	tristate "TI/National Semiconductor LP3943 GPIO expander"
 	depends on MFD_LP3943
drivers/gpio/Makefile +1 -0
index 6309aff..e6cd935 100644
@@ -20,6 +20,7 @@ obj-$(CONFIG_GPIO_BCM_KONA)	+= gpio-bcm-kona.o
 obj-$(CONFIG_GPIO_BT8XX)	+= gpio-bt8xx.o
 obj-$(CONFIG_GPIO_CLPS711X)	+= gpio-clps711x.o
 obj-$(CONFIG_GPIO_CS5535)	+= gpio-cs5535.o
+obj-$(CONFIG_GPIO_CRYSTAL_COVE)	+= gpio-crystalcove.o
 obj-$(CONFIG_GPIO_DA9052)	+= gpio-da9052.o
 obj-$(CONFIG_GPIO_DA9055)	+= gpio-da9055.o
 obj-$(CONFIG_GPIO_DAVINCI)	+= gpio-davinci.o
drivers/gpio/gpio-crystalcove.c new file +347 -0

347 lines not on this page · raw message

Signature · 1 line
1.8.3.2
Reviewed-by on v3 1/1
#1 lore raw

drivers/gpio/gpio-crystalcove.c line 276

Quoted 9 lines · Lejun
drivers/gpio/gpio-crystalcove.c new file +9 -0
+static int crystalcove_gpio_probe(struct platform_device *pdev)
+{
+	int irq = platform_get_irq(pdev, 0);
+	struct crystalcove_gpio *cg;
+	int retval;
+	struct device *dev = pdev->dev.parent;
+
+	cg = devm_kzalloc(&pdev->dev, sizeof(*cg), GFP_KERNEL);
+	if (!cg) {

A minor comment here:

return -ENOMEM;

drivers/gpio/gpio-crystalcove.c line 279

Quoted 3 lines
drivers/gpio/gpio-crystalcove.c new file +3 -0
+		retval = -ENOMEM;
+		goto out;
+	}

Other than that this looks good to me,

I suppose this is dependent on the MFD driver right? If so, this should probably be merged along with that patch.

author
#2 lore raw
Quoted 3 lines · Mika Westerberg

I suppose this is dependent on the MFD driver right? If so, this should probably be merged along with that patch.

The MFD driver has been submitted on LKML as well. I think these two drivers can be pulled into corresponding trees, and meet each other in the Linus tree in the end, right?

Best Regards
Lejun

#3 lore raw
In reply to Zhu, Lejun
Quoted 13 lines · Lejun

Devices based on Intel SoC products such as Baytrail have a Power Management IC. In the PMIC there are subsystems for voltage regulation, A/D conversion, GPIO and PWMs. The PMIC in Baytrail-T platform is called Crystal Cove.

This patch adds support for the GPIO function in Crystal Cove.

v2:
- Use IRQ chip helper to provide irqdomain.
- Implement .remove and can now build as a module.
- Various fix for unreadable or ugly code pieces. v3:
- More fix in irq_handler and probe.

(...)

Quoted 6 lines
drivers/gpio/gpio-crystalcove.c new file +6 -0
+       gpiochip_irqchip_add(&cg->chip, &crystalcove_irqchip, 0,
+                            handle_simple_irq, IRQ_TYPE_NONE);
+
+       retval = request_threaded_irq(irq, NULL, crystalcove_gpio_irq_handler,
+                                     IRQF_ONESHOT, KBUILD_MODNAME, cg);
+

drivers/gpio/gpio-crystalcove.c line 308

Quoted 10 lines
drivers/gpio/gpio-crystalcove.c new file +10 -0
+       if (retval) {
+               dev_warn(&pdev->dev, "request irq failed: %d\n", retval);
+               goto out;
+       }
+
+       retval = gpiochip_add(&cg->chip);
+       if (retval) {
+               dev_warn(&pdev->dev, "add gpio chip error: %d\n", retval);
+               goto out_free_irq;
+       }

As concluded from discussion, please switch the order of gpiochip_irqchip_add() and gpiochip_add() so that the gpiochip is added first, then the irqchip.

Yours,
Linus Walleij