summaryrefslogtreecommitdiffstats
path: root/arch/arm/boards/embest-marsboard/board.c
blob: a11b7b6579c0a1e21e827d485f6c3c37d23bc420 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (C) 2013 Lucas Stach <l.stach@pengutronix.de>
 * Copyright (C) 2014 Eric Bénard <eric@eukrea.com>
 * Copyright (C) 2019 Ahmad Fatoum <a.fatoum@pengutronix.de>
 */

#include <common.h>
#include <init.h>
#include <envfs.h>
#include <mach/bbu.h>
#include <linux/phy.h>
#include <deep-probe.h>

static int ar8035_phy_fixup(struct phy_device *dev)
{
	u16 val;

	/* Ar803x phy SmartEEE feature cause link status generates glitch,
	 * which cause ethernet link down/up issue, so disable SmartEEE
	 */
	val = phy_read_mmd_indirect(dev, 0x805d, 0x3);
	phy_write(dev, MII_MMD_DATA, val & ~(1 << 8));

	val = phy_read_mmd_indirect(dev, 0x4003, 0x3);
	phy_write(dev, MII_MMD_DATA, val & ~(1 << 8));

	val = phy_read_mmd_indirect(dev, 0x4007, 0x3);
	val &= 0xffe3;
	val |= 0x18;
	phy_write(dev, MII_MMD_DATA, val);

	return 0;
}

static int marsboard_device_init(struct device_d *dev)
{
	barebox_set_hostname("marsboard");

	phy_register_fixup_for_uid(0x004dd072, 0xffffffef, ar8035_phy_fixup);

	imx6_bbu_internal_spi_i2c_register_handler("spiflash",
		"/dev/m25p0.barebox", BBU_HANDLER_FLAG_DEFAULT);

	defaultenv_append_directory(defaultenv_mars);

	return 0;
}

static const struct of_device_id marsboard_of_match[] = {
	{ .compatible = "embest,imx6q-marsboard" },
	{ /* sentinel */ },
};
BAREBOX_DEEP_PROBE_ENABLE(marsboard_of_match);

static struct driver_d marsboard_driver = {
	.name = "board-mars",
	.probe = marsboard_device_init,
	.of_compatible = marsboard_of_match,
};
postcore_platform_driver(marsboard_driver);