Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / u-boot / board / kup / common / kup.c
1 /*
2  * (C) Copyright 2004
3  * Klaus Heydeck, Kieback & Peter GmbH & Co KG, heydeck@kieback-peter.de.
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7
8 #include <common.h>
9 #include <mpc8xx.h>
10 #include "kup.h"
11 #include <asm/io.h>
12
13
14 int misc_init_f(void)
15 {
16         volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
17         volatile sysconf8xx_t *siu = &immap->im_siu_conf;
18
19         while (in_be32(&siu->sc_sipend) & 0x20000000) {
20                 debug("waiting for 5V VCC\n");
21         }
22
23         /* RS232 / RS485 default is RS232 */
24         clrbits_be16(&immap->im_ioport.iop_padat, PA_RS485);
25         clrbits_be16(&immap->im_ioport.iop_papar, PA_RS485);
26         clrbits_be16(&immap->im_ioport.iop_paodr, PA_RS485);
27         setbits_be16(&immap->im_ioport.iop_padir, PA_RS485);
28
29         /* IO Reset min 1 msec */
30         setbits_be16(&immap->im_ioport.iop_padat,
31                                  (PA_RESET_IO_01 | PA_RESET_IO_02));
32         clrbits_be16(&immap->im_ioport.iop_papar,
33                                  (PA_RESET_IO_01 | PA_RESET_IO_02));
34         clrbits_be16(&immap->im_ioport.iop_paodr,
35                                  (PA_RESET_IO_01 | PA_RESET_IO_02));
36         setbits_be16(&immap->im_ioport.iop_padir,
37                                  (PA_RESET_IO_01 | PA_RESET_IO_02));
38         udelay(1000);
39         clrbits_be16(&immap->im_ioport.iop_padat,
40                                  (PA_RESET_IO_01 | PA_RESET_IO_02));
41         return (0);
42 }
43
44 #ifdef CONFIG_IDE_LED
45 void ide_led(uchar led, uchar status)
46 {
47         volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
48
49         /* We have one led for both pcmcia slots */
50         if (status)
51                 clrbits_be16(&immap->im_ioport.iop_padat, PA_LED_YELLOW);
52         else
53                 setbits_be16(&immap->im_ioport.iop_padat, PA_LED_YELLOW);
54 }
55 #endif
56
57 void poweron_key(void)
58 {
59         volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
60
61         clrbits_be16(&immap->im_ioport.iop_pcpar, PC_SWITCH1);
62         clrbits_be16(&immap->im_ioport.iop_pcdir, PC_SWITCH1);
63
64         if (in_be16(&immap->im_ioport.iop_pcdat) & (PC_SWITCH1))
65                 setenv("key1", "off");
66         else
67                 setenv("key1", "on");
68 }