Re: [PATCH v5 3/3] gpio: Add support for Intel Crystal Cove PMIC
On Tue, 03 Jun 2014, Zhu, Lejun wrote: > Devices based on Intel SoC products such as Baytrail have a Power > Management IC. In the PMIC there are subsystems for voltage regulation, > A/D conversion, GPIO and PWMs. The PMIC in Baytrail-T platform is > called Crystal Cove. > > This patch adds support for the GPIO function in Crystal Cove. > > Signed-off-by: Yang, Bin > Signed-off-by: Zhu, Lejun > Reviewed-by: Mika Westerberg > Reviewed-by: Alexandre Courbot > Reviewed-by: Linus Walleij > --- > v5: > - Fix the order of doing gpiochip_add() and gpiochip_irqchip_add(). > - Add it to this patch set, to merge it along with the MFD changes. > --- > drivers/gpio/Kconfig| 13 ++ > drivers/gpio/Makefile | 1 + > drivers/gpio/gpio-crystalcove.c | 379 > > 3 files changed, 393 insertions(+) > create mode 100644 drivers/gpio/gpio-crystalcove.c Applied, thanks. I will send a pull-request out to GPIO momentarily. > diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig > index a86c49a..fed08d9d 100644 > --- a/drivers/gpio/Kconfig > +++ b/drivers/gpio/Kconfig > @@ -440,6 +440,19 @@ config GPIO_ARIZONA > help > Support for GPIOs on Wolfson Arizona class devices. > > +config GPIO_CRYSTAL_COVE > + tristate "GPIO support for Crystal Cove PMIC" > + depends on INTEL_SOC_PMIC > + select GPIOLIB_IRQCHIP > + help > + Support for GPIO pins on Crystal Cove PMIC. > + > + Say Yes if you have a Intel SoC based tablet with Crystal Cove PMIC > + inside. > + > + This driver can also be built as a module. If so, the module will be > + called gpio-crystalcove. > + > config GPIO_LP3943 > tristate "TI/National Semiconductor LP3943 GPIO expander" > depends on MFD_LP3943 > diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile > index 6309aff..e6cd935 100644 > --- a/drivers/gpio/Makefile > +++ b/drivers/gpio/Makefile > @@ -20,6 +20,7 @@ obj-$(CONFIG_GPIO_BCM_KONA) += gpio-bcm-kona.o > obj-$(CONFIG_GPIO_BT8XX) += gpio-bt8xx.o > obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o > obj-$(CONFIG_GPIO_CS5535)+= gpio-cs5535.o > +obj-$(CONFIG_GPIO_CRYSTAL_COVE) += gpio-crystalcove.o > obj-$(CONFIG_GPIO_DA9052)+= gpio-da9052.o > obj-$(CONFIG_GPIO_DA9055)+= gpio-da9055.o > obj-$(CONFIG_GPIO_DAVINCI) += gpio-davinci.o > diff --git a/drivers/gpio/gpio-crystalcove.c b/drivers/gpio/gpio-crystalcove.c > new file mode 100644 > index 000..5a98499 > --- /dev/null > +++ b/drivers/gpio/gpio-crystalcove.c > @@ -0,0 +1,379 @@ > +/* > + * gpio-crystalcove.c - Intel Crystal Cove GPIO Driver > + * > + * Copyright (C) 2012, 2014 Intel Corporation. All rights reserved. > + * > + * 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. > + * > + * This program is distributed in the hope that 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. > + * > + * Author: Yang, Bin > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define CRYSTALCOVE_GPIO_NUM 16 > + > +#define UPDATE_IRQ_TYPE BIT(0) > +#define UPDATE_IRQ_MASK BIT(1) > + > +#define GPIO0IRQ 0x0b > +#define GPIO1IRQ 0x0c > +#define MGPIO0IRQS0 0x19 > +#define MGPIO1IRQS0 0x1a > +#define MGPIO0IRQSX 0x1b > +#define MGPIO1IRQSX 0x1c > +#define GPIO0P0CTLO 0x2b > +#define GPIO0P0CTLI 0x33 > +#define GPIO1P0CTLO 0x3b > +#define GPIO1P0CTLI 0x43 > + > +#define CTLI_INTCNT_DIS (0) > +#define CTLI_INTCNT_NE (1 << 1) > +#define CTLI_INTCNT_PE (2 << 1) > +#define CTLI_INTCNT_BE (3 << 1) > + > +#define CTLO_DIR_IN (0) > +#define CTLO_DIR_OUT (1 << 5) > + > +#define CTLO_DRV_CMOS(0) > +#define CTLO_DRV_OD (1 << 4) > + > +#define CTLO_DRV_REN (1 << 3) > + > +#define CTLO_RVAL_2KDW (0) > +#define CTLO_RVAL_2KUP (1 << 1) > +#define CTLO_RVAL_50KDW (2 << 1) > +#define CTLO_RVAL_50KUP (3 << 1) > + > +#define CTLO_INPUT_SET (CTLO_DRV_CMOS | CTLO_DRV_REN | CTLO_RVAL_2KUP) > +#define CTLO_OUTPUT_SET (CTLO_DIR_OUT | CTLO_INPUT_SET) > + > +enum ctrl_register { > + CTRL_IN, > + CTRL_OUT, > +}; > + > +/** > + * struct crystalcove_gpio - Crystal Cove GPIO controller > + * @buslock: for bus lock/sync and unlock. > + * @chip: the abstract gpio_chip structure. > + * @regmap: the regmap from the parent device. > + * @update: pending IRQ setting update, to be written to the chip upon > unlock. > + * @intcnt_value: the Interrupt
Re: [PATCH v5 3/3] gpio: Add support for Intel Crystal Cove PMIC
On Tue, 03 Jun 2014, Zhu, Lejun wrote: Devices based on Intel SoC products such as Baytrail have a Power Management IC. In the PMIC there are subsystems for voltage regulation, A/D conversion, GPIO and PWMs. The PMIC in Baytrail-T platform is called Crystal Cove. This patch adds support for the GPIO function in Crystal Cove. Signed-off-by: Yang, Bin bin.y...@intel.com Signed-off-by: Zhu, Lejun lejun@linux.intel.com Reviewed-by: Mika Westerberg mika.westerb...@linux.intel.com Reviewed-by: Alexandre Courbot acour...@nvidia.com Reviewed-by: Linus Walleij linus.wall...@linaro.org --- v5: - Fix the order of doing gpiochip_add() and gpiochip_irqchip_add(). - Add it to this patch set, to merge it along with the MFD changes. --- drivers/gpio/Kconfig| 13 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-crystalcove.c | 379 3 files changed, 393 insertions(+) create mode 100644 drivers/gpio/gpio-crystalcove.c Applied, thanks. I will send a pull-request out to GPIO momentarily. diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index a86c49a..fed08d9d 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -440,6 +440,19 @@ config GPIO_ARIZONA help Support for GPIOs on Wolfson Arizona class devices. +config GPIO_CRYSTAL_COVE + tristate GPIO support for Crystal Cove PMIC + depends on INTEL_SOC_PMIC + select GPIOLIB_IRQCHIP + help + Support for GPIO pins on Crystal Cove PMIC. + + Say Yes if you have a Intel SoC based tablet with Crystal Cove PMIC + inside. + + This driver can also be built as a module. If so, the module will be + called gpio-crystalcove. + config GPIO_LP3943 tristate TI/National Semiconductor LP3943 GPIO expander depends on MFD_LP3943 diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 6309aff..e6cd935 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -20,6 +20,7 @@ obj-$(CONFIG_GPIO_BCM_KONA) += gpio-bcm-kona.o obj-$(CONFIG_GPIO_BT8XX) += gpio-bt8xx.o obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o obj-$(CONFIG_GPIO_CS5535)+= gpio-cs5535.o +obj-$(CONFIG_GPIO_CRYSTAL_COVE) += gpio-crystalcove.o obj-$(CONFIG_GPIO_DA9052)+= gpio-da9052.o obj-$(CONFIG_GPIO_DA9055)+= gpio-da9055.o obj-$(CONFIG_GPIO_DAVINCI) += gpio-davinci.o diff --git a/drivers/gpio/gpio-crystalcove.c b/drivers/gpio/gpio-crystalcove.c new file mode 100644 index 000..5a98499 --- /dev/null +++ b/drivers/gpio/gpio-crystalcove.c @@ -0,0 +1,379 @@ +/* + * gpio-crystalcove.c - Intel Crystal Cove GPIO Driver + * + * Copyright (C) 2012, 2014 Intel Corporation. All rights reserved. + * + * 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. + * + * This program is distributed in the hope that 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. + * + * Author: Yang, Bin bin.y...@intel.com + */ + +#include linux/interrupt.h +#include linux/platform_device.h +#include linux/gpio.h +#include linux/bitops.h +#include linux/regmap.h +#include linux/mfd/intel_soc_pmic.h + +#define CRYSTALCOVE_GPIO_NUM 16 + +#define UPDATE_IRQ_TYPE BIT(0) +#define UPDATE_IRQ_MASK BIT(1) + +#define GPIO0IRQ 0x0b +#define GPIO1IRQ 0x0c +#define MGPIO0IRQS0 0x19 +#define MGPIO1IRQS0 0x1a +#define MGPIO0IRQSX 0x1b +#define MGPIO1IRQSX 0x1c +#define GPIO0P0CTLO 0x2b +#define GPIO0P0CTLI 0x33 +#define GPIO1P0CTLO 0x3b +#define GPIO1P0CTLI 0x43 + +#define CTLI_INTCNT_DIS (0) +#define CTLI_INTCNT_NE (1 1) +#define CTLI_INTCNT_PE (2 1) +#define CTLI_INTCNT_BE (3 1) + +#define CTLO_DIR_IN (0) +#define CTLO_DIR_OUT (1 5) + +#define CTLO_DRV_CMOS(0) +#define CTLO_DRV_OD (1 4) + +#define CTLO_DRV_REN (1 3) + +#define CTLO_RVAL_2KDW (0) +#define CTLO_RVAL_2KUP (1 1) +#define CTLO_RVAL_50KDW (2 1) +#define CTLO_RVAL_50KUP (3 1) + +#define CTLO_INPUT_SET (CTLO_DRV_CMOS | CTLO_DRV_REN | CTLO_RVAL_2KUP) +#define CTLO_OUTPUT_SET (CTLO_DIR_OUT | CTLO_INPUT_SET) + +enum ctrl_register { + CTRL_IN, + CTRL_OUT, +}; + +/** + * struct crystalcove_gpio - Crystal Cove GPIO controller + * @buslock: for bus lock/sync and unlock. + * @chip: the abstract gpio_chip structure. + * @regmap: the regmap from the parent device. + * @update: pending IRQ setting
[PATCH v5 3/3] gpio: Add support for Intel Crystal Cove PMIC
Devices based on Intel SoC products such as Baytrail have a Power Management IC. In the PMIC there are subsystems for voltage regulation, A/D conversion, GPIO and PWMs. The PMIC in Baytrail-T platform is called Crystal Cove. This patch adds support for the GPIO function in Crystal Cove. Signed-off-by: Yang, Bin Signed-off-by: Zhu, Lejun Reviewed-by: Mika Westerberg Reviewed-by: Alexandre Courbot Reviewed-by: Linus Walleij --- v5: - Fix the order of doing gpiochip_add() and gpiochip_irqchip_add(). - Add it to this patch set, to merge it along with the MFD changes. --- drivers/gpio/Kconfig| 13 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-crystalcove.c | 379 3 files changed, 393 insertions(+) create mode 100644 drivers/gpio/gpio-crystalcove.c diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index a86c49a..fed08d9d 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -440,6 +440,19 @@ config GPIO_ARIZONA help Support for GPIOs on Wolfson Arizona class devices. +config GPIO_CRYSTAL_COVE + tristate "GPIO support for Crystal Cove PMIC" + depends on INTEL_SOC_PMIC + select GPIOLIB_IRQCHIP + help + Support for GPIO pins on Crystal Cove PMIC. + + Say Yes if you have a Intel SoC based tablet with Crystal Cove PMIC + inside. + + This driver can also be built as a module. If so, the module will be + called gpio-crystalcove. + config GPIO_LP3943 tristate "TI/National Semiconductor LP3943 GPIO expander" depends on MFD_LP3943 diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 6309aff..e6cd935 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -20,6 +20,7 @@ obj-$(CONFIG_GPIO_BCM_KONA) += gpio-bcm-kona.o obj-$(CONFIG_GPIO_BT8XX) += gpio-bt8xx.o obj-$(CONFIG_GPIO_CLPS711X)+= gpio-clps711x.o obj-$(CONFIG_GPIO_CS5535) += gpio-cs5535.o +obj-$(CONFIG_GPIO_CRYSTAL_COVE)+= gpio-crystalcove.o obj-$(CONFIG_GPIO_DA9052) += gpio-da9052.o obj-$(CONFIG_GPIO_DA9055) += gpio-da9055.o obj-$(CONFIG_GPIO_DAVINCI) += gpio-davinci.o diff --git a/drivers/gpio/gpio-crystalcove.c b/drivers/gpio/gpio-crystalcove.c new file mode 100644 index 000..5a98499 --- /dev/null +++ b/drivers/gpio/gpio-crystalcove.c @@ -0,0 +1,379 @@ +/* + * gpio-crystalcove.c - Intel Crystal Cove GPIO Driver + * + * Copyright (C) 2012, 2014 Intel Corporation. All rights reserved. + * + * 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. + * + * This program is distributed in the hope that 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. + * + * Author: Yang, Bin + */ + +#include +#include +#include +#include +#include +#include + +#define CRYSTALCOVE_GPIO_NUM 16 + +#define UPDATE_IRQ_TYPEBIT(0) +#define UPDATE_IRQ_MASKBIT(1) + +#define GPIO0IRQ 0x0b +#define GPIO1IRQ 0x0c +#define MGPIO0IRQS00x19 +#define MGPIO1IRQS00x1a +#define MGPIO0IRQSX0x1b +#define MGPIO1IRQSX0x1c +#define GPIO0P0CTLO0x2b +#define GPIO0P0CTLI0x33 +#define GPIO1P0CTLO0x3b +#define GPIO1P0CTLI0x43 + +#define CTLI_INTCNT_DIS(0) +#define CTLI_INTCNT_NE (1 << 1) +#define CTLI_INTCNT_PE (2 << 1) +#define CTLI_INTCNT_BE (3 << 1) + +#define CTLO_DIR_IN(0) +#define CTLO_DIR_OUT (1 << 5) + +#define CTLO_DRV_CMOS (0) +#define CTLO_DRV_OD(1 << 4) + +#define CTLO_DRV_REN (1 << 3) + +#define CTLO_RVAL_2KDW (0) +#define CTLO_RVAL_2KUP (1 << 1) +#define CTLO_RVAL_50KDW(2 << 1) +#define CTLO_RVAL_50KUP(3 << 1) + +#define CTLO_INPUT_SET (CTLO_DRV_CMOS | CTLO_DRV_REN | CTLO_RVAL_2KUP) +#define CTLO_OUTPUT_SET(CTLO_DIR_OUT | CTLO_INPUT_SET) + +enum ctrl_register { + CTRL_IN, + CTRL_OUT, +}; + +/** + * struct crystalcove_gpio - Crystal Cove GPIO controller + * @buslock: for bus lock/sync and unlock. + * @chip: the abstract gpio_chip structure. + * @regmap: the regmap from the parent device. + * @update: pending IRQ setting update, to be written to the chip upon unlock. + * @intcnt_value: the Interrupt Detect value to be written. + * @set_irq_mask: true if the IRQ mask needs to be set, false to clear. + */ +struct crystalcove_gpio { + struct mutex buslock; /* irq_bus_lock */ + struct gpio_chip chip; + struct regmap *regmap; + int update; + int intcnt_value; + bool set_irq_mask; +}; + +static inline struct
[PATCH v5 3/3] gpio: Add support for Intel Crystal Cove PMIC
Devices based on Intel SoC products such as Baytrail have a Power Management IC. In the PMIC there are subsystems for voltage regulation, A/D conversion, GPIO and PWMs. The PMIC in Baytrail-T platform is called Crystal Cove. This patch adds support for the GPIO function in Crystal Cove. Signed-off-by: Yang, Bin bin.y...@intel.com Signed-off-by: Zhu, Lejun lejun@linux.intel.com Reviewed-by: Mika Westerberg mika.westerb...@linux.intel.com Reviewed-by: Alexandre Courbot acour...@nvidia.com Reviewed-by: Linus Walleij linus.wall...@linaro.org --- v5: - Fix the order of doing gpiochip_add() and gpiochip_irqchip_add(). - Add it to this patch set, to merge it along with the MFD changes. --- drivers/gpio/Kconfig| 13 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-crystalcove.c | 379 3 files changed, 393 insertions(+) create mode 100644 drivers/gpio/gpio-crystalcove.c diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index a86c49a..fed08d9d 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -440,6 +440,19 @@ config GPIO_ARIZONA help Support for GPIOs on Wolfson Arizona class devices. +config GPIO_CRYSTAL_COVE + tristate GPIO support for Crystal Cove PMIC + depends on INTEL_SOC_PMIC + select GPIOLIB_IRQCHIP + help + Support for GPIO pins on Crystal Cove PMIC. + + Say Yes if you have a Intel SoC based tablet with Crystal Cove PMIC + inside. + + This driver can also be built as a module. If so, the module will be + called gpio-crystalcove. + config GPIO_LP3943 tristate TI/National Semiconductor LP3943 GPIO expander depends on MFD_LP3943 diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 6309aff..e6cd935 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -20,6 +20,7 @@ obj-$(CONFIG_GPIO_BCM_KONA) += gpio-bcm-kona.o obj-$(CONFIG_GPIO_BT8XX) += gpio-bt8xx.o obj-$(CONFIG_GPIO_CLPS711X)+= gpio-clps711x.o obj-$(CONFIG_GPIO_CS5535) += gpio-cs5535.o +obj-$(CONFIG_GPIO_CRYSTAL_COVE)+= gpio-crystalcove.o obj-$(CONFIG_GPIO_DA9052) += gpio-da9052.o obj-$(CONFIG_GPIO_DA9055) += gpio-da9055.o obj-$(CONFIG_GPIO_DAVINCI) += gpio-davinci.o diff --git a/drivers/gpio/gpio-crystalcove.c b/drivers/gpio/gpio-crystalcove.c new file mode 100644 index 000..5a98499 --- /dev/null +++ b/drivers/gpio/gpio-crystalcove.c @@ -0,0 +1,379 @@ +/* + * gpio-crystalcove.c - Intel Crystal Cove GPIO Driver + * + * Copyright (C) 2012, 2014 Intel Corporation. All rights reserved. + * + * 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. + * + * This program is distributed in the hope that 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. + * + * Author: Yang, Bin bin.y...@intel.com + */ + +#include linux/interrupt.h +#include linux/platform_device.h +#include linux/gpio.h +#include linux/bitops.h +#include linux/regmap.h +#include linux/mfd/intel_soc_pmic.h + +#define CRYSTALCOVE_GPIO_NUM 16 + +#define UPDATE_IRQ_TYPEBIT(0) +#define UPDATE_IRQ_MASKBIT(1) + +#define GPIO0IRQ 0x0b +#define GPIO1IRQ 0x0c +#define MGPIO0IRQS00x19 +#define MGPIO1IRQS00x1a +#define MGPIO0IRQSX0x1b +#define MGPIO1IRQSX0x1c +#define GPIO0P0CTLO0x2b +#define GPIO0P0CTLI0x33 +#define GPIO1P0CTLO0x3b +#define GPIO1P0CTLI0x43 + +#define CTLI_INTCNT_DIS(0) +#define CTLI_INTCNT_NE (1 1) +#define CTLI_INTCNT_PE (2 1) +#define CTLI_INTCNT_BE (3 1) + +#define CTLO_DIR_IN(0) +#define CTLO_DIR_OUT (1 5) + +#define CTLO_DRV_CMOS (0) +#define CTLO_DRV_OD(1 4) + +#define CTLO_DRV_REN (1 3) + +#define CTLO_RVAL_2KDW (0) +#define CTLO_RVAL_2KUP (1 1) +#define CTLO_RVAL_50KDW(2 1) +#define CTLO_RVAL_50KUP(3 1) + +#define CTLO_INPUT_SET (CTLO_DRV_CMOS | CTLO_DRV_REN | CTLO_RVAL_2KUP) +#define CTLO_OUTPUT_SET(CTLO_DIR_OUT | CTLO_INPUT_SET) + +enum ctrl_register { + CTRL_IN, + CTRL_OUT, +}; + +/** + * struct crystalcove_gpio - Crystal Cove GPIO controller + * @buslock: for bus lock/sync and unlock. + * @chip: the abstract gpio_chip structure. + * @regmap: the regmap from the parent device. + * @update: pending IRQ setting update, to be written to the chip upon unlock. + * @intcnt_value: the Interrupt Detect value to be written. + * @set_irq_mask: true if the IRQ mask needs to be set, false to clear. + */ +struct