mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-24 21:54:01 +00:00
clk: Rename clk_get_by_driver_info()
This is actually a misnomer now, since the phandle info may contain a driver_info index or a udevice index. Rename it to use the word 'phandle', which seems more accurate. Add a comment while we are here. Also add a test for this function. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
4ee0cc89db
commit
f0ab8f9fbe
7 changed files with 54 additions and 11 deletions
|
@ -36,8 +36,8 @@ struct clk *dev_get_clk_ptr(struct udevice *dev)
|
|||
}
|
||||
|
||||
#if CONFIG_IS_ENABLED(OF_PLATDATA)
|
||||
int clk_get_by_driver_info(struct udevice *dev, struct phandle_1_arg *cells,
|
||||
struct clk *clk)
|
||||
int clk_get_by_phandle(struct udevice *dev, const struct phandle_1_arg *cells,
|
||||
struct clk *clk)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -413,6 +413,7 @@ int clk_get_by_name(struct udevice *dev, const char *name, struct clk *clk)
|
|||
|
||||
return clk_get_by_index(dev, index, clk);
|
||||
}
|
||||
#endif /* OF_REAL */
|
||||
|
||||
int clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk)
|
||||
{
|
||||
|
@ -465,8 +466,6 @@ int clk_release_all(struct clk *clk, int count)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#endif /* OF_REAL */
|
||||
|
||||
int clk_request(struct udevice *dev, struct clk *clk)
|
||||
{
|
||||
const struct clk_ops *ops;
|
||||
|
|
|
@ -433,7 +433,7 @@ static int ftsdc010_mmc_probe(struct udevice *dev)
|
|||
chip->priv = dev;
|
||||
chip->dev_index = 1;
|
||||
memcpy(priv->minmax, dtplat->clock_freq_min_max, sizeof(priv->minmax));
|
||||
ret = clk_get_by_driver_info(dev, dtplat->clocks, &priv->clk);
|
||||
ret = clk_get_by_phandle(dev, dtplat->clocks, &priv->clk);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
#endif
|
||||
|
|
|
@ -123,7 +123,7 @@ static int rockchip_dwmmc_probe(struct udevice *dev)
|
|||
priv->minmax[0] = 400000; /* 400 kHz */
|
||||
priv->minmax[1] = dtplat->max_frequency;
|
||||
|
||||
ret = clk_get_by_driver_info(dev, dtplat->clocks, &priv->clk);
|
||||
ret = clk_get_by_phandle(dev, dtplat->clocks, &priv->clk);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
#else
|
||||
|
|
|
@ -3107,7 +3107,7 @@ static int rk3399_dmc_init(struct udevice *dev)
|
|||
priv->cic, priv->pmugrf, priv->pmusgrf, priv->pmucru, priv->pmu);
|
||||
|
||||
#if CONFIG_IS_ENABLED(OF_PLATDATA)
|
||||
ret = clk_get_by_driver_info(dev, dtplat->clocks, &priv->ddr_clk);
|
||||
ret = clk_get_by_phandle(dev, dtplat->clocks, &priv->ddr_clk);
|
||||
#else
|
||||
ret = clk_get_by_index(dev, 0, &priv->ddr_clk);
|
||||
#endif
|
||||
|
|
|
@ -183,7 +183,7 @@ static int conv_of_plat(struct udevice *dev)
|
|||
|
||||
plat->base = dtplat->reg[0];
|
||||
plat->frequency = 20000000;
|
||||
ret = clk_get_by_driver_info(dev, dtplat->clocks, &priv->clk);
|
||||
ret = clk_get_by_phandle(dev, dtplat->clocks, &priv->clk);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -89,11 +89,36 @@ struct clk_bulk {
|
|||
|
||||
#if CONFIG_IS_ENABLED(OF_CONTROL) && CONFIG_IS_ENABLED(CLK)
|
||||
struct phandle_1_arg;
|
||||
int clk_get_by_driver_info(struct udevice *dev,
|
||||
struct phandle_1_arg *cells, struct clk *clk);
|
||||
/**
|
||||
* clk_get_by_phandle() - Get a clock by its phandle information (of-platadata)
|
||||
*
|
||||
* This function is used when of-platdata is enabled.
|
||||
*
|
||||
* This looks up a clock using the phandle info. With dtoc, each phandle in the
|
||||
* 'clocks' property is transformed into an idx representing the device. For
|
||||
* example:
|
||||
*
|
||||
* clocks = <&dpll_mpu_ck 23>;
|
||||
*
|
||||
* might result in:
|
||||
*
|
||||
* .clocks = {1, {23}},},
|
||||
*
|
||||
* indicating that the clock is udevice idx 1 in dt-plat.c with an argument of
|
||||
* 23. This function can return a valid clock given the above information. In
|
||||
* this example it would return a clock containing the 'dpll_mpu_ck' device and
|
||||
* the clock ID 23.
|
||||
*
|
||||
* @dev: Device containing the phandle
|
||||
* @cells: Phandle info
|
||||
* @clock: A pointer to a clock struct to initialise
|
||||
* @return 0 if OK, or a negative error code.
|
||||
*/
|
||||
int clk_get_by_phandle(struct udevice *dev, const struct phandle_1_arg *cells,
|
||||
struct clk *clk);
|
||||
|
||||
/**
|
||||
* clk_get_by_index - Get/request a clock by integer index.
|
||||
* clk_get_by_index() - Get/request a clock by integer index.
|
||||
*
|
||||
* This looks up and requests a clock. The index is relative to the client
|
||||
* device; each device is assumed to have n clocks associated with it somehow,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include <common.h>
|
||||
#include <clk.h>
|
||||
#include <dm.h>
|
||||
#include <dt-structs.h>
|
||||
#include <dm/test.h>
|
||||
|
@ -222,3 +223,21 @@ static int dm_test_of_plat_parent(struct unit_test_state *uts)
|
|||
}
|
||||
DM_TEST(dm_test_of_plat_parent, UT_TESTF_SCAN_PDATA);
|
||||
#endif
|
||||
|
||||
/* Test clocks with of-platdata */
|
||||
static int dm_test_of_plat_clk(struct unit_test_state *uts)
|
||||
{
|
||||
struct dtd_sandbox_clk_test *plat;
|
||||
struct udevice *dev;
|
||||
struct clk clk;
|
||||
|
||||
ut_assertok(uclass_first_device_err(UCLASS_MISC, &dev));
|
||||
ut_asserteq_str("sandbox_clk_test", dev->name);
|
||||
plat = dev_get_plat(dev);
|
||||
|
||||
ut_assertok(clk_get_by_phandle(dev, &plat->clocks[0], &clk));
|
||||
ut_asserteq_str("sandbox_fixed_clock", clk.dev->name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
DM_TEST(dm_test_of_plat_clk, UT_TESTF_SCAN_PDATA);
|
||||
|
|
Loading…
Reference in a new issue