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