@@ -124,6 +124,21 @@ static void palmte_button_event(void *opaque, int keycode)
124
124
!(keycode & 0x80 ));
125
125
}
126
126
127
+ /*
128
+ * Encapsulation of some GPIO line behaviour for the Palm board
129
+ *
130
+ * QEMU interface:
131
+ * + unnamed GPIO inputs 0..6: for the various miscellaneous input lines
132
+ */
133
+
134
+ #define TYPE_PALM_MISC_GPIO "palm-misc-gpio"
135
+ #define PALM_MISC_GPIO (obj ) \
136
+ OBJECT_CHECK(PalmMiscGPIOState, (obj), TYPE_PALM_MISC_GPIO)
137
+
138
+ typedef struct PalmMiscGPIOState {
139
+ SysBusDevice parent_obj ;
140
+ } PalmMiscGPIOState ;
141
+
127
142
static void palmte_onoff_gpios (void * opaque , int line , int level )
128
143
{
129
144
switch (line ) {
@@ -151,23 +166,44 @@ static void palmte_onoff_gpios(void *opaque, int line, int level)
151
166
}
152
167
}
153
168
169
+ static void palm_misc_gpio_init (Object * obj )
170
+ {
171
+ DeviceState * dev = DEVICE (obj );
172
+
173
+ qdev_init_gpio_in (dev , palmte_onoff_gpios , 7 );
174
+ }
175
+
176
+ static const TypeInfo palm_misc_gpio_info = {
177
+ .name = TYPE_PALM_MISC_GPIO ,
178
+ .parent = TYPE_SYS_BUS_DEVICE ,
179
+ .instance_size = sizeof (PalmMiscGPIOState ),
180
+ .instance_init = palm_misc_gpio_init ,
181
+ /*
182
+ * No class init required: device has no internal state so does not
183
+ * need to set up reset or vmstate, and has no realize method.
184
+ */
185
+ };
186
+
154
187
static void palmte_gpio_setup (struct omap_mpu_state_s * cpu )
155
188
{
156
- qemu_irq * misc_gpio ;
189
+ DeviceState * misc_gpio ;
190
+
191
+ misc_gpio = sysbus_create_simple (TYPE_PALM_MISC_GPIO , -1 , NULL );
157
192
158
193
omap_mmc_handlers (cpu -> mmc ,
159
194
qdev_get_gpio_in (cpu -> gpio , PALMTE_MMC_WP_GPIO ),
160
195
qemu_irq_invert (omap_mpuio_in_get (cpu -> mpuio )
161
196
[PALMTE_MMC_SWITCH_GPIO ]));
162
197
163
- misc_gpio = qemu_allocate_irqs (palmte_onoff_gpios , cpu , 7 );
164
- qdev_connect_gpio_out (cpu -> gpio , PALMTE_MMC_POWER_GPIO , misc_gpio [0 ]);
165
- qdev_connect_gpio_out (cpu -> gpio , PALMTE_SPEAKER_GPIO , misc_gpio [1 ]);
166
- qdev_connect_gpio_out (cpu -> gpio , 11 , misc_gpio [2 ]);
167
- qdev_connect_gpio_out (cpu -> gpio , 12 , misc_gpio [3 ]);
168
- qdev_connect_gpio_out (cpu -> gpio , 13 , misc_gpio [4 ]);
169
- omap_mpuio_out_set (cpu -> mpuio , 1 , misc_gpio [5 ]);
170
- omap_mpuio_out_set (cpu -> mpuio , 3 , misc_gpio [6 ]);
198
+ qdev_connect_gpio_out (cpu -> gpio , PALMTE_MMC_POWER_GPIO ,
199
+ qdev_get_gpio_in (misc_gpio , 0 ));
200
+ qdev_connect_gpio_out (cpu -> gpio , PALMTE_SPEAKER_GPIO ,
201
+ qdev_get_gpio_in (misc_gpio , 1 ));
202
+ qdev_connect_gpio_out (cpu -> gpio , 11 , qdev_get_gpio_in (misc_gpio , 2 ));
203
+ qdev_connect_gpio_out (cpu -> gpio , 12 , qdev_get_gpio_in (misc_gpio , 3 ));
204
+ qdev_connect_gpio_out (cpu -> gpio , 13 , qdev_get_gpio_in (misc_gpio , 4 ));
205
+ omap_mpuio_out_set (cpu -> mpuio , 1 , qdev_get_gpio_in (misc_gpio , 5 ));
206
+ omap_mpuio_out_set (cpu -> mpuio , 3 , qdev_get_gpio_in (misc_gpio , 6 ));
171
207
172
208
/* Reset some inputs to initial state. */
173
209
qemu_irq_lower (qdev_get_gpio_in (cpu -> gpio , PALMTE_USBDETECT_GPIO ));
@@ -276,3 +312,10 @@ static void palmte_machine_init(MachineClass *mc)
276
312
}
277
313
278
314
DEFINE_MACHINE ("cheetah" , palmte_machine_init )
315
+
316
+ static void palm_register_types (void )
317
+ {
318
+ type_register_static (& palm_misc_gpio_info );
319
+ }
320
+
321
+ type_init (palm_register_types )
0 commit comments