Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Veli-Pekka Peltola | d8fbe2f | 2012-07-09 03:14:50 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Bluegiga APX4 Development Kit |
| 4 | * |
| 5 | * Copyright (C) 2012 Bluegiga Technologies Oy |
| 6 | * |
| 7 | * Authors: |
| 8 | * Veli-Pekka Peltola <veli-pekka.peltola@bluegiga.com> |
| 9 | * Lauri Hintsala <lauri.hintsala@bluegiga.com> |
| 10 | * |
| 11 | * Based on m28evk.c: |
| 12 | * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com> |
| 13 | * on behalf of DENX Software Engineering GmbH |
Veli-Pekka Peltola | d8fbe2f | 2012-07-09 03:14:50 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <common.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 17 | #include <init.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 18 | #include <net.h> |
Veli-Pekka Peltola | d8fbe2f | 2012-07-09 03:14:50 +0000 | [diff] [blame] | 19 | #include <asm/gpio.h> |
| 20 | #include <asm/io.h> |
Simon Glass | d9a766f | 2017-05-17 08:23:00 -0600 | [diff] [blame] | 21 | #include <asm/setup.h> |
Veli-Pekka Peltola | d8fbe2f | 2012-07-09 03:14:50 +0000 | [diff] [blame] | 22 | #include <asm/arch/imx-regs.h> |
| 23 | #include <asm/arch/iomux-mx28.h> |
| 24 | #include <asm/arch/clock.h> |
| 25 | #include <asm/arch/sys_proto.h> |
Simon Glass | 0af6e2d | 2019-08-01 09:46:52 -0600 | [diff] [blame] | 26 | #include <env.h> |
Veli-Pekka Peltola | d8fbe2f | 2012-07-09 03:14:50 +0000 | [diff] [blame] | 27 | #include <linux/mii.h> |
| 28 | #include <miiphy.h> |
| 29 | #include <netdev.h> |
| 30 | #include <errno.h> |
| 31 | |
| 32 | DECLARE_GLOBAL_DATA_PTR; |
| 33 | |
| 34 | /* Functions */ |
| 35 | int board_early_init_f(void) |
| 36 | { |
| 37 | /* IO0 clock at 480MHz */ |
Otavio Salvador | 2906f94 | 2013-01-11 03:19:03 +0000 | [diff] [blame] | 38 | mxs_set_ioclk(MXC_IOCLK0, 480000); |
Veli-Pekka Peltola | d8fbe2f | 2012-07-09 03:14:50 +0000 | [diff] [blame] | 39 | /* IO1 clock at 480MHz */ |
Otavio Salvador | 2906f94 | 2013-01-11 03:19:03 +0000 | [diff] [blame] | 40 | mxs_set_ioclk(MXC_IOCLK1, 480000); |
Veli-Pekka Peltola | d8fbe2f | 2012-07-09 03:14:50 +0000 | [diff] [blame] | 41 | |
| 42 | /* SSP0 clock at 96MHz */ |
Otavio Salvador | 2906f94 | 2013-01-11 03:19:03 +0000 | [diff] [blame] | 43 | mxs_set_sspclk(MXC_SSPCLK0, 96000, 0); |
Veli-Pekka Peltola | d8fbe2f | 2012-07-09 03:14:50 +0000 | [diff] [blame] | 44 | |
| 45 | return 0; |
| 46 | } |
| 47 | |
| 48 | int dram_init(void) |
| 49 | { |
Otavio Salvador | a2bbe0c | 2012-08-19 04:58:30 +0000 | [diff] [blame] | 50 | return mxs_dram_init(); |
Veli-Pekka Peltola | d8fbe2f | 2012-07-09 03:14:50 +0000 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | int board_init(void) |
| 54 | { |
| 55 | /* Adress of boot parameters */ |
| 56 | gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100; |
| 57 | |
| 58 | return 0; |
| 59 | } |
| 60 | |
| 61 | #ifdef CONFIG_CMD_MMC |
| 62 | int board_mmc_init(bd_t *bis) |
| 63 | { |
Marek Vasut | 722181e | 2013-01-22 15:01:03 +0000 | [diff] [blame] | 64 | return mxsmmc_initialize(bis, 0, NULL, NULL); |
Veli-Pekka Peltola | d8fbe2f | 2012-07-09 03:14:50 +0000 | [diff] [blame] | 65 | } |
| 66 | #endif |
| 67 | |
| 68 | |
| 69 | #ifdef CONFIG_CMD_NET |
| 70 | |
| 71 | #define MII_PHY_CTRL2 0x1f |
| 72 | int fecmxc_mii_postcall(int phy) |
| 73 | { |
| 74 | /* change PHY RMII clock to 50MHz */ |
| 75 | miiphy_write("FEC", 0, MII_PHY_CTRL2, 0x8180); |
| 76 | |
| 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | int board_eth_init(bd_t *bis) |
| 81 | { |
| 82 | int ret; |
| 83 | struct eth_device *dev; |
| 84 | |
| 85 | ret = cpu_eth_init(bis); |
| 86 | if (ret) { |
| 87 | printf("FEC MXS: Unable to init FEC clocks\n"); |
| 88 | return ret; |
| 89 | } |
| 90 | |
| 91 | ret = fecmxc_initialize(bis); |
| 92 | if (ret) { |
| 93 | printf("FEC MXS: Unable to init FEC\n"); |
| 94 | return ret; |
| 95 | } |
| 96 | |
| 97 | dev = eth_get_dev_by_name("FEC"); |
| 98 | if (!dev) { |
| 99 | printf("FEC MXS: Unable to get FEC device entry\n"); |
| 100 | return -EINVAL; |
| 101 | } |
| 102 | |
| 103 | ret = fecmxc_register_mii_postcall(dev, fecmxc_mii_postcall); |
| 104 | if (ret) { |
| 105 | printf("FEC MXS: Unable to register FEC MII postcall\n"); |
| 106 | return ret; |
| 107 | } |
| 108 | |
| 109 | return ret; |
| 110 | } |
| 111 | #endif |
| 112 | |
| 113 | #ifdef CONFIG_SERIAL_TAG |
| 114 | #define MXS_OCOTP_MAX_TIMEOUT 1000000 |
| 115 | void get_board_serial(struct tag_serialnr *serialnr) |
| 116 | { |
Otavio Salvador | 22f4ff9 | 2012-08-05 09:05:31 +0000 | [diff] [blame] | 117 | struct mxs_ocotp_regs *ocotp_regs = |
| 118 | (struct mxs_ocotp_regs *)MXS_OCOTP_BASE; |
Veli-Pekka Peltola | d8fbe2f | 2012-07-09 03:14:50 +0000 | [diff] [blame] | 119 | |
| 120 | serialnr->high = 0; |
| 121 | serialnr->low = 0; |
| 122 | |
| 123 | writel(OCOTP_CTRL_RD_BANK_OPEN, &ocotp_regs->hw_ocotp_ctrl_set); |
| 124 | |
Otavio Salvador | cbf0bf2 | 2012-08-13 09:53:12 +0000 | [diff] [blame] | 125 | if (mxs_wait_mask_clr(&ocotp_regs->hw_ocotp_ctrl_reg, OCOTP_CTRL_BUSY, |
Veli-Pekka Peltola | d8fbe2f | 2012-07-09 03:14:50 +0000 | [diff] [blame] | 126 | MXS_OCOTP_MAX_TIMEOUT)) { |
| 127 | printf("MXS: Can't get serial number from OCOTP\n"); |
| 128 | return; |
| 129 | } |
| 130 | |
| 131 | serialnr->low = readl(&ocotp_regs->hw_ocotp_cust3); |
| 132 | } |
| 133 | #endif |
| 134 | |
| 135 | #ifdef CONFIG_REVISION_TAG |
| 136 | u32 get_board_rev(void) |
| 137 | { |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 138 | if (env_get("revision#") != NULL) |
| 139 | return simple_strtoul(env_get("revision#"), NULL, 10); |
Veli-Pekka Peltola | d8fbe2f | 2012-07-09 03:14:50 +0000 | [diff] [blame] | 140 | return 0; |
| 141 | } |
| 142 | #endif |