mbox series

[0/7] pinctrl/arm: dt-bindings: deprecate header with register constants

Message ID 20220526143707.767490-1-krzysztof.kozlowski@linaro.org
Headers show
Series pinctrl/arm: dt-bindings: deprecate header with register constants | expand

Message

Krzysztof Kozlowski May 26, 2022, 2:37 p.m. UTC
Hi,

The Samsung pin controller drivers were always expecting DTS to use raw
register values for pin configuration (e.g. pull up/down, drive strength).  DTS
had these values hard-coded all over, so at some point we decided for
convenience to move them to dt-bindings header.  Less code duplication, some
meaning added to raw number, etc.

However these constants do not fit the purpose of bindings.  They do not
provide any abstraction, any hardware and driver independent ID.  With minor
exceptions, the Linux drivers actually do not use the bindings header at
all.  Because of this "dt-bindings ID" approach, these constants were re-used
between chips, e.g. Exynos ones in S5PV210.  These does not make much sense
because the values between Exynos and S5PV210 (or S3C24xx) are not related.  If
it was an abstraction ID, this would be fine. But it's not.

Clean this up by:
1. Moving the constants to DTS-local headers.
2. Deprecating the bindings header.

Tested by comparing DTBs (dtx_diff, fdtdump).

Best regards,
Krzysztof

Krzysztof Kozlowski (7):
  ARM: dts: s3c2410: use local header for pinctrl register values
  ARM: dts: s3c64xx: use local header for pinctrl register values
  ARM: dts: s5pv210: use local header for pinctrl register values
  ARM: dts: exynos: use local header for pinctrl register values
  arm64: dts: exynos: use local header for pinctrl register values
  arm64: dts: fsd: use local header for pinctrl register values
  dt-bindings: pinctrl: deprecate header with register constants

 arch/arm/boot/dts/exynos-pinctrl.h            |  55 ++
 arch/arm/boot/dts/exynos3250-pinctrl.dtsi     |   2 +-
 arch/arm/boot/dts/exynos4210-pinctrl.dtsi     |   2 +-
 arch/arm/boot/dts/exynos4412-midas.dtsi       |   3 +-
 arch/arm/boot/dts/exynos4412-p4note.dtsi      |   2 +-
 arch/arm/boot/dts/exynos4412-pinctrl.dtsi     |   2 +-
 arch/arm/boot/dts/exynos5250-pinctrl.dtsi     |   2 +-
 arch/arm/boot/dts/exynos5260-pinctrl.dtsi     |   2 +-
 arch/arm/boot/dts/exynos5410-pinctrl.dtsi     |   2 +-
 arch/arm/boot/dts/exynos5420-pinctrl.dtsi     |   2 +-
 arch/arm/boot/dts/s3c2410-pinctrl.h           |  19 +
 arch/arm/boot/dts/s3c2416-pinctrl.dtsi        |  38 +-
 arch/arm/boot/dts/s3c64xx-pinctrl.dtsi        | 178 +++----
 arch/arm/boot/dts/s3c64xx-pinctrl.h           |  27 +
 arch/arm/boot/dts/s5pv210-aquila.dts          |   4 +-
 arch/arm/boot/dts/s5pv210-aries.dtsi          | 134 ++---
 arch/arm/boot/dts/s5pv210-fascinate4g.dts     |  22 +-
 arch/arm/boot/dts/s5pv210-galaxys.dts         |  34 +-
 arch/arm/boot/dts/s5pv210-pinctrl.dtsi        | 480 +++++++++---------
 arch/arm/boot/dts/s5pv210-pinctrl.h           |  39 ++
 arch/arm64/boot/dts/exynos/exynos-pinctrl.h   |  79 +++
 .../boot/dts/exynos/exynos5433-pinctrl.dtsi   |   2 +-
 .../boot/dts/exynos/exynos7-espresso.dts      |   6 +-
 .../boot/dts/exynos/exynos7-pinctrl.dtsi      |  72 +--
 .../boot/dts/exynos/exynos7885-pinctrl.dtsi   |   2 +-
 .../boot/dts/exynos/exynos850-pinctrl.dtsi    |   2 +-
 .../boot/dts/exynos/exynosautov9-pinctrl.dtsi |   2 +-
 arch/arm64/boot/dts/tesla/fsd-pinctrl.dtsi    |  92 ++--
 arch/arm64/boot/dts/tesla/fsd-pinctrl.h       |  33 ++
 drivers/pinctrl/samsung/pinctrl-exynos.c      |   6 +-
 drivers/pinctrl/samsung/pinctrl-exynos.h      |   3 +
 drivers/pinctrl/samsung/pinctrl-samsung.c     |   4 +-
 drivers/pinctrl/samsung/pinctrl-samsung.h     |   8 +
 include/dt-bindings/pinctrl/samsung.h         |   3 +
 34 files changed, 813 insertions(+), 550 deletions(-)
 create mode 100644 arch/arm/boot/dts/exynos-pinctrl.h
 create mode 100644 arch/arm/boot/dts/s3c2410-pinctrl.h
 create mode 100644 arch/arm/boot/dts/s3c64xx-pinctrl.h
 create mode 100644 arch/arm/boot/dts/s5pv210-pinctrl.h
 create mode 100644 arch/arm64/boot/dts/exynos/exynos-pinctrl.h
 create mode 100644 arch/arm64/boot/dts/tesla/fsd-pinctrl.h

Comments

Chanho Park May 27, 2022, 3:34 a.m. UTC | #1
> Subject: [PATCH 5/7] arm64: dts: exynos: use local header for pinctrl
> register values
> 
> The DTS uses hardware register values directly in pin controller pin
> configuration.  These are not some IDs or other abstraction layer but raw
> numbers used in the registers.
> 
> These numbers were previously put in the bindings header to avoid code
> duplication and to provide some context meaning (name), but they do not
> fit the purpose of bindings.
> 
> Store the constants in a header next to DTS and use them instead of
> bindings.
> 

I also verified before & after using dtx_diff tool and booting & pinctrl
value dump on my exynosautov9-sadk board.

Reviewed-by: Chanho Park <chanho61.park@samsung.com>
Tested-by: Chanho Park <chanho61.park@samsung.com>

Best Regards,
Chanho Park
Chanho Park May 27, 2022, 4:22 a.m. UTC | #2
> Subject: [PATCH 1/7] ARM: dts: s3c2410: use local header for pinctrl
> register values
> 
> The DTS uses hardware register values directly in pin controller pin
> configuration.  These are not some IDs or other abstraction layer but raw
> numbers used in the registers.
> 
> These numbers were previously put in the bindings header to avoid code
> duplication and to provide some context meaning (name), but they do not
> fit the purpose of bindings.  It is also quite confusing to use constants
> prefixed with Exynos for other SoC, because there is actually nothing here
> in common, except the actual value.
> 
> Store the constants in a header next to DTS and use them instead of
> bindings.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
>  arch/arm/boot/dts/s3c2410-pinctrl.h    | 19 +++++++++++++
>  arch/arm/boot/dts/s3c2416-pinctrl.dtsi | 38 +++++++++++++-------------
>  2 files changed, 38 insertions(+), 19 deletions(-)  create mode 100644
> arch/arm/boot/dts/s3c2410-pinctrl.h
> 
> diff --git a/arch/arm/boot/dts/s3c2410-pinctrl.h
> b/arch/arm/boot/dts/s3c2410-pinctrl.h
> new file mode 100644
> index 000000000000..71cb0ac815b3
> --- /dev/null
> +++ b/arch/arm/boot/dts/s3c2410-pinctrl.h
> @@ -0,0 +1,19 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Samsung's Exynos pinctrl bindings

"Exynos" -> "s3c2410"

Best Regards,
Chanho Park

> + *
> + * Copyright (c) 2016 Samsung Electronics Co., Ltd.
> + *		http://www.samsung.com
> + * Copyright (c) 2022 Linaro Ltd
> + * Author: Krzysztof Kozlowski <krzk@kernel.org>  */
> +
> +#ifndef __DTS_ARM_SAMSUNG_S3C2410_PINCTRL_H__
> +#define __DTS_ARM_SAMSUNG_S3C2410_PINCTRL_H__
> +
> +#define S3C2410_PIN_FUNC_INPUT		0
> +#define S3C2410_PIN_FUNC_OUTPUT		1
> +#define S3C2410_PIN_FUNC_2		2
> +#define S3C2410_PIN_FUNC_3		3
> +
> +#endif /* __DTS_ARM_SAMSUNG_S3C2410_PINCTRL_H__ */
> diff --git a/arch/arm/boot/dts/s3c2416-pinctrl.dtsi
> b/arch/arm/boot/dts/s3c2416-pinctrl.dtsi
> index 20a7d72827c2..3268366bd8bc 100644
> --- a/arch/arm/boot/dts/s3c2416-pinctrl.dtsi
> +++ b/arch/arm/boot/dts/s3c2416-pinctrl.dtsi
> @@ -5,7 +5,7 @@
>   * Copyright (c) 2013 Heiko Stuebner <heiko@sntech.de>
>   */
> 
> -#include <dt-bindings/pinctrl/samsung.h>
> +#include "s3c2410-pinctrl.h"
> 
>  &pinctrl_0 {
>  	/*
> @@ -82,91 +82,91 @@ gpm: gpm-gpio-bank {
> 
>  	uart0_data: uart0-data-pins {
>  		samsung,pins = "gph-0", "gph-1";
> -		samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
> +		samsung,pin-function = <S3C2410_PIN_FUNC_2>;
>  	};
> 
>  	uart0_fctl: uart0-fctl-pins {
>  		samsung,pins = "gph-8", "gph-9";
> -		samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
> +		samsung,pin-function = <S3C2410_PIN_FUNC_2>;
>  	};
> 
>  	uart1_data: uart1-data-pins {
>  		samsung,pins = "gph-2", "gph-3";
> -		samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
> +		samsung,pin-function = <S3C2410_PIN_FUNC_2>;
>  	};
> 
>  	uart1_fctl: uart1-fctl-pins {
>  		samsung,pins = "gph-10", "gph-11";
> -		samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
> +		samsung,pin-function = <S3C2410_PIN_FUNC_2>;
>  	};
> 
>  	uart2_data: uart2-data-pins {
>  		samsung,pins = "gph-4", "gph-5";
> -		samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
> +		samsung,pin-function = <S3C2410_PIN_FUNC_2>;
>  	};
> 
>  	uart2_fctl: uart2-fctl-pins {
>  		samsung,pins = "gph-6", "gph-7";
> -		samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
> +		samsung,pin-function = <S3C2410_PIN_FUNC_2>;
>  	};
> 
>  	uart3_data: uart3-data-pins {
>  		samsung,pins = "gph-6", "gph-7";
> -		samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
> +		samsung,pin-function = <S3C2410_PIN_FUNC_2>;
>  	};
> 
>  	extuart_clk: extuart-clk-pins {
>  		samsung,pins = "gph-12";
> -		samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
> +		samsung,pin-function = <S3C2410_PIN_FUNC_2>;
>  	};
> 
>  	i2c0_bus: i2c0-bus-pins {
>  		samsung,pins = "gpe-14", "gpe-15";
> -		samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
> +		samsung,pin-function = <S3C2410_PIN_FUNC_2>;
>  	};
> 
>  	spi0_bus: spi0-bus-pins {
>  		samsung,pins = "gpe-11", "gpe-12", "gpe-13";
> -		samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
> +		samsung,pin-function = <S3C2410_PIN_FUNC_2>;
>  	};
> 
>  	sd0_clk: sd0-clk-pins {
>  		samsung,pins = "gpe-5";
> -		samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
> +		samsung,pin-function = <S3C2410_PIN_FUNC_2>;
>  	};
> 
>  	sd0_cmd: sd0-cmd-pins {
>  		samsung,pins = "gpe-6";
> -		samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
> +		samsung,pin-function = <S3C2410_PIN_FUNC_2>;
>  	};
> 
>  	sd0_bus1: sd0-bus1-pins {
>  		samsung,pins = "gpe-7";
> -		samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
> +		samsung,pin-function = <S3C2410_PIN_FUNC_2>;
>  	};
> 
>  	sd0_bus4: sd0-bus4-pins {
>  		samsung,pins = "gpe-8", "gpe-9", "gpe-10";
> -		samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
> +		samsung,pin-function = <S3C2410_PIN_FUNC_2>;
>  	};
> 
>  	sd1_cmd: sd1-cmd-pins {
>  		samsung,pins = "gpl-8";
> -		samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
> +		samsung,pin-function = <S3C2410_PIN_FUNC_2>;
>  	};
> 
>  	sd1_clk: sd1-clk-pins {
>  		samsung,pins = "gpl-9";
> -		samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
> +		samsung,pin-function = <S3C2410_PIN_FUNC_2>;
>  	};
> 
>  	sd1_bus1: sd1-bus1-pins {
>  		samsung,pins = "gpl-0";
> -		samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
> +		samsung,pin-function = <S3C2410_PIN_FUNC_2>;
>  	};
> 
>  	sd1_bus4: sd1-bus4-pins {
>  		samsung,pins = "gpl-1", "gpl-2", "gpl-3";
> -		samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
> +		samsung,pin-function = <S3C2410_PIN_FUNC_2>;
>  	};
>  };
> --
> 2.34.1
Krzysztof Kozlowski May 29, 2022, 8:07 a.m. UTC | #3
On 27/05/2022 06:22, Chanho Park wrote:
>> Subject: [PATCH 1/7] ARM: dts: s3c2410: use local header for pinctrl
>> register values
>>
>> The DTS uses hardware register values directly in pin controller pin
>> configuration.  These are not some IDs or other abstraction layer but raw
>> numbers used in the registers.
>>
>> These numbers were previously put in the bindings header to avoid code
>> duplication and to provide some context meaning (name), but they do not
>> fit the purpose of bindings.  It is also quite confusing to use constants
>> prefixed with Exynos for other SoC, because there is actually nothing here
>> in common, except the actual value.
>>
>> Store the constants in a header next to DTS and use them instead of
>> bindings.
>>
>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>> ---
>>  arch/arm/boot/dts/s3c2410-pinctrl.h    | 19 +++++++++++++
>>  arch/arm/boot/dts/s3c2416-pinctrl.dtsi | 38 +++++++++++++-------------
>>  2 files changed, 38 insertions(+), 19 deletions(-)  create mode 100644
>> arch/arm/boot/dts/s3c2410-pinctrl.h
>>
>> diff --git a/arch/arm/boot/dts/s3c2410-pinctrl.h
>> b/arch/arm/boot/dts/s3c2410-pinctrl.h
>> new file mode 100644
>> index 000000000000..71cb0ac815b3
>> --- /dev/null
>> +++ b/arch/arm/boot/dts/s3c2410-pinctrl.h
>> @@ -0,0 +1,19 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +/*
>> + * Samsung's Exynos pinctrl bindings
> 
> "Exynos" -> "s3c2410"
> 

Thanks, I need to fix it also in other files.

Best regards,
Krzysztof