]> Git Repo - J-u-boot.git/blame - drivers/misc/microchip_flexcom.c
Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""
[J-u-boot.git] / drivers / misc / microchip_flexcom.c
CommitLineData
f8164958
EH
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * (C) Copyright 2019, Microchip Technology, Inc.
4 * Author: Eugen Hristev <[email protected]>
5 */
6
d678a59d 7#include <common.h>
f8164958
EH
8#include <dm.h>
9#include <errno.h>
f7ae49fc 10#include <log.h>
f8164958
EH
11#include <misc.h>
12#include <asm/io.h>
61b29b82 13#include <linux/err.h>
f8164958
EH
14
15struct microchip_flexcom_regs {
16 u32 cr;
17};
18
8a8d24bd 19struct microchip_flexcom_plat {
f8164958
EH
20 struct microchip_flexcom_regs *regs;
21 u32 flexcom_mode;
22};
23
d1998a9f 24static int microchip_flexcom_of_to_plat(struct udevice *dev)
f8164958 25{
8a8d24bd 26 struct microchip_flexcom_plat *plat = dev_get_plat(dev);
f8164958
EH
27 int ret;
28
2548493a 29 plat->regs = map_physmem(dev_read_addr(dev),
f8164958
EH
30 sizeof(struct microchip_flexcom_regs),
31 MAP_NOCACHE);
32
33 ret = dev_read_u32(dev, "atmel,flexcom-mode", &plat->flexcom_mode);
34
35 if (IS_ERR_VALUE(ret)) {
36 debug("Missing atmel,flexcom-mode property\n");
37 return ret;
38 }
39
40 /*
41 * The mode must have only 2 bits. If any other bits are set,
42 * the value is not supported.
43 */
44 if (plat->flexcom_mode & 0xfffffffc) {
45 debug("Wrong atmel,flexcom-mode property\n");
46 return -EINVAL;
47 }
48
49 writel(plat->flexcom_mode, &plat->regs->cr);
50
51 return 0;
52}
53
54static const struct udevice_id microchip_flexcom_ids[] = {
55 { .compatible = "atmel,sama5d2-flexcom" },
56 { .compatible = "microchip,flexcom" },
57 {}
58};
59
60U_BOOT_DRIVER(microchip_flexcom) = {
61 .name = "microchip_flexcom",
62 .id = UCLASS_MISC,
63 .of_match = microchip_flexcom_ids,
d1998a9f 64 .of_to_plat = microchip_flexcom_of_to_plat,
8a8d24bd 65 .plat_auto = sizeof(struct microchip_flexcom_plat),
f8164958 66};
This page took 0.149421 seconds and 4 git commands to generate.