[RFC PATCH] imx: skip unused compatible strings in drivers

Soeren Moch smoch at web.de
Tue May 26 13:12:46 CEST 2020


On 25.05.20 22:24, Anatolij Gustschin wrote:
> Converting to DM increases binary size and breaks building some
> boards (i.e. tbs2910, gcc 9.2). The approach to address this issue
> via cutting off unused properties/nodes in device tree via custom
> u-boot.dtsi was not welcome, even if the affected boards do not
> pass the built-in device tree to the kernel.
But there is CONFIG_OF_REMOVE_PROPS="dmas dma-names interrupt-parent
interrupts interrupts-extended interrupt-names interrupt-map
interrupt-map-mask" in tbs2910_defconfig. So removing properties is
already done via this config option. Removing nodes is not implemented
(yet? AFAIK). But would be welcome if someone implements this in a
similar way, I think.

Soeren
> Try to drop not
> required compatible strings in drivers when building for different
> iMX variants. This saves a few bytes when building for i.MX6, with
> current buildman default GCC 9.2:
>
>     all -843.0 bss +8.0 data -40.0 rodata -547.0 text -264.0
>
> Signed-off-by: Anatolij Gustschin <agust at denx.de>
> Cc: Heiko Schocher <hs at denx.de>
> Cc: Peng Fan <peng.fan at nxp.com>
> Cc: Joe Hershberger <joe.hershberger at ni.com>
> Cc: Lukasz Majewski <lukma at denx.de>
> Cc: Marek Vasut <marex at denx.de>
> Cc: Stefano Babic <sbabic at denx.de>
> ---
>  drivers/i2c/mxc_i2c.c              |  3 +++
>  drivers/mmc/fsl_esdhc_imx.c        | 18 ++++++++++++++++++
>  drivers/net/fec_mxc.c              | 16 ++++++++++++++++
>  drivers/pinctrl/nxp/pinctrl-imx6.c | 14 ++++++++++++++
>  drivers/serial/serial_mxc.c        | 10 ++++++++++
>  5 files changed, 61 insertions(+)
>
> diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c
> index 3b0d27e6cd..abef9d888e 100644
> --- a/drivers/i2c/mxc_i2c.c
> +++ b/drivers/i2c/mxc_i2c.c
> @@ -1058,7 +1058,10 @@ static const struct dm_i2c_ops mxc_i2c_ops = {
>
>  static const struct udevice_id mxc_i2c_ids[] = {
>  	{ .compatible = "fsl,imx21-i2c", },
> +#if defined(CONFIG_VF610) || defined(CONFIG_FSL_LSCH2) || \
> +    defined(CONFIG_FSL_LSCH3) || defined(CONFIG_ARCH_LS1021A)
>  	{ .compatible = "fsl,vf610-i2c", .data = I2C_QUIRK_FLAG, },
> +#endif
>  	{}
>  };
>
> diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
> index 588d6a9d76..6943e4867e 100644
> --- a/drivers/mmc/fsl_esdhc_imx.c
> +++ b/drivers/mmc/fsl_esdhc_imx.c
> @@ -1601,31 +1601,49 @@ static const struct dm_mmc_ops fsl_esdhc_ops = {
>  };
>  #endif
>
> +#if defined(CONFIG_ARCH_MX7)
>  static struct esdhc_soc_data usdhc_imx7d_data = {
>  	.flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING
>  			| ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200
>  			| ESDHC_FLAG_HS400,
>  };
> +#endif
>
> +#if defined(CONFIG_ARCH_IMX8) || defined(CONFIG_ARCH_IMX8M)
>  static struct esdhc_soc_data usdhc_imx8qm_data = {
>  	.flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING |
>  		ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200 |
>  		ESDHC_FLAG_HS400 | ESDHC_FLAG_HS400_ES,
>  };
> +#endif
>
>  static const struct udevice_id fsl_esdhc_ids[] = {
> +#ifdef CONFIG_ARCH_MX5
>  	{ .compatible = "fsl,imx53-esdhc", },
> +#endif
> +#ifdef CONFIG_ARCH_MX6
>  	{ .compatible = "fsl,imx6ul-usdhc", },
>  	{ .compatible = "fsl,imx6sx-usdhc", },
>  	{ .compatible = "fsl,imx6sl-usdhc", },
>  	{ .compatible = "fsl,imx6q-usdhc", },
> +#endif
> +#ifdef CONFIG_ARCH_MX7
>  	{ .compatible = "fsl,imx7d-usdhc", .data = (ulong)&usdhc_imx7d_data,},
> +#endif
> +#ifdef CONFIG_ARCH_MX7ULP
>  	{ .compatible = "fsl,imx7ulp-usdhc", },
> +#endif
> +#ifdef CONFIG_ARCH_IMX8
>  	{ .compatible = "fsl,imx8qm-usdhc", .data = (ulong)&usdhc_imx8qm_data,},
> +#endif
> +#ifdef CONFIG_ARCH_IMX8M
>  	{ .compatible = "fsl,imx8mm-usdhc", .data = (ulong)&usdhc_imx8qm_data,},
>  	{ .compatible = "fsl,imx8mn-usdhc", .data = (ulong)&usdhc_imx8qm_data,},
>  	{ .compatible = "fsl,imx8mq-usdhc", .data = (ulong)&usdhc_imx8qm_data,},
> +#endif
> +#ifdef CONFIG_ARCH_IMXRT
>  	{ .compatible = "fsl,imxrt-usdhc", },
> +#endif
>  	{ .compatible = "fsl,esdhc", },
>  	{ /* sentinel */ }
>  };
> diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
> index 9ae2db033e..d829b5b5ba 100644
> --- a/drivers/net/fec_mxc.c
> +++ b/drivers/net/fec_mxc.c
> @@ -1574,14 +1574,30 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev)
>  }
>
>  static const struct udevice_id fecmxc_ids[] = {
> +#ifdef CONFIG_ARCH_MX28
>  	{ .compatible = "fsl,imx28-fec" },
> +#endif
> +#ifdef CONFIG_ARCH_MX6
>  	{ .compatible = "fsl,imx6q-fec" },
> +#endif
> +#ifdef CONFIG_MX6SL
>  	{ .compatible = "fsl,imx6sl-fec" },
> +#endif
> +#ifdef CONFIG_MX6SX
>  	{ .compatible = "fsl,imx6sx-fec" },
> +#endif
> +#ifdef CONFIG_MX6UL
>  	{ .compatible = "fsl,imx6ul-fec" },
> +#endif
> +#ifdef CONFIG_ARCH_MX5
>  	{ .compatible = "fsl,imx53-fec" },
> +#endif
> +#ifdef CONFIG_ARCH_MX7
>  	{ .compatible = "fsl,imx7d-fec" },
> +#endif
> +#ifdef CONFIG_ARCH_VF610
>  	{ .compatible = "fsl,mvf600-fec" },
> +#endif
>  	{ }
>  };
>
> diff --git a/drivers/pinctrl/nxp/pinctrl-imx6.c b/drivers/pinctrl/nxp/pinctrl-imx6.c
> index aafa3057ad..dff4954344 100644
> --- a/drivers/pinctrl/nxp/pinctrl-imx6.c
> +++ b/drivers/pinctrl/nxp/pinctrl-imx6.c
> @@ -12,14 +12,18 @@
>
>  static struct imx_pinctrl_soc_info imx6_pinctrl_soc_info __section(".data");
>
> +#ifdef CONFIG_MX6UL
>  /* FIXME Before reloaction, BSS is overlapped with DT area */
>  static struct imx_pinctrl_soc_info imx6ul_pinctrl_soc_info = {
>  	.flags = ZERO_OFFSET_VALID,
>  };
> +#endif
>
> +#if defined(CONFIG_MX6SLL) || defined(CONFIG_MX6ULL)
>  static struct imx_pinctrl_soc_info imx6_snvs_pinctrl_soc_info = {
>  	.flags = ZERO_OFFSET_VALID,
>  };
> +#endif
>
>  static int imx6_pinctrl_probe(struct udevice *dev)
>  {
> @@ -32,12 +36,22 @@ static int imx6_pinctrl_probe(struct udevice *dev)
>  static const struct udevice_id imx6_pinctrl_match[] = {
>  	{ .compatible = "fsl,imx6q-iomuxc", .data = (ulong)&imx6_pinctrl_soc_info },
>  	{ .compatible = "fsl,imx6dl-iomuxc", .data = (ulong)&imx6_pinctrl_soc_info },
> +#ifdef CONFIG_MX6SL
>  	{ .compatible = "fsl,imx6sl-iomuxc", .data = (ulong)&imx6_pinctrl_soc_info },
> +#endif
> +#ifdef CONFIG_MX6SLL
>  	{ .compatible = "fsl,imx6sll-iomuxc-snvs", .data = (ulong)&imx6_snvs_pinctrl_soc_info },
>  	{ .compatible = "fsl,imx6sll-iomuxc", .data = (ulong)&imx6_pinctrl_soc_info },
> +#endif
> +#ifdef CONFIG_MX6SX
>  	{ .compatible = "fsl,imx6sx-iomuxc", .data = (ulong)&imx6_pinctrl_soc_info },
> +#endif
> +#ifdef CONFIG_MX6UL
>  	{ .compatible = "fsl,imx6ul-iomuxc", .data = (ulong)&imx6ul_pinctrl_soc_info },
> +#endif
> +#ifdef CONFIG_MX6ULL
>  	{ .compatible = "fsl,imx6ull-iomuxc-snvs", .data = (ulong)&imx6_snvs_pinctrl_soc_info },
> +#endif
>  	{ /* sentinel */ }
>  };
>
> diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c
> index 42abb96a26..f4a0d56e09 100644
> --- a/drivers/serial/serial_mxc.c
> +++ b/drivers/serial/serial_mxc.c
> @@ -343,11 +343,21 @@ static int mxc_serial_ofdata_to_platdata(struct udevice *dev)
>
>  static const struct udevice_id mxc_serial_ids[] = {
>  	{ .compatible = "fsl,imx21-uart" },
> +#ifdef CONFIG_ARCH_MX5
>  	{ .compatible = "fsl,imx53-uart" },
> +#endif
> +#ifdef CONFIG_ARCH_MX6SX
>  	{ .compatible = "fsl,imx6sx-uart" },
> +#endif
> +#if defined(CONFIG_ARCH_MX6UL) || defined(CONFIG_ARCH_MX6ULL)
>  	{ .compatible = "fsl,imx6ul-uart" },
> +#endif
> +#ifdef CONFIG_ARCH_MX7
>  	{ .compatible = "fsl,imx7d-uart" },
> +#endif
> +#if defined(CONFIG_ARCH_MX6) || defined(CONFIG_ARCH_MX6SL) || defined(CONFIG_ARCH_MX6SLL)
>  	{ .compatible = "fsl,imx6q-uart" },
> +#endif
>  	{ }
>  };
>  #endif



More information about the U-Boot mailing list