gumstix.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 "hw.h"
  36. #include "pxa.h"
  37. #include "net/net.h"
  38. #include "flash.h"
  39. #include "devices.h"
  40. #include "boards.h"
  41. #include "sysemu/blockdev.h"
  42. #include "exec/address-spaces.h"
  43. static const int sector_len = 128 * 1024;
  44. static void connex_init(QEMUMachineInitArgs *args)
  45. {
  46. PXA2xxState *cpu;
  47. DriveInfo *dinfo;
  48. int be;
  49. MemoryRegion *address_space_mem = get_system_memory();
  50. uint32_t connex_rom = 0x01000000;
  51. uint32_t connex_ram = 0x04000000;
  52. cpu = pxa255_init(address_space_mem, connex_ram);
  53. dinfo = drive_get(IF_PFLASH, 0, 0);
  54. if (!dinfo) {
  55. fprintf(stderr, "A flash image must be given with the "
  56. "'pflash' parameter\n");
  57. exit(1);
  58. }
  59. #ifdef TARGET_WORDS_BIGENDIAN
  60. be = 1;
  61. #else
  62. be = 0;
  63. #endif
  64. if (!pflash_cfi01_register(0x00000000, NULL, "connext.rom", connex_rom,
  65. dinfo->bdrv, sector_len, connex_rom / sector_len,
  66. 2, 0, 0, 0, 0, be)) {
  67. fprintf(stderr, "qemu: Error registering flash memory.\n");
  68. exit(1);
  69. }
  70. /* Interrupt line of NIC is connected to GPIO line 36 */
  71. smc91c111_init(&nd_table[0], 0x04000300,
  72. qdev_get_gpio_in(cpu->gpio, 36));
  73. }
  74. static void verdex_init(QEMUMachineInitArgs *args)
  75. {
  76. const char *cpu_model = args->cpu_model;
  77. PXA2xxState *cpu;
  78. DriveInfo *dinfo;
  79. int be;
  80. MemoryRegion *address_space_mem = get_system_memory();
  81. uint32_t verdex_rom = 0x02000000;
  82. uint32_t verdex_ram = 0x10000000;
  83. cpu = pxa270_init(address_space_mem, verdex_ram, cpu_model ?: "pxa270-c0");
  84. dinfo = drive_get(IF_PFLASH, 0, 0);
  85. if (!dinfo) {
  86. fprintf(stderr, "A flash image must be given with the "
  87. "'pflash' parameter\n");
  88. exit(1);
  89. }
  90. #ifdef TARGET_WORDS_BIGENDIAN
  91. be = 1;
  92. #else
  93. be = 0;
  94. #endif
  95. if (!pflash_cfi01_register(0x00000000, NULL, "verdex.rom", verdex_rom,
  96. dinfo->bdrv, sector_len, verdex_rom / sector_len,
  97. 2, 0, 0, 0, 0, be)) {
  98. fprintf(stderr, "qemu: Error registering flash memory.\n");
  99. exit(1);
  100. }
  101. /* Interrupt line of NIC is connected to GPIO line 99 */
  102. smc91c111_init(&nd_table[0], 0x04000300,
  103. qdev_get_gpio_in(cpu->gpio, 99));
  104. }
  105. static QEMUMachine connex_machine = {
  106. .name = "connex",
  107. .desc = "Gumstix Connex (PXA255)",
  108. .init = connex_init,
  109. DEFAULT_MACHINE_OPTIONS,
  110. };
  111. static QEMUMachine verdex_machine = {
  112. .name = "verdex",
  113. .desc = "Gumstix Verdex (PXA270)",
  114. .init = verdex_init,
  115. DEFAULT_MACHINE_OPTIONS,
  116. };
  117. static void gumstix_machine_init(void)
  118. {
  119. qemu_register_machine(&connex_machine);
  120. qemu_register_machine(&verdex_machine);
  121. }
  122. machine_init(gumstix_machine_init);