u-boot-brain/board/phytec/phycore_rk3288/phycore-rk3288.c
Tom Rini 83d290c56f SPDX: Convert all of our single license tags to Linux Kernel style
When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from.  So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry.  Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents.  There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>
2018-05-07 09:34:12 -04:00

71 lines
1.4 KiB
C

// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2017 PHYTEC Messtechnik GmbH
* Author: Wadim Egorov <w.egorov@phytec.de>
*/
#include <asm/io.h>
#include <common.h>
#include <dm.h>
#include <environment.h>
#include <i2c.h>
#include <i2c_eeprom.h>
#include <netdev.h>
#include "som.h"
static int valid_rk3288_som(struct rk3288_som *som)
{
unsigned char *p = (unsigned char *)som;
unsigned char *e = p + sizeof(struct rk3288_som) - 1;
int hw = 0;
while (p < e) {
hw += hweight8(*p);
p++;
}
return hw == som->bs;
}
int rk_board_late_init(void)
{
int ret;
struct udevice *dev;
struct rk3288_som opt;
int off;
/* Get the identificatioin page of M24C32-D EEPROM */
off = fdt_path_offset(gd->fdt_blob, "eeprom0");
if (off < 0) {
printf("%s: No eeprom0 path offset\n", __func__);
return off;
}
ret = uclass_get_device_by_of_offset(UCLASS_I2C_EEPROM, off, &dev);
if (ret) {
printf("%s: Could not find EEPROM\n", __func__);
return ret;
}
ret = i2c_set_chip_offset_len(dev, 2);
if (ret)
return ret;
ret = i2c_eeprom_read(dev, 0, (uint8_t *)&opt,
sizeof(struct rk3288_som));
if (ret) {
printf("%s: Could not read EEPROM\n", __func__);
return ret;
}
if (opt.api_version != 0 || !valid_rk3288_som(&opt)) {
printf("Invalid data or wrong EEPROM layout version.\n");
/* Proceed anyway, since there is no fallback option */
}
if (is_valid_ethaddr(opt.mac))
eth_env_set_enetaddr("ethaddr", opt.mac);
return 0;
}