-static int ipic_set_irq_type(unsigned int virq, unsigned int flow_type)
-{
- struct ipic *ipic = ipic_from_irq(virq);
- unsigned int src = ipic_irq_to_hw(virq);
- struct irq_desc *desc = get_irq_desc(virq);
- unsigned int vold, vnew, edibit;
-
- if (flow_type == IRQ_TYPE_NONE)
- flow_type = IRQ_TYPE_LEVEL_LOW;
-
- /* ipic supports only low assertion and high-to-low change senses
- */
- if (!(flow_type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_EDGE_FALLING))) {
- printk(KERN_ERR "ipic: sense type 0x%x not supported\n",
- flow_type);
- return -EINVAL;
- }
-
- desc->status &= ~(IRQ_TYPE_SENSE_MASK | IRQ_LEVEL);
- desc->status |= flow_type & IRQ_TYPE_SENSE_MASK;
- if (flow_type & IRQ_TYPE_LEVEL_LOW) {
- desc->status |= IRQ_LEVEL;
- set_irq_handler(virq, handle_level_irq);
- } else {
- set_irq_handler(virq, handle_edge_irq);
- }
-
- /* only EXT IRQ senses are programmable on ipic
- * internal IRQ senses are LEVEL_LOW
- */
- if (src == IPIC_IRQ_EXT0)
- edibit = 15;
- else
- if (src >= IPIC_IRQ_EXT1 && src <= IPIC_IRQ_EXT7)
- edibit = (14 - (src - IPIC_IRQ_EXT1));
- else
- return (flow_type & IRQ_TYPE_LEVEL_LOW) ? 0 : -EINVAL;
-
- vold = ipic_read(ipic->regs, IPIC_SECNR);
- if ((flow_type & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_FALLING) {
- vnew = vold | (1 << edibit);
- } else {
- vnew = vold & ~(1 << edibit);
- }
- if (vold != vnew)
- ipic_write(ipic->regs, IPIC_SECNR, vnew);
- return 0;
-}
-
-static struct irq_chip ipic_irq_chip = {
- .typename = " IPIC ",
- .unmask = ipic_unmask_irq,
- .mask = ipic_mask_irq,
- .mask_ack = ipic_mask_irq_and_ack,
- .ack = ipic_ack_irq,
- .set_type = ipic_set_irq_type,
-};
-
-static int ipic_host_match(struct irq_host *h, struct device_node *node)
-{
- struct ipic *ipic = h->host_data;
-
- /* Exact match, unless ipic node is NULL */
- return ipic->of_node == NULL || ipic->of_node == node;
-}
-
-static int ipic_host_map(struct irq_host *h, unsigned int virq,
- irq_hw_number_t hw)
-{
- struct ipic *ipic = h->host_data;
- struct irq_chip *chip;
-
- /* Default chip */
- chip = &ipic->hc_irq;
-
- set_irq_chip_data(virq, ipic);
- set_irq_chip_and_handler(virq, chip, handle_level_irq);
-
- /* Set default irq type */
- set_irq_type(virq, IRQ_TYPE_NONE);
-
- return 0;
-}
-
-static int ipic_host_xlate(struct irq_host *h, struct device_node *ct,
- u32 *intspec, unsigned int intsize,
- irq_hw_number_t *out_hwirq, unsigned int *out_flags)
-
-{
- /* interrupt sense values coming from the device tree equal either
- * LEVEL_LOW (low assertion) or EDGE_FALLING (high-to-low change)
- */
- *out_hwirq = intspec[0];
- if (intsize > 1)
- *out_flags = intspec[1];
- else
- *out_flags = IRQ_TYPE_NONE;
- return 0;
-}
-
-static struct irq_host_ops ipic_host_ops = {
- .match = ipic_host_match,
- .map = ipic_host_map,
- .xlate = ipic_host_xlate,