mainstone.c 5.5 KB

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