/* * The hardware uses 3 bits to indicate interrupt "style". * we clear and set these three bits accordingly. The lower 24 * bits in two registers (GPIT1 and GPIT2) are used to set up * the style for 8 lines each for a total of 16 GPIO lines.
*/ #define IXP4XX_GPIO_STYLE_ACTIVE_HIGH 0x0 #define IXP4XX_GPIO_STYLE_ACTIVE_LOW 0x1 #define IXP4XX_GPIO_STYLE_RISING_EDGE 0x2 #define IXP4XX_GPIO_STYLE_FALLING_EDGE 0x3 #define IXP4XX_GPIO_STYLE_TRANSITIONAL 0x4 #define IXP4XX_GPIO_STYLE_MASK GENMASK(2, 0) #define IXP4XX_GPIO_STYLE_SIZE 3
/* Clear the style for the appropriate pin */
val = __raw_readl(g->base + int_reg);
val &= ~(IXP4XX_GPIO_STYLE_MASK << (line * IXP4XX_GPIO_STYLE_SIZE));
__raw_writel(val, g->base + int_reg);
/* Set the new style */
val = __raw_readl(g->base + int_reg);
val |= (int_style << (line * IXP4XX_GPIO_STYLE_SIZE));
__raw_writel(val, g->base + int_reg);
/* Force-configure this line as an input */
val = __raw_readl(g->base + IXP4XX_REG_GPOE);
val |= BIT(d->hwirq);
__raw_writel(val, g->base + IXP4XX_REG_GPOE);
staticint ixp4xx_gpio_child_to_parent_hwirq(struct gpio_chip *gc, unsignedint child, unsignedint child_type, unsignedint *parent, unsignedint *parent_type)
{ /* All these interrupts are level high in the CPU */
*parent_type = IRQ_TYPE_LEVEL_HIGH;
g = devm_kzalloc(dev, sizeof(*g), GFP_KERNEL); if (!g) return -ENOMEM;
g->dev = dev;
g->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(g->base)) return PTR_ERR(g->base);
irq_parent = of_irq_find_parent(np); if (!irq_parent) {
dev_err(dev, "no IRQ parent node\n"); return -ENODEV;
}
parent = irq_find_host(irq_parent); if (!parent) {
dev_err(dev, "no IRQ parent domain\n"); return -ENODEV;
}
/* * If either clock output is enabled explicitly in the device tree * we take full control of the clock by masking off all bits for * the clock control and selectively enabling them. Otherwise * we leave the hardware default settings. * * Enable clock outputs with default timings of requested clock. * If you need control over TC and DC, add these to the device * tree bindings and use them here.
*/
clk_14 = of_property_read_bool(np, "intel,ixp4xx-gpio14-clkout");
clk_15 = of_property_read_bool(np, "intel,ixp4xx-gpio15-clkout");
/* * Make sure GPIO 14 and 15 are NOT used as clocks but GPIO on * specific machines.
*/ if (of_machine_is_compatible("dlink,dsm-g600-a") ||
of_machine_is_compatible("iom,nas-100d"))
val = 0; else {
val = __raw_readl(g->base + IXP4XX_REG_GPCLK);
if (clk_14 || clk_15) {
val &= ~(IXP4XX_GPCLK_MUX14 | IXP4XX_GPCLK_MUX15);
val &= ~IXP4XX_GPCLK_CLK0_MASK;
val &= ~IXP4XX_GPCLK_CLK1_MASK; if (clk_14) { /* IXP4XX_GPCLK_CLK0DC implicit low */
val |= (1 << IXP4XX_GPCLK_CLK0TC_SHIFT);
val |= IXP4XX_GPCLK_MUX14;
}
if (clk_15) { /* IXP4XX_GPCLK_CLK1DC implicit low */
val |= (1 << IXP4XX_GPCLK_CLK1TC_SHIFT);
val |= IXP4XX_GPCLK_MUX15;
}
}
}
__raw_writel(val, g->base + IXP4XX_REG_GPCLK);
/* * This is a very special big-endian ARM issue: when the IXP4xx is * run in big endian mode, all registers in the machine are switched * around to the CPU-native endianness. As you see mostly in the * driver we use __raw_readl()/__raw_writel() to access the registers * in the appropriate order. With the GPIO library we need to specify * byte order explicitly, so this flag needs to be set when compiling * for big endian.
*/ #ifdefined(CONFIG_CPU_BIG_ENDIAN)
flags = BGPIOF_BIG_ENDIAN_BYTE_ORDER; #else
flags = 0; #endif
/* Populate and register gpio chip */
ret = bgpio_init(&g->gc, dev, 4,
g->base + IXP4XX_REG_GPIN,
g->base + IXP4XX_REG_GPOUT,
NULL,
NULL,
g->base + IXP4XX_REG_GPOE,
flags); if (ret) {
dev_err(dev, "unable to init generic GPIO\n"); return ret;
}
g->gc.ngpio = 16;
g->gc.label = "IXP4XX_GPIO_CHIP"; /* * TODO: when we have migrated to device tree and all GPIOs * are fetched using phandles, set this to -1 to get rid of * the fixed gpiochip base.
*/
g->gc.base = 0;
g->gc.parent = &pdev->dev;
g->gc.owner = THIS_MODULE;
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.