Skip to content

Commit 0f57b21

Browse files
Wenhua LinBartosz Golaszewski
authored andcommitted
gpio: pmic-eic-sprd: Configure the bit corresponding to the EIC through offset
A bank PMIC EIC contains 16 EICs, and the operating registers are BIT0-BIT15, such as BIT0 of the register operated by EIC0. Using the one-dimensional array reg[CACHE_NR_REGS] for maintenance will cause the configuration of other EICs to be affected when operating a certain EIC. In order to solve this problem, configure the bit corresponding to the EIC through offset. Signed-off-by: Wenhua Lin <Wenhua.Lin@unisoc.com> Reviewed-by: Chunyan Zhang <zhang.lyra@gmail.com> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent f34fd6e commit 0f57b21

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

drivers/gpio/gpio-pmic-eic-sprd.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ static void sprd_pmic_eic_irq_mask(struct irq_data *data)
151151
struct sprd_pmic_eic *pmic_eic = gpiochip_get_data(chip);
152152
u32 offset = irqd_to_hwirq(data);
153153

154-
pmic_eic->reg[REG_IE] = 0;
155-
pmic_eic->reg[REG_TRIG] = 0;
154+
pmic_eic->reg[REG_IE] &= ~BIT(offset);
155+
pmic_eic->reg[REG_TRIG] &= ~BIT(offset);
156156

157157
gpiochip_disable_irq(chip, offset);
158158
}
@@ -165,22 +165,23 @@ static void sprd_pmic_eic_irq_unmask(struct irq_data *data)
165165

166166
gpiochip_enable_irq(chip, offset);
167167

168-
pmic_eic->reg[REG_IE] = 1;
169-
pmic_eic->reg[REG_TRIG] = 1;
168+
pmic_eic->reg[REG_IE] |= BIT(offset);
169+
pmic_eic->reg[REG_TRIG] |= BIT(offset);
170170
}
171171

172172
static int sprd_pmic_eic_irq_set_type(struct irq_data *data,
173173
unsigned int flow_type)
174174
{
175175
struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
176176
struct sprd_pmic_eic *pmic_eic = gpiochip_get_data(chip);
177+
u32 offset = irqd_to_hwirq(data);
177178

178179
switch (flow_type) {
179180
case IRQ_TYPE_LEVEL_HIGH:
180-
pmic_eic->reg[REG_IEV] = 1;
181+
pmic_eic->reg[REG_IEV] |= BIT(offset);
181182
break;
182183
case IRQ_TYPE_LEVEL_LOW:
183-
pmic_eic->reg[REG_IEV] = 0;
184+
pmic_eic->reg[REG_IEV] &= ~BIT(offset);
184185
break;
185186
case IRQ_TYPE_EDGE_RISING:
186187
case IRQ_TYPE_EDGE_FALLING:
@@ -222,15 +223,15 @@ static void sprd_pmic_eic_bus_sync_unlock(struct irq_data *data)
222223
sprd_pmic_eic_update(chip, offset, SPRD_PMIC_EIC_IEV, 1);
223224
} else {
224225
sprd_pmic_eic_update(chip, offset, SPRD_PMIC_EIC_IEV,
225-
pmic_eic->reg[REG_IEV]);
226+
!!(pmic_eic->reg[REG_IEV] & BIT(offset)));
226227
}
227228

228229
/* Set irq unmask */
229230
sprd_pmic_eic_update(chip, offset, SPRD_PMIC_EIC_IE,
230-
pmic_eic->reg[REG_IE]);
231+
!!(pmic_eic->reg[REG_IE] & BIT(offset)));
231232
/* Generate trigger start pulse for debounce EIC */
232233
sprd_pmic_eic_update(chip, offset, SPRD_PMIC_EIC_TRIG,
233-
pmic_eic->reg[REG_TRIG]);
234+
!!(pmic_eic->reg[REG_TRIG] & BIT(offset)));
234235

235236
mutex_unlock(&pmic_eic->buslock);
236237
}

0 commit comments

Comments
 (0)