aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-fsl-spi.c
diff options
context:
space:
mode:
authorHolger Brunck <holger.brunck@keymile.com>2011-06-20 12:31:57 -0400
committerGrant Likely <grant.likely@secretlab.ca>2011-07-05 13:59:17 -0400
commitfb6440955fcc5d175397fd0e9a00c6967cb26a74 (patch)
treea5100e437776f5c20e8d9eedb67be5411c9dcdf4 /drivers/spi/spi-fsl-spi.c
parentc25ded1fbc069265e4d26df45a93ace18780974f (diff)
spi/fsl_spi: fix CPM spi driver
This patch fixes the freescale spi driver for CPM. Without this patch SPI on CPM failed because cpm_muram_alloc_fixed tries to allocate muram in an preserved area. The error reported was: mpc8xxx_spi f0011a80.spi: can't allocate spi parameter ram mpc8xxx_spi: probe of f0011a80.spi failed with error -12 Now the driver uses of_iomap to get access to this area similar to i2c driver driver in the i2c-cpm.c which has a similar device tree node. This is tested on a MPC8247 with CPM2. Signed-off-by: Holger Brunck <holger.brunck@keymile.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi/spi-fsl-spi.c')
-rw-r--r--drivers/spi/spi-fsl-spi.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
index e013117a404d..d2407558773f 100644
--- a/drivers/spi/spi-fsl-spi.c
+++ b/drivers/spi/spi-fsl-spi.c
@@ -684,7 +684,7 @@ static unsigned long fsl_spi_cpm_get_pram(struct mpc8xxx_spi *mspi)
684 struct device_node *np = dev->of_node; 684 struct device_node *np = dev->of_node;
685 const u32 *iprop; 685 const u32 *iprop;
686 int size; 686 int size;
687 unsigned long spi_base_ofs; 687 void __iomem *spi_base;
688 unsigned long pram_ofs = -ENOMEM; 688 unsigned long pram_ofs = -ENOMEM;
689 689
690 /* Can't use of_address_to_resource(), QE muram isn't at 0. */ 690 /* Can't use of_address_to_resource(), QE muram isn't at 0. */
@@ -702,33 +702,27 @@ static unsigned long fsl_spi_cpm_get_pram(struct mpc8xxx_spi *mspi)
702 return pram_ofs; 702 return pram_ofs;
703 } 703 }
704 704
705 /* CPM1 and CPM2 pram must be at a fixed addr. */ 705 spi_base = of_iomap(np, 1);
706 if (!iprop || size != sizeof(*iprop) * 4) 706 if (spi_base == NULL)
707 return -ENOMEM; 707 return -EINVAL;
708
709 spi_base_ofs = cpm_muram_alloc_fixed(iprop[2], 2);
710 if (IS_ERR_VALUE(spi_base_ofs))
711 return -ENOMEM;
712 708
713 if (mspi->flags & SPI_CPM2) { 709 if (mspi->flags & SPI_CPM2) {
714 pram_ofs = cpm_muram_alloc(SPI_PRAM_SIZE, 64); 710 pram_ofs = cpm_muram_alloc(SPI_PRAM_SIZE, 64);
715 if (!IS_ERR_VALUE(pram_ofs)) { 711 out_be16(spi_base, pram_ofs);
716 u16 __iomem *spi_base = cpm_muram_addr(spi_base_ofs);
717
718 out_be16(spi_base, pram_ofs);
719 }
720 } else { 712 } else {
721 struct spi_pram __iomem *pram = cpm_muram_addr(spi_base_ofs); 713 struct spi_pram __iomem *pram = spi_base;
722 u16 rpbase = in_be16(&pram->rpbase); 714 u16 rpbase = in_be16(&pram->rpbase);
723 715
724 /* Microcode relocation patch applied? */ 716 /* Microcode relocation patch applied? */
725 if (rpbase) 717 if (rpbase)
726 pram_ofs = rpbase; 718 pram_ofs = rpbase;
727 else 719 else {
728 return spi_base_ofs; 720 pram_ofs = cpm_muram_alloc(SPI_PRAM_SIZE, 64);
721 out_be16(spi_base, pram_ofs);
722 }
729 } 723 }
730 724
731 cpm_muram_free(spi_base_ofs); 725 iounmap(spi_base);
732 return pram_ofs; 726 return pram_ofs;
733} 727}
734 728