162-clk-sunxi-codec-clock.patch 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. From 9b95732096c11d84bd0082aed0d575d8c09e3ab6 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Emilio=20L=C3=B3pez?= <emilio@elopez.com.ar>
  3. Date: Fri, 18 Jul 2014 15:49:37 -0300
  4. Subject: [PATCH] clk: sunxi: codec clock support
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. The codec clock on sun4i, sun5i and sun7i is a simple gate with PLL2 as
  9. parent.
  10. Signed-off-by: Emilio López <emilio@elopez.com.ar>
  11. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  12. ---
  13. drivers/clk/sunxi/Makefile | 1 +
  14. drivers/clk/sunxi/clk-a10-codec.c | 41 +++++++++++++++++++++++++++++++++++++++
  15. 2 files changed, 42 insertions(+)
  16. create mode 100644 drivers/clk/sunxi/clk-a10-codec.c
  17. --- a/drivers/clk/sunxi/Makefile
  18. +++ b/drivers/clk/sunxi/Makefile
  19. @@ -3,6 +3,7 @@
  20. #
  21. obj-y += clk-sunxi.o clk-factors.o
  22. +obj-y += clk-a10-codec.o
  23. obj-y += clk-a10-hosc.o
  24. obj-y += clk-a10-pll2.o
  25. obj-y += clk-a20-gmac.o
  26. --- /dev/null
  27. +++ b/drivers/clk/sunxi/clk-a10-codec.c
  28. @@ -0,0 +1,41 @@
  29. +/*
  30. + * Copyright 2013 Emilio López
  31. + *
  32. + * Emilio López <emilio@elopez.com.ar>
  33. + *
  34. + * This program is free software; you can redistribute it and/or modify
  35. + * it under the terms of the GNU General Public License as published by
  36. + * the Free Software Foundation; either version 2 of the License, or
  37. + * (at your option) any later version.
  38. + *
  39. + * This program is distributed in the hope that it will be useful,
  40. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  41. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  42. + * GNU General Public License for more details.
  43. + */
  44. +
  45. +#include <linux/clk-provider.h>
  46. +#include <linux/clkdev.h>
  47. +#include <linux/of.h>
  48. +#include <linux/of_address.h>
  49. +
  50. +#define SUN4I_CODEC_GATE 31
  51. +
  52. +static void __init sun4i_codec_clk_setup(struct device_node *node)
  53. +{
  54. + struct clk *clk;
  55. + const char *clk_name = node->name, *parent_name;
  56. + void __iomem *reg;
  57. +
  58. + of_property_read_string(node, "clock-output-names", &clk_name);
  59. + parent_name = of_clk_get_parent_name(node, 0);
  60. + reg = of_iomap(node, 0);
  61. +
  62. + clk = clk_register_gate(NULL, clk_name, parent_name,
  63. + CLK_SET_RATE_PARENT, reg,
  64. + SUN4I_CODEC_GATE, 0, NULL);
  65. +
  66. + if (!IS_ERR(clk))
  67. + of_clk_add_provider(node, of_clk_src_simple_get, clk);
  68. +}
  69. +CLK_OF_DECLARE(sun4i_codec, "allwinner,sun4i-a10-codec-clk", sun4i_codec_clk_setup);