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