Lines Matching +full:out +full:- +full:functions

1 // SPDX-License-Identifier: GPL-2.0
64 val = gpiod_get_value(pin->gpiod); in sync_in_pin()
66 pinmap_set(pin->pdata->regs, pin->value_mask); in sync_in_pin()
68 pinmap_unset(pin->pdata->regs, pin->value_mask); in sync_in_pin()
83 pr_debug("%s: reg: 0x%x\n", __func__, readl(pdata->regs)); in brcmstb_usb_pinmap_ovr_isr()
84 pout = pdata->out_pins; in brcmstb_usb_pinmap_ovr_isr()
85 for (x = 0; x < pdata->out_count; x++) { in brcmstb_usb_pinmap_ovr_isr()
86 val = readl(pdata->regs); in brcmstb_usb_pinmap_ovr_isr()
87 if (val & pout->changed_mask) { in brcmstb_usb_pinmap_ovr_isr()
88 pinmap_set(pdata->regs, pout->clr_changed_mask); in brcmstb_usb_pinmap_ovr_isr()
89 pinmap_unset(pdata->regs, pout->clr_changed_mask); in brcmstb_usb_pinmap_ovr_isr()
90 bit = val & pout->value_mask; in brcmstb_usb_pinmap_ovr_isr()
91 gpiod_set_value(pout->gpiod, bit ? 1 : 0); in brcmstb_usb_pinmap_ovr_isr()
93 __func__, pout->name, bit ? 1 : 0); in brcmstb_usb_pinmap_ovr_isr()
106 pr_debug("%s: %s pin changed state\n", __func__, pin->name); in brcmstb_usb_pinmap_gpio_isr()
116 int out; in get_pin_counts() local
120 in = of_property_count_strings(dn, "brcm,in-functions"); in get_pin_counts()
123 out = of_property_count_strings(dn, "brcm,out-functions"); in get_pin_counts()
124 if (out < 0) in get_pin_counts()
127 *out_count = out; in get_pin_counts()
139 pin = pdata->in_pins; in parse_pins()
140 for (x = 0, index = 0; x < pdata->in_count; x++) { in parse_pins()
141 pin->gpiod = devm_gpiod_get_index(dev, "in", x, GPIOD_IN); in parse_pins()
142 if (IS_ERR(pin->gpiod)) { in parse_pins()
143 dev_err(dev, "Error getting gpio %s\n", pin->name); in parse_pins()
144 return PTR_ERR(pin->gpiod); in parse_pins()
147 res = of_property_read_string_index(dn, "brcm,in-functions", x, in parse_pins()
148 &pin->name); in parse_pins()
150 dev_err(dev, "Error getting brcm,in-functions for %s\n", in parse_pins()
151 pin->name); in parse_pins()
154 res = of_property_read_u32_index(dn, "brcm,in-masks", index++, in parse_pins()
155 &pin->enable_mask); in parse_pins()
157 dev_err(dev, "Error getting 1st brcm,in-masks for %s\n", in parse_pins()
158 pin->name); in parse_pins()
161 res = of_property_read_u32_index(dn, "brcm,in-masks", index++, in parse_pins()
162 &pin->value_mask); in parse_pins()
164 dev_err(dev, "Error getting 2nd brcm,in-masks for %s\n", in parse_pins()
165 pin->name); in parse_pins()
168 pin->pdata = pdata; in parse_pins()
171 pout = pdata->out_pins; in parse_pins()
172 for (x = 0, index = 0; x < pdata->out_count; x++) { in parse_pins()
173 pout->gpiod = devm_gpiod_get_index(dev, "out", x, in parse_pins()
175 if (IS_ERR(pout->gpiod)) { in parse_pins()
176 dev_err(dev, "Error getting gpio %s\n", pin->name); in parse_pins()
177 return PTR_ERR(pout->gpiod); in parse_pins()
179 res = of_property_read_string_index(dn, "brcm,out-functions", x, in parse_pins()
180 &pout->name); in parse_pins()
182 dev_err(dev, "Error getting brcm,out-functions for %s\n", in parse_pins()
183 pout->name); in parse_pins()
186 res = of_property_read_u32_index(dn, "brcm,out-masks", index++, in parse_pins()
187 &pout->enable_mask); in parse_pins()
189 dev_err(dev, "Error getting 1st brcm,out-masks for %s\n", in parse_pins()
190 pout->name); in parse_pins()
193 res = of_property_read_u32_index(dn, "brcm,out-masks", index++, in parse_pins()
194 &pout->value_mask); in parse_pins()
196 dev_err(dev, "Error getting 2nd brcm,out-masks for %s\n", in parse_pins()
197 pout->name); in parse_pins()
200 res = of_property_read_u32_index(dn, "brcm,out-masks", index++, in parse_pins()
201 &pout->changed_mask); in parse_pins()
203 dev_err(dev, "Error getting 3rd brcm,out-masks for %s\n", in parse_pins()
204 pout->name); in parse_pins()
207 res = of_property_read_u32_index(dn, "brcm,out-masks", index++, in parse_pins()
208 &pout->clr_changed_mask); in parse_pins()
210 dev_err(dev, "Error getting 4th out-masks for %s\n", in parse_pins()
211 pout->name); in parse_pins()
228 * propagate the state to the GPIO for all out pins. in sync_all_pins()
230 pout = pdata->out_pins; in sync_all_pins()
231 for (x = 0; x < pdata->out_count; x++) { in sync_all_pins()
232 pinmap_set(pdata->regs, pout->enable_mask); in sync_all_pins()
233 pinmap_set(pdata->regs, pout->clr_changed_mask); in sync_all_pins()
234 pinmap_unset(pdata->regs, pout->clr_changed_mask); in sync_all_pins()
235 val = readl(pdata->regs) & pout->value_mask; in sync_all_pins()
236 gpiod_set_value(pout->gpiod, val ? 1 : 0); in sync_all_pins()
241 pin = pdata->in_pins; in sync_all_pins()
242 for (x = 0; x < pdata->in_count; x++) { in sync_all_pins()
244 pinmap_set(pdata->regs, pin->enable_mask); in sync_all_pins()
251 struct device_node *dn = pdev->dev.of_node; in brcmstb_usb_pinmap_probe()
263 return -EINVAL; in brcmstb_usb_pinmap_probe()
267 return -EINVAL; in brcmstb_usb_pinmap_probe()
269 pdata = devm_kzalloc(&pdev->dev, in brcmstb_usb_pinmap_probe()
274 return -ENOMEM; in brcmstb_usb_pinmap_probe()
276 pdata->in_count = in_count; in brcmstb_usb_pinmap_probe()
277 pdata->out_count = out_count; in brcmstb_usb_pinmap_probe()
278 pdata->in_pins = (struct in_pin *)(pdata + 1); in brcmstb_usb_pinmap_probe()
279 pdata->out_pins = (struct out_pin *)(pdata->in_pins + in_count); in brcmstb_usb_pinmap_probe()
281 pdata->regs = devm_ioremap(&pdev->dev, r->start, resource_size(r)); in brcmstb_usb_pinmap_probe()
282 if (!pdata->regs) in brcmstb_usb_pinmap_probe()
283 return -ENOMEM; in brcmstb_usb_pinmap_probe()
286 err = parse_pins(&pdev->dev, dn, pdata); in brcmstb_usb_pinmap_probe()
294 /* Enable interrupt for out pins */ in brcmstb_usb_pinmap_probe()
298 err = devm_request_irq(&pdev->dev, irq, in brcmstb_usb_pinmap_probe()
301 pdev->name, pdata); in brcmstb_usb_pinmap_probe()
303 dev_err(&pdev->dev, "Error requesting IRQ\n"); in brcmstb_usb_pinmap_probe()
308 for (x = 0, pin = pdata->in_pins; x < pdata->in_count; x++, pin++) { in brcmstb_usb_pinmap_probe()
309 irq = gpiod_to_irq(pin->gpiod); in brcmstb_usb_pinmap_probe()
311 dev_err(&pdev->dev, "Error getting IRQ for %s pin\n", in brcmstb_usb_pinmap_probe()
312 pin->name); in brcmstb_usb_pinmap_probe()
315 err = devm_request_irq(&pdev->dev, irq, in brcmstb_usb_pinmap_probe()
319 pdev->name, pin); in brcmstb_usb_pinmap_probe()
321 dev_err(&pdev->dev, "Error requesting IRQ for %s pin\n", in brcmstb_usb_pinmap_probe()
322 pin->name); in brcmstb_usb_pinmap_probe()
327 dev_dbg(&pdev->dev, "Driver probe succeeded\n"); in brcmstb_usb_pinmap_probe()
328 dev_dbg(&pdev->dev, "In pin count: %d, out pin count: %d\n", in brcmstb_usb_pinmap_probe()
329 pdata->in_count, pdata->out_count); in brcmstb_usb_pinmap_probe()
335 { .compatible = "brcm,usb-pinmap" },
342 .name = "brcm-usb-pinmap",