Re: [PATCH] net/davicom: Add SOC to dm9000 to initialize SROM_BANK clock.

From: Sascha Hauer
Date: Mon May 11 2020 - 02:25:57 EST


On Sun, May 10, 2020 at 07:02:13PM +0800, zhoubo.mr@xxxxxxxxxxx wrote:
> From: To-run-away <zhoubo.mr@xxxxxxxxxxx>
>
> Increase the use of dm9000 to initialize the SROM_BANK clock in the SOC,
> otherwise the chip will not work.

The dm9000 doesn't have anything called SROM in it. You have to
describe the clock input pin of the dm9000 here, not the pin of
your SoC where the clock is coming out.

> The device tree file can be increased like this:
> ethernet@88000000 {
> compatible = "davicom,dm9000";
> ....
> clocks = <&clocks CLK_SROMC>;
> clock-names = "sromc";

This must be documented in
Documentation/devicetree/bindings/net/davicom-dm9000.txt.

> + /* Enable clock if specified */
> + if (!of_property_read_string(dev->of_node, "clock-names", &clk_name)) {
> + struct clk *clk = devm_clk_get(dev, clk_name);
> + if (IS_ERR(clk)) {
> + dev_err(dev, "cannot get clock of %s\n", clk_name);
> + ret = PTR_ERR(clk);
> + goto out;
> + }
> + clk_prepare_enable(clk);
> + dev_info(dev, "enable clock '%s'\n", clk_name);
> + }

There's devm_clk_get_optional() which you should use here.

the "name" passed to devm_clk_get_optional() should match the name of
the clock, you must specify it according to the dm9000 datasheet. It
makes no sense to read the name from the device tree, instead pick a
name which you expect to be there.

Sascha

--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |