nbg460n.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * (C) Copyright 2010
  3. * Michael Kurz <michi.kurz@googlemail.com>.
  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 <netdev.h>
  25. #include <asm/mipsregs.h>
  26. #include <asm/addrspace.h>
  27. #include <asm/reboot.h>
  28. #include <asm/ar71xx.h>
  29. #include <asm/ar71xx_gpio.h>
  30. #define NBG460N_WAN_LED 19
  31. phys_size_t initdram(int board_type)
  32. {
  33. return (32*1024*1024);
  34. }
  35. int checkboard(void)
  36. {
  37. // Set pin 19 to 1, to stop WAN LED blinking
  38. ar71xx_setpindir(NBG460N_WAN_LED, 1);
  39. ar71xx_setpin(NBG460N_WAN_LED, 1);
  40. printf("U-boot on Zyxel NBG460N\n");
  41. return 0;
  42. }
  43. void _machine_restart(void)
  44. {
  45. for (;;) {
  46. writel((RESET_MODULE_FULL_CHIP | RESET_MODULE_DDR),
  47. KSEG1ADDR(AR71XX_RESET_BASE + AR91XX_RESET_REG_RESET_MODULE));
  48. readl(KSEG1ADDR(AR71XX_RESET_BASE + AR91XX_RESET_REG_RESET_MODULE));
  49. }
  50. }
  51. int board_eth_init(bd_t *bis)
  52. {
  53. char *phynames[] = {RTL8366_DEVNAME, RTL8366_DEVNAME};
  54. u16 phyids[] = {RTL8366_LANPHY_ID, RTL8366_WANPHY_ID};
  55. u16 phyfixed[] = {1, 0};
  56. if (ag71xx_register(bis, phynames, phyids, phyfixed) <= 0)
  57. return -1;
  58. if (rtl8366s_initialize())
  59. return -1;
  60. if (rtl8366_mii_register(bis))
  61. return -1;
  62. return 0;
  63. }
  64. int misc_init_r(void) {
  65. uint8_t macaddr[6];
  66. uint8_t enetaddr[6];
  67. debug("Testing mac addresses\n");
  68. memcpy(macaddr, (uint8_t *) CONFIG_ETHADDR_ADDR, 6);
  69. if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
  70. debug("Setting eth0 mac addr to %pM\n", macaddr);
  71. eth_setenv_enetaddr("ethaddr", macaddr);
  72. }
  73. if (!eth_getenv_enetaddr("eth1addr", enetaddr)) {
  74. macaddr[5] += 1;
  75. debug("Setting eth1 mac addr to %pM\n", macaddr);
  76. eth_setenv_enetaddr("eth1addr", macaddr);
  77. }
  78. return 0;
  79. }