sckc.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * drivers/clk/at91/sckc.c
  3. *
  4. * Copyright (C) 2013 Boris BREZILLON <b.brezillon@overkiz.com>
  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. */
  12. #include <linux/clk-provider.h>
  13. #include <linux/clkdev.h>
  14. #include <linux/of.h>
  15. #include <linux/of_address.h>
  16. #include <linux/io.h>
  17. #include "sckc.h"
  18. static const struct of_device_id sckc_clk_ids[] __initconst = {
  19. /* Slow clock */
  20. {
  21. .compatible = "atmel,at91sam9x5-clk-slow-osc",
  22. .data = of_at91sam9x5_clk_slow_osc_setup,
  23. },
  24. {
  25. .compatible = "atmel,at91sam9x5-clk-slow-rc-osc",
  26. .data = of_at91sam9x5_clk_slow_rc_osc_setup,
  27. },
  28. {
  29. .compatible = "atmel,at91sam9x5-clk-slow",
  30. .data = of_at91sam9x5_clk_slow_setup,
  31. },
  32. { /*sentinel*/ }
  33. };
  34. static void __init of_at91sam9x5_sckc_setup(struct device_node *np)
  35. {
  36. struct device_node *childnp;
  37. void (*clk_setup)(struct device_node *, void __iomem *);
  38. const struct of_device_id *clk_id;
  39. void __iomem *regbase = of_iomap(np, 0);
  40. if (!regbase)
  41. return;
  42. for_each_child_of_node(np, childnp) {
  43. clk_id = of_match_node(sckc_clk_ids, childnp);
  44. if (!clk_id)
  45. continue;
  46. clk_setup = clk_id->data;
  47. clk_setup(childnp, regbase);
  48. }
  49. }
  50. CLK_OF_DECLARE(at91sam9x5_clk_sckc, "atmel,at91sam9x5-sckc",
  51. of_at91sam9x5_sckc_setup);