spi: fsl-spi: Allow dynamic allocation of CPM1 parameter RAM
PATCH v2 2/2 spi: fsl-spi: Allow dynamic allocation of CPM1 parameter RAM
On CPM1, the SPI parameter RAM has a default location. In order to use SPI while using SCC2 with features like QMC or Ethernet, it is necessary to relocate SPI parameter RAM in a free location in the CPM dual port RAM. With this patch, when "fsl,cpm1-spi-reloc" instead of "fsl,cpm1-spi" compatible is set in the device tree, the parameter RAM for SPI is dynamically allocated with cpm_muram_alloc().
---
Changes from v1 to v2: using OF compatible instead of compile time option
drivers/spi/spi-fsl-cpm.c | 3 +++ drivers/spi/spi-fsl-lib.c | 2 ++ include/linux/fsl_devices.h | 1 + 3 files changed, 6 insertions(+)
drivers/spi/spi-fsl-cpm.c +3 -0
@@ -261,6 +261,9 @@ static unsigned long fsl_spi_cpm_get_pram(struct mpc8xxx_spi *mspi)if (mspi->flags &SPI_CPM2 ) { pram_ofs =cpm_muram_alloc (SPI_PRAM_SIZE ,64 );out_be16 (spi_base, pram_ofs); + }else if (mspi->flags &SPI_CPM1_RELOC ) { + pram_ofs =cpm_muram_alloc (SPI_PRAM_SIZE ,32 ); +out_be16 (spi_base, pram_ofs); }else {u16 rpbase =in_be16 (spi_base);
drivers/spi/spi-fsl-lib.c +2 -0
@@ -227,6 +227,8 @@ int of_mpc8xxx_spi_probe(struct platform_device *ofdev) pdata->flags =SPI_CPM_MODE |SPI_CPM2 ; else if (of_device_is_compatible(np, "fsl,cpm1-spi")) pdata->flags = SPI_CPM_MODE | SPI_CPM1; + else if (of_device_is_compatible(np, "fsl,cpm1-spi-reloc")) + pdata->flags =SPI_CPM_MODE |SPI_CPM1 |SPI_CPM1_RELOC ;return 0 ; }
include/linux/fsl_devices.h +1 -0
@@ -123,6 +123,7 @@ struct fsl_spi_platform_data {#define SPI_CPM1 (1 << 2)/* SPI unit is in CPM1 block */ #define SPI_CPM2 (1 << 3)/* SPI unit is in CPM2 block */ #define SPI_QE (1 << 4)/* SPI unit is in QE block */ +#define SPI_CPM1_RELOC (1 << 5)/* SPI pram has to be relocated */ /* board specific information */ u16 max_chipselect;void (*cs_control)(struct spi_device *spi,bool on);
Signature · 1 line
2.1.0
Quoted 3 lines · Christophe Leroy
On CPM1, the SPI parameter RAM has a default location. In order to use SPI while using SCC2 with features like QMC or Ethernet, it is necessary to relocate SPI parameter RAM in a free location in the CPM dual port RAM.
Please explain in more detail why it's necessary.
Quoted 34 lines
With this patch,
when "fsl,cpm1-spi-reloc" instead of "fsl,cpm1-spi" compatible is set in the device tree, the parameter RAM for SPI is dynamically allocated withcpm_muram_alloc().Signed-off-by Christophe Leroy <[email protected]>---
Changes from v1 to v2: using OF compatible instead of compile time optiondrivers/spi/spi-fsl-cpm.c | 3 +++ drivers/spi/spi-fsl-lib.c | 2 ++ include/linux/fsl_devices.h | 1 + 3 files changed, 6 insertions(+)drivers/spi/spi-fsl-cpm.c +3
-0@@ -261,6 +261,9 @@ static unsigned long fsl_spi_cpm_get_pram(struct mpc8xxx_spi *mspi)if (mspi->flags &SPI_CPM2 ) { pram_ofs =cpm_muram_alloc (SPI_PRAM_SIZE ,64 );out_be16 (spi_base, pram_ofs); + }else if (mspi->flags &SPI_CPM1_RELOC ) { + pram_ofs =cpm_muram_alloc (SPI_PRAM_SIZE ,32 ); +out_be16 (spi_base, pram_ofs); }else {u16 rpbase =in_be16 (spi_base);drivers/spi/spi-fsl-lib.c +0
-0
drivers/spi/spi-fsl-lib.c int of_mpc8xxx_spi_probe(struct platform_device *ofdev) · line 231
Quoted 5 lines
drivers/spi/spi-fsl-lib.c +2
-0@@ -227,6 +227,8 @@ int of_mpc8xxx_spi_probe(struct platform_device *ofdev) pdata->flags =SPI_CPM_MODE |SPI_CPM2 ; else if (of_device_is_compatible(np, "fsl,cpm1-spi")) pdata->flags = SPI_CPM_MODE | SPI_CPM1; + else if (of_device_is_compatible(np, "fsl,cpm1-spi-reloc")) + pdata->flags =SPI_CPM_MODE |SPI_CPM1 |SPI_CPM1_RELOC ;
Where's the binding and device tree update for this? What specific aspect of hardware does it describe?
-Scott
Quoted 5 lines · Scott Wood
Quoted 3 lines · Christophe Leroy
On CPM1, the SPI parameter RAM has a default location. In order to use SPI while using SCC2 with features like QMC or Ethernet, it is necessary to relocate SPI parameter RAM in a free location in the CPM dual port RAM.
Please explain in more detail why it's necessary.
SCC2 parameter RAM is located at offset 0x1D00 inside the CPM dual port RAM.
SPI parameter RAM is located at offset 0x1D80.
When using SCC2 in Ethernet Mode, the parameter RAM size is 0xA4.
When using SCC2 in QMC mode, the parameter RAM size is 0xAC.
Therefore in both case, it overlaps the SPI parameter RAM which shall then be relocated.
On MPC860 this can only be done using an additional microcode. Therefore, the relocation configuration is managed within arch/powerpc/sysdep/micropatch.c On MPC866 and MPC885 (at least) no microcode is needed. Therefore, if we want to relocate the SPI param, we must handle that outside of micropatch.c Since the SPI driver already handle dynamic parameter RAM allocation for CPM2, I though it was the good place to do it also for CPM1.
Quoted 30 lines
Quoted 30 lines
With this patch,
when "fsl,cpm1-spi-reloc" instead of "fsl,cpm1-spi" compatible is set in the device tree, the parameter RAM for SPI is dynamically allocated withcpm_muram_alloc().Signed-off-by Christophe Leroy <[email protected]>---
Changes from v1 to v2: using OF compatible instead of compile time optiondrivers/spi/spi-fsl-cpm.c | 3 +++ drivers/spi/spi-fsl-lib.c | 2 ++ include/linux/fsl_devices.h | 1 + 3 files changed, 6 insertions(+)drivers/spi/spi-fsl-cpm.c +3
-0@@ -261,6 +261,9 @@ static unsigned long fsl_spi_cpm_get_pram(struct mpc8xxx_spi *mspi)if (mspi->flags &SPI_CPM2 ) { pram_ofs =cpm_muram_alloc (SPI_PRAM_SIZE ,64 );out_be16 (spi_base, pram_ofs); + }else if (mspi->flags &SPI_CPM1_RELOC ) { + pram_ofs =cpm_muram_alloc (SPI_PRAM_SIZE ,32 ); +out_be16 (spi_base, pram_ofs); }else {u16 rpbase =in_be16 (spi_base);
Quoted 12 lines
drivers/spi/spi-fsl-lib.c int of_mpc8xxx_spi_probe(struct platform_device *ofdev) · line 231
Quoted 10 lines
drivers/spi/spi-fsl-lib.c +2
-0@@ -227,6 +227,8 @@ int of_mpc8xxx_spi_probe(struct platform_device *ofdev) pdata->flags =SPI_CPM_MODE |SPI_CPM2 ; else if (of_device_is_compatible(np, "fsl,cpm1-spi")) pdata->flags = SPI_CPM_MODE | SPI_CPM1; + else if (of_device_is_compatible(np, "fsl,cpm1-spi-reloc")) + pdata->flags =SPI_CPM_MODE |SPI_CPM1 |SPI_CPM1_RELOC ;Where's the binding and device tree update for this? What specific aspect of hardware does it describe?
Well, the intension was not really to describe any specific aspect of hardware, but to provide an easy way to tell the driver that we want dynamic reallocation of the parameter RAM.
On CPM2, dynamic allocation of parameter RAM is the only way.
On CPM1:
* The parameter RAM has a default location.
* When the SPI relocation micropatch is applied, the kernel reallocate it just after the patch, when loading the patch. This is not good for using QMC, because it is within the part of dual port RAM used by the QMC, therefore it reduce even more the number of channels that the QMC can use.
The bindings for that driver are described in Documentation/devicetree/bindings/spi/fsl-spi.txt. But it seems that it doesn't describe anything related to those compatibles. The driver has a match on "fsl,fsl-spi" only, and for using it with CPM you have to add "fsl,cpm1-spi" or "fsl,cpm2-spi" to tell the driver that it is CPM (existing code below).
prop = of_get_property(np, "mode", NULL);
if (prop && !strcmp(prop, "cpu-qe"))
pdata->flags = SPI_QE_CPU_MODE;
else if (prop && !strcmp(prop, "qe"))
pdata->flags = SPI_CPM_MODE | SPI_QE;
else if (of_device_is_compatible(np, "fsl,cpm2-spi"))
pdata->flags = SPI_CPM_MODE | SPI_CPM2;
else if (of_device_is_compatible(np, "fsl,cpm1-spi"))
pdata->flags = SPI_CPM_MODE | SPI_CPM1;Christophe
---
Ce courrier électronique ne contient aucun virus ou logiciel malveillant parce que la protection avast! Antivirus est active.
http://www.avast.com
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 4 lines · christophe leroy
The bindings for that driver are described in
Documentation/devicetree/bindings/spi/fsl-spi.txt. But it seems that it doesn't describe anything related to those compatibles. The driver has a match on "fsl,fsl-spi" only,
I think you mean "fsl,spi", and that's a terrible compatible name.
Quoted 3 lines
and for using it with CPM you have to add
"fsl,cpm1-spi" or "fsl,cpm2-spi" to tell the driver that it is CPM (existing code below).
fsl-spi.txt doesn't describe CPM1/2 at all, but rather QE (CPM3) and non-CPM.
-Scott
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html