2 * Setup code for SAMA5 Evaluation Kits with Device Tree support
4 * Copyright (C) 2013 Atmel,
5 * 2013 Ludovic Desroches <ludovic.desroches@atmel.com>
7 * Licensed under GPLv2 or later.
10 #include <linux/types.h>
11 #include <linux/init.h>
12 #include <linux/module.h>
13 #include <linux/gpio.h>
14 #include <linux/micrel_phy.h>
16 #include <linux/of_irq.h>
17 #include <linux/of_platform.h>
18 #include <linux/phy.h>
19 #include <linux/clk-provider.h>
21 #include <asm/setup.h>
23 #include <asm/mach/arch.h>
24 #include <asm/mach/map.h>
25 #include <asm/mach/irq.h>
30 static int ksz9021rn_phy_fixup(struct phy_device *phy)
34 /* Set delay values */
35 value = MICREL_KSZ9021_RGMII_CLK_CTRL_PAD_SCEW | 0x8000;
36 phy_write(phy, MICREL_KSZ9021_EXTREG_CTRL, value);
38 phy_write(phy, MICREL_KSZ9021_EXTREG_DATA_WRITE, value);
39 value = MICREL_KSZ9021_RGMII_RX_DATA_PAD_SCEW | 0x8000;
40 phy_write(phy, MICREL_KSZ9021_EXTREG_CTRL, value);
42 phy_write(phy, MICREL_KSZ9021_EXTREG_DATA_WRITE, value);
47 static void __init sama5_dt_device_init(void)
49 if (of_machine_is_compatible("atmel,sama5d3xcm") &&
50 IS_ENABLED(CONFIG_PHYLIB))
51 phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
54 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
57 static const char *sama5_dt_board_compat[] __initdata = {
62 DT_MACHINE_START(sama5_dt, "Atmel SAMA5 (Device Tree)")
63 /* Maintainer: Atmel */
64 .map_io = at91_map_io,
65 .init_early = at91_dt_initialize,
66 .init_machine = sama5_dt_device_init,
67 .dt_compat = sama5_dt_board_compat,