sama5.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Setup code for SAMA5
  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 <linux/phy.h>
  20. #include <mach/hardware.h>
  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. #include "generic.h"
  27. static int ksz8081_phy_fixup(struct phy_device *phy)
  28. {
  29. int value;
  30. value = phy_read(phy, 0x16);
  31. value &= ~0x20;
  32. phy_write(phy, 0x16, value);
  33. return 0;
  34. }
  35. static void __init sama5_dt_device_init(void)
  36. {
  37. if (of_machine_is_compatible("atmel,sama5d4ek") &&
  38. IS_ENABLED(CONFIG_PHYLIB)) {
  39. phy_register_fixup_for_id("fc028000.etherne:00",
  40. ksz8081_phy_fixup);
  41. }
  42. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  43. at91sam9x5_pm_init();
  44. }
  45. static const char *sama5_dt_board_compat[] __initconst = {
  46. "atmel,sama5",
  47. NULL
  48. };
  49. DT_MACHINE_START(sama5_dt, "Atmel SAMA5")
  50. /* Maintainer: Atmel */
  51. .map_io = at91_map_io,
  52. .init_machine = sama5_dt_device_init,
  53. .dt_compat = sama5_dt_board_compat,
  54. MACHINE_END
  55. static struct map_desc at91_io_desc[] __initdata = {
  56. {
  57. .virtual = (unsigned long)AT91_ALT_IO_P2V(SAMA5D4_BASE_MPDDRC),
  58. .pfn = __phys_to_pfn(SAMA5D4_BASE_MPDDRC),
  59. .length = SZ_512,
  60. .type = MT_DEVICE,
  61. },
  62. {
  63. .virtual = (unsigned long)AT91_ALT_IO_P2V(SAMA5D4_BASE_PMC),
  64. .pfn = __phys_to_pfn(SAMA5D4_BASE_PMC),
  65. .length = SZ_512,
  66. .type = MT_DEVICE,
  67. },
  68. { /* On sama5d4, we use USART3 as serial console */
  69. .virtual = (unsigned long)AT91_ALT_IO_P2V(SAMA5D4_BASE_USART3),
  70. .pfn = __phys_to_pfn(SAMA5D4_BASE_USART3),
  71. .length = SZ_256,
  72. .type = MT_DEVICE,
  73. },
  74. { /* A bunch of peripheral with fine grained IO space */
  75. .virtual = (unsigned long)AT91_ALT_IO_P2V(SAMA5D4_BASE_SYS2),
  76. .pfn = __phys_to_pfn(SAMA5D4_BASE_SYS2),
  77. .length = SZ_2K,
  78. .type = MT_DEVICE,
  79. },
  80. };
  81. static void __init sama5_alt_map_io(void)
  82. {
  83. at91_alt_map_io();
  84. iotable_init(at91_io_desc, ARRAY_SIZE(at91_io_desc));
  85. }
  86. static const char *sama5_alt_dt_board_compat[] __initconst = {
  87. "atmel,sama5d4",
  88. NULL
  89. };
  90. DT_MACHINE_START(sama5_alt_dt, "Atmel SAMA5")
  91. /* Maintainer: Atmel */
  92. .map_io = sama5_alt_map_io,
  93. .init_machine = sama5_dt_device_init,
  94. .dt_compat = sama5_alt_dt_board_compat,
  95. .l2c_aux_mask = ~0UL,
  96. MACHINE_END