kup.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. #include <common.h>
  24. #include <mpc8xx.h>
  25. #include "kup.h"
  26. #include <asm/io.h>
  27. int misc_init_f(void)
  28. {
  29. volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
  30. volatile sysconf8xx_t *siu = &immap->im_siu_conf;
  31. while (in_be32(&siu->sc_sipend) & 0x20000000) {
  32. debug("waiting for 5V VCC\n");
  33. }
  34. /* RS232 / RS485 default is RS232 */
  35. clrbits_be16(&immap->im_ioport.iop_padat, PA_RS485);
  36. clrbits_be16(&immap->im_ioport.iop_papar, PA_RS485);
  37. clrbits_be16(&immap->im_ioport.iop_paodr, PA_RS485);
  38. setbits_be16(&immap->im_ioport.iop_padir, PA_RS485);
  39. /* IO Reset min 1 msec */
  40. setbits_be16(&immap->im_ioport.iop_padat,
  41. (PA_RESET_IO_01 | PA_RESET_IO_02));
  42. clrbits_be16(&immap->im_ioport.iop_papar,
  43. (PA_RESET_IO_01 | PA_RESET_IO_02));
  44. clrbits_be16(&immap->im_ioport.iop_paodr,
  45. (PA_RESET_IO_01 | PA_RESET_IO_02));
  46. setbits_be16(&immap->im_ioport.iop_padir,
  47. (PA_RESET_IO_01 | PA_RESET_IO_02));
  48. udelay(1000);
  49. clrbits_be16(&immap->im_ioport.iop_padat,
  50. (PA_RESET_IO_01 | PA_RESET_IO_02));
  51. return (0);
  52. }
  53. #ifdef CONFIG_IDE_LED
  54. void ide_led(uchar led, uchar status)
  55. {
  56. volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
  57. /* We have one led for both pcmcia slots */
  58. if (status)
  59. clrbits_be16(&immap->im_ioport.iop_padat, PA_LED_YELLOW);
  60. else
  61. setbits_be16(&immap->im_ioport.iop_padat, PA_LED_YELLOW);
  62. }
  63. #endif
  64. void poweron_key(void)
  65. {
  66. volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
  67. clrbits_be16(&immap->im_ioport.iop_pcpar, PC_SWITCH1);
  68. clrbits_be16(&immap->im_ioport.iop_pcdir, PC_SWITCH1);
  69. if (in_be16(&immap->im_ioport.iop_pcdat) & (PC_SWITCH1))
  70. setenv("key1", "off");
  71. else
  72. setenv("key1", "on");
  73. }