Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Wenhua Lin and committed by
Bartosz Golaszewski
0f57b213 f34fd6ee

+10 -9
+10 -9
drivers/gpio/gpio-pmic-eic-sprd.c
··· 151 151 struct sprd_pmic_eic *pmic_eic = gpiochip_get_data(chip); 152 152 u32 offset = irqd_to_hwirq(data); 153 153 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); 156 156 157 157 gpiochip_disable_irq(chip, offset); 158 158 } ··· 165 165 166 166 gpiochip_enable_irq(chip, offset); 167 167 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); 170 170 } 171 171 172 172 static int sprd_pmic_eic_irq_set_type(struct irq_data *data, ··· 174 174 { 175 175 struct gpio_chip *chip = irq_data_get_irq_chip_data(data); 176 176 struct sprd_pmic_eic *pmic_eic = gpiochip_get_data(chip); 177 + u32 offset = irqd_to_hwirq(data); 177 178 178 179 switch (flow_type) { 179 180 case IRQ_TYPE_LEVEL_HIGH: 180 - pmic_eic->reg[REG_IEV] = 1; 181 + pmic_eic->reg[REG_IEV] |= BIT(offset); 181 182 break; 182 183 case IRQ_TYPE_LEVEL_LOW: 183 - pmic_eic->reg[REG_IEV] = 0; 184 + pmic_eic->reg[REG_IEV] &= ~BIT(offset); 184 185 break; 185 186 case IRQ_TYPE_EDGE_RISING: 186 187 case IRQ_TYPE_EDGE_FALLING: ··· 223 222 sprd_pmic_eic_update(chip, offset, SPRD_PMIC_EIC_IEV, 1); 224 223 } else { 225 224 sprd_pmic_eic_update(chip, offset, SPRD_PMIC_EIC_IEV, 226 - pmic_eic->reg[REG_IEV]); 225 + !!(pmic_eic->reg[REG_IEV] & BIT(offset))); 227 226 } 228 227 229 228 /* Set irq unmask */ 230 229 sprd_pmic_eic_update(chip, offset, SPRD_PMIC_EIC_IE, 231 - pmic_eic->reg[REG_IE]); 230 + !!(pmic_eic->reg[REG_IE] & BIT(offset))); 232 231 /* Generate trigger start pulse for debounce EIC */ 233 232 sprd_pmic_eic_update(chip, offset, SPRD_PMIC_EIC_TRIG, 234 - pmic_eic->reg[REG_TRIG]); 233 + !!(pmic_eic->reg[REG_TRIG] & BIT(offset))); 235 234 236 235 mutex_unlock(&pmic_eic->buslock); 237 236 }