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> |
Ilya Yanok | e484f8e | 2012-11-06 13:48:28 +0000 | [diff] [blame] | 31 | #include <netdev.h> |
Vaibhav Hiremath | db5c558 | 2010-06-07 15:20:43 -0400 | [diff] [blame] | 32 | #include "am3517evm.h" |
| 33 | |
| 34 | DECLARE_GLOBAL_DATA_PTR; |
| 35 | |
Yegor Yefremov | d7ac796 | 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 | b32f5f3 | 2017-09-19 20:32:11 -0500 | [diff] [blame] | 38 | #define PHY_GPIO 30 |
| 39 | |
Yegor Yefremov | d7ac796 | 2013-12-11 15:41:11 +0100 | [diff] [blame] | 40 | |
Vaibhav Hiremath | db5c558 | 2010-06-07 15:20:43 -0400 | [diff] [blame] | 41 | /* |
| 42 | * Routine: board_init |
| 43 | * Description: Early hardware init. |
| 44 | */ |
| 45 | int board_init(void) |
| 46 | { |
| 47 | gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ |
| 48 | /* board id for Linux */ |
| 49 | gd->bd->bi_arch_number = MACH_TYPE_OMAP3517EVM; |
| 50 | /* boot param addr */ |
| 51 | gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); |
| 52 | |
| 53 | return 0; |
| 54 | } |
| 55 | |
Ilya Yanok | e484f8e | 2012-11-06 13:48:28 +0000 | [diff] [blame] | 56 | #ifdef CONFIG_USB_MUSB_AM35X |
| 57 | static struct musb_hdrc_config musb_config = { |
| 58 | .multipoint = 1, |
| 59 | .dyn_fifo = 1, |
| 60 | .num_eps = 16, |
| 61 | .ram_bits = 12, |
| 62 | }; |
| 63 | |
| 64 | static struct omap_musb_board_data musb_board_data = { |
| 65 | .set_phy_power = am35x_musb_phy_power, |
| 66 | .clear_irq = am35x_musb_clear_irq, |
| 67 | .reset = am35x_musb_reset, |
| 68 | }; |
| 69 | |
| 70 | static struct musb_hdrc_platform_data musb_plat = { |
Paul Kocialkowski | f34dfcb | 2015-08-04 17:04:06 +0200 | [diff] [blame] | 71 | #if defined(CONFIG_USB_MUSB_HOST) |
Ilya Yanok | e484f8e | 2012-11-06 13:48:28 +0000 | [diff] [blame] | 72 | .mode = MUSB_HOST, |
Paul Kocialkowski | f34dfcb | 2015-08-04 17:04:06 +0200 | [diff] [blame] | 73 | #elif defined(CONFIG_USB_MUSB_GADGET) |
Ilya Yanok | e484f8e | 2012-11-06 13:48:28 +0000 | [diff] [blame] | 74 | .mode = MUSB_PERIPHERAL, |
| 75 | #else |
Paul Kocialkowski | f34dfcb | 2015-08-04 17:04:06 +0200 | [diff] [blame] | 76 | #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] | 77 | #endif |
| 78 | .config = &musb_config, |
| 79 | .power = 250, |
| 80 | .platform_ops = &am35x_ops, |
| 81 | .board_data = &musb_board_data, |
| 82 | }; |
| 83 | |
| 84 | static void am3517_evm_musb_init(void) |
| 85 | { |
| 86 | /* |
| 87 | * Set up USB clock/mode in the DEVCONF2 register. |
| 88 | * USB2.0 PHY reference clock is 13 MHz |
| 89 | */ |
| 90 | clrsetbits_le32(&am35x_scm_general_regs->devconf2, |
| 91 | CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE, |
| 92 | CONF2_REFFREQ_13MHZ | CONF2_SESENDEN | |
| 93 | CONF2_VBDTCTEN | CONF2_DATPOL); |
| 94 | |
| 95 | musb_register(&musb_plat, &musb_board_data, |
| 96 | (void *)AM35XX_IPSS_USBOTGSS_BASE); |
| 97 | } |
| 98 | #else |
| 99 | #define am3517_evm_musb_init() do {} while (0) |
| 100 | #endif |
| 101 | |
Vaibhav Hiremath | db5c558 | 2010-06-07 15:20:43 -0400 | [diff] [blame] | 102 | /* |
| 103 | * Routine: misc_init_r |
| 104 | * Description: Init i2c, ethernet, etc... (done here so udelay works) |
| 105 | */ |
| 106 | int misc_init_r(void) |
| 107 | { |
Yegor Yefremov | d7ac796 | 2013-12-11 15:41:11 +0100 | [diff] [blame] | 108 | volatile unsigned int ctr; |
| 109 | u32 reset; |
| 110 | |
Adam Ford | 49e96f2 | 2017-08-07 13:11:19 -0500 | [diff] [blame] | 111 | #ifdef CONFIG_SYS_I2C_OMAP24XX |
Heiko Schocher | f53f2b8 | 2013-10-22 11:03:18 +0200 | [diff] [blame] | 112 | i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE); |
Vaibhav Hiremath | db5c558 | 2010-06-07 15:20:43 -0400 | [diff] [blame] | 113 | #endif |
| 114 | |
Paul Kocialkowski | 6bc318e | 2015-08-27 19:37:13 +0200 | [diff] [blame] | 115 | omap_die_id_display(); |
Vaibhav Hiremath | db5c558 | 2010-06-07 15:20:43 -0400 | [diff] [blame] | 116 | |
Ilya Yanok | e484f8e | 2012-11-06 13:48:28 +0000 | [diff] [blame] | 117 | am3517_evm_musb_init(); |
| 118 | |
Adam Ford | b32f5f3 | 2017-09-19 20:32:11 -0500 | [diff] [blame] | 119 | if (gpio_request(PHY_GPIO, "gpio_30") == 0) { |
| 120 | /* activate PHY reset */ |
| 121 | gpio_direction_output(PHY_GPIO, 0); |
| 122 | gpio_set_value(PHY_GPIO, 0); |
Yegor Yefremov | d7ac796 | 2013-12-11 15:41:11 +0100 | [diff] [blame] | 123 | |
Adam Ford | b32f5f3 | 2017-09-19 20:32:11 -0500 | [diff] [blame] | 124 | ctr = 0; |
| 125 | do { |
| 126 | udelay(1000); |
| 127 | ctr++; |
| 128 | } while (ctr < 300); |
Yegor Yefremov | d7ac796 | 2013-12-11 15:41:11 +0100 | [diff] [blame] | 129 | |
Adam Ford | b32f5f3 | 2017-09-19 20:32:11 -0500 | [diff] [blame] | 130 | /* deactivate PHY reset */ |
| 131 | gpio_set_value(PHY_GPIO, 1); |
Yegor Yefremov | d7ac796 | 2013-12-11 15:41:11 +0100 | [diff] [blame] | 132 | |
Adam Ford | b32f5f3 | 2017-09-19 20:32:11 -0500 | [diff] [blame] | 133 | /* allow the PHY to stabilize and settle down */ |
| 134 | ctr = 0; |
| 135 | do { |
| 136 | udelay(1000); |
| 137 | ctr++; |
| 138 | } while (ctr < 300); |
| 139 | |
| 140 | /* ensure that the module is out of reset */ |
| 141 | reset = readl(AM3517_IP_SW_RESET); |
| 142 | reset &= (~CPGMACSS_SW_RST); |
| 143 | writel(reset, AM3517_IP_SW_RESET); |
Yegor Yefremov | d7ac796 | 2013-12-11 15:41:11 +0100 | [diff] [blame] | 144 | |
Adam Ford | b32f5f3 | 2017-09-19 20:32:11 -0500 | [diff] [blame] | 145 | /* Free requested GPIO */ |
| 146 | gpio_free(PHY_GPIO); |
| 147 | } |
Yegor Yefremov | d7ac796 | 2013-12-11 15:41:11 +0100 | [diff] [blame] | 148 | |
Vaibhav Hiremath | db5c558 | 2010-06-07 15:20:43 -0400 | [diff] [blame] | 149 | return 0; |
| 150 | } |
| 151 | |
| 152 | /* |
| 153 | * Routine: set_muxconf_regs |
| 154 | * Description: Setting up the configuration Mux registers specific to the |
| 155 | * hardware. Many pins need to be moved from protect to primary |
| 156 | * mode. |
| 157 | */ |
| 158 | void set_muxconf_regs(void) |
| 159 | { |
| 160 | MUX_AM3517EVM(); |
| 161 | } |
Vaibhav Hiremath | 1e05ff8 | 2011-09-03 21:47:44 -0400 | [diff] [blame] | 162 | |
Masahiro Yamada | 0a78017 | 2017-05-09 20:31:39 +0900 | [diff] [blame] | 163 | #if defined(CONFIG_MMC) |
Vaibhav Hiremath | 1e05ff8 | 2011-09-03 21:47:44 -0400 | [diff] [blame] | 164 | int board_mmc_init(bd_t *bis) |
| 165 | { |
Nikita Kiryanov | 4be9dbc | 2012-12-03 02:19:47 +0000 | [diff] [blame] | 166 | return omap_mmc_init(0, 0, 0, -1, -1); |
Vaibhav Hiremath | 1e05ff8 | 2011-09-03 21:47:44 -0400 | [diff] [blame] | 167 | } |
| 168 | #endif |
Ilya Yanok | e484f8e | 2012-11-06 13:48:28 +0000 | [diff] [blame] | 169 | |
Paul Kocialkowski | f34dfcb | 2015-08-04 17:04:06 +0200 | [diff] [blame] | 170 | #if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET) |
Ilya Yanok | e484f8e | 2012-11-06 13:48:28 +0000 | [diff] [blame] | 171 | int board_eth_init(bd_t *bis) |
| 172 | { |
| 173 | int rv, n = 0; |
| 174 | |
| 175 | rv = cpu_eth_init(bis); |
| 176 | if (rv > 0) |
| 177 | n += rv; |
| 178 | |
| 179 | rv = usb_eth_initialize(bis); |
| 180 | if (rv > 0) |
| 181 | n += rv; |
| 182 | |
| 183 | return n; |
| 184 | } |
| 185 | #endif |