flash.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* Handle mapping of the flash on the ASB2303 board
  2. *
  3. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #include <linux/init.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/mtd/partitions.h>
  14. #include <linux/mtd/physmap.h>
  15. #define ASB2303_PROM_ADDR 0xA0000000 /* Boot PROM */
  16. #define ASB2303_PROM_SIZE (2 * 1024 * 1024)
  17. #define ASB2303_FLASH_ADDR 0xA4000000 /* System Flash */
  18. #define ASB2303_FLASH_SIZE (32 * 1024 * 1024)
  19. #define ASB2303_CONFIG_ADDR 0xA6000000 /* System Config EEPROM */
  20. #define ASB2303_CONFIG_SIZE (8 * 1024)
  21. /*
  22. * default MTD partition table for both main flash devices, expected to be
  23. * overridden by RedBoot
  24. */
  25. static struct mtd_partition asb2303_partitions[] = {
  26. {
  27. .name = "Bootloader",
  28. .size = 0x00040000,
  29. .offset = 0,
  30. .mask_flags = MTD_CAP_ROM /* force read-only */
  31. }, {
  32. .name = "Kernel",
  33. .size = 0x00400000,
  34. .offset = 0x00040000,
  35. }, {
  36. .name = "Filesystem",
  37. .size = MTDPART_SIZ_FULL,
  38. .offset = 0x00440000
  39. }
  40. };
  41. /*
  42. * the ASB2303 Boot PROM definition
  43. */
  44. static struct physmap_flash_data asb2303_bootprom_data = {
  45. .width = 2,
  46. .nr_parts = 1,
  47. .parts = asb2303_partitions,
  48. };
  49. static struct resource asb2303_bootprom_resource = {
  50. .start = ASB2303_PROM_ADDR,
  51. .end = ASB2303_PROM_ADDR + ASB2303_PROM_SIZE,
  52. .flags = IORESOURCE_MEM,
  53. };
  54. static struct platform_device asb2303_bootprom = {
  55. .name = "physmap-flash",
  56. .id = 0,
  57. .dev.platform_data = &asb2303_bootprom_data,
  58. .num_resources = 1,
  59. .resource = &asb2303_bootprom_resource,
  60. };
  61. /*
  62. * the ASB2303 System Flash definition
  63. */
  64. static struct physmap_flash_data asb2303_sysflash_data = {
  65. .width = 4,
  66. .nr_parts = 1,
  67. .parts = asb2303_partitions,
  68. };
  69. static struct resource asb2303_sysflash_resource = {
  70. .start = ASB2303_FLASH_ADDR,
  71. .end = ASB2303_FLASH_ADDR + ASB2303_FLASH_SIZE,
  72. .flags = IORESOURCE_MEM,
  73. };
  74. static struct platform_device asb2303_sysflash = {
  75. .name = "physmap-flash",
  76. .id = 1,
  77. .dev.platform_data = &asb2303_sysflash_data,
  78. .num_resources = 1,
  79. .resource = &asb2303_sysflash_resource,
  80. };
  81. /*
  82. * register the ASB2303 flashes
  83. */
  84. static int __init asb2303_mtd_init(void)
  85. {
  86. platform_device_register(&asb2303_bootprom);
  87. platform_device_register(&asb2303_sysflash);
  88. return 0;
  89. }
  90. device_initcall(asb2303_mtd_init);