blob: 1f0dfb4d403e6dc97194ff4ad3f97fb49d89885a [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>
Peter Meerwald9e9f4a42010-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
32static void board_init_enetaddr(uchar *mac_addr)
33{
34 puts("Warning: Generating 'random' MAC address\n");
Joe Hershberger8ecdbed2015-04-08 01:41:04 -050035 net_random_ethaddr(mac_addr);
Peter Meerwald9e9f4a42010-09-20 14:08:57 -040036 eth_setenv_enetaddr("ethaddr", mac_addr);
37}
38
39int board_eth_init(bd_t *bis)
40{
41 int retry = 3;
42 int ret;
43
44 ret = bfin_EMAC_initialize(bis);
45
46 uchar enetaddr[6];
47 if (eth_getenv_enetaddr("ethaddr", enetaddr)) {
48 printf("setting MAC %pM\n", enetaddr);
49 }
50 puts(" ");
51
52 puts("initialize SMSC LAN9303i ethernet switch\n");
53
54 while (retry-- > 0) {
55 if (init_smsc9303i_mii())
56 return ret;
57 }
58
59 return ret;
60}
61#endif
62
63static void init_tlv320aic31(void)
64{
65 puts("Audio: setup TIMER0 to enable 16.384 MHz clock for tlv320aic31\n");
66 peripheral_request(P_TMR0, "tlv320aic31 clock");
67 bfin_write_TIMER0_CONFIG(0x020d);
68 bfin_write_TIMER0_PERIOD(0x0008);
69 bfin_write_TIMER0_WIDTH(0x0008/2);
70 bfin_write_TIMER_ENABLE(bfin_read_TIMER_ENABLE() | 1);
71 SSYNC();
72 udelay(10000);
73
74 puts(" resetting tlv320aic31\n");
75
76 gpio_request(GPIO_PF2, "tlv320aic31");
77 gpio_direction_output(GPIO_PF2, 0);
78 udelay(10000);
79 gpio_direction_output(GPIO_PF2, 1);
80 udelay(10000);
81 gpio_free(GPIO_PF2);
82}
83
84static void init_mute_pin(void)
85{
86 printf(" unmute class D amplifier\n");
87
88 gpio_request(GPIO_PF5, "mute");
89 gpio_direction_output(GPIO_PF5, 1);
90 gpio_free(GPIO_PF5);
91}
92
93/* sometimes LEDs (speech, status) are still on after reboot, turn 'em off */
94static void turn_leds_off(void)
95{
96 printf(" turn LEDs off\n");
97
98 gpio_request(GPIO_PF6, "led");
99 gpio_direction_output(GPIO_PF6, 0);
100 gpio_free(GPIO_PF6);
101
102 gpio_request(GPIO_PF15, "led");
103 gpio_direction_output(GPIO_PF15, 0);
104 gpio_free(GPIO_PF15);
105}
106
107/* miscellaneous platform dependent initialisations */
108int misc_init_r(void)
109{
110#ifdef CONFIG_BFIN_MAC
111 uchar enetaddr[6];
112 if (!eth_getenv_enetaddr("ethaddr", enetaddr))
113 board_init_enetaddr(enetaddr);
114#endif
115
116 gpio_cfi_flash_init();
117 init_tlv320aic31();
118 init_mute_pin();
119 turn_leds_off();
120
121 return 0;
122}