Path: blob/master/arch/powerpc/platforms/pseries/event_sources.c
10818 views
/*1* Copyright (C) 2001 Dave Engebretsen IBM Corporation2*3* This program is free software; you can redistribute it and/or modify4* it under the terms of the GNU General Public License as published by5* the Free Software Foundation; either version 2 of the License, or6* (at your option) any later version.7*8* This program is distributed in the hope that it will be useful,9* but WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11* GNU General Public License for more details.12*13* You should have received a copy of the GNU General Public License14* along with this program; if not, write to the Free Software15* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA16*/1718#include <asm/prom.h>1920#include "pseries.h"2122void request_event_sources_irqs(struct device_node *np,23irq_handler_t handler,24const char *name)25{26int i, index, count = 0;27struct of_irq oirq;28const u32 *opicprop;29unsigned int opicplen;30unsigned int virqs[16];3132/* Check for obsolete "open-pic-interrupt" property. If present, then33* map those interrupts using the default interrupt host and default34* trigger35*/36opicprop = of_get_property(np, "open-pic-interrupt", &opicplen);37if (opicprop) {38opicplen /= sizeof(u32);39for (i = 0; i < opicplen; i++) {40if (count > 15)41break;42virqs[count] = irq_create_mapping(NULL, *(opicprop++));43if (virqs[count] == NO_IRQ) {44pr_err("event-sources: Unable to allocate "45"interrupt number for %s\n",46np->full_name);47WARN_ON(1);48}49else50count++;5152}53}54/* Else use normal interrupt tree parsing */55else {56/* First try to do a proper OF tree parsing */57for (index = 0; of_irq_map_one(np, index, &oirq) == 0;58index++) {59if (count > 15)60break;61virqs[count] = irq_create_of_mapping(oirq.controller,62oirq.specifier,63oirq.size);64if (virqs[count] == NO_IRQ) {65pr_err("event-sources: Unable to allocate "66"interrupt number for %s\n",67np->full_name);68WARN_ON(1);69}70else71count++;72}73}7475/* Now request them */76for (i = 0; i < count; i++) {77if (request_irq(virqs[i], handler, 0, name, NULL)) {78pr_err("event-sources: Unable to request interrupt "79"%d for %s\n", virqs[i], np->full_name);80WARN_ON(1);81return;82}83}84}85868788