linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] sfi, intel_mid: introduce SFI GPIO API and use it
@ 2013-11-20 14:31 Andy Shevchenko
  2013-11-20 14:31 ` [PATCH v2 1/3] sfi: fix compiler warnings Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Andy Shevchenko @ 2013-11-20 14:31 UTC (permalink / raw)
  To: Linus Walleij, David Cohen, linux-gpio @ vger . kernel . org,
	Alexandre Courbot, Sathyanarayanan Kuppuswamy, Len Brown,
	linux-kernel @ vger . kernel . org, Grant Likely
  Cc: Andy Shevchenko

Here is a second [1] version of the SFI GPIO API. This series contains SFI GPIO
API layer along with the update of intel-mid platform to use it instead of
internal copy.

It has been tested on Medfield device with linux-next 20131118.

[1] https://lkml.org/lkml/2013/6/5/316

Andy Shevchenko (3):
  sfi: fix compiler warnings
  gpiolib: append SFI helpers for GPIO API
  intel_mid: switch to use SFI GPIO API

 arch/x86/include/asm/intel-mid.h                   |  1 -
 .../intel-mid/device_libs/platform_emc1403.c       |  8 +--
 .../intel-mid/device_libs/platform_gpio_keys.c     | 10 +--
 .../intel-mid/device_libs/platform_lis331.c        |  8 +--
 .../intel-mid/device_libs/platform_max3111.c       |  6 +-
 .../intel-mid/device_libs/platform_max7315.c       | 10 +--
 .../intel-mid/device_libs/platform_mpu3050.c       |  6 +-
 .../intel-mid/device_libs/platform_msic_gpio.c     |  6 +-
 .../intel-mid/device_libs/platform_msic_ocd.c      |  5 +-
 .../intel-mid/device_libs/platform_pmic_gpio.c     |  7 +-
 .../intel-mid/device_libs/platform_tc35876x.c      |  8 +--
 .../intel-mid/device_libs/platform_tca6416.c       | 10 +--
 arch/x86/platform/intel-mid/sfi.c                  | 51 --------------
 drivers/gpio/Kconfig                               |  4 ++
 drivers/gpio/Makefile                              |  1 +
 drivers/gpio/gpiolib-sfi.c                         | 77 ++++++++++++++++++++++
 drivers/sfi/sfi_acpi.c                             |  8 +--
 drivers/sfi/sfi_core.c                             | 13 +++-
 include/linux/gpio/sfi.h                           | 37 +++++++++++
 include/linux/sfi_acpi.h                           |  2 +-
 20 files changed, 176 insertions(+), 102 deletions(-)
 create mode 100644 drivers/gpio/gpiolib-sfi.c
 create mode 100644 include/linux/gpio/sfi.h

-- 
1.8.4.3


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 1/3] sfi: fix compiler warnings
  2013-11-20 14:31 [PATCH v2 0/3] sfi, intel_mid: introduce SFI GPIO API and use it Andy Shevchenko
@ 2013-11-20 14:31 ` Andy Shevchenko
  2013-11-20 14:31 ` [PATCH v2 2/3] gpiolib: append SFI helpers for GPIO API Andy Shevchenko
  2013-11-20 14:31 ` [PATCH v2 3/3] intel_mid: switch to use SFI " Andy Shevchenko
  2 siblings, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2013-11-20 14:31 UTC (permalink / raw)
  To: Linus Walleij, David Cohen, linux-gpio @ vger . kernel . org,
	Alexandre Courbot, Sathyanarayanan Kuppuswamy, Len Brown,
	linux-kernel @ vger . kernel . org, Grant Likely
  Cc: Andy Shevchenko

This fixes the following compiler warnings when build is done by make W=1.

drivers/sfi/sfi_acpi.c:154:5: warning: no previous prototype for ‘sfi_acpi_table_parse’ [-Wmissing-prototypes]

drivers/sfi/sfi_core.c:164:26: warning: no previous prototype for ‘sfi_map_table’ [-Wmissing-prototypes]
drivers/sfi/sfi_core.c:192:6: warning: no previous prototype for ‘sfi_unmap_table’ [-Wmissing-prototypes]

Indentation fixes are also included.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/sfi/sfi_acpi.c   | 8 ++++----
 drivers/sfi/sfi_core.c   | 4 ++--
 include/linux/sfi_acpi.h | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/sfi/sfi_acpi.c b/drivers/sfi/sfi_acpi.c
index f5b4ca5..728a2e2 100644
--- a/drivers/sfi/sfi_acpi.c
+++ b/drivers/sfi/sfi_acpi.c
@@ -63,6 +63,7 @@
 #include <acpi/acpi.h>
 
 #include <linux/sfi.h>
+#include <linux/sfi_acpi.h>
 #include "sfi_core.h"
 
 /*
@@ -152,7 +153,7 @@ static void sfi_acpi_put_table(struct acpi_table_header *table)
  * Find specified table in XSDT, run handler on it and return its return value
  */
 int sfi_acpi_table_parse(char *signature, char *oem_id, char *oem_table_id,
-			int(*handler)(struct acpi_table_header *))
+			 int(*handler)(struct acpi_table_header *))
 {
 	struct acpi_table_header *table = NULL;
 	struct sfi_table_key key;
@@ -175,8 +176,8 @@ int sfi_acpi_table_parse(char *signature, char *oem_id, char *oem_table_id,
 }
 
 static ssize_t sfi_acpi_table_show(struct file *filp, struct kobject *kobj,
-			       struct bin_attribute *bin_attr, char *buf,
-			       loff_t offset, size_t count)
+				   struct bin_attribute *bin_attr, char *buf,
+				   loff_t offset, size_t count)
 {
 	struct sfi_table_attr *tbl_attr =
 	    container_of(bin_attr, struct sfi_table_attr, attr);
@@ -199,7 +200,6 @@ static ssize_t sfi_acpi_table_show(struct file *filp, struct kobject *kobj,
 	return cnt;
 }
 
-
 void __init sfi_acpi_sysfs_init(void)
 {
 	u32 tbl_cnt, i;
diff --git a/drivers/sfi/sfi_core.c b/drivers/sfi/sfi_core.c
index 1e824fb..296db7a 100644
--- a/drivers/sfi/sfi_core.c
+++ b/drivers/sfi/sfi_core.c
@@ -161,7 +161,7 @@ static int sfi_verify_table(struct sfi_table_header *table)
  * Check for common case that we can re-use mapping to SYST,
  * which requires syst_pa, syst_va to be initialized.
  */
-struct sfi_table_header *sfi_map_table(u64 pa)
+static struct sfi_table_header *sfi_map_table(u64 pa)
 {
 	struct sfi_table_header *th;
 	u32 length;
@@ -189,7 +189,7 @@ struct sfi_table_header *sfi_map_table(u64 pa)
  * Undoes effect of sfi_map_table() by unmapping table
  * if it did not completely fit on same page as SYST.
  */
-void sfi_unmap_table(struct sfi_table_header *th)
+static void sfi_unmap_table(struct sfi_table_header *th)
 {
 	if (!TABLE_ON_PAGE(syst_va, th, th->len))
 		sfi_unmap_memory(th, TABLE_ON_PAGE(th, th, th->len) ?
diff --git a/include/linux/sfi_acpi.h b/include/linux/sfi_acpi.h
index 631af63..1a88ef6 100644
--- a/include/linux/sfi_acpi.h
+++ b/include/linux/sfi_acpi.h
@@ -60,7 +60,7 @@
 #define _LINUX_SFI_ACPI_H
 
 #ifdef CONFIG_SFI
-#include <acpi/acpi.h>		/* struct acpi_table_header */
+#include <linux/acpi.h>		/* struct acpi_table_header */
 
 extern int sfi_acpi_table_parse(char *signature, char *oem_id,
 				char *oem_table_id,
-- 
1.8.4.3


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 2/3] gpiolib: append SFI helpers for GPIO API
  2013-11-20 14:31 [PATCH v2 0/3] sfi, intel_mid: introduce SFI GPIO API and use it Andy Shevchenko
  2013-11-20 14:31 ` [PATCH v2 1/3] sfi: fix compiler warnings Andy Shevchenko
@ 2013-11-20 14:31 ` Andy Shevchenko
  2013-11-21 10:40   ` Mika Westerberg
  2013-11-20 14:31 ` [PATCH v2 3/3] intel_mid: switch to use SFI " Andy Shevchenko
  2 siblings, 1 reply; 10+ messages in thread
From: Andy Shevchenko @ 2013-11-20 14:31 UTC (permalink / raw)
  To: Linus Walleij, David Cohen, linux-gpio @ vger . kernel . org,
	Alexandre Courbot, Sathyanarayanan Kuppuswamy, Len Brown,
	linux-kernel @ vger . kernel . org, Grant Likely
  Cc: Andy Shevchenko, Len Brown

To support some (legacy) firmwares and platforms let's make life easier for
their customers.

This patch extracts SFI GPIO API from arch/x86/platform/intel-mid/sfi.c and
moves it to GPIO descriptor API.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Grant Likely <grant.likely@linaro.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpio/Kconfig       |  4 +++
 drivers/gpio/Makefile      |  1 +
 drivers/gpio/gpiolib-sfi.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/sfi/sfi_core.c     |  9 +++++-
 include/linux/gpio/sfi.h   | 37 ++++++++++++++++++++++
 5 files changed, 127 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpio/gpiolib-sfi.c
 create mode 100644 include/linux/gpio/sfi.h

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 0f04444..9a4fe9f 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -51,6 +51,10 @@ config OF_GPIO
 	def_bool y
 	depends on OF
 
+config GPIO_SFI
+	def_bool y
+	depends on SFI
+
 config GPIO_ACPI
 	def_bool y
 	depends on ACPI
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 7971e36..b6820bc 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -5,6 +5,7 @@ ccflags-$(CONFIG_DEBUG_GPIO)	+= -DDEBUG
 obj-$(CONFIG_GPIO_DEVRES)	+= devres.o
 obj-$(CONFIG_GPIOLIB)		+= gpiolib.o
 obj-$(CONFIG_OF_GPIO)		+= gpiolib-of.o
+obj-$(CONFIG_GPIO_SFI)		+= gpiolib-sfi.o
 obj-$(CONFIG_GPIO_ACPI)		+= gpiolib-acpi.o
 
 # Device drivers. Generally keep list sorted alphabetically
diff --git a/drivers/gpio/gpiolib-sfi.c b/drivers/gpio/gpiolib-sfi.c
new file mode 100644
index 0000000..5dc6314
--- /dev/null
+++ b/drivers/gpio/gpiolib-sfi.c
@@ -0,0 +1,77 @@
+/*
+ * Simple Firmware Interface (SFI) helpers for GPIO API
+ *
+ * Copyright (C) 2013, Intel Corporation
+ * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+ *
+ * Based on work done for Intel MID platform
+ *
+ * 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.
+ */
+
+#define pr_fmt(fmt) "SFI: GPIO: " fmt
+
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/slab.h>
+#include <linux/export.h>
+#include <linux/sfi.h>
+#include <linux/gpio/consumer.h>
+#include <linux/gpio/sfi.h>
+
+static struct sfi_gpio_table_entry *sfi_gpio_table;
+static int sfi_gpio_num_entry;
+
+struct gpio_desc *sfi_get_gpiod_by_name(const char *name)
+{
+	struct sfi_gpio_table_entry *pentry = sfi_gpio_table;
+	int i;
+
+	if (!pentry)
+		return ERR_PTR(-EINVAL);
+
+	for (i = 0; i < sfi_gpio_num_entry; i++, pentry++) {
+		if (!strncmp(name, pentry->pin_name, SFI_NAME_LEN))
+			return gpio_to_desc(pentry->pin_no);
+	}
+
+	return ERR_PTR(-ENODEV);
+}
+EXPORT_SYMBOL_GPL(sfi_get_gpiod_by_name);
+
+static int __init sfi_gpio_parse(struct sfi_table_header *table)
+{
+	struct sfi_table_simple *sb;
+	struct sfi_gpio_table_entry *pentry;
+	int num, i;
+
+	if (sfi_gpio_table)
+		return 0;
+
+	sb = container_of(table, struct sfi_table_simple, header);
+
+	num = SFI_GET_NUM_ENTRIES(sb, struct sfi_gpio_table_entry);
+	pentry = (struct sfi_gpio_table_entry *)sb->pentry;
+
+	sfi_gpio_table = kmemdup(pentry, num * sizeof(*pentry), GFP_KERNEL);
+	if (!sfi_gpio_table)
+		return -ENOMEM;
+
+	sfi_gpio_num_entry = num;
+
+	pr_debug("Pin info:\n");
+	for (i = 0; i < num; i++, pentry++)
+		pr_debug("[%2d] chip = %16.16s, name = %16.16s, pin=%d\n", i,
+			 pentry->controller_name, pentry->pin_name,
+			 pentry->pin_no);
+
+	return 0;
+}
+
+int __init sfi_gpio_init(void)
+{
+	return sfi_table_parse(SFI_SIG_GPIO, NULL, NULL, sfi_gpio_parse);
+}
diff --git a/drivers/sfi/sfi_core.c b/drivers/sfi/sfi_core.c
index 296db7a..1fab93d 100644
--- a/drivers/sfi/sfi_core.c
+++ b/drivers/sfi/sfi_core.c
@@ -66,8 +66,9 @@
 #include <linux/types.h>
 #include <linux/acpi.h>
 #include <linux/init.h>
-#include <linux/sfi.h>
 #include <linux/slab.h>
+#include <linux/sfi.h>
+#include <linux/gpio/sfi.h>
 
 #include "sfi_core.h"
 
@@ -512,6 +513,12 @@ void __init sfi_init_late(void)
 	syst_va = sfi_map_memory(syst_pa, length);
 
 	sfi_acpi_init();
+
+	/*
+	 * Parsing GPIO table first, since the DEVS table will need this table
+	 * to map the pin name to the actual pin.
+	 */
+	sfi_gpio_init();
 }
 
 /*
diff --git a/include/linux/gpio/sfi.h b/include/linux/gpio/sfi.h
new file mode 100644
index 0000000..3e111ad
--- /dev/null
+++ b/include/linux/gpio/sfi.h
@@ -0,0 +1,37 @@
+#ifndef _LINUX_SFI_GPIO_H_
+#define _LINUX_SFI_GPIO_H_
+
+#include <linux/err.h>
+#include <linux/errno.h>
+#include <linux/gpio/consumer.h>
+#include <linux/sfi.h>
+
+#ifdef CONFIG_GPIO_SFI
+
+struct gpio_desc *sfi_get_gpiod_by_name(const char *name);
+int sfi_gpio_init(void);
+
+#else /* CONFIG_GPIO_SFI */
+
+static inline struct gpio_desc *sfi_get_gpiod_by_name(const char *name);
+{
+	return ERR_PTR(-ENODEV);
+}
+
+static inline int sfi_gpio_init(void)
+{
+	return -ENODEV;
+}
+
+#endif /* CONFIG_GPIO_SFI */
+
+static inline int sfi_get_gpio_by_name(const char *name)
+{
+	struct gpio_desc *desc = sfi_get_gpiod_by_name(name);
+
+	if (IS_ERR(desc))
+		return PTR_ERR(desc);
+	return desc_to_gpio(desc);
+}
+
+#endif /* _LINUX_SFI_GPIO_H_ */
-- 
1.8.4.3


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 3/3] intel_mid: switch to use SFI GPIO API
  2013-11-20 14:31 [PATCH v2 0/3] sfi, intel_mid: introduce SFI GPIO API and use it Andy Shevchenko
  2013-11-20 14:31 ` [PATCH v2 1/3] sfi: fix compiler warnings Andy Shevchenko
  2013-11-20 14:31 ` [PATCH v2 2/3] gpiolib: append SFI helpers for GPIO API Andy Shevchenko
@ 2013-11-20 14:31 ` Andy Shevchenko
  2013-11-20 18:13   ` David Cohen
  2013-11-26  9:38   ` Linus Walleij
  2 siblings, 2 replies; 10+ messages in thread
From: Andy Shevchenko @ 2013-11-20 14:31 UTC (permalink / raw)
  To: Linus Walleij, David Cohen, linux-gpio @ vger . kernel . org,
	Alexandre Courbot, Sathyanarayanan Kuppuswamy, Len Brown,
	linux-kernel @ vger . kernel . org, Grant Likely
  Cc: Andy Shevchenko

Instead of custom implementation of the SFI GPIO API let's use one provided by
gpiolib.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/include/asm/intel-mid.h                   |  1 -
 .../intel-mid/device_libs/platform_emc1403.c       |  8 ++--
 .../intel-mid/device_libs/platform_gpio_keys.c     | 10 ++---
 .../intel-mid/device_libs/platform_lis331.c        |  8 ++--
 .../intel-mid/device_libs/platform_max3111.c       |  6 +--
 .../intel-mid/device_libs/platform_max7315.c       | 10 ++---
 .../intel-mid/device_libs/platform_mpu3050.c       |  6 +--
 .../intel-mid/device_libs/platform_msic_gpio.c     |  6 +--
 .../intel-mid/device_libs/platform_msic_ocd.c      |  5 +--
 .../intel-mid/device_libs/platform_pmic_gpio.c     |  7 +--
 .../intel-mid/device_libs/platform_tc35876x.c      |  8 ++--
 .../intel-mid/device_libs/platform_tca6416.c       | 10 ++---
 arch/x86/platform/intel-mid/sfi.c                  | 51 ----------------------
 13 files changed, 42 insertions(+), 94 deletions(-)

diff --git a/arch/x86/include/asm/intel-mid.h b/arch/x86/include/asm/intel-mid.h
index 459769d..7e426b1 100644
--- a/arch/x86/include/asm/intel-mid.h
+++ b/arch/x86/include/asm/intel-mid.h
@@ -15,7 +15,6 @@
 #include <linux/platform_device.h>
 
 extern int intel_mid_pci_init(void);
-extern int get_gpio_by_name(const char *name);
 extern void intel_scu_device_register(struct platform_device *pdev);
 extern int __init sfi_parse_mrtc(struct sfi_table_header *table);
 extern int __init sfi_parse_mtmr(struct sfi_table_header *table);
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_emc1403.c b/arch/x86/platform/intel-mid/device_libs/platform_emc1403.c
index 0d942c1..502f50f 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_emc1403.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_emc1403.c
@@ -11,7 +11,7 @@
  */
 
 #include <linux/init.h>
-#include <linux/gpio.h>
+#include <linux/gpio/sfi.h>
 #include <linux/i2c.h>
 #include <asm/intel-mid.h>
 
@@ -19,10 +19,10 @@ static void __init *emc1403_platform_data(void *info)
 {
 	static short intr2nd_pdata;
 	struct i2c_board_info *i2c_info = info;
-	int intr = get_gpio_by_name("thermal_int");
-	int intr2nd = get_gpio_by_name("thermal_alert");
+	int intr = sfi_get_gpio_by_name("thermal_int");
+	int intr2nd = sfi_get_gpio_by_name("thermal_alert");
 
-	if (intr == -1 || intr2nd == -1)
+	if (intr < 0 || intr2nd < 0)
 		return NULL;
 
 	i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET;
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c b/arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c
index a013a48..e3fb5be 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c
@@ -13,7 +13,7 @@
 #include <linux/input.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
-#include <linux/gpio.h>
+#include <linux/gpio/sfi.h>
 #include <linux/gpio_keys.h>
 #include <linux/platform_device.h>
 #include <asm/intel-mid.h>
@@ -61,12 +61,12 @@ static int __init pb_keys_init(void)
 	struct gpio_keys_button *gb = gpio_button;
 	int i, num, good = 0;
 
-	num = sizeof(gpio_button) / sizeof(struct gpio_keys_button);
+	num = ARRAY_SIZE(gpio_button);
 	for (i = 0; i < num; i++) {
-		gb[i].gpio = get_gpio_by_name(gb[i].desc);
+		gb[i].gpio = sfi_get_gpio_by_name(gb[i].desc);
 		pr_debug("info[%2d]: name = %s, gpio = %d\n", i, gb[i].desc,
-					gb[i].gpio);
-		if (gb[i].gpio == -1)
+			 gb[i].gpio);
+		if (gb[i].gpio < 0)
 			continue;
 
 		if (i != good)
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_lis331.c b/arch/x86/platform/intel-mid/device_libs/platform_lis331.c
index 15278c1..8cd0c33 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_lis331.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_lis331.c
@@ -11,17 +11,17 @@
  */
 
 #include <linux/i2c.h>
-#include <linux/gpio.h>
+#include <linux/gpio/sfi.h>
 #include <asm/intel-mid.h>
 
 static void __init *lis331dl_platform_data(void *info)
 {
 	static short intr2nd_pdata;
 	struct i2c_board_info *i2c_info = info;
-	int intr = get_gpio_by_name("accel_int");
-	int intr2nd = get_gpio_by_name("accel_2");
+	int intr = sfi_get_gpio_by_name("accel_int");
+	int intr2nd = sfi_get_gpio_by_name("accel_2");
 
-	if (intr == -1 || intr2nd == -1)
+	if (intr < 0 || intr2nd < 0)
 		return NULL;
 
 	i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET;
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_max3111.c b/arch/x86/platform/intel-mid/device_libs/platform_max3111.c
index afd1df9..99d3832 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_max3111.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_max3111.c
@@ -10,17 +10,17 @@
  * of the License.
  */
 
-#include <linux/gpio.h>
+#include <linux/gpio/sfi.h>
 #include <linux/spi/spi.h>
 #include <asm/intel-mid.h>
 
 static void __init *max3111_platform_data(void *info)
 {
 	struct spi_board_info *spi_info = info;
-	int intr = get_gpio_by_name("max3111_int");
+	int intr = sfi_get_gpio_by_name("max3111_int");
 
 	spi_info->mode = SPI_MODE_0;
-	if (intr == -1)
+	if (intr < 0)
 		return NULL;
 	spi_info->irq = intr + INTEL_MID_IRQ_OFFSET;
 	return NULL;
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_max7315.c b/arch/x86/platform/intel-mid/device_libs/platform_max7315.c
index 94ade10..7613b86 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_max7315.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_max7315.c
@@ -11,7 +11,7 @@
  */
 
 #include <linux/init.h>
-#include <linux/gpio.h>
+#include <linux/gpio/sfi.h>
 #include <linux/i2c.h>
 #include <linux/platform_data/pca953x.h>
 #include <asm/intel-mid.h>
@@ -45,13 +45,13 @@ static void __init *max7315_platform_data(void *info)
 		strcpy(intr_pin_name, "max7315_int");
 	}
 
-	gpio_base = get_gpio_by_name(base_pin_name);
-	intr = get_gpio_by_name(intr_pin_name);
+	gpio_base = sfi_get_gpio_by_name(base_pin_name);
+	intr = sfi_get_gpio_by_name(intr_pin_name);
 
-	if (gpio_base == -1)
+	if (gpio_base < 0)
 		return NULL;
 	max7315->gpio_base = gpio_base;
-	if (intr != -1) {
+	if (intr >= 0) {
 		i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET;
 		max7315->irq_base = gpio_base + INTEL_MID_IRQ_OFFSET;
 	} else {
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_mpu3050.c b/arch/x86/platform/intel-mid/device_libs/platform_mpu3050.c
index dd28d63..af62a2a 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_mpu3050.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_mpu3050.c
@@ -10,16 +10,16 @@
  * of the License.
  */
 
-#include <linux/gpio.h>
+#include <linux/gpio/sfi.h>
 #include <linux/i2c.h>
 #include <asm/intel-mid.h>
 
 static void *mpu3050_platform_data(void *info)
 {
 	struct i2c_board_info *i2c_info = info;
-	int intr = get_gpio_by_name("mpu3050_int");
+	int intr = sfi_get_gpio_by_name("mpu3050_int");
 
-	if (intr == -1)
+	if (intr < 0)
 		return NULL;
 
 	i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET;
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_msic_gpio.c b/arch/x86/platform/intel-mid/device_libs/platform_msic_gpio.c
index 2a4f7b1..dc347da 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_msic_gpio.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_msic_gpio.c
@@ -15,7 +15,7 @@
 #include <linux/scatterlist.h>
 #include <linux/sfi.h>
 #include <linux/init.h>
-#include <linux/gpio.h>
+#include <linux/gpio/sfi.h>
 #include <linux/mfd/intel_msic.h>
 #include <asm/intel-mid.h>
 
@@ -25,9 +25,9 @@
 static void __init *msic_gpio_platform_data(void *info)
 {
 	static struct intel_msic_gpio_pdata msic_gpio_pdata;
+	int gpio;
 
-	int gpio = get_gpio_by_name("msic_gpio_base");
-
+	gpio = sfi_get_gpio_by_name("msic_gpio_base");
 	if (gpio < 0)
 		return NULL;
 
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_msic_ocd.c b/arch/x86/platform/intel-mid/device_libs/platform_msic_ocd.c
index 6497111..8f59154 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_msic_ocd.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_msic_ocd.c
@@ -15,7 +15,7 @@
 #include <linux/scatterlist.h>
 #include <linux/sfi.h>
 #include <linux/init.h>
-#include <linux/gpio.h>
+#include <linux/gpio/sfi.h>
 #include <linux/mfd/intel_msic.h>
 #include <asm/intel-mid.h>
 
@@ -27,8 +27,7 @@ static void __init *msic_ocd_platform_data(void *info)
 	static struct intel_msic_ocd_pdata msic_ocd_pdata;
 	int gpio;
 
-	gpio = get_gpio_by_name("ocd_gpio");
-
+	gpio = sfi_get_gpio_by_name("ocd_gpio");
 	if (gpio < 0)
 		return NULL;
 
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_pmic_gpio.c b/arch/x86/platform/intel-mid/device_libs/platform_pmic_gpio.c
index d87182a..954f5d9 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_pmic_gpio.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_pmic_gpio.c
@@ -13,7 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/interrupt.h>
 #include <linux/scatterlist.h>
-#include <linux/gpio.h>
+#include <linux/gpio/sfi.h>
 #include <linux/init.h>
 #include <linux/sfi.h>
 #include <linux/intel_pmic_gpio.h>
@@ -24,10 +24,11 @@
 static void __init *pmic_gpio_platform_data(void *info)
 {
 	static struct intel_pmic_gpio_platform_data pmic_gpio_pdata;
-	int gpio_base = get_gpio_by_name("pmic_gpio_base");
+	int gpio_base = sfi_get_gpio_by_name("pmic_gpio_base");
 
-	if (gpio_base == -1)
+	if (gpio_base < 0)
 		gpio_base = 64;
+
 	pmic_gpio_pdata.gpio_base = gpio_base;
 	pmic_gpio_pdata.irq_base = gpio_base + INTEL_MID_IRQ_OFFSET;
 	pmic_gpio_pdata.gpiointr = 0xffffeff8;
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_tc35876x.c b/arch/x86/platform/intel-mid/device_libs/platform_tc35876x.c
index 740fc75..3c62875 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_tc35876x.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_tc35876x.c
@@ -10,7 +10,7 @@
  * of the License.
  */
 
-#include <linux/gpio.h>
+#include <linux/gpio/sfi.h>
 #include <linux/i2c/tc35876x.h>
 #include <asm/intel-mid.h>
 
@@ -20,9 +20,9 @@ static void *tc35876x_platform_data(void *data)
 	static struct tc35876x_platform_data pdata;
 
 	/* gpio pins set to -1 will not be used by the driver */
-	pdata.gpio_bridge_reset = get_gpio_by_name("LCMB_RXEN");
-	pdata.gpio_panel_bl_en = get_gpio_by_name("6S6P_BL_EN");
-	pdata.gpio_panel_vadd = get_gpio_by_name("EN_VREG_LCD_V3P3");
+	pdata.gpio_bridge_reset = sfi_get_gpio_by_name("LCMB_RXEN");
+	pdata.gpio_panel_bl_en = sfi_get_gpio_by_name("6S6P_BL_EN");
+	pdata.gpio_panel_vadd = sfi_get_gpio_by_name("EN_VREG_LCD_V3P3");
 
 	return &pdata;
 }
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_tca6416.c b/arch/x86/platform/intel-mid/device_libs/platform_tca6416.c
index 22881c9..eb6d241 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_tca6416.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_tca6416.c
@@ -12,7 +12,7 @@
 
 #include <linux/platform_data/pca953x.h>
 #include <linux/i2c.h>
-#include <linux/gpio.h>
+#include <linux/gpio/sfi.h>
 #include <asm/intel-mid.h>
 
 #define TCA6416_NAME	"tca6416"
@@ -31,13 +31,13 @@ static void *tca6416_platform_data(void *info)
 	strcpy(base_pin_name, TCA6416_BASE);
 	strcpy(intr_pin_name, TCA6416_INTR);
 
-	gpio_base = get_gpio_by_name(base_pin_name);
-	intr = get_gpio_by_name(intr_pin_name);
+	gpio_base = sfi_get_gpio_by_name(base_pin_name);
+	intr = sfi_get_gpio_by_name(intr_pin_name);
 
-	if (gpio_base == -1)
+	if (gpio_base < 0)
 		return NULL;
 	tca6416.gpio_base = gpio_base;
-	if (intr != -1) {
+	if (intr >= 0) {
 		i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET;
 		tca6416.irq_base = gpio_base + INTEL_MID_IRQ_OFFSET;
 	} else {
diff --git a/arch/x86/platform/intel-mid/sfi.c b/arch/x86/platform/intel-mid/sfi.c
index c84c1ca..88beeb2 100644
--- a/arch/x86/platform/intel-mid/sfi.c
+++ b/arch/x86/platform/intel-mid/sfi.c
@@ -19,7 +19,6 @@
 #include <linux/spi/spi.h>
 #include <linux/i2c.h>
 #include <linux/skbuff.h>
-#include <linux/gpio.h>
 #include <linux/gpio_keys.h>
 #include <linux/input.h>
 #include <linux/platform_device.h>
@@ -51,13 +50,11 @@
 static struct platform_device *ipc_devs[MAX_IPCDEVS];
 static struct spi_board_info *spi_devs[MAX_SCU_SPI];
 static struct i2c_board_info *i2c_devs[MAX_SCU_I2C];
-static struct sfi_gpio_table_entry *gpio_table;
 static struct sfi_timer_table_entry sfi_mtimer_array[SFI_MTMR_MAX_NUM];
 static int ipc_next_dev;
 static int spi_next_dev;
 static int i2c_next_dev;
 static int i2c_bus[MAX_SCU_I2C];
-static int gpio_num_entry;
 static u32 sfi_mtimer_usage[SFI_MTMR_MAX_NUM];
 int sfi_mrtc_num;
 int sfi_mtimer_num;
@@ -180,53 +177,6 @@ int __init sfi_parse_mrtc(struct sfi_table_header *table)
 	return 0;
 }
 
-
-/*
- * Parsing GPIO table first, since the DEVS table will need this table
- * to map the pin name to the actual pin.
- */
-static int __init sfi_parse_gpio(struct sfi_table_header *table)
-{
-	struct sfi_table_simple *sb;
-	struct sfi_gpio_table_entry *pentry;
-	int num, i;
-
-	if (gpio_table)
-		return 0;
-	sb = (struct sfi_table_simple *)table;
-	num = SFI_GET_NUM_ENTRIES(sb, struct sfi_gpio_table_entry);
-	pentry = (struct sfi_gpio_table_entry *)sb->pentry;
-
-	gpio_table = kmalloc(num * sizeof(*pentry), GFP_KERNEL);
-	if (!gpio_table)
-		return -1;
-	memcpy(gpio_table, pentry, num * sizeof(*pentry));
-	gpio_num_entry = num;
-
-	pr_debug("GPIO pin info:\n");
-	for (i = 0; i < num; i++, pentry++)
-		pr_debug("info[%2d]: controller = %16.16s, pin_name = %16.16s,"
-		" pin = %d\n", i,
-			pentry->controller_name,
-			pentry->pin_name,
-			pentry->pin_no);
-	return 0;
-}
-
-int get_gpio_by_name(const char *name)
-{
-	struct sfi_gpio_table_entry *pentry = gpio_table;
-	int i;
-
-	if (!pentry)
-		return -1;
-	for (i = 0; i < gpio_num_entry; i++, pentry++) {
-		if (!strncmp(name, pentry->pin_name, SFI_NAME_LEN))
-			return pentry->pin_no;
-	}
-	return -1;
-}
-
 void __init intel_scu_device_register(struct platform_device *pdev)
 {
 	if (ipc_next_dev == MAX_IPCDEVS)
@@ -481,7 +431,6 @@ static int __init sfi_parse_devs(struct sfi_table_header *table)
 
 static int __init intel_mid_platform_init(void)
 {
-	sfi_table_parse(SFI_SIG_GPIO, NULL, NULL, sfi_parse_gpio);
 	sfi_table_parse(SFI_SIG_DEVS, NULL, NULL, sfi_parse_devs);
 	return 0;
 }
-- 
1.8.4.3


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 3/3] intel_mid: switch to use SFI GPIO API
  2013-11-20 14:31 ` [PATCH v2 3/3] intel_mid: switch to use SFI " Andy Shevchenko
@ 2013-11-20 18:13   ` David Cohen
  2013-11-26  9:38   ` Linus Walleij
  1 sibling, 0 replies; 10+ messages in thread
From: David Cohen @ 2013-11-20 18:13 UTC (permalink / raw)
  To: Andy Shevchenko, Linus Walleij, H. Peter Anvin, Ingo Molnar
  Cc: linux-gpio @ vger . kernel . org, Alexandre Courbot,
	Sathyanarayanan Kuppuswamy, Len Brown,
	linux-kernel @ vger . kernel . org, Grant Likely

Hi Andy,

Thanks for the patch.

On 11/20/2013 06:31 AM, Andy Shevchenko wrote:
> Instead of custom implementation of the SFI GPIO API let's use one provided by
> gpiolib.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Acked-by: David Cohen <david.a.cohen@linux.intel.com>

> ---
>  arch/x86/include/asm/intel-mid.h                   |  1 -
>  .../intel-mid/device_libs/platform_emc1403.c       |  8 ++--
>  .../intel-mid/device_libs/platform_gpio_keys.c     | 10 ++---
>  .../intel-mid/device_libs/platform_lis331.c        |  8 ++--
>  .../intel-mid/device_libs/platform_max3111.c       |  6 +--
>  .../intel-mid/device_libs/platform_max7315.c       | 10 ++---
>  .../intel-mid/device_libs/platform_mpu3050.c       |  6 +--
>  .../intel-mid/device_libs/platform_msic_gpio.c     |  6 +--
>  .../intel-mid/device_libs/platform_msic_ocd.c      |  5 +--
>  .../intel-mid/device_libs/platform_pmic_gpio.c     |  7 +--
>  .../intel-mid/device_libs/platform_tc35876x.c      |  8 ++--
>  .../intel-mid/device_libs/platform_tca6416.c       | 10 ++---
>  arch/x86/platform/intel-mid/sfi.c                  | 51 ----------------------
>  13 files changed, 42 insertions(+), 94 deletions(-)
>
> diff --git a/arch/x86/include/asm/intel-mid.h b/arch/x86/include/asm/intel-mid.h
> index 459769d..7e426b1 100644
> --- a/arch/x86/include/asm/intel-mid.h
> +++ b/arch/x86/include/asm/intel-mid.h
> @@ -15,7 +15,6 @@
>  #include <linux/platform_device.h>
>  
>  extern int intel_mid_pci_init(void);
> -extern int get_gpio_by_name(const char *name);
>  extern void intel_scu_device_register(struct platform_device *pdev);
>  extern int __init sfi_parse_mrtc(struct sfi_table_header *table);
>  extern int __init sfi_parse_mtmr(struct sfi_table_header *table);
> diff --git a/arch/x86/platform/intel-mid/device_libs/platform_emc1403.c b/arch/x86/platform/intel-mid/device_libs/platform_emc1403.c
> index 0d942c1..502f50f 100644
> --- a/arch/x86/platform/intel-mid/device_libs/platform_emc1403.c
> +++ b/arch/x86/platform/intel-mid/device_libs/platform_emc1403.c
> @@ -11,7 +11,7 @@
>   */
>  
>  #include <linux/init.h>
> -#include <linux/gpio.h>
> +#include <linux/gpio/sfi.h>
>  #include <linux/i2c.h>
>  #include <asm/intel-mid.h>
>  
> @@ -19,10 +19,10 @@ static void __init *emc1403_platform_data(void *info)
>  {
>  	static short intr2nd_pdata;
>  	struct i2c_board_info *i2c_info = info;
> -	int intr = get_gpio_by_name("thermal_int");
> -	int intr2nd = get_gpio_by_name("thermal_alert");
> +	int intr = sfi_get_gpio_by_name("thermal_int");
> +	int intr2nd = sfi_get_gpio_by_name("thermal_alert");
>  
> -	if (intr == -1 || intr2nd == -1)
> +	if (intr < 0 || intr2nd < 0)
>  		return NULL;
>  
>  	i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET;
> diff --git a/arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c b/arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c
> index a013a48..e3fb5be 100644
> --- a/arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c
> +++ b/arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c
> @@ -13,7 +13,7 @@
>  #include <linux/input.h>
>  #include <linux/init.h>
>  #include <linux/kernel.h>
> -#include <linux/gpio.h>
> +#include <linux/gpio/sfi.h>
>  #include <linux/gpio_keys.h>
>  #include <linux/platform_device.h>
>  #include <asm/intel-mid.h>
> @@ -61,12 +61,12 @@ static int __init pb_keys_init(void)
>  	struct gpio_keys_button *gb = gpio_button;
>  	int i, num, good = 0;
>  
> -	num = sizeof(gpio_button) / sizeof(struct gpio_keys_button);
> +	num = ARRAY_SIZE(gpio_button);
>  	for (i = 0; i < num; i++) {
> -		gb[i].gpio = get_gpio_by_name(gb[i].desc);
> +		gb[i].gpio = sfi_get_gpio_by_name(gb[i].desc);
>  		pr_debug("info[%2d]: name = %s, gpio = %d\n", i, gb[i].desc,
> -					gb[i].gpio);
> -		if (gb[i].gpio == -1)
> +			 gb[i].gpio);
> +		if (gb[i].gpio < 0)
>  			continue;
>  
>  		if (i != good)
> diff --git a/arch/x86/platform/intel-mid/device_libs/platform_lis331.c b/arch/x86/platform/intel-mid/device_libs/platform_lis331.c
> index 15278c1..8cd0c33 100644
> --- a/arch/x86/platform/intel-mid/device_libs/platform_lis331.c
> +++ b/arch/x86/platform/intel-mid/device_libs/platform_lis331.c
> @@ -11,17 +11,17 @@
>   */
>  
>  #include <linux/i2c.h>
> -#include <linux/gpio.h>
> +#include <linux/gpio/sfi.h>
>  #include <asm/intel-mid.h>
>  
>  static void __init *lis331dl_platform_data(void *info)
>  {
>  	static short intr2nd_pdata;
>  	struct i2c_board_info *i2c_info = info;
> -	int intr = get_gpio_by_name("accel_int");
> -	int intr2nd = get_gpio_by_name("accel_2");
> +	int intr = sfi_get_gpio_by_name("accel_int");
> +	int intr2nd = sfi_get_gpio_by_name("accel_2");
>  
> -	if (intr == -1 || intr2nd == -1)
> +	if (intr < 0 || intr2nd < 0)
>  		return NULL;
>  
>  	i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET;
> diff --git a/arch/x86/platform/intel-mid/device_libs/platform_max3111.c b/arch/x86/platform/intel-mid/device_libs/platform_max3111.c
> index afd1df9..99d3832 100644
> --- a/arch/x86/platform/intel-mid/device_libs/platform_max3111.c
> +++ b/arch/x86/platform/intel-mid/device_libs/platform_max3111.c
> @@ -10,17 +10,17 @@
>   * of the License.
>   */
>  
> -#include <linux/gpio.h>
> +#include <linux/gpio/sfi.h>
>  #include <linux/spi/spi.h>
>  #include <asm/intel-mid.h>
>  
>  static void __init *max3111_platform_data(void *info)
>  {
>  	struct spi_board_info *spi_info = info;
> -	int intr = get_gpio_by_name("max3111_int");
> +	int intr = sfi_get_gpio_by_name("max3111_int");
>  
>  	spi_info->mode = SPI_MODE_0;
> -	if (intr == -1)
> +	if (intr < 0)
>  		return NULL;
>  	spi_info->irq = intr + INTEL_MID_IRQ_OFFSET;
>  	return NULL;
> diff --git a/arch/x86/platform/intel-mid/device_libs/platform_max7315.c b/arch/x86/platform/intel-mid/device_libs/platform_max7315.c
> index 94ade10..7613b86 100644
> --- a/arch/x86/platform/intel-mid/device_libs/platform_max7315.c
> +++ b/arch/x86/platform/intel-mid/device_libs/platform_max7315.c
> @@ -11,7 +11,7 @@
>   */
>  
>  #include <linux/init.h>
> -#include <linux/gpio.h>
> +#include <linux/gpio/sfi.h>
>  #include <linux/i2c.h>
>  #include <linux/platform_data/pca953x.h>
>  #include <asm/intel-mid.h>
> @@ -45,13 +45,13 @@ static void __init *max7315_platform_data(void *info)
>  		strcpy(intr_pin_name, "max7315_int");
>  	}
>  
> -	gpio_base = get_gpio_by_name(base_pin_name);
> -	intr = get_gpio_by_name(intr_pin_name);
> +	gpio_base = sfi_get_gpio_by_name(base_pin_name);
> +	intr = sfi_get_gpio_by_name(intr_pin_name);
>  
> -	if (gpio_base == -1)
> +	if (gpio_base < 0)
>  		return NULL;
>  	max7315->gpio_base = gpio_base;
> -	if (intr != -1) {
> +	if (intr >= 0) {
>  		i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET;
>  		max7315->irq_base = gpio_base + INTEL_MID_IRQ_OFFSET;
>  	} else {
> diff --git a/arch/x86/platform/intel-mid/device_libs/platform_mpu3050.c b/arch/x86/platform/intel-mid/device_libs/platform_mpu3050.c
> index dd28d63..af62a2a 100644
> --- a/arch/x86/platform/intel-mid/device_libs/platform_mpu3050.c
> +++ b/arch/x86/platform/intel-mid/device_libs/platform_mpu3050.c
> @@ -10,16 +10,16 @@
>   * of the License.
>   */
>  
> -#include <linux/gpio.h>
> +#include <linux/gpio/sfi.h>
>  #include <linux/i2c.h>
>  #include <asm/intel-mid.h>
>  
>  static void *mpu3050_platform_data(void *info)
>  {
>  	struct i2c_board_info *i2c_info = info;
> -	int intr = get_gpio_by_name("mpu3050_int");
> +	int intr = sfi_get_gpio_by_name("mpu3050_int");
>  
> -	if (intr == -1)
> +	if (intr < 0)
>  		return NULL;
>  
>  	i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET;
> diff --git a/arch/x86/platform/intel-mid/device_libs/platform_msic_gpio.c b/arch/x86/platform/intel-mid/device_libs/platform_msic_gpio.c
> index 2a4f7b1..dc347da 100644
> --- a/arch/x86/platform/intel-mid/device_libs/platform_msic_gpio.c
> +++ b/arch/x86/platform/intel-mid/device_libs/platform_msic_gpio.c
> @@ -15,7 +15,7 @@
>  #include <linux/scatterlist.h>
>  #include <linux/sfi.h>
>  #include <linux/init.h>
> -#include <linux/gpio.h>
> +#include <linux/gpio/sfi.h>
>  #include <linux/mfd/intel_msic.h>
>  #include <asm/intel-mid.h>
>  
> @@ -25,9 +25,9 @@
>  static void __init *msic_gpio_platform_data(void *info)
>  {
>  	static struct intel_msic_gpio_pdata msic_gpio_pdata;
> +	int gpio;
>  
> -	int gpio = get_gpio_by_name("msic_gpio_base");
> -
> +	gpio = sfi_get_gpio_by_name("msic_gpio_base");
>  	if (gpio < 0)
>  		return NULL;
>  
> diff --git a/arch/x86/platform/intel-mid/device_libs/platform_msic_ocd.c b/arch/x86/platform/intel-mid/device_libs/platform_msic_ocd.c
> index 6497111..8f59154 100644
> --- a/arch/x86/platform/intel-mid/device_libs/platform_msic_ocd.c
> +++ b/arch/x86/platform/intel-mid/device_libs/platform_msic_ocd.c
> @@ -15,7 +15,7 @@
>  #include <linux/scatterlist.h>
>  #include <linux/sfi.h>
>  #include <linux/init.h>
> -#include <linux/gpio.h>
> +#include <linux/gpio/sfi.h>
>  #include <linux/mfd/intel_msic.h>
>  #include <asm/intel-mid.h>
>  
> @@ -27,8 +27,7 @@ static void __init *msic_ocd_platform_data(void *info)
>  	static struct intel_msic_ocd_pdata msic_ocd_pdata;
>  	int gpio;
>  
> -	gpio = get_gpio_by_name("ocd_gpio");
> -
> +	gpio = sfi_get_gpio_by_name("ocd_gpio");
>  	if (gpio < 0)
>  		return NULL;
>  
> diff --git a/arch/x86/platform/intel-mid/device_libs/platform_pmic_gpio.c b/arch/x86/platform/intel-mid/device_libs/platform_pmic_gpio.c
> index d87182a..954f5d9 100644
> --- a/arch/x86/platform/intel-mid/device_libs/platform_pmic_gpio.c
> +++ b/arch/x86/platform/intel-mid/device_libs/platform_pmic_gpio.c
> @@ -13,7 +13,7 @@
>  #include <linux/kernel.h>
>  #include <linux/interrupt.h>
>  #include <linux/scatterlist.h>
> -#include <linux/gpio.h>
> +#include <linux/gpio/sfi.h>
>  #include <linux/init.h>
>  #include <linux/sfi.h>
>  #include <linux/intel_pmic_gpio.h>
> @@ -24,10 +24,11 @@
>  static void __init *pmic_gpio_platform_data(void *info)
>  {
>  	static struct intel_pmic_gpio_platform_data pmic_gpio_pdata;
> -	int gpio_base = get_gpio_by_name("pmic_gpio_base");
> +	int gpio_base = sfi_get_gpio_by_name("pmic_gpio_base");
>  
> -	if (gpio_base == -1)
> +	if (gpio_base < 0)
>  		gpio_base = 64;
> +
>  	pmic_gpio_pdata.gpio_base = gpio_base;
>  	pmic_gpio_pdata.irq_base = gpio_base + INTEL_MID_IRQ_OFFSET;
>  	pmic_gpio_pdata.gpiointr = 0xffffeff8;
> diff --git a/arch/x86/platform/intel-mid/device_libs/platform_tc35876x.c b/arch/x86/platform/intel-mid/device_libs/platform_tc35876x.c
> index 740fc75..3c62875 100644
> --- a/arch/x86/platform/intel-mid/device_libs/platform_tc35876x.c
> +++ b/arch/x86/platform/intel-mid/device_libs/platform_tc35876x.c
> @@ -10,7 +10,7 @@
>   * of the License.
>   */
>  
> -#include <linux/gpio.h>
> +#include <linux/gpio/sfi.h>
>  #include <linux/i2c/tc35876x.h>
>  #include <asm/intel-mid.h>
>  
> @@ -20,9 +20,9 @@ static void *tc35876x_platform_data(void *data)
>  	static struct tc35876x_platform_data pdata;
>  
>  	/* gpio pins set to -1 will not be used by the driver */
> -	pdata.gpio_bridge_reset = get_gpio_by_name("LCMB_RXEN");
> -	pdata.gpio_panel_bl_en = get_gpio_by_name("6S6P_BL_EN");
> -	pdata.gpio_panel_vadd = get_gpio_by_name("EN_VREG_LCD_V3P3");
> +	pdata.gpio_bridge_reset = sfi_get_gpio_by_name("LCMB_RXEN");
> +	pdata.gpio_panel_bl_en = sfi_get_gpio_by_name("6S6P_BL_EN");
> +	pdata.gpio_panel_vadd = sfi_get_gpio_by_name("EN_VREG_LCD_V3P3");
>  
>  	return &pdata;
>  }
> diff --git a/arch/x86/platform/intel-mid/device_libs/platform_tca6416.c b/arch/x86/platform/intel-mid/device_libs/platform_tca6416.c
> index 22881c9..eb6d241 100644
> --- a/arch/x86/platform/intel-mid/device_libs/platform_tca6416.c
> +++ b/arch/x86/platform/intel-mid/device_libs/platform_tca6416.c
> @@ -12,7 +12,7 @@
>  
>  #include <linux/platform_data/pca953x.h>
>  #include <linux/i2c.h>
> -#include <linux/gpio.h>
> +#include <linux/gpio/sfi.h>
>  #include <asm/intel-mid.h>
>  
>  #define TCA6416_NAME	"tca6416"
> @@ -31,13 +31,13 @@ static void *tca6416_platform_data(void *info)
>  	strcpy(base_pin_name, TCA6416_BASE);
>  	strcpy(intr_pin_name, TCA6416_INTR);
>  
> -	gpio_base = get_gpio_by_name(base_pin_name);
> -	intr = get_gpio_by_name(intr_pin_name);
> +	gpio_base = sfi_get_gpio_by_name(base_pin_name);
> +	intr = sfi_get_gpio_by_name(intr_pin_name);
>  
> -	if (gpio_base == -1)
> +	if (gpio_base < 0)
>  		return NULL;
>  	tca6416.gpio_base = gpio_base;
> -	if (intr != -1) {
> +	if (intr >= 0) {
>  		i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET;
>  		tca6416.irq_base = gpio_base + INTEL_MID_IRQ_OFFSET;
>  	} else {
> diff --git a/arch/x86/platform/intel-mid/sfi.c b/arch/x86/platform/intel-mid/sfi.c
> index c84c1ca..88beeb2 100644
> --- a/arch/x86/platform/intel-mid/sfi.c
> +++ b/arch/x86/platform/intel-mid/sfi.c
> @@ -19,7 +19,6 @@
>  #include <linux/spi/spi.h>
>  #include <linux/i2c.h>
>  #include <linux/skbuff.h>
> -#include <linux/gpio.h>
>  #include <linux/gpio_keys.h>
>  #include <linux/input.h>
>  #include <linux/platform_device.h>
> @@ -51,13 +50,11 @@
>  static struct platform_device *ipc_devs[MAX_IPCDEVS];
>  static struct spi_board_info *spi_devs[MAX_SCU_SPI];
>  static struct i2c_board_info *i2c_devs[MAX_SCU_I2C];
> -static struct sfi_gpio_table_entry *gpio_table;
>  static struct sfi_timer_table_entry sfi_mtimer_array[SFI_MTMR_MAX_NUM];
>  static int ipc_next_dev;
>  static int spi_next_dev;
>  static int i2c_next_dev;
>  static int i2c_bus[MAX_SCU_I2C];
> -static int gpio_num_entry;
>  static u32 sfi_mtimer_usage[SFI_MTMR_MAX_NUM];
>  int sfi_mrtc_num;
>  int sfi_mtimer_num;
> @@ -180,53 +177,6 @@ int __init sfi_parse_mrtc(struct sfi_table_header *table)
>  	return 0;
>  }
>  
> -
> -/*
> - * Parsing GPIO table first, since the DEVS table will need this table
> - * to map the pin name to the actual pin.
> - */
> -static int __init sfi_parse_gpio(struct sfi_table_header *table)
> -{
> -	struct sfi_table_simple *sb;
> -	struct sfi_gpio_table_entry *pentry;
> -	int num, i;
> -
> -	if (gpio_table)
> -		return 0;
> -	sb = (struct sfi_table_simple *)table;
> -	num = SFI_GET_NUM_ENTRIES(sb, struct sfi_gpio_table_entry);
> -	pentry = (struct sfi_gpio_table_entry *)sb->pentry;
> -
> -	gpio_table = kmalloc(num * sizeof(*pentry), GFP_KERNEL);
> -	if (!gpio_table)
> -		return -1;
> -	memcpy(gpio_table, pentry, num * sizeof(*pentry));
> -	gpio_num_entry = num;
> -
> -	pr_debug("GPIO pin info:\n");
> -	for (i = 0; i < num; i++, pentry++)
> -		pr_debug("info[%2d]: controller = %16.16s, pin_name = %16.16s,"
> -		" pin = %d\n", i,
> -			pentry->controller_name,
> -			pentry->pin_name,
> -			pentry->pin_no);
> -	return 0;
> -}
> -
> -int get_gpio_by_name(const char *name)
> -{
> -	struct sfi_gpio_table_entry *pentry = gpio_table;
> -	int i;
> -
> -	if (!pentry)
> -		return -1;
> -	for (i = 0; i < gpio_num_entry; i++, pentry++) {
> -		if (!strncmp(name, pentry->pin_name, SFI_NAME_LEN))
> -			return pentry->pin_no;
> -	}
> -	return -1;
> -}
> -
>  void __init intel_scu_device_register(struct platform_device *pdev)
>  {
>  	if (ipc_next_dev == MAX_IPCDEVS)
> @@ -481,7 +431,6 @@ static int __init sfi_parse_devs(struct sfi_table_header *table)
>  
>  static int __init intel_mid_platform_init(void)
>  {
> -	sfi_table_parse(SFI_SIG_GPIO, NULL, NULL, sfi_parse_gpio);
>  	sfi_table_parse(SFI_SIG_DEVS, NULL, NULL, sfi_parse_devs);
>  	return 0;
>  }


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/3] gpiolib: append SFI helpers for GPIO API
  2013-11-20 14:31 ` [PATCH v2 2/3] gpiolib: append SFI helpers for GPIO API Andy Shevchenko
@ 2013-11-21 10:40   ` Mika Westerberg
  2013-11-21 16:29     ` Andy Shevchenko
  0 siblings, 1 reply; 10+ messages in thread
From: Mika Westerberg @ 2013-11-21 10:40 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linus Walleij, David Cohen, linux-gpio @ vger . kernel . org,
	Alexandre Courbot, Sathyanarayanan Kuppuswamy, Len Brown,
	linux-kernel @ vger . kernel . org, Grant Likely, Len Brown

On Wed, Nov 20, 2013 at 04:31:35PM +0200, Andy Shevchenko wrote:
> diff --git a/include/linux/gpio/sfi.h b/include/linux/gpio/sfi.h
> new file mode 100644
> index 0000000..3e111ad
> --- /dev/null
> +++ b/include/linux/gpio/sfi.h
> @@ -0,0 +1,37 @@
> +#ifndef _LINUX_SFI_GPIO_H_
> +#define _LINUX_SFI_GPIO_H_
> +
> +#include <linux/err.h>
> +#include <linux/errno.h>
> +#include <linux/gpio/consumer.h>
> +#include <linux/sfi.h>
> +
> +#ifdef CONFIG_GPIO_SFI
> +
> +struct gpio_desc *sfi_get_gpiod_by_name(const char *name);

I'm wondering should this function be exported at all? What the drivers
should be using is gpiod_get_xxx() APIs and not DT/ACPI/SFI specific
interfaces.

Yeah, we have the same in ACPI version but I'm planning to get rid of it
completely.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/3] gpiolib: append SFI helpers for GPIO API
  2013-11-21 10:40   ` Mika Westerberg
@ 2013-11-21 16:29     ` Andy Shevchenko
  2013-11-26  9:37       ` Linus Walleij
  0 siblings, 1 reply; 10+ messages in thread
From: Andy Shevchenko @ 2013-11-21 16:29 UTC (permalink / raw)
  To: Mika Westerberg
  Cc: Linus Walleij, David Cohen, linux-gpio @ vger . kernel . org,
	Alexandre Courbot, Sathyanarayanan Kuppuswamy, Len Brown,
	linux-kernel @ vger . kernel . org, Grant Likely, Len Brown

On Thu, 2013-11-21 at 12:40 +0200, Mika Westerberg wrote:
> On Wed, Nov 20, 2013 at 04:31:35PM +0200, Andy Shevchenko wrote:
> > diff --git a/include/linux/gpio/sfi.h b/include/linux/gpio/sfi.h
> > new file mode 100644
> > index 0000000..3e111ad
> > --- /dev/null
> > +++ b/include/linux/gpio/sfi.h
> > @@ -0,0 +1,37 @@
> > +#ifndef _LINUX_SFI_GPIO_H_
> > +#define _LINUX_SFI_GPIO_H_
> > +
> > +#include <linux/err.h>
> > +#include <linux/errno.h>
> > +#include <linux/gpio/consumer.h>
> > +#include <linux/sfi.h>
> > +
> > +#ifdef CONFIG_GPIO_SFI
> > +
> > +struct gpio_desc *sfi_get_gpiod_by_name(const char *name);
> 
> I'm wondering should this function be exported at all? What the drivers
> should be using is gpiod_get_xxx() APIs and not DT/ACPI/SFI specific
> interfaces.

I won't mix this with generic stuff since we have really few users of
SFI and there should be no new users at all.

> Yeah, we have the same in ACPI version but I'm planning to get rid of it
> completely.

I'm okay to move to this direction, if Linus and others are okay with
it.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/3] gpiolib: append SFI helpers for GPIO API
  2013-11-21 16:29     ` Andy Shevchenko
@ 2013-11-26  9:37       ` Linus Walleij
  0 siblings, 0 replies; 10+ messages in thread
From: Linus Walleij @ 2013-11-26  9:37 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Mika Westerberg, David Cohen, linux-gpio @ vger . kernel . org,
	Alexandre Courbot, Sathyanarayanan Kuppuswamy, Len Brown,
	linux-kernel @ vger . kernel . org, Grant Likely, Len Brown

On Thu, Nov 21, 2013 at 5:29 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> On Thu, 2013-11-21 at 12:40 +0200, Mika Westerberg wrote:
>> On Wed, Nov 20, 2013 at 04:31:35PM +0200, Andy Shevchenko wrote:

>> > +struct gpio_desc *sfi_get_gpiod_by_name(const char *name);
>>
>> I'm wondering should this function be exported at all? What the drivers
>> should be using is gpiod_get_xxx() APIs and not DT/ACPI/SFI specific
>> interfaces.
>
> I won't mix this with generic stuff since we have really few users of
> SFI and there should be no new users at all.
>
>> Yeah, we have the same in ACPI version but I'm planning to get rid of it
>> completely.
>
> I'm okay to move to this direction, if Linus and others are okay with
> it.

Go for it. Mika is right that we need to get rid of any custom calls
and this is the way ACPI is moving too...

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 3/3] intel_mid: switch to use SFI GPIO API
  2013-11-20 14:31 ` [PATCH v2 3/3] intel_mid: switch to use SFI " Andy Shevchenko
  2013-11-20 18:13   ` David Cohen
@ 2013-11-26  9:38   ` Linus Walleij
  2013-11-27 11:55     ` Andy Shevchenko
  1 sibling, 1 reply; 10+ messages in thread
From: Linus Walleij @ 2013-11-26  9:38 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: David Cohen, linux-gpio @ vger . kernel . org, Alexandre Courbot,
	Sathyanarayanan Kuppuswamy, Len Brown,
	linux-kernel @ vger . kernel . org, Grant Likely

On Wed, Nov 20, 2013 at 3:31 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> Instead of custom implementation of the SFI GPIO API let's use one provided by
> gpiolib.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

So is it possible to move this to just do gpiod_get() from the drivers
and abstract away SFI altogether as indicated by Mika?

I'd love that, if possible.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 3/3] intel_mid: switch to use SFI GPIO API
  2013-11-26  9:38   ` Linus Walleij
@ 2013-11-27 11:55     ` Andy Shevchenko
  0 siblings, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2013-11-27 11:55 UTC (permalink / raw)
  To: Linus Walleij
  Cc: David Cohen, linux-gpio @ vger . kernel . org, Alexandre Courbot,
	Sathyanarayanan Kuppuswamy, Len Brown,
	linux-kernel @ vger . kernel . org, Grant Likely

On Tue, 2013-11-26 at 10:38 +0100, Linus Walleij wrote:
> On Wed, Nov 20, 2013 at 3:31 PM, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> 
> > Instead of custom implementation of the SFI GPIO API let's use one provided by
> > gpiolib.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> So is it possible to move this to just do gpiod_get() from the drivers
> and abstract away SFI altogether as indicated by Mika?
> 
> I'd love that, if possible.

I will look at it later.
Anyway it's apparently for 3.14.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-11-27 11:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-20 14:31 [PATCH v2 0/3] sfi, intel_mid: introduce SFI GPIO API and use it Andy Shevchenko
2013-11-20 14:31 ` [PATCH v2 1/3] sfi: fix compiler warnings Andy Shevchenko
2013-11-20 14:31 ` [PATCH v2 2/3] gpiolib: append SFI helpers for GPIO API Andy Shevchenko
2013-11-21 10:40   ` Mika Westerberg
2013-11-21 16:29     ` Andy Shevchenko
2013-11-26  9:37       ` Linus Walleij
2013-11-20 14:31 ` [PATCH v2 3/3] intel_mid: switch to use SFI " Andy Shevchenko
2013-11-20 18:13   ` David Cohen
2013-11-26  9:38   ` Linus Walleij
2013-11-27 11:55     ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).