405ep.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * (C) Copyright 2010
  3. * Dirk Eibach, Guntermann & Drunck GmbH, eibach@gdsys.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 <command.h>
  25. #include <asm/processor.h>
  26. #include <asm/io.h>
  27. #include <asm/ppc4xx-gpio.h>
  28. #include "../common/fpga.h"
  29. #define LATCH0_BASE (CONFIG_SYS_LATCH_BASE)
  30. #define LATCH1_BASE (CONFIG_SYS_LATCH_BASE + 0x100)
  31. #define LATCH2_BASE (CONFIG_SYS_LATCH_BASE + 0x200)
  32. #define REFLECTION_TESTPATTERN 0xdede
  33. #define REFLECTION_TESTPATTERN_INV (~REFLECTION_TESTPATTERN & 0xffff)
  34. int board_early_init_f(void)
  35. {
  36. mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
  37. mtdcr(UIC0ER, 0x00000000); /* disable all ints */
  38. mtdcr(UIC0CR, 0x00000000); /* set all to be non-critical */
  39. mtdcr(UIC0PR, 0xFFFFFF80); /* set int polarities */
  40. mtdcr(UIC0TR, 0x10000000); /* set int trigger levels */
  41. mtdcr(UIC0VCR, 0x00000001); /* set vect base=0,INT0 highest prio */
  42. mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
  43. /*
  44. * EBC Configuration Register: set ready timeout to 512 ebc-clks
  45. * -> ca. 15 us
  46. */
  47. mtebc(EBC0_CFG, 0xa8400000); /* ebc always driven */
  48. /*
  49. * setup io-latches for reset
  50. */
  51. out_le16((void *)LATCH0_BASE, CONFIG_SYS_LATCH0_RESET);
  52. out_le16((void *)LATCH1_BASE, CONFIG_SYS_LATCH1_RESET);
  53. /*
  54. * set "startup-finished"-gpios
  55. */
  56. gpio_write_bit(21, 0);
  57. gpio_write_bit(22, 1);
  58. /*
  59. * wait for fpga-done
  60. * fail ungraceful if fpga is not configuring properly
  61. */
  62. while (!(in_le16((void *)LATCH2_BASE) & 0x0010))
  63. ;
  64. /*
  65. * setup io-latches for boot (stop reset)
  66. */
  67. udelay(10);
  68. out_le16((void *)LATCH0_BASE, CONFIG_SYS_LATCH0_BOOT);
  69. out_le16((void *)LATCH1_BASE, CONFIG_SYS_LATCH1_BOOT);
  70. /*
  71. * wait for fpga out of reset
  72. * fail ungraceful if fpga is not working properly
  73. */
  74. while (1) {
  75. fpga_set_reg(CONFIG_SYS_FPGA_RFL_LOW, REFLECTION_TESTPATTERN);
  76. if (fpga_get_reg(CONFIG_SYS_FPGA_RFL_HIGH) ==
  77. REFLECTION_TESTPATTERN_INV)
  78. break;
  79. }
  80. return 0;
  81. }