bct-brettl2.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * U-boot - main board file for BCT brettl2
  3. *
  4. * Copyright (c) 2010 BCT Electronic GmbH
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #include <common.h>
  9. #include <config.h>
  10. #include <command.h>
  11. #include <asm/blackfin.h>
  12. #include <asm/portmux.h>
  13. #include <asm/gpio.h>
  14. #include <net.h>
  15. #include <netdev.h>
  16. #include <miiphy.h>
  17. #include "../cm-bf537e/gpio_cfi_flash.h"
  18. #include "smsc9303.h"
  19. DECLARE_GLOBAL_DATA_PTR;
  20. int checkboard(void)
  21. {
  22. printf("Board: bct-brettl2 board\n");
  23. printf(" Support: http://www.bct-electronic.com/\n");
  24. return 0;
  25. }
  26. #ifdef CONFIG_BFIN_MAC
  27. static void board_init_enetaddr(uchar *mac_addr)
  28. {
  29. puts("Warning: Generating 'random' MAC address\n");
  30. eth_random_addr(mac_addr);
  31. eth_setenv_enetaddr("ethaddr", mac_addr);
  32. }
  33. int board_eth_init(bd_t *bis)
  34. {
  35. int retry = 3;
  36. int ret;
  37. ret = bfin_EMAC_initialize(bis);
  38. uchar enetaddr[6];
  39. if (eth_getenv_enetaddr("ethaddr", enetaddr)) {
  40. printf("setting MAC %pM\n", enetaddr);
  41. }
  42. puts(" ");
  43. puts("initialize SMSC LAN9303i ethernet switch\n");
  44. while (retry-- > 0) {
  45. if (init_smsc9303i_mii())
  46. return ret;
  47. }
  48. return ret;
  49. }
  50. #endif
  51. static void init_tlv320aic31(void)
  52. {
  53. puts("Audio: setup TIMER0 to enable 16.384 MHz clock for tlv320aic31\n");
  54. peripheral_request(P_TMR0, "tlv320aic31 clock");
  55. bfin_write_TIMER0_CONFIG(0x020d);
  56. bfin_write_TIMER0_PERIOD(0x0008);
  57. bfin_write_TIMER0_WIDTH(0x0008/2);
  58. bfin_write_TIMER_ENABLE(bfin_read_TIMER_ENABLE() | 1);
  59. SSYNC();
  60. udelay(10000);
  61. puts(" resetting tlv320aic31\n");
  62. gpio_request(GPIO_PF2, "tlv320aic31");
  63. gpio_direction_output(GPIO_PF2, 0);
  64. udelay(10000);
  65. gpio_direction_output(GPIO_PF2, 1);
  66. udelay(10000);
  67. gpio_free(GPIO_PF2);
  68. }
  69. static void init_mute_pin(void)
  70. {
  71. printf(" unmute class D amplifier\n");
  72. gpio_request(GPIO_PF5, "mute");
  73. gpio_direction_output(GPIO_PF5, 1);
  74. gpio_free(GPIO_PF5);
  75. }
  76. /* sometimes LEDs (speech, status) are still on after reboot, turn 'em off */
  77. static void turn_leds_off(void)
  78. {
  79. printf(" turn LEDs off\n");
  80. gpio_request(GPIO_PF6, "led");
  81. gpio_direction_output(GPIO_PF6, 0);
  82. gpio_free(GPIO_PF6);
  83. gpio_request(GPIO_PF15, "led");
  84. gpio_direction_output(GPIO_PF15, 0);
  85. gpio_free(GPIO_PF15);
  86. }
  87. /* miscellaneous platform dependent initialisations */
  88. int misc_init_r(void)
  89. {
  90. #ifdef CONFIG_BFIN_MAC
  91. uchar enetaddr[6];
  92. if (!eth_getenv_enetaddr("ethaddr", enetaddr))
  93. board_init_enetaddr(enetaddr);
  94. #endif
  95. gpio_cfi_flash_init();
  96. init_tlv320aic31();
  97. init_mute_pin();
  98. turn_leds_off();
  99. return 0;
  100. }