soc-gemini.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (C) 2017 Linaro Ltd.
  4. *
  5. * Author: Linus Walleij <linus.walleij@linaro.org>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2, as
  9. * published by the Free Software Foundation.
  10. *
  11. */
  12. #include <linux/init.h>
  13. #include <linux/kernel.h>
  14. #include <linux/mfd/syscon.h>
  15. #include <linux/regmap.h>
  16. #include <linux/of.h>
  17. #define GLOBAL_WORD_ID 0x00
  18. #define GEMINI_GLOBAL_ARB1_CTRL 0x2c
  19. #define GEMINI_ARB1_BURST_MASK GENMASK(21, 16)
  20. #define GEMINI_ARB1_BURST_SHIFT 16
  21. /* These all define the priority on the BUS2 backplane */
  22. #define GEMINI_ARB1_PRIO_MASK GENMASK(9, 0)
  23. #define GEMINI_ARB1_DMAC_HIGH_PRIO BIT(0)
  24. #define GEMINI_ARB1_IDE_HIGH_PRIO BIT(1)
  25. #define GEMINI_ARB1_RAID_HIGH_PRIO BIT(2)
  26. #define GEMINI_ARB1_SECURITY_HIGH_PRIO BIT(3)
  27. #define GEMINI_ARB1_GMAC0_HIGH_PRIO BIT(4)
  28. #define GEMINI_ARB1_GMAC1_HIGH_PRIO BIT(5)
  29. #define GEMINI_ARB1_USB0_HIGH_PRIO BIT(6)
  30. #define GEMINI_ARB1_USB1_HIGH_PRIO BIT(7)
  31. #define GEMINI_ARB1_PCI_HIGH_PRIO BIT(8)
  32. #define GEMINI_ARB1_TVE_HIGH_PRIO BIT(9)
  33. #define GEMINI_DEFAULT_BURST_SIZE 0x20
  34. #define GEMINI_DEFAULT_PRIO (GEMINI_ARB1_GMAC0_HIGH_PRIO | \
  35. GEMINI_ARB1_GMAC1_HIGH_PRIO)
  36. static int __init gemini_soc_init(void)
  37. {
  38. struct regmap *map;
  39. u32 rev;
  40. u32 val;
  41. int ret;
  42. /* Multiplatform guard, only proceed on Gemini */
  43. if (!of_machine_is_compatible("cortina,gemini"))
  44. return 0;
  45. map = syscon_regmap_lookup_by_compatible("cortina,gemini-syscon");
  46. if (IS_ERR(map))
  47. return PTR_ERR(map);
  48. ret = regmap_read(map, GLOBAL_WORD_ID, &rev);
  49. if (ret)
  50. return ret;
  51. val = (GEMINI_DEFAULT_BURST_SIZE << GEMINI_ARB1_BURST_SHIFT) |
  52. GEMINI_DEFAULT_PRIO;
  53. /* Set up system arbitration */
  54. regmap_update_bits(map,
  55. GEMINI_GLOBAL_ARB1_CTRL,
  56. GEMINI_ARB1_BURST_MASK | GEMINI_ARB1_PRIO_MASK,
  57. val);
  58. pr_info("Gemini SoC %04x revision %02x, set arbitration %08x\n",
  59. rev >> 8, rev & 0xff, val);
  60. return 0;
  61. }
  62. subsys_initcall(gemini_soc_init);