wdenk | 65faef9 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2004 |
| 3 | * Klaus Heydeck, Kieback & Peter GmbH & Co KG, heydeck@kieback-peter.de. |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 65faef9 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <mpc8xx.h> |
| 10 | #include "kup.h" |
Heiko Schocher | 4c934d0 | 2010-07-19 23:46:48 +0200 | [diff] [blame] | 11 | #include <asm/io.h> |
wdenk | 65faef9 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 12 | |
Heiko Schocher | 4c934d0 | 2010-07-19 23:46:48 +0200 | [diff] [blame] | 13 | |
| 14 | int misc_init_f(void) |
wdenk | 65faef9 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 15 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 16 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | 65faef9 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 17 | volatile sysconf8xx_t *siu = &immap->im_siu_conf; |
| 18 | |
Heiko Schocher | 4c934d0 | 2010-07-19 23:46:48 +0200 | [diff] [blame] | 19 | while (in_be32(&siu->sc_sipend) & 0x20000000) { |
| 20 | debug("waiting for 5V VCC\n"); |
wdenk | 65faef9 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | /* RS232 / RS485 default is RS232 */ |
Heiko Schocher | 4c934d0 | 2010-07-19 23:46:48 +0200 | [diff] [blame] | 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)); |
wdenk | 65faef9 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 41 | return (0); |
| 42 | } |
| 43 | |
wdenk | 65faef9 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 44 | #ifdef CONFIG_IDE_LED |
Heiko Schocher | 4c934d0 | 2010-07-19 23:46:48 +0200 | [diff] [blame] | 45 | void ide_led(uchar led, uchar status) |
wdenk | 65faef9 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 46 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 47 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | 65faef9 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 48 | |
| 49 | /* We have one led for both pcmcia slots */ |
Heiko Schocher | 4c934d0 | 2010-07-19 23:46:48 +0200 | [diff] [blame] | 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); |
wdenk | 65faef9 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 54 | } |
| 55 | #endif |
| 56 | |
Heiko Schocher | 4c934d0 | 2010-07-19 23:46:48 +0200 | [diff] [blame] | 57 | void poweron_key(void) |
wdenk | 65faef9 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 58 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 59 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | 65faef9 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 60 | |
Heiko Schocher | 4c934d0 | 2010-07-19 23:46:48 +0200 | [diff] [blame] | 61 | clrbits_be16(&immap->im_ioport.iop_pcpar, PC_SWITCH1); |
| 62 | clrbits_be16(&immap->im_ioport.iop_pcdir, PC_SWITCH1); |
wdenk | 65faef9 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 63 | |
Heiko Schocher | 4c934d0 | 2010-07-19 23:46:48 +0200 | [diff] [blame] | 64 | if (in_be16(&immap->im_ioport.iop_pcdat) & (PC_SWITCH1)) |
| 65 | setenv("key1", "off"); |
wdenk | 65faef9 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 66 | else |
Heiko Schocher | 4c934d0 | 2010-07-19 23:46:48 +0200 | [diff] [blame] | 67 | setenv("key1", "on"); |
wdenk | 65faef9 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 68 | } |