static void write_config_reg(struct pinmux_info *gpioc, struct pinmux_cfg_reg *crp, unsigned long field, unsigned long value) { void *mapped_reg; unsigned long mask, pos, data; config_reg_helper(gpioc, crp, field, &mapped_reg, &mask, &pos); debug("write_reg addr = %lx, value = %ld, field = %ld, " "r_width = %ld, f_width = %ld\n", crp->reg, value, field, crp->reg_width, crp->field_width); mask = ~(mask << pos); value = value << pos; data = gpio_read_raw_reg(mapped_reg, crp->reg_width); data &= mask; data |= value; if (gpioc->unlock_reg) gpio_write_raw_reg(pfc_phys_to_virt(gpioc, gpioc->unlock_reg), 32, ~data); gpio_write_raw_reg(mapped_reg, crp->reg_width, data); }
static int read_config_reg(struct pinmux_info *gpioc, struct pinmux_cfg_reg *crp, unsigned long field) { void __iomem *mapped_reg; unsigned long mask, pos; config_reg_helper(gpioc, crp, field, &mapped_reg, &mask, &pos); pr_debug("read_reg: addr = %lx, field = %ld, " "r_width = %ld, f_width = %ld\n", crp->reg, field, crp->reg_width, crp->field_width); return (gpio_read_raw_reg(mapped_reg, crp->reg_width) >> pos) & mask; }