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