Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Marek Vasut | b09c8bf | 2013-09-20 16:14:13 +0200 | [diff] [blame] | 2 | /* |
| 3 | * PPC-AG BG0900 board |
| 4 | * |
| 5 | * Copyright (C) 2013 Marek Vasut <marex@denx.de> |
Marek Vasut | b09c8bf | 2013-09-20 16:14:13 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 9 | #include <init.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 10 | #include <net.h> |
Marek Vasut | b09c8bf | 2013-09-20 16:14:13 +0200 | [diff] [blame] | 11 | #include <asm/gpio.h> |
| 12 | #include <asm/io.h> |
| 13 | #include <asm/arch/imx-regs.h> |
| 14 | #include <asm/arch/iomux-mx28.h> |
| 15 | #include <asm/arch/clock.h> |
| 16 | #include <asm/arch/sys_proto.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 17 | #include <linux/delay.h> |
Marek Vasut | b09c8bf | 2013-09-20 16:14:13 +0200 | [diff] [blame] | 18 | #include <linux/mii.h> |
| 19 | #include <miiphy.h> |
| 20 | #include <netdev.h> |
| 21 | #include <errno.h> |
| 22 | |
| 23 | DECLARE_GLOBAL_DATA_PTR; |
| 24 | |
| 25 | /* |
| 26 | * Functions |
| 27 | */ |
| 28 | int board_early_init_f(void) |
| 29 | { |
| 30 | /* IO0 clock at 480MHz */ |
| 31 | mxs_set_ioclk(MXC_IOCLK0, 480000); |
| 32 | /* IO1 clock at 480MHz */ |
| 33 | mxs_set_ioclk(MXC_IOCLK1, 480000); |
| 34 | |
| 35 | /* SSP2 clock at 160MHz */ |
| 36 | mxs_set_sspclk(MXC_SSPCLK2, 160000, 0); |
| 37 | |
| 38 | return 0; |
| 39 | } |
| 40 | |
| 41 | int dram_init(void) |
| 42 | { |
| 43 | return mxs_dram_init(); |
| 44 | } |
| 45 | |
| 46 | int board_init(void) |
| 47 | { |
| 48 | /* Adress of boot parameters */ |
| 49 | gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100; |
| 50 | |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | #ifdef CONFIG_CMD_NET |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 55 | int board_eth_init(struct bd_info *bis) |
Marek Vasut | b09c8bf | 2013-09-20 16:14:13 +0200 | [diff] [blame] | 56 | { |
| 57 | struct mxs_clkctrl_regs *clkctrl_regs = |
| 58 | (struct mxs_clkctrl_regs *)MXS_CLKCTRL_BASE; |
| 59 | struct eth_device *dev; |
| 60 | int ret; |
| 61 | |
| 62 | ret = cpu_eth_init(bis); |
| 63 | |
| 64 | /* BG0900 uses ENET_CLK PAD to drive FEC clock */ |
| 65 | writel(CLKCTRL_ENET_TIME_SEL_RMII_CLK | CLKCTRL_ENET_CLK_OUT_EN, |
| 66 | &clkctrl_regs->hw_clkctrl_enet); |
| 67 | |
| 68 | /* Reset FEC PHYs */ |
| 69 | gpio_direction_output(MX28_PAD_ENET0_RX_CLK__GPIO_4_13, 0); |
| 70 | udelay(200); |
| 71 | gpio_set_value(MX28_PAD_ENET0_RX_CLK__GPIO_4_13, 1); |
| 72 | |
| 73 | ret = fecmxc_initialize_multi(bis, 0, 0, MXS_ENET0_BASE); |
| 74 | if (ret) { |
| 75 | puts("FEC MXS: Unable to init FEC0\n"); |
| 76 | return ret; |
| 77 | } |
| 78 | |
| 79 | dev = eth_get_dev_by_name("FEC0"); |
| 80 | if (!dev) { |
| 81 | puts("FEC MXS: Unable to get FEC0 device entry\n"); |
| 82 | return -EINVAL; |
| 83 | } |
| 84 | |
| 85 | return ret; |
| 86 | } |
| 87 | |
| 88 | #endif |