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