blob: 03ab018c8977b2fd49bea61204060c1798f6d66c [file] [log] [blame]
wdenk65faef92004-03-25 19:29:38 +00001/*
2 * (C) Copyright 2004
3 * Klaus Heydeck, Kieback & Peter GmbH & Co KG, heydeck@kieback-peter.de.
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenk65faef92004-03-25 19:29:38 +00006 */
7
8#include <common.h>
9#include <mpc8xx.h>
10#include "kup.h"
Heiko Schocher4c934d02010-07-19 23:46:48 +020011#include <asm/io.h>
wdenk65faef92004-03-25 19:29:38 +000012
Heiko Schocher4c934d02010-07-19 23:46:48 +020013
14int misc_init_f(void)
wdenk65faef92004-03-25 19:29:38 +000015{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020016 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
wdenk65faef92004-03-25 19:29:38 +000017 volatile sysconf8xx_t *siu = &immap->im_siu_conf;
18
Heiko Schocher4c934d02010-07-19 23:46:48 +020019 while (in_be32(&siu->sc_sipend) & 0x20000000) {
20 debug("waiting for 5V VCC\n");
wdenk65faef92004-03-25 19:29:38 +000021 }
22
23 /* RS232 / RS485 default is RS232 */
Heiko Schocher4c934d02010-07-19 23:46:48 +020024 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));
wdenk65faef92004-03-25 19:29:38 +000041 return (0);
42}
43
wdenk65faef92004-03-25 19:29:38 +000044#ifdef CONFIG_IDE_LED
Heiko Schocher4c934d02010-07-19 23:46:48 +020045void ide_led(uchar led, uchar status)
wdenk65faef92004-03-25 19:29:38 +000046{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020047 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
wdenk65faef92004-03-25 19:29:38 +000048
49 /* We have one led for both pcmcia slots */
Heiko Schocher4c934d02010-07-19 23:46:48 +020050 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);
wdenk65faef92004-03-25 19:29:38 +000054}
55#endif
56
Heiko Schocher4c934d02010-07-19 23:46:48 +020057void poweron_key(void)
wdenk65faef92004-03-25 19:29:38 +000058{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020059 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
wdenk65faef92004-03-25 19:29:38 +000060
Heiko Schocher4c934d02010-07-19 23:46:48 +020061 clrbits_be16(&immap->im_ioport.iop_pcpar, PC_SWITCH1);
62 clrbits_be16(&immap->im_ioport.iop_pcdir, PC_SWITCH1);
wdenk65faef92004-03-25 19:29:38 +000063
Heiko Schocher4c934d02010-07-19 23:46:48 +020064 if (in_be16(&immap->im_ioport.iop_pcdat) & (PC_SWITCH1))
65 setenv("key1", "off");
wdenk65faef92004-03-25 19:29:38 +000066 else
Heiko Schocher4c934d02010-07-19 23:46:48 +020067 setenv("key1", "on");
wdenk65faef92004-03-25 19:29:38 +000068}