217 |
217 |
static int spitz_gpio_invert[5] = { 0, 0, 0, 0, 0, };
|
218 |
218 |
|
219 |
219 |
struct spitz_keyboard_s {
|
220 |
|
struct pxa2xx_state_s *cpu;
|
|
220 |
qemu_irq sense[SPITZ_KEY_SENSE_NUM];
|
|
221 |
qemu_irq *strobe;
|
|
222 |
qemu_irq gpiomap[5];
|
221 |
223 |
int keymap[0x80];
|
222 |
224 |
uint16_t keyrow[SPITZ_KEY_SENSE_NUM];
|
223 |
225 |
uint16_t strobe_state;
|
... | ... | |
240 |
242 |
if (strobe) {
|
241 |
243 |
sense |= 1 << i;
|
242 |
244 |
if (!(s->sense_state & (1 << i)))
|
243 |
|
pxa2xx_gpio_set(s->cpu->gpio, spitz_gpio_key_sense[i], 1);
|
|
245 |
qemu_irq_raise(s->sense[i]);
|
244 |
246 |
} else if (s->sense_state & (1 << i))
|
245 |
|
pxa2xx_gpio_set(s->cpu->gpio, spitz_gpio_key_sense[i], 0);
|
|
247 |
qemu_irq_lower(s->sense[i]);
|
246 |
248 |
}
|
247 |
249 |
|
248 |
250 |
s->sense_state = sense;
|
249 |
251 |
}
|
250 |
252 |
|
251 |
|
static void spitz_keyboard_strobe(int line, int level,
|
252 |
|
struct spitz_keyboard_s *s)
|
|
253 |
static void spitz_keyboard_strobe(void *opaque, int line, int level)
|
253 |
254 |
{
|
254 |
|
int i;
|
255 |
|
for (i = 0; i < SPITZ_KEY_STROBE_NUM; i ++)
|
256 |
|
if (spitz_gpio_key_strobe[i] == line) {
|
257 |
|
if (level)
|
258 |
|
s->strobe_state |= 1 << i;
|
259 |
|
else
|
260 |
|
s->strobe_state &= ~(1 << i);
|
261 |
|
|
262 |
|
spitz_keyboard_sense_update(s);
|
263 |
|
break;
|
264 |
|
}
|
|
255 |
struct spitz_keyboard_s *s = (struct spitz_keyboard_s *) opaque;
|
|
256 |
|
|
257 |
if (level)
|
|
258 |
s->strobe_state |= 1 << line;
|
|
259 |
else
|
|
260 |
s->strobe_state &= ~(1 << line);
|
|
261 |
spitz_keyboard_sense_update(s);
|
265 |
262 |
}
|
266 |
263 |
|
267 |
264 |
static void spitz_keyboard_keydown(struct spitz_keyboard_s *s, int keycode)
|
... | ... | |
272 |
269 |
|
273 |
270 |
/* Handle the additional keys */
|
274 |
271 |
if ((spitz_keycode >> 4) == SPITZ_KEY_SENSE_NUM) {
|
275 |
|
pxa2xx_gpio_set(s->cpu->gpio, spitz_gpiomap[spitz_keycode & 0xf],
|
276 |
|
(keycode < 0x80) ^
|
|
272 |
qemu_set_irq(s->gpiomap[spitz_keycode & 0xf], (keycode < 0x80) ^
|
277 |
273 |
spitz_gpio_invert[spitz_keycode & 0xf]);
|
278 |
274 |
return;
|
279 |
275 |
}
|
... | ... | |
486 |
482 |
s = (struct spitz_keyboard_s *)
|
487 |
483 |
qemu_mallocz(sizeof(struct spitz_keyboard_s));
|
488 |
484 |
memset(s, 0, sizeof(struct spitz_keyboard_s));
|
489 |
|
s->cpu = cpu;
|
490 |
485 |
|
491 |
486 |
for (i = 0; i < 0x80; i ++)
|
492 |
487 |
s->keymap[i] = -1;
|
... | ... | |
495 |
490 |
if (spitz_keymap[i][j] != -1)
|
496 |
491 |
s->keymap[spitz_keymap[i][j]] = (i << 4) | j;
|
497 |
492 |
|
|
493 |
for (i = 0; i < SPITZ_KEY_SENSE_NUM; i ++)
|
|
494 |
s->sense[i] = pxa2xx_gpio_in_get(cpu->gpio)[spitz_gpio_key_sense[i]];
|
|
495 |
|
|
496 |
for (i = 0; i < 5; i ++)
|
|
497 |
s->gpiomap[i] = pxa2xx_gpio_in_get(cpu->gpio)[spitz_gpiomap[i]];
|
|
498 |
|
|
499 |
s->strobe = qemu_allocate_irqs(spitz_keyboard_strobe, s,
|
|
500 |
SPITZ_KEY_STROBE_NUM);
|
498 |
501 |
for (i = 0; i < SPITZ_KEY_STROBE_NUM; i ++)
|
499 |
|
pxa2xx_gpio_handler_set(cpu->gpio, spitz_gpio_key_strobe[i],
|
500 |
|
(gpio_handler_t) spitz_keyboard_strobe, s);
|
|
502 |
pxa2xx_gpio_out_set(cpu->gpio, spitz_gpio_key_strobe[i], s->strobe[i]);
|
501 |
503 |
|
502 |
504 |
spitz_keyboard_pre_map(s);
|
503 |
505 |
qemu_add_kbd_event_handler((QEMUPutKBDEvent *) spitz_keyboard_handler, s);
|
... | ... | |
510 |
512 |
|
511 |
513 |
struct scoop_info_s {
|
512 |
514 |
target_phys_addr_t target_base;
|
|
515 |
qemu_irq handler[16];
|
|
516 |
qemu_irq *in;
|
513 |
517 |
uint16_t status;
|
514 |
518 |
uint16_t power;
|
515 |
519 |
uint32_t gpio_level;
|
516 |
520 |
uint32_t gpio_dir;
|
517 |
521 |
uint32_t prev_level;
|
518 |
|
struct {
|
519 |
|
gpio_handler_t fn;
|
520 |
|
void *opaque;
|
521 |
|
} handler[16];
|
522 |
522 |
|
523 |
523 |
uint16_t mcr;
|
524 |
524 |
uint16_t cdr;
|
... | ... | |
548 |
548 |
|
549 |
549 |
for (diff = s->prev_level ^ level; diff; diff ^= 1 << bit) {
|
550 |
550 |
bit = ffs(diff) - 1;
|
551 |
|
if (s->handler[bit].fn)
|
552 |
|
s->handler[bit].fn(bit, (level >> bit) & 1,
|
553 |
|
s->handler[bit].opaque);
|
|
551 |
qemu_set_irq(s->handler[bit], (level >> bit) & 1);
|
554 |
552 |
}
|
555 |
553 |
|
556 |
554 |
s->prev_level = level;
|
... | ... | |
648 |
646 |
scoop_writeb,
|
649 |
647 |
};
|
650 |
648 |
|
651 |
|
static inline void scoop_gpio_set(struct scoop_info_s *s, int line, int level)
|
|
649 |
static void scoop_gpio_set(void *opaque, int line, int level)
|
652 |
650 |
{
|
653 |
|
if (line >= 16) {
|
654 |
|
spitz_printf("No GPIO pin %i\n", line);
|
655 |
|
return;
|
656 |
|
}
|
|
651 |
struct scoop_info_s *s = (struct scoop_info_s *) s;
|
657 |
652 |
|
658 |
653 |
if (level)
|
659 |
654 |
s->gpio_level |= (1 << line);
|
... | ... | |
661 |
656 |
s->gpio_level &= ~(1 << line);
|
662 |
657 |
}
|
663 |
658 |
|
664 |
|
static inline void scoop_gpio_handler_set(struct scoop_info_s *s, int line,
|
665 |
|
gpio_handler_t handler, void *opaque) {
|
|
659 |
static inline qemu_irq *scoop_gpio_in_get(struct scoop_info_s *s)
|
|
660 |
{
|
|
661 |
return s->in;
|
|
662 |
}
|
|
663 |
|
|
664 |
static inline void scoop_gpio_out_set(struct scoop_info_s *s, int line,
|
|
665 |
qemu_irq handler) {
|
666 |
666 |
if (line >= 16) {
|
667 |
667 |
spitz_printf("No GPIO pin %i\n", line);
|
668 |
668 |
return;
|
669 |
669 |
}
|
670 |
670 |
|
671 |
|
s->handler[line].fn = handler;
|
672 |
|
s->handler[line].opaque = opaque;
|
|
671 |
s->handler[line] = handler;
|
673 |
672 |
}
|
674 |
673 |
|
675 |
674 |
static void scoop_save(QEMUFile *f, void *opaque)
|
... | ... | |
723 |
722 |
s[0].status = 0x02;
|
724 |
723 |
s[1].status = 0x02;
|
725 |
724 |
|
|
725 |
s[0].in = qemu_allocate_irqs(scoop_gpio_set, &s[0], 16);
|
726 |
726 |
iomemtype = cpu_register_io_memory(0, scoop_readfn,
|
727 |
727 |
scoop_writefn, &s[0]);
|
728 |
728 |
cpu_register_physical_memory(s[0].target_base, 0x1000, iomemtype);
|
... | ... | |
731 |
731 |
if (count < 2)
|
732 |
732 |
return s;
|
733 |
733 |
|
|
734 |
s[1].in = qemu_allocate_irqs(scoop_gpio_set, &s[1], 16);
|
734 |
735 |
iomemtype = cpu_register_io_memory(0, scoop_readfn,
|
735 |
736 |
scoop_writefn, &s[1]);
|
736 |
737 |
cpu_register_physical_memory(s[1].target_base, 0x1000, iomemtype);
|
... | ... | |
760 |
761 |
spitz_printf("LCD Backlight now off\n");
|
761 |
762 |
}
|
762 |
763 |
|
763 |
|
static void spitz_bl_bit5(int line, int level, void *opaque)
|
|
764 |
static inline void spitz_bl_bit5(void *opaque, int line, int level)
|
764 |
765 |
{
|
765 |
766 |
int prev = bl_intensity;
|
766 |
767 |
|
... | ... | |
773 |
774 |
spitz_bl_update((struct pxa2xx_state_s *) opaque);
|
774 |
775 |
}
|
775 |
776 |
|
776 |
|
static void spitz_bl_power(int line, int level, void *opaque)
|
|
777 |
static inline void spitz_bl_power(void *opaque, int line, int level)
|
777 |
778 |
{
|
778 |
779 |
bl_power = !!level;
|
779 |
780 |
spitz_bl_update((struct pxa2xx_state_s *) opaque);
|
... | ... | |
841 |
842 |
max111x_write(max1111, value);
|
842 |
843 |
}
|
843 |
844 |
|
844 |
|
static void corgi_ssp_gpio_cs(int line, int level, struct pxa2xx_state_s *s)
|
|
845 |
static void corgi_ssp_gpio_cs(void *opaque, int line, int level)
|
845 |
846 |
{
|
846 |
|
if (line == SPITZ_GPIO_LCDCON_CS)
|
|
847 |
switch (line) {
|
|
848 |
case 0:
|
847 |
849 |
lcd_en = !level;
|
848 |
|
else if (line == SPITZ_GPIO_ADS7846_CS)
|
|
850 |
break;
|
|
851 |
case 1:
|
849 |
852 |
ads_en = !level;
|
850 |
|
else if (line == SPITZ_GPIO_MAX1111_CS)
|
|
853 |
break;
|
|
854 |
case 2:
|
851 |
855 |
max_en = !level;
|
|
856 |
break;
|
|
857 |
}
|
852 |
858 |
}
|
853 |
859 |
|
854 |
860 |
#define MAX1111_BATT_VOLT 1
|
... | ... | |
859 |
865 |
#define SPITZ_BATTERY_VOLT 0xd0 /* About 4.0V */
|
860 |
866 |
#define SPITZ_CHARGEON_ACIN 0x80 /* About 5.0V */
|
861 |
867 |
|
862 |
|
static void spitz_adc_temp_on(int line, int level, void *opaque)
|
|
868 |
static void spitz_adc_temp_on(void *opaque, int line, int level)
|
863 |
869 |
{
|
864 |
870 |
if (!max1111)
|
865 |
871 |
return;
|
... | ... | |
870 |
876 |
max111x_set_input(max1111, MAX1111_BATT_TEMP, 0);
|
871 |
877 |
}
|
872 |
878 |
|
873 |
|
static void spitz_pendown_set(void *opaque, int line, int level)
|
874 |
|
{
|
875 |
|
struct pxa2xx_state_s *cpu = (struct pxa2xx_state_s *) opaque;
|
876 |
|
pxa2xx_gpio_set(cpu->gpio, SPITZ_GPIO_TP_INT, level);
|
877 |
|
}
|
878 |
|
|
879 |
879 |
static void spitz_ssp_save(QEMUFile *f, void *opaque)
|
880 |
880 |
{
|
881 |
881 |
qemu_put_be32(f, lcd_en);
|
... | ... | |
898 |
898 |
|
899 |
899 |
static void spitz_ssp_attach(struct pxa2xx_state_s *cpu)
|
900 |
900 |
{
|
|
901 |
qemu_irq *chipselects;
|
|
902 |
|
901 |
903 |
lcd_en = ads_en = max_en = 0;
|
902 |
904 |
|
903 |
|
ads7846 = ads7846_init(qemu_allocate_irqs(spitz_pendown_set, cpu, 1)[0]);
|
|
905 |
ads7846 = ads7846_init(pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_TP_INT]);
|
904 |
906 |
|
905 |
907 |
max1111 = max1111_init(0);
|
906 |
908 |
max111x_set_input(max1111, MAX1111_BATT_VOLT, SPITZ_BATTERY_VOLT);
|
... | ... | |
910 |
912 |
pxa2xx_ssp_attach(cpu->ssp[CORGI_SSP_PORT - 1], corgi_ssp_read,
|
911 |
913 |
corgi_ssp_write, cpu);
|
912 |
914 |
|
913 |
|
pxa2xx_gpio_handler_set(cpu->gpio, SPITZ_GPIO_LCDCON_CS,
|
914 |
|
(gpio_handler_t) corgi_ssp_gpio_cs, cpu);
|
915 |
|
pxa2xx_gpio_handler_set(cpu->gpio, SPITZ_GPIO_ADS7846_CS,
|
916 |
|
(gpio_handler_t) corgi_ssp_gpio_cs, cpu);
|
917 |
|
pxa2xx_gpio_handler_set(cpu->gpio, SPITZ_GPIO_MAX1111_CS,
|
918 |
|
(gpio_handler_t) corgi_ssp_gpio_cs, cpu);
|
|
915 |
chipselects = qemu_allocate_irqs(corgi_ssp_gpio_cs, cpu, 3);
|
|
916 |
pxa2xx_gpio_out_set(cpu->gpio, SPITZ_GPIO_LCDCON_CS, chipselects[0]);
|
|
917 |
pxa2xx_gpio_out_set(cpu->gpio, SPITZ_GPIO_ADS7846_CS, chipselects[1]);
|
|
918 |
pxa2xx_gpio_out_set(cpu->gpio, SPITZ_GPIO_MAX1111_CS, chipselects[2]);
|
919 |
919 |
|
920 |
920 |
bl_intensity = 0x20;
|
921 |
921 |
bl_power = 0;
|
... | ... | |
945 |
945 |
#define SPITZ_GPIO_WM 5
|
946 |
946 |
|
947 |
947 |
#ifdef HAS_AUDIO
|
948 |
|
static void spitz_wm8750_addr(int line, int level, void *opaque)
|
|
948 |
static void spitz_wm8750_addr(void *opaque, int line, int level)
|
949 |
949 |
{
|
950 |
950 |
i2c_slave *wm = (i2c_slave *) opaque;
|
951 |
951 |
if (level)
|
... | ... | |
970 |
970 |
/* Attach a WM8750 to the bus */
|
971 |
971 |
wm = wm8750_init(bus, audio);
|
972 |
972 |
|
973 |
|
spitz_wm8750_addr(0, 0, wm);
|
974 |
|
pxa2xx_gpio_handler_set(cpu->gpio, SPITZ_GPIO_WM, spitz_wm8750_addr, wm);
|
|
973 |
spitz_wm8750_addr(wm, 0, 0);
|
|
974 |
pxa2xx_gpio_out_set(cpu->gpio, SPITZ_GPIO_WM,
|
|
975 |
qemu_allocate_irqs(spitz_wm8750_addr, wm, 1)[0]);
|
975 |
976 |
/* .. and to the sound interface. */
|
976 |
977 |
cpu->i2s->opaque = wm;
|
977 |
978 |
cpu->i2s->codec_out = wm8750_dac_dat;
|
... | ... | |
989 |
990 |
|
990 |
991 |
/* Other peripherals */
|
991 |
992 |
|
992 |
|
static void spitz_charge_switch(int line, int level, void *opaque)
|
|
993 |
static void spitz_out_switch(void *opaque, int line, int level)
|
993 |
994 |
{
|
994 |
|
spitz_printf("Charging %s.\n", level ? "off" : "on");
|
995 |
|
}
|
996 |
|
|
997 |
|
static void spitz_discharge_switch(int line, int level, void *opaque)
|
998 |
|
{
|
999 |
|
spitz_printf("Discharging %s.\n", level ? "on" : "off");
|
1000 |
|
}
|
1001 |
|
|
1002 |
|
static void spitz_greenled_switch(int line, int level, void *opaque)
|
1003 |
|
{
|
1004 |
|
spitz_printf("Green LED %s.\n", level ? "on" : "off");
|
1005 |
|
}
|
1006 |
|
|
1007 |
|
static void spitz_orangeled_switch(int line, int level, void *opaque)
|
1008 |
|
{
|
1009 |
|
spitz_printf("Orange LED %s.\n", level ? "on" : "off");
|
|
995 |
switch (line) {
|
|
996 |
case 0:
|
|
997 |
spitz_printf("Charging %s.\n", level ? "off" : "on");
|
|
998 |
break;
|
|
999 |
case 1:
|
|
1000 |
spitz_printf("Discharging %s.\n", level ? "on" : "off");
|
|
1001 |
break;
|
|
1002 |
case 2:
|
|
1003 |
spitz_printf("Green LED %s.\n", level ? "on" : "off");
|
|
1004 |
break;
|
|
1005 |
case 3:
|
|
1006 |
spitz_printf("Orange LED %s.\n", level ? "on" : "off");
|
|
1007 |
break;
|
|
1008 |
case 4:
|
|
1009 |
spitz_bl_bit5(opaque, line, level);
|
|
1010 |
break;
|
|
1011 |
case 5:
|
|
1012 |
spitz_bl_power(opaque, line, level);
|
|
1013 |
break;
|
|
1014 |
case 6:
|
|
1015 |
spitz_adc_temp_on(opaque, line, level);
|
|
1016 |
break;
|
|
1017 |
}
|
1010 |
1018 |
}
|
1011 |
1019 |
|
1012 |
1020 |
#define SPITZ_SCP_LED_GREEN 1
|
... | ... | |
1027 |
1035 |
static void spitz_scoop_gpio_setup(struct pxa2xx_state_s *cpu,
|
1028 |
1036 |
struct scoop_info_s *scp, int num)
|
1029 |
1037 |
{
|
1030 |
|
scoop_gpio_handler_set(&scp[0], SPITZ_SCP_CHRG_ON,
|
1031 |
|
spitz_charge_switch, cpu);
|
1032 |
|
scoop_gpio_handler_set(&scp[0], SPITZ_SCP_JK_B,
|
1033 |
|
spitz_discharge_switch, cpu);
|
1034 |
|
scoop_gpio_handler_set(&scp[0], SPITZ_SCP_LED_GREEN,
|
1035 |
|
spitz_greenled_switch, cpu);
|
1036 |
|
scoop_gpio_handler_set(&scp[0], SPITZ_SCP_LED_ORANGE,
|
1037 |
|
spitz_orangeled_switch, cpu);
|
|
1038 |
qemu_irq *outsignals = qemu_allocate_irqs(spitz_out_switch, cpu, 8);
|
|
1039 |
|
|
1040 |
scoop_gpio_out_set(&scp[0], SPITZ_SCP_CHRG_ON, outsignals[0]);
|
|
1041 |
scoop_gpio_out_set(&scp[0], SPITZ_SCP_JK_B, outsignals[1]);
|
|
1042 |
scoop_gpio_out_set(&scp[0], SPITZ_SCP_LED_GREEN, outsignals[2]);
|
|
1043 |
scoop_gpio_out_set(&scp[0], SPITZ_SCP_LED_ORANGE, outsignals[3]);
|
1038 |
1044 |
|
1039 |
1045 |
if (num >= 2) {
|
1040 |
|
scoop_gpio_handler_set(&scp[1], SPITZ_SCP2_BACKLIGHT_CONT,
|
1041 |
|
spitz_bl_bit5, cpu);
|
1042 |
|
scoop_gpio_handler_set(&scp[1], SPITZ_SCP2_BACKLIGHT_ON,
|
1043 |
|
spitz_bl_power, cpu);
|
|
1046 |
scoop_gpio_out_set(&scp[1], SPITZ_SCP2_BACKLIGHT_CONT, outsignals[4]);
|
|
1047 |
scoop_gpio_out_set(&scp[1], SPITZ_SCP2_BACKLIGHT_ON, outsignals[5]);
|
1044 |
1048 |
}
|
1045 |
1049 |
|
1046 |
|
scoop_gpio_handler_set(&scp[0], SPITZ_SCP_ADC_TEMP_ON,
|
1047 |
|
spitz_adc_temp_on, cpu);
|
|
1050 |
scoop_gpio_out_set(&scp[0], SPITZ_SCP_ADC_TEMP_ON, outsignals[6]);
|
1048 |
1051 |
}
|
1049 |
1052 |
|
1050 |
1053 |
#define SPITZ_GPIO_HSYNC 22
|
... | ... | |
1057 |
1060 |
#define SPITZ_GPIO_CF2_IRQ 106
|
1058 |
1061 |
#define SPITZ_GPIO_CF2_CD 93
|
1059 |
1062 |
|
1060 |
|
int spitz_hsync;
|
|
1063 |
static int spitz_hsync;
|
1061 |
1064 |
|
1062 |
|
static void spitz_lcd_hsync_handler(void *opaque)
|
|
1065 |
static void spitz_lcd_hsync_handler(void *opaque, int line, int level)
|
1063 |
1066 |
{
|
1064 |
1067 |
struct pxa2xx_state_s *cpu = (struct pxa2xx_state_s *) opaque;
|
1065 |
|
pxa2xx_gpio_set(cpu->gpio, SPITZ_GPIO_HSYNC, spitz_hsync);
|
|
1068 |
qemu_set_irq(pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_HSYNC], spitz_hsync);
|
1066 |
1069 |
spitz_hsync ^= 1;
|
1067 |
1070 |
}
|
1068 |
1071 |
|
1069 |
1072 |
static void spitz_mmc_coverswitch_change(void *opaque, int in)
|
1070 |
1073 |
{
|
1071 |
1074 |
struct pxa2xx_state_s *cpu = (struct pxa2xx_state_s *) opaque;
|
1072 |
|
pxa2xx_gpio_set(cpu->gpio, SPITZ_GPIO_SD_DETECT, in);
|
|
1075 |
qemu_set_irq(pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_SD_DETECT], in);
|
1073 |
1076 |
}
|
1074 |
1077 |
|
1075 |
1078 |
static void spitz_mmc_writeprotect_change(void *opaque, int wp)
|
1076 |
1079 |
{
|
1077 |
1080 |
struct pxa2xx_state_s *cpu = (struct pxa2xx_state_s *) opaque;
|
1078 |
|
pxa2xx_gpio_set(cpu->gpio, SPITZ_GPIO_SD_WP, wp);
|
1079 |
|
}
|
1080 |
|
|
1081 |
|
static void spitz_pcmcia_cb(void *opaque, int line, int level)
|
1082 |
|
{
|
1083 |
|
struct pxa2xx_state_s *cpu = (struct pxa2xx_state_s *) opaque;
|
1084 |
|
static const int gpio_map[] = {
|
1085 |
|
SPITZ_GPIO_CF1_IRQ, SPITZ_GPIO_CF1_CD,
|
1086 |
|
SPITZ_GPIO_CF2_IRQ, SPITZ_GPIO_CF2_CD,
|
1087 |
|
};
|
1088 |
|
pxa2xx_gpio_set(cpu->gpio, gpio_map[line], level);
|
|
1081 |
qemu_set_irq(pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_SD_WP], wp);
|
1089 |
1082 |
}
|
1090 |
1083 |
|
1091 |
1084 |
static void spitz_gpio_setup(struct pxa2xx_state_s *cpu, int slots)
|
1092 |
1085 |
{
|
1093 |
|
qemu_irq *pcmcia_cb;
|
|
1086 |
qemu_irq lcd_hsync;
|
1094 |
1087 |
/*
|
1095 |
1088 |
* Bad hack: We toggle the LCD hsync GPIO on every GPIO status
|
1096 |
1089 |
* read to satisfy broken guests that poll-wait for hsync.
|
... | ... | |
1098 |
1091 |
* wouldn't guarantee that a guest ever exits the loop.
|
1099 |
1092 |
*/
|
1100 |
1093 |
spitz_hsync = 0;
|
1101 |
|
pxa2xx_gpio_read_notifier(cpu->gpio, spitz_lcd_hsync_handler, cpu);
|
1102 |
|
pxa2xx_lcd_vsync_cb(cpu->lcd, spitz_lcd_hsync_handler, cpu);
|
|
1094 |
lcd_hsync = qemu_allocate_irqs(spitz_lcd_hsync_handler, cpu, 1)[0];
|
|
1095 |
pxa2xx_gpio_read_notifier(cpu->gpio, lcd_hsync);
|
|
1096 |
pxa2xx_lcd_vsync_notifier(cpu->lcd, lcd_hsync);
|
1103 |
1097 |
|
1104 |
1098 |
/* MMC/SD host */
|
1105 |
1099 |
pxa2xx_mmci_handlers(cpu->mmc, cpu, spitz_mmc_writeprotect_change,
|
1106 |
1100 |
spitz_mmc_coverswitch_change);
|
1107 |
1101 |
|
1108 |
1102 |
/* Battery lock always closed */
|
1109 |
|
pxa2xx_gpio_set(cpu->gpio, SPITZ_GPIO_BAT_COVER, 1);
|
|
1103 |
qemu_irq_raise(pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_BAT_COVER]);
|
1110 |
1104 |
|
1111 |
1105 |
/* Handle reset */
|
1112 |
|
pxa2xx_gpio_handler_set(cpu->gpio, SPITZ_GPIO_ON_RESET, pxa2xx_reset, cpu);
|
|
1106 |
pxa2xx_gpio_out_set(cpu->gpio, SPITZ_GPIO_ON_RESET, cpu->reset);
|
1113 |
1107 |
|
1114 |
1108 |
/* PCMCIA signals: card's IRQ and Card-Detect */
|
1115 |
|
pcmcia_cb = qemu_allocate_irqs(spitz_pcmcia_cb, cpu, slots * 2);
|
1116 |
1109 |
if (slots >= 1)
|
1117 |
|
pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[0], pcmcia_cb[0], pcmcia_cb[1]);
|
|
1110 |
pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[0],
|
|
1111 |
pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_CF1_IRQ],
|
|
1112 |
pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_CF1_CD]);
|
1118 |
1113 |
if (slots >= 2)
|
1119 |
|
pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[1], pcmcia_cb[2], pcmcia_cb[3]);
|
|
1114 |
pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[1],
|
|
1115 |
pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_CF2_IRQ],
|
|
1116 |
pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_CF2_CD]);
|
1120 |
1117 |
|
1121 |
1118 |
/* Initialise the screen rotation related signals */
|
1122 |
1119 |
spitz_gpio_invert[3] = 0; /* Always open */
|
... | ... | |
1125 |
1122 |
} else { /* Portrait mode */
|
1126 |
1123 |
spitz_gpio_invert[4] = 1;
|
1127 |
1124 |
}
|
1128 |
|
pxa2xx_gpio_set(cpu->gpio, SPITZ_GPIO_SWA, spitz_gpio_invert[3]);
|
1129 |
|
pxa2xx_gpio_set(cpu->gpio, SPITZ_GPIO_SWB, spitz_gpio_invert[4]);
|
|
1125 |
qemu_set_irq(pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_SWA],
|
|
1126 |
spitz_gpio_invert[3]);
|
|
1127 |
qemu_set_irq(pxa2xx_gpio_in_get(cpu->gpio)[SPITZ_GPIO_SWB],
|
|
1128 |
spitz_gpio_invert[4]);
|
1130 |
1129 |
}
|
1131 |
1130 |
|
1132 |
1131 |
/* Write the bootloader parameters memory area. */
|