summaryrefslogtreecommitdiff
path: root/board/kup/common/kup.c
blob: 03ab018c8977b2fd49bea61204060c1798f6d66c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
 * (C) Copyright 2004
 * Klaus Heydeck, Kieback & Peter GmbH & Co KG, heydeck@kieback-peter.de.
 *
 * SPDX-License-Identifier:	GPL-2.0+
 */

#include <common.h>
#include <mpc8xx.h>
#include "kup.h"
#include <asm/io.h>


int misc_init_f(void)
{
	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
	volatile sysconf8xx_t *siu = &immap->im_siu_conf;

	while (in_be32(&siu->sc_sipend) & 0x20000000) {
		debug("waiting for 5V VCC\n");
	}

	/* RS232 / RS485 default is RS232 */
	clrbits_be16(&immap->im_ioport.iop_padat, PA_RS485);
	clrbits_be16(&immap->im_ioport.iop_papar, PA_RS485);
	clrbits_be16(&immap->im_ioport.iop_paodr, PA_RS485);
	setbits_be16(&immap->im_ioport.iop_padir, PA_RS485);

	/* IO Reset min 1 msec */
	setbits_be16(&immap->im_ioport.iop_padat,
				 (PA_RESET_IO_01 | PA_RESET_IO_02));
	clrbits_be16(&immap->im_ioport.iop_papar,
				 (PA_RESET_IO_01 | PA_RESET_IO_02));
	clrbits_be16(&immap->im_ioport.iop_paodr,
				 (PA_RESET_IO_01 | PA_RESET_IO_02));
	setbits_be16(&immap->im_ioport.iop_padir,
				 (PA_RESET_IO_01 | PA_RESET_IO_02));
	udelay(1000);
	clrbits_be16(&immap->im_ioport.iop_padat,
				 (PA_RESET_IO_01 | PA_RESET_IO_02));
	return (0);
}

#ifdef CONFIG_IDE_LED
void ide_led(uchar led, uchar status)
{
	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;

	/* We have one led for both pcmcia slots */
	if (status)
		clrbits_be16(&immap->im_ioport.iop_padat, PA_LED_YELLOW);
	else
		setbits_be16(&immap->im_ioport.iop_padat, PA_LED_YELLOW);
}
#endif

void poweron_key(void)
{
	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;

	clrbits_be16(&immap->im_ioport.iop_pcpar, PC_SWITCH1);
	clrbits_be16(&immap->im_ioport.iop_pcdir, PC_SWITCH1);

	if (in_be16(&immap->im_ioport.iop_pcdat) & (PC_SWITCH1))
		setenv("key1", "off");
	else
		setenv("key1", "on");
}