sparc,leon: support for GRPCI1 PCI host bridge controller
PATCH 1/1 sparc,leon: support for GRPCI1 PCI host bridge controller
Some of the GRPCI1 cores does not support detection of all PCI errors, the default is therefore limited PCI error handling. The property all_pci_errors my be set by the boot loader to enable interrupt on all PCI errors.
--- arch/sparc/Kconfig | 11 + arch/sparc/kernel/Makefile | 1 + arch/sparc/kernel/leon_pci_grpci1.c | 725 +++++++++++++++++++++++++++++++++++ 3 files changed, 737 insertions(+), 0 deletions(-) create mode 100644 arch/sparc/kernel/leon_pci_grpci1.c
arch/sparc/Kconfig +11 -0
@@ -500,6 +500,17 @@ config LEON_PCI depends on PCI && SPARC_LEON default y +config GRPCI1 + bool "GRPCI Host Bridge Support" + depends on LEON_PCI + default y + help + Say Y here to include the GRPCI Host Bridge Driver. The GRPCI + PCI host controller is typically found in GRLIB SPARC32/LEON + systems. The driver has one property (all_pci_errors) controlled + from the bootloader that makes the GRPCI to generate interrupts + on detected PCI Parity and System errors. + config GRPCI2 bool "GRPCI2 Host Bridge Support" depends on LEON_PCI
arch/sparc/kernel/Makefile +1 -0
@@ -75,6 +75,7 @@ obj-y += dma.o obj-$(CONFIG_PCIC_PCI) += pcic.o obj-$(CONFIG_LEON_PCI) += leon_pci.o obj-$(CONFIG_GRPCI2) += leon_pci_grpci2.o +obj-$(CONFIG_GRPCI1) += leon_pci_grpci1.o obj-$(CONFIG_SMP) += trampoline_$(BITS).o smp_$(BITS).o obj-$(CONFIG_SPARC32_SMP) += sun4m_smp.o sun4d_smp.o leon_smp.o
arch/sparc/kernel/leon_pci_grpci1.c new file +725 -0
725 lines not on this page · raw message
Signature · 1 line
1.7.0.4
Hi Daniel.
some nitpicks.
Quoted 18 lines · Daniel Hellstrom
Some of the GRPCI1 cores does not support detection of all PCI errors, the default is therefore limited PCI error handling. The property
all_pci_errorsmy be set by the boot loader to enable interrupt on all PCI errors.Signed-off-by Daniel Hellstrom <[email protected]>--- arch/sparc/Kconfig | 11 + arch/sparc/kernel/Makefile | 1 + arch/sparc/kernel/leon_pci_grpci1.c | 725 +++++++++++++++++++++++++++++++++++ 3 files changed, 737 insertions(+), 0 deletions(-) create mode 100644 arch/sparc/kernel/leon_pci_grpci1.carch/sparc/Kconfig +0
-0
arch/sparc/Kconfig config LEON_PCI · line 503
Quoted 4 lines
arch/sparc/Kconfig +1
-0@@ -500,6 +500,17 @@ config LEON_PCI depends on PCI && SPARC_LEON default y +config GRPCI1
I see we do not do so with GRPCI2 - but please prefix all SPARC specific kconfig symbols with SPARC_
A follow-up patch that fixes GRPCI2 would be nice!
Quoted 13 lines
arch/sparc/kernel/leon_pci_grpci1.c new file +7
-0@@ -0,0 +1,725 @@ +/* +* leon_pci_grpci1.c: GRPCI1 Host PCI driver +* +* Copyright (C) 2013 Aeroflex Gaisler AB +* +* This GRPCI1 driver does not support PCI interrupts taken from +* GPIO pins.
arch/sparc/kernel/leon_pci_grpci1.c line 17
Quoted 10 lines
arch/sparc/kernel/leon_pci_grpci1.c new file +10
-0+* +* Contributors: Daniel Hellstrom <[email protected]> +*/ + +#include <linux/of_device.h> +#include <linux/kernel.h> +#include <linux/pci.h> +#include <linux/delay.h> +#include <linux/export.h> +#include <linux/of_irq.h>
Sort using inverse christmas tree.
Longest lines at top - equal length lines alphabetically. And add an empty line between <linux/...> and <asm/...> includes.
Quoted 59 lines
arch/sparc/kernel/leon_pci_grpci1.c new file +59
-0+#include <asm/io.h> +#include <asm/leon.h> +#include <asm/vaddrs.h> +#include <asm/sections.h> +#include <asm/leon_pci.h> + +#include "irq.h" + +/* Enable/Disable Debugging Configuration Space Access */ +#undef GRPCI1_DEBUG_CFGACCESS + +/* +* GRPCI1 APB Register MAP +*/ +struct grpci1_regs { +unsigned int cfg_stat;/* 0x00 Configuration / Status */ +unsigned int bar0;/* 0x04 BAR0 (RO) */ +unsigned int page0;/* 0x08 PAGE0 (RO) */ +unsigned int bar1;/* 0x0C BAR1 (RO) */ +unsigned int page1;/* 0x10 PAGE1 */ +unsigned int iomap;/* 0x14 IO Map */ +unsigned int stat_cmd;/* 0x18 PCI Status & Command (RO) */ +unsigned int irq;/* 0x1C Interrupt register */ +}; + +#define REGLOAD (a) (be32_to_cpu(__raw_readl(&(a)))) +#define REGSTORE (a, v) (__raw_writel(cpu_to_be32(v), &(a))) + +#define PAGE0_BTEN_BIT 0 +#define PAGE0_BTEN (1 << PAGE0_BTEN_BIT) + +#define CFGSTAT_HOST_BIT 13 +#define CFGSTAT_CTO_BIT 8 +#define CFGSTAT_HOST (1 << CFGSTAT_HOST_BIT) +#define CFGSTAT_CTO (1 << CFGSTAT_CTO_BIT) + +#define IRQ_DPE (1 << 9) +#define IRQ_SSE (1 << 8) +#define IRQ_RMA (1 << 7) +#define IRQ_RTA (1 << 6) +#define IRQ_STA (1 << 5) +#define IRQ_DPED (1 << 4) +#define IRQ_INTD (1 << 3) +#define IRQ_INTC (1 << 2) +#define IRQ_INTB (1 << 1) +#define IRQ_INTA (1 << 0) +#define IRQ_DEF_ERRORS (IRQ_RMA | IRQ_RTA | IRQ_STA) +#define IRQ_ALL_ERRORS (IRQ_DPED | IRQ_DEF_ERRORS | IRQ_SSE | IRQ_DPE) +#define IRQ_INTX (IRQ_INTA | IRQ_INTB | IRQ_INTC | IRQ_INTD) +#define IRQ_MASK_BIT 16 + +#define DEF_PCI_ERRORS (PCI_STATUS_SIG_TARGET_ABORT | \ + PCI_STATUS_REC_TARGET_ABORT | \ + PCI_STATUS_REC_MASTER_ABORT) +#define ALL_PCI_ERRORS (PCI_STATUS_PARITY | PCI_STATUS_DETECTED_PARITY | \ + PCI_STATUS_SIG_SYSTEM_ERROR | DEF_PCI_ERRORS) + +#define TGT 256 +
arch/sparc/kernel/leon_pci_grpci1.c line 86
Quoted 10 lines
arch/sparc/kernel/leon_pci_grpci1.c new file +10
-0+struct grpci1_priv { +struct leon_pci_info info;/* must be on top of this structure */ +struct grpci1_regs *regs; +struct device *dev; +int pci_err_mask; +int irq; +unsigned char irq_map[4 ]; + +/* Virtual IRQ numbers */ +unsigned int virq_err;
In all new code I add I use "irq" for the irq numbers. This mathces the generic irq code.
But I know that a lot of sparc code uses virq.
arch/sparc/kernel/leon_pci_grpci1.c line 98
Quoted 11 lines
arch/sparc/kernel/leon_pci_grpci1.c new file +11
-0+/* AHB PCI Windows */ +unsigned long pci_area;/* MEMORY */ +unsigned long pci_area_end; +unsigned long pci_io;/* I/O */ +unsigned long pci_conf;/* CONFIGURATION */ +unsigned long pci_conf_end; +unsigned long pci_io_va; +}; + +DEFINE_SPINLOCK (grpci1_dev_lock); +struct grpci1_priv *grpci1priv;
static?
Sam
Hi Sam,
Thanks for your input. I will update my patch, please see below
Quoted 26 lines · Sam Ravnborg
Hi Daniel.
some nitpicks.
Quoted 21 lines · Daniel Hellstrom
Some of the GRPCI1 cores does not support detection of all PCI errors, the default is therefore limited PCI error handling. The property
all_pci_errorsmy be set by the boot loader to enable interrupt on all PCI errors.Signed-off-by Daniel Hellstrom <[email protected]>--- arch/sparc/Kconfig | 11 + arch/sparc/kernel/Makefile | 1 + arch/sparc/kernel/leon_pci_grpci1.c | 725 +++++++++++++++++++++++++++++++++++ 3 files changed, 737 insertions(+), 0 deletions(-)create mode 100644
arch/sparc/kernel/leon_pci_grpci1.carch/sparc/Kconfig +0
-0@@ -500,6 +500,17 @@ config LEON_PCI depends on PCI && SPARC_LEON default y
Quoted 3 lines
arch/sparc/Kconfig config LEON_PCI · line 503
Quoted 1 line
arch/sparc/Kconfig +1
-0+config GRPCI1I see we do not do so with GRPCI2 - but please prefix all SPARC specific kconfig symbols with
SPARC_
I can only see SPARC_LED and SPARC_LEON in arch/sparc/Kconfig following that naming convention. Would it be more correct to call it LEON_GRPCI1? I see there are some SUN_ and US3_ names.
Quoted 2 lines
A follow-up patch that fixes GRPCI2 would be nice!
I can do that, if we establish what is appropriate.
Quoted 18 lines
Quoted 18 lines
arch/sparc/kernel/leon_pci_grpci1.c new file +12
-0@@ -0,0 +1,725 @@ +/* +* leon_pci_grpci1.c: GRPCI1 Host PCI driver +* +* Copyright (C) 2013 Aeroflex Gaisler AB +* +* This GRPCI1 driver does not support PCI interrupts taken from +* GPIO pins. +* +* Contributors: Daniel Hellstrom <[email protected]> +*/ + +#include <linux/of_device.h>
Quoted 8 lines
arch/sparc/kernel/leon_pci_grpci1.c line 17
Quoted 5 lines
arch/sparc/kernel/leon_pci_grpci1.c new file +5
-0+#include <linux/kernel.h> +#include <linux/pci.h> +#include <linux/delay.h> +#include <linux/export.h> +#include <linux/of_irq.h> Sort using inverse christmas tree.
Longest lines at top - equal length lines alphabetically. And add an empty line between <linux/...> and <asm/...> includes.
ok.
Quoted 73 lines
Quoted 60 lines
arch/sparc/kernel/leon_pci_grpci1.c new file +59
-0+#include <asm/io.h> +#include <asm/leon.h> +#include <asm/vaddrs.h> +#include <asm/sections.h> +#include <asm/leon_pci.h> + +#include "irq.h" + +/* Enable/Disable Debugging Configuration Space Access */ +#undef GRPCI1_DEBUG_CFGACCESS + +/* +* GRPCI1 APB Register MAP +*/ +struct grpci1_regs { +unsigned int cfg_stat;/* 0x00 Configuration / Status */ +unsigned int bar0;/* 0x04 BAR0 (RO) */ +unsigned int page0;/* 0x08 PAGE0 (RO) */ +unsigned int bar1;/* 0x0C BAR1 (RO) */ +unsigned int page1;/* 0x10 PAGE1 */ +unsigned int iomap;/* 0x14 IO Map */ +unsigned int stat_cmd;/* 0x18 PCI Status & Command (RO) */ +unsigned int irq;/* 0x1C Interrupt register */ +}; + +#define REGLOAD (a) (be32_to_cpu(__raw_readl(&(a)))) +#define REGSTORE (a, v) (__raw_writel(cpu_to_be32(v), &(a))) + +#define PAGE0_BTEN_BIT 0 +#define PAGE0_BTEN (1 << PAGE0_BTEN_BIT) + +#define CFGSTAT_HOST_BIT 13 +#define CFGSTAT_CTO_BIT 8 +#define CFGSTAT_HOST (1 << CFGSTAT_HOST_BIT) +#define CFGSTAT_CTO (1 << CFGSTAT_CTO_BIT) + +#define IRQ_DPE (1 << 9) +#define IRQ_SSE (1 << 8) +#define IRQ_RMA (1 << 7) +#define IRQ_RTA (1 << 6) +#define IRQ_STA (1 << 5) +#define IRQ_DPED (1 << 4) +#define IRQ_INTD (1 << 3) +#define IRQ_INTC (1 << 2) +#define IRQ_INTB (1 << 1) +#define IRQ_INTA (1 << 0) +#define IRQ_DEF_ERRORS (IRQ_RMA | IRQ_RTA | IRQ_STA) +#define IRQ_ALL_ERRORS (IRQ_DPED | IRQ_DEF_ERRORS | IRQ_SSE | IRQ_DPE) +#define IRQ_INTX (IRQ_INTA | IRQ_INTB | IRQ_INTC | IRQ_INTD) +#define IRQ_MASK_BIT 16 + +#define DEF_PCI_ERRORS (PCI_STATUS_SIG_TARGET_ABORT | \ + PCI_STATUS_REC_TARGET_ABORT | \ + PCI_STATUS_REC_MASTER_ABORT) +#define ALL_PCI_ERRORS (PCI_STATUS_PARITY | PCI_STATUS_DETECTED_PARITY | \ + PCI_STATUS_SIG_SYSTEM_ERROR | DEF_PCI_ERRORS) + +#define TGT 256 +arch/sparc/kernel/leon_pci_grpci1.c line 86
Quoted 10 lines
arch/sparc/kernel/leon_pci_grpci1.c new file +10
-0+struct grpci1_priv { +struct leon_pci_info info;/* must be on top of this structure */ +struct grpci1_regs *regs; +struct device *dev; +int pci_err_mask; +int irq; +unsigned char irq_map[4 ]; + +/* Virtual IRQ numbers */ +unsigned int virq_err;In all new code I add I use "irq" for the irq numbers. This mathces the generic irq code.
Quoted 1 line
But I know that a lot of sparc code uses virq.
ok, I will change to irq_err
Quoted 13 lines
arch/sparc/kernel/leon_pci_grpci1.c line 98
Quoted 12 lines
arch/sparc/kernel/leon_pci_grpci1.c new file +11
-0+/* AHB PCI Windows */ +unsigned long pci_area;/* MEMORY */ +unsigned long pci_area_end; +unsigned long pci_io;/* I/O */ +unsigned long pci_conf;/* CONFIGURATION */ +unsigned long pci_conf_end; +unsigned long pci_io_va; +}; + +DEFINE_SPINLOCK (grpci1_dev_lock); +struct grpci1_priv *grpci1priv;static?
You are correct, I will update.
Thanks,
Daniel
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
default y
+config GRPCI1I see we do not do so with GRPCI2 - but please prefix all SPARC specific kconfig symbols with
SPARC_I can only see
SPARC_LEDandSPARC_LEONinarch/sparc/Kconfigfollowing that naming convention.
Would it be more correct to call itLEON_GRPCI1? I see there are someSUN_andUS3_names.
sparc is not a good example here :-(
For the new architectures I have reviewed recently all their arch specific symbols has been prefixed with the abbreviated arch name.
And sparc specific symbols we add shall follow the same rule.
I may fix up the other sparc specific symbols one day too, but it is low on my todo list.
On the other hand using the name SPARC_LEON_xxx is too specific. We already should know what it is from the SPARC_GRPCI part of the name.
Quoted 3 lines
Quoted 1 line
A follow-up patch that fixes GRPCI2 would be nice!
I can do that, if we establish what is appropriate.
Would be nice - so the GRPCI symbols has consistent names.
Sam
David Miller
maintainerFrom: Sam Ravnborg <[email protected]>
Date: Fri, 1 Mar 2013 19:51:46 +0100
Quoted 12 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
default y
+config GRPCI1I see we do not do so with GRPCI2 - but please prefix all SPARC specific kconfig symbols with
SPARC_I can only see
SPARC_LEDandSPARC_LEONinarch/sparc/Kconfigfollowing that naming convention.
Would it be more correct to call itLEON_GRPCI1? I see there are someSUN_andUS3_names.sparc is not a good example here :-(
For the new architectures I have reviewed recently all their arch specific symbols has been prefixed with the abbreviated arch name.
And sparc specific symbols we add shall follow the same rule.
Quoted 4 lines
I may fix up the other sparc specific symbols one day too, but it is low on my todo list.
On the other hand using the nameSPARC_LEON_xxxis too specific. We already should know what it is from theSPARC_GRPCIpart of the name.
I agree with Sam, prefix all your new Kconfig symbols with SPARC_*, thanks.
Quoted 14 lines · David Miller
From: Sam Ravnborg <[email protected]>
Date: Fri, 1 Mar 2013 19:51:46 +0100Quoted 11 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
default y
+config GRPCI1I see we do not do so with GRPCI2 - but please prefix all SPARC specific kconfig symbols with
SPARC_I can only see
SPARC_LEDandSPARC_LEONinarch/sparc/Kconfigfollowing that naming convention.
Would it be more correct to call itLEON_GRPCI1? I see there are someSUN_andUS3_names.sparc is not a good example here :-(
For the new architectures I have reviewed recently all their arch specific symbols has been prefixed with the abbreviated arch name.
And sparc specific symbols we add shall follow the same rule.
Quoted 5 lines
Quoted 4 lines
I may fix up the other sparc specific symbols one day too, but it is low on my todo list.
On the other hand using the nameSPARC_LEON_xxxis too specific. We already should know what it is from theSPARC_GRPCIpart of the name.I agree with Sam, prefix all your new
Kconfigsymbols with SPARC_*, thanks.
Ok, that makes sense. I will update the two patches and resend.
Thanks,
Daniel