val = gpiod_get_value(pin->gpiod); if (val)
pinmap_set(pin->pdata->regs, pin->value_mask); else
pinmap_unset(pin->pdata->regs, pin->value_mask);
}
/* * Interrupt from override register, propagate from override bit * to GPIO.
*/ static irqreturn_t brcmstb_usb_pinmap_ovr_isr(int irq, void *dev_id)
{ struct brcmstb_usb_pinmap_data *pdata = dev_id; struct out_pin *pout;
u32 val;
u32 bit; int x;
pr_debug("%s: reg: 0x%x\n", __func__, readl(pdata->regs));
pout = pdata->out_pins; for (x = 0; x < pdata->out_count; x++) {
val = readl(pdata->regs); if (val & pout->changed_mask) {
pinmap_set(pdata->regs, pout->clr_changed_mask);
pinmap_unset(pdata->regs, pout->clr_changed_mask);
bit = val & pout->value_mask;
gpiod_set_value(pout->gpiod, bit ? 1 : 0);
pr_debug("%s: %s bit changed state to %d\n",
__func__, pout->name, bit ? 1 : 0);
}
} return IRQ_HANDLED;
}
/* * Interrupt from GPIO, propagate from GPIO to override bit.
*/ static irqreturn_t brcmstb_usb_pinmap_gpio_isr(int irq, void *dev_id)
{ struct in_pin *pin = dev_id;
staticvoid get_pin_counts(struct device_node *dn, int *in_count, int *out_count)
{ int in; int out;
*in_count = 0;
*out_count = 0;
in = of_property_count_strings(dn, "brcm,in-functions"); if (in < 0) return;
out = of_property_count_strings(dn, "brcm,out-functions"); if (out < 0) return;
*in_count = in;
*out_count = out;
}
staticint parse_pins(struct device *dev, struct device_node *dn, struct brcmstb_usb_pinmap_data *pdata)
{ struct out_pin *pout; struct in_pin *pin; int index; int res; int x;
pin = pdata->in_pins; for (x = 0, index = 0; x < pdata->in_count; x++) {
pin->gpiod = devm_gpiod_get_index(dev, "in", x, GPIOD_IN); if (IS_ERR(pin->gpiod)) {
dev_err(dev, "Error getting gpio %s\n", pin->name); return PTR_ERR(pin->gpiod);
}
res = of_property_read_string_index(dn, "brcm,in-functions", x,
&pin->name); if (res < 0) {
dev_err(dev, "Error getting brcm,in-functions for %s\n",
pin->name); return res;
}
res = of_property_read_u32_index(dn, "brcm,in-masks", index++,
&pin->enable_mask); if (res < 0) {
dev_err(dev, "Error getting 1st brcm,in-masks for %s\n",
pin->name); return res;
}
res = of_property_read_u32_index(dn, "brcm,in-masks", index++,
&pin->value_mask); if (res < 0) {
dev_err(dev, "Error getting 2nd brcm,in-masks for %s\n",
pin->name); return res;
}
pin->pdata = pdata;
pin++;
}
pout = pdata->out_pins; for (x = 0, index = 0; x < pdata->out_count; x++) {
pout->gpiod = devm_gpiod_get_index(dev, "out", x,
GPIOD_OUT_HIGH); if (IS_ERR(pout->gpiod)) {
dev_err(dev, "Error getting gpio %s\n", pin->name); return PTR_ERR(pout->gpiod);
}
res = of_property_read_string_index(dn, "brcm,out-functions", x,
&pout->name); if (res < 0) {
dev_err(dev, "Error getting brcm,out-functions for %s\n",
pout->name); return res;
}
res = of_property_read_u32_index(dn, "brcm,out-masks", index++,
&pout->enable_mask); if (res < 0) {
dev_err(dev, "Error getting 1st brcm,out-masks for %s\n",
pout->name); return res;
}
res = of_property_read_u32_index(dn, "brcm,out-masks", index++,
&pout->value_mask); if (res < 0) {
dev_err(dev, "Error getting 2nd brcm,out-masks for %s\n",
pout->name); return res;
}
res = of_property_read_u32_index(dn, "brcm,out-masks", index++,
&pout->changed_mask); if (res < 0) {
dev_err(dev, "Error getting 3rd brcm,out-masks for %s\n",
pout->name); return res;
}
res = of_property_read_u32_index(dn, "brcm,out-masks", index++,
&pout->clr_changed_mask); if (res < 0) {
dev_err(dev, "Error getting 4th out-masks for %s\n",
pout->name); return res;
}
pout++;
} return 0;
}
staticvoid sync_all_pins(struct brcmstb_usb_pinmap_data *pdata)
{ struct out_pin *pout; struct in_pin *pin; int val; int x;
/* * Enable the override, clear any changed condition and * propagate the state to the GPIO for all out pins.
*/
pout = pdata->out_pins; for (x = 0; x < pdata->out_count; x++) {
pinmap_set(pdata->regs, pout->enable_mask);
pinmap_set(pdata->regs, pout->clr_changed_mask);
pinmap_unset(pdata->regs, pout->clr_changed_mask);
val = readl(pdata->regs) & pout->value_mask;
gpiod_set_value(pout->gpiod, val ? 1 : 0);
pout++;
}
/* sync and enable all in pins. */
pin = pdata->in_pins; for (x = 0; x < pdata->in_count; x++) {
sync_in_pin(pin);
pinmap_set(pdata->regs, pin->enable_mask);
pin++;
}
}
staticint __init brcmstb_usb_pinmap_probe(struct platform_device *pdev)
{ struct device_node *dn = pdev->dev.of_node; struct brcmstb_usb_pinmap_data *pdata; struct in_pin *pin; struct resource *r; int out_count; int in_count; int err; int irq; int x;
module_init(brcmstb_usb_pinmap_init);
MODULE_AUTHOR("Al Cooper <alcooperx@gmail.com>");
MODULE_DESCRIPTION("Broadcom USB Pinmap Driver");
MODULE_LICENSE("GPL");
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-04-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.