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