dde_linux: enhance clock infrastructure

Issue #5036
This commit is contained in:
Christian Helmuth 2023-06-15 08:52:17 +02:00
parent 394a495b55
commit 4d1e75ce3b
3 changed files with 47 additions and 3 deletions

View File

@ -15,8 +15,21 @@
#include <lx_kit/env.h>
#include <lx_emul/clock.h>
extern "C" int of_device_is_compatible(const struct device_node * node,
const char * compat);
/*
* CONFIG_OF is normally disabled on PC thus of_device_is_compatible() should
* be "static inline" not "extern" (see include/linux/of.h), thus enable this
* function only if not building for x86.
*/
extern "C" int of_device_is_compatible(const struct device_node * node, const char * compat);
static int _of_device_is_compatible(const struct device_node * node, const char * compat)
{
#if defined(__x86_64__) || defined(__i386__)
(void)node; (void)compat;
return 0;
#else
return of_device_is_compatible(node, compat);
#endif
}
struct clk * lx_emul_clock_get(const struct device_node * node,
const char * name)
@ -26,7 +39,7 @@ struct clk * lx_emul_clock_get(const struct device_node * node,
struct clk * ret = nullptr;
env().devices.for_each([&] (Device & d) {
if (!of_device_is_compatible(node, d.compatible()))
if (!_of_device_is_compatible(node, d.compatible()))
return;
ret = name ? d.clock(name) : d.clock(0U);
if (!ret) warning("No clock ", name, " found for device ", d.name());

View File

@ -0,0 +1,26 @@
/*
* \brief Replaces drivers/clk/clk-devres.c
* \author Christian Helmuth
* \date 2023-06-13
*/
/*
* Copyright (C) 2023 Genode Labs GmbH
*
* This file is distributed under the terms of the GNU General Public License
* version 2.
*/
#include <linux/clk.h>
struct clk *devm_clk_get(struct device *dev, const char *id)
{
return clk_get(dev, id);
}
struct clk *devm_clk_get_optional(struct device *dev,const char *id)
{
return devm_clk_get(dev, id);
}

View File

@ -52,3 +52,8 @@ struct of_device_id;
void of_clk_init(const struct of_device_id *matches) { }
const char *__clk_get_name(const struct clk *clk)
{
return "unknown-clk";
}