2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2017-09-01 08:26:16 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 Microchip
|
|
|
|
* Wenyou Yang <wenyou.yang@microchip.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2020-07-19 16:15:42 +00:00
|
|
|
#include <dm.h>
|
2019-08-01 15:46:51 +00:00
|
|
|
#include <env.h>
|
2018-09-18 07:35:42 +00:00
|
|
|
#include <w1.h>
|
|
|
|
#include <w1-eeprom.h>
|
|
|
|
#include <dm/device-internal.h>
|
|
|
|
|
|
|
|
#define AT91_PDA_EEPROM_ID_OFFSET 15
|
|
|
|
#define AT91_PDA_EEPROM_ID_LENGTH 5
|
|
|
|
#define AT91_PDA_EEPROM_DEFAULT_BUS 0
|
2017-09-01 08:26:16 +00:00
|
|
|
|
2018-10-08 06:54:27 +00:00
|
|
|
char *get_cpu_name(void);
|
|
|
|
|
2017-09-01 08:26:16 +00:00
|
|
|
void dummy(void)
|
|
|
|
{
|
|
|
|
}
|
2018-09-18 07:35:42 +00:00
|
|
|
|
|
|
|
#if defined CONFIG_W1
|
|
|
|
void at91_pda_detect(void)
|
|
|
|
{
|
|
|
|
struct udevice *bus, *dev;
|
|
|
|
u8 buf[AT91_PDA_EEPROM_ID_LENGTH + 1] = {0};
|
|
|
|
int ret;
|
|
|
|
int pda = 0;
|
|
|
|
|
|
|
|
ret = w1_get_bus(AT91_PDA_EEPROM_DEFAULT_BUS, &bus);
|
|
|
|
if (ret)
|
2019-06-12 10:16:18 +00:00
|
|
|
goto pda_detect_err;
|
2018-09-18 07:35:42 +00:00
|
|
|
|
|
|
|
for (device_find_first_child(bus, &dev);
|
|
|
|
dev;
|
|
|
|
device_find_next_child(&dev)) {
|
|
|
|
ret = device_probe(dev);
|
|
|
|
if (ret) {
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
ret = w1_eeprom_read_buf(dev, AT91_PDA_EEPROM_ID_OFFSET,
|
|
|
|
(u8 *)buf, AT91_PDA_EEPROM_ID_LENGTH);
|
|
|
|
if (ret)
|
2019-06-12 10:16:18 +00:00
|
|
|
goto pda_detect_err;
|
2018-09-18 07:35:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-07-24 15:03:30 +00:00
|
|
|
pda = dectoul((const char *)buf, NULL);
|
2018-09-18 07:35:42 +00:00
|
|
|
|
|
|
|
switch (pda) {
|
|
|
|
case 7000:
|
|
|
|
if (buf[4] == 'B')
|
|
|
|
printf("PDA TM7000B detected\n");
|
|
|
|
else
|
|
|
|
printf("PDA TM7000 detected\n");
|
|
|
|
break;
|
|
|
|
case 4300:
|
|
|
|
printf("PDA TM4300 detected\n");
|
|
|
|
break;
|
|
|
|
case 5000:
|
|
|
|
printf("PDA TM5000 detected\n");
|
|
|
|
break;
|
|
|
|
}
|
2019-06-12 10:16:18 +00:00
|
|
|
|
|
|
|
pda_detect_err:
|
2018-09-18 07:35:42 +00:00
|
|
|
env_set("pda", (const char *)buf);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
void at91_pda_detect(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
2018-10-08 06:54:27 +00:00
|
|
|
|
|
|
|
void at91_prepare_cpu_var(void)
|
|
|
|
{
|
|
|
|
env_set("cpu", get_cpu_name());
|
|
|
|
}
|