mainstone.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * PXA270-based Intel Mainstone platforms.
  3. *
  4. * Copyright (c) 2007 by Armin Kuster <akuster@kama-aina.net> or
  5. * <akuster@mvista.com>
  6. *
  7. * Code based on spitz platform by Andrzej Zaborowski <balrog@zabor.org>
  8. *
  9. * This code is licensed under the GNU GPL v2.
  10. */
  11. #include "hw.h"
  12. #include "pxa.h"
  13. #include "arm-misc.h"
  14. #include "net.h"
  15. #include "devices.h"
  16. #include "boards.h"
  17. #include "mainstone.h"
  18. #include "sysemu.h"
  19. #include "flash.h"
  20. static struct keymap map[0xE0] = {
  21. [0 ... 0xDF] = { -1, -1 },
  22. [0x1e] = {0,0}, /* a */
  23. [0x30] = {0,1}, /* b */
  24. [0x2e] = {0,2}, /* c */
  25. [0x20] = {0,3}, /* d */
  26. [0x12] = {0,4}, /* e */
  27. [0x21] = {0,5}, /* f */
  28. [0x22] = {1,0}, /* g */
  29. [0x23] = {1,1}, /* h */
  30. [0x17] = {1,2}, /* i */
  31. [0x24] = {1,3}, /* j */
  32. [0x25] = {1,4}, /* k */
  33. [0x26] = {1,5}, /* l */
  34. [0x32] = {2,0}, /* m */
  35. [0x31] = {2,1}, /* n */
  36. [0x18] = {2,2}, /* o */
  37. [0x19] = {2,3}, /* p */
  38. [0x10] = {2,4}, /* q */
  39. [0x13] = {2,5}, /* r */
  40. [0x1f] = {3,0}, /* s */
  41. [0x14] = {3,1}, /* t */
  42. [0x16] = {3,2}, /* u */
  43. [0x2f] = {3,3}, /* v */
  44. [0x11] = {3,4}, /* w */
  45. [0x2d] = {3,5}, /* x */
  46. [0x15] = {4,2}, /* y */
  47. [0x2c] = {4,3}, /* z */
  48. [0xc7] = {5,0}, /* Home */
  49. [0x2a] = {5,1}, /* shift */
  50. [0x39] = {5,2}, /* space */
  51. [0x39] = {5,3}, /* space */
  52. [0x1c] = {5,5}, /* enter */
  53. [0xc8] = {6,0}, /* up */
  54. [0xd0] = {6,1}, /* down */
  55. [0xcb] = {6,2}, /* left */
  56. [0xcd] = {6,3}, /* right */
  57. };
  58. enum mainstone_model_e { mainstone };
  59. #define MAINSTONE_RAM 0x04000000
  60. #define MAINSTONE_ROM 0x00800000
  61. #define MAINSTONE_FLASH 0x02000000
  62. static struct arm_boot_info mainstone_binfo = {
  63. .loader_start = PXA2XX_SDRAM_BASE,
  64. .ram_size = 0x04000000,
  65. };
  66. static void mainstone_common_init(ram_addr_t ram_size, int vga_ram_size,
  67. const char *kernel_filename,
  68. const char *kernel_cmdline, const char *initrd_filename,
  69. const char *cpu_model, enum mainstone_model_e model, int arm_id)
  70. {
  71. uint32_t sector_len = 256 * 1024;
  72. target_phys_addr_t mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 };
  73. struct pxa2xx_state_s *cpu;
  74. qemu_irq *mst_irq;
  75. int i, index;
  76. if (!cpu_model)
  77. cpu_model = "pxa270-c5";
  78. /* Setup CPU & memory */
  79. if (ram_size < MAINSTONE_RAM + MAINSTONE_ROM + 2 * MAINSTONE_FLASH +
  80. PXA2XX_INTERNAL_SIZE) {
  81. fprintf(stderr, "This platform requires %i bytes of memory\n",
  82. MAINSTONE_RAM + MAINSTONE_ROM + 2 * MAINSTONE_FLASH +
  83. PXA2XX_INTERNAL_SIZE);
  84. exit(1);
  85. }
  86. cpu = pxa270_init(mainstone_binfo.ram_size, cpu_model);
  87. cpu_register_physical_memory(0, MAINSTONE_ROM,
  88. qemu_ram_alloc(MAINSTONE_ROM) | IO_MEM_ROM);
  89. /* Setup initial (reset) machine state */
  90. cpu->env->regs[15] = mainstone_binfo.loader_start;
  91. /* There are two 32MiB flash devices on the board */
  92. for (i = 0; i < 2; i ++) {
  93. index = drive_get_index(IF_PFLASH, 0, i);
  94. if (index == -1) {
  95. fprintf(stderr, "Two flash images must be given with the "
  96. "'pflash' parameter\n");
  97. exit(1);
  98. }
  99. if (!pflash_cfi01_register(mainstone_flash_base[i],
  100. qemu_ram_alloc(MAINSTONE_FLASH),
  101. drives_table[index].bdrv, sector_len,
  102. MAINSTONE_FLASH / sector_len, 4, 0, 0, 0, 0)) {
  103. fprintf(stderr, "qemu: Error registering flash memory.\n");
  104. exit(1);
  105. }
  106. }
  107. mst_irq = mst_irq_init(cpu, MST_FPGA_PHYS, PXA2XX_PIC_GPIO_0);
  108. /* setup keypad */
  109. printf("map addr %p\n", &map);
  110. pxa27x_register_keypad(cpu->kp, map, 0xe0);
  111. /* MMC/SD host */
  112. pxa2xx_mmci_handlers(cpu->mmc, NULL, mst_irq[MMC_IRQ]);
  113. smc91c111_init(&nd_table[0], MST_ETH_PHYS, mst_irq[ETHERNET_IRQ]);
  114. mainstone_binfo.kernel_filename = kernel_filename;
  115. mainstone_binfo.kernel_cmdline = kernel_cmdline;
  116. mainstone_binfo.initrd_filename = initrd_filename;
  117. mainstone_binfo.board_id = arm_id;
  118. arm_load_kernel(cpu->env, &mainstone_binfo);
  119. }
  120. static void mainstone_init(ram_addr_t ram_size, int vga_ram_size,
  121. const char *boot_device,
  122. const char *kernel_filename, const char *kernel_cmdline,
  123. const char *initrd_filename, const char *cpu_model)
  124. {
  125. mainstone_common_init(ram_size, vga_ram_size, kernel_filename,
  126. kernel_cmdline, initrd_filename, cpu_model, mainstone, 0x196);
  127. }
  128. QEMUMachine mainstone2_machine = {
  129. .name = "mainstone",
  130. .desc = "Mainstone II (PXA27x)",
  131. .init = mainstone_init,
  132. .ram_require = (MAINSTONE_RAM + MAINSTONE_ROM + 2 * MAINSTONE_FLASH +
  133. PXA2XX_INTERNAL_SIZE) | RAMSIZE_FIXED,
  134. };