gumstix.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * Gumstix Platforms
  3. *
  4. * Copyright (c) 2007 by Thorsten Zitterell <info@bitmux.org>
  5. *
  6. * Code based on spitz platform by Andrzej Zaborowski <balrog@zabor.org>
  7. *
  8. * This code is licensed under the GNU GPL v2.
  9. *
  10. * Contributions after 2012-01-13 are licensed under the terms of the
  11. * GNU GPL, version 2 or (at your option) any later version.
  12. */
  13. /*
  14. * Example usage:
  15. *
  16. * connex:
  17. * =======
  18. * create image:
  19. * # dd of=flash bs=1k count=16k if=/dev/zero
  20. * # dd of=flash bs=1k conv=notrunc if=u-boot.bin
  21. * # dd of=flash bs=1k conv=notrunc seek=256 if=rootfs.arm_nofpu.jffs2
  22. * start it:
  23. * # qemu-system-arm -M connex -pflash flash -monitor null -nographic
  24. *
  25. * verdex:
  26. * =======
  27. * create image:
  28. * # dd of=flash bs=1k count=32k if=/dev/zero
  29. * # dd of=flash bs=1k conv=notrunc if=u-boot.bin
  30. * # dd of=flash bs=1k conv=notrunc seek=256 if=rootfs.arm_nofpu.jffs2
  31. * # dd of=flash bs=1k conv=notrunc seek=31744 if=uImage
  32. * start it:
  33. * # qemu-system-arm -M verdex -pflash flash -monitor null -nographic -m 289
  34. */
  35. #include "qemu/osdep.h"
  36. #include "qemu/error-report.h"
  37. #include "hw/arm/pxa.h"
  38. #include "net/net.h"
  39. #include "hw/block/flash.h"
  40. #include "hw/net/smc91c111.h"
  41. #include "hw/boards.h"
  42. #include "exec/address-spaces.h"
  43. #include "sysemu/qtest.h"
  44. #include "cpu.h"
  45. static const int sector_len = 128 * 1024;
  46. static void connex_init(MachineState *machine)
  47. {
  48. PXA2xxState *cpu;
  49. DriveInfo *dinfo;
  50. int be;
  51. MemoryRegion *address_space_mem = get_system_memory();
  52. uint32_t connex_rom = 0x01000000;
  53. uint32_t connex_ram = 0x04000000;
  54. cpu = pxa255_init(address_space_mem, connex_ram);
  55. dinfo = drive_get(IF_PFLASH, 0, 0);
  56. if (!dinfo && !qtest_enabled()) {
  57. error_report("A flash image must be given with the "
  58. "'pflash' parameter");
  59. exit(1);
  60. }
  61. #ifdef TARGET_WORDS_BIGENDIAN
  62. be = 1;
  63. #else
  64. be = 0;
  65. #endif
  66. if (!pflash_cfi01_register(0x00000000, "connext.rom", connex_rom,
  67. dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
  68. sector_len, 2, 0, 0, 0, 0, be)) {
  69. error_report("Error registering flash memory");
  70. exit(1);
  71. }
  72. /* Interrupt line of NIC is connected to GPIO line 36 */
  73. smc91c111_init(&nd_table[0], 0x04000300,
  74. qdev_get_gpio_in(cpu->gpio, 36));
  75. }
  76. static void verdex_init(MachineState *machine)
  77. {
  78. PXA2xxState *cpu;
  79. DriveInfo *dinfo;
  80. int be;
  81. MemoryRegion *address_space_mem = get_system_memory();
  82. uint32_t verdex_rom = 0x02000000;
  83. uint32_t verdex_ram = 0x10000000;
  84. cpu = pxa270_init(address_space_mem, verdex_ram, machine->cpu_type);
  85. dinfo = drive_get(IF_PFLASH, 0, 0);
  86. if (!dinfo && !qtest_enabled()) {
  87. error_report("A flash image must be given with the "
  88. "'pflash' parameter");
  89. exit(1);
  90. }
  91. #ifdef TARGET_WORDS_BIGENDIAN
  92. be = 1;
  93. #else
  94. be = 0;
  95. #endif
  96. if (!pflash_cfi01_register(0x00000000, "verdex.rom", verdex_rom,
  97. dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
  98. sector_len, 2, 0, 0, 0, 0, be)) {
  99. error_report("Error registering flash memory");
  100. exit(1);
  101. }
  102. /* Interrupt line of NIC is connected to GPIO line 99 */
  103. smc91c111_init(&nd_table[0], 0x04000300,
  104. qdev_get_gpio_in(cpu->gpio, 99));
  105. }
  106. static void connex_class_init(ObjectClass *oc, void *data)
  107. {
  108. MachineClass *mc = MACHINE_CLASS(oc);
  109. mc->desc = "Gumstix Connex (PXA255)";
  110. mc->init = connex_init;
  111. mc->ignore_memory_transaction_failures = true;
  112. }
  113. static const TypeInfo connex_type = {
  114. .name = MACHINE_TYPE_NAME("connex"),
  115. .parent = TYPE_MACHINE,
  116. .class_init = connex_class_init,
  117. };
  118. static void verdex_class_init(ObjectClass *oc, void *data)
  119. {
  120. MachineClass *mc = MACHINE_CLASS(oc);
  121. mc->desc = "Gumstix Verdex (PXA270)";
  122. mc->init = verdex_init;
  123. mc->ignore_memory_transaction_failures = true;
  124. mc->default_cpu_type = ARM_CPU_TYPE_NAME("pxa270-c0");
  125. }
  126. static const TypeInfo verdex_type = {
  127. .name = MACHINE_TYPE_NAME("verdex"),
  128. .parent = TYPE_MACHINE,
  129. .class_init = verdex_class_init,
  130. };
  131. static void gumstix_machine_init(void)
  132. {
  133. type_register_static(&connex_type);
  134. type_register_static(&verdex_type);
  135. }
  136. type_init(gumstix_machine_init)