Re: [PATCH net-next v5 2/2] net: dsa: microchip: add property to select internal RMII reference clock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Nov 24, 2023 at 05:01:48PM +0100, Ante Knezic wrote:
> +static int ksz88x3_config_rmii_clk(struct ksz_device *dev, int cpu_port)
> +{
> +	struct device_node *ports, *port, *cpu_node;
> +	bool rmii_clk_internal;
> +
> +	if (!ksz_is_ksz88x3(dev))
> +		return 0;
> +
> +	cpu_node = NULL;
> +
> +	ports = of_get_child_by_name(dev->dev->of_node, "ports");
> +	if (!ports)
> +		ports = of_get_child_by_name(dev->dev->of_node,
> +					     "ethernet-ports");
> +	if (!ports)
> +		return -ENODEV;
> +
> +	for_each_available_child_of_node(ports, port) {
> +		u32 index;
> +
> +		if (of_property_read_u32(port, "reg", &index) < 0)
> +			return -ENODEV;
> +
> +		if (index == cpu_port) {
> +			cpu_node = port;
> +			break;
> +		}
> +	}
> +
> +	if (!cpu_node)
> +		return -ENODEV;

Too much code. Assuming you have struct dsa_port *cpu_dp, you can access
cpu_dp->dn instead of re-parsing the device tree.

> +
> +	rmii_clk_internal = of_property_read_bool(cpu_node,
> +						  "microchip,rmii-clk-internal");
> +
> +	ksz_cfg(dev, KSZ88X3_REG_FVID_AND_HOST_MODE,
> +		KSZ88X3_PORT3_RMII_CLK_INTERNAL, rmii_clk_internal);
> +
> +	return 0;
> +}

Please wait for 24 hours before reposting, maybe you get more feedback.




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux