clk-a10-codec.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright 2013 Emilio López
  3. *
  4. * Emilio López <emilio@elopez.com.ar>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. */
  16. #include <linux/clk-provider.h>
  17. #include <linux/of.h>
  18. #include <linux/of_address.h>
  19. #define SUN4I_CODEC_GATE 31
  20. static void __init sun4i_codec_clk_setup(struct device_node *node)
  21. {
  22. struct clk *clk;
  23. const char *clk_name = node->name, *parent_name;
  24. void __iomem *reg;
  25. reg = of_io_request_and_map(node, 0, of_node_full_name(node));
  26. if (IS_ERR(reg))
  27. return;
  28. of_property_read_string(node, "clock-output-names", &clk_name);
  29. parent_name = of_clk_get_parent_name(node, 0);
  30. clk = clk_register_gate(NULL, clk_name, parent_name,
  31. CLK_SET_RATE_PARENT, reg,
  32. SUN4I_CODEC_GATE, 0, NULL);
  33. if (!IS_ERR(clk))
  34. of_clk_add_provider(node, of_clk_src_simple_get, clk);
  35. }
  36. CLK_OF_DECLARE(sun4i_codec, "allwinner,sun4i-a10-codec-clk",
  37. sun4i_codec_clk_setup);