clk-uniphier-fixed-rate.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (C) 2016 Socionext Inc.
  3. * Author: Masahiro Yamada <[email protected]>
  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 as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #include <linux/clk-provider.h>
  16. #include <linux/device.h>
  17. #include "clk-uniphier.h"
  18. struct clk_hw *uniphier_clk_register_fixed_rate(struct device *dev,
  19. const char *name,
  20. const struct uniphier_clk_fixed_rate_data *data)
  21. {
  22. struct clk_fixed_rate *fixed;
  23. struct clk_init_data init;
  24. int ret;
  25. /* allocate fixed-rate clock */
  26. fixed = devm_kzalloc(dev, sizeof(*fixed), GFP_KERNEL);
  27. if (!fixed)
  28. return ERR_PTR(-ENOMEM);
  29. init.name = name;
  30. init.ops = &clk_fixed_rate_ops;
  31. init.parent_names = NULL;
  32. init.num_parents = 0;
  33. fixed->fixed_rate = data->fixed_rate;
  34. fixed->hw.init = &init;
  35. ret = devm_clk_hw_register(dev, &fixed->hw);
  36. if (ret)
  37. return ERR_PTR(ret);
  38. return &fixed->hw;
  39. }