Skip to content

Commit 22c4e5b

Browse files
committed
Merge tag 'gpio-fixes-for-v5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux
Pull gpio fix from Bartosz Golaszewski: "Save and restore the sysconfig register in gpio-omap to fix a power-management issue" * tag 'gpio-fixes-for-v5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: gpio: omap: Save and restore sysconfig
2 parents 18a3c5f + ddd8d94 commit 22c4e5b

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

drivers/gpio/gpio-omap.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#define OMAP4_GPIO_DEBOUNCINGTIME_MASK 0xFF
3030

3131
struct gpio_regs {
32+
u32 sysconfig;
3233
u32 irqenable1;
3334
u32 irqenable2;
3435
u32 wake_en;
@@ -1069,6 +1070,7 @@ static void omap_gpio_init_context(struct gpio_bank *p)
10691070
const struct omap_gpio_reg_offs *regs = p->regs;
10701071
void __iomem *base = p->base;
10711072

1073+
p->context.sysconfig = readl_relaxed(base + regs->sysconfig);
10721074
p->context.ctrl = readl_relaxed(base + regs->ctrl);
10731075
p->context.oe = readl_relaxed(base + regs->direction);
10741076
p->context.wake_en = readl_relaxed(base + regs->wkup_en);
@@ -1088,6 +1090,7 @@ static void omap_gpio_restore_context(struct gpio_bank *bank)
10881090
const struct omap_gpio_reg_offs *regs = bank->regs;
10891091
void __iomem *base = bank->base;
10901092

1093+
writel_relaxed(bank->context.sysconfig, base + regs->sysconfig);
10911094
writel_relaxed(bank->context.wake_en, base + regs->wkup_en);
10921095
writel_relaxed(bank->context.ctrl, base + regs->ctrl);
10931096
writel_relaxed(bank->context.leveldetect0, base + regs->leveldetect0);
@@ -1115,6 +1118,10 @@ static void omap_gpio_idle(struct gpio_bank *bank, bool may_lose_context)
11151118

11161119
bank->saved_datain = readl_relaxed(base + bank->regs->datain);
11171120

1121+
/* Save syconfig, it's runtime value can be different from init value */
1122+
if (bank->loses_context)
1123+
bank->context.sysconfig = readl_relaxed(base + bank->regs->sysconfig);
1124+
11181125
if (!bank->enabled_non_wakeup_gpios)
11191126
goto update_gpio_context_count;
11201127

@@ -1279,6 +1286,7 @@ static int gpio_omap_cpu_notifier(struct notifier_block *nb,
12791286

12801287
static const struct omap_gpio_reg_offs omap2_gpio_regs = {
12811288
.revision = OMAP24XX_GPIO_REVISION,
1289+
.sysconfig = OMAP24XX_GPIO_SYSCONFIG,
12821290
.direction = OMAP24XX_GPIO_OE,
12831291
.datain = OMAP24XX_GPIO_DATAIN,
12841292
.dataout = OMAP24XX_GPIO_DATAOUT,
@@ -1302,6 +1310,7 @@ static const struct omap_gpio_reg_offs omap2_gpio_regs = {
13021310

13031311
static const struct omap_gpio_reg_offs omap4_gpio_regs = {
13041312
.revision = OMAP4_GPIO_REVISION,
1313+
.sysconfig = OMAP4_GPIO_SYSCONFIG,
13051314
.direction = OMAP4_GPIO_OE,
13061315
.datain = OMAP4_GPIO_DATAIN,
13071316
.dataout = OMAP4_GPIO_DATAOUT,

include/linux/platform_data/gpio-omap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
* omap2+ specific GPIO registers
8686
*/
8787
#define OMAP24XX_GPIO_REVISION 0x0000
88+
#define OMAP24XX_GPIO_SYSCONFIG 0x0010
8889
#define OMAP24XX_GPIO_IRQSTATUS1 0x0018
8990
#define OMAP24XX_GPIO_IRQSTATUS2 0x0028
9091
#define OMAP24XX_GPIO_IRQENABLE2 0x002c
@@ -108,6 +109,7 @@
108109
#define OMAP24XX_GPIO_SETDATAOUT 0x0094
109110

110111
#define OMAP4_GPIO_REVISION 0x0000
112+
#define OMAP4_GPIO_SYSCONFIG 0x0010
111113
#define OMAP4_GPIO_EOI 0x0020
112114
#define OMAP4_GPIO_IRQSTATUSRAW0 0x0024
113115
#define OMAP4_GPIO_IRQSTATUSRAW1 0x0028
@@ -148,6 +150,7 @@
148150
#ifndef __ASSEMBLER__
149151
struct omap_gpio_reg_offs {
150152
u16 revision;
153+
u16 sysconfig;
151154
u16 direction;
152155
u16 datain;
153156
u16 dataout;

0 commit comments

Comments
 (0)