mainstone.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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 "flash.h"
  18. #include "blockdev.h"
  19. #include "sysbus.h"
  20. #include "exec-memory.h"
  21. /* Device addresses */
  22. #define MST_FPGA_PHYS 0x08000000
  23. #define MST_ETH_PHYS 0x10000300
  24. #define MST_FLASH_0 0x00000000
  25. #define MST_FLASH_1 0x04000000
  26. /* IRQ definitions */
  27. #define MMC_IRQ 0
  28. #define USIM_IRQ 1
  29. #define USBC_IRQ 2
  30. #define ETHERNET_IRQ 3
  31. #define AC97_IRQ 4
  32. #define PEN_IRQ 5
  33. #define MSINS_IRQ 6
  34. #define EXBRD_IRQ 7
  35. #define S0_CD_IRQ 9
  36. #define S0_STSCHG_IRQ 10
  37. #define S0_IRQ 11
  38. #define S1_CD_IRQ 13
  39. #define S1_STSCHG_IRQ 14
  40. #define S1_IRQ 15
  41. static struct keymap map[0xE0] = {
  42. [0 ... 0xDF] = { -1, -1 },
  43. [0x1e] = {0,0}, /* a */
  44. [0x30] = {0,1}, /* b */
  45. [0x2e] = {0,2}, /* c */
  46. [0x20] = {0,3}, /* d */
  47. [0x12] = {0,4}, /* e */
  48. [0x21] = {0,5}, /* f */
  49. [0x22] = {1,0}, /* g */
  50. [0x23] = {1,1}, /* h */
  51. [0x17] = {1,2}, /* i */
  52. [0x24] = {1,3}, /* j */
  53. [0x25] = {1,4}, /* k */
  54. [0x26] = {1,5}, /* l */
  55. [0x32] = {2,0}, /* m */
  56. [0x31] = {2,1}, /* n */
  57. [0x18] = {2,2}, /* o */
  58. [0x19] = {2,3}, /* p */
  59. [0x10] = {2,4}, /* q */
  60. [0x13] = {2,5}, /* r */
  61. [0x1f] = {3,0}, /* s */
  62. [0x14] = {3,1}, /* t */
  63. [0x16] = {3,2}, /* u */
  64. [0x2f] = {3,3}, /* v */
  65. [0x11] = {3,4}, /* w */
  66. [0x2d] = {3,5}, /* x */
  67. [0x15] = {4,2}, /* y */
  68. [0x2c] = {4,3}, /* z */
  69. [0xc7] = {5,0}, /* Home */
  70. [0x2a] = {5,1}, /* shift */
  71. [0x39] = {5,2}, /* space */
  72. [0x39] = {5,3}, /* space */
  73. [0x1c] = {5,5}, /* enter */
  74. [0xc8] = {6,0}, /* up */
  75. [0xd0] = {6,1}, /* down */
  76. [0xcb] = {6,2}, /* left */
  77. [0xcd] = {6,3}, /* right */
  78. };
  79. enum mainstone_model_e { mainstone };
  80. #define MAINSTONE_RAM 0x04000000
  81. #define MAINSTONE_ROM 0x00800000
  82. #define MAINSTONE_FLASH 0x02000000
  83. static struct arm_boot_info mainstone_binfo = {
  84. .loader_start = PXA2XX_SDRAM_BASE,
  85. .ram_size = 0x04000000,
  86. };
  87. static void mainstone_common_init(MemoryRegion *address_space_mem,
  88. ram_addr_t ram_size,
  89. const char *kernel_filename,
  90. const char *kernel_cmdline, const char *initrd_filename,
  91. const char *cpu_model, enum mainstone_model_e model, int arm_id)
  92. {
  93. uint32_t sector_len = 256 * 1024;
  94. target_phys_addr_t mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 };
  95. PXA2xxState *cpu;
  96. DeviceState *mst_irq;
  97. DriveInfo *dinfo;
  98. int i;
  99. int be;
  100. MemoryRegion *rom = g_new(MemoryRegion, 1);
  101. if (!cpu_model)
  102. cpu_model = "pxa270-c5";
  103. /* Setup CPU & memory */
  104. cpu = pxa270_init(address_space_mem, mainstone_binfo.ram_size, cpu_model);
  105. memory_region_init_ram(rom, NULL, "mainstone.rom", MAINSTONE_ROM);
  106. memory_region_set_readonly(rom, true);
  107. memory_region_add_subregion(address_space_mem, 0, rom);
  108. #ifdef TARGET_WORDS_BIGENDIAN
  109. be = 1;
  110. #else
  111. be = 0;
  112. #endif
  113. /* There are two 32MiB flash devices on the board */
  114. for (i = 0; i < 2; i ++) {
  115. dinfo = drive_get(IF_PFLASH, 0, i);
  116. if (!dinfo) {
  117. fprintf(stderr, "Two flash images must be given with the "
  118. "'pflash' parameter\n");
  119. exit(1);
  120. }
  121. if (!pflash_cfi01_register(mainstone_flash_base[i], NULL,
  122. i ? "mainstone.flash1" : "mainstone.flash0",
  123. MAINSTONE_FLASH,
  124. dinfo->bdrv, sector_len,
  125. MAINSTONE_FLASH / sector_len, 4, 0, 0, 0, 0,
  126. be)) {
  127. fprintf(stderr, "qemu: Error registering flash memory.\n");
  128. exit(1);
  129. }
  130. }
  131. mst_irq = sysbus_create_simple("mainstone-fpga", MST_FPGA_PHYS,
  132. qdev_get_gpio_in(cpu->gpio, 0));
  133. /* setup keypad */
  134. printf("map addr %p\n", &map);
  135. pxa27x_register_keypad(cpu->kp, map, 0xe0);
  136. /* MMC/SD host */
  137. pxa2xx_mmci_handlers(cpu->mmc, NULL, qdev_get_gpio_in(mst_irq, MMC_IRQ));
  138. pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[0],
  139. qdev_get_gpio_in(mst_irq, S0_IRQ),
  140. qdev_get_gpio_in(mst_irq, S0_CD_IRQ));
  141. pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[1],
  142. qdev_get_gpio_in(mst_irq, S1_IRQ),
  143. qdev_get_gpio_in(mst_irq, S1_CD_IRQ));
  144. smc91c111_init(&nd_table[0], MST_ETH_PHYS,
  145. qdev_get_gpio_in(mst_irq, ETHERNET_IRQ));
  146. mainstone_binfo.kernel_filename = kernel_filename;
  147. mainstone_binfo.kernel_cmdline = kernel_cmdline;
  148. mainstone_binfo.initrd_filename = initrd_filename;
  149. mainstone_binfo.board_id = arm_id;
  150. arm_load_kernel(cpu->env, &mainstone_binfo);
  151. }
  152. static void mainstone_init(ram_addr_t ram_size,
  153. const char *boot_device,
  154. const char *kernel_filename, const char *kernel_cmdline,
  155. const char *initrd_filename, const char *cpu_model)
  156. {
  157. mainstone_common_init(get_system_memory(), ram_size, kernel_filename,
  158. kernel_cmdline, initrd_filename, cpu_model, mainstone, 0x196);
  159. }
  160. static QEMUMachine mainstone2_machine = {
  161. .name = "mainstone",
  162. .desc = "Mainstone II (PXA27x)",
  163. .init = mainstone_init,
  164. };
  165. static void mainstone_machine_init(void)
  166. {
  167. qemu_register_machine(&mainstone2_machine);
  168. }
  169. machine_init(mainstone_machine_init);