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