[linux-yocto] [PATCH 4/6] valleyisland-io: gpio-baytrail: enable platform device when ACPI enum is absent

boon.leong.ong at intel.com boon.leong.ong at intel.com
Thu Feb 20 07:06:21 PST 2014


From: Ong Boon Leong <boon.leong.ong at intel.com>

This is to cater the need for non-ACPI system whereby
a platform device has to be created in order to bind
with the BYT GPIO platform driver.

This commit is only applicable for v3.8 GPIO driver and not after.
For v3.10 onwards, only ACPI enumeration will be supported in
in drivers/pinctrl/pinctrl-baytrail.c.

Signed-off-by: Ong Boon Leong <boon.leong.ong at intel.com>
---
 ...il-enable-platform-device-in-the-absent-o.patch |  330 ++++++++++++++++++++
 1 file changed, 330 insertions(+)
 create mode 100644 meta/cfg/kernel-cache/features/valleyisland-io/0023-gpio-baytrail-enable-platform-device-in-the-absent-o.patch

diff --git a/meta/cfg/kernel-cache/features/valleyisland-io/0023-gpio-baytrail-enable-platform-device-in-the-absent-o.patch b/meta/cfg/kernel-cache/features/valleyisland-io/0023-gpio-baytrail-enable-platform-device-in-the-absent-o.patch
new file mode 100644
index 0000000..5d043e0
--- /dev/null
+++ b/meta/cfg/kernel-cache/features/valleyisland-io/0023-gpio-baytrail-enable-platform-device-in-the-absent-o.patch
@@ -0,0 +1,330 @@
+From 61926b893d8bcc086ba388ec812e5197eb88bc47 Mon Sep 17 00:00:00 2001
+From: "Chew, Kean Ho" <kean.ho.chew at intel.com>
+Date: Wed, 12 Feb 2014 06:14:33 -0500
+Subject: [PATCH 4/5] gpio-baytrail: enable platform device in the absent of
+ ACPI enumeration
+
+This is to cater the need for non-ACPI system whereby
+a platform device has to be created in order to bind
+with the BYT GPIO platform driver.
+
+Signed-off-by: Chew, Kean Ho <kean.ho.chew at intel.com>
+Signed-off-by: Chew, Chiau Ee <chiau.ee.chew at intel.com>
+---
+ drivers/gpio/Kconfig             |  16 +++-
+ drivers/gpio/Makefile            |   1 +
+ drivers/gpio/gpio-baytrail-dev.c | 159 +++++++++++++++++++++++++++++++++++++++
+ drivers/gpio/gpio-baytrail.c     |  19 ++++-
+ include/linux/gpio-byt.h         |  16 ++++
+ 5 files changed, 206 insertions(+), 5 deletions(-)
+ create mode 100644 drivers/gpio/gpio-baytrail-dev.c
+ create mode 100644 include/linux/gpio-byt.h
+
+diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
+index 1cf77f2..4205678 100644
+--- a/drivers/gpio/Kconfig
++++ b/drivers/gpio/Kconfig
+@@ -226,7 +226,6 @@ config GPIO_TS5500
+ 
+ config GPIO_BAYTRAIL
+ 	bool "Intel Baytrail GPIO support"
+-	depends on ACPI
+ 	select IRQ_DOMAIN
+ 	help
+ 	  driver for memory mapped GPIO functionality on Intel Baytrail
+@@ -234,7 +233,20 @@ config GPIO_BAYTRAIL
+ 	  Most pins are usually muxed to some other functionality by firmware,
+ 	  so only a small amount is available for gpio use.
+ 
+-	  Requires ACPI device enumeration code to set up a platform device.
++	  For ACPI platform, it would require ACPI device enumeration code
++	  to set up a platform device. Else, say yes to GPIO_BAYTRAIL_DEV
++	  as well to set up platform device in the absent of ACPI enumeration
++	  code.
++
++config GPIO_BAYTRAIL_DEV
++	bool "Intel Baytrail GPIO Platform Device Emulation"
++	depends on GPIO_BAYTRAIL
++	help
++	  This driver is to set up platform device in the absent of ACPI
++	  enumeration.
++
++	  Say yes for non-ACPI platform. This will enable the platform devices
++	  to be created and bind with the BayTrail GPIO platform driver.
+ 
+ config GPIO_VT8500
+ 	bool "VIA/Wondermedia SoC GPIO Support"
+diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
+index 759777b..9320223 100644
+--- a/drivers/gpio/Makefile
++++ b/drivers/gpio/Makefile
+@@ -77,6 +77,7 @@ obj-$(CONFIG_GPIO_TWL4030)	+= gpio-twl4030.o
+ obj-$(CONFIG_GPIO_TWL6040)	+= gpio-twl6040.o
+ obj-$(CONFIG_GPIO_UCB1400)	+= gpio-ucb1400.o
+ obj-$(CONFIG_GPIO_BAYTRAIL)	+= gpio-baytrail.o
++obj-$(CONFIG_GPIO_BAYTRAIL_DEV)	+= gpio-baytrail-dev.o
+ obj-$(CONFIG_GPIO_VIPERBOARD)	+= gpio-viperboard.o
+ obj-$(CONFIG_GPIO_VR41XX)	+= gpio-vr41xx.o
+ obj-$(CONFIG_GPIO_VT8500)	+= gpio-vt8500.o
+diff --git a/drivers/gpio/gpio-baytrail-dev.c b/drivers/gpio/gpio-baytrail-dev.c
+new file mode 100644
+index 0000000..a291fd2
+--- /dev/null
++++ b/drivers/gpio/gpio-baytrail-dev.c
+@@ -0,0 +1,159 @@
++/*
++ * gpio-baytrail-dev.c: BayTrail GPIO Platform Device
++ *
++ * (C) Copyright 2013 Intel Corporation
++ * Author: Kean Ho, Chew (kean.ho.chew at intel.com)
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; version 2
++ * of the License.
++ */
++
++#include <linux/kernel.h>
++#include <linux/module.h>
++#include <linux/init.h>
++#include <linux/types.h>
++#include <linux/bitops.h>
++#include <linux/interrupt.h>
++#include <linux/platform_device.h>
++#include <linux/seq_file.h>
++#include <linux/pci.h>
++#include <linux/gpio-byt.h>
++
++/* PCI Memory Base Access */
++#define PCI_DEVICE_ID_INTEL_BYT_PCU	0x0f1c
++#define NO_REGISTER_SETTINGS	(BIT(0) | BIT(1) | BIT(2))
++
++/* Offsets */
++#define SCORE_OFFSET		0x0
++#define NCORE_OFFSET		0x1000
++#define SUS_OFFSET		0x2000
++#define SCORE_END		0x72C
++#define NCORE_END		0x970
++#define SUS_END			0x98C
++
++static struct byt_gpio_port byt_gpio_score_platform_data = {
++	.unique_id = "1",
++};
++
++static struct resource byt_gpio_score_resources[] = {
++	{
++		.start	= 0x0,
++		.end	= 0x0,
++		.flags	= IORESOURCE_MEM,
++		.name	= "io-memory",
++	},
++	{
++		.start	= 49,
++		.end	= 49,
++		.flags	= IORESOURCE_IRQ,
++		.name	= "irq",
++	}
++};
++
++static struct byt_gpio_port byt_gpio_ncore_platform_data = {
++	.unique_id = "2",
++};
++
++static struct resource byt_gpio_ncore_resources[] = {
++	{
++		.start	= 0x0,
++		.end	= 0x0,
++		.flags	= IORESOURCE_MEM,
++		.name	= "io-memory",
++	},
++	{
++		.start	= 48,
++		.end	= 48,
++		.flags	= IORESOURCE_IRQ,
++		.name	= "irq",
++	}
++};
++
++static struct byt_gpio_port byt_gpio_sus_platform_data = {
++	.unique_id = "3",
++};
++
++static struct resource byt_gpio_sus_resources[] = {
++	{
++		.start	= 0x0,
++		.end	= 0x0,
++		.flags	= IORESOURCE_MEM,
++		.name	= "io-memory",
++	},
++	{
++		.start	= 50,
++		.end	= 50,
++		.flags	= IORESOURCE_IRQ,
++		.name	= "irq",
++	}
++};
++
++static struct platform_device byt_gpio_score_device = {
++	.name			= "byt_gpio",
++	.id			= 0,
++	.num_resources		= ARRAY_SIZE(byt_gpio_score_resources),
++	.resource		= byt_gpio_score_resources,
++	.dev			= {
++		.platform_data	= &byt_gpio_score_platform_data,
++	}
++};
++
++static struct platform_device byt_gpio_ncore_device = {
++	.name			= "byt_gpio",
++	.id			= 1,
++	.num_resources		= ARRAY_SIZE(byt_gpio_ncore_resources),
++	.resource		= byt_gpio_ncore_resources,
++	.dev			= {
++		.platform_data	= &byt_gpio_ncore_platform_data,
++	}
++};
++
++static struct platform_device byt_gpio_sus_device = {
++	.name			= "byt_gpio",
++	.id			= 2,
++	.num_resources		= ARRAY_SIZE(byt_gpio_sus_resources),
++	.resource		= byt_gpio_sus_resources,
++	.dev			= {
++		.platform_data	= &byt_gpio_sus_platform_data,
++	}
++};
++
++static struct platform_device *devices[] __initdata = {
++	&byt_gpio_score_device,
++	&byt_gpio_ncore_device,
++	&byt_gpio_sus_device,
++};
++
++static int __init get_pci_memory_init(void)
++{
++	u32 io_base_add;
++	struct pci_dev *pci_dev;
++	pci_dev = pci_get_device(PCI_VENDOR_ID_INTEL,
++				PCI_DEVICE_ID_INTEL_BYT_PCU,
++				NULL);
++
++	if (pci_dev == NULL) {
++		return -EFAULT;
++	};
++	pci_read_config_dword(pci_dev, 0x4c, &io_base_add);
++	io_base_add &= ~NO_REGISTER_SETTINGS;
++	byt_gpio_score_resources[0].start = io_base_add + SCORE_OFFSET;
++	byt_gpio_score_resources[0].end =
++				io_base_add + SCORE_OFFSET + SCORE_END;
++	byt_gpio_ncore_resources[0].start = io_base_add + NCORE_OFFSET;
++	byt_gpio_ncore_resources[0].end =
++				io_base_add + NCORE_OFFSET + NCORE_END;
++	byt_gpio_sus_resources[0].start = io_base_add + SUS_OFFSET;
++	byt_gpio_sus_resources[0].end = io_base_add + SUS_OFFSET + SUS_END;
++	return 0;
++};
++rootfs_initcall(get_pci_memory_init);
++
++
++static int __init byt_gpio_device_init(void)
++{
++	return platform_add_devices(devices, ARRAY_SIZE(devices));
++};
++device_initcall(byt_gpio_device_init);
+diff --git a/drivers/gpio/gpio-baytrail.c b/drivers/gpio/gpio-baytrail.c
+index f3fac33..ecd53ea 100644
+--- a/drivers/gpio/gpio-baytrail.c
++++ b/drivers/gpio/gpio-baytrail.c
+@@ -34,6 +34,7 @@
+ #include <linux/seq_file.h>
+ #include <linux/io.h>
+ #include <linux/pm_runtime.h>
++#include <linux/gpio-byt.h>
+ 
+ /* memory mapped register offsets */
+ #define BYT_CONF0_REG		0x000
+@@ -436,15 +437,19 @@ static int byt_gpio_probe(struct platform_device *pdev)
+ 	struct gpio_chip *gc;
+ 	struct resource *mem_rc, *irq_rc;
+ 	struct device *dev = &pdev->dev;
+-	struct acpi_device *acpi_dev;
+ 	struct gpio_bank *bank;
+-	acpi_handle handle = ACPI_HANDLE(dev);
+ 	unsigned hwirq;
+ 	int ret;
+ 
++#ifdef CONFIG_GPIO_BAYTRAIL_DEV
++	struct byt_gpio_port *platform_data = dev->platform_data;
++#else
++	struct acpi_device *acpi_dev;
++	acpi_handle handle = ACPI_HANDLE(dev);
++
+ 	if (acpi_bus_get_device(handle, &acpi_dev))
+ 		return -ENODEV;
+-
++#endif
+ 	vg = devm_kzalloc(dev, sizeof(struct byt_gpio), GFP_KERNEL);
+ 	if (!vg) {
+ 		dev_err(&pdev->dev, "can't allocate byt_gpio chip data\n");
+@@ -452,7 +457,11 @@ static int byt_gpio_probe(struct platform_device *pdev)
+ 	}
+ 
+ 	for (bank = byt_banks; bank->uid; bank++) {
++#ifdef CONFIG_GPIO_BAYTRAIL_DEV
++		if (!strcmp(platform_data->unique_id, bank->uid)) {
++#else
+ 		if (!strcmp(acpi_dev->pnp.unique_id, bank->uid)) {
++#endif
+ 			vg->chip.ngpio = bank->ngpio;
+ 			vg->gpio_to_pad = bank->to_pad;
+ 			break;
+@@ -538,11 +547,13 @@ static const struct dev_pm_ops byt_gpio_pm_ops = {
+ 	.runtime_resume = byt_gpio_runtime_resume,
+ };
+ 
++#ifndef CONFIG_GPIO_BAYTRAIL_DEV
+ static const struct acpi_device_id byt_gpio_acpi_match[] = {
+ 	{ "INT33B2", 0 },
+ 	{ }
+ };
+ MODULE_DEVICE_TABLE(acpi, byt_gpio_acpi_match);
++#endif
+ 
+ static int byt_gpio_remove(struct platform_device *pdev)
+ {
+@@ -563,8 +574,10 @@ static struct platform_driver byt_gpio_driver = {
+ 	.driver         = {
+ 		.name   = "byt_gpio",
+ 		.owner  = THIS_MODULE,
++#ifndef CONFIG_GPIO_BAYTRAIL_DEV
+ 		.pm	= &byt_gpio_pm_ops,
+ 		.acpi_match_table = ACPI_PTR(byt_gpio_acpi_match),
++#endif
+ 	},
+ };
+ 
+diff --git a/include/linux/gpio-byt.h b/include/linux/gpio-byt.h
+new file mode 100644
+index 0000000..d4f74d7
+--- /dev/null
++++ b/include/linux/gpio-byt.h
+@@ -0,0 +1,16 @@
++/*
++ * gpio_byt.h: BayTrail GPIO header file
++ *
++ * Copyright (C) 2013 Intel Corporation
++ * Author: Chew, Kean Ho <kean.ho.chew at intel.com>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2
++ * as published by the Free Software Foundation.
++ */
++
++#ifdef CONFIG_GPIO_BAYTRAIL_DEV
++struct byt_gpio_port {
++	char *unique_id;
++};
++#endif
+-- 
+1.8.4.2
+
-- 
1.7.10.4



More information about the linux-yocto mailing list