0433-clk-bcm2835-Do-appropriate-name-lookups-for-DSI1-s-p.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. From 332b2ceea539c6dc84d7478aa89f96317060e7f9 Mon Sep 17 00:00:00 2001
  2. From: Eric Anholt <eric@anholt.net>
  3. Date: Thu, 14 Apr 2016 15:13:53 -0700
  4. Subject: [PATCH] clk: bcm2835: Do appropriate name lookups for DSI1's parents
  5. as well.
  6. Signed-off-by: Eric Anholt <eric@anholt.net>
  7. ---
  8. .../bindings/clock/brcm,bcm2835-cprman.txt | 12 ++++-
  9. drivers/clk/bcm/clk-bcm2835.c | 54 +++++++++++++++++-----
  10. 2 files changed, 54 insertions(+), 12 deletions(-)
  11. --- a/Documentation/devicetree/bindings/clock/brcm,bcm2835-cprman.txt
  12. +++ b/Documentation/devicetree/bindings/clock/brcm,bcm2835-cprman.txt
  13. @@ -16,7 +16,17 @@ Required properties:
  14. - #clock-cells: Should be <1>. The permitted clock-specifier values can be
  15. found in include/dt-bindings/clock/bcm2835.h
  16. - reg: Specifies base physical address and size of the registers
  17. -- clocks: The external oscillator clock phandle
  18. +- clocks: phandles to the parent clocks used as input to the module, in
  19. + the following order:
  20. +
  21. + - External oscillator
  22. + - DSI1 byte clock
  23. + - DSI1 DDR2 clock
  24. + - DSI1 DDR clock
  25. +
  26. + Only external oscillator is required. The DSI clocks may
  27. + not be present, in which case their children will be
  28. + unusable.
  29. Example:
  30. --- a/drivers/clk/bcm/clk-bcm2835.c
  31. +++ b/drivers/clk/bcm/clk-bcm2835.c
  32. @@ -297,11 +297,29 @@
  33. #define LOCK_TIMEOUT_NS 100000000
  34. #define BCM2835_MAX_FB_RATE 1750000000u
  35. +/*
  36. + * Names of clocks used within the driver that need to be replaced
  37. + * with an external parent's name. This array is in the order that
  38. + * the clocks node in the DT references external clocks.
  39. + */
  40. +static const char *cprman_parent_names[] = {
  41. + "xosc",
  42. + "dsi1_byte",
  43. + "dsi1_ddr2",
  44. + "dsi1_ddr",
  45. +};
  46. +
  47. struct bcm2835_cprman {
  48. struct device *dev;
  49. void __iomem *regs;
  50. spinlock_t regs_lock; /* spinlock for all clocks */
  51. - const char *osc_name;
  52. +
  53. + /*
  54. + * Real names of cprman clock parents looked up through
  55. + * of_clk_get_parent_name(), which will be used in the
  56. + * parent_names[] arrays for clock registration.
  57. + */
  58. + const char *real_parent_names[ARRAY_SIZE(cprman_parent_names)];
  59. struct clk_onecell_data onecell;
  60. struct clk *clks[];
  61. @@ -1176,7 +1194,7 @@ static struct clk *bcm2835_register_pll(
  62. memset(&init, 0, sizeof(init));
  63. /* All of the PLLs derive from the external oscillator. */
  64. - init.parent_names = &cprman->osc_name;
  65. + init.parent_names = &cprman->real_parent_names[0];
  66. init.num_parents = 1;
  67. init.name = data->name;
  68. init.ops = &bcm2835_pll_clk_ops;
  69. @@ -1259,17 +1277,21 @@ static struct clk *bcm2835_register_cloc
  70. struct bcm2835_clock *clock;
  71. struct clk_init_data init;
  72. const char *parents[1 << CM_SRC_BITS];
  73. - size_t i;
  74. + size_t i, j;
  75. /*
  76. - * Replace our "xosc" references with the oscillator's
  77. - * actual name.
  78. + * Replace our strings referencing parent clocks with the
  79. + * actual clock-output-name of the parent.
  80. */
  81. for (i = 0; i < data->num_mux_parents; i++) {
  82. - if (strcmp(data->parents[i], "xosc") == 0)
  83. - parents[i] = cprman->osc_name;
  84. - else
  85. - parents[i] = data->parents[i];
  86. + parents[i] = data->parents[i];
  87. +
  88. + for (j = 0; j < ARRAY_SIZE(cprman_parent_names); j++) {
  89. + if (strcmp(parents[i], cprman_parent_names[j]) == 0) {
  90. + parents[i] = cprman->real_parent_names[j];
  91. + break;
  92. + }
  93. + }
  94. }
  95. memset(&init, 0, sizeof(init));
  96. @@ -1891,8 +1913,18 @@ static int bcm2835_clk_probe(struct plat
  97. if (IS_ERR(cprman->regs))
  98. return PTR_ERR(cprman->regs);
  99. - cprman->osc_name = of_clk_get_parent_name(dev->of_node, 0);
  100. - if (!cprman->osc_name)
  101. + for (i = 0; i < ARRAY_SIZE(cprman_parent_names); i++) {
  102. + cprman->real_parent_names[i] =
  103. + of_clk_get_parent_name(dev->of_node, i);
  104. + }
  105. + /*
  106. + * Make sure the external oscillator has been registered.
  107. + *
  108. + * The other (DSI) clocks are not present on older device
  109. + * trees, which we still need to support for backwards
  110. + * compatibility.
  111. + */
  112. + if (!cprman->real_parent_names[0])
  113. return -ENODEV;
  114. platform_set_drvdata(pdev, cprman);