summaryrefslogtreecommitdiffstats
path: root/arch/arm/boards/beaglebone/board.c
blob: b87ccef1df8209608160304f9db8e5ea0400cccb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*
 * (C) Copyright 2008
 * Texas Instruments, <www.ti.com>
 * Raghavendra KH <r-khandenahally@ti.com>
 *
 * Copyright (C) 2012 Jan Luebbe <j.luebbe@pengutronix.de>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

/**
 * @file
 * @brief BeagleBone Specific Board Initialization routines
 */

#include <common.h>
#include <console.h>
#include <init.h>
#include <driver.h>
#include <envfs.h>
#include <environment.h>
#include <globalvar.h>
#include <sizes.h>
#include <io.h>
#include <ns16550.h>
#include <net.h>
#include <bootsource.h>
#include <asm/armlinux.h>
#include <generated/mach-types.h>
#include <mach/am33xx-silicon.h>
#include <mach/am33xx-clock.h>
#include <mach/sdrc.h>
#include <mach/sys_info.h>
#include <mach/syslib.h>
#include <mach/gpmc.h>
#include <mach/ehci.h>
#include <i2c/i2c.h>
#include <linux/err.h>
#include <linux/phy.h>
#include <usb/ehci.h>
#include <mach/am33xx-devices.h>
#include <mach/am33xx-mux.h>
#include <mach/wdt.h>
#include <mach/am33xx-generic.h>
#include <mach/cpsw.h>

#include "beaglebone.h"

#ifdef CONFIG_DRIVER_SERIAL_NS16550

/**
 * @brief UART serial port initialization - remember to enable COM clocks in
 * arch
 *
 * @return result of device registration
 */
static int beaglebone_console_init(void)
{
	barebox_set_model("Texas Instruments beaglebone");
	barebox_set_hostname("beaglebone");

	am33xx_add_uart0();

	return 0;
}
console_initcall(beaglebone_console_init);
#endif /* CONFIG_DRIVER_SERIAL_NS16550 */

static int beaglebone_mem_init(void)
{
	if (is_beaglebone_black())
		omap_add_ram0(SZ_512M);
	else
		omap_add_ram0(SZ_256M);

	return 0;
}
mem_initcall(beaglebone_mem_init);

static struct cpsw_slave_data cpsw_slaves[] = {
	{
		.phy_id		= 0,
		.phy_if		= PHY_INTERFACE_MODE_MII,
	},
};

static struct cpsw_platform_data cpsw_data = {
	.slave_data		= cpsw_slaves,
	.num_slaves		= ARRAY_SIZE(cpsw_slaves),
};

static void beaglebone_eth_init(void)
{
	am33xx_register_ethaddr(0, 0);

	writel(0, AM33XX_MAC_MII_SEL);

	am33xx_enable_mii1_pin_mux();

	am33xx_add_cpsw(&cpsw_data);
}

static struct i2c_board_info i2c0_devices[] = {
	{
		I2C_BOARD_INFO("24c256", 0x50)
	},
};

static const __maybe_unused struct module_pin_mux mmc1_pin_mux[] = {
	{OFFSET(gpmc_ad0), (MODE(1) | RXACTIVE)},	/* MMC1_DAT0 */
	{OFFSET(gpmc_ad1), (MODE(1) | RXACTIVE)},	/* MMC1_DAT1 */
	{OFFSET(gpmc_ad2), (MODE(1) | RXACTIVE)},	/* MMC1_DAT2 */
	{OFFSET(gpmc_ad3), (MODE(1) | RXACTIVE)},	/* MMC1_DAT3 */
	{OFFSET(gpmc_ad4), (MODE(1) | RXACTIVE)},	/* MMC1_DAT4 */
	{OFFSET(gpmc_ad5), (MODE(1) | RXACTIVE)},	/* MMC1_DAT5 */
	{OFFSET(gpmc_ad6), (MODE(1) | RXACTIVE)},	/* MMC1_DAT6 */
	{OFFSET(gpmc_ad7), (MODE(1) | RXACTIVE)},	/* MMC1_DAT7 */
	{OFFSET(gpmc_csn1), (MODE(2) | RXACTIVE | PULLUP_EN)},	/* MMC1_CLK */
	{OFFSET(gpmc_csn2), (MODE(2) | RXACTIVE | PULLUP_EN)},	/* MMC1_CMD */
	{-1},
};

static struct omap_hsmmc_platform_data beaglebone_sd = {
	.devname = "sd",
};

static struct omap_hsmmc_platform_data beaglebone_emmc = {
	.devname = "emmc",
};

static int beaglebone_devices_init(void)
{
	am33xx_enable_mmc0_pin_mux();
	am33xx_add_mmc0(&beaglebone_sd);

	if (is_beaglebone_black()) {
		configure_module_pin_mux(mmc1_pin_mux);
		am33xx_add_mmc1(&beaglebone_emmc);
	}

	if (bootsource_get() == BOOTSOURCE_MMC) {
		if (bootsource_get_instance() == 0)
			omap_set_bootmmc_devname("sd");
		else
			omap_set_bootmmc_devname("emmc");
	}

	am33xx_enable_i2c0_pin_mux();
	i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
	am33xx_add_i2c0(NULL);

	beaglebone_eth_init();

	return 0;
}
device_initcall(beaglebone_devices_init);

static int beaglebone_env_init(void)
{
	int black = is_beaglebone_black();

	globalvar_add_simple("board.variant", black ? "boneblack" : "bone");

	printf("detected 'BeagleBone %s'\n", black ? "Black" : "White");

	armlinux_set_architecture(MACH_TYPE_BEAGLEBONE);

	return 0;
}
late_initcall(beaglebone_env_init);