Skip to content

Commit b8e73b5

Browse files
committed
Merge tag 'intel-pinctrl-v5.9-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pinctrl/intel into devel
intel-pinctrl for v5.9-1 * New driver for Emmitsburg * New driver for Tiger Lake-H * Part 3 of Cherryview driver clean up * Fix a glitch on Baytrail platforms The following is an automated git shortlog grouped by driver: ARM/orion/gpio: - Make use of for_each_requested_gpio() at91: - Make use of for_each_requested_gpio() baytrail: - Use fallthrough pseudo-keyword - Fix pin being driven low for a while on gpiod_get(..., GPIOD_OUT_HIGH) - Drop no-op ACPI_PTR() call cherryview: - Re-use data structures from pinctrl-intel.h (part 3) - Convert chv_writel() to use chv_padreg() - Introduce helpers to IO with common registers - Introduce chv_readl() helper gpio: - xra1403: Make use of for_each_requested_gpio() - mvebu: Make use of for_each_requested_gpio() gpiolib: - Introduce for_each_requested_gpio_in_range() macro intel: - Add Intel Emmitsburg pin controller support - Make use of for_each_requested_gpio_in_range() - Protect IO in few call backs by lock - Split intel_config_get() to three functions - Drop the only label in the code for consistency - Get rid of redundant 'else' in intel_config_set_debounce() - Make use of IRQ_RETVAL() - Reduce scope of the lock - Disable input and output buffer when switching to GPIO - Allow drivers to define ACPI address space ID - Allow drivers to define total amount of IRQs per community lynxpoint: - Drop no-op ACPI_PTR() call - Introduce helpers to enable or disable input - Make use of for_each_requested_gpio() merrifield: - Add I²S bus 2 pins to groups and functions - Update pin names in accordance with official list tigerlake: - Add support for Tiger Lake-H
2 parents 66c00f5 + b4f2fcb commit b8e73b5

File tree

10 files changed

+1191
-329
lines changed

10 files changed

+1191
-329
lines changed

drivers/pinctrl/intel/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ config PINCTRL_DENVERTON
9595
This pinctrl driver provides an interface that allows configuring
9696
of Intel Denverton SoC pins and using them as GPIOs.
9797

98+
config PINCTRL_EMMITSBURG
99+
tristate "Intel Emmitsburg pinctrl and GPIO driver"
100+
depends on ACPI
101+
select PINCTRL_INTEL
102+
help
103+
This pinctrl driver provides an interface that allows configuring
104+
of Intel Emmitsburg pins and using them as GPIOs.
105+
98106
config PINCTRL_GEMINILAKE
99107
tristate "Intel Gemini Lake SoC pinctrl and GPIO driver"
100108
depends on ACPI

drivers/pinctrl/intel/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ obj-$(CONFIG_PINCTRL_BROXTON) += pinctrl-broxton.o
1010
obj-$(CONFIG_PINCTRL_CANNONLAKE) += pinctrl-cannonlake.o
1111
obj-$(CONFIG_PINCTRL_CEDARFORK) += pinctrl-cedarfork.o
1212
obj-$(CONFIG_PINCTRL_DENVERTON) += pinctrl-denverton.o
13+
obj-$(CONFIG_PINCTRL_EMMITSBURG) += pinctrl-emmitsburg.o
1314
obj-$(CONFIG_PINCTRL_GEMINILAKE) += pinctrl-geminilake.o
1415
obj-$(CONFIG_PINCTRL_ICELAKE) += pinctrl-icelake.o
1516
obj-$(CONFIG_PINCTRL_JASPERLAKE) += pinctrl-jasperlake.o

drivers/pinctrl/intel/pinctrl-baytrail.c

Lines changed: 56 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -800,14 +800,28 @@ static void byt_gpio_disable_free(struct pinctrl_dev *pctl_dev,
800800
pm_runtime_put(vg->dev);
801801
}
802802

803+
static void byt_gpio_direct_irq_check(struct intel_pinctrl *vg,
804+
unsigned int offset)
805+
{
806+
void __iomem *conf_reg = byt_gpio_reg(vg, offset, BYT_CONF0_REG);
807+
808+
/*
809+
* Before making any direction modifications, do a check if gpio is set
810+
* for direct IRQ. On Bay Trail, setting GPIO to output does not make
811+
* sense, so let's at least inform the caller before they shoot
812+
* themselves in the foot.
813+
*/
814+
if (readl(conf_reg) & BYT_DIRECT_IRQ_EN)
815+
dev_info_once(vg->dev, "Potential Error: Setting GPIO with direct_irq_en to output");
816+
}
817+
803818
static int byt_gpio_set_direction(struct pinctrl_dev *pctl_dev,
804819
struct pinctrl_gpio_range *range,
805820
unsigned int offset,
806821
bool input)
807822
{
808823
struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctl_dev);
809824
void __iomem *val_reg = byt_gpio_reg(vg, offset, BYT_VAL_REG);
810-
void __iomem *conf_reg = byt_gpio_reg(vg, offset, BYT_CONF0_REG);
811825
unsigned long flags;
812826
u32 value;
813827

@@ -817,14 +831,8 @@ static int byt_gpio_set_direction(struct pinctrl_dev *pctl_dev,
817831
value &= ~BYT_DIR_MASK;
818832
if (input)
819833
value |= BYT_OUTPUT_EN;
820-
else if (readl(conf_reg) & BYT_DIRECT_IRQ_EN)
821-
/*
822-
* Before making any direction modifications, do a check if gpio
823-
* is set for direct IRQ. On baytrail, setting GPIO to output
824-
* does not make sense, so let's at least inform the caller before
825-
* they shoot themselves in the foot.
826-
*/
827-
dev_info_once(vg->dev, "Potential Error: Setting GPIO with direct_irq_en to output");
834+
else
835+
byt_gpio_direct_irq_check(vg, offset);
828836

829837
writel(value, val_reg);
830838

@@ -1165,19 +1173,50 @@ static int byt_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
11651173

11661174
static int byt_gpio_direction_input(struct gpio_chip *chip, unsigned int offset)
11671175
{
1168-
return pinctrl_gpio_direction_input(chip->base + offset);
1176+
struct intel_pinctrl *vg = gpiochip_get_data(chip);
1177+
void __iomem *val_reg = byt_gpio_reg(vg, offset, BYT_VAL_REG);
1178+
unsigned long flags;
1179+
u32 reg;
1180+
1181+
raw_spin_lock_irqsave(&byt_lock, flags);
1182+
1183+
reg = readl(val_reg);
1184+
reg &= ~BYT_DIR_MASK;
1185+
reg |= BYT_OUTPUT_EN;
1186+
writel(reg, val_reg);
1187+
1188+
raw_spin_unlock_irqrestore(&byt_lock, flags);
1189+
return 0;
11691190
}
11701191

1192+
/*
1193+
* Note despite the temptation this MUST NOT be converted into a call to
1194+
* pinctrl_gpio_direction_output() + byt_gpio_set() that does not work this
1195+
* MUST be done as a single BYT_VAL_REG register write.
1196+
* See the commit message of the commit adding this comment for details.
1197+
*/
11711198
static int byt_gpio_direction_output(struct gpio_chip *chip,
11721199
unsigned int offset, int value)
11731200
{
1174-
int ret = pinctrl_gpio_direction_output(chip->base + offset);
1201+
struct intel_pinctrl *vg = gpiochip_get_data(chip);
1202+
void __iomem *val_reg = byt_gpio_reg(vg, offset, BYT_VAL_REG);
1203+
unsigned long flags;
1204+
u32 reg;
11751205

1176-
if (ret)
1177-
return ret;
1206+
raw_spin_lock_irqsave(&byt_lock, flags);
1207+
1208+
byt_gpio_direct_irq_check(vg, offset);
1209+
1210+
reg = readl(val_reg);
1211+
reg &= ~BYT_DIR_MASK;
1212+
if (value)
1213+
reg |= BYT_LEVEL;
1214+
else
1215+
reg &= ~BYT_LEVEL;
11781216

1179-
byt_gpio_set(chip, offset, value);
1217+
writel(reg, val_reg);
11801218

1219+
raw_spin_unlock_irqrestore(&byt_lock, flags);
11811220
return 0;
11821221
}
11831222

@@ -1333,13 +1372,13 @@ static void byt_irq_unmask(struct irq_data *d)
13331372
switch (irqd_get_trigger_type(d)) {
13341373
case IRQ_TYPE_LEVEL_HIGH:
13351374
value |= BYT_TRIG_LVL;
1336-
/* fall through */
1375+
fallthrough;
13371376
case IRQ_TYPE_EDGE_RISING:
13381377
value |= BYT_TRIG_POS;
13391378
break;
13401379
case IRQ_TYPE_LEVEL_LOW:
13411380
value |= BYT_TRIG_LVL;
1342-
/* fall through */
1381+
fallthrough;
13431382
case IRQ_TYPE_EDGE_FALLING:
13441383
value |= BYT_TRIG_NEG;
13451384
break;
@@ -1757,9 +1796,8 @@ static struct platform_driver byt_gpio_driver = {
17571796
.driver = {
17581797
.name = "byt_gpio",
17591798
.pm = &byt_gpio_pm_ops,
1799+
.acpi_match_table = byt_gpio_acpi_match,
17601800
.suppress_bind_attrs = true,
1761-
1762-
.acpi_match_table = ACPI_PTR(byt_gpio_acpi_match),
17631801
},
17641802
};
17651803

0 commit comments

Comments
 (0)