board-dt-sama5.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 <asm/setup.h>
  19. #include <asm/irq.h>
  20. #include <asm/mach/arch.h>
  21. #include <asm/mach/map.h>
  22. #include <asm/mach/irq.h>
  23. #include "at91_aic.h"
  24. #include "generic.h"
  25. static const struct of_device_id irq_of_match[] __initconst = {
  26. { .compatible = "atmel,sama5d3-aic", .data = at91_aic5_of_init },
  27. { /*sentinel*/ }
  28. };
  29. static void __init at91_dt_init_irq(void)
  30. {
  31. of_irq_init(irq_of_match);
  32. }
  33. static int ksz9021rn_phy_fixup(struct phy_device *phy)
  34. {
  35. int value;
  36. /* Set delay values */
  37. value = MICREL_KSZ9021_RGMII_CLK_CTRL_PAD_SCEW | 0x8000;
  38. phy_write(phy, MICREL_KSZ9021_EXTREG_CTRL, value);
  39. value = 0xF2F4;
  40. phy_write(phy, MICREL_KSZ9021_EXTREG_DATA_WRITE, value);
  41. value = MICREL_KSZ9021_RGMII_RX_DATA_PAD_SCEW | 0x8000;
  42. phy_write(phy, MICREL_KSZ9021_EXTREG_CTRL, value);
  43. value = 0x2222;
  44. phy_write(phy, MICREL_KSZ9021_EXTREG_DATA_WRITE, value);
  45. return 0;
  46. }
  47. static void __init sama5_dt_device_init(void)
  48. {
  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,
  52. ksz9021rn_phy_fixup);
  53. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  54. }
  55. static const char *sama5_dt_board_compat[] __initdata = {
  56. "atmel,sama5",
  57. NULL
  58. };
  59. DT_MACHINE_START(sama5_dt, "Atmel SAMA5 (Device Tree)")
  60. /* Maintainer: Atmel */
  61. .init_time = at91sam926x_pit_init,
  62. .map_io = at91_map_io,
  63. .handle_irq = at91_aic5_handle_irq,
  64. .init_early = at91_dt_initialize,
  65. .init_irq = at91_dt_init_irq,
  66. .init_machine = sama5_dt_device_init,
  67. .dt_compat = sama5_dt_board_compat,
  68. MACHINE_END