blob: bf00d15d954d3d3f1b6ce1d55ec5840890518fa4 [file] [log] [blame]
Ludovic Desroches8f4b4792013-03-22 13:24:12 +00001/*
2 * Setup code for SAMA5 Evaluation Kits with Device Tree support
3 *
4 * Copyright (C) 2013 Atmel,
5 * 2013 Ludovic Desroches <ludovic.desroches@atmel.com>
6 *
7 * Licensed under GPLv2 or later.
8 */
9
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>
15#include <linux/of.h>
16#include <linux/of_irq.h>
17#include <linux/of_platform.h>
18#include <linux/phy.h>
19
20#include <asm/setup.h>
21#include <asm/irq.h>
22#include <asm/mach/arch.h>
23#include <asm/mach/map.h>
24#include <asm/mach/irq.h>
25
26#include "at91_aic.h"
27#include "generic.h"
28
29
30static const struct of_device_id irq_of_match[] __initconst = {
31
32 { .compatible = "atmel,sama5d3-aic", .data = at91_aic5_of_init },
33 { /*sentinel*/ }
34};
35
36static void __init at91_dt_init_irq(void)
37{
38 of_irq_init(irq_of_match);
39}
40
41static int ksz9021rn_phy_fixup(struct phy_device *phy)
42{
43 int value;
44
Ludovic Desroches8f4b4792013-03-22 13:24:12 +000045 /* Set delay values */
Dinh Nguyendc76a1a2013-08-13 09:59:00 -050046 value = MICREL_KSZ9021_RGMII_CLK_CTRL_PAD_SCEW | 0x8000;
47 phy_write(phy, MICREL_KSZ9021_EXTREG_CTRL, value);
Ludovic Desroches8f4b4792013-03-22 13:24:12 +000048 value = 0xF2F4;
Dinh Nguyendc76a1a2013-08-13 09:59:00 -050049 phy_write(phy, MICREL_KSZ9021_EXTREG_DATA_WRITE, value);
50 value = MICREL_KSZ9021_RGMII_RX_DATA_PAD_SCEW | 0x8000;
51 phy_write(phy, MICREL_KSZ9021_EXTREG_CTRL, value);
Ludovic Desroches8f4b4792013-03-22 13:24:12 +000052 value = 0x2222;
Dinh Nguyendc76a1a2013-08-13 09:59:00 -050053 phy_write(phy, MICREL_KSZ9021_EXTREG_DATA_WRITE, value);
Ludovic Desroches8f4b4792013-03-22 13:24:12 +000054
55 return 0;
56}
57
58static void __init sama5_dt_device_init(void)
59{
Alexandre Belloni0580ed32013-06-05 09:50:43 +000060 if (of_machine_is_compatible("atmel,sama5d3xcm") &&
61 IS_ENABLED(CONFIG_PHYLIB))
Ludovic Desroches8f4b4792013-03-22 13:24:12 +000062 phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
63 ksz9021rn_phy_fixup);
64
65 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
66}
67
68static const char *sama5_dt_board_compat[] __initdata = {
69 "atmel,sama5",
70 NULL
71};
72
73DT_MACHINE_START(sama5_dt, "Atmel SAMA5 (Device Tree)")
74 /* Maintainer: Atmel */
75 .init_time = at91sam926x_pit_init,
76 .map_io = at91_map_io,
77 .handle_irq = at91_aic5_handle_irq,
78 .init_early = at91_dt_initialize,
79 .init_irq = at91_dt_init_irq,
80 .init_machine = sama5_dt_device_init,
81 .dt_compat = sama5_dt_board_compat,
82MACHINE_END