clk-uniphier-fixed-rate.c 871 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright (C) 2016 Socionext Inc.
  4. * Author: Masahiro Yamada <[email protected]>
  5. */
  6. #include <linux/clk-provider.h>
  7. #include <linux/device.h>
  8. #include "clk-uniphier.h"
  9. struct clk_hw *uniphier_clk_register_fixed_rate(struct device *dev,
  10. const char *name,
  11. const struct uniphier_clk_fixed_rate_data *data)
  12. {
  13. struct clk_fixed_rate *fixed;
  14. struct clk_init_data init;
  15. int ret;
  16. /* allocate fixed-rate clock */
  17. fixed = devm_kzalloc(dev, sizeof(*fixed), GFP_KERNEL);
  18. if (!fixed)
  19. return ERR_PTR(-ENOMEM);
  20. init.name = name;
  21. init.ops = &clk_fixed_rate_ops;
  22. init.flags = 0;
  23. init.parent_names = NULL;
  24. init.num_parents = 0;
  25. fixed->fixed_rate = data->fixed_rate;
  26. fixed->hw.init = &init;
  27. ret = devm_clk_hw_register(dev, &fixed->hw);
  28. if (ret)
  29. return ERR_PTR(ret);
  30. return &fixed->hw;
  31. }