powerpc/44x: Fix PCI MSI support for APM821xx SoC and Bluestone board
Subsystems (2)
PATCH 1/2 powerpc/44x: Fix PCI MSI support for APM821xx SoC and Bluestone board
This patch consists of:
- Enable PCI MSI as default for Bluestone board
- Define number of MSI interrupt for Maui APM821xx SoC using in Bluestone board
- Fix returning ENODEV as finding MSI node
- Fix MSI physical high and low address
- Keep MSI data logically
--- arch/powerpc/platforms/44x/Kconfig | 2 ++ arch/powerpc/sysdev/ppc4xx_msi.c | 28 ++++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-)
arch/powerpc/platforms/44x/Kconfig +2 -0
@@ -23,6 +23,8 @@ config BLUESTONE default n select PPC44x_SIMPLE select APM821xx + select PCI_MSI + select PPC4xx_MSI select IBM_EMAC_RGMII help This option enables support for the APM APM821xx Evaluation board.
arch/powerpc/sysdev/ppc4xx_msi.c +18 -10
@@ -31,7 +31,7 @@#include <asm/prom.h> #include <asm/hw_irq.h> #include <asm/ppc-pci.h> -#include <boot/dcr.h> +#include <asm/dcr.h> #include <asm/dcr-regs.h> #include <asm/msi_bitmap.h>
@@ -43,7 +43,12 @@#define PEIH_FLUSH0 0x30#define PEIH_FLUSH1 0x38#define PEIH_CNTRST 0x48 + +#ifdef CONFIG_APM821xx +#define NR_MSI_IRQS 8 +#else #define NR_MSI_IRQS 4 +#endif struct ppc4xx_msi {u32 msi_addr_lo;
@@ -150,12 +155,11 @@ static int ppc4xx_setup_pcieh_hw(struct platform_device *dev,if (!sdr_addr)return -1 ; -SDR0_WRITE (sdr_addr, (u64 )res.start >>32 );/*HIGH addr */ -SDR0_WRITE (sdr_addr +1 , res.start &0xFFFFFFFF );/* Low addr */ - +mtdcri (SDR0 , *sdr_addr, (u64 )res.start >>32 );/*HIGH addr */ +mtdcri (SDR0 , *sdr_addr +1 , res.start &0xFFFFFFFF );/* Low addr */ msi->msi_dev =of_find_node_by_name (NULL ,"ppc4xx-msi" ); -if (msi->msi_dev) +if (!msi->msi_dev)return -ENODEV ; msi->msi_regs =of_iomap (msi->msi_dev,0 );
@@ -167,9 +171,12 @@ static int ppc4xx_setup_pcieh_hw(struct platform_device *dev, (u32) (msi->msi_regs + PEIH_TERMADH), (u32) (msi->msi_regs)); msi_virt =dma_alloc_coherent (&dev->dev,64 , &msi_phys,GFP_KERNEL ); - msi->msi_addr_hi =0x0 ; - msi->msi_addr_lo = (u32 ) msi_phys; -dev_dbg (&dev->dev,"PCIE-MSI: msi address 0x%x\n" , msi->msi_addr_lo); +if (!msi_virt) +return -ENOMEM ; + msi->msi_addr_hi = (u32)(msi_phys >>32 ); + msi->msi_addr_lo = (u32)(msi_phys &0xffffffff ); +dev_dbg (&dev->dev,"PCIE-MSI: msi address high 0x%x, low 0x%x\n" , + msi->msi_addr_hi, msi->msi_addr_lo);/* Progam the Interrupt handler Termination addr registers */ out_be32 (msi->msi_regs +PEIH_TERMADH , msi->msi_addr_hi);
@@ -185,6 +192,8 @@ static int ppc4xx_setup_pcieh_hw(struct platform_device *dev,out_be32 (msi->msi_regs +PEIH_MSIED , *msi_data);out_be32 (msi->msi_regs +PEIH_MSIMK , *msi_mask); +dma_free_coherent (&dev->dev,64 , msi_virt, msi_phys); +return 0 ; }
@@ -215,8 +224,6 @@ static int __devinit ppc4xx_msi_probe(struct platform_device *dev)struct resource res;int err =0 ; - msi = &ppc4xx_msi;/*keep the msi data for further use*/ -dev_dbg (&dev->dev,"PCIE-MSI: Setting up MSI support...\n" ); msi =kzalloc (sizeof (struct ppc4xx_msi ),GFP_KERNEL );
@@ -242,6 +249,7 @@ static int __devinit ppc4xx_msi_probe(struct platform_device *dev)dev_err (&dev->dev,"Error allocating MSI bitmap\n" ); goto error_out; } + ppc4xx_msi = *msi; ppc_md.setup_msi_irqs = ppc4xx_setup_msi_irqs; ppc_md.teardown_msi_irqs = ppc4xx_teardown_msi_irqs;
Signature · 1 line
1.7.3.4
arch/powerpc/sysdev/ppc4xx_msi.c line 52
Quoted 12 lines · Mai La
arch/powerpc/sysdev/ppc4xx_msi.c +5
-0@@ -43,7 +43,12 @@#define PEIH_FLUSH0 0x30#define PEIH_FLUSH1 0x38#define PEIH_CNTRST 0x48 + +#ifdef CONFIG_APM821xx +#define NR_MSI_IRQS 8 +#else #define NR_MSI_IRQS 4 +#endif
does this need to go into the dts binding?
arch/powerpc/sysdev/ppc4xx_msi.c static int ppc4xx_setup_pcieh_hw(struct platform_device *dev, · line 159
Quoted 11 lines
arch/powerpc/sysdev/ppc4xx_msi.c +2
-3struct ppc4xx_msi {u32 msi_addr_lo;@@ -150,12 +155,11 @@ static int ppc4xx_setup_pcieh_hw(struct platform_device *dev,if (!sdr_addr)return -1 ; -SDR0_WRITE (sdr_addr, (u64 )res.start >>32 );/*HIGH addr */ -SDR0_WRITE (sdr_addr +1 , res.start &0xFFFFFFFF );/* Low addr */ - +mtdcri (SDR0 , *sdr_addr, (u64 )res.start >>32 );/*HIGH addr */ +mtdcri (SDR0 , *sdr_addr +1 , res.start &0xFFFFFFFF );/* Low addr */
Please use upper_32_bits and lower_32_bits from linux/kernel.h
Quoted 7 lines
arch/powerpc/sysdev/ppc4xx_msi.c +1
-1msi->msi_dev =of_find_node_by_name (NULL ,"ppc4xx-msi" ); -if (msi->msi_dev) +if (!msi->msi_dev)return -ENODEV ; msi->msi_regs =of_iomap (msi->msi_dev,0 );
arch/powerpc/sysdev/ppc4xx_msi.c static int ppc4xx_setup_pcieh_hw(struct platform_device *dev, · line 177
Quoted 10 lines
arch/powerpc/sysdev/ppc4xx_msi.c +4
-3@@ -167,9 +171,12 @@ static int ppc4xx_setup_pcieh_hw(struct platform_device *dev, (u32) (msi->msi_regs + PEIH_TERMADH), (u32) (msi->msi_regs)); msi_virt =dma_alloc_coherent (&dev->dev,64 , &msi_phys,GFP_KERNEL ); - msi->msi_addr_hi =0x0 ; - msi->msi_addr_lo = (u32 ) msi_phys; -dev_dbg (&dev->dev,"PCIE-MSI: msi address 0x%x\n" , msi->msi_addr_lo); +if (!msi_virt) +return -ENOMEM ; + msi->msi_addr_hi = (u32)(msi_phys >>32 ); + msi->msi_addr_lo = (u32)(msi_phys &0xffffffff );
ditto
milton
Quoted 15 lines · Milton Miller
arch/powerpc/sysdev/ppc4xx_msi.c line 52
Quoted 12 lines · Mai La
arch/powerpc/sysdev/ppc4xx_msi.c +5
-0@@ -43,7 +43,12 @@#define PEIH_FLUSH0 0x30#define PEIH_FLUSH1 0x38#define PEIH_CNTRST 0x48 + +#ifdef CONFIG_APM821xx +#define NR_MSI_IRQS 8 +#else #define NR_MSI_IRQS 4 +#endif does this need to go into the dts binding?
A compile time #define is definitely not acceptable as it would break a multiplatform kernel.
Ben.
Quoted 36 lines
arch/powerpc/sysdev/ppc4xx_msi.c static int ppc4xx_setup_pcieh_hw(struct platform_device *dev, · line 159
Quoted 11 lines
arch/powerpc/sysdev/ppc4xx_msi.c +2
-3struct ppc4xx_msi {u32 msi_addr_lo;@@ -150,12 +155,11 @@ static int ppc4xx_setup_pcieh_hw(struct platform_device *dev,if (!sdr_addr)return -1 ; -SDR0_WRITE (sdr_addr, (u64 )res.start >>32 );/*HIGH addr */ -SDR0_WRITE (sdr_addr +1 , res.start &0xFFFFFFFF );/* Low addr */ - +mtdcri (SDR0 , *sdr_addr, (u64 )res.start >>32 );/*HIGH addr */ +mtdcri (SDR0 , *sdr_addr +1 , res.start &0xFFFFFFFF );/* Low addr */ Please use
upper_32_bitsandlower_32_bitsfromlinux/kernel.hQuoted 7 lines
arch/powerpc/sysdev/ppc4xx_msi.c +1
-1msi->msi_dev =of_find_node_by_name (NULL ,"ppc4xx-msi" ); -if (msi->msi_dev) +if (!msi->msi_dev)return -ENODEV ; msi->msi_regs =of_iomap (msi->msi_dev,0 );arch/powerpc/sysdev/ppc4xx_msi.c static int ppc4xx_setup_pcieh_hw(struct platform_device *dev, · line 177
Quoted 10 lines
arch/powerpc/sysdev/ppc4xx_msi.c +4
-3@@ -167,9 +171,12 @@ static int ppc4xx_setup_pcieh_hw(struct platform_device *dev, (u32) (msi->msi_regs + PEIH_TERMADH), (u32) (msi->msi_regs)); msi_virt =dma_alloc_coherent (&dev->dev,64 , &msi_phys,GFP_KERNEL ); - msi->msi_addr_hi =0x0 ; - msi->msi_addr_lo = (u32 ) msi_phys; -dev_dbg (&dev->dev,"PCIE-MSI: msi address 0x%x\n" , msi->msi_addr_lo); +if (!msi_virt) +return -ENOMEM ; + msi->msi_addr_hi = (u32)(msi_phys >>32 ); + msi->msi_addr_lo = (u32)(msi_phys &0xffffffff );ditto
milton