Received: by 10.192.165.148 with SMTP id m20csp347913imm; Thu, 3 May 2018 22:01:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo8Hjb3RnKmzaVsA1FSzRkYWKen5hkUBUkjZbZnuff6WCUwwIr37kVlEBq8Zugt8waqQTuV X-Received: by 2002:a17:902:28ab:: with SMTP id f40-v6mr26465481plb.208.1525410114197; Thu, 03 May 2018 22:01:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525410114; cv=none; d=google.com; s=arc-20160816; b=Hrst6p4+eC2NF4FovoC04kLyBDFRKry6237XQZJxIWUG3a8nodJX4mTczEsijnLMAd CZaMek4Hr5jdYlUYNwV7bvUFI0JDX/u8rv/oFq/S9s2Q1r9FXuiC451VOhQUt8XyE7PX 8d+FYoR0do72dVLPxgHwGLopC0nMS6oyB89cXhmTy+qan8vIGcI53FDGxDmZT0+xDXJI lY/VrnKS2VDU+7SQI7gkJlPGTZjxSfCwWysWiTQDCNFwIKMRe++l7mx5lh/DQZnCOB00 JC2ri4qbxohOMI8EUN9XbdlWbIHJqZI8YcJOOcV4I5ceSRzn8J3ywD7uQ8rUS9t4nlxR wbVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:cc:subject:date:to :from:arc-authentication-results; bh=NxEdgfNZbWZ1zJht4iaE++8NhWNxTIBAPVxgiaxaCQQ=; b=F1rtCP3iADrFJMJVOIg8+33FUg907w1j2byfxBQDKIIS6tDVqhvuEFUaWeCZnJ+95v H2B8mnG1yavHv1OsxdoMFx/hcORL9L18j8XAuGbaX4rsr+Ff9+NpgV07MJtaZ+WBkqqM 56FZwdgIJTayD4uMKa1Cdu+nhVa+ym+cKb7qWNSOk3ZGxCLZqoWaZKxPuqbIe0ikLFG9 JXiKocS0Qwc19OOq+J7UaJ+aoy9c3VnaNB9oW9zMg7aSgri6EeOO6q5loZPTQs8zjm4n lnvLtqSkiwWgEPftWY+ySvxsZCWW0TRGk1UixrTusMUVQwFJgJu4gWRgGlTar3d6qGE/ SxTw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 14-v6si14910389ple.450.2018.05.03.22.01.40; Thu, 03 May 2018 22:01:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751401AbeEDFBG (ORCPT + 99 others); Fri, 4 May 2018 01:01:06 -0400 Received: from mx2.suse.de ([195.135.220.15]:48356 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750820AbeEDFBE (ORCPT ); Fri, 4 May 2018 01:01:04 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id EF66EABE9; Fri, 4 May 2018 05:01:02 +0000 (UTC) From: NeilBrown To: Greg Kroah-Hartman Date: Fri, 04 May 2018 14:58:36 +1000 Subject: [PATCH 3/8] staging: mt7621-pci: improve interrupt mapping Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Message-ID: <152540991599.12190.16303092955078809939.stgit@noble> In-Reply-To: <152540982998.12190.15220622955317261586.stgit@noble> References: <152540982998.12190.15220622955317261586.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As the Interrupts for the PCI adapters are listed in devicetree we shouldn't need to have them explicit in the code. The simplest way to do this is to use of_irq_parse_and_map_pci() and specify an interrupt-map which identifies the different PCI hosts by bus/slot numbers. This has the advantage that the hwirq number are mapped to virq numbers for us, so the ugly hack can go. Signed-off-by: NeilBrown --- drivers/staging/mt7621-dts/mt7621.dtsi | 9 ++- drivers/staging/mt7621-pci/pci-mt7621.c | 90 +++---------------------------- 2 files changed, 14 insertions(+), 85 deletions(-) diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi b/drivers/staging/mt7621-dts/mt7621.dtsi index ebcaa8b1fc81..9d941b531712 100644 --- a/drivers/staging/mt7621-dts/mt7621.dtsi +++ b/drivers/staging/mt7621-dts/mt7621.dtsi @@ -429,10 +429,11 @@ 0x01000000 0 0x00000000 0x1e160000 0 0x00010000 /* io space */ >; - interrupt-parent = <&gic>; - interrupts = ; + #interrupt-cells = <1>; + interrupt-map-mask = <0xF0000 0 0 1>; + interrupt-map = <0x10000 0 0 1 &gic GIC_SHARED 4 IRQ_TYPE_LEVEL_HIGH>, + <0x20000 0 0 1 &gic GIC_SHARED 24 IRQ_TYPE_LEVEL_HIGH>, + <0x30000 0 0 1 &gic GIC_SHARED 25 IRQ_TYPE_LEVEL_HIGH>; status = "disabled"; diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index c49442c9b187..cc89d464ef7f 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -73,12 +73,6 @@ extern void chk_phy_pll(void); #define RALINK_PCI_CONFIG_ADDR 0x20 #define RALINK_PCI_CONFIG_DATA_VIRTUAL_REG 0x24 -#define SURFBOARDINT_PCIE0 11 /* PCIE0 */ -#define RALINK_INT_PCIE0 SURFBOARDINT_PCIE0 -#define RALINK_INT_PCIE1 SURFBOARDINT_PCIE1 -#define RALINK_INT_PCIE2 SURFBOARDINT_PCIE2 -#define SURFBOARDINT_PCIE1 31 /* PCIE1 */ -#define SURFBOARDINT_PCIE2 32 /* PCIE2 */ #define RALINK_PCI_MEMBASE *(volatile u32 *)(RALINK_PCI_BASE + 0x0028) #define RALINK_PCI_IOBASE *(volatile u32 *)(RALINK_PCI_BASE + 0x002C) #define RALINK_PCIE0_RST (1<<24) @@ -367,68 +361,12 @@ pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) { u16 cmd; u32 val; - int irq = 0; - - if ((dev->bus->number == 0) && (slot == 0)) { - write_config(0, 0, 0, PCI_BASE_ADDRESS_0, MEMORY_BASE); - read_config(0, 0, 0, PCI_BASE_ADDRESS_0, (unsigned long *)&val); - printk("BAR0 at slot 0 = %x\n", val); - printk("bus=0x%x, slot = 0x%x\n",dev->bus->number, slot); - } else if((dev->bus->number == 0) && (slot == 0x1)) { - write_config(0, 1, 0, PCI_BASE_ADDRESS_0, MEMORY_BASE); - read_config(0, 1, 0, PCI_BASE_ADDRESS_0, (unsigned long *)&val); - printk("BAR0 at slot 1 = %x\n", val); - printk("bus=0x%x, slot = 0x%x\n",dev->bus->number, slot); - } else if((dev->bus->number == 0) && (slot == 0x2)) { - write_config(0, 2, 0, PCI_BASE_ADDRESS_0, MEMORY_BASE); - read_config(0, 2, 0, PCI_BASE_ADDRESS_0, (unsigned long *)&val); - printk("BAR0 at slot 2 = %x\n", val); - printk("bus=0x%x, slot = 0x%x\n",dev->bus->number, slot); - } else if ((dev->bus->number == 1) && (slot == 0x0)) { - switch (pcie_link_status) { - case 2: - case 6: - irq = RALINK_INT_PCIE1; - break; - case 4: - irq = RALINK_INT_PCIE2; - break; - default: - irq = RALINK_INT_PCIE0; - } - printk("bus=0x%x, slot = 0x%x, irq=0x%x\n",dev->bus->number, slot, dev->irq); - } else if ((dev->bus->number == 2) && (slot == 0x0)) { - switch (pcie_link_status) { - case 5: - case 6: - irq = RALINK_INT_PCIE2; - break; - default: - irq = RALINK_INT_PCIE1; - } - printk("bus=0x%x, slot = 0x%x, irq=0x%x\n",dev->bus->number, slot, dev->irq); - } else if ((dev->bus->number == 2) && (slot == 0x1)) { - switch (pcie_link_status) { - case 5: - case 6: - irq = RALINK_INT_PCIE2; - break; - default: - irq = RALINK_INT_PCIE1; - } - printk("bus=0x%x, slot = 0x%x, irq=0x%x\n",dev->bus->number, slot, dev->irq); - } else if ((dev->bus->number ==3) && (slot == 0x0)) { - irq = RALINK_INT_PCIE2; - printk("bus=0x%x, slot = 0x%x, irq=0x%x\n",dev->bus->number, slot, dev->irq); - } else if ((dev->bus->number ==3) && (slot == 0x1)) { - irq = RALINK_INT_PCIE2; - printk("bus=0x%x, slot = 0x%x, irq=0x%x\n",dev->bus->number, slot, dev->irq); - } else if ((dev->bus->number ==3) && (slot == 0x2)) { - irq = RALINK_INT_PCIE2; - printk("bus=0x%x, slot = 0x%x, irq=0x%x\n",dev->bus->number, slot, dev->irq); - } else { - printk("bus=0x%x, slot = 0x%x\n",dev->bus->number, slot); - return 0; + int irq; + + if (dev->bus->number == 0) { + write_config(0, slot, 0, PCI_BASE_ADDRESS_0, MEMORY_BASE); + read_config(0, slot, 0, PCI_BASE_ADDRESS_0, (unsigned long *)&val); + printk("BAR0 at slot %d = %x\n", slot, val); } pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 0x14); //configure cache line size 0x14 @@ -436,20 +374,10 @@ pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) pci_read_config_word(dev, PCI_COMMAND, &cmd); cmd = cmd | PCI_COMMAND_MASTER | PCI_COMMAND_IO | PCI_COMMAND_MEMORY; pci_write_config_word(dev, PCI_COMMAND, cmd); + + irq = of_irq_parse_and_map_pci(dev, slot, pin); + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); -#ifdef CONFIG_DTB_GNUBEE1 - /* - * 'irq' here is a hwirq, but a virq is needed. Until we know how and where - * to convert one to the other, we have this hack for the GNUBEE1 - * Similarly 31->23 and 32->24. - */ - if (irq == 11) - return 22; - if (irq == 31) - return 23; - if (irq == 32) - return 24; -#endif return irq; }