]> git.ipfire.org Git - people/ms/u-boot.git/blame - board/kup/common/kup.c
Add GPL-2.0+ SPDX-License-Identifier to source files
[people/ms/u-boot.git] / board / kup / common / kup.c
CommitLineData
0608e04d
WD
1/*
2 * (C) Copyright 2004
3 * Klaus Heydeck, Kieback & Peter GmbH & Co KG, heydeck@kieback-peter.de.
4 *
1a459660 5 * SPDX-License-Identifier: GPL-2.0+
0608e04d
WD
6 */
7
8#include <common.h>
9#include <mpc8xx.h>
10#include "kup.h"
e604e409 11#include <asm/io.h>
0608e04d 12
e604e409
HS
13
14int misc_init_f(void)
0608e04d 15{
6d0f6bcf 16 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
0608e04d
WD
17 volatile sysconf8xx_t *siu = &immap->im_siu_conf;
18
e604e409
HS
19 while (in_be32(&siu->sc_sipend) & 0x20000000) {
20 debug("waiting for 5V VCC\n");
0608e04d
WD
21 }
22
23 /* RS232 / RS485 default is RS232 */
e604e409
HS
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));
0608e04d
WD
41 return (0);
42}
43
0608e04d 44#ifdef CONFIG_IDE_LED
e604e409 45void ide_led(uchar led, uchar status)
0608e04d 46{
6d0f6bcf 47 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
0608e04d
WD
48
49 /* We have one led for both pcmcia slots */
e604e409
HS
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);
0608e04d
WD
54}
55#endif
56
e604e409 57void poweron_key(void)
0608e04d 58{
6d0f6bcf 59 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
0608e04d 60
e604e409
HS
61 clrbits_be16(&immap->im_ioport.iop_pcpar, PC_SWITCH1);
62 clrbits_be16(&immap->im_ioport.iop_pcdir, PC_SWITCH1);
0608e04d 63
e604e409
HS
64 if (in_be16(&immap->im_ioport.iop_pcdat) & (PC_SWITCH1))
65 setenv("key1", "off");
0608e04d 66 else
e604e409 67 setenv("key1", "on");
0608e04d 68}