blob: da5bc731852c428078fe76fa484240096f62c6a0 [file] [log] [blame]
Chandan Nath7d744102011-10-14 02:58:26 +00001/*
2 * board.c
3 *
4 * Common board functions for AM33XX based boards
5 *
6 * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19#include <common.h>
Tom Rini59c2cc92012-07-30 16:13:10 -070020#include <errno.h>
Tom Rini28591df2012-08-13 12:03:19 -070021#include <spl.h>
Chandan Nath7d744102011-10-14 02:58:26 +000022#include <asm/arch/cpu.h>
23#include <asm/arch/hardware.h>
Chandan Nath77a73fe2012-01-09 20:38:59 +000024#include <asm/arch/omap.h>
Chandan Nath7d744102011-10-14 02:58:26 +000025#include <asm/arch/ddr_defs.h>
26#include <asm/arch/clock.h>
Steve Sakoman6229e332012-06-04 05:35:34 +000027#include <asm/arch/gpio.h>
Chandan Nath77a73fe2012-01-09 20:38:59 +000028#include <asm/arch/mmc_host_def.h>
Tom Rini7a247722012-07-31 10:50:01 -070029#include <asm/arch/sys_proto.h>
Chandan Nath7d744102011-10-14 02:58:26 +000030#include <asm/io.h>
Tom Rini3fd44562012-07-03 08:51:34 -070031#include <asm/emif.h>
Tom Rini4b302402012-07-31 08:55:01 -070032#include <asm/gpio.h>
Tom Rini59c2cc92012-07-30 16:13:10 -070033#include <i2c.h>
34#include <miiphy.h>
35#include <cpsw.h>
Ilya Yanok7aa1a6e2012-11-06 13:48:23 +000036#include <asm/errno.h>
37#include <linux/usb/ch9.h>
38#include <linux/usb/gadget.h>
39#include <linux/usb/musb.h>
40#include <asm/omap_musb.h>
Chandan Nath7d744102011-10-14 02:58:26 +000041
42DECLARE_GLOBAL_DATA_PTR;
43
Steve Sakoman6229e332012-06-04 05:35:34 +000044static const struct gpio_bank gpio_bank_am33xx[4] = {
45 { (void *)AM33XX_GPIO0_BASE, METHOD_GPIO_24XX },
46 { (void *)AM33XX_GPIO1_BASE, METHOD_GPIO_24XX },
47 { (void *)AM33XX_GPIO2_BASE, METHOD_GPIO_24XX },
48 { (void *)AM33XX_GPIO3_BASE, METHOD_GPIO_24XX },
49};
50
51const struct gpio_bank *const omap_gpio_bank = gpio_bank_am33xx;
52
Chandan Nathd6e97f82012-01-09 20:38:58 +000053#if defined(CONFIG_OMAP_HSMMC) && !defined(CONFIG_SPL_BUILD)
Peter Korsgaardaabb9f82012-10-18 01:21:10 +000054int cpu_mmc_init(bd_t *bis)
Chandan Nathd6e97f82012-01-09 20:38:58 +000055{
Tom Rini0dc71d12012-08-08 10:31:08 -070056 int ret;
Peter Korsgaardaabb9f82012-10-18 01:21:10 +000057
Tom Rini0dc71d12012-08-08 10:31:08 -070058 ret = omap_mmc_init(0, 0, 0);
59 if (ret)
60 return ret;
61
62 return omap_mmc_init(1, 0, 0);
Chandan Nathd6e97f82012-01-09 20:38:58 +000063}
64#endif
Chandan Nath77a73fe2012-01-09 20:38:59 +000065
66void setup_clocks_for_console(void)
67{
68 /* Not yet implemented */
69 return;
70}
Ilya Yanok7aa1a6e2012-11-06 13:48:23 +000071
72/* AM33XX has two MUSB controllers which can be host or gadget */
73#if (defined(CONFIG_MUSB_GADGET) || defined(CONFIG_MUSB_HOST)) && \
74 (defined(CONFIG_AM335X_USB0) || defined(CONFIG_AM335X_USB1))
75static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
76
77/* USB 2.0 PHY Control */
78#define CM_PHY_PWRDN (1 << 0)
79#define CM_PHY_OTG_PWRDN (1 << 1)
80#define OTGVDET_EN (1 << 19)
81#define OTGSESSENDEN (1 << 20)
82
83static void am33xx_usb_set_phy_power(u8 on, u32 *reg_addr)
84{
85 if (on) {
86 clrsetbits_le32(reg_addr, CM_PHY_PWRDN | CM_PHY_OTG_PWRDN,
87 OTGVDET_EN | OTGSESSENDEN);
88 } else {
89 clrsetbits_le32(reg_addr, 0, CM_PHY_PWRDN | CM_PHY_OTG_PWRDN);
90 }
91}
92
93static struct musb_hdrc_config musb_config = {
94 .multipoint = 1,
95 .dyn_fifo = 1,
96 .num_eps = 16,
97 .ram_bits = 12,
98};
99
100#ifdef CONFIG_AM335X_USB0
101static void am33xx_otg0_set_phy_power(u8 on)
102{
103 am33xx_usb_set_phy_power(on, &cdev->usb_ctrl0);
104}
105
106struct omap_musb_board_data otg0_board_data = {
107 .set_phy_power = am33xx_otg0_set_phy_power,
108};
109
110static struct musb_hdrc_platform_data otg0_plat = {
111 .mode = CONFIG_AM335X_USB0_MODE,
112 .config = &musb_config,
113 .power = 50,
114 .platform_ops = &musb_dsps_ops,
115 .board_data = &otg0_board_data,
116};
117#endif
118
119#ifdef CONFIG_AM335X_USB1
120static void am33xx_otg1_set_phy_power(u8 on)
121{
122 am33xx_usb_set_phy_power(on, &cdev->usb_ctrl1);
123}
124
125struct omap_musb_board_data otg1_board_data = {
126 .set_phy_power = am33xx_otg1_set_phy_power,
127};
128
129static struct musb_hdrc_platform_data otg1_plat = {
130 .mode = CONFIG_AM335X_USB1_MODE,
131 .config = &musb_config,
132 .power = 50,
133 .platform_ops = &musb_dsps_ops,
134 .board_data = &otg1_board_data,
135};
136#endif
137#endif
138
139int arch_misc_init(void)
140{
141#ifdef CONFIG_AM335X_USB0
142 musb_register(&otg0_plat, &otg0_board_data,
143 (void *)AM335X_USB0_OTG_BASE);
144#endif
145#ifdef CONFIG_AM335X_USB1
146 musb_register(&otg1_plat, &otg1_board_data,
147 (void *)AM335X_USB1_OTG_BASE);
148#endif
149 return 0;
150}