flash.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * ATNGW100 board-specific flash initialization
  3. *
  4. * Copyright (C) 2005-2006 Atmel Corporation
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/init.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/mtd/mtd.h>
  13. #include <linux/mtd/partitions.h>
  14. #include <linux/mtd/physmap.h>
  15. #include <mach/smc.h>
  16. static struct smc_timing flash_timing __initdata = {
  17. .ncs_read_setup = 0,
  18. .nrd_setup = 40,
  19. .ncs_write_setup = 0,
  20. .nwe_setup = 10,
  21. .ncs_read_pulse = 80,
  22. .nrd_pulse = 40,
  23. .ncs_write_pulse = 65,
  24. .nwe_pulse = 55,
  25. .read_cycle = 120,
  26. .write_cycle = 120,
  27. };
  28. static struct smc_config flash_config __initdata = {
  29. .bus_width = 2,
  30. .nrd_controlled = 1,
  31. .nwe_controlled = 1,
  32. .byte_write = 1,
  33. };
  34. static struct mtd_partition flash_parts[] = {
  35. {
  36. .name = "u-boot",
  37. .offset = 0x00000000,
  38. .size = 0x00020000, /* 128 KiB */
  39. .mask_flags = MTD_WRITEABLE,
  40. },
  41. {
  42. .name = "root",
  43. .offset = 0x00020000,
  44. .size = 0x007d0000,
  45. },
  46. {
  47. .name = "env",
  48. .offset = 0x007f0000,
  49. .size = 0x00010000,
  50. .mask_flags = MTD_WRITEABLE,
  51. },
  52. };
  53. static struct physmap_flash_data flash_data = {
  54. .width = 2,
  55. .nr_parts = ARRAY_SIZE(flash_parts),
  56. .parts = flash_parts,
  57. };
  58. static struct resource flash_resource = {
  59. .start = 0x00000000,
  60. .end = 0x007fffff,
  61. .flags = IORESOURCE_MEM,
  62. };
  63. static struct platform_device flash_device = {
  64. .name = "physmap-flash",
  65. .id = 0,
  66. .resource = &flash_resource,
  67. .num_resources = 1,
  68. .dev = {
  69. .platform_data = &flash_data,
  70. },
  71. };
  72. /* This needs to be called after the SMC has been initialized */
  73. static int __init atngw100_flash_init(void)
  74. {
  75. int ret;
  76. smc_set_timing(&flash_config, &flash_timing);
  77. ret = smc_set_configuration(0, &flash_config);
  78. if (ret < 0) {
  79. printk(KERN_ERR "atngw100: failed to set NOR flash timing\n");
  80. return ret;
  81. }
  82. platform_device_register(&flash_device);
  83. return 0;
  84. }
  85. device_initcall(atngw100_flash_init);