root / hw / tosa.c @ 5ef98b47
History | View | Annotate | Download (3.7 kB)
1 | 89cdb6af | balrog | /* vim:set shiftwidth=4 ts=4 et: */
|
---|---|---|---|
2 | 89cdb6af | balrog | /*
|
3 | 89cdb6af | balrog | * PXA255 Sharp Zaurus SL-6000 PDA platform
|
4 | 89cdb6af | balrog | *
|
5 | 89cdb6af | balrog | * Copyright (c) 2008 Dmitry Baryshkov
|
6 | 89cdb6af | balrog | *
|
7 | 89cdb6af | balrog | * Code based on spitz platform by Andrzej Zaborowski <balrog@zabor.org>
|
8 | 89cdb6af | balrog | * This code is licensed under the GNU GPL v2.
|
9 | 89cdb6af | balrog | */
|
10 | 89cdb6af | balrog | |
11 | 89cdb6af | balrog | #include "hw.h" |
12 | 89cdb6af | balrog | #include "pxa.h" |
13 | 89cdb6af | balrog | #include "arm-misc.h" |
14 | 89cdb6af | balrog | #include "sysemu.h" |
15 | 88d2c950 | balrog | #include "devices.h" |
16 | 89cdb6af | balrog | #include "sharpsl.h" |
17 | 89cdb6af | balrog | #include "pcmcia.h" |
18 | 89cdb6af | balrog | #include "block.h" |
19 | 89cdb6af | balrog | #include "boards.h" |
20 | 89cdb6af | balrog | |
21 | 89cdb6af | balrog | #define TOSA_RAM 0x04000000 |
22 | 89cdb6af | balrog | #define TOSA_ROM 0x00800000 |
23 | 89cdb6af | balrog | |
24 | 89cdb6af | balrog | #define TOSA_GPIO_nSD_DETECT (9) |
25 | 89cdb6af | balrog | #define TOSA_GPIO_ON_RESET (19) |
26 | 89cdb6af | balrog | #define TOSA_GPIO_CF_IRQ (21) /* CF slot0 Ready */ |
27 | 89cdb6af | balrog | #define TOSA_GPIO_CF_CD (13) |
28 | 89cdb6af | balrog | #define TOSA_GPIO_JC_CF_IRQ (36) /* CF slot1 Ready */ |
29 | 89cdb6af | balrog | |
30 | 89cdb6af | balrog | #define TOSA_SCOOP_GPIO_BASE 0 |
31 | 89cdb6af | balrog | #define TOSA_GPIO_IR_POWERDWN (TOSA_SCOOP_GPIO_BASE + 2) |
32 | 89cdb6af | balrog | #define TOSA_GPIO_SD_WP (TOSA_SCOOP_GPIO_BASE + 3) |
33 | 89cdb6af | balrog | #define TOSA_GPIO_PWR_ON (TOSA_SCOOP_GPIO_BASE + 4) |
34 | 89cdb6af | balrog | |
35 | 89cdb6af | balrog | static void tosa_microdrive_attach(struct pxa2xx_state_s *cpu) |
36 | 89cdb6af | balrog | { |
37 | 89cdb6af | balrog | struct pcmcia_card_s *md;
|
38 | 89cdb6af | balrog | int index;
|
39 | 89cdb6af | balrog | BlockDriverState *bs; |
40 | 89cdb6af | balrog | |
41 | 89cdb6af | balrog | index = drive_get_index(IF_IDE, 0, 0); |
42 | 89cdb6af | balrog | if (index == -1) |
43 | 89cdb6af | balrog | return;
|
44 | 89cdb6af | balrog | bs = drives_table[index].bdrv; |
45 | 89cdb6af | balrog | if (bdrv_is_inserted(bs) && !bdrv_is_removable(bs)) {
|
46 | 89cdb6af | balrog | md = dscm1xxxx_init(bs); |
47 | 89cdb6af | balrog | pxa2xx_pcmcia_attach(cpu->pcmcia[0], md);
|
48 | 89cdb6af | balrog | } |
49 | 89cdb6af | balrog | } |
50 | 89cdb6af | balrog | |
51 | 89cdb6af | balrog | static void tosa_gpio_setup(struct pxa2xx_state_s *cpu, |
52 | 89cdb6af | balrog | struct scoop_info_s *scp0,
|
53 | 89cdb6af | balrog | struct scoop_info_s *scp1)
|
54 | 89cdb6af | balrog | { |
55 | 89cdb6af | balrog | /* MMC/SD host */
|
56 | 89cdb6af | balrog | pxa2xx_mmci_handlers(cpu->mmc, |
57 | 89cdb6af | balrog | scoop_gpio_in_get(scp0)[TOSA_GPIO_SD_WP], |
58 | 89cdb6af | balrog | qemu_irq_invert(pxa2xx_gpio_in_get(cpu->gpio)[TOSA_GPIO_nSD_DETECT])); |
59 | 89cdb6af | balrog | |
60 | 89cdb6af | balrog | /* Handle reset */
|
61 | 89cdb6af | balrog | pxa2xx_gpio_out_set(cpu->gpio, TOSA_GPIO_ON_RESET, cpu->reset); |
62 | 89cdb6af | balrog | |
63 | 89cdb6af | balrog | /* PCMCIA signals: card's IRQ and Card-Detect */
|
64 | 89cdb6af | balrog | pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[0],
|
65 | 89cdb6af | balrog | pxa2xx_gpio_in_get(cpu->gpio)[TOSA_GPIO_CF_IRQ], |
66 | 89cdb6af | balrog | pxa2xx_gpio_in_get(cpu->gpio)[TOSA_GPIO_CF_CD]); |
67 | 89cdb6af | balrog | |
68 | 89cdb6af | balrog | pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[1],
|
69 | 89cdb6af | balrog | pxa2xx_gpio_in_get(cpu->gpio)[TOSA_GPIO_JC_CF_IRQ], |
70 | 89cdb6af | balrog | NULL);
|
71 | 89cdb6af | balrog | |
72 | 89cdb6af | balrog | } |
73 | 89cdb6af | balrog | |
74 | 89cdb6af | balrog | static struct arm_boot_info tosa_binfo = { |
75 | 89cdb6af | balrog | .loader_start = PXA2XX_SDRAM_BASE, |
76 | 89cdb6af | balrog | .ram_size = 0x04000000,
|
77 | 89cdb6af | balrog | }; |
78 | 89cdb6af | balrog | |
79 | 89cdb6af | balrog | static void tosa_init(ram_addr_t ram_size, int vga_ram_size, |
80 | 89cdb6af | balrog | const char *boot_device, DisplayState *ds, |
81 | 89cdb6af | balrog | const char *kernel_filename, const char *kernel_cmdline, |
82 | 89cdb6af | balrog | const char *initrd_filename, const char *cpu_model) |
83 | 89cdb6af | balrog | { |
84 | 89cdb6af | balrog | struct pxa2xx_state_s *cpu;
|
85 | 89cdb6af | balrog | struct scoop_info_s *scp0, *scp1;
|
86 | 89cdb6af | balrog | |
87 | 89cdb6af | balrog | if (ram_size < (TOSA_RAM + TOSA_ROM + PXA2XX_INTERNAL_SIZE)) {
|
88 | 89cdb6af | balrog | fprintf(stderr, "This platform requires %i bytes of memory\n",
|
89 | 89cdb6af | balrog | TOSA_RAM + TOSA_ROM + PXA2XX_INTERNAL_SIZE); |
90 | 89cdb6af | balrog | exit(1);
|
91 | 89cdb6af | balrog | } |
92 | 89cdb6af | balrog | |
93 | 89cdb6af | balrog | if (!cpu_model)
|
94 | 89cdb6af | balrog | cpu_model = "pxa255";
|
95 | 89cdb6af | balrog | |
96 | 89cdb6af | balrog | cpu = pxa255_init(tosa_binfo.ram_size, ds); |
97 | 89cdb6af | balrog | |
98 | 89cdb6af | balrog | cpu_register_physical_memory(0, TOSA_ROM,
|
99 | 89cdb6af | balrog | qemu_ram_alloc(TOSA_ROM) | IO_MEM_ROM); |
100 | 89cdb6af | balrog | |
101 | 88d2c950 | balrog | tc6393xb_init(0x10000000, NULL); |
102 | 89cdb6af | balrog | |
103 | 89cdb6af | balrog | scp0 = scoop_init(cpu, 0, 0x08800000); |
104 | 89cdb6af | balrog | scp1 = scoop_init(cpu, 1, 0x14800040); |
105 | 89cdb6af | balrog | |
106 | 89cdb6af | balrog | tosa_gpio_setup(cpu, scp0, scp1); |
107 | 89cdb6af | balrog | |
108 | 89cdb6af | balrog | tosa_microdrive_attach(cpu); |
109 | 89cdb6af | balrog | |
110 | 89cdb6af | balrog | /* Setup initial (reset) machine state */
|
111 | 89cdb6af | balrog | cpu->env->regs[15] = tosa_binfo.loader_start;
|
112 | 89cdb6af | balrog | |
113 | 89cdb6af | balrog | tosa_binfo.kernel_filename = kernel_filename; |
114 | 89cdb6af | balrog | tosa_binfo.kernel_cmdline = kernel_cmdline; |
115 | 89cdb6af | balrog | tosa_binfo.initrd_filename = initrd_filename; |
116 | 89cdb6af | balrog | tosa_binfo.board_id = 0x208;
|
117 | 89cdb6af | balrog | arm_load_kernel(cpu->env, &tosa_binfo); |
118 | 89cdb6af | balrog | sl_bootparam_write(SL_PXA_PARAM_BASE - PXA2XX_SDRAM_BASE); |
119 | 89cdb6af | balrog | } |
120 | 89cdb6af | balrog | |
121 | 89cdb6af | balrog | QEMUMachine tosapda_machine = { |
122 | 89cdb6af | balrog | "tosa",
|
123 | 89cdb6af | balrog | "Tosa PDA (PXA255)",
|
124 | 89cdb6af | balrog | tosa_init, |
125 | 89cdb6af | balrog | TOSA_RAM + TOSA_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED, |
126 | 89cdb6af | balrog | }; |