Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 1 | /* |
| 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> |
Boris BREZILLON | d4d24c1 | 2013-10-11 14:43:31 +0200 | [diff] [blame] | 19 | #include <linux/clk-provider.h> |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 20 | |
| 21 | #include <asm/setup.h> |
| 22 | #include <asm/irq.h> |
| 23 | #include <asm/mach/arch.h> |
| 24 | #include <asm/mach/map.h> |
| 25 | #include <asm/mach/irq.h> |
| 26 | |
| 27 | #include "at91_aic.h" |
| 28 | #include "generic.h" |
| 29 | |
Boris BREZILLON | d4d24c1 | 2013-10-11 14:43:31 +0200 | [diff] [blame] | 30 | static void __init sama5_dt_timer_init(void) |
| 31 | { |
| 32 | #if defined(CONFIG_COMMON_CLK) |
| 33 | of_clk_init(NULL); |
| 34 | #endif |
| 35 | at91sam926x_pit_init(); |
| 36 | } |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 37 | |
| 38 | static const struct of_device_id irq_of_match[] __initconst = { |
| 39 | |
| 40 | { .compatible = "atmel,sama5d3-aic", .data = at91_aic5_of_init }, |
| 41 | { /*sentinel*/ } |
| 42 | }; |
| 43 | |
| 44 | static void __init at91_dt_init_irq(void) |
| 45 | { |
| 46 | of_irq_init(irq_of_match); |
| 47 | } |
| 48 | |
| 49 | static int ksz9021rn_phy_fixup(struct phy_device *phy) |
| 50 | { |
| 51 | int value; |
| 52 | |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 53 | /* Set delay values */ |
Dinh Nguyen | dc76a1a | 2013-08-13 09:59:00 -0500 | [diff] [blame] | 54 | value = MICREL_KSZ9021_RGMII_CLK_CTRL_PAD_SCEW | 0x8000; |
| 55 | phy_write(phy, MICREL_KSZ9021_EXTREG_CTRL, value); |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 56 | value = 0xF2F4; |
Dinh Nguyen | dc76a1a | 2013-08-13 09:59:00 -0500 | [diff] [blame] | 57 | phy_write(phy, MICREL_KSZ9021_EXTREG_DATA_WRITE, value); |
| 58 | value = MICREL_KSZ9021_RGMII_RX_DATA_PAD_SCEW | 0x8000; |
| 59 | phy_write(phy, MICREL_KSZ9021_EXTREG_CTRL, value); |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 60 | value = 0x2222; |
Dinh Nguyen | dc76a1a | 2013-08-13 09:59:00 -0500 | [diff] [blame] | 61 | phy_write(phy, MICREL_KSZ9021_EXTREG_DATA_WRITE, value); |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 62 | |
| 63 | return 0; |
| 64 | } |
| 65 | |
| 66 | static void __init sama5_dt_device_init(void) |
| 67 | { |
Alexandre Belloni | 0580ed3 | 2013-06-05 09:50:43 +0000 | [diff] [blame] | 68 | if (of_machine_is_compatible("atmel,sama5d3xcm") && |
| 69 | IS_ENABLED(CONFIG_PHYLIB)) |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 70 | phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK, |
| 71 | ksz9021rn_phy_fixup); |
| 72 | |
| 73 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); |
| 74 | } |
| 75 | |
| 76 | static const char *sama5_dt_board_compat[] __initdata = { |
| 77 | "atmel,sama5", |
| 78 | NULL |
| 79 | }; |
| 80 | |
| 81 | DT_MACHINE_START(sama5_dt, "Atmel SAMA5 (Device Tree)") |
| 82 | /* Maintainer: Atmel */ |
Boris BREZILLON | d4d24c1 | 2013-10-11 14:43:31 +0200 | [diff] [blame] | 83 | .init_time = sama5_dt_timer_init, |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 84 | .map_io = at91_map_io, |
| 85 | .handle_irq = at91_aic5_handle_irq, |
| 86 | .init_early = at91_dt_initialize, |
| 87 | .init_irq = at91_dt_init_irq, |
| 88 | .init_machine = sama5_dt_device_init, |
| 89 | .dt_compat = sama5_dt_board_compat, |
| 90 | MACHINE_END |