[PATCH v4 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

2015-02-01 Thread Raymond Tan
In Quark X1000, there's a single PCI device that provides both
an I2C controller and a GPIO controller. This MFD driver will
split the 2 devices for their respective drivers.

This patch is based on Josef Ahmad's initial work for Quark enabling.

Acked-by: Michael Turquette 
Reviewed-by: Andy Shevchenko 
Signed-off-by: Weike Chen 
Signed-off-by: Raymond Tan 
---
 drivers/mfd/Kconfig|   12 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/intel_quark_i2c_gpio.c |  277 
 3 files changed, 290 insertions(+)
 create mode 100644 drivers/mfd/intel_quark_i2c_gpio.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index b7c74a7..2f2f62d 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -219,6 +219,18 @@ config HTC_I2CPLD
  This device provides input and output GPIOs through an I2C
  interface to one or more sub-chips.
 
+config MFD_INTEL_QUARK_I2C_GPIO
+   tristate "Intel Quark MFD I2C GPIO"
+   depends on PCI
+   depends on X86
+   depends on COMMON_CLK
+   select MFD_CORE
+   help
+ This MFD provides support for I2C and GPIO that exist only
+ in a single PCI device. It splits the 2 IO devices to
+ their respective IO driver.
+ The GPIO exports a total amount of 8 interrupt-capable GPIOs.
+
 config LPC_ICH
tristate "Intel ICH LPC"
depends on PCI
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 8a28dc9..d42652d 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -133,6 +133,7 @@ obj-$(CONFIG_AB8500_CORE)   += ab8500-core.o 
ab8500-sysctrl.o
 obj-$(CONFIG_MFD_TIMBERDALE)+= timberdale.o
 obj-$(CONFIG_PMIC_ADP5520) += adp5520.o
 obj-$(CONFIG_MFD_KEMPLD)   += kempld-core.o
+obj-$(CONFIG_MFD_INTEL_QUARK_I2C_GPIO) += intel_quark_i2c_gpio.o
 obj-$(CONFIG_LPC_SCH)  += lpc_sch.o
 obj-$(CONFIG_LPC_ICH)  += lpc_ich.o
 obj-$(CONFIG_MFD_RDC321X)  += rdc321x-southbridge.o
diff --git a/drivers/mfd/intel_quark_i2c_gpio.c 
b/drivers/mfd/intel_quark_i2c_gpio.c
new file mode 100644
index 000..006f2a1
--- /dev/null
+++ b/drivers/mfd/intel_quark_i2c_gpio.c
@@ -0,0 +1,277 @@
+/*
+ * Intel Quark MFD PCI driver for I2C & GPIO
+ *
+ * Copyright(c) 2014 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * Intel Quark PCI device for I2C and GPIO controller sharing the same
+ * PCI function. This PCI driver will split the 2 devices into their
+ * respective drivers.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* PCI BAR for register base address */
+#define MFD_I2C_BAR0
+#define MFD_GPIO_BAR   1
+
+/* The base GPIO number under GPIOLIB framework */
+#define INTEL_QUARK_MFD_GPIO_BASE  8
+
+/* The default number of South-Cluster GPIO on Quark. */
+#define INTEL_QUARK_MFD_NGPIO  8
+
+/* The DesignWare GPIO ports on Quark. */
+#define INTEL_QUARK_GPIO_NPORTS1
+
+#define INTEL_QUARK_IORES_MEM  0
+#define INTEL_QUARK_IORES_IRQ  1
+
+#define INTEL_QUARK_I2C_CONTROLLER_CLK "i2c_designware.0"
+
+/* The Quark I2C controller source clock */
+#define INTEL_QUARK_I2C_CLK_HZ 3300
+
+#define INTEL_QUARK_I2C_NCLK   1
+
+struct intel_quark_mfd {
+   struct pci_dev  *pdev;
+   struct clk  *i2c_clk;
+   struct clk_lookup   *i2c_clk_lookup;
+};
+
+struct i2c_mode_info {
+   const char *name;
+   unsigned int i2c_scl_freq;
+};
+
+static const struct i2c_mode_info platform_i2c_mode_info[] = {
+   {
+   .name = "Galileo",
+   .i2c_scl_freq = 10,
+   },
+   {
+   .name = "GalileoGen2",
+   .i2c_scl_freq = 40,
+   },
+};
+
+static struct resource intel_quark_i2c_res[] = {
+   [INTEL_QUARK_IORES_MEM] = {
+   .flags = IORESOURCE_MEM,
+   },
+   [INTEL_QUARK_IORES_IRQ] = {
+   .flags = IORESOURCE_IRQ,
+   },
+};
+
+static struct resource intel_quark_gpio_res[] = {
+   [INTEL_QUARK_IORES_MEM] = {
+   .flags = IORESOURCE_MEM,
+   },
+};
+
+static struct mfd_cell intel_quark_mfd_cells[] = {
+   {
+   .id = MFD_I2C_BAR,
+   .name = "i2c_designware",
+   .num_resources = ARRAY_SIZE(intel_quark_i2c_res),
+   .resources = intel_quark_i2c_res,
+   .ignore_resource_conflicts = true,
+   },
+   {
+  

[PATCH v4 0/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

2015-02-01 Thread Raymond Tan
From: "Tan, Raymond" 

Hi,
This patch is for enabling support of Intel Quark X1000 I2C controller and
GPIO controller. In Quark X1000, the platform exports a single PCI device
with both I2C and GPIO functions.

This MFD driver will split the 2 devices for their respective drivers.

---
Changes in v4:
* Modify the formatting and alignment of source lines
* Change variable name retval to ret to be consistent with the rest of the 
kernel

Changes in v3:
* Simplify the call path for both gpio and i2c controllers initialization
* Move the global variables clk and clk_lookup into a struct

Changes in v2:
* Fix possible memory leak

Raymond Tan (1):
  mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

 drivers/mfd/Kconfig|   12 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/intel_quark_i2c_gpio.c |  277 
 3 files changed, 290 insertions(+)
 create mode 100644 drivers/mfd/intel_quark_i2c_gpio.c

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

2015-02-01 Thread Raymond Tan
In Quark X1000, there's a single PCI device that provides both
an I2C controller and a GPIO controller. This MFD driver will
split the 2 devices for their respective drivers.

This patch is based on Josef Ahmad's initial work for Quark enabling.

Acked-by: Michael Turquette mturque...@linaro.org
Reviewed-by: Andy Shevchenko andriy.shevche...@linux.intel.com
Signed-off-by: Weike Chen alvin.c...@intel.com
Signed-off-by: Raymond Tan raymond@intel.com
---
 drivers/mfd/Kconfig|   12 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/intel_quark_i2c_gpio.c |  277 
 3 files changed, 290 insertions(+)
 create mode 100644 drivers/mfd/intel_quark_i2c_gpio.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index b7c74a7..2f2f62d 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -219,6 +219,18 @@ config HTC_I2CPLD
  This device provides input and output GPIOs through an I2C
  interface to one or more sub-chips.
 
+config MFD_INTEL_QUARK_I2C_GPIO
+   tristate Intel Quark MFD I2C GPIO
+   depends on PCI
+   depends on X86
+   depends on COMMON_CLK
+   select MFD_CORE
+   help
+ This MFD provides support for I2C and GPIO that exist only
+ in a single PCI device. It splits the 2 IO devices to
+ their respective IO driver.
+ The GPIO exports a total amount of 8 interrupt-capable GPIOs.
+
 config LPC_ICH
tristate Intel ICH LPC
depends on PCI
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 8a28dc9..d42652d 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -133,6 +133,7 @@ obj-$(CONFIG_AB8500_CORE)   += ab8500-core.o 
ab8500-sysctrl.o
 obj-$(CONFIG_MFD_TIMBERDALE)+= timberdale.o
 obj-$(CONFIG_PMIC_ADP5520) += adp5520.o
 obj-$(CONFIG_MFD_KEMPLD)   += kempld-core.o
+obj-$(CONFIG_MFD_INTEL_QUARK_I2C_GPIO) += intel_quark_i2c_gpio.o
 obj-$(CONFIG_LPC_SCH)  += lpc_sch.o
 obj-$(CONFIG_LPC_ICH)  += lpc_ich.o
 obj-$(CONFIG_MFD_RDC321X)  += rdc321x-southbridge.o
diff --git a/drivers/mfd/intel_quark_i2c_gpio.c 
b/drivers/mfd/intel_quark_i2c_gpio.c
new file mode 100644
index 000..006f2a1
--- /dev/null
+++ b/drivers/mfd/intel_quark_i2c_gpio.c
@@ -0,0 +1,277 @@
+/*
+ * Intel Quark MFD PCI driver for I2C  GPIO
+ *
+ * Copyright(c) 2014 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * Intel Quark PCI device for I2C and GPIO controller sharing the same
+ * PCI function. This PCI driver will split the 2 devices into their
+ * respective drivers.
+ */
+
+#include linux/kernel.h
+#include linux/module.h
+#include linux/pci.h
+#include linux/mfd/core.h
+#include linux/clkdev.h
+#include linux/clk-provider.h
+#include linux/dmi.h
+#include linux/platform_data/gpio-dwapb.h
+#include linux/platform_data/i2c-designware.h
+
+/* PCI BAR for register base address */
+#define MFD_I2C_BAR0
+#define MFD_GPIO_BAR   1
+
+/* The base GPIO number under GPIOLIB framework */
+#define INTEL_QUARK_MFD_GPIO_BASE  8
+
+/* The default number of South-Cluster GPIO on Quark. */
+#define INTEL_QUARK_MFD_NGPIO  8
+
+/* The DesignWare GPIO ports on Quark. */
+#define INTEL_QUARK_GPIO_NPORTS1
+
+#define INTEL_QUARK_IORES_MEM  0
+#define INTEL_QUARK_IORES_IRQ  1
+
+#define INTEL_QUARK_I2C_CONTROLLER_CLK i2c_designware.0
+
+/* The Quark I2C controller source clock */
+#define INTEL_QUARK_I2C_CLK_HZ 3300
+
+#define INTEL_QUARK_I2C_NCLK   1
+
+struct intel_quark_mfd {
+   struct pci_dev  *pdev;
+   struct clk  *i2c_clk;
+   struct clk_lookup   *i2c_clk_lookup;
+};
+
+struct i2c_mode_info {
+   const char *name;
+   unsigned int i2c_scl_freq;
+};
+
+static const struct i2c_mode_info platform_i2c_mode_info[] = {
+   {
+   .name = Galileo,
+   .i2c_scl_freq = 10,
+   },
+   {
+   .name = GalileoGen2,
+   .i2c_scl_freq = 40,
+   },
+};
+
+static struct resource intel_quark_i2c_res[] = {
+   [INTEL_QUARK_IORES_MEM] = {
+   .flags = IORESOURCE_MEM,
+   },
+   [INTEL_QUARK_IORES_IRQ] = {
+   .flags = IORESOURCE_IRQ,
+   },
+};
+
+static struct resource intel_quark_gpio_res[] = {
+   [INTEL_QUARK_IORES_MEM] = {
+   .flags = IORESOURCE_MEM,
+   },
+};
+
+static struct mfd_cell intel_quark_mfd_cells[] = {
+   {
+   .id = MFD_I2C_BAR,
+   .name = i2c_designware

[PATCH v4 0/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

2015-02-01 Thread Raymond Tan
From: Tan, Raymond raymond@intel.com

Hi,
This patch is for enabling support of Intel Quark X1000 I2C controller and
GPIO controller. In Quark X1000, the platform exports a single PCI device
with both I2C and GPIO functions.

This MFD driver will split the 2 devices for their respective drivers.

---
Changes in v4:
* Modify the formatting and alignment of source lines
* Change variable name retval to ret to be consistent with the rest of the 
kernel

Changes in v3:
* Simplify the call path for both gpio and i2c controllers initialization
* Move the global variables clk and clk_lookup into a struct

Changes in v2:
* Fix possible memory leak

Raymond Tan (1):
  mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

 drivers/mfd/Kconfig|   12 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/intel_quark_i2c_gpio.c |  277 
 3 files changed, 290 insertions(+)
 create mode 100644 drivers/mfd/intel_quark_i2c_gpio.c

-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 0/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

2014-12-11 Thread Raymond Tan
From: "Tan, Raymond" 

Hi,
This patch is for enabling support of Intel Quark X1000 I2C controller and
GPIO controller. In Quark X1000, the platform exports a single PCI device
with both I2C and GPIO functions.

This MFD driver will split the 2 devices for their respective drivers.

---
Changes in v3:
* Simplify the call path for both gpio and i2c controllers initialization
* Move the global variables clk and clk_lookup into a struct

Changes in v2:
* Fix possible memory leak

Raymond Tan (1):
  mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

 drivers/mfd/Kconfig|   12 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/intel_quark_i2c_gpio.c |  279 
 3 files changed, 292 insertions(+)
 create mode 100644 drivers/mfd/intel_quark_i2c_gpio.c

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

2014-12-11 Thread Raymond Tan
In Quark X1000, there's a single PCI device that provides both
an I2C controller and a GPIO controller. This MFD driver will
split the 2 devices for their respective drivers.

This patch is based on Josef Ahmad's initial work for Quark enabling.

Reviewed-by: Andy Shevchenko 
Signed-off-by: Weike Chen 
Signed-off-by: Raymond Tan 
---
 drivers/mfd/Kconfig|   12 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/intel_quark_i2c_gpio.c |  279 
 3 files changed, 292 insertions(+)
 create mode 100644 drivers/mfd/intel_quark_i2c_gpio.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index b7c74a7..2f2f62d 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -219,6 +219,18 @@ config HTC_I2CPLD
  This device provides input and output GPIOs through an I2C
  interface to one or more sub-chips.
 
+config MFD_INTEL_QUARK_I2C_GPIO
+   tristate "Intel Quark MFD I2C GPIO"
+   depends on PCI
+   depends on X86
+   depends on COMMON_CLK
+   select MFD_CORE
+   help
+ This MFD provides support for I2C and GPIO that exist only
+ in a single PCI device. It splits the 2 IO devices to
+ their respective IO driver.
+ The GPIO exports a total amount of 8 interrupt-capable GPIOs.
+
 config LPC_ICH
tristate "Intel ICH LPC"
depends on PCI
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 8a28dc9..d42652d 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -133,6 +133,7 @@ obj-$(CONFIG_AB8500_CORE)   += ab8500-core.o 
ab8500-sysctrl.o
 obj-$(CONFIG_MFD_TIMBERDALE)+= timberdale.o
 obj-$(CONFIG_PMIC_ADP5520) += adp5520.o
 obj-$(CONFIG_MFD_KEMPLD)   += kempld-core.o
+obj-$(CONFIG_MFD_INTEL_QUARK_I2C_GPIO) += intel_quark_i2c_gpio.o
 obj-$(CONFIG_LPC_SCH)  += lpc_sch.o
 obj-$(CONFIG_LPC_ICH)  += lpc_ich.o
 obj-$(CONFIG_MFD_RDC321X)  += rdc321x-southbridge.o
diff --git a/drivers/mfd/intel_quark_i2c_gpio.c 
b/drivers/mfd/intel_quark_i2c_gpio.c
new file mode 100644
index 000..a3a7043
--- /dev/null
+++ b/drivers/mfd/intel_quark_i2c_gpio.c
@@ -0,0 +1,279 @@
+/*
+ * Intel Quark MFD PCI driver for I2C & GPIO
+ *
+ * Copyright(c) 2014 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * Intel Quark PCI device for I2C and GPIO controller sharing the same
+ * PCI function. This PCI driver will split the 2 devices into their
+ * respective drivers.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* PCI BAR for register base address */
+#define MFD_I2C_BAR0
+#define MFD_GPIO_BAR   1
+
+/* The base GPIO number under GPIOLIB framework */
+#define INTEL_QUARK_MFD_GPIO_BASE  8
+
+/* The default number of South-Cluster GPIO on Quark. */
+#define INTEL_QUARK_MFD_NGPIO  8
+
+/* The DesignWare GPIO ports on Quark. */
+#define INTEL_QUARK_GPIO_NPORTS1
+
+#define INTEL_QUARK_IORES_MEM  0
+#define INTEL_QUARK_IORES_IRQ  1
+
+#define INTEL_QUARK_I2C_CONTROLLER_CLK "i2c_designware.0"
+
+/* The Quark I2C controller source clock */
+#define INTEL_QUARK_I2C_CLK_HZ 3300
+
+#define INTEL_QUARK_I2C_NCLK   1
+
+struct intel_quark_mfd {
+   struct pci_dev  *pdev;
+   struct clk  *i2c_clk;
+   struct clk_lookup   *i2c_clk_lookup;
+};
+
+struct i2c_mode_info {
+   const char *name;
+   unsigned int i2c_scl_freq;
+};
+
+static const struct i2c_mode_info platform_i2c_mode_info[] = {
+   {
+   .name = "Galileo",
+   .i2c_scl_freq = 10,
+   },
+   {
+   .name = "GalileoGen2",
+   .i2c_scl_freq = 40,
+   },
+};
+
+static struct resource intel_quark_i2c_res[] = {
+   [INTEL_QUARK_IORES_MEM] = {
+   .flags = IORESOURCE_MEM,
+   },
+   [INTEL_QUARK_IORES_IRQ] = {
+   .flags = IORESOURCE_IRQ,
+   },
+};
+
+static struct resource intel_quark_gpio_res[] = {
+   [INTEL_QUARK_IORES_MEM] = {
+   .flags = IORESOURCE_MEM,
+   },
+};
+
+static struct mfd_cell intel_quark_mfd_cells[] = {
+   {
+   .id = MFD_I2C_BAR,
+   .name = "i2c_designware",
+   .num_resources = ARRAY_SIZE(intel_quark_i2c_res),
+   .resources = intel_quark_i2c_res,
+   .ignore_resource_conflicts = true,
+   },
+   {
+  

[PATCH v3 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

2014-12-11 Thread Raymond Tan
In Quark X1000, there's a single PCI device that provides both
an I2C controller and a GPIO controller. This MFD driver will
split the 2 devices for their respective drivers.

This patch is based on Josef Ahmad's initial work for Quark enabling.

Reviewed-by: Andy Shevchenko andriy.shevche...@linux.intel.com
Signed-off-by: Weike Chen alvin.c...@intel.com
Signed-off-by: Raymond Tan raymond@intel.com
---
 drivers/mfd/Kconfig|   12 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/intel_quark_i2c_gpio.c |  279 
 3 files changed, 292 insertions(+)
 create mode 100644 drivers/mfd/intel_quark_i2c_gpio.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index b7c74a7..2f2f62d 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -219,6 +219,18 @@ config HTC_I2CPLD
  This device provides input and output GPIOs through an I2C
  interface to one or more sub-chips.
 
+config MFD_INTEL_QUARK_I2C_GPIO
+   tristate Intel Quark MFD I2C GPIO
+   depends on PCI
+   depends on X86
+   depends on COMMON_CLK
+   select MFD_CORE
+   help
+ This MFD provides support for I2C and GPIO that exist only
+ in a single PCI device. It splits the 2 IO devices to
+ their respective IO driver.
+ The GPIO exports a total amount of 8 interrupt-capable GPIOs.
+
 config LPC_ICH
tristate Intel ICH LPC
depends on PCI
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 8a28dc9..d42652d 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -133,6 +133,7 @@ obj-$(CONFIG_AB8500_CORE)   += ab8500-core.o 
ab8500-sysctrl.o
 obj-$(CONFIG_MFD_TIMBERDALE)+= timberdale.o
 obj-$(CONFIG_PMIC_ADP5520) += adp5520.o
 obj-$(CONFIG_MFD_KEMPLD)   += kempld-core.o
+obj-$(CONFIG_MFD_INTEL_QUARK_I2C_GPIO) += intel_quark_i2c_gpio.o
 obj-$(CONFIG_LPC_SCH)  += lpc_sch.o
 obj-$(CONFIG_LPC_ICH)  += lpc_ich.o
 obj-$(CONFIG_MFD_RDC321X)  += rdc321x-southbridge.o
diff --git a/drivers/mfd/intel_quark_i2c_gpio.c 
b/drivers/mfd/intel_quark_i2c_gpio.c
new file mode 100644
index 000..a3a7043
--- /dev/null
+++ b/drivers/mfd/intel_quark_i2c_gpio.c
@@ -0,0 +1,279 @@
+/*
+ * Intel Quark MFD PCI driver for I2C  GPIO
+ *
+ * Copyright(c) 2014 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * Intel Quark PCI device for I2C and GPIO controller sharing the same
+ * PCI function. This PCI driver will split the 2 devices into their
+ * respective drivers.
+ */
+
+#include linux/kernel.h
+#include linux/module.h
+#include linux/pci.h
+#include linux/mfd/core.h
+#include linux/clkdev.h
+#include linux/clk-provider.h
+#include linux/dmi.h
+#include linux/platform_data/gpio-dwapb.h
+#include linux/platform_data/i2c-designware.h
+
+/* PCI BAR for register base address */
+#define MFD_I2C_BAR0
+#define MFD_GPIO_BAR   1
+
+/* The base GPIO number under GPIOLIB framework */
+#define INTEL_QUARK_MFD_GPIO_BASE  8
+
+/* The default number of South-Cluster GPIO on Quark. */
+#define INTEL_QUARK_MFD_NGPIO  8
+
+/* The DesignWare GPIO ports on Quark. */
+#define INTEL_QUARK_GPIO_NPORTS1
+
+#define INTEL_QUARK_IORES_MEM  0
+#define INTEL_QUARK_IORES_IRQ  1
+
+#define INTEL_QUARK_I2C_CONTROLLER_CLK i2c_designware.0
+
+/* The Quark I2C controller source clock */
+#define INTEL_QUARK_I2C_CLK_HZ 3300
+
+#define INTEL_QUARK_I2C_NCLK   1
+
+struct intel_quark_mfd {
+   struct pci_dev  *pdev;
+   struct clk  *i2c_clk;
+   struct clk_lookup   *i2c_clk_lookup;
+};
+
+struct i2c_mode_info {
+   const char *name;
+   unsigned int i2c_scl_freq;
+};
+
+static const struct i2c_mode_info platform_i2c_mode_info[] = {
+   {
+   .name = Galileo,
+   .i2c_scl_freq = 10,
+   },
+   {
+   .name = GalileoGen2,
+   .i2c_scl_freq = 40,
+   },
+};
+
+static struct resource intel_quark_i2c_res[] = {
+   [INTEL_QUARK_IORES_MEM] = {
+   .flags = IORESOURCE_MEM,
+   },
+   [INTEL_QUARK_IORES_IRQ] = {
+   .flags = IORESOURCE_IRQ,
+   },
+};
+
+static struct resource intel_quark_gpio_res[] = {
+   [INTEL_QUARK_IORES_MEM] = {
+   .flags = IORESOURCE_MEM,
+   },
+};
+
+static struct mfd_cell intel_quark_mfd_cells[] = {
+   {
+   .id = MFD_I2C_BAR,
+   .name = i2c_designware,
+   .num_resources = ARRAY_SIZE

[PATCH v3 0/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

2014-12-11 Thread Raymond Tan
From: Tan, Raymond raymond@intel.com

Hi,
This patch is for enabling support of Intel Quark X1000 I2C controller and
GPIO controller. In Quark X1000, the platform exports a single PCI device
with both I2C and GPIO functions.

This MFD driver will split the 2 devices for their respective drivers.

---
Changes in v3:
* Simplify the call path for both gpio and i2c controllers initialization
* Move the global variables clk and clk_lookup into a struct

Changes in v2:
* Fix possible memory leak

Raymond Tan (1):
  mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

 drivers/mfd/Kconfig|   12 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/intel_quark_i2c_gpio.c |  279 
 3 files changed, 292 insertions(+)
 create mode 100644 drivers/mfd/intel_quark_i2c_gpio.c

-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

2014-11-11 Thread Raymond Tan
In Quark X1000, there's a single PCI device that provides both
an I2C controller and a GPIO controller. This MFD driver will
split the 2 devices for their respective drivers.

This patch is based on Josef Ahmad's initial work for Quark enabling.

Reviewed-by: Andy Shevchenko 
Signed-off-by: Weike Chen 
Signed-off-by: Raymond Tan 
---
 drivers/mfd/Kconfig|   11 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/intel_quark_i2c_gpio.c |  298 
 3 files changed, 310 insertions(+)
 create mode 100644 drivers/mfd/intel_quark_i2c_gpio.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index b7c74a7..d01d042 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -219,6 +219,17 @@ config HTC_I2CPLD
  This device provides input and output GPIOs through an I2C
  interface to one or more sub-chips.
 
+config MFD_INTEL_QUARK_I2C_GPIO
+   tristate "Intel Quark MFD I2C GPIO"
+   depends on PCI && X86
+   depends on COMMON_CLK
+   select MFD_CORE
+   help
+ This MFD provides support for I2C and GPIO that exist only
+ in a single PCI device. It splits the 2 IO devices to
+ their respective IO driver.
+ The GPIO exports a total amount of 8 interrupt-capable GPIOs.
+
 config LPC_ICH
tristate "Intel ICH LPC"
depends on PCI
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 8a28dc9..d42652d 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -133,6 +133,7 @@ obj-$(CONFIG_AB8500_CORE)   += ab8500-core.o 
ab8500-sysctrl.o
 obj-$(CONFIG_MFD_TIMBERDALE)+= timberdale.o
 obj-$(CONFIG_PMIC_ADP5520) += adp5520.o
 obj-$(CONFIG_MFD_KEMPLD)   += kempld-core.o
+obj-$(CONFIG_MFD_INTEL_QUARK_I2C_GPIO) += intel_quark_i2c_gpio.o
 obj-$(CONFIG_LPC_SCH)  += lpc_sch.o
 obj-$(CONFIG_LPC_ICH)  += lpc_ich.o
 obj-$(CONFIG_MFD_RDC321X)  += rdc321x-southbridge.o
diff --git a/drivers/mfd/intel_quark_i2c_gpio.c 
b/drivers/mfd/intel_quark_i2c_gpio.c
new file mode 100644
index 000..eed95da
--- /dev/null
+++ b/drivers/mfd/intel_quark_i2c_gpio.c
@@ -0,0 +1,298 @@
+/*
+ * Intel Quark MFD PCI driver for I2C & GPIO
+ *
+ * Copyright(c) 2014 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * Intel Quark PCI device for I2C and GPIO controller sharing the same
+ * PCI function. This PCI driver will split the 2 devices into their
+ * respective drivers.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* PCI BAR for register base address */
+#define MFD_I2C_BAR0
+#define MFD_GPIO_BAR   1
+
+/* The base GPIO number under GPIOLIB framework */
+#define INTEL_QUARK_MFD_GPIO_BASE  8
+
+/* The default number of South-Cluster GPIO on Quark. */
+#define INTEL_QUARK_MFD_NGPIO  8
+
+/* The DesignWare GPIO ports on Quark. */
+#define INTEL_QUARK_GPIO_NPORTS1
+
+#define INTEL_QUARK_IORES_MEM  0
+#define INTEL_QUARK_IORES_IRQ  1
+
+#define INTEL_QUARK_I2C_CONTROLLER_CLK "i2c_designware.0"
+
+/* The Quark I2C controller source clock */
+#define INTEL_QUARK_I2C_CLK_HZ 3300
+
+#define INTEL_QUARK_I2C_NCLK   1
+
+struct clk *intel_quark_i2c_clk;
+struct clk_lookup *intel_quark_i2c_clk_lookups;
+
+struct i2c_mode_info {
+   const char *name;
+   unsigned int i2c_scl_freq;
+};
+
+static const struct i2c_mode_info platform_i2c_mode_info[] = {
+   {
+   .name = "Galileo",
+   .i2c_scl_freq = 10,
+   },
+   {
+   .name = "GalileoGen2",
+   .i2c_scl_freq = 40,
+   },
+};
+
+static struct resource intel_quark_i2c_res[] = {
+   [INTEL_QUARK_IORES_MEM] = {
+   .flags = IORESOURCE_MEM,
+   },
+   [INTEL_QUARK_IORES_IRQ] = {
+   .flags = IORESOURCE_IRQ,
+   },
+};
+
+static struct resource intel_quark_gpio_res[] = {
+   [INTEL_QUARK_IORES_MEM] = {
+   .flags = IORESOURCE_MEM,
+   },
+};
+
+static struct mfd_cell intel_quark_mfd_cells[] = {
+   {
+   .id = MFD_I2C_BAR,
+   .name = "i2c_designware",
+   .num_resources = ARRAY_SIZE(intel_quark_i2c_res),
+   .resources = intel_quark_i2c_res,
+   .ignore_resource_conflicts = true,
+   },
+   {
+   .id = MFD_GPIO_BAR,
+   .name = "gpio-dwapb",
+   .num_resources = A

[PATCH v2 0/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

2014-11-11 Thread Raymond Tan
From: "Tan, Raymond" 

Hi,
This patch is for enabling support of Intel Quark X1000 I2C controller and
GPIO controller. In Quark X1000, the platform exports a single PCI device
with both I2C and GPIO functions.

This MFD driver will split the 2 devices for their respective drivers.

---
Changes in v2:
* Fix possible memory leak

Raymond Tan (1):
  mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

 drivers/mfd/Kconfig|   11 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/intel_quark_i2c_gpio.c |  298 
 3 files changed, 310 insertions(+)
 create mode 100644 drivers/mfd/intel_quark_i2c_gpio.c

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 0/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

2014-11-11 Thread Raymond Tan
From: Tan, Raymond raymond@intel.com

Hi,
This patch is for enabling support of Intel Quark X1000 I2C controller and
GPIO controller. In Quark X1000, the platform exports a single PCI device
with both I2C and GPIO functions.

This MFD driver will split the 2 devices for their respective drivers.

---
Changes in v2:
* Fix possible memory leak

Raymond Tan (1):
  mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

 drivers/mfd/Kconfig|   11 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/intel_quark_i2c_gpio.c |  298 
 3 files changed, 310 insertions(+)
 create mode 100644 drivers/mfd/intel_quark_i2c_gpio.c

-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

2014-11-11 Thread Raymond Tan
In Quark X1000, there's a single PCI device that provides both
an I2C controller and a GPIO controller. This MFD driver will
split the 2 devices for their respective drivers.

This patch is based on Josef Ahmad's initial work for Quark enabling.

Reviewed-by: Andy Shevchenko andriy.shevche...@linux.intel.com
Signed-off-by: Weike Chen alvin.c...@intel.com
Signed-off-by: Raymond Tan raymond@intel.com
---
 drivers/mfd/Kconfig|   11 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/intel_quark_i2c_gpio.c |  298 
 3 files changed, 310 insertions(+)
 create mode 100644 drivers/mfd/intel_quark_i2c_gpio.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index b7c74a7..d01d042 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -219,6 +219,17 @@ config HTC_I2CPLD
  This device provides input and output GPIOs through an I2C
  interface to one or more sub-chips.
 
+config MFD_INTEL_QUARK_I2C_GPIO
+   tristate Intel Quark MFD I2C GPIO
+   depends on PCI  X86
+   depends on COMMON_CLK
+   select MFD_CORE
+   help
+ This MFD provides support for I2C and GPIO that exist only
+ in a single PCI device. It splits the 2 IO devices to
+ their respective IO driver.
+ The GPIO exports a total amount of 8 interrupt-capable GPIOs.
+
 config LPC_ICH
tristate Intel ICH LPC
depends on PCI
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 8a28dc9..d42652d 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -133,6 +133,7 @@ obj-$(CONFIG_AB8500_CORE)   += ab8500-core.o 
ab8500-sysctrl.o
 obj-$(CONFIG_MFD_TIMBERDALE)+= timberdale.o
 obj-$(CONFIG_PMIC_ADP5520) += adp5520.o
 obj-$(CONFIG_MFD_KEMPLD)   += kempld-core.o
+obj-$(CONFIG_MFD_INTEL_QUARK_I2C_GPIO) += intel_quark_i2c_gpio.o
 obj-$(CONFIG_LPC_SCH)  += lpc_sch.o
 obj-$(CONFIG_LPC_ICH)  += lpc_ich.o
 obj-$(CONFIG_MFD_RDC321X)  += rdc321x-southbridge.o
diff --git a/drivers/mfd/intel_quark_i2c_gpio.c 
b/drivers/mfd/intel_quark_i2c_gpio.c
new file mode 100644
index 000..eed95da
--- /dev/null
+++ b/drivers/mfd/intel_quark_i2c_gpio.c
@@ -0,0 +1,298 @@
+/*
+ * Intel Quark MFD PCI driver for I2C  GPIO
+ *
+ * Copyright(c) 2014 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * Intel Quark PCI device for I2C and GPIO controller sharing the same
+ * PCI function. This PCI driver will split the 2 devices into their
+ * respective drivers.
+ */
+
+#include linux/kernel.h
+#include linux/module.h
+#include linux/pci.h
+#include linux/mfd/core.h
+#include linux/clkdev.h
+#include linux/clk-provider.h
+#include linux/dmi.h
+#include linux/platform_data/gpio-dwapb.h
+#include linux/platform_data/i2c-designware.h
+
+/* PCI BAR for register base address */
+#define MFD_I2C_BAR0
+#define MFD_GPIO_BAR   1
+
+/* The base GPIO number under GPIOLIB framework */
+#define INTEL_QUARK_MFD_GPIO_BASE  8
+
+/* The default number of South-Cluster GPIO on Quark. */
+#define INTEL_QUARK_MFD_NGPIO  8
+
+/* The DesignWare GPIO ports on Quark. */
+#define INTEL_QUARK_GPIO_NPORTS1
+
+#define INTEL_QUARK_IORES_MEM  0
+#define INTEL_QUARK_IORES_IRQ  1
+
+#define INTEL_QUARK_I2C_CONTROLLER_CLK i2c_designware.0
+
+/* The Quark I2C controller source clock */
+#define INTEL_QUARK_I2C_CLK_HZ 3300
+
+#define INTEL_QUARK_I2C_NCLK   1
+
+struct clk *intel_quark_i2c_clk;
+struct clk_lookup *intel_quark_i2c_clk_lookups;
+
+struct i2c_mode_info {
+   const char *name;
+   unsigned int i2c_scl_freq;
+};
+
+static const struct i2c_mode_info platform_i2c_mode_info[] = {
+   {
+   .name = Galileo,
+   .i2c_scl_freq = 10,
+   },
+   {
+   .name = GalileoGen2,
+   .i2c_scl_freq = 40,
+   },
+};
+
+static struct resource intel_quark_i2c_res[] = {
+   [INTEL_QUARK_IORES_MEM] = {
+   .flags = IORESOURCE_MEM,
+   },
+   [INTEL_QUARK_IORES_IRQ] = {
+   .flags = IORESOURCE_IRQ,
+   },
+};
+
+static struct resource intel_quark_gpio_res[] = {
+   [INTEL_QUARK_IORES_MEM] = {
+   .flags = IORESOURCE_MEM,
+   },
+};
+
+static struct mfd_cell intel_quark_mfd_cells[] = {
+   {
+   .id = MFD_I2C_BAR,
+   .name = i2c_designware,
+   .num_resources = ARRAY_SIZE(intel_quark_i2c_res),
+   .resources = intel_quark_i2c_res,
+   .ignore_resource_conflicts

[PATCH 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

2014-11-02 Thread Raymond Tan
In Quark X1000, there's a single PCI device that provides both
an I2C controller and a GPIO controller. This MFD driver will
split the 2 devices for their respective drivers.

This patch is based on Josef Ahmad's initial work for Quark enabling.

Signed-off-by: Weike Chen 
Signed-off-by: Raymond Tan 
---
 drivers/mfd/Kconfig|   11 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/intel_quark_i2c_gpio.c |  298 
 3 files changed, 310 insertions(+)
 create mode 100644 drivers/mfd/intel_quark_i2c_gpio.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index b7c74a7..d01d042 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -219,6 +219,17 @@ config HTC_I2CPLD
  This device provides input and output GPIOs through an I2C
  interface to one or more sub-chips.
 
+config MFD_INTEL_QUARK_I2C_GPIO
+   tristate "Intel Quark MFD I2C GPIO"
+   depends on PCI && X86
+   depends on COMMON_CLK
+   select MFD_CORE
+   help
+ This MFD provides support for I2C and GPIO that exist only
+ in a single PCI device. It splits the 2 IO devices to
+ their respective IO driver.
+ The GPIO exports a total amount of 8 interrupt-capable GPIOs.
+
 config LPC_ICH
tristate "Intel ICH LPC"
depends on PCI
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 8a28dc9..d42652d 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -133,6 +133,7 @@ obj-$(CONFIG_AB8500_CORE)   += ab8500-core.o 
ab8500-sysctrl.o
 obj-$(CONFIG_MFD_TIMBERDALE)+= timberdale.o
 obj-$(CONFIG_PMIC_ADP5520) += adp5520.o
 obj-$(CONFIG_MFD_KEMPLD)   += kempld-core.o
+obj-$(CONFIG_MFD_INTEL_QUARK_I2C_GPIO) += intel_quark_i2c_gpio.o
 obj-$(CONFIG_LPC_SCH)  += lpc_sch.o
 obj-$(CONFIG_LPC_ICH)  += lpc_ich.o
 obj-$(CONFIG_MFD_RDC321X)  += rdc321x-southbridge.o
diff --git a/drivers/mfd/intel_quark_i2c_gpio.c 
b/drivers/mfd/intel_quark_i2c_gpio.c
new file mode 100644
index 000..e3cd6fb
--- /dev/null
+++ b/drivers/mfd/intel_quark_i2c_gpio.c
@@ -0,0 +1,298 @@
+/*
+ * Intel Quark MFD PCI driver for I2C & GPIO
+ *
+ * Copyright(c) 2014 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * Intel Quark PCI device for I2C and GPIO controller sharing the same
+ * PCI function. This PCI driver will split the 2 devices into their
+ * respective drivers.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* PCI BAR for register base address */
+#define MFD_I2C_BAR0
+#define MFD_GPIO_BAR   1
+
+/* The base GPIO number under GPIOLIB framework */
+#define INTEL_QUARK_MFD_GPIO_BASE  8
+
+/* The default number of South-Cluster GPIO on Quark. */
+#define INTEL_QUARK_MFD_NGPIO  8
+
+/* The DesignWare GPIO ports on Quark. */
+#define INTEL_QUARK_GPIO_NPORTS1
+
+#define INTEL_QUARK_IORES_MEM  0
+#define INTEL_QUARK_IORES_IRQ  1
+
+#define INTEL_QUARK_I2C_CONTROLLER_CLK "i2c_designware.0"
+
+/* The Quark I2C controller source clock */
+#define INTEL_QUARK_I2C_CLK_HZ 3300
+
+#define INTEL_QUARK_I2C_NCLK   1
+
+struct clk *intel_quark_i2c_clk;
+struct clk_lookup *intel_quark_i2c_clk_lookups;
+
+struct i2c_mode_info {
+   const char *name;
+   unsigned int i2c_scl_freq;
+};
+
+static const struct i2c_mode_info platform_i2c_mode_info[] = {
+   {
+   .name = "Galileo",
+   .i2c_scl_freq = 10,
+   },
+   {
+   .name = "GalileoGen2",
+   .i2c_scl_freq = 40,
+   },
+};
+
+static struct resource intel_quark_i2c_res[] = {
+   [INTEL_QUARK_IORES_MEM] = {
+   .flags = IORESOURCE_MEM,
+   },
+   [INTEL_QUARK_IORES_IRQ] = {
+   .flags = IORESOURCE_IRQ,
+   },
+};
+
+static struct resource intel_quark_gpio_res[] = {
+   [INTEL_QUARK_IORES_MEM] = {
+   .flags = IORESOURCE_MEM,
+   },
+};
+
+static struct mfd_cell intel_quark_mfd_cells[] = {
+   {
+   .id = MFD_I2C_BAR,
+   .name = "i2c_designware",
+   .num_resources = ARRAY_SIZE(intel_quark_i2c_res),
+   .resources = intel_quark_i2c_res,
+   .ignore_resource_conflicts = true,
+   },
+   {
+   .id = MFD_GPIO_BAR,
+   .name = "gpio-dwapb",
+   .num_resources = A

[PATCH 0/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

2014-11-02 Thread Raymond Tan
From: "Tan, Raymond" 

Hi,
This patch is for enabling support of Intel Quark X1000 I2C controller and
GPIO controller. In Quark X1000, the platform exports a single PCI device
with both I2C and GPIO functions.

This MFD driver will split the 2 devices for their respective drivers.

Raymond Tan (1):
  mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

 drivers/mfd/Kconfig|   11 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/intel_quark_i2c_gpio.c |  298 
 3 files changed, 310 insertions(+)
 create mode 100644 drivers/mfd/intel_quark_i2c_gpio.c

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

2014-11-02 Thread Raymond Tan
From: Tan, Raymond raymond@intel.com

Hi,
This patch is for enabling support of Intel Quark X1000 I2C controller and
GPIO controller. In Quark X1000, the platform exports a single PCI device
with both I2C and GPIO functions.

This MFD driver will split the 2 devices for their respective drivers.

Raymond Tan (1):
  mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

 drivers/mfd/Kconfig|   11 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/intel_quark_i2c_gpio.c |  298 
 3 files changed, 310 insertions(+)
 create mode 100644 drivers/mfd/intel_quark_i2c_gpio.c

-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver

2014-11-02 Thread Raymond Tan
In Quark X1000, there's a single PCI device that provides both
an I2C controller and a GPIO controller. This MFD driver will
split the 2 devices for their respective drivers.

This patch is based on Josef Ahmad's initial work for Quark enabling.

Signed-off-by: Weike Chen alvin.c...@intel.com
Signed-off-by: Raymond Tan raymond@intel.com
---
 drivers/mfd/Kconfig|   11 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/intel_quark_i2c_gpio.c |  298 
 3 files changed, 310 insertions(+)
 create mode 100644 drivers/mfd/intel_quark_i2c_gpio.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index b7c74a7..d01d042 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -219,6 +219,17 @@ config HTC_I2CPLD
  This device provides input and output GPIOs through an I2C
  interface to one or more sub-chips.
 
+config MFD_INTEL_QUARK_I2C_GPIO
+   tristate Intel Quark MFD I2C GPIO
+   depends on PCI  X86
+   depends on COMMON_CLK
+   select MFD_CORE
+   help
+ This MFD provides support for I2C and GPIO that exist only
+ in a single PCI device. It splits the 2 IO devices to
+ their respective IO driver.
+ The GPIO exports a total amount of 8 interrupt-capable GPIOs.
+
 config LPC_ICH
tristate Intel ICH LPC
depends on PCI
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 8a28dc9..d42652d 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -133,6 +133,7 @@ obj-$(CONFIG_AB8500_CORE)   += ab8500-core.o 
ab8500-sysctrl.o
 obj-$(CONFIG_MFD_TIMBERDALE)+= timberdale.o
 obj-$(CONFIG_PMIC_ADP5520) += adp5520.o
 obj-$(CONFIG_MFD_KEMPLD)   += kempld-core.o
+obj-$(CONFIG_MFD_INTEL_QUARK_I2C_GPIO) += intel_quark_i2c_gpio.o
 obj-$(CONFIG_LPC_SCH)  += lpc_sch.o
 obj-$(CONFIG_LPC_ICH)  += lpc_ich.o
 obj-$(CONFIG_MFD_RDC321X)  += rdc321x-southbridge.o
diff --git a/drivers/mfd/intel_quark_i2c_gpio.c 
b/drivers/mfd/intel_quark_i2c_gpio.c
new file mode 100644
index 000..e3cd6fb
--- /dev/null
+++ b/drivers/mfd/intel_quark_i2c_gpio.c
@@ -0,0 +1,298 @@
+/*
+ * Intel Quark MFD PCI driver for I2C  GPIO
+ *
+ * Copyright(c) 2014 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * Intel Quark PCI device for I2C and GPIO controller sharing the same
+ * PCI function. This PCI driver will split the 2 devices into their
+ * respective drivers.
+ */
+
+#include linux/kernel.h
+#include linux/module.h
+#include linux/pci.h
+#include linux/mfd/core.h
+#include linux/clkdev.h
+#include linux/clk-provider.h
+#include linux/dmi.h
+#include linux/platform_data/gpio-dwapb.h
+#include linux/platform_data/i2c-designware.h
+
+/* PCI BAR for register base address */
+#define MFD_I2C_BAR0
+#define MFD_GPIO_BAR   1
+
+/* The base GPIO number under GPIOLIB framework */
+#define INTEL_QUARK_MFD_GPIO_BASE  8
+
+/* The default number of South-Cluster GPIO on Quark. */
+#define INTEL_QUARK_MFD_NGPIO  8
+
+/* The DesignWare GPIO ports on Quark. */
+#define INTEL_QUARK_GPIO_NPORTS1
+
+#define INTEL_QUARK_IORES_MEM  0
+#define INTEL_QUARK_IORES_IRQ  1
+
+#define INTEL_QUARK_I2C_CONTROLLER_CLK i2c_designware.0
+
+/* The Quark I2C controller source clock */
+#define INTEL_QUARK_I2C_CLK_HZ 3300
+
+#define INTEL_QUARK_I2C_NCLK   1
+
+struct clk *intel_quark_i2c_clk;
+struct clk_lookup *intel_quark_i2c_clk_lookups;
+
+struct i2c_mode_info {
+   const char *name;
+   unsigned int i2c_scl_freq;
+};
+
+static const struct i2c_mode_info platform_i2c_mode_info[] = {
+   {
+   .name = Galileo,
+   .i2c_scl_freq = 10,
+   },
+   {
+   .name = GalileoGen2,
+   .i2c_scl_freq = 40,
+   },
+};
+
+static struct resource intel_quark_i2c_res[] = {
+   [INTEL_QUARK_IORES_MEM] = {
+   .flags = IORESOURCE_MEM,
+   },
+   [INTEL_QUARK_IORES_IRQ] = {
+   .flags = IORESOURCE_IRQ,
+   },
+};
+
+static struct resource intel_quark_gpio_res[] = {
+   [INTEL_QUARK_IORES_MEM] = {
+   .flags = IORESOURCE_MEM,
+   },
+};
+
+static struct mfd_cell intel_quark_mfd_cells[] = {
+   {
+   .id = MFD_I2C_BAR,
+   .name = i2c_designware,
+   .num_resources = ARRAY_SIZE(intel_quark_i2c_res),
+   .resources = intel_quark_i2c_res,
+   .ignore_resource_conflicts = true,
+   },
+   {
+   .id = MFD_GPIO_BAR

[PATCH 1/1] i2c: designware: add support of platform data to set I2C mode

2014-09-02 Thread Raymond Tan
From: "Tan, Raymond" 

Use the platform data to set the clk_freq when there is no DT configuration
available. The clk_freq in turn will determine the I2C speed mode.

In Quark, there is currently no other configuration mechanism other than
board files.

Signed-off-by: Raymond Tan 
Reviewed-by: Mika Westerberg 
Reviewed-by: Hock Leong Kweh 
---
 drivers/i2c/busses/i2c-designware-platdrv.c  |6 ++
 include/linux/platform_data/i2c-designware.h |   21 +
 2 files changed, 27 insertions(+)
 create mode 100644 include/linux/platform_data/i2c-designware.h

diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c 
b/drivers/i2c/busses/i2c-designware-platdrv.c
index b543fe1..ce3f779 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "i2c-designware-core.h"
 
 static struct i2c_algorithm i2c_dw_algo = {
@@ -121,6 +122,7 @@ static int dw_i2c_probe(struct platform_device *pdev)
struct dw_i2c_dev *dev;
struct i2c_adapter *adap;
struct resource *mem;
+   struct dw_i2c_platform_data *pdata;
int irq, r;
u32 clk_freq;
 
@@ -181,6 +183,10 @@ static int dw_i2c_probe(struct platform_device *pdev)
dev_err(>dev, "Only 100kHz and 400kHz supported");
return -EINVAL;
}
+   } else {
+   pdata = dev_get_platdata(>dev);
+   if (pdata)
+   clk_freq = pdata->i2c_scl_freq;
}
 
dev->functionality =
diff --git a/include/linux/platform_data/i2c-designware.h 
b/include/linux/platform_data/i2c-designware.h
new file mode 100644
index 000..7a61fb2
--- /dev/null
+++ b/include/linux/platform_data/i2c-designware.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright(c) 2014 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+#ifndef I2C_DESIGNWARE_H
+#define I2C_DESIGNWARE_H
+
+struct dw_i2c_platform_data {
+   unsigned int i2c_scl_freq;
+};
+
+#endif
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/1] i2c: designware: Add support for Intel Quark X1000

2014-09-02 Thread Raymond Tan
From: "Tan, Raymond" 

Hi,
This patch is for enabling support of Intel Quark X1000 i2c controller. The
Quark designware i2c controller is registered as a MFD device, and Quark
exports a single PCI device with both I2C and GPIO functions.

In Quark, there is currently no other configuration mechanism other than
board files to configure the I2C mode for the the controller.

This patch is built upon the changes made by Romain Baeriswyl, titled
[PATCH V3 2/2] i2c designware add support of I2C standard mode, at
https://lkml.org/lkml/2014/3/25/135

Tan, Raymond (1):
  i2c: designware: add support of platform data to set I2C mode

 drivers/i2c/busses/i2c-designware-platdrv.c  |6 ++
 include/linux/platform_data/i2c-designware.h |   21 +
 2 files changed, 27 insertions(+)
 create mode 100644 include/linux/platform_data/i2c-designware.h

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/1] i2c: designware: Add support for Intel Quark X1000

2014-09-02 Thread Raymond Tan
From: Tan, Raymond raymond@intel.com

Hi,
This patch is for enabling support of Intel Quark X1000 i2c controller. The
Quark designware i2c controller is registered as a MFD device, and Quark
exports a single PCI device with both I2C and GPIO functions.

In Quark, there is currently no other configuration mechanism other than
board files to configure the I2C mode for the the controller.

This patch is built upon the changes made by Romain Baeriswyl, titled
[PATCH V3 2/2] i2c designware add support of I2C standard mode, at
https://lkml.org/lkml/2014/3/25/135

Tan, Raymond (1):
  i2c: designware: add support of platform data to set I2C mode

 drivers/i2c/busses/i2c-designware-platdrv.c  |6 ++
 include/linux/platform_data/i2c-designware.h |   21 +
 2 files changed, 27 insertions(+)
 create mode 100644 include/linux/platform_data/i2c-designware.h

-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] i2c: designware: add support of platform data to set I2C mode

2014-09-02 Thread Raymond Tan
From: Tan, Raymond raymond@intel.com

Use the platform data to set the clk_freq when there is no DT configuration
available. The clk_freq in turn will determine the I2C speed mode.

In Quark, there is currently no other configuration mechanism other than
board files.

Signed-off-by: Raymond Tan raymond@intel.com
Reviewed-by: Mika Westerberg mika.westerb...@linux.intel.com
Reviewed-by: Hock Leong Kweh hock.leong.k...@intel.com
---
 drivers/i2c/busses/i2c-designware-platdrv.c  |6 ++
 include/linux/platform_data/i2c-designware.h |   21 +
 2 files changed, 27 insertions(+)
 create mode 100644 include/linux/platform_data/i2c-designware.h

diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c 
b/drivers/i2c/busses/i2c-designware-platdrv.c
index b543fe1..ce3f779 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -41,6 +41,7 @@
 #include linux/io.h
 #include linux/slab.h
 #include linux/acpi.h
+#include linux/platform_data/i2c-designware.h
 #include i2c-designware-core.h
 
 static struct i2c_algorithm i2c_dw_algo = {
@@ -121,6 +122,7 @@ static int dw_i2c_probe(struct platform_device *pdev)
struct dw_i2c_dev *dev;
struct i2c_adapter *adap;
struct resource *mem;
+   struct dw_i2c_platform_data *pdata;
int irq, r;
u32 clk_freq;
 
@@ -181,6 +183,10 @@ static int dw_i2c_probe(struct platform_device *pdev)
dev_err(pdev-dev, Only 100kHz and 400kHz supported);
return -EINVAL;
}
+   } else {
+   pdata = dev_get_platdata(pdev-dev);
+   if (pdata)
+   clk_freq = pdata-i2c_scl_freq;
}
 
dev-functionality =
diff --git a/include/linux/platform_data/i2c-designware.h 
b/include/linux/platform_data/i2c-designware.h
new file mode 100644
index 000..7a61fb2
--- /dev/null
+++ b/include/linux/platform_data/i2c-designware.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright(c) 2014 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+#ifndef I2C_DESIGNWARE_H
+#define I2C_DESIGNWARE_H
+
+struct dw_i2c_platform_data {
+   unsigned int i2c_scl_freq;
+};
+
+#endif
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/