wdenk | 0608e04 | 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 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
| 25 | #include <mpc8xx.h> |
| 26 | #include "kup.h" |
Heiko Schocher | e604e40 | 2010-07-19 23:46:48 +0200 | [diff] [blame^] | 27 | #include <asm/io.h> |
wdenk | 0608e04 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 28 | |
Heiko Schocher | e604e40 | 2010-07-19 23:46:48 +0200 | [diff] [blame^] | 29 | |
| 30 | int misc_init_f(void) |
wdenk | 0608e04 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 31 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 32 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | 0608e04 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 33 | volatile sysconf8xx_t *siu = &immap->im_siu_conf; |
| 34 | |
Heiko Schocher | e604e40 | 2010-07-19 23:46:48 +0200 | [diff] [blame^] | 35 | while (in_be32(&siu->sc_sipend) & 0x20000000) { |
| 36 | debug("waiting for 5V VCC\n"); |
wdenk | 0608e04 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | /* RS232 / RS485 default is RS232 */ |
Heiko Schocher | e604e40 | 2010-07-19 23:46:48 +0200 | [diff] [blame^] | 40 | clrbits_be16(&immap->im_ioport.iop_padat, PA_RS485); |
| 41 | clrbits_be16(&immap->im_ioport.iop_papar, PA_RS485); |
| 42 | clrbits_be16(&immap->im_ioport.iop_paodr, PA_RS485); |
| 43 | setbits_be16(&immap->im_ioport.iop_padir, PA_RS485); |
| 44 | |
| 45 | /* IO Reset min 1 msec */ |
| 46 | setbits_be16(&immap->im_ioport.iop_padat, |
| 47 | (PA_RESET_IO_01 | PA_RESET_IO_02)); |
| 48 | clrbits_be16(&immap->im_ioport.iop_papar, |
| 49 | (PA_RESET_IO_01 | PA_RESET_IO_02)); |
| 50 | clrbits_be16(&immap->im_ioport.iop_paodr, |
| 51 | (PA_RESET_IO_01 | PA_RESET_IO_02)); |
| 52 | setbits_be16(&immap->im_ioport.iop_padir, |
| 53 | (PA_RESET_IO_01 | PA_RESET_IO_02)); |
| 54 | udelay(1000); |
| 55 | clrbits_be16(&immap->im_ioport.iop_padat, |
| 56 | (PA_RESET_IO_01 | PA_RESET_IO_02)); |
wdenk | 0608e04 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 57 | return (0); |
| 58 | } |
| 59 | |
wdenk | 0608e04 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 60 | #ifdef CONFIG_IDE_LED |
Heiko Schocher | e604e40 | 2010-07-19 23:46:48 +0200 | [diff] [blame^] | 61 | void ide_led(uchar led, uchar status) |
wdenk | 0608e04 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 62 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 63 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | 0608e04 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 64 | |
| 65 | /* We have one led for both pcmcia slots */ |
Heiko Schocher | e604e40 | 2010-07-19 23:46:48 +0200 | [diff] [blame^] | 66 | if (status) |
| 67 | clrbits_be16(&immap->im_ioport.iop_padat, PA_LED_YELLOW); |
| 68 | else |
| 69 | setbits_be16(&immap->im_ioport.iop_padat, PA_LED_YELLOW); |
wdenk | 0608e04 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 70 | } |
| 71 | #endif |
| 72 | |
Heiko Schocher | e604e40 | 2010-07-19 23:46:48 +0200 | [diff] [blame^] | 73 | void poweron_key(void) |
wdenk | 0608e04 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 74 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 75 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | 0608e04 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 76 | |
Heiko Schocher | e604e40 | 2010-07-19 23:46:48 +0200 | [diff] [blame^] | 77 | clrbits_be16(&immap->im_ioport.iop_pcpar, PC_SWITCH1); |
| 78 | clrbits_be16(&immap->im_ioport.iop_pcdir, PC_SWITCH1); |
wdenk | 0608e04 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 79 | |
Heiko Schocher | e604e40 | 2010-07-19 23:46:48 +0200 | [diff] [blame^] | 80 | if (in_be16(&immap->im_ioport.iop_pcdat) & (PC_SWITCH1)) |
| 81 | setenv("key1", "off"); |
wdenk | 0608e04 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 82 | else |
Heiko Schocher | e604e40 | 2010-07-19 23:46:48 +0200 | [diff] [blame^] | 83 | setenv("key1", "on"); |
wdenk | 0608e04 | 2004-03-25 19:29:38 +0000 | [diff] [blame] | 84 | } |