Skip to content

Commit 828907e

Browse files
committed
Merge tag 'gpio-v5.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO updates from Linus Walleij: "This is the bulk of GPIO development for the v5.7 kernel cycle. Core and userspace API: - The userspace API KFIFOs have been imoproved with locks that do not block interrupts. This makes us better at getting events to userspace without blocking or disturbing new events arriving in the same time. This was reviewed by the KFIFO maintainer Stefani. This is a generic improvement which paves the road for similar improvements in other subsystems. - We provide a new ioctl() for monitoring changes in the line information, such as when multiple clients are taking lines and giving them back, possibly reconfiguring them in the process: we can now monitor that and not get stuck with stale static information. - An example tool 'gpio-watch' is provided to showcase this functionality. - Timestamps for events are switched to ktime_get_ns() which is monotonic. We previously had a 'realtime' stamp which could move forward and *backward* in time, which probably would just cause silent bugs and weird behaviour. In the long run we see two relevant timestamps: ktime_get_ns() or the timestamp sometimes provided by the GPIO hardware itself, if that exists. - Device Tree overlay support for GPIO hogs. On systems that load overlays, these overlays can now contain hogs, and will then be respected. - Handle pin control interaction with nonexisting pin ranges in the GPIO library core instead of in the individual drivers. New drivers: - New driver for the Mellanox BlueField 2 GPIO controller. Driver improvements: - Introduce the BGPIOF_NO_SET_ON_INPUT flag to the generic MMIO GPIO library and use this flag in the MT7621 driver. - Texas Instruments OMAP CPU power management improvements, such as blocking of idle on pending GPIO interrupts" * tag 'gpio-v5.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (59 commits) Revert "gpio: eic-sprd: Use devm_platform_ioremap_resource()" pinctrl: Unconditionally assign .request()/.free() gpio: Unconditionally assign .request()/.free() gpio: export of_pinctrl_get to modules pinctrl: Define of_pinctrl_get() dummy for !PINCTRL gpio: Rename variable in core APIs gpio: Avoid using pin ranges with !PINCTRL gpiolib: Remove unused gpio_chip parameter from gpio_set_bias() gpiolib: Pass gpio_desc to gpio_set_config() gpiolib: Introduce gpiod_set_config() tools: gpio: Fix out-of-tree build regression gpio: gpiolib: fix a doc warning gpio: tegra186: Add Tegra194 pin ranges for GG.0 and GG.1 gpio: tegra186: Add support for pin ranges gpio: Support GPIO controllers without pin-ranges ARM: integrator: impd1: Use GPIO_LOOKUP() helper macro gpio: brcmstb: support gpio-line-names property tools: gpio: Fix typo in gpio-utils tools: gpio-hammer: Apply scripts/Lindent and retain good changes gpiolib: gpio_name_to_desc: factor out !name check ...
2 parents 6f43bae + 4ed7d7d commit 828907e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1815
-775
lines changed

Documentation/driver-api/gpio/driver.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ The preferred way to set up the helpers is to fill in the
416416
struct gpio_irq_chip inside struct gpio_chip before adding the gpio_chip.
417417
If you do this, the additional irq_chip will be set up by gpiolib at the
418418
same time as setting up the rest of the GPIO functionality. The following
419-
is a typical example of a cascaded interrupt handler using gpio_irq_chip::
419+
is a typical example of a cascaded interrupt handler using gpio_irq_chip:
420420

421421
.. code-block:: c
422422
@@ -453,7 +453,7 @@ is a typical example of a cascaded interrupt handler using gpio_irq_chip::
453453
return devm_gpiochip_add_data(dev, &g->gc, g);
454454
455455
The helper support using hierarchical interrupt controllers as well.
456-
In this case the typical set-up will look like this::
456+
In this case the typical set-up will look like this:
457457

458458
.. code-block:: c
459459

arch/arm/mach-integrator/impd1.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -410,13 +410,10 @@ static int __ref impd1_probe(struct lm_device *dev)
410410
* 5 = Key lower right
411411
*/
412412
/* We need the two MMCI GPIO entries */
413-
lookup->table[0].chip_label = chipname;
414-
lookup->table[0].chip_hwnum = 3;
415-
lookup->table[0].con_id = "wp";
416-
lookup->table[1].chip_label = chipname;
417-
lookup->table[1].chip_hwnum = 4;
418-
lookup->table[1].con_id = "cd";
419-
lookup->table[1].flags = GPIO_ACTIVE_LOW;
413+
lookup->table[0] = (struct gpiod_lookup)
414+
GPIO_LOOKUP(chipname, 3, "wp", 0);
415+
lookup->table[1] = (struct gpiod_lookup)
416+
GPIO_LOOKUP(chipname, 4, "cd", GPIO_ACTIVE_LOW);
420417
gpiod_add_lookup_table(lookup);
421418
}
422419

arch/arm/mach-omap2/cpuidle34xx.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ static int omap3_enter_idle(struct cpuidle_device *dev,
109109
int index)
110110
{
111111
struct omap3_idle_statedata *cx = &omap3_idle_data[index];
112+
int error;
112113

113114
if (omap_irq_pending() || need_resched())
114115
goto return_sleep_time;
@@ -125,8 +126,11 @@ static int omap3_enter_idle(struct cpuidle_device *dev,
125126
* Call idle CPU PM enter notifier chain so that
126127
* VFP context is saved.
127128
*/
128-
if (cx->mpu_state == PWRDM_POWER_OFF)
129-
cpu_pm_enter();
129+
if (cx->mpu_state == PWRDM_POWER_OFF) {
130+
error = cpu_pm_enter();
131+
if (error)
132+
goto out_clkdm_set;
133+
}
130134

131135
/* Execute ARM wfi */
132136
omap_sram_idle();
@@ -139,6 +143,7 @@ static int omap3_enter_idle(struct cpuidle_device *dev,
139143
pwrdm_read_prev_pwrst(mpu_pd) == PWRDM_POWER_OFF)
140144
cpu_pm_exit();
141145

146+
out_clkdm_set:
142147
/* Re-allow idle for C1 */
143148
if (cx->flags & OMAP_CPUIDLE_CX_NO_CLKDM_IDLE)
144149
clkdm_allow_idle(mpu_pd->pwrdm_clkdms[0]);

arch/arm/mach-omap2/cpuidle44xx.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev,
122122
{
123123
struct idle_statedata *cx = state_ptr + index;
124124
u32 mpuss_can_lose_context = 0;
125+
int error;
125126

126127
/*
127128
* CPU0 has to wait and stay ON until CPU1 is OFF state.
@@ -159,7 +160,9 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev,
159160
* Call idle CPU PM enter notifier chain so that
160161
* VFP and per CPU interrupt context is saved.
161162
*/
162-
cpu_pm_enter();
163+
error = cpu_pm_enter();
164+
if (error)
165+
goto cpu_pm_out;
163166

164167
if (dev->cpu == 0) {
165168
pwrdm_set_logic_retst(mpu_pd, cx->mpu_logic_state);
@@ -169,13 +172,17 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev,
169172
* Call idle CPU cluster PM enter notifier chain
170173
* to save GIC and wakeupgen context.
171174
*/
172-
if (mpuss_can_lose_context)
173-
cpu_cluster_pm_enter();
175+
if (mpuss_can_lose_context) {
176+
error = cpu_cluster_pm_enter();
177+
if (error)
178+
goto cpu_cluster_pm_out;
179+
}
174180
}
175181

176182
omap4_enter_lowpower(dev->cpu, cx->cpu_state);
177183
cpu_done[dev->cpu] = true;
178184

185+
cpu_cluster_pm_out:
179186
/* Wakeup CPU1 only if it is not offlined */
180187
if (dev->cpu == 0 && cpumask_test_cpu(1, cpu_online_mask)) {
181188

@@ -197,19 +204,20 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev,
197204
}
198205
}
199206

200-
/*
201-
* Call idle CPU PM exit notifier chain to restore
202-
* VFP and per CPU IRQ context.
203-
*/
204-
cpu_pm_exit();
205-
206207
/*
207208
* Call idle CPU cluster PM exit notifier chain
208209
* to restore GIC and wakeupgen context.
209210
*/
210211
if (dev->cpu == 0 && mpuss_can_lose_context)
211212
cpu_cluster_pm_exit();
212213

214+
/*
215+
* Call idle CPU PM exit notifier chain to restore
216+
* VFP and per CPU IRQ context.
217+
*/
218+
cpu_pm_exit();
219+
220+
cpu_pm_out:
213221
tick_broadcast_exit();
214222

215223
fail:

arch/arm/mach-omap2/pm34xx.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ void omap_sram_idle(void)
191191
int per_next_state = PWRDM_POWER_ON;
192192
int core_next_state = PWRDM_POWER_ON;
193193
u32 sdrc_pwr = 0;
194+
int error;
194195

195196
mpu_next_state = pwrdm_read_next_pwrst(mpu_pwrdm);
196197
switch (mpu_next_state) {
@@ -219,8 +220,11 @@ void omap_sram_idle(void)
219220
pwrdm_pre_transition(NULL);
220221

221222
/* PER */
222-
if (per_next_state == PWRDM_POWER_OFF)
223-
cpu_cluster_pm_enter();
223+
if (per_next_state == PWRDM_POWER_OFF) {
224+
error = cpu_cluster_pm_enter();
225+
if (error)
226+
return;
227+
}
224228

225229
/* CORE */
226230
if (core_next_state < PWRDM_POWER_ON) {

drivers/gpio/Kconfig

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,13 @@ config GPIO_MVEBU
394394

395395
config GPIO_MXC
396396
def_bool y
397-
depends on ARCH_MXC
397+
depends on ARCH_MXC || COMPILE_TEST
398398
select GPIO_GENERIC
399399
select GENERIC_IRQ_CHIP
400400

401401
config GPIO_MXS
402402
def_bool y
403-
depends on ARCH_MXS
403+
depends on ARCH_MXS || COMPILE_TEST
404404
select GPIO_GENERIC
405405
select GENERIC_IRQ_CHIP
406406

@@ -1399,6 +1399,13 @@ config GPIO_MLXBF
13991399
help
14001400
Say Y here if you want GPIO support on Mellanox BlueField SoC.
14011401

1402+
config GPIO_MLXBF2
1403+
tristate "Mellanox BlueField 2 SoC GPIO"
1404+
depends on (MELLANOX_PLATFORM && ARM64 && ACPI) || (64BIT && COMPILE_TEST)
1405+
select GPIO_GENERIC
1406+
help
1407+
Say Y here if you want GPIO support on Mellanox BlueField 2 SoC.
1408+
14021409
config GPIO_ML_IOH
14031410
tristate "OKI SEMICONDUCTOR ML7213 IOH GPIO support"
14041411
depends on X86 || COMPILE_TEST

drivers/gpio/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ obj-$(CONFIG_GPIO_MENZ127) += gpio-menz127.o
9393
obj-$(CONFIG_GPIO_MERRIFIELD) += gpio-merrifield.o
9494
obj-$(CONFIG_GPIO_ML_IOH) += gpio-ml-ioh.o
9595
obj-$(CONFIG_GPIO_MLXBF) += gpio-mlxbf.o
96+
obj-$(CONFIG_GPIO_MLXBF2) += gpio-mlxbf2.o
9697
obj-$(CONFIG_GPIO_MM_LANTIQ) += gpio-mm-lantiq.o
9798
obj-$(CONFIG_GPIO_MOCKUP) += gpio-mockup.o
9899
obj-$(CONFIG_GPIO_MOXTET) += gpio-moxtet.o

drivers/gpio/gpio-brcmstb.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,49 @@ static const struct dev_pm_ops brcmstb_gpio_pm_ops = {
603603
.resume_noirq = brcmstb_gpio_resume,
604604
};
605605

606+
static void brcmstb_gpio_set_names(struct device *dev,
607+
struct brcmstb_gpio_bank *bank)
608+
{
609+
struct device_node *np = dev->of_node;
610+
const char **names;
611+
int nstrings, base;
612+
unsigned int i;
613+
614+
base = bank->id * MAX_GPIO_PER_BANK;
615+
616+
nstrings = of_property_count_strings(np, "gpio-line-names");
617+
if (nstrings <= base)
618+
/* Line names not present */
619+
return;
620+
621+
names = devm_kcalloc(dev, MAX_GPIO_PER_BANK, sizeof(*names),
622+
GFP_KERNEL);
623+
if (!names)
624+
return;
625+
626+
/*
627+
* Make sure to not index beyond the end of the number of descriptors
628+
* of the GPIO device.
629+
*/
630+
for (i = 0; i < bank->width; i++) {
631+
const char *name;
632+
int ret;
633+
634+
ret = of_property_read_string_index(np, "gpio-line-names",
635+
base + i, &name);
636+
if (ret) {
637+
if (ret != -ENODATA)
638+
dev_err(dev, "unable to name line %d: %d\n",
639+
base + i, ret);
640+
break;
641+
}
642+
if (*name)
643+
names[i] = name;
644+
}
645+
646+
bank->gc.names = names;
647+
}
648+
606649
static int brcmstb_gpio_probe(struct platform_device *pdev)
607650
{
608651
struct device *dev = &pdev->dev;
@@ -726,6 +769,7 @@ static int brcmstb_gpio_probe(struct platform_device *pdev)
726769
need_wakeup_event |= !!__brcmstb_gpio_get_active_irqs(bank);
727770
gc->write_reg(reg_base + GIO_MASK(bank->id), 0);
728771

772+
brcmstb_gpio_set_names(dev, bank);
729773
err = gpiochip_add_data(gc, bank);
730774
if (err) {
731775
dev_err(dev, "Could not add gpiochip for bank %d\n",

drivers/gpio/gpio-davinci.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,8 @@ static int davinci_gpio_probe(struct platform_device *pdev)
259259
chips->chip.of_gpio_n_cells = 2;
260260
chips->chip.parent = dev;
261261
chips->chip.of_node = dev->of_node;
262-
263-
if (of_property_read_bool(dev->of_node, "gpio-ranges")) {
264-
chips->chip.request = gpiochip_generic_request;
265-
chips->chip.free = gpiochip_generic_free;
266-
}
262+
chips->chip.request = gpiochip_generic_request;
263+
chips->chip.free = gpiochip_generic_free;
267264
#endif
268265
spin_lock_init(&chips->lock);
269266

drivers/gpio/gpio-eic-sprd.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@ static int sprd_eic_probe(struct platform_device *pdev)
569569
const struct sprd_eic_variant_data *pdata;
570570
struct gpio_irq_chip *irq;
571571
struct sprd_eic *sprd_eic;
572+
struct resource *res;
572573
int ret, i;
573574

574575
pdata = of_device_get_match_data(&pdev->dev);
@@ -595,9 +596,13 @@ static int sprd_eic_probe(struct platform_device *pdev)
595596
* have one bank EIC, thus base[1] and base[2] can be
596597
* optional.
597598
*/
598-
sprd_eic->base[i] = devm_platform_ioremap_resource(pdev, i);
599-
if (IS_ERR(sprd_eic->base[i]))
599+
res = platform_get_resource(pdev, IORESOURCE_MEM, i);
600+
if (!res)
600601
continue;
602+
603+
sprd_eic->base[i] = devm_ioremap_resource(&pdev->dev, res);
604+
if (IS_ERR(sprd_eic->base[i]))
605+
return PTR_ERR(sprd_eic->base[i]);
601606
}
602607

603608
sprd_eic->chip.label = sprd_eic_label_name[sprd_eic->type];

0 commit comments

Comments
 (0)