board-dt-sama5.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. #include <linux/types.h>
  10. #include <linux/init.h>
  11. #include <linux/module.h>
  12. #include <linux/gpio.h>
  13. #include <linux/micrel_phy.h>
  14. #include <linux/of.h>
  15. #include <linux/of_irq.h>
  16. #include <linux/of_platform.h>
  17. #include <linux/phy.h>
  18. #include <linux/clk-provider.h>
  19. #include <asm/setup.h>
  20. #include <asm/irq.h>
  21. #include <asm/mach/arch.h>
  22. #include <asm/mach/map.h>
  23. #include <asm/mach/irq.h>
  24. #include "at91_aic.h"
  25. #include "generic.h"
  26. static void __init sama5_dt_timer_init(void)
  27. {
  28. #if defined(CONFIG_COMMON_CLK)
  29. of_clk_init(NULL);
  30. #endif
  31. at91sam926x_pit_init();
  32. }
  33. static const struct of_device_id irq_of_match[] __initconst = {
  34. { .compatible = "atmel,sama5d3-aic", .data = at91_aic5_of_init },
  35. { /*sentinel*/ }
  36. };
  37. static void __init at91_dt_init_irq(void)
  38. {
  39. of_irq_init(irq_of_match);
  40. }
  41. static int ksz9021rn_phy_fixup(struct phy_device *phy)
  42. {
  43. int value;
  44. /* Set delay values */
  45. value = MICREL_KSZ9021_RGMII_CLK_CTRL_PAD_SCEW | 0x8000;
  46. phy_write(phy, MICREL_KSZ9021_EXTREG_CTRL, value);
  47. value = 0xF2F4;
  48. phy_write(phy, MICREL_KSZ9021_EXTREG_DATA_WRITE, value);
  49. value = MICREL_KSZ9021_RGMII_RX_DATA_PAD_SCEW | 0x8000;
  50. phy_write(phy, MICREL_KSZ9021_EXTREG_CTRL, value);
  51. value = 0x2222;
  52. phy_write(phy, MICREL_KSZ9021_EXTREG_DATA_WRITE, value);
  53. return 0;
  54. }
  55. static void __init sama5_dt_device_init(void)
  56. {
  57. if (of_machine_is_compatible("atmel,sama5d3xcm") &&
  58. IS_ENABLED(CONFIG_PHYLIB))
  59. phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
  60. ksz9021rn_phy_fixup);
  61. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  62. }
  63. static const char *sama5_dt_board_compat[] __initdata = {
  64. "atmel,sama5",
  65. NULL
  66. };
  67. DT_MACHINE_START(sama5_dt, "Atmel SAMA5 (Device Tree)")
  68. /* Maintainer: Atmel */
  69. .init_time = sama5_dt_timer_init,
  70. .map_io = at91_map_io,
  71. .handle_irq = at91_aic5_handle_irq,
  72. .init_early = at91_dt_initialize,
  73. .init_irq = at91_dt_init_irq,
  74. .init_machine = sama5_dt_device_init,
  75. .dt_compat = sama5_dt_board_compat,
  76. MACHINE_END