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