0155-clk-bcm2835-Add-a-driver-for-the-auxiliary-periphera.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. From 55c1d677bb9f90db7d08c514171a9e3cbf643910 Mon Sep 17 00:00:00 2001
  2. From: Eric Anholt <eric@anholt.net>
  3. Date: Tue, 15 Dec 2015 15:35:58 -0800
  4. Subject: [PATCH] clk: bcm2835: Add a driver for the auxiliary peripheral clock
  5. gates.
  6. There are a pair of SPI masters and a mini UART that were last minute
  7. additions. As a result, they didn't get integrated in the same way as
  8. the other gates off of the VPU clock in CPRMAN.
  9. Signed-off-by: Eric Anholt <eric@anholt.net>
  10. Signed-off-by: Michael Turquette <mturquette@baylibre.com>
  11. updated Makefile to preserve the rasoberry pi architectures
  12. ---
  13. drivers/clk/bcm/Makefile | 1 +
  14. drivers/clk/bcm/clk-bcm2835-aux.c | 85 +++++++++++++++++++++++++++++++++++++++
  15. 2 files changed, 86 insertions(+)
  16. create mode 100644 drivers/clk/bcm/clk-bcm2835-aux.c
  17. --- a/drivers/clk/bcm/Makefile
  18. +++ b/drivers/clk/bcm/Makefile
  19. @@ -4,6 +4,7 @@ obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm281
  20. obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm21664.o
  21. obj-$(CONFIG_COMMON_CLK_IPROC) += clk-iproc-armpll.o clk-iproc-pll.o clk-iproc-asiu.o
  22. obj-$(CONFIG_ARCH_BCM2835)$(CONFIG_ARCH_BCM2708)$(CONFIG_ARCH_BCM2709) += clk-bcm2835.o
  23. +obj-$(CONFIG_ARCH_BCM2835) += clk-bcm2835-aux.o
  24. obj-$(CONFIG_COMMON_CLK_IPROC) += clk-ns2.o
  25. obj-$(CONFIG_ARCH_BCM_CYGNUS) += clk-cygnus.o
  26. obj-$(CONFIG_ARCH_BCM_NSP) += clk-nsp.o
  27. --- /dev/null
  28. +++ b/drivers/clk/bcm/clk-bcm2835-aux.c
  29. @@ -0,0 +1,85 @@
  30. +/*
  31. + * Copyright (C) 2015 Broadcom
  32. + *
  33. + * This program is free software; you can redistribute it and/or modify
  34. + * it under the terms of the GNU General Public License as published by
  35. + * the Free Software Foundation; either version 2 of the License, or
  36. + * (at your option) any later version.
  37. + *
  38. + * This program is distributed in the hope that it will be useful,
  39. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  40. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  41. + * GNU General Public License for more details.
  42. + */
  43. +
  44. +#include <linux/clk.h>
  45. +#include <linux/clk-provider.h>
  46. +#include <linux/clk/bcm2835.h>
  47. +#include <linux/module.h>
  48. +#include <linux/platform_device.h>
  49. +#include <dt-bindings/clock/bcm2835-aux.h>
  50. +
  51. +#define BCM2835_AUXIRQ 0x00
  52. +#define BCM2835_AUXENB 0x04
  53. +
  54. +static int bcm2835_aux_clk_probe(struct platform_device *pdev)
  55. +{
  56. + struct device *dev = &pdev->dev;
  57. + struct clk_onecell_data *onecell;
  58. + const char *parent;
  59. + struct clk *parent_clk;
  60. + struct resource *res;
  61. + void __iomem *reg, *gate;
  62. +
  63. + parent_clk = devm_clk_get(dev, NULL);
  64. + if (IS_ERR(parent_clk))
  65. + return PTR_ERR(parent_clk);
  66. + parent = __clk_get_name(parent_clk);
  67. +
  68. + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  69. + reg = devm_ioremap_resource(dev, res);
  70. + if (!reg)
  71. + return -ENODEV;
  72. +
  73. + onecell = devm_kmalloc(dev, sizeof(*onecell), GFP_KERNEL);
  74. + if (!onecell)
  75. + return -ENOMEM;
  76. + onecell->clk_num = BCM2835_AUX_CLOCK_COUNT;
  77. + onecell->clks = devm_kcalloc(dev, BCM2835_AUX_CLOCK_COUNT,
  78. + sizeof(*onecell->clks), GFP_KERNEL);
  79. + if (!onecell->clks)
  80. + return -ENOMEM;
  81. +
  82. + gate = reg + BCM2835_AUXENB;
  83. + onecell->clks[BCM2835_AUX_CLOCK_UART] =
  84. + clk_register_gate(dev, "aux_uart", parent, 0, gate, 0, 0, NULL);
  85. +
  86. + onecell->clks[BCM2835_AUX_CLOCK_SPI1] =
  87. + clk_register_gate(dev, "aux_spi1", parent, 0, gate, 1, 0, NULL);
  88. +
  89. + onecell->clks[BCM2835_AUX_CLOCK_SPI2] =
  90. + clk_register_gate(dev, "aux_spi2", parent, 0, gate, 2, 0, NULL);
  91. +
  92. + of_clk_add_provider(pdev->dev.of_node, of_clk_src_onecell_get, onecell);
  93. +
  94. + return 0;
  95. +}
  96. +
  97. +static const struct of_device_id bcm2835_aux_clk_of_match[] = {
  98. + { .compatible = "brcm,bcm2835-aux", },
  99. + {},
  100. +};
  101. +MODULE_DEVICE_TABLE(of, bcm2835_aux_clk_of_match);
  102. +
  103. +static struct platform_driver bcm2835_aux_clk_driver = {
  104. + .driver = {
  105. + .name = "bcm2835-aux-clk",
  106. + .of_match_table = bcm2835_aux_clk_of_match,
  107. + },
  108. + .probe = bcm2835_aux_clk_probe,
  109. +};
  110. +builtin_platform_driver(bcm2835_aux_clk_driver);
  111. +
  112. +MODULE_AUTHOR("Eric Anholt <eric@anholt.net>");
  113. +MODULE_DESCRIPTION("BCM2835 auxiliary peripheral clock driver");
  114. +MODULE_LICENSE("GPL v2");