diff options
-rw-r--r-- | drivers/memory/fsl_ifc.c | 13 | ||||
-rw-r--r-- | drivers/mtd/nand/fsl_ifc_nand.c | 10 | ||||
-rw-r--r-- | include/linux/fsl_ifc.h | 21 |
3 files changed, 31 insertions, 13 deletions
diff --git a/drivers/memory/fsl_ifc.c b/drivers/memory/fsl_ifc.c index 3d5d792d5cb2..410c39749872 100644 --- a/drivers/memory/fsl_ifc.c +++ b/drivers/memory/fsl_ifc.c | |||
@@ -61,7 +61,7 @@ int fsl_ifc_find(phys_addr_t addr_base) | |||
61 | if (!fsl_ifc_ctrl_dev || !fsl_ifc_ctrl_dev->regs) | 61 | if (!fsl_ifc_ctrl_dev || !fsl_ifc_ctrl_dev->regs) |
62 | return -ENODEV; | 62 | return -ENODEV; |
63 | 63 | ||
64 | for (i = 0; i < ARRAY_SIZE(fsl_ifc_ctrl_dev->regs->cspr_cs); i++) { | 64 | for (i = 0; i < fsl_ifc_ctrl_dev->banks; i++) { |
65 | u32 cspr = in_be32(&fsl_ifc_ctrl_dev->regs->cspr_cs[i].cspr); | 65 | u32 cspr = in_be32(&fsl_ifc_ctrl_dev->regs->cspr_cs[i].cspr); |
66 | if (cspr & CSPR_V && (cspr & CSPR_BA) == | 66 | if (cspr & CSPR_V && (cspr & CSPR_BA) == |
67 | convert_ifc_address(addr_base)) | 67 | convert_ifc_address(addr_base)) |
@@ -213,7 +213,7 @@ static irqreturn_t fsl_ifc_ctrl_irq(int irqno, void *data) | |||
213 | static int fsl_ifc_ctrl_probe(struct platform_device *dev) | 213 | static int fsl_ifc_ctrl_probe(struct platform_device *dev) |
214 | { | 214 | { |
215 | int ret = 0; | 215 | int ret = 0; |
216 | 216 | int version, banks; | |
217 | 217 | ||
218 | dev_info(&dev->dev, "Freescale Integrated Flash Controller\n"); | 218 | dev_info(&dev->dev, "Freescale Integrated Flash Controller\n"); |
219 | 219 | ||
@@ -231,6 +231,15 @@ static int fsl_ifc_ctrl_probe(struct platform_device *dev) | |||
231 | goto err; | 231 | goto err; |
232 | } | 232 | } |
233 | 233 | ||
234 | version = ioread32be(&fsl_ifc_ctrl_dev->regs->ifc_rev) & | ||
235 | FSL_IFC_VERSION_MASK; | ||
236 | banks = (version == FSL_IFC_VERSION_1_0_0) ? 4 : 8; | ||
237 | dev_info(&dev->dev, "IFC version %d.%d, %d banks\n", | ||
238 | version >> 24, (version >> 16) & 0xf, banks); | ||
239 | |||
240 | fsl_ifc_ctrl_dev->version = version; | ||
241 | fsl_ifc_ctrl_dev->banks = banks; | ||
242 | |||
234 | /* get the Controller level irq */ | 243 | /* get the Controller level irq */ |
235 | fsl_ifc_ctrl_dev->irq = irq_of_parse_and_map(dev->dev.of_node, 0); | 244 | fsl_ifc_ctrl_dev->irq = irq_of_parse_and_map(dev->dev.of_node, 0); |
236 | if (fsl_ifc_ctrl_dev->irq == NO_IRQ) { | 245 | if (fsl_ifc_ctrl_dev->irq == NO_IRQ) { |
diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c index 2338124dd05f..4d40fdb24187 100644 --- a/drivers/mtd/nand/fsl_ifc_nand.c +++ b/drivers/mtd/nand/fsl_ifc_nand.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include <linux/mtd/nand_ecc.h> | 31 | #include <linux/mtd/nand_ecc.h> |
32 | #include <linux/fsl_ifc.h> | 32 | #include <linux/fsl_ifc.h> |
33 | 33 | ||
34 | #define FSL_IFC_V1_1_0 0x01010000 | ||
35 | #define ERR_BYTE 0xFF /* Value returned for read | 34 | #define ERR_BYTE 0xFF /* Value returned for read |
36 | bytes when read failed */ | 35 | bytes when read failed */ |
37 | #define IFC_TIMEOUT_MSECS 500 /* Maximum number of mSecs to wait | 36 | #define IFC_TIMEOUT_MSECS 500 /* Maximum number of mSecs to wait |
@@ -877,7 +876,7 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) | |||
877 | struct fsl_ifc_regs __iomem *ifc = ctrl->regs; | 876 | struct fsl_ifc_regs __iomem *ifc = ctrl->regs; |
878 | struct nand_chip *chip = &priv->chip; | 877 | struct nand_chip *chip = &priv->chip; |
879 | struct nand_ecclayout *layout; | 878 | struct nand_ecclayout *layout; |
880 | u32 csor, ver; | 879 | u32 csor; |
881 | 880 | ||
882 | /* Fill in fsl_ifc_mtd structure */ | 881 | /* Fill in fsl_ifc_mtd structure */ |
883 | priv->mtd.priv = chip; | 882 | priv->mtd.priv = chip; |
@@ -984,8 +983,7 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) | |||
984 | chip->ecc.mode = NAND_ECC_SOFT; | 983 | chip->ecc.mode = NAND_ECC_SOFT; |
985 | } | 984 | } |
986 | 985 | ||
987 | ver = ioread32be(&ifc->ifc_rev); | 986 | if (ctrl->version == FSL_IFC_VERSION_1_1_0) |
988 | if (ver == FSL_IFC_V1_1_0) | ||
989 | fsl_ifc_sram_init(priv); | 987 | fsl_ifc_sram_init(priv); |
990 | 988 | ||
991 | return 0; | 989 | return 0; |
@@ -1045,12 +1043,12 @@ static int fsl_ifc_nand_probe(struct platform_device *dev) | |||
1045 | } | 1043 | } |
1046 | 1044 | ||
1047 | /* find which chip select it is connected to */ | 1045 | /* find which chip select it is connected to */ |
1048 | for (bank = 0; bank < FSL_IFC_BANK_COUNT; bank++) { | 1046 | for (bank = 0; bank < fsl_ifc_ctrl_dev->banks; bank++) { |
1049 | if (match_bank(ifc, bank, res.start)) | 1047 | if (match_bank(ifc, bank, res.start)) |
1050 | break; | 1048 | break; |
1051 | } | 1049 | } |
1052 | 1050 | ||
1053 | if (bank >= FSL_IFC_BANK_COUNT) { | 1051 | if (bank >= fsl_ifc_ctrl_dev->banks) { |
1054 | dev_err(&dev->dev, "%s: address did not match any chip selects\n", | 1052 | dev_err(&dev->dev, "%s: address did not match any chip selects\n", |
1055 | __func__); | 1053 | __func__); |
1056 | return -ENODEV; | 1054 | return -ENODEV; |
diff --git a/include/linux/fsl_ifc.h b/include/linux/fsl_ifc.h index 84d60cb841b1..bf0321eabbda 100644 --- a/include/linux/fsl_ifc.h +++ b/include/linux/fsl_ifc.h | |||
@@ -29,7 +29,16 @@ | |||
29 | #include <linux/of_platform.h> | 29 | #include <linux/of_platform.h> |
30 | #include <linux/interrupt.h> | 30 | #include <linux/interrupt.h> |
31 | 31 | ||
32 | #define FSL_IFC_BANK_COUNT 4 | 32 | /* |
33 | * The actual number of banks implemented depends on the IFC version | ||
34 | * - IFC version 1.0 implements 4 banks. | ||
35 | * - IFC version 1.1 onward implements 8 banks. | ||
36 | */ | ||
37 | #define FSL_IFC_BANK_COUNT 8 | ||
38 | |||
39 | #define FSL_IFC_VERSION_MASK 0x0F0F0000 | ||
40 | #define FSL_IFC_VERSION_1_0_0 0x01000000 | ||
41 | #define FSL_IFC_VERSION_1_1_0 0x01010000 | ||
33 | 42 | ||
34 | /* | 43 | /* |
35 | * CSPR - Chip Select Property Register | 44 | * CSPR - Chip Select Property Register |
@@ -776,23 +785,23 @@ struct fsl_ifc_regs { | |||
776 | __be32 cspr; | 785 | __be32 cspr; |
777 | u32 res2; | 786 | u32 res2; |
778 | } cspr_cs[FSL_IFC_BANK_COUNT]; | 787 | } cspr_cs[FSL_IFC_BANK_COUNT]; |
779 | u32 res3[0x19]; | 788 | u32 res3[0xd]; |
780 | struct { | 789 | struct { |
781 | __be32 amask; | 790 | __be32 amask; |
782 | u32 res4[0x2]; | 791 | u32 res4[0x2]; |
783 | } amask_cs[FSL_IFC_BANK_COUNT]; | 792 | } amask_cs[FSL_IFC_BANK_COUNT]; |
784 | u32 res5[0x18]; | 793 | u32 res5[0xc]; |
785 | struct { | 794 | struct { |
786 | __be32 csor; | 795 | __be32 csor; |
787 | __be32 csor_ext; | 796 | __be32 csor_ext; |
788 | u32 res6; | 797 | u32 res6; |
789 | } csor_cs[FSL_IFC_BANK_COUNT]; | 798 | } csor_cs[FSL_IFC_BANK_COUNT]; |
790 | u32 res7[0x18]; | 799 | u32 res7[0xc]; |
791 | struct { | 800 | struct { |
792 | __be32 ftim[4]; | 801 | __be32 ftim[4]; |
793 | u32 res8[0x8]; | 802 | u32 res8[0x8]; |
794 | } ftim_cs[FSL_IFC_BANK_COUNT]; | 803 | } ftim_cs[FSL_IFC_BANK_COUNT]; |
795 | u32 res9[0x60]; | 804 | u32 res9[0x30]; |
796 | __be32 rb_stat; | 805 | __be32 rb_stat; |
797 | u32 res10[0x2]; | 806 | u32 res10[0x2]; |
798 | __be32 ifc_gcr; | 807 | __be32 ifc_gcr; |
@@ -827,6 +836,8 @@ struct fsl_ifc_ctrl { | |||
827 | int nand_irq; | 836 | int nand_irq; |
828 | spinlock_t lock; | 837 | spinlock_t lock; |
829 | void *nand; | 838 | void *nand; |
839 | int version; | ||
840 | int banks; | ||
830 | 841 | ||
831 | u32 nand_stat; | 842 | u32 nand_stat; |
832 | wait_queue_head_t nand_wait; | 843 | wait_queue_head_t nand_wait; |