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. @@ -77,7 +77,9 @@ static const struct reset_control_ops su
  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. @@ -110,6 +112,7 @@ static int sunxi_reset_init(struct devic
  35. data->rcdev.nr_resets = size * 8;
  36. data->rcdev.ops = &sunxi_reset_ops;
  37. data->rcdev.of_node = np;
  38. + data->rcdev.of_xlate = of_xlate;
  39. return reset_controller_register(&data->rcdev);
  40. @@ -118,6 +121,21 @@ err_alloc:
  41. return ret;
  42. };
  43. +static int sun8i_h3_bus_reset_xlate(struct reset_controller_dev *rcdev,
  44. + const struct of_phandle_args *reset_spec)
  45. +{
  46. + unsigned int index = reset_spec->args[0];
  47. +
  48. + if (index < 96)
  49. + return index;
  50. + else if (index < 128)
  51. + return index + 32;
  52. + else if (index < 160)
  53. + return index + 64;
  54. + else
  55. + return -EINVAL;
  56. +}
  57. +
  58. /*
  59. * These are the reset controller we need to initialize early on in
  60. * our system, before we can even think of using a regular device
  61. @@ -125,15 +143,21 @@ err_alloc:
  62. */
  63. static const struct of_device_id sunxi_early_reset_dt_ids[] __initconst = {
  64. { .compatible = "allwinner,sun6i-a31-ahb1-reset", },
  65. + { .compatible = "allwinner,sun8i-h3-bus-reset", .data = sun8i_h3_bus_reset_xlate, },
  66. { /* sentinel */ },
  67. };
  68. void __init sun6i_reset_init(void)
  69. {
  70. struct device_node *np;
  71. -
  72. - for_each_matching_node(np, sunxi_early_reset_dt_ids)
  73. - sunxi_reset_init(np);
  74. + const struct of_device_id *match;
  75. + int (*of_xlate)(struct reset_controller_dev *rcdev,
  76. + const struct of_phandle_args *reset_spec);
  77. +
  78. + for_each_matching_node_and_match(np, sunxi_early_reset_dt_ids, &match) {
  79. + of_xlate = match->data;
  80. + sunxi_reset_init(np, of_xlate);
  81. + }
  82. }
  83. /*