162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (C) 2016 Socionext Inc.
462306a36Sopenharmony_ci *   Author: Masahiro Yamada <yamada.masahiro@socionext.com>
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#include <linux/clk-provider.h>
862306a36Sopenharmony_ci#include <linux/device.h>
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#include "clk-uniphier.h"
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_cistruct clk_hw *uniphier_clk_register_fixed_rate(struct device *dev,
1362306a36Sopenharmony_ci						const char *name,
1462306a36Sopenharmony_ci				const struct uniphier_clk_fixed_rate_data *data)
1562306a36Sopenharmony_ci{
1662306a36Sopenharmony_ci	struct clk_fixed_rate *fixed;
1762306a36Sopenharmony_ci	struct clk_init_data init;
1862306a36Sopenharmony_ci	int ret;
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci	/* allocate fixed-rate clock */
2162306a36Sopenharmony_ci	fixed = devm_kzalloc(dev, sizeof(*fixed), GFP_KERNEL);
2262306a36Sopenharmony_ci	if (!fixed)
2362306a36Sopenharmony_ci		return ERR_PTR(-ENOMEM);
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci	init.name = name;
2662306a36Sopenharmony_ci	init.ops = &clk_fixed_rate_ops;
2762306a36Sopenharmony_ci	init.flags = 0;
2862306a36Sopenharmony_ci	init.parent_names = NULL;
2962306a36Sopenharmony_ci	init.num_parents = 0;
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci	fixed->fixed_rate = data->fixed_rate;
3262306a36Sopenharmony_ci	fixed->hw.init = &init;
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci	ret = devm_clk_hw_register(dev, &fixed->hw);
3562306a36Sopenharmony_ci	if (ret)
3662306a36Sopenharmony_ci		return ERR_PTR(ret);
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci	return &fixed->hw;
3962306a36Sopenharmony_ci}
40