2
0

131-reset-add-h3-resets.patch 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. From 5f0bb9d0bc545ef53a83f7bd176fdc0736eed8e5 Mon Sep 17 00:00:00 2001
  2. From: Jens Kuske <jenskuske@gmail.com>
  3. Date: Tue, 27 Oct 2015 17:50:24 +0100
  4. Subject: [PATCH] reset: sunxi: Add Allwinner H3 bus resets
  5. The H3 bus resets have some holes between the registers, so we add
  6. an of_xlate() function to skip them according to the datasheet.
  7. Signed-off-by: Jens Kuske <jenskuske@gmail.com>
  8. ---
  9. .../bindings/reset/allwinner,sunxi-clock-reset.txt | 1 +
  10. drivers/reset/reset-sunxi.c | 30 +++++++++++++++++++---
  11. 2 files changed, 28 insertions(+), 3 deletions(-)
  12. --- a/Documentation/devicetree/bindings/reset/allwinner,sunxi-clock-reset.txt
  13. +++ b/Documentation/devicetree/bindings/reset/allwinner,sunxi-clock-reset.txt
  14. @@ -8,6 +8,7 @@ Required properties:
  15. - compatible: Should be one of the following:
  16. "allwinner,sun6i-a31-ahb1-reset"
  17. "allwinner,sun6i-a31-clock-reset"
  18. + "allwinner,sun8i-h3-bus-reset"
  19. - reg: should be register base and length as documented in the
  20. datasheet
  21. - #reset-cells: 1, see below
  22. --- a/drivers/reset/reset-sunxi.c
  23. +++ b/drivers/reset/reset-sunxi.c
  24. @@ -75,7 +75,9 @@ static struct reset_control_ops sunxi_re
  25. .deassert = sunxi_reset_deassert,
  26. };
  27. -static int sunxi_reset_init(struct device_node *np)
  28. +static int sunxi_reset_init(struct device_node *np,
  29. + int (*of_xlate)(struct reset_controller_dev *rcdev,
  30. + const struct of_phandle_args *reset_spec))
  31. {
  32. struct sunxi_reset_data *data;
  33. struct resource res;
  34. @@ -108,6 +110,7 @@ static int sunxi_reset_init(struct devic
  35. data->rcdev.nr_resets = size * 32;
  36. data->rcdev.ops = &sunxi_reset_ops;
  37. data->rcdev.of_node = np;
  38. + data->rcdev.of_xlate = of_xlate;
  39. reset_controller_register(&data->rcdev);
  40. return 0;
  41. @@ -117,6 +120,21 @@ err_alloc:
  42. return ret;
  43. };
  44. +static int sun8i_h3_bus_reset_xlate(struct reset_controller_dev *rcdev,
  45. + const struct of_phandle_args *reset_spec)
  46. +{
  47. + unsigned int index = reset_spec->args[0];
  48. +
  49. + if (index < 96)
  50. + return index;
  51. + else if (index < 128)
  52. + return index + 32;
  53. + else if (index < 160)
  54. + return index + 64;
  55. + else
  56. + return -EINVAL;
  57. +}
  58. +
  59. /*
  60. * These are the reset controller we need to initialize early on in
  61. * our system, before we can even think of using a regular device
  62. @@ -124,15 +142,21 @@ err_alloc:
  63. */
  64. static const struct of_device_id sunxi_early_reset_dt_ids[] __initdata = {
  65. { .compatible = "allwinner,sun6i-a31-ahb1-reset", },
  66. + { .compatible = "allwinner,sun8i-h3-bus-reset", .data = sun8i_h3_bus_reset_xlate, },
  67. { /* sentinel */ },
  68. };
  69. void __init sun6i_reset_init(void)
  70. {
  71. struct device_node *np;
  72. -
  73. - for_each_matching_node(np, sunxi_early_reset_dt_ids)
  74. - sunxi_reset_init(np);
  75. + const struct of_device_id *match;
  76. + int (*of_xlate)(struct reset_controller_dev *rcdev,
  77. + const struct of_phandle_args *reset_spec);
  78. +
  79. + for_each_matching_node_and_match(np, sunxi_early_reset_dt_ids, &match) {
  80. + of_xlate = match->data;
  81. + sunxi_reset_init(np, of_xlate);
  82. + }
  83. }
  84. /*