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

[MTD] [NAND] pxa3xx_nand: moved some helper variables out from platform data

This patch moves some attributes out from the platform data into the
dynamically created nand device. This results into a cleaner interface
and allows to use constant pxa3xx_nand_flash definitions.

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

authored by

Enrico Scholz and committed by
David Woodhouse
c8c17c88 7dad482e

+26 -26
+1 -8
arch/arm/mach-pxa/include/mach/pxa3xx_nand.h
··· 39 39 uint32_t dfc_width; /* Width of flash controller(DWIDTH_C) */ 40 40 uint32_t num_blocks; /* Number of physical blocks in Flash */ 41 41 uint32_t chip_id; 42 - 43 - /* NOTE: these are automatically calculated, do not define */ 44 - size_t oob_size; 45 - size_t read_id_bytes; 46 - 47 - unsigned int col_addr_cycles; 48 - unsigned int row_addr_cycles; 49 42 }; 50 43 51 44 struct pxa3xx_nand_platform_data { ··· 52 59 const struct mtd_partition *parts; 53 60 unsigned int nr_parts; 54 61 55 - struct pxa3xx_nand_flash * const flash; 62 + const struct pxa3xx_nand_flash * flash; 56 63 size_t num_flash; 57 64 }; 58 65
+25 -18
drivers/mtd/nand/pxa3xx_nand.c
··· 119 119 struct nand_chip nand_chip; 120 120 121 121 struct platform_device *pdev; 122 - struct pxa3xx_nand_flash *flash_info; 122 + const struct pxa3xx_nand_flash *flash_info; 123 123 124 124 struct clk *clk; 125 125 void __iomem *mmio_base; ··· 158 158 uint32_t ndcb0; 159 159 uint32_t ndcb1; 160 160 uint32_t ndcb2; 161 + 162 + /* calculated from pxa3xx_nand_flash data */ 163 + size_t oob_size; 164 + size_t read_id_bytes; 165 + 166 + unsigned int col_addr_cycles; 167 + unsigned int row_addr_cycles; 161 168 }; 162 169 163 170 static int use_dma = 1; ··· 342 335 static int prepare_read_prog_cmd(struct pxa3xx_nand_info *info, 343 336 uint16_t cmd, int column, int page_addr) 344 337 { 345 - struct pxa3xx_nand_flash *f = info->flash_info; 338 + const struct pxa3xx_nand_flash *f = info->flash_info; 346 339 const struct pxa3xx_nand_cmdset *cmdset = f->cmdset; 347 340 348 341 /* calculate data size */ ··· 361 354 info->ndcb0 = cmd | ((cmd & 0xff00) ? NDCB0_DBC : 0); 362 355 info->ndcb1 = 0; 363 356 info->ndcb2 = 0; 364 - info->ndcb0 |= NDCB0_ADDR_CYC(f->row_addr_cycles + f->col_addr_cycles); 357 + info->ndcb0 |= NDCB0_ADDR_CYC(info->row_addr_cycles + info->col_addr_cycles); 365 358 366 - if (f->col_addr_cycles == 2) { 359 + if (info->col_addr_cycles == 2) { 367 360 /* large block, 2 cycles for column address 368 361 * row address starts from 3rd cycle 369 362 */ 370 363 info->ndcb1 |= (page_addr << 16) | (column & 0xffff); 371 - if (f->row_addr_cycles == 3) 364 + if (info->row_addr_cycles == 3) 372 365 info->ndcb2 = (page_addr >> 16) & 0xff; 373 366 } else 374 367 /* small block, 1 cycles for column address ··· 629 622 int column, int page_addr) 630 623 { 631 624 struct pxa3xx_nand_info *info = mtd->priv; 632 - struct pxa3xx_nand_flash *flash_info = info->flash_info; 625 + const struct pxa3xx_nand_flash *flash_info = info->flash_info; 633 626 const struct pxa3xx_nand_cmdset *cmdset = flash_info->cmdset; 634 627 int ret; 635 628 ··· 708 701 info->use_dma = 0; /* force PIO read */ 709 702 info->buf_start = 0; 710 703 info->buf_count = (command == NAND_CMD_READID) ? 711 - flash_info->read_id_bytes : 1; 704 + info->read_id_bytes : 1; 712 705 713 706 if (prepare_other_cmd(info, (command == NAND_CMD_READID) ? 714 707 cmdset->read_id : cmdset->read_status)) ··· 849 842 850 843 static int __readid(struct pxa3xx_nand_info *info, uint32_t *id) 851 844 { 852 - struct pxa3xx_nand_flash *f = info->flash_info; 845 + const struct pxa3xx_nand_flash *f = info->flash_info; 853 846 const struct pxa3xx_nand_cmdset *cmdset = f->cmdset; 854 847 uint32_t ndcr; 855 848 uint8_t id_buff[8]; ··· 879 872 } 880 873 881 874 static int pxa3xx_nand_config_flash(struct pxa3xx_nand_info *info, 882 - struct pxa3xx_nand_flash *f) 875 + const struct pxa3xx_nand_flash *f) 883 876 { 884 877 struct platform_device *pdev = info->pdev; 885 878 struct pxa3xx_nand_platform_data *pdata = pdev->dev.platform_data; ··· 892 885 return -EINVAL; 893 886 894 887 /* calculate flash information */ 895 - f->oob_size = (f->page_size == 2048) ? 64 : 16; 896 - f->read_id_bytes = (f->page_size == 2048) ? 4 : 2; 888 + info->oob_size = (f->page_size == 2048) ? 64 : 16; 889 + info->read_id_bytes = (f->page_size == 2048) ? 4 : 2; 897 890 898 891 /* calculate addressing information */ 899 - f->col_addr_cycles = (f->page_size == 2048) ? 2 : 1; 892 + info->col_addr_cycles = (f->page_size == 2048) ? 2 : 1; 900 893 901 894 if (f->num_blocks * f->page_per_block > 65536) 902 - f->row_addr_cycles = 3; 895 + info->row_addr_cycles = 3; 903 896 else 904 - f->row_addr_cycles = 2; 897 + info->row_addr_cycles = 2; 905 898 906 899 ndcr |= (pdata->enable_arbiter) ? NDCR_ND_ARB_EN : 0; 907 - ndcr |= (f->col_addr_cycles == 2) ? NDCR_RA_START : 0; 900 + ndcr |= (info->col_addr_cycles == 2) ? NDCR_RA_START : 0; 908 901 ndcr |= (f->page_per_block == 64) ? NDCR_PG_PER_BLK : 0; 909 902 ndcr |= (f->page_size == 2048) ? NDCR_PAGE_SZ : 0; 910 903 ndcr |= (f->flash_width == 16) ? NDCR_DWIDTH_M : 0; 911 904 ndcr |= (f->dfc_width == 16) ? NDCR_DWIDTH_C : 0; 912 905 913 - ndcr |= NDCR_RD_ID_CNT(f->read_id_bytes); 906 + ndcr |= NDCR_RD_ID_CNT(info->read_id_bytes); 914 907 ndcr |= NDCR_SPARE_EN; /* enable spare by default */ 915 908 916 909 info->reg_ndcr = ndcr; ··· 923 916 static int pxa3xx_nand_detect_flash(struct pxa3xx_nand_info *info, 924 917 const struct pxa3xx_nand_platform_data *pdata) 925 918 { 926 - struct pxa3xx_nand_flash *f; 919 + const struct pxa3xx_nand_flash *f; 927 920 uint32_t id; 928 921 int i; 929 922 ··· 1018 1011 static void pxa3xx_nand_init_mtd(struct mtd_info *mtd, 1019 1012 struct pxa3xx_nand_info *info) 1020 1013 { 1021 - struct pxa3xx_nand_flash *f = info->flash_info; 1014 + const struct pxa3xx_nand_flash *f = info->flash_info; 1022 1015 struct nand_chip *this = &info->nand_chip; 1023 1016 1024 1017 this->options = (f->flash_width == 16) ? NAND_BUSWIDTH_16: 0;