RE: [PATCH 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver
Hi Andy, Thanks for your review. I've made the changes and will resend the patch v2. Warm Regards, Raymond Tan Software Engineer Malaysia IT Flex Services INET: 8-253-0075 Flex Website: http://flexservices.intel.com > -Original Message- > From: Andy Shevchenko [mailto:andriy.shevche...@linux.intel.com] > Sent: Monday, November 03, 2014 5:12 PM > To: Tan, Raymond > Cc: Lee Jones; Samuel Ortiz; linux-kernel@vger.kernel.org; Chen, Alvin > Subject: Re: [PATCH 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 > I2C-GPIO MFD Driver > > On Mon, 2014-11-03 at 15:39 +0800, Raymond Tan wrote: > > 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. > > Few comments below. > > After addressing take my > 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..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. */ >
Re: [PATCH 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver
On 04/11/14 00:51, Chen, Alvin wrote: -Original Message- From: Chen, Alvin Sent: Tuesday, November 4, 2014 8:46 AM To: 'Bryan O'Donoghue'; Tan, Raymond; Lee Jones; Samuel Ortiz Cc: linux-kernel@vger.kernel.org; Shevchenko, Andriy Subject: RE: [PATCH 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver On 03/11/14 07:39, Raymond Tan wrote: + pdata->properties->irq= pdev->irq; + pdata->properties->irq_shared = true; OK I see it. Thanks. My question is. How extensively have edge triggered interrupts been tested on the GPIO block ? The BSP reference code is quite explicit about not missing edge interrupts. Have you tested GPIO input in edge mode ? We indeed test edge mode. Now all are moved to gpio-dwapb module which has been accepted by maintainer. OK then good enough for me. -- 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/
Re: [PATCH 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver
On Tue, 04 Nov 2014, Shevchenko, Andriy wrote: > On Mon, 2014-11-03 at 09:43 +, Bryan O'Donoghue wrote: > > On 03/11/14 07:39, Raymond Tan wrote: > > > 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. > > > > Hi Raymond. > > > > I see support for interrupts on GPIO input has been dropped. In fact it > > doesn't appear you have any IRQ support here at all. > > > > Could you detail the reasons why ? > > In general the MFD drivers are just dispatchers which split an original > compound device by its slices. +1 That's a really nice way of putting it. -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- 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/
Re: [PATCH 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver
On Mon, 2014-11-03 at 09:43 +, Bryan O'Donoghue wrote: > On 03/11/14 07:39, Raymond Tan wrote: > > 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. > > Hi Raymond. > > I see support for interrupts on GPIO input has been dropped. In fact it > doesn't appear you have any IRQ support here at all. > > Could you detail the reasons why ? In general the MFD drivers are just dispatchers which split an original compound device by its slices. -- Andy Shevchenko Intel Finland Oy - Intel Finland Oy Registered Address: PL 281, 00181 Helsinki Business Identity Code: 0357606 - 4 Domiciled in Helsinki This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
RE: [PATCH 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver
> -Original Message- > From: Chen, Alvin > Sent: Tuesday, November 4, 2014 8:46 AM > To: 'Bryan O'Donoghue'; Tan, Raymond; Lee Jones; Samuel Ortiz > Cc: linux-kernel@vger.kernel.org; Shevchenko, Andriy > Subject: RE: [PATCH 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 > I2C-GPIO MFD Driver > > > > > On 03/11/14 07:39, Raymond Tan wrote: > > > + pdata->properties->irq = pdev->irq; > > > + pdata->properties->irq_shared = true; > > > > OK I see it. > > > > Thanks. > > > > My question is. How extensively have edge triggered interrupts been > > tested on the GPIO block ? > > > > The BSP reference code is quite explicit about not missing edge interrupts. > > > > Have you tested GPIO input in edge mode ? > We indeed test edge mode. Now all are moved to gpio-dwapb module which > has been accepted by maintainer. > The BSP code doesn't meet the requirement of upstream, so we totally > re-implement this feature in gpio-dwapb. > This patch only passes the necessary parameters and registers the platform > devices. > > Just double check, the support of Quark designware GPIO has been in 3.18-rc2. -- 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/
RE: [PATCH 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver
> > On 03/11/14 07:39, Raymond Tan wrote: > > + pdata->properties->irq = pdev->irq; > > + pdata->properties->irq_shared = true; > > OK I see it. > > Thanks. > > My question is. How extensively have edge triggered interrupts been tested on > the GPIO block ? > > The BSP reference code is quite explicit about not missing edge interrupts. > > Have you tested GPIO input in edge mode ? We indeed test edge mode. Now all are moved to gpio-dwapb module which has been accepted by maintainer. The BSP code doesn't meet the requirement of upstream, so we totally re-implement this feature in gpio-dwapb. This patch only passes the necessary parameters and registers the platform devices. > > +irqreturn_t intel_qrk_gpio_isr(int irq, void *dev_id) { > + irqreturn_t ret = IRQ_NONE; > + u32 pending = 0, gpio = 0; > + void __iomem *reg_pending = reg_base + PORTA_INT_STATUS; > + void __iomem *reg_eoi = reg_base + PORTA_INT_EOI; > + > + /* Which pin (if any) triggered the interrupt */ > + while ((pending = ioread32(reg_pending))) { > + /* > + * Acknowledge all the asserted GPIO interrupt lines before > + * serving them, so that we don't lose an edge. > + * This has only effect on edge-triggered interrupts. > + */ > + iowrite32(pending, reg_eoi); > + > + /* Serve each asserted interrupt */ > + do { > + gpio = __ffs(pending); > + generic_handle_irq( > + gpio_to_irq(INTEL_QRK_GIP_GPIO_BASE + gpio)); > + pending &= ~BIT(gpio); > + ret = IRQ_HANDLED; > + } while(pending); > + } > + > + return ret; > +} -- 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/
Re: [PATCH 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver
On Mon, 03 Nov 2014, Andy Shevchenko wrote: > On Mon, 2014-11-03 at 15:39 +0800, Raymond Tan wrote: > > 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. > > Few comments below. > > After addressing take my > Reviewed-by: Andy Shevchenko [...] > > +static const struct i2c_mode_info platform_i2c_mode_info[] = { > > + { > > + .name = "Galileo", > > + .i2c_scl_freq = 10, > > + }, > > + { > > + .name = "GalileoGen2", > > + .i2c_scl_freq = 40, > > + }, > > You can decrease indentation level if you want to by using > > = {{ > }, { > }}; > > Though I don't know if Lee likes it :-) No, please don't do that. [...] -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- 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/
Re: [PATCH 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver
On 03/11/14 07:39, Raymond Tan wrote: + pdata->properties->irq= pdev->irq; + pdata->properties->irq_shared = true; OK I see it. Thanks. My question is. How extensively have edge triggered interrupts been tested on the GPIO block ? The BSP reference code is quite explicit about not missing edge interrupts. Have you tested GPIO input in edge mode ? +irqreturn_t intel_qrk_gpio_isr(int irq, void *dev_id) +{ + irqreturn_t ret = IRQ_NONE; + u32 pending = 0, gpio = 0; + void __iomem *reg_pending = reg_base + PORTA_INT_STATUS; + void __iomem *reg_eoi = reg_base + PORTA_INT_EOI; + + /* Which pin (if any) triggered the interrupt */ + while ((pending = ioread32(reg_pending))) { + /* +* Acknowledge all the asserted GPIO interrupt lines before +* serving them, so that we don't lose an edge. +* This has only effect on edge-triggered interrupts. +*/ + iowrite32(pending, reg_eoi); + + /* Serve each asserted interrupt */ + do { + gpio = __ffs(pending); + generic_handle_irq( + gpio_to_irq(INTEL_QRK_GIP_GPIO_BASE + gpio)); + pending &= ~BIT(gpio); + ret = IRQ_HANDLED; + } while(pending); + } + + return ret; +} -- 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/
Re: [PATCH 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver
On 03/11/14 07:39, Raymond Tan wrote: 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. Hi Raymond. I see support for interrupts on GPIO input has been dropped. In fact it doesn't appear you have any IRQ support here at all. Could you detail the reasons why ? Bryan -- 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/
Re: [PATCH 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver
On Mon, 2014-11-03 at 15:39 +0800, Raymond Tan wrote: > 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. Few comments below. After addressing take my 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..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_BAR 0 > +#define MFD_GPIO_BAR 1 > + > +/* The base GPIO number under GPIOLIB framework */ > +#define INTEL_QUARK_MFD_GPIO_BASE8 > + > +/* The default number of South-Cluster GPIO on Quark. */ > +#define INTEL_QUARK_MFD_NGPIO8 > + > +/* The DesignWare GPIO ports on Quark. */ > +#define INTEL_QUARK_GPIO_NPORTS 1 > + > +#define INTEL_QUARK_IORES_MEM0 > +#define INTEL_QUARK_IORES_IRQ1 > + > +#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, > + }, You can decrease indentation level if you want to by using = {{ }, { }}; Though I don't know if Lee likes it :-) At least you may use }, { at one line I think. > +}; > + > +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 stru
[PATCH 1/1] mfd: intel_quark_i2c_gpio: Add Intel Quark X1000 I2C-GPIO MFD Driver
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 = ARRAY_SIZE(intel_quark_gpio_res), + .resources = intel_quark_gpio_res, + .ignore_resource_conflict