From 56825c88ff438f4dbb51a44591cc29e707fe783a Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Thu, 8 Jul 2010 21:16:10 +0400 Subject: [PATCH 1/4] powerpc/cpm: Reintroduce global spi_pram struct (fixes build issue) spi_t was removed in commit 644b2a680ccc51a9ec4d6beb12e9d47d2dee98e2 ("powerpc/cpm: Remove SPI defines and spi structs"), the commit assumed that spi_t isn't used anywhere outside of the spi_mpc8xxx driver. But it appears that the struct is needed for micropatch code. So, let's reintroduce the struct. Fixes the following build issue: CC arch/powerpc/sysdev/micropatch.o micropatch.c: In function 'cpm_load_patch': micropatch.c:629: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token micropatch.c:629: error: 'spp' undeclared (first use in this function) micropatch.c:629: error: (Each undeclared identifier is reported only once micropatch.c:629: error: for each function it appears in.) Reported-by: LEROY Christophe Reported-by: Tony Breeds Cc: [ .33, .34 ] Signed-off-by: Anton Vorontsov Signed-off-by: Kumar Gala --- arch/powerpc/include/asm/cpm.h | 24 ++++++++++++++++++++++++ arch/powerpc/sysdev/micropatch.c | 7 ++++--- drivers/spi/spi_mpc8xxx.c | 22 ---------------------- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/arch/powerpc/include/asm/cpm.h b/arch/powerpc/include/asm/cpm.h index 0835eb977ba9..e50323fe941f 100644 --- a/arch/powerpc/include/asm/cpm.h +++ b/arch/powerpc/include/asm/cpm.h @@ -6,6 +6,30 @@ #include #include +/* + * SPI Parameter RAM common to QE and CPM. + */ +struct spi_pram { + __be16 rbase; /* Rx Buffer descriptor base address */ + __be16 tbase; /* Tx Buffer descriptor base address */ + u8 rfcr; /* Rx function code */ + u8 tfcr; /* Tx function code */ + __be16 mrblr; /* Max receive buffer length */ + __be32 rstate; /* Internal */ + __be32 rdp; /* Internal */ + __be16 rbptr; /* Internal */ + __be16 rbc; /* Internal */ + __be32 rxtmp; /* Internal */ + __be32 tstate; /* Internal */ + __be32 tdp; /* Internal */ + __be16 tbptr; /* Internal */ + __be16 tbc; /* Internal */ + __be32 txtmp; /* Internal */ + __be32 res; /* Tx temp. */ + __be16 rpbase; /* Relocation pointer (CPM1 only) */ + __be16 res1; /* Reserved */ +}; + /* * USB Controller pram common to QE and CPM. */ diff --git a/arch/powerpc/sysdev/micropatch.c b/arch/powerpc/sysdev/micropatch.c index d8d602840757..18080f376e1a 100644 --- a/arch/powerpc/sysdev/micropatch.c +++ b/arch/powerpc/sysdev/micropatch.c @@ -16,6 +16,7 @@ #include #include #include +#include #include /* @@ -626,7 +627,7 @@ cpm_load_patch(cpm8xx_t *cp) volatile uint *dp; /* Dual-ported RAM. */ volatile cpm8xx_t *commproc; volatile iic_t *iip; - volatile spi_t *spp; + volatile struct spi_pram *spp; volatile smc_uart_t *smp; int i; @@ -668,8 +669,8 @@ cpm_load_patch(cpm8xx_t *cp) /* Put SPI above the IIC, also 32-byte aligned. */ i = (RPBASE + sizeof(iic_t) + 31) & ~31; - spp = (spi_t *)&commproc->cp_dparam[PROFF_SPI]; - spp->spi_rpbase = i; + spp = (struct spi_pram *)&commproc->cp_dparam[PROFF_SPI]; + spp->rpbase = i; # if defined(CONFIG_I2C_SPI_UCODE_PATCH) commproc->cp_cpmcr1 = 0x802a; diff --git a/drivers/spi/spi_mpc8xxx.c b/drivers/spi/spi_mpc8xxx.c index ffa111a7e9d4..97ab0a81338a 100644 --- a/drivers/spi/spi_mpc8xxx.c +++ b/drivers/spi/spi_mpc8xxx.c @@ -66,28 +66,6 @@ struct mpc8xxx_spi_reg { __be32 receive; }; -/* SPI Parameter RAM */ -struct spi_pram { - __be16 rbase; /* Rx Buffer descriptor base address */ - __be16 tbase; /* Tx Buffer descriptor base address */ - u8 rfcr; /* Rx function code */ - u8 tfcr; /* Tx function code */ - __be16 mrblr; /* Max receive buffer length */ - __be32 rstate; /* Internal */ - __be32 rdp; /* Internal */ - __be16 rbptr; /* Internal */ - __be16 rbc; /* Internal */ - __be32 rxtmp; /* Internal */ - __be32 tstate; /* Internal */ - __be32 tdp; /* Internal */ - __be16 tbptr; /* Internal */ - __be16 tbc; /* Internal */ - __be32 txtmp; /* Internal */ - __be32 res; /* Tx temp. */ - __be16 rpbase; /* Relocation pointer (CPM1 only) */ - __be16 res1; /* Reserved */ -}; - /* SPI Controller mode register definitions */ #define SPMODE_LOOP (1 << 30) #define SPMODE_CI_INACTIVEHIGH (1 << 29) From 2069a6ae19a34d96cc9cb284eb645b165138e03f Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Thu, 8 Jul 2010 21:16:14 +0400 Subject: [PATCH 2/4] powerpc/cpm1: Fix build with various CONFIG_*_UCODE_PATCH combinations Warnings are treated as errors for arch/powerpc code, so build fails with CONFIG_I2C_SPI_UCODE_PATCH=y: CC arch/powerpc/sysdev/micropatch.o cc1: warnings being treated as errors arch/powerpc/sysdev/micropatch.c: In function 'cpm_load_patch': arch/powerpc/sysdev/micropatch.c:630: warning: unused variable 'smp' make[1]: *** [arch/powerpc/sysdev/micropatch.o] Error 1 And with CONFIG_USB_SOF_UCODE_PATCH=y: CC arch/powerpc/sysdev/micropatch.o cc1: warnings being treated as errors arch/powerpc/sysdev/micropatch.c: In function 'cpm_load_patch': arch/powerpc/sysdev/micropatch.c:629: warning: unused variable 'spp' arch/powerpc/sysdev/micropatch.c:628: warning: unused variable 'iip' make[1]: *** [arch/powerpc/sysdev/micropatch.o] Error 1 This patch fixes these issues by introducing proper #ifdefs. Cc: [ .33, .34 ] Signed-off-by: Anton Vorontsov Signed-off-by: Kumar Gala --- arch/powerpc/sysdev/micropatch.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/powerpc/sysdev/micropatch.c b/arch/powerpc/sysdev/micropatch.c index 18080f376e1a..6c56ae902d4c 100644 --- a/arch/powerpc/sysdev/micropatch.c +++ b/arch/powerpc/sysdev/micropatch.c @@ -626,9 +626,14 @@ cpm_load_patch(cpm8xx_t *cp) { volatile uint *dp; /* Dual-ported RAM. */ volatile cpm8xx_t *commproc; +#if defined(CONFIG_I2C_SPI_UCODE_PATCH) || \ + defined(CONFIG_I2C_SPI_SMC1_UCODE_PATCH) volatile iic_t *iip; volatile struct spi_pram *spp; +#ifdef CONFIG_I2C_SPI_SMC1_UCODE_PATCH volatile smc_uart_t *smp; +#endif +#endif int i; commproc = cp; From af71bcfeaaaad92147922282341d394093a4fc9b Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Thu, 8 Jul 2010 21:16:16 +0400 Subject: [PATCH 3/4] powerpc/cpm1: Mark micropatch code/data static and __init This saves runtime memory and fixes lots of sparse warnings like this: CHECK arch/powerpc/sysdev/micropatch.c arch/powerpc/sysdev/micropatch.c:27:6: warning: symbol 'patch_2000' was not declared. Should it be static? arch/powerpc/sysdev/micropatch.c:146:6: warning: symbol 'patch_2f00' was not declared. Should it be static? ... Signed-off-by: Anton Vorontsov Signed-off-by: Kumar Gala --- arch/powerpc/include/asm/cpm1.h | 3 ++- arch/powerpc/sysdev/micropatch.c | 18 +++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/include/asm/cpm1.h b/arch/powerpc/include/asm/cpm1.h index 81b01192f440..bd07650dca56 100644 --- a/arch/powerpc/include/asm/cpm1.h +++ b/arch/powerpc/include/asm/cpm1.h @@ -17,6 +17,7 @@ #ifndef __CPM1__ #define __CPM1__ +#include #include #include #include @@ -54,7 +55,7 @@ extern cpm8xx_t __iomem *cpmp; /* Pointer to comm processor */ extern void cpm_setbrg(uint brg, uint rate); -extern void cpm_load_patch(cpm8xx_t *cp); +extern void __init cpm_load_patch(cpm8xx_t *cp); extern void cpm_reset(void); diff --git a/arch/powerpc/sysdev/micropatch.c b/arch/powerpc/sysdev/micropatch.c index 6c56ae902d4c..c0bb76ef7242 100644 --- a/arch/powerpc/sysdev/micropatch.c +++ b/arch/powerpc/sysdev/micropatch.c @@ -4,6 +4,7 @@ * also relocates SMC2, but this would require additional changes * to uart.c, so I am holding off on that for a moment. */ +#include #include #include #include @@ -25,7 +26,7 @@ #ifdef CONFIG_I2C_SPI_UCODE_PATCH -uint patch_2000[] = { +static uint patch_2000[] __initdata = { 0x7FFFEFD9, 0x3FFD0000, 0x7FFB49F7, @@ -144,7 +145,7 @@ uint patch_2000[] = { 0x5F8247F8 }; -uint patch_2f00[] = { +static uint patch_2f00[] __initdata = { 0x3E303430, 0x34343737, 0xABF7BF9B, @@ -183,7 +184,7 @@ uint patch_2f00[] = { #ifdef CONFIG_I2C_SPI_SMC1_UCODE_PATCH -uint patch_2000[] = { +static uint patch_2000[] __initdata = { 0x3fff0000, 0x3ffd0000, 0x3ffb0000, @@ -506,7 +507,7 @@ uint patch_2000[] = { 0x6079e2bb }; -uint patch_2f00[] = { +static uint patch_2f00[] __initdata = { 0x30303030, 0x3e3e3434, 0xabbf9b99, @@ -573,7 +574,7 @@ uint patch_2f00[] = { 0xf22f3f23 }; -uint patch_2e00[] = { +static uint patch_2e00[] __initdata = { 0x27eeeeee, 0xeeeeeeee, 0xeeeeeeee, @@ -599,7 +600,7 @@ uint patch_2e00[] = { #ifdef CONFIG_USB_SOF_UCODE_PATCH -uint patch_2000[] = { +static uint patch_2000[] __initdata = { 0x7fff0000, 0x7ffd0000, 0x7ffb0000, @@ -614,15 +615,14 @@ uint patch_2000[] = { 0x60750000 }; -uint patch_2f00[] = { +static uint patch_2f00[] __initdata = { 0x3030304c, 0xcab9e441, 0xa1aaf220 }; #endif -void -cpm_load_patch(cpm8xx_t *cp) +void __init cpm_load_patch(cpm8xx_t *cp) { volatile uint *dp; /* Dual-ported RAM. */ volatile cpm8xx_t *commproc; From 77154a2026ee5cb2ce05a7d370c16e4c123028e5 Mon Sep 17 00:00:00 2001 From: Matthew McClintock Date: Tue, 29 Jun 2010 14:42:07 -0500 Subject: [PATCH 4/4] powerpc/fsl-booke: Fix address issue when using relocatable kernels When booting a relocatable kernel it needs to jump to the correct start address, which for BookE parts is usually unchanged regardless of the physical memory offset. Recent changes cause problems with how we calculate the start address, it was always adding the RMO into the start address which is incorrect. This patch only adds in the RMO offset if we are in the kexec code path, as it needs the RMO to work correctly. Instead of adding the RMO offset in in the common code path, we can just set r6 to the RMO offset in the kexec code path instead of to zero, and finally perform the masking in the common code path Signed-off-by: Matthew McClintock Signed-off-by: Kumar Gala --- arch/powerpc/kernel/fsl_booke_entry_mapping.S | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/fsl_booke_entry_mapping.S b/arch/powerpc/kernel/fsl_booke_entry_mapping.S index beb4d78a2304..a92c79be2728 100644 --- a/arch/powerpc/kernel/fsl_booke_entry_mapping.S +++ b/arch/powerpc/kernel/fsl_booke_entry_mapping.S @@ -205,8 +205,7 @@ next_tlb_setup: bdnz+ next_tlb_setup /* 7. Jump to our 1:1 mapping */ - li r6, 0 - + mr r6, r25 #else #error You need to specify the mapping or not use this at all. #endif @@ -217,7 +216,6 @@ next_tlb_setup: 1: mflr r9 rlwimi r6,r9,0,20,31 addi r6,r6,(2f - 1b) - add r6, r6, r25 mtspr SPRN_SRR0,r6 mtspr SPRN_SRR1,r7 rfi /* start execution out of TLB1[0] entry */