Vaibhav Hiremath | ed01e45 | 2010-06-07 15:20:43 -0400 | [diff] [blame] | 1 | /* |
| 2 | * am3517evm.c - board file for TI's AM3517 family of devices. |
| 3 | * |
| 4 | * Author: Vaibhav Hiremath <hvaibhav@ti.com> |
| 5 | * |
| 6 | * Based on ti/evm/evm.c |
| 7 | * |
| 8 | * Copyright (C) 2010 |
| 9 | * Texas Instruments Incorporated - http://www.ti.com/ |
| 10 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 11 | * SPDX-License-Identifier: GPL-2.0+ |
Vaibhav Hiremath | ed01e45 | 2010-06-07 15:20:43 -0400 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #include <common.h> |
| 15 | #include <asm/io.h> |
Ilya Yanok | 88919ff | 2012-11-06 13:48:28 +0000 | [diff] [blame] | 16 | #include <asm/omap_musb.h> |
| 17 | #include <asm/arch/am35x_def.h> |
Vaibhav Hiremath | ed01e45 | 2010-06-07 15:20:43 -0400 | [diff] [blame] | 18 | #include <asm/arch/mem.h> |
| 19 | #include <asm/arch/mux.h> |
| 20 | #include <asm/arch/sys_proto.h> |
Vaibhav Hiremath | 122e6e0 | 2011-09-03 21:47:44 -0400 | [diff] [blame] | 21 | #include <asm/arch/mmc_host_def.h> |
Ilya Yanok | 88919ff | 2012-11-06 13:48:28 +0000 | [diff] [blame] | 22 | #include <asm/arch/musb.h> |
Vaibhav Hiremath | ed01e45 | 2010-06-07 15:20:43 -0400 | [diff] [blame] | 23 | #include <asm/mach-types.h> |
Ilya Yanok | 88919ff | 2012-11-06 13:48:28 +0000 | [diff] [blame] | 24 | #include <asm/errno.h> |
Yegor Yefremov | 6a1df37 | 2013-12-11 15:41:11 +0100 | [diff] [blame] | 25 | #include <asm/gpio.h> |
Ilya Yanok | 88919ff | 2012-11-06 13:48:28 +0000 | [diff] [blame] | 26 | #include <linux/usb/ch9.h> |
| 27 | #include <linux/usb/gadget.h> |
| 28 | #include <linux/usb/musb.h> |
Vaibhav Hiremath | ed01e45 | 2010-06-07 15:20:43 -0400 | [diff] [blame] | 29 | #include <i2c.h> |
Ilya Yanok | 88919ff | 2012-11-06 13:48:28 +0000 | [diff] [blame] | 30 | #include <netdev.h> |
Vaibhav Hiremath | ed01e45 | 2010-06-07 15:20:43 -0400 | [diff] [blame] | 31 | #include "am3517evm.h" |
| 32 | |
| 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
Yegor Yefremov | 6a1df37 | 2013-12-11 15:41:11 +0100 | [diff] [blame] | 35 | #define AM3517_IP_SW_RESET 0x48002598 |
| 36 | #define CPGMACSS_SW_RST (1 << 1) |
| 37 | |
Vaibhav Hiremath | ed01e45 | 2010-06-07 15:20:43 -0400 | [diff] [blame] | 38 | /* |
| 39 | * Routine: board_init |
| 40 | * Description: Early hardware init. |
| 41 | */ |
| 42 | int board_init(void) |
| 43 | { |
| 44 | gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ |
| 45 | /* board id for Linux */ |
| 46 | gd->bd->bi_arch_number = MACH_TYPE_OMAP3517EVM; |
| 47 | /* boot param addr */ |
| 48 | gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); |
| 49 | |
| 50 | return 0; |
| 51 | } |
| 52 | |
Ilya Yanok | 88919ff | 2012-11-06 13:48:28 +0000 | [diff] [blame] | 53 | #ifdef CONFIG_USB_MUSB_AM35X |
| 54 | static struct musb_hdrc_config musb_config = { |
| 55 | .multipoint = 1, |
| 56 | .dyn_fifo = 1, |
| 57 | .num_eps = 16, |
| 58 | .ram_bits = 12, |
| 59 | }; |
| 60 | |
| 61 | static struct omap_musb_board_data musb_board_data = { |
| 62 | .set_phy_power = am35x_musb_phy_power, |
| 63 | .clear_irq = am35x_musb_clear_irq, |
| 64 | .reset = am35x_musb_reset, |
| 65 | }; |
| 66 | |
| 67 | static struct musb_hdrc_platform_data musb_plat = { |
Paul Kocialkowski | 95de1e2 | 2015-08-04 17:04:06 +0200 | [diff] [blame] | 68 | #if defined(CONFIG_USB_MUSB_HOST) |
Ilya Yanok | 88919ff | 2012-11-06 13:48:28 +0000 | [diff] [blame] | 69 | .mode = MUSB_HOST, |
Paul Kocialkowski | 95de1e2 | 2015-08-04 17:04:06 +0200 | [diff] [blame] | 70 | #elif defined(CONFIG_USB_MUSB_GADGET) |
Ilya Yanok | 88919ff | 2012-11-06 13:48:28 +0000 | [diff] [blame] | 71 | .mode = MUSB_PERIPHERAL, |
| 72 | #else |
Paul Kocialkowski | 95de1e2 | 2015-08-04 17:04:06 +0200 | [diff] [blame] | 73 | #error "Please define either CONFIG_USB_MUSB_HOST or CONFIG_USB_MUSB_GADGET" |
Ilya Yanok | 88919ff | 2012-11-06 13:48:28 +0000 | [diff] [blame] | 74 | #endif |
| 75 | .config = &musb_config, |
| 76 | .power = 250, |
| 77 | .platform_ops = &am35x_ops, |
| 78 | .board_data = &musb_board_data, |
| 79 | }; |
| 80 | |
| 81 | static void am3517_evm_musb_init(void) |
| 82 | { |
| 83 | /* |
| 84 | * Set up USB clock/mode in the DEVCONF2 register. |
| 85 | * USB2.0 PHY reference clock is 13 MHz |
| 86 | */ |
| 87 | clrsetbits_le32(&am35x_scm_general_regs->devconf2, |
| 88 | CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE, |
| 89 | CONF2_REFFREQ_13MHZ | CONF2_SESENDEN | |
| 90 | CONF2_VBDTCTEN | CONF2_DATPOL); |
| 91 | |
| 92 | musb_register(&musb_plat, &musb_board_data, |
| 93 | (void *)AM35XX_IPSS_USBOTGSS_BASE); |
| 94 | } |
| 95 | #else |
| 96 | #define am3517_evm_musb_init() do {} while (0) |
| 97 | #endif |
| 98 | |
Vaibhav Hiremath | ed01e45 | 2010-06-07 15:20:43 -0400 | [diff] [blame] | 99 | /* |
| 100 | * Routine: misc_init_r |
| 101 | * Description: Init i2c, ethernet, etc... (done here so udelay works) |
| 102 | */ |
| 103 | int misc_init_r(void) |
| 104 | { |
Yegor Yefremov | 6a1df37 | 2013-12-11 15:41:11 +0100 | [diff] [blame] | 105 | volatile unsigned int ctr; |
| 106 | u32 reset; |
| 107 | |
Heiko Schocher | 6789e84 | 2013-10-22 11:03:18 +0200 | [diff] [blame] | 108 | #ifdef CONFIG_SYS_I2C_OMAP34XX |
| 109 | i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE); |
Vaibhav Hiremath | ed01e45 | 2010-06-07 15:20:43 -0400 | [diff] [blame] | 110 | #endif |
| 111 | |
Paul Kocialkowski | 679f82c | 2015-08-27 19:37:13 +0200 | [diff] [blame^] | 112 | omap_die_id_display(); |
Vaibhav Hiremath | ed01e45 | 2010-06-07 15:20:43 -0400 | [diff] [blame] | 113 | |
Ilya Yanok | 88919ff | 2012-11-06 13:48:28 +0000 | [diff] [blame] | 114 | am3517_evm_musb_init(); |
| 115 | |
Yegor Yefremov | 6a1df37 | 2013-12-11 15:41:11 +0100 | [diff] [blame] | 116 | /* activate PHY reset */ |
| 117 | gpio_direction_output(30, 0); |
| 118 | gpio_set_value(30, 0); |
| 119 | |
| 120 | ctr = 0; |
| 121 | do { |
| 122 | udelay(1000); |
| 123 | ctr++; |
| 124 | } while (ctr < 300); |
| 125 | |
| 126 | /* deactivate PHY reset */ |
| 127 | gpio_set_value(30, 1); |
| 128 | |
| 129 | /* allow the PHY to stabilize and settle down */ |
| 130 | ctr = 0; |
| 131 | do { |
| 132 | udelay(1000); |
| 133 | ctr++; |
| 134 | } while (ctr < 300); |
| 135 | |
| 136 | /* ensure that the module is out of reset */ |
| 137 | reset = readl(AM3517_IP_SW_RESET); |
| 138 | reset &= (~CPGMACSS_SW_RST); |
| 139 | writel(reset,AM3517_IP_SW_RESET); |
| 140 | |
Vaibhav Hiremath | ed01e45 | 2010-06-07 15:20:43 -0400 | [diff] [blame] | 141 | return 0; |
| 142 | } |
| 143 | |
| 144 | /* |
| 145 | * Routine: set_muxconf_regs |
| 146 | * Description: Setting up the configuration Mux registers specific to the |
| 147 | * hardware. Many pins need to be moved from protect to primary |
| 148 | * mode. |
| 149 | */ |
| 150 | void set_muxconf_regs(void) |
| 151 | { |
| 152 | MUX_AM3517EVM(); |
| 153 | } |
Vaibhav Hiremath | 122e6e0 | 2011-09-03 21:47:44 -0400 | [diff] [blame] | 154 | |
Tom Rini | 5059a2a | 2011-11-18 12:48:10 +0000 | [diff] [blame] | 155 | #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD) |
Vaibhav Hiremath | 122e6e0 | 2011-09-03 21:47:44 -0400 | [diff] [blame] | 156 | int board_mmc_init(bd_t *bis) |
| 157 | { |
Nikita Kiryanov | e3913f5 | 2012-12-03 02:19:47 +0000 | [diff] [blame] | 158 | return omap_mmc_init(0, 0, 0, -1, -1); |
Vaibhav Hiremath | 122e6e0 | 2011-09-03 21:47:44 -0400 | [diff] [blame] | 159 | } |
| 160 | #endif |
Ilya Yanok | 88919ff | 2012-11-06 13:48:28 +0000 | [diff] [blame] | 161 | |
Paul Kocialkowski | 95de1e2 | 2015-08-04 17:04:06 +0200 | [diff] [blame] | 162 | #if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET) |
Ilya Yanok | 88919ff | 2012-11-06 13:48:28 +0000 | [diff] [blame] | 163 | int board_eth_init(bd_t *bis) |
| 164 | { |
| 165 | int rv, n = 0; |
| 166 | |
| 167 | rv = cpu_eth_init(bis); |
| 168 | if (rv > 0) |
| 169 | n += rv; |
| 170 | |
| 171 | rv = usb_eth_initialize(bis); |
| 172 | if (rv > 0) |
| 173 | n += rv; |
| 174 | |
| 175 | return n; |
| 176 | } |
| 177 | #endif |