flash.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * ATSTK1000 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 <asm/arch/smc.h>
  16. static struct smc_config flash_config __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. .bus_width = 2,
  28. .nrd_controlled = 1,
  29. .nwe_controlled = 1,
  30. .byte_write = 1,
  31. };
  32. static struct mtd_partition flash_parts[] = {
  33. {
  34. .name = "u-boot",
  35. .offset = 0x00000000,
  36. .size = 0x00020000, /* 128 KiB */
  37. .mask_flags = MTD_WRITEABLE,
  38. },
  39. {
  40. .name = "root",
  41. .offset = 0x00020000,
  42. .size = 0x007d0000,
  43. },
  44. {
  45. .name = "env",
  46. .offset = 0x007f0000,
  47. .size = 0x00010000,
  48. .mask_flags = MTD_WRITEABLE,
  49. },
  50. };
  51. static struct physmap_flash_data flash_data = {
  52. .width = 2,
  53. .nr_parts = ARRAY_SIZE(flash_parts),
  54. .parts = flash_parts,
  55. };
  56. static struct resource flash_resource = {
  57. .start = 0x00000000,
  58. .end = 0x007fffff,
  59. .flags = IORESOURCE_MEM,
  60. };
  61. static struct platform_device flash_device = {
  62. .name = "physmap-flash",
  63. .id = 0,
  64. .resource = &flash_resource,
  65. .num_resources = 1,
  66. .dev = {
  67. .platform_data = &flash_data,
  68. },
  69. };
  70. /* This needs to be called after the SMC has been initialized */
  71. static int __init atstk1000_flash_init(void)
  72. {
  73. int ret;
  74. ret = smc_set_configuration(0, &flash_config);
  75. if (ret < 0) {
  76. printk(KERN_ERR "atstk1000: failed to set NOR flash timing\n");
  77. return ret;
  78. }
  79. platform_device_register(&flash_device);
  80. return 0;
  81. }
  82. device_initcall(atstk1000_flash_init);