Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ace85c70 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: clock: Introduce device tree lookups"

parents 769a844e 062bfa43
Loading
Loading
Loading
Loading
+52 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <linux/list.h>
#include <linux/regulator/consumer.h>
#include <linux/mutex.h>
#include <linux/of.h>
#include <trace/events/power.h>
#include <mach/clk-provider.h>
#include "clock.h"
@@ -784,6 +785,57 @@ int msm_clock_register(struct clk_lookup *table, size_t size)
}
EXPORT_SYMBOL(msm_clock_register);

struct of_msm_provider_data {
	struct clk_lookup *table;
	size_t size;
};

static struct clk *of_clk_src_get(struct of_phandle_args *clkspec,
				  void *data)
{
	struct of_msm_provider_data *ofdata = data;
	int n;

	for (n = 0; n < ofdata->size; n++) {
		if (clkspec->args[0] == ofdata->table[n].of_idx)
			return ofdata->table[n].clk;
	}
	return ERR_PTR(-ENOENT);
}

/**
 * of_msm_clock_register() - Register clock tables with clkdev and with the
 *			     clock DT framework
 * @table: Table of clocks
 * @size: Size of @table
 * @np: Device pointer corresponding to the clock-provider device
 *
 * Upon return, clock APIs may be used to control clocks registered using this
 * function.
 */
int of_msm_clock_register(struct device_node *np, struct clk_lookup *table,
				size_t size)
{
	int ret = 0;
	struct of_msm_provider_data *data;

	data = kzalloc(sizeof(*data), GFP_KERNEL);
	if (!data)
		return -ENOMEM;

	data->table = table;
	data->size = size;

	ret = of_clk_add_provider(np, of_clk_src_get, data);
	if (ret) {
		kfree(data);
		return -ENOMEM;
	}

	return msm_clock_register(table, size);
}
EXPORT_SYMBOL(of_msm_clock_register);

/**
 * msm_clock_init() - Register and initialize a clock driver
 * @data: Driver-specific clock initialization data
+5 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <linux/list.h>
#include <linux/clkdev.h>
#include <linux/of.h>
#include <linux/device.h>
#include <linux/spinlock.h>
#include <linux/mutex.h>
#include <linux/regulator/consumer.h>
@@ -196,6 +197,8 @@ void __clk_post_reparent(struct clk *c, struct clk *old, unsigned long *flags);

/* Register clocks with the MSM clock driver */
int msm_clock_register(struct clk_lookup *table, size_t size);
int of_msm_clock_register(struct device_node *np, struct clk_lookup *table,
				size_t size);

extern struct clk dummy_clk;
extern struct clk_ops clk_ops_dummy;
@@ -217,6 +220,8 @@ extern struct clk_ops clk_ops_dummy;
	};

#define CLK_LOOKUP(con, c, dev) { .con_id = con, .clk = &c, .dev_id = dev }
#define CLK_LOOKUP_OF(con, _c, dev) { .con_id = con, .clk = &(&_c)->c, \
				      .dev_id = dev, .of_idx = clk_##_c }

static inline bool is_better_rate(unsigned long req, unsigned long best,
				  unsigned long new)