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

[MTD] [NAND] TXx9: add NDFMC support

Add platform support for NAND Flash Memory Controller of TXx9 SoCs.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Acked-By: Ralf Bächle <ralf@linux-mips.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

authored by

Atsushi Nemoto and committed by
David Woodhouse
a591f5d3 fc371a25

+98
+30
arch/mips/include/asm/txx9/ndfmc.h
··· 1 + /* 2 + * This program is free software; you can redistribute it and/or modify 3 + * it under the terms of the GNU General Public License version 2 as 4 + * published by the Free Software Foundation. 5 + * 6 + * (C) Copyright TOSHIBA CORPORATION 2007 7 + */ 8 + #ifndef __ASM_TXX9_NDFMC_H 9 + #define __ASM_TXX9_NDFMC_H 10 + 11 + #define NDFMC_PLAT_FLAG_USE_BSPRT 0x01 12 + #define NDFMC_PLAT_FLAG_NO_RSTR 0x02 13 + #define NDFMC_PLAT_FLAG_HOLDADD 0x04 14 + #define NDFMC_PLAT_FLAG_DUMMYWRITE 0x08 15 + 16 + struct txx9ndfmc_platform_data { 17 + unsigned int shift; 18 + unsigned int gbus_clock; 19 + unsigned int hold; /* hold time in nanosecond */ 20 + unsigned int spw; /* strobe pulse width in nanosecond */ 21 + unsigned int flags; 22 + unsigned char ch_mask; /* available channel bitmask */ 23 + unsigned char wp_mask; /* write-protect bitmask */ 24 + unsigned char wide_mask; /* 16bit-nand bitmask */ 25 + }; 26 + 27 + void txx9_ndfmc_init(unsigned long baseaddr, 28 + const struct txx9ndfmc_platform_data *plat_data); 29 + 30 + #endif /* __ASM_TXX9_NDFMC_H */
+1
arch/mips/include/asm/txx9/tx4938.h
··· 291 291 void tx4938_setup_pcierr_irq(void); 292 292 void tx4938_irq_init(void); 293 293 void tx4938_mtd_init(int ch); 294 + void tx4938_ndfmc_init(unsigned int hold, unsigned int spw); 294 295 295 296 struct tx4938ide_platform_info { 296 297 /*
+2
arch/mips/include/asm/txx9/tx4939.h
··· 542 542 void tx4939_mtd_init(int ch); 543 543 void tx4939_ata_init(void); 544 544 void tx4939_rtc_init(void); 545 + void tx4939_ndfmc_init(unsigned int hold, unsigned int spw, 546 + unsigned char ch_mask, unsigned char wide_mask); 545 547 546 548 #endif /* __ASM_TXX9_TX4939_H */
+21
arch/mips/txx9/generic/setup.c
··· 32 32 #include <asm/txx9/generic.h> 33 33 #include <asm/txx9/pci.h> 34 34 #include <asm/txx9tmr.h> 35 + #include <asm/txx9/ndfmc.h> 35 36 #ifdef CONFIG_CPU_TX49XX 36 37 #include <asm/txx9/tx4938.h> 37 38 #endif ··· 684 683 } 685 684 #endif 686 685 pdev = platform_device_alloc("physmap-flash", no); 686 + if (!pdev || 687 + platform_device_add_resources(pdev, &res, 1) || 688 + platform_device_add_data(pdev, pdata, sizeof(*pdata)) || 689 + platform_device_add(pdev)) 690 + platform_device_put(pdev); 691 + #endif 692 + } 693 + 694 + void __init txx9_ndfmc_init(unsigned long baseaddr, 695 + const struct txx9ndfmc_platform_data *pdata) 696 + { 697 + #if defined(CONFIG_MTD_NAND_TXX9NDFMC) || \ 698 + defined(CONFIG_MTD_NAND_TXX9NDFMC_MODULE) 699 + struct resource res = { 700 + .start = baseaddr, 701 + .end = baseaddr + 0x1000 - 1, 702 + .flags = IORESOURCE_MEM, 703 + }; 704 + struct platform_device *pdev = platform_device_alloc("txx9ndfmc", -1); 705 + 687 706 if (!pdev || 688 707 platform_device_add_resources(pdev, &res, 1) || 689 708 platform_device_add_data(pdev, pdata, sizeof(*pdata)) ||
+21
arch/mips/txx9/generic/setup_tx4938.c
··· 23 23 #include <asm/txx9tmr.h> 24 24 #include <asm/txx9pio.h> 25 25 #include <asm/txx9/generic.h> 26 + #include <asm/txx9/ndfmc.h> 26 27 #include <asm/txx9/tx4938.h> 27 28 28 29 static void __init tx4938_wdr_init(void) ··· 381 380 platform_device_add_data(pdev, &pdata, sizeof(pdata)) || 382 381 platform_device_add(pdev)) 383 382 platform_device_put(pdev); 383 + } 384 + 385 + void __init tx4938_ndfmc_init(unsigned int hold, unsigned int spw) 386 + { 387 + struct txx9ndfmc_platform_data plat_data = { 388 + .shift = 1, 389 + .gbus_clock = txx9_gbus_clock, 390 + .hold = hold, 391 + .spw = spw, 392 + .ch_mask = 1, 393 + }; 394 + unsigned long baseaddr = TX4938_NDFMC_REG & 0xfffffffffULL; 395 + 396 + #ifdef __BIG_ENDIAN 397 + baseaddr += 4; 398 + #endif 399 + if ((__raw_readq(&tx4938_ccfgptr->pcfg) & 400 + (TX4938_PCFG_ATA_SEL|TX4938_PCFG_ISA_SEL|TX4938_PCFG_NDF_SEL)) == 401 + TX4938_PCFG_NDF_SEL) 402 + txx9_ndfmc_init(baseaddr, &plat_data); 384 403 } 385 404 386 405 static void __init tx4938_stop_unused_modules(void)
+17
arch/mips/txx9/generic/setup_tx4939.c
··· 27 27 #include <asm/txx9irq.h> 28 28 #include <asm/txx9tmr.h> 29 29 #include <asm/txx9/generic.h> 30 + #include <asm/txx9/ndfmc.h> 30 31 #include <asm/txx9/tx4939.h> 31 32 32 33 static void __init tx4939_wdr_init(void) ··· 456 455 }; 457 456 458 457 platform_device_register(&rtc_dev); 458 + } 459 + 460 + void __init tx4939_ndfmc_init(unsigned int hold, unsigned int spw, 461 + unsigned char ch_mask, unsigned char wide_mask) 462 + { 463 + struct txx9ndfmc_platform_data plat_data = { 464 + .shift = 1, 465 + .gbus_clock = txx9_gbus_clock, 466 + .hold = hold, 467 + .spw = spw, 468 + .flags = NDFMC_PLAT_FLAG_NO_RSTR | NDFMC_PLAT_FLAG_HOLDADD | 469 + NDFMC_PLAT_FLAG_DUMMYWRITE, 470 + .ch_mask = ch_mask, 471 + .wide_mask = wide_mask, 472 + }; 473 + txx9_ndfmc_init(TX4939_NDFMC_REG & 0xfffffffffULL, &plat_data); 459 474 } 460 475 461 476 static void __init tx4939_stop_unused_modules(void)
+2
arch/mips/txx9/rbtx4938/setup.c
··· 352 352 rbtx4938_ne_init(); 353 353 tx4938_wdt_init(); 354 354 rbtx4938_mtd_init(); 355 + /* TC58DVM82A1FT: tDH=10ns, tWP=tRP=tREADID=35ns */ 356 + tx4938_ndfmc_init(10, 35); 355 357 tx4938_ata_init(RBTX4938_IRQ_IOC_ATA, 0, 1); 356 358 txx9_iocled_init(RBTX4938_LED_ADDR - IO_BASE, -1, 8, 1, "green", NULL); 357 359 }
+4
arch/mips/txx9/rbtx4939/setup.c
··· 333 333 platform_device_add_data(pdev, &smc_pdata, sizeof(smc_pdata)) || 334 334 platform_device_add(pdev)) 335 335 platform_device_put(pdev); 336 + /* TC58DVM82A1FT: tDH=10ns, tWP=tRP=tREADID=35ns */ 337 + tx4939_ndfmc_init(10, 35, 338 + (1 << 1) | (1 << 2), 339 + (1 << 2)); /* ch1:8bit, ch2:16bit */ 336 340 rbtx4939_led_setup(); 337 341 tx4939_wdt_init(); 338 342 tx4939_ata_init();