]> git.ipfire.org Git - people/ms/u-boot.git/blame - board/compulab/cm_t3517/cm_t3517.c
omap3: cm-t3517: add USB support
[people/ms/u-boot.git] / board / compulab / cm_t3517 / cm_t3517.c
CommitLineData
b09bf723
IG
1/*
2 * (C) Copyright 2014 CompuLab, Ltd. <www.compulab.co.il>
3 *
4 * Authors: Igor Grinberg <grinberg@compulab.co.il>
5 *
6 * SPDX-License-Identifier: GPL-2.0+
7 */
8
9#include <common.h>
10#include <status_led.h>
011f5c13 11#include <usb.h>
b09bf723
IG
12#include <mmc.h>
13#include <linux/compiler.h>
011f5c13 14#include <linux/usb/musb.h>
b09bf723
IG
15
16#include <asm/io.h>
17#include <asm/arch/mem.h>
18#include <asm/arch/am35x_def.h>
19#include <asm/arch/mmc_host_def.h>
20#include <asm/arch/sys_proto.h>
011f5c13
IG
21#include <asm/arch/musb.h>
22#include <asm/omap_musb.h>
23#include <asm/ehci-omap.h>
b09bf723
IG
24
25#include "../common/common.h"
26
27DECLARE_GLOBAL_DATA_PTR;
28
29const omap3_sysinfo sysinfo = {
30 DDR_DISCRETE,
31 "CM-T3517 board",
32 "NAND 128/512M",
33};
34
011f5c13
IG
35#ifdef CONFIG_USB_MUSB_AM35X
36static struct musb_hdrc_config cm_t3517_musb_config = {
37 .multipoint = 1,
38 .dyn_fifo = 1,
39 .num_eps = 16,
40 .ram_bits = 12,
41};
42
43static struct omap_musb_board_data cm_t3517_musb_board_data = {
44 .set_phy_power = am35x_musb_phy_power,
45 .clear_irq = am35x_musb_clear_irq,
46 .reset = am35x_musb_reset,
47};
48
49static struct musb_hdrc_platform_data cm_t3517_musb_pdata = {
50#if defined(CONFIG_MUSB_HOST)
51 .mode = MUSB_HOST,
52#elif defined(CONFIG_MUSB_GADGET)
53 .mode = MUSB_PERIPHERAL,
54#else
55#error "Please define either CONFIG_MUSB_HOST or CONFIG_MUSB_GADGET"
56#endif
57 .config = &cm_t3517_musb_config,
58 .power = 250,
59 .platform_ops = &am35x_ops,
60 .board_data = &cm_t3517_musb_board_data,
61};
62
63static void cm_t3517_musb_init(void)
64{
65 /*
66 * Set up USB clock/mode in the DEVCONF2 register.
67 * USB2.0 PHY reference clock is 13 MHz
68 */
69 clrsetbits_le32(&am35x_scm_general_regs->devconf2,
70 CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE,
71 CONF2_REFFREQ_13MHZ | CONF2_SESENDEN |
72 CONF2_VBDTCTEN | CONF2_DATPOL);
73
74 if (musb_register(&cm_t3517_musb_pdata, &cm_t3517_musb_board_data,
75 (void *)AM35XX_IPSS_USBOTGSS_BASE))
76 printf("Failed initializing AM35x MUSB!\n");
77}
78#else
79static inline void am3517_evm_musb_init(void) {}
80#endif
81
b09bf723
IG
82int board_init(void)
83{
84 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
85
86 /* boot param addr */
87 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
88
89#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
90 status_led_set(STATUS_LED_BOOT, STATUS_LED_ON);
91#endif
92
011f5c13
IG
93 cm_t3517_musb_init();
94
b09bf723
IG
95 return 0;
96}
97
98int misc_init_r(void)
99{
100 cl_print_pcb_info();
101 dieid_num_r();
102
103 return 0;
104}
105
106#if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
107#define SB_T35_CD_GPIO 144
108#define SB_T35_WP_GPIO 59
109
110int board_mmc_init(bd_t *bis)
111{
112 return omap_mmc_init(0, 0, 0, SB_T35_CD_GPIO, SB_T35_WP_GPIO);
113}
114#endif
011f5c13
IG
115
116#ifdef CONFIG_USB_EHCI_OMAP
117static struct omap_usbhs_board_data cm_t3517_usbhs_bdata = {
118 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
119 .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
120 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
121};
122
123#define CM_T3517_USB_HUB_RESET_GPIO 152
124#define SB_T35_USB_HUB_RESET_GPIO 98
125
126int ehci_hcd_init(int index, enum usb_init_type init,
127 struct ehci_hccr **hccr, struct ehci_hcor **hcor)
128{
129 cl_usb_hub_init(CM_T3517_USB_HUB_RESET_GPIO, "cm-t3517 hub rst");
130 cl_usb_hub_init(SB_T35_USB_HUB_RESET_GPIO, "sb-t35 hub rst");
131
132 return omap_ehci_hcd_init(index, &cm_t3517_usbhs_bdata, hccr, hcor);
133}
134
135int ehci_hcd_stop(void)
136{
137 cl_usb_hub_deinit(CM_T3517_USB_HUB_RESET_GPIO);
138 cl_usb_hub_deinit(SB_T35_USB_HUB_RESET_GPIO);
139
140 return omap_ehci_hcd_stop();
141}
142#endif /* CONFIG_USB_EHCI_OMAP */