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

pinctrl: sunxi: introduce IRQ bank conversion function

The Allwinner H6 SoC have its pin controllers with the first IRQ-capable
GPIO bank at IRQ bank 1 and the second bank at IRQ bank 5. Some
refactors in the sunxi pinctrl framework are needed.

This commit introduces a IRQ bank conversion function, which replaces
the "(bank_base + bank)" code in IRQ register access.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Icenowy Zheng and committed by
Linus Walleij
29dfc6bb 4b0d6c5a

+12 -11
+12 -11
drivers/pinctrl/sunxi/pinctrl-sunxi.h
··· 263 263 return pin_num * PULL_PINS_BITS; 264 264 } 265 265 266 + static inline u32 sunxi_irq_hw_bank_num(const struct sunxi_pinctrl_desc *desc, u8 bank) 267 + { 268 + return desc->irq_bank_base + bank; 269 + } 270 + 266 271 static inline u32 sunxi_irq_cfg_reg(const struct sunxi_pinctrl_desc *desc, 267 272 u16 irq) 268 273 { 269 - unsigned bank_base = desc->irq_bank_base; 270 274 u8 bank = irq / IRQ_PER_BANK; 271 275 u8 reg = (irq % IRQ_PER_BANK) / IRQ_CFG_IRQ_PER_REG * 0x04; 272 276 273 - return IRQ_CFG_REG + (bank_base + bank) * IRQ_MEM_SIZE + reg; 277 + return IRQ_CFG_REG + 278 + sunxi_irq_hw_bank_num(desc, bank) * IRQ_MEM_SIZE + reg; 274 279 } 275 280 276 281 static inline u32 sunxi_irq_cfg_offset(u16 irq) ··· 286 281 287 282 static inline u32 sunxi_irq_ctrl_reg_from_bank(const struct sunxi_pinctrl_desc *desc, u8 bank) 288 283 { 289 - unsigned bank_base = desc->irq_bank_base; 290 - 291 - return IRQ_CTRL_REG + (bank_base + bank) * IRQ_MEM_SIZE; 284 + return IRQ_CTRL_REG + sunxi_irq_hw_bank_num(desc, bank) * IRQ_MEM_SIZE; 292 285 } 293 286 294 287 static inline u32 sunxi_irq_ctrl_reg(const struct sunxi_pinctrl_desc *desc, ··· 305 302 306 303 static inline u32 sunxi_irq_debounce_reg_from_bank(const struct sunxi_pinctrl_desc *desc, u8 bank) 307 304 { 308 - unsigned bank_base = desc->irq_bank_base; 309 - 310 - return IRQ_DEBOUNCE_REG + (bank_base + bank) * IRQ_MEM_SIZE; 305 + return IRQ_DEBOUNCE_REG + 306 + sunxi_irq_hw_bank_num(desc, bank) * IRQ_MEM_SIZE; 311 307 } 312 308 313 309 static inline u32 sunxi_irq_status_reg_from_bank(const struct sunxi_pinctrl_desc *desc, u8 bank) 314 310 { 315 - unsigned bank_base = desc->irq_bank_base; 316 - 317 - return IRQ_STATUS_REG + (bank_base + bank) * IRQ_MEM_SIZE; 311 + return IRQ_STATUS_REG + 312 + sunxi_irq_hw_bank_num(desc, bank) * IRQ_MEM_SIZE; 318 313 } 319 314 320 315 static inline u32 sunxi_irq_status_reg(const struct sunxi_pinctrl_desc *desc,