[RFC 2/3] serial: mxc: Enable getting and enabling clocks with CCF Composite

Peng Fan (OSS) peng.fan at oss.nxp.com
Sun May 1 11:48:05 CEST 2022



On 2022/5/1 0:14, Adam Ford wrote:
> Certain platforms have the UART clocks exposed through the CCF.
> When they are, it's possible to enable and query the clock(s)
> for a given UART. Add support getting, enabling, and querying
> the clocks.
> 
> Signed-off-by: Adam Ford <aford173 at gmail.com>
> 
> diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c
> index e4970a169b..c68040ba74 100644
> --- a/drivers/serial/serial_mxc.c
> +++ b/drivers/serial/serial_mxc.c
> @@ -10,6 +10,7 @@
>   #include <asm/arch/imx-regs.h>
>   #include <asm/arch/clock.h>
>   #include <asm/global_data.h>
> +#include <clk.h>
>   #include <dm/platform_data/serial_mxc.h>
>   #include <serial.h>
>   #include <linux/compiler.h>
> @@ -266,8 +267,13 @@ __weak struct serial_device *default_serial_console(void)
>   int mxc_serial_setbrg(struct udevice *dev, int baudrate)
>   {
>   	struct mxc_serial_plat *plat = dev_get_plat(dev);
> -	u32 clk = imx_get_uartclk();
> +	u32 clk;
>   
> +#if CONFIG_IS_ENABLED(CLK_COMPOSITE_CCF)

CONFIG_IS_ENABLED(CLK) should be fine.

> +	 clk = clk_get_rate(&plat->ipg_clk);
> +#else
> +	clk = imx_get_uartclk;

"()" should not be dropped.

> +#endif
>   	_mxc_serial_setbrg(plat->reg, clk, baudrate, plat->use_dte);
>   
>   	return 0;
> @@ -277,6 +283,22 @@ static int mxc_serial_probe(struct udevice *dev)
>   {
>   	struct mxc_serial_plat *plat = dev_get_plat(dev);
>   
> +#if CONFIG_IS_ENABLED(CLK_COMPOSITE_CCF)

Ditto

> +	int ret = 0;
> +
> +	ret = clk_enable(&plat->per_clk);
> +	if (ret) {
> +		printf("Failed to enable per_clk\n");
> +		return ret;
> +	}
> +
> +	ret = clk_enable(&plat->per_clk);

ipg_clk?

> +	if (ret) {
> +		printf("Failed to enable ipg_clk\n");
> +		return ret;
> +	}
> +
> +#endif
>   	_mxc_serial_init(plat->reg, plat->use_dte);
>   
>   	return 0;
> @@ -339,6 +361,21 @@ static int mxc_serial_of_to_plat(struct udevice *dev)
>   
>   	plat->use_dte = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
>   					"fsl,dte-mode");
> +#if CONFIG_IS_ENABLED(CLK_COMPOSITE_CCF)
> +	int ret = 0;
> +
> +	ret = clk_get_by_name(dev, "per", &plat->per_clk);
> +	if (ret) {
> +		printf("Failed to get per_clk\n");
> +		return ret;
> +	}
> +
> +	ret = clk_get_by_name(dev, "ipg", &plat->ipg_clk);
> +	if (ret) {
> +		printf("Failed to get per_clk\n");
> +		return ret;
> +	}
> +#endif

Regards,
Peng.

>   	return 0;
>   }
>   
> diff --git a/include/dm/platform_data/serial_mxc.h b/include/dm/platform_data/serial_mxc.h
> index cc59eeb1dd..9a8c8498bf 100644
> --- a/include/dm/platform_data/serial_mxc.h
> +++ b/include/dm/platform_data/serial_mxc.h
> @@ -10,6 +10,8 @@
>   struct mxc_serial_plat {
>   	struct mxc_uart *reg;  /* address of registers in physical memory */
>   	bool use_dte;
> +	struct clk per_clk;
> +	struct clk ipg_clk;
>   };
>   
>   #endif
> 


More information about the U-Boot mailing list