aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2023-02-12 15:25:32 -0500
committerTom Rini <trini@konsulko.com>2023-02-12 15:25:32 -0500
commit9345f165eb52888a61f3a67546f7834dfb9238b2 (patch)
treec92fa4df033f811914aa92ac306baba36ecd9bc6
parent386e77cda8b690dbf5b2b7c828b3313205e5078c (diff)
parent5a675abfe7c3f12b475cc0a6c9074a9fbe0b6bb6 (diff)
downloadu-boot-9345f165eb52888a61f3a67546f7834dfb9238b2.zip
u-boot-9345f165eb52888a61f3a67546f7834dfb9238b2.tar.gz
u-boot-9345f165eb52888a61f3a67546f7834dfb9238b2.tar.bz2
Merge tag 'clk-2023.04-rc1' of https://source.denx.de/u-boot/custodians/u-boot-clk
Clock changes for 2023.04-rc1 This contains various fixes and small features. I've included a reset patch as well since it was in the same series as a clock patch.
-rw-r--r--cmd/clk.c15
-rw-r--r--drivers/clk/clk-uclass.c12
-rw-r--r--drivers/clk/imx/clk-imx8mn.c22
-rw-r--r--drivers/clk/nuvoton/clk_npcm7xx.c2
-rw-r--r--drivers/reset/reset-uclass.c12
-rw-r--r--include/clk.h4
-rw-r--r--include/reset.h3
-rw-r--r--test/dm/clk.c5
-rw-r--r--test/dm/reset.c3
9 files changed, 41 insertions, 37 deletions
diff --git a/cmd/clk.c b/cmd/clk.c
index a483fd8..ff7c764 100644
--- a/cmd/clk.c
+++ b/cmd/clk.c
@@ -22,7 +22,7 @@ static void show_clks(struct udevice *dev, int depth, int last_flag)
u32 rate;
clkp = dev_get_clk_ptr(dev);
- if (device_get_uclass_id(dev) == UCLASS_CLK && clkp) {
+ if (clkp) {
parent = clk_get_parent(clkp);
if (!IS_ERR(parent) && depth == -1)
return;
@@ -49,10 +49,11 @@ static void show_clks(struct udevice *dev, int depth, int last_flag)
printf("%s\n", dev->name);
}
- list_for_each_entry(child, &dev->child_head, sibling_node) {
+ device_foreach_child_probe(child, dev) {
+ if (device_get_uclass_id(child) != UCLASS_CLK)
+ continue;
if (child == dev)
continue;
-
is_last = list_is_last(&child->sibling_node, &dev->child_head);
show_clks(child, depth, (last_flag << 1) | is_last);
}
@@ -61,17 +62,11 @@ static void show_clks(struct udevice *dev, int depth, int last_flag)
int __weak soc_clk_dump(void)
{
struct udevice *dev;
- struct uclass *uc;
- int ret;
-
- ret = uclass_get(UCLASS_CLK, &uc);
- if (ret)
- return ret;
printf(" Rate Usecnt Name\n");
printf("------------------------------------------\n");
- uclass_foreach_dev(dev, uc)
+ uclass_foreach_dev_probe(UCLASS_CLK, dev)
show_clks(dev, -1, 0);
return 0;
diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 2f96355..dc3e9d6 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -399,16 +399,18 @@ int clk_get_by_name(struct udevice *dev, const char *name, struct clk *clk)
int clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk)
{
- int index;
+ int index = 0;
debug("%s(node=%p, name=%s, clk=%p)\n", __func__,
ofnode_get_name(node), name, clk);
clk->dev = NULL;
- index = ofnode_stringlist_search(node, "clock-names", name);
- if (index < 0) {
- debug("fdt_stringlist_search() failed: %d\n", index);
- return index;
+ if (name) {
+ index = ofnode_stringlist_search(node, "clock-names", name);
+ if (index < 0) {
+ debug("fdt_stringlist_search() failed: %d\n", index);
+ return index;
+ }
}
return clk_get_by_index_nodev(node, index, clk);
diff --git a/drivers/clk/imx/clk-imx8mn.c b/drivers/clk/imx/clk-imx8mn.c
index 35e0d93..692823e 100644
--- a/drivers/clk/imx/clk-imx8mn.c
+++ b/drivers/clk/imx/clk-imx8mn.c
@@ -28,20 +28,20 @@ static const char *imx8mn_a53_sels[] = {"clock-osc-24m", "arm_pll_out", "sys_pll
"sys_pll1_800m", "sys_pll1_400m", "audio_pll1_out", "sys_pll3_out", };
static const char *imx8mn_ahb_sels[] = {"clock-osc-24m", "sys_pll1_133m", "sys_pll1_800m", "sys_pll1_400m",
- "sys_pll2_125m", "sys_pll3_out", "audio_pll1_out", "video_pll1_out", };
+ "sys_pll2_125m", "sys_pll3_out", "audio_pll1_out", "video_pll_out", };
static const char *imx8mn_enet_axi_sels[] = {"clock-osc-24m", "sys_pll1_266m", "sys_pll1_800m", "sys_pll2_250m",
- "sys_pll2_200m", "audio_pll1_out", "video_pll1_out", "sys_pll3_out", };
+ "sys_pll2_200m", "audio_pll1_out", "video_pll_out", "sys_pll3_out", };
#ifndef CONFIG_SPL_BUILD
static const char *imx8mn_enet_ref_sels[] = {"clock-osc-24m", "sys_pll2_125m", "sys_pll2_50m", "sys_pll2_100m",
- "sys_pll1_160m", "audio_pll1_out", "video_pll1_out", "clk_ext4", };
+ "sys_pll1_160m", "audio_pll1_out", "video_pll_out", "clk_ext4", };
static const char *imx8mn_enet_timer_sels[] = {"clock-osc-24m", "sys_pll2_100m", "audio_pll1_out", "clk_ext1", "clk_ext2",
- "clk_ext3", "clk_ext4", "video_pll1_out", };
+ "clk_ext3", "clk_ext4", "video_pll_out", };
static const char *imx8mn_enet_phy_sels[] = {"clock-osc-24m", "sys_pll2_50m", "sys_pll2_125m", "sys_pll2_200m",
- "sys_pll2_500m", "video_pll1_out", "audio_pll2_out", };
+ "sys_pll2_500m", "audio_pll1_out", "video_pll_out", "audio_pll2_out", };
#endif
static const char *imx8mn_nand_usdhc_sels[] = {"clock-osc-24m", "sys_pll1_266m", "sys_pll1_800m", "sys_pll2_200m",
@@ -72,18 +72,18 @@ static const char *imx8mn_ecspi3_sels[] = {"osc_24m", "sys_pll2_200m", "sys_pll1
#endif
static const char *imx8mn_i2c1_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m", "sys_pll3_out", "audio_pll1_out",
- "video_pll1_out", "audio_pll2_out", "sys_pll1_133m", };
+ "video_pll_out", "audio_pll2_out", "sys_pll1_133m", };
static const char *imx8mn_i2c2_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m", "sys_pll3_out", "audio_pll1_out",
- "video_pll1_out", "audio_pll2_out", "sys_pll1_133m", };
+ "video_pll_out", "audio_pll2_out", "sys_pll1_133m", };
static const char *imx8mn_i2c3_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m", "sys_pll3_out", "audio_pll1_out",
- "video_pll1_out", "audio_pll2_out", "sys_pll1_133m", };
+ "video_pll_out", "audio_pll2_out", "sys_pll1_133m", };
static const char *imx8mn_i2c4_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m", "sys_pll3_out", "audio_pll1_out",
- "video_pll1_out", "audio_pll2_out", "sys_pll1_133m", };
+ "video_pll_out", "audio_pll2_out", "sys_pll1_133m", };
-static const char *imx8mn_wdog_sels[] = {"clock-osc-24m", "sys_pll1_133m", "sys_pll1_160m", "vpu_pll_out",
+static const char *imx8mn_wdog_sels[] = {"clock-osc-24m", "sys_pll1_133m", "sys_pll1_160m", "m7_alt_pll",
"sys_pll2_125m", "sys_pll3_out", "sys_pll1_80m", "sys_pll2_166m", };
static const char *imx8mn_usdhc3_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll1_800m", "sys_pll2_500m",
@@ -94,7 +94,7 @@ static const char *imx8mn_qspi_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_
static const char * const imx8mn_nand_sels[] = {"osc_24m", "sys_pll2_500m", "audio_pll1_out",
"sys_pll1_400m", "audio_pll2_out", "sys_pll3_out",
- "sys_pll2_250m", "video_pll1_out", };
+ "sys_pll2_250m", "video_pll_out", };
static const char * const imx8mn_usb_core_sels[] = {"clock-osc-24m", "sys_pll1_100m", "sys_pll1_40m",
"sys_pll2_100m", "sys_pll2_200m", "clk_ext2",
diff --git a/drivers/clk/nuvoton/clk_npcm7xx.c b/drivers/clk/nuvoton/clk_npcm7xx.c
index a12aaa2..b23dd37 100644
--- a/drivers/clk/nuvoton/clk_npcm7xx.c
+++ b/drivers/clk/nuvoton/clk_npcm7xx.c
@@ -25,7 +25,7 @@ static const struct parent_data apb_parent[] = {{NPCM7XX_CLK_AHB, 0}};
static struct npcm_clk_pll npcm7xx_clk_plls[] = {
{NPCM7XX_CLK_PLL0, NPCM7XX_CLK_REFCLK, PLLCON0, 0},
- {NPCM7XX_CLK_PLL1, NPCM7XX_CLK_REFCLK, PLLCON1, 0},
+ {NPCM7XX_CLK_PLL1, NPCM7XX_CLK_REFCLK, PLLCON1, POST_DIV2},
{NPCM7XX_CLK_PLL2, NPCM7XX_CLK_REFCLK, PLLCON2, 0},
{NPCM7XX_CLK_PLL2DIV2, NPCM7XX_CLK_REFCLK, PLLCON2, POST_DIV2}
};
diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c
index bcef460..b972faf 100644
--- a/drivers/reset/reset-uclass.c
+++ b/drivers/reset/reset-uclass.c
@@ -147,16 +147,18 @@ int reset_get_bulk(struct udevice *dev, struct reset_ctl_bulk *bulk)
int reset_get_by_name(struct udevice *dev, const char *name,
struct reset_ctl *reset_ctl)
{
- int index;
+ int index = 0;
debug("%s(dev=%p, name=%s, reset_ctl=%p)\n", __func__, dev, name,
reset_ctl);
reset_ctl->dev = NULL;
- index = dev_read_stringlist_search(dev, "reset-names", name);
- if (index < 0) {
- debug("fdt_stringlist_search() failed: %d\n", index);
- return index;
+ if (name) {
+ index = dev_read_stringlist_search(dev, "reset-names", name);
+ if (index < 0) {
+ debug("fdt_stringlist_search() failed: %d\n", index);
+ return index;
+ }
}
return reset_get_by_index(dev, index, reset_ctl);
diff --git a/include/clk.h b/include/clk.h
index 138766b..d912852 100644
--- a/include/clk.h
+++ b/include/clk.h
@@ -167,7 +167,7 @@ int clk_get_bulk(struct udevice *dev, struct clk_bulk *bulk);
* clk_get_by_name() - Get/request a clock by name.
* @dev: The client device.
* @name: The name of the clock to request, within the client's list of
- * clocks.
+ * clocks, or NULL to request the first clock in the list.
* @clk: A pointer to a clock struct to initialize.
*
* This looks up and requests a clock. The name is relative to the client
@@ -184,7 +184,7 @@ int clk_get_by_name(struct udevice *dev, const char *name, struct clk *clk);
* clk_get_by_name_nodev - Get/request a clock by name without a device.
* @node: The client ofnode.
* @name: The name of the clock to request, within the client's list of
- * clocks.
+ * clocks, or NULL to request the first clock in the list.
* @clk: A pointer to a clock struct to initialize.
*
* Return: 0 if OK, or a negative error code.
diff --git a/include/reset.h b/include/reset.h
index 965f02e..036a786 100644
--- a/include/reset.h
+++ b/include/reset.h
@@ -238,7 +238,8 @@ int reset_get_bulk(struct udevice *dev, struct reset_ctl_bulk *bulk);
*
* @dev: The client device.
* @name: The name of the reset signal to request, within the client's
- * list of reset signals.
+ * list of reset signals, or NULL to request the first reset
+ * signal in the list.
* @reset_ctl: A pointer to a reset control struct to initialize.
* Return: 0 if OK, or a negative error code.
*/
diff --git a/test/dm/clk.c b/test/dm/clk.c
index 21997ed..f48de05 100644
--- a/test/dm/clk.c
+++ b/test/dm/clk.c
@@ -26,6 +26,11 @@ static int dm_test_clk_base(struct unit_test_state *uts)
ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "clk-test", &dev));
/* Get the same clk port in 2 different ways and compare */
+ ut_assertok(clk_get_by_index(dev, 0, &clk_method1));
+ ut_assertok(clk_get_by_name(dev, NULL, &clk_method2));
+ ut_asserteq(clk_is_match(&clk_method1, &clk_method2), true);
+ ut_asserteq(clk_method1.id, clk_method2.id);
+
ut_assertok(clk_get_by_index(dev, 1, &clk_method1));
ut_assertok(clk_get_by_index_nodev(dev_ofnode(dev), 1, &clk_method2));
ut_asserteq(clk_is_match(&clk_method1, &clk_method2), true);
diff --git a/test/dm/reset.c b/test/dm/reset.c
index 9c00452..e2d6f45 100644
--- a/test/dm/reset.c
+++ b/test/dm/reset.c
@@ -35,8 +35,7 @@ static int dm_test_reset_base(struct unit_test_state *uts)
/* Get the same reset port in 2 different ways and compare */
ut_assertok(reset_get_by_index(dev, 0, &reset_method1));
- ut_assertok(reset_get_by_index_nodev(dev_ofnode(dev), 0,
- &reset_method1_1));
+ ut_assertok(reset_get_by_name(dev, NULL, &reset_method1_1));
ut_assertok(reset_get_by_index(dev, 1, &reset_method2));
ut_assertok(reset_get_by_index_nodev(dev_ofnode(dev), 1,
&reset_method2_1));