Ejemplo n.º 1
0
struct clk *kona_clk_setup(struct ccu_data *ccu, const char *name,
			enum bcm_clk_type type, void *data)
{
	struct kona_clk *bcm_clk;
	struct clk_init_data *init_data;
	struct clk *clk = NULL;

	bcm_clk = kzalloc(sizeof(*bcm_clk), GFP_KERNEL);
	if (!bcm_clk) {
		pr_err("%s: failed to allocate bcm_clk for %s\n", __func__,
			name);
		return NULL;
	}
	bcm_clk->ccu = ccu;
	bcm_clk->name = name;

	init_data = &bcm_clk->init_data;
	init_data->name = name;
	switch (type) {
	case bcm_clk_peri:
		if (peri_clk_setup(ccu, data, init_data))
			goto out_free;
		break;
	default:
		data = NULL;
		break;
	}
	bcm_clk->type = type;
	bcm_clk->data = data;

	/* Make sure everything makes sense before we set it up */
	if (!kona_clk_valid(bcm_clk)) {
		pr_err("%s: clock data invalid for %s\n", __func__, name);
		goto out_teardown;
	}

	bcm_clk->hw.init = init_data;
	clk = clk_register(NULL, &bcm_clk->hw);
	if (IS_ERR(clk)) {
		pr_err("%s: error registering clock %s (%ld)\n", __func__,
				name, PTR_ERR(clk));
		goto out_teardown;
	}
	BUG_ON(!clk);

	return clk;
out_teardown:
	bcm_clk_teardown(bcm_clk);
out_free:
	kfree(bcm_clk);

	return NULL;
}
static int kona_clk_setup(struct kona_clk *bcm_clk)
{
	int ret;
	struct clk_init_data *init_data = &bcm_clk->init_data;

	switch (bcm_clk->type) {
	case bcm_clk_peri:
		ret = peri_clk_setup(bcm_clk->u.data, init_data);
		if (ret)
			return ret;
		break;
	default:
		pr_err("%s: clock type %d invalid for %s\n", __func__,
			(int)bcm_clk->type, init_data->name);
		return -EINVAL;
	}

	/* Make sure everything makes sense before we set it up */
	if (!kona_clk_valid(bcm_clk)) {
		pr_err("%s: clock data invalid for %s\n", __func__,
			init_data->name);
		ret = -EINVAL;
		goto out_teardown;
	}

	bcm_clk->hw.init = init_data;
	ret = clk_hw_register(NULL, &bcm_clk->hw);
	if (ret) {
		pr_err("%s: error registering clock %s (%d)\n", __func__,
			init_data->name, ret);
		goto out_teardown;
	}

	return 0;
out_teardown:
	bcm_clk_teardown(bcm_clk);

	return ret;
}
Ejemplo n.º 3
0
struct clk *kona_clk_setup(struct kona_clk *bcm_clk)
{
	struct clk_init_data *init_data = &bcm_clk->init_data;
	struct clk *clk = NULL;

	switch (bcm_clk->type) {
	case bcm_clk_peri:
		if (peri_clk_setup(bcm_clk->u.data, init_data))
			return NULL;
		break;
	default:
		pr_err("%s: clock type %d invalid for %s\n", __func__,
			(int)bcm_clk->type, init_data->name);
		return NULL;
	}

	/* Make sure everything makes sense before we set it up */
	if (!kona_clk_valid(bcm_clk)) {
		pr_err("%s: clock data invalid for %s\n", __func__,
			init_data->name);
		goto out_teardown;
	}

	bcm_clk->hw.init = init_data;
	clk = clk_register(NULL, &bcm_clk->hw);
	if (IS_ERR(clk)) {
		pr_err("%s: error registering clock %s (%ld)\n", __func__,
			init_data->name, PTR_ERR(clk));
		goto out_teardown;
	}
	BUG_ON(!clk);

	return clk;
out_teardown:
	bcm_clk_teardown(bcm_clk);

	return NULL;
}