[U-Boot] [PATCH] meson-gxbb: Add NanoPi K2
Andreas Färber
afaerber at suse.de
Sun May 21 19:44:32 UTC 2017
Hi FriendlyARM,
Am 15.05.2017 um 03:15 schrieb Andreas Färber:
> diff --git a/board/amlogic/nanopi-k2/nanopi-k2.c b/board/amlogic/nanopi-k2/nanopi-k2.c
> new file mode 100644
> index 0000000000..b61daaa4a7
> --- /dev/null
> +++ b/board/amlogic/nanopi-k2/nanopi-k2.c
> @@ -0,0 +1,54 @@
> +/*
> + * (C) Copyright 2016 Beniamino Galvani <b.galvani at gmail.com>
> + *
> + * SPDX-License-Identifier: GPL-2.0+
> + */
> +
> +#include <common.h>
> +#include <asm/io.h>
> +#include <asm/arch/gxbb.h>
> +#include <asm/arch/sm.h>
> +#include <dm/platdata.h>
> +#include <phy.h>
> +
> +#define EFUSE_SN_OFFSET 20
> +#define EFUSE_SN_SIZE 16
> +#define EFUSE_MAC_OFFSET 52
> +#define EFUSE_MAC_SIZE 6
> +
> +int board_init(void)
> +{
> + return 0;
> +}
> +
> +int misc_init_r(void)
> +{
> + u8 mac_addr[EFUSE_MAC_SIZE];
> + ssize_t len;
> +
> + /* Set RGMII mode */
> + setbits_le32(GXBB_ETH_REG_0, GXBB_ETH_REG_0_PHY_INTF |
> + GXBB_ETH_REG_0_TX_PHASE(1) |
> + GXBB_ETH_REG_0_TX_RATIO(4) |
> + GXBB_ETH_REG_0_PHY_CLK_EN |
> + GXBB_ETH_REG_0_CLK_EN);
> +
> + /* Enable power and clock gate */
> + setbits_le32(GXBB_GCLK_MPEG_1, GXBB_GCLK_MPEG_1_ETH);
> + clrbits_le32(GXBB_MEM_PD_REG_0, GXBB_MEM_PD_REG_0_ETH_MASK);
> +
> + /* Reset PHY on GPIOZ_14 */
> + clrbits_le32(GXBB_GPIO_EN(3), BIT(14));
> + clrbits_le32(GXBB_GPIO_OUT(3), BIT(14));
> + mdelay(10);
> + setbits_le32(GXBB_GPIO_OUT(3), BIT(14));
> +
> + if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
> + len = meson_sm_read_efuse(EFUSE_MAC_OFFSET,
> + mac_addr, EFUSE_MAC_SIZE);
> + if (len == EFUSE_MAC_SIZE && is_valid_ethaddr(mac_addr))
> + eth_setenv_enetaddr("ethaddr", mac_addr);
This code copied from odroid-c2 is not working, I always get a random
MAC address.
The downstream U-Boot has no code in board_eth_init() to read the efuse,
unlike Hardkernel's. Is the MAC address not programmed into K2's efuse?
https://github.com/friendlyarm/u-boot/blob/nanopi-k2-v2015.01/board/amlogic/nanopi-k2/eth_setup.c
https://github.com/hardkernel/u-boot/blob/odroidc2-v2015.01/board/hardkernel/odroidc2/odroidc2-eth.c
> + }
> +
> + return 0;
> +}
[snip]
Regards,
Andreas
--
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
More information about the U-Boot
mailing list