Lines Matching refs:hcg

32 	struct creg_gpio *hcg = gpiochip_get_data(gc);  in creg_gpio_set()  local
33 const struct creg_layout *layout = hcg->layout; in creg_gpio_set()
38 value = val ? hcg->layout->on[offset] : hcg->layout->off[offset]; in creg_gpio_set()
44 spin_lock_irqsave(&hcg->lock, flags); in creg_gpio_set()
45 reg = readl(hcg->regs); in creg_gpio_set()
48 writel(reg, hcg->regs); in creg_gpio_set()
49 spin_unlock_irqrestore(&hcg->lock, flags); in creg_gpio_set()
59 static int creg_gpio_validate_pg(struct device *dev, struct creg_gpio *hcg, in creg_gpio_validate_pg() argument
62 const struct creg_layout *layout = hcg->layout; in creg_gpio_validate_pg()
81 static int creg_gpio_validate(struct device *dev, struct creg_gpio *hcg, in creg_gpio_validate() argument
87 if (hcg->layout->ngpio < 1 || hcg->layout->ngpio > MAX_GPIO) in creg_gpio_validate()
90 if (ngpios < 1 || ngpios > hcg->layout->ngpio) { in creg_gpio_validate()
91 dev_err(dev, "ngpios must be in [1:%u]\n", hcg->layout->ngpio); in creg_gpio_validate()
95 for (i = 0; i < hcg->layout->ngpio; i++) { in creg_gpio_validate()
96 if (creg_gpio_validate_pg(dev, hcg, i)) in creg_gpio_validate()
99 reg_len += hcg->layout->shift[i] + hcg->layout->bit_per_gpio[i]; in creg_gpio_validate()
139 struct creg_gpio *hcg; in creg_gpio_probe() local
143 hcg = devm_kzalloc(dev, sizeof(struct creg_gpio), GFP_KERNEL); in creg_gpio_probe()
144 if (!hcg) in creg_gpio_probe()
147 hcg->regs = devm_platform_ioremap_resource(pdev, 0); in creg_gpio_probe()
148 if (IS_ERR(hcg->regs)) in creg_gpio_probe()
149 return PTR_ERR(hcg->regs); in creg_gpio_probe()
152 hcg->layout = match->data; in creg_gpio_probe()
153 if (!hcg->layout) in creg_gpio_probe()
160 ret = creg_gpio_validate(dev, hcg, ngpios); in creg_gpio_probe()
164 spin_lock_init(&hcg->lock); in creg_gpio_probe()
166 hcg->gc.parent = dev; in creg_gpio_probe()
167 hcg->gc.label = dev_name(dev); in creg_gpio_probe()
168 hcg->gc.base = -1; in creg_gpio_probe()
169 hcg->gc.ngpio = ngpios; in creg_gpio_probe()
170 hcg->gc.set = creg_gpio_set; in creg_gpio_probe()
171 hcg->gc.direction_output = creg_gpio_dir_out; in creg_gpio_probe()
173 ret = devm_gpiochip_add_data(dev, &hcg->gc, hcg); in creg_gpio_probe()