board-dt.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Author: Alexander Shiyan <shc_work@mail.ru>, 2016
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. */
  9. #include <linux/io.h>
  10. #include <linux/of_fdt.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/random.h>
  13. #include <linux/sizes.h>
  14. #include <linux/mfd/syscon/clps711x.h>
  15. #include <asm/system_info.h>
  16. #include <asm/system_misc.h>
  17. #include <asm/mach/arch.h>
  18. #include <asm/mach/map.h>
  19. #define CLPS711X_VIRT_BASE IOMEM(0xfeff4000)
  20. #define CLPS711X_PHYS_BASE (0x80000000)
  21. # define SYSFLG1 (0x0140)
  22. # define HALT (0x0800)
  23. # define UNIQID (0x2440)
  24. # define RANDID0 (0x2700)
  25. # define RANDID1 (0x2704)
  26. # define RANDID2 (0x2708)
  27. # define RANDID3 (0x270c)
  28. static struct map_desc clps711x_io_desc __initdata = {
  29. .virtual = (unsigned long)CLPS711X_VIRT_BASE,
  30. .pfn = __phys_to_pfn(CLPS711X_PHYS_BASE),
  31. .length = 48 * SZ_1K,
  32. .type = MT_DEVICE,
  33. };
  34. static void __init clps711x_map_io(void)
  35. {
  36. iotable_init(&clps711x_io_desc, 1);
  37. }
  38. static const struct resource clps711x_cpuidle_res =
  39. DEFINE_RES_MEM(CLPS711X_PHYS_BASE + HALT, SZ_128);
  40. static void __init clps711x_init(void)
  41. {
  42. u32 id[5];
  43. id[0] = readl(CLPS711X_VIRT_BASE + UNIQID);
  44. id[1] = readl(CLPS711X_VIRT_BASE + RANDID0);
  45. id[2] = readl(CLPS711X_VIRT_BASE + RANDID1);
  46. id[3] = readl(CLPS711X_VIRT_BASE + RANDID2);
  47. id[4] = readl(CLPS711X_VIRT_BASE + RANDID3);
  48. system_rev = SYSFLG1_VERID(readl(CLPS711X_VIRT_BASE + SYSFLG1));
  49. add_device_randomness(id, sizeof(id));
  50. system_serial_low = id[0];
  51. platform_device_register_simple("clps711x-cpuidle", PLATFORM_DEVID_NONE,
  52. &clps711x_cpuidle_res, 1);
  53. }
  54. static void clps711x_restart(enum reboot_mode mode, const char *cmd)
  55. {
  56. soft_restart(0);
  57. }
  58. static const char *clps711x_compat[] __initconst = {
  59. "cirrus,ep7209",
  60. NULL
  61. };
  62. DT_MACHINE_START(CLPS711X_DT, "Cirrus Logic CLPS711X (Device Tree Support)")
  63. .dt_compat = clps711x_compat,
  64. .map_io = clps711x_map_io,
  65. .init_late = clps711x_init,
  66. .restart = clps711x_restart,
  67. MACHINE_END