Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: FSMC NAND use the PrimeCell identifier macros

The FSMC actually has a standard ARM PrimeCell ID register, and
the "revision" part of that register contains the thing that
the code is looking at. Reuse the infrastructure from the AMBA
bus abstraction and rid local defines.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

authored by

Linus Walleij and committed by
David Woodhouse
593cd871 4ad916bc

+20 -22
+20 -3
drivers/mtd/nand/fsmc_nand.c
··· 31 31 #include <linux/io.h> 32 32 #include <linux/slab.h> 33 33 #include <linux/mtd/fsmc.h> 34 + #include <linux/amba/bus.h> 34 35 #include <mtd/mtd-abi.h> 35 36 36 37 static struct nand_ecclayout fsmc_ecc1_layout = { ··· 185 184 #endif 186 185 187 186 /** 188 - * struct fsmc_nand_data - atructure for FSMC NAND device state 187 + * struct fsmc_nand_data - structure for FSMC NAND device state 189 188 * 189 + * @pid: Part ID on the AMBA PrimeCell format 190 190 * @mtd: MTD info for a NAND flash. 191 191 * @nand: Chip related info for a NAND flash. 192 192 * @partitions: Partition info for a NAND Flash. ··· 203 201 * @regs_va: FSMC regs base address. 204 202 */ 205 203 struct fsmc_nand_data { 204 + u32 pid; 206 205 struct mtd_info mtd; 207 206 struct nand_chip nand; 208 207 struct mtd_partition *partitions; ··· 544 541 struct fsmc_regs *regs; 545 542 struct resource *res; 546 543 int ret = 0; 544 + u32 pid; 545 + int i; 547 546 548 547 if (!pdata) { 549 548 dev_err(&pdev->dev, "platform data is NULL\n"); ··· 635 630 if (ret) 636 631 goto err_probe1; 637 632 633 + /* 634 + * This device ID is actually a common AMBA ID as used on the 635 + * AMBA PrimeCell bus. However it is not a PrimeCell. 636 + */ 637 + for (pid = 0, i = 0; i < 4; i++) 638 + pid |= (readl(host->regs_va + resource_size(res) - 0x20 + 4 * i) & 255) << (i * 8); 639 + host->pid = pid; 640 + dev_info(&pdev->dev, "FSMC device partno %03x, manufacturer %02x, " 641 + "revision %02x, config %02x\n", 642 + AMBA_PART_BITS(pid), AMBA_MANF_BITS(pid), 643 + AMBA_REV_BITS(pid), AMBA_CONFIG_BITS(pid)); 644 + 638 645 host->bank = pdata->bank; 639 646 host->select_chip = pdata->select_bank; 640 647 regs = host->regs_va; ··· 674 657 675 658 fsmc_nand_setup(regs, host->bank, nand->options & NAND_BUSWIDTH_16); 676 659 677 - if (get_fsmc_version(host->regs_va) == FSMC_VER8) { 660 + if (AMBA_REV_BITS(host->pid) >= 8) { 678 661 nand->ecc.read_page = fsmc_read_page_hwecc; 679 662 nand->ecc.calculate = fsmc_read_hwecc_ecc4; 680 663 nand->ecc.correct = fsmc_correct_data; ··· 694 677 goto err_probe; 695 678 } 696 679 697 - if (get_fsmc_version(host->regs_va) == FSMC_VER8) { 680 + if (AMBA_REV_BITS(host->pid) >= 8) { 698 681 if (host->mtd.writesize == 512) { 699 682 nand->ecc.layout = &fsmc_ecc4_sp_layout; 700 683 host->ecc_place = &fsmc_ecc4_sp_place;
-19
include/linux/mtd/fsmc.h
··· 115 115 #define FSMC_THOLD_4 (4 << 16) 116 116 #define FSMC_THIZ_1 (1 << 24) 117 117 118 - /* peripid2 register definitions */ 119 - #define FSMC_REVISION_MSK (0xf) 120 - #define FSMC_REVISION_SHFT (0x4) 121 - 122 - #define FSMC_VER1 1 123 - #define FSMC_VER2 2 124 - #define FSMC_VER3 3 125 - #define FSMC_VER4 4 126 - #define FSMC_VER5 5 127 - #define FSMC_VER6 6 128 - #define FSMC_VER7 7 129 - #define FSMC_VER8 8 130 - 131 - static inline uint32_t get_fsmc_version(struct fsmc_regs *regs) 132 - { 133 - return (readl(&regs->peripid2) >> FSMC_REVISION_SHFT) & 134 - FSMC_REVISION_MSK; 135 - } 136 - 137 118 /* 138 119 * There are 13 bytes of ecc for every 512 byte block in FSMC version 8 139 120 * and it has to be read consecutively and immediately after the 512