clk-pll-v1.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (c) 2014 MediaTek Inc.
  3. * Author: James Liao <jamesjj.liao@mediatek.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #include <linux/io.h>
  15. #include <linux/slab.h>
  16. #include <linux/clkdev.h>
  17. #include "clk-mtk-v1.h"
  18. #include "clk-pll-v1.h"
  19. /*
  20. * clk_pll
  21. */
  22. struct clk *mtk_clk_register_pll(
  23. const char *name,
  24. const char *parent_name,
  25. u32 *base_addr,
  26. u32 *pwr_addr,
  27. u32 en_mask,
  28. u32 flags,
  29. const struct clk_ops *ops)
  30. {
  31. struct mtk_clk_pll *pll;
  32. struct clk_init_data init;
  33. struct clk *clk;
  34. pr_debug("name: %s\n", name);
  35. pll = kzalloc(sizeof(*pll), GFP_KERNEL);
  36. if (!pll)
  37. return ERR_PTR(-ENOMEM);
  38. pll->base_addr = base_addr;
  39. pll->pwr_addr = pwr_addr;
  40. pll->en_mask = en_mask;
  41. pll->flags = flags;
  42. pll->hw.init = &init;
  43. init.name = name;
  44. init.ops = ops;
  45. init.flags = CLK_IGNORE_UNUSED;
  46. init.parent_names = &parent_name;
  47. init.num_parents = 1;
  48. clk = clk_register(NULL, &pll->hw);
  49. if (IS_ERR(clk))
  50. kfree(pll);
  51. return clk;
  52. }