platform.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Generic RDC321x platform devices
  3. *
  4. * Copyright (C) 2007-2009 OpenWrt.org
  5. * Copyright (C) 2007 Florian Fainelli <[email protected]>
  6. * Copyright (C) 2008-2009 Daniel Gimpelevich <[email protected]>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301, USA.
  22. *
  23. */
  24. #include <linux/init.h>
  25. //#include <linux/kernel.h>
  26. //#include <linux/list.h>
  27. //#include <linux/device.h>
  28. #include <linux/platform_device.h>
  29. //#include <linux/version.h>
  30. //#include <linux/input.h>
  31. #include <linux/mtd/map.h>
  32. #include <linux/mtd/mtd.h>
  33. #include <linux/mtd/physmap.h>
  34. #include <linux/root_dev.h>
  35. #include <asm/rdc_boards.h>
  36. static struct rdc_platform_data rdcplat_data;
  37. /* LEDS */
  38. static struct platform_device rdc321x_leds = {
  39. .name = "leds-gpio",
  40. .id = -1,
  41. .dev = {
  42. .platform_data = &rdcplat_data.led_data,
  43. }
  44. };
  45. /* Button */
  46. static struct platform_device rdc321x_buttons = {
  47. .name = "gpio-buttons",
  48. .id = -1,
  49. .dev = {
  50. .platform_data = &rdcplat_data.button_data,
  51. }
  52. };
  53. static __initdata struct platform_device *rdc321x_devs[] = {
  54. &rdc321x_leds,
  55. &rdc321x_buttons,
  56. };
  57. const char *__initdata boards[] = {
  58. "Sitecom",
  59. "AR525W",
  60. "Bifferboard",
  61. "R8610",
  62. 0
  63. };
  64. static struct map_info rdc_map_info = {
  65. .name = "rdc_flash",
  66. .size = 0x800000, //8MB
  67. .phys = 0xFF800000, //(u32) -rdc_map_info.size;
  68. .bankwidth = 2
  69. };
  70. static int __init rdc_board_setup(void)
  71. {
  72. struct mtd_partition *partitions;
  73. int count, res;
  74. struct mtd_info *mtdinfo;
  75. simple_map_init(&rdc_map_info);
  76. while (true) {
  77. rdc_map_info.virt = ioremap(rdc_map_info.phys, rdc_map_info.size);
  78. if (rdc_map_info.virt == NULL)
  79. continue;
  80. mtdinfo = do_map_probe("cfi_probe", &rdc_map_info);
  81. if (mtdinfo == NULL)
  82. mtdinfo = do_map_probe("jedec_probe", &rdc_map_info);
  83. if (mtdinfo != NULL)
  84. break;
  85. iounmap(rdc_map_info.virt);
  86. if ((rdc_map_info.size >>= 1) < 0x100000) //1MB
  87. panic("RDC321x: Could not find start of flash!");
  88. rdc_map_info.phys = (u32) -rdc_map_info.size;
  89. }
  90. count = parse_mtd_partitions(mtdinfo, boards, &partitions, (unsigned long) &rdcplat_data);
  91. if (count <= 0) {
  92. panic("RDC321x: can't identify board type");
  93. return -ENOSYS;
  94. }
  95. ROOT_DEV = 0;
  96. res = add_mtd_partitions(mtdinfo, partitions, count);
  97. if (res)
  98. return res;
  99. return platform_add_devices(rdc321x_devs, ARRAY_SIZE(rdc321x_devs));
  100. }
  101. late_initcall(rdc_board_setup);