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