Support pwm/tach driver for aspeed ast26xx
Subsystems (5)
Billy Tsai
reviewercover Support pwm/tach driver for aspeed ast26xx
Unlike the old design that the register setting of the TACH should based on the configure of the PWM. In ast26xx, the dependency between pwm and tach controller is eliminated and becomes a separate hardware block. One is used to provide pwm output and another is used to monitor the frequency of the input. Therefore, this patch serials implements them by writing the two driver "pwm-aspeed-ast2600.c" and "tach-aspeed-ast2600.c". The former is following the pwm subsystem which can apply the existed driver to controller the fan(pwm-fan.c), beeper(pwm-beeper.c) and so on. The latter is following the sysfs interface of hwmon to creat the node for fan monitor.
Billy Tsai (3):
dt-bindings: Add bindings for aspeed pwm-tach.
pwm: Add Aspeed ast2600 PWM support
hwmon: Add Aspeed ast2600 TACH support
.../bindings/hwmon/aspeed,ast2600-tach.yaml | 48 ++ .../bindings/mfd/aspeed,ast2600-pwm-tach.yaml | 76 ++ .../bindings/pwm/aspeed,ast2600-pwm.yaml | 64 ++ drivers/hwmon/Kconfig | 9 + drivers/hwmon/Makefile | 1 + drivers/hwmon/tach-aspeed-ast2600.c | 692 ++++++++++++++++++ drivers/pwm/Kconfig | 10 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-aspeed-ast2600.c | 325 ++++++++ 9 files changed, 1226 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/aspeed,ast2600-tach.yaml create mode 100644 Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml create mode 100644 Documentation/devicetree/bindings/pwm/aspeed,ast2600-pwm.yaml create mode 100644 drivers/hwmon/tach-aspeed-ast2600.c create mode 100644 drivers/pwm/pwm-aspeed-ast2600.c
Signature · 1 line
2.25.1
Billy Tsai
reviewerPATCH 1/3 dt-bindings: Add bindings for aspeed pwm-tach.
Unlike the old design that the register setting of the TACH should based on the configure of the PWM. In ast26xx, the dependency between pwm and tach controller is eliminated and becomes a separate hardware block. They only shared the same base address, source clock and reset. This patch adds device binding for aspeed pwm-tach device which is a multi-function device include pwm and tach function and pwm/tach device bindings which should be the child-node of pwm-tach device.
--- .../bindings/hwmon/aspeed,ast2600-tach.yaml | 48 ++++++++++++ .../bindings/mfd/aspeed,ast2600-pwm-tach.yaml | 76 +++++++++++++++++++ .../bindings/pwm/aspeed,ast2600-pwm.yaml | 64 ++++++++++++++++ 3 files changed, 188 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/aspeed,ast2600-tach.yaml create mode 100644 Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml create mode 100644 Documentation/devicetree/bindings/pwm/aspeed,ast2600-pwm.yaml
Documentation/devicetree/bindings/hwmon/aspeed,ast2600-tach.yaml new file +48 -0
@@ -0,0 +1,48 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2021 Aspeed, Inc. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/aspeed,ast2600-tach.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Aspeed Ast2600 Tach controller + +maintainers: + - Billy Tsai <[email protected]> + +description: | + The Aspeed Tach controller can support upto 16 fan input. + This module is part of the ast2600-pwm-tach multi-function device. For more + details see ../mfd/aspeed,ast2600-pwm-tach.yaml. + +properties: + compatible: + enum: + - aspeed,ast2600-tach + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + pinctrl-0: true + + pinctrl-names: + const: default + +required: + - compatible + - "#address-cells" + - "#size-cells" + +additionalProperties: + type: object + properties: + reg: + description: + The tach channel used for this node. + maxItems: 1 + + required: + - reg
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml new file +76 -0
76 lines not on this page · raw message
Documentation/devicetree/bindings/pwm/aspeed,ast2600-pwm.yaml new file +64 -0
64 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH 1/3] dt-bindings: Add bindings for aspeed pwm-tach.
Quoted 1 line · Billy Tsai
Unlike the old design that the register setting of the TACH should based
Drop full stop in subject. Drop redundant, second "bindings" in subject.
Quoted 5 lines
on the configure of the PWM. In ast26xx, the dependency between pwm and tach controller is eliminated and becomes a separate hardware block. They only shared the same base address, source clock and reset. This patch adds device binding for aspeed pwm-tach device which is a multi-function device include pwm and tach function and pwm/tach device
Do not use "This commit/patch".
https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitting-patches.rst#L95
Quoted 1 line
bindings which should be the child-node of pwm-tach device.
Please use scripts/get_maintainers.pl to get a list of necessary people and lists to CC. It might happen, that command when run on an older kernel, gives you outdated entries. Therefore please be sure you base your patches on recent Linux kernel.
Quoted 6 lines
Signed-off-by Billy Tsai <[email protected]>--- .../bindings/hwmon/aspeed,ast2600-tach.yaml | 48 ++++++++++++ .../bindings/mfd/aspeed,ast2600-pwm-tach.yaml | 76 +++++++++++++++++++ .../bindings/pwm/aspeed,ast2600-pwm.yaml | 64 ++++++++++++++++
Split per subsystem. And Cc necessary people...
Quoted 33 lines
3 files changed, 188 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/aspeed,ast2600-tach.yaml create mode 100644 Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml create mode 100644 Documentation/devicetree/bindings/pwm/aspeed,ast2600-pwm.yamlDocumentation/devicetree/bindings/hwmon/aspeed,ast2600-tach.yaml new file +22
-0@@ -0,0 +1,48 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2021 Aspeed, Inc. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/aspeed,ast2600-tach.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Aspeed Ast2600 Tach controller + +maintainers: + - Billy Tsai <[email protected]> + +description: | + The Aspeed Tach controller can support upto 16 fan input. + This module is part of the ast2600-pwm-tach multi-function device. For more + details see ../mfd/aspeed,ast2600-pwm-tach.yaml. + +properties: + compatible: + enum: + - aspeed,ast2600-tach +
Documentation/devicetree/bindings/hwmon/aspeed,ast2600-tach.yaml line 32
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/aspeed,ast2600-tach.yaml new file +10
-0+ "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + pinctrl-0: true + + pinctrl-names: + const: default
These should not be needed.
Documentation/devicetree/bindings/hwmon/aspeed,ast2600-tach.yaml line 39
Quoted 7 lines
Documentation/devicetree/bindings/hwmon/aspeed,ast2600-tach.yaml new file +7
-0+ +required: + - compatible + - "#address-cells" + - "#size-cells" + +additionalProperties:
Instead patternProperties and put them above "required:"
Documentation/devicetree/bindings/hwmon/aspeed,ast2600-tach.yaml line 48
Quoted 9 lines
Documentation/devicetree/bindings/hwmon/aspeed,ast2600-tach.yaml new file +9
-0+ type: object + properties: + reg: + description: + The tach channel used for this node. + maxItems: 1 + + required: + - reg
additionalProperties on this level of indentation.
Quoted 6 lines
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml new file +0
-0
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml line 8
Quoted 8 lines
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml new file +8
-0@@ -0,0 +1,76 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2021 Aspeed, Inc. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/aspeed,ast2600-pwm-tach.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: PWM Tach controller Device Tree Bindings
Drop "Device Tree Bindings"
Quoted 26 lines
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml new file +26
-0+ +description: | + The PWM Tach controller is represented as a multi-function device which + includes: + PWM + Tach + +maintainers: + - Billy Tsai <[email protected]> + +properties: + compatible: + items: + - enum: + - aspeed,ast2600-pwm-tach + - const: syscon + - const: simple-mfd + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + resets: + maxItems: 1
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml line 44
Quoted 10 lines
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml new file +10
-0+ +required: + - compatible + - reg + - clocks + - resets + +patternProperties: + "^pwm(@[0-9a-f]+)?$": + $ref: ../pwm/aspeed,ast2600-pwm.yaml
Full path, so: /schemas/pwm/aspeed,ast2600-pwm.yaml
Why unit addresses are optional?
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml line 47
Quoted 3 lines
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml new file +3
-0+ + "^tach(@[0-9a-f]+)?$": + $ref: ../hwmon/aspeed,ast2600-tach.yaml
Ditto
Why unit addresses are optional?
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml
Quoted 7 lines
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml new file +7
-0+ +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/ast2600-clock.h> + pwm_tach: pwm_tach at 1e610000 {
Node names should be generic.
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation
No underscores in node names.
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml line 63
Quoted 9 lines
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml new file +9
-0+ compatible = "aspeed,ast2600-pwm-tach", "syscon", "simple-mfd"; + reg = <0x1e610000 0x100>; + clocks = <&syscon ASPEED_CLK_AHB>; + resets = <&syscon ASPEED_RESET_PWM>; + + pwm: pwm { + compatible = "aspeed,ast2600-pwm"; + #address-cells = <1>; + #size-cells = <0>;
No need for address/size cells. No children.
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml line 72
Quoted 9 lines
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml new file +9
-0+ #pwm-cells = <3>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_pwm0_default>; + }; + + tach: tach { + compatible = "aspeed,ast2600-tach"; + #address-cells = <1>; + #size-cells = <0>;
Ditto.
Quoted 14 lines
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml new file +4
-0+ pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_tach0_default>; + }; + };Documentation/devicetree/bindings/pwm/aspeed,ast2600-pwm.yaml new file +4
-0@@ -0,0 +1,64 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2021 Aspeed, Inc. +%YAML 1.2 +---
Documentation/devicetree/bindings/pwm/aspeed,ast2600-pwm.yaml line 14
Quoted 10 lines
Documentation/devicetree/bindings/pwm/aspeed,ast2600-pwm.yaml new file +10
-0+$id: http://devicetree.org/schemas/pwm/aspeed,ast2600-pwm.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Aspeed Ast2600 PWM controller + +maintainers: + - Billy Tsai <[email protected]> + +description: | + The Aspeed PWM controller can support upto 16 PWM outputs.
s/can support/supports/
s/upto/up to/
Documentation/devicetree/bindings/pwm/aspeed,ast2600-pwm.yaml line 17
Quoted 3 lines
Documentation/devicetree/bindings/pwm/aspeed,ast2600-pwm.yaml new file +3
-0+ This module is part of the ast2600-pwm-tach multi-function device. For more + details see ../mfd/aspeed,ast2600-pwm-tach.yaml. +
Missing $ref to pwm.yaml
Documentation/devicetree/bindings/pwm/aspeed,ast2600-pwm.yaml line 19
Quoted 2 lines
Documentation/devicetree/bindings/pwm/aspeed,ast2600-pwm.yaml new file +2
-0+properties: + compatible:
Below, same comments apply.
This is incomplete review.
Best regards,
Krzysztof
Billy Tsai
reviewerRe: [PATCH 1/3] dt-bindings: Add bindings for aspeed pwm-tach.
On 2022/11/3, 5:20 AM, "Krzysztof Kozlowski" <[email protected]> wrote:
On 31/10/2022 06:38, Billy Tsai wrote:
> > +patternProperties:
> > + "^pwm(@[0-9a-f]+)?$":
> > + $ref: ../pwm/aspeed,ast2600-pwm.yaml
> Full path, so: /schemas/pwm/aspeed,ast2600-pwm.yaml
> Why unit addresses are optional?
> > +
> > + "^tach(@[0-9a-f]+)?$":
> > + $ref: ../hwmon/aspeed,ast2600-tach.yaml
> Ditto
> Why unit addresses are optional?The pwm_tach is not the bus. I will use
pwm:
type: object
$ref: "/schemas/pwm/aspeed,ast2600-pwm.yaml"tach:
type: object
$ref: "/schemas/hwmon/aspeed,ast2600-tach.yaml"to replace it.
Quoted 10 lines
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml
Quoted 7 lines
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml new file +7
-0+ +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/ast2600-clock.h> + pwm_tach: pwm_tach at 1e610000 {Node names should be generic.
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation
This is the mfd with pwm and tach, so they are combined as the node name.
Quoted 1 line
No underscores in node names.
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#table-1
I see that the underscore is the valid characters for node names. Did I miss any information?
Thanks
Best Regards,
Billy Tsai
Re: [PATCH 1/3] dt-bindings: Add bindings for aspeed pwm-tach.
Quoted 41 lines · Billy Tsai
On 2022/11/3, 5:20 AM, "Krzysztof Kozlowski" <[email protected]> wrote:
On 31/10/2022 06:38, Billy Tsai wrote: > > +patternProperties: > > + "^pwm(@[0-9a-f]+)?$": > > + $ref: ../pwm/aspeed,ast2600-pwm.yaml > Full path, so: /schemas/pwm/aspeed,ast2600-pwm.yaml > Why unit addresses are optional? > > + > > + "^tach(@[0-9a-f]+)?$": > > + $ref: ../hwmon/aspeed,ast2600-tach.yaml > Ditto > Why unit addresses are optional?The
pwm_tachis not the bus. I will use
pwm:type: object $ref: "/schemas/pwm/aspeed,ast2600-pwm.yaml"tach:
type: object $ref: "/schemas/hwmon/aspeed,ast2600-tach.yaml"to replace it.
Quoted 10 lines
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml
Quoted 7 lines
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml new file +7
-0+ +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/ast2600-clock.h> + pwm_tach: pwm_tach at 1e610000 {Node names should be generic.
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation
Quoted 7 lines
This is the mfd with pwm and tach, so they are combined as the node name.
Quoted 1 line
No underscores in node names.
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#table-1
I see that the underscore is the valid characters for node names. Did I miss any information?
W=2 warnings.
Best regards,
Krzysztof
Billy Tsai
reviewerPATCH 2/3 pwm: Add Aspeed ast2600 PWM support
In reply to Billy TsaiThis patch add the support of PWM controller which can be found at aspeed ast2600 soc. The pwm supoorts up to 16 channels and it's part function of multi-function device "pwm-tach controller".
--- drivers/pwm/Kconfig | 10 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-aspeed-ast2600.c | 325 +++++++++++++++++++++++++++++++ 3 files changed, 336 insertions(+) create mode 100644 drivers/pwm/pwm-aspeed-ast2600.c
drivers/pwm/Kconfig +10 -0
@@ -51,6 +51,16 @@ config PWM_AB8500 To compile this driver as a module, choose M here: the module will be called pwm-ab8500. +config PWM_ASPEED_AST2600 + tristate "Aspeed ast2600 PWM support" + depends on ARCH_ASPEED || COMPILE_TEST + depends on HAVE_CLK && HAS_IOMEM + help + This driver provides support for Aspeed ast2600 PWM controllers. + + To compile this driver as a module, choose M here: the module + will be called pwm-aspeed-ast2600. + config PWM_ATMEL tristate "Atmel PWM support" depends on ARCH_AT91 || COMPILE_TEST
drivers/pwm/Makefile +1 -0
@@ -2,6 +2,7 @@ obj-$(CONFIG_PWM) += core.o obj-$(CONFIG_PWM_SYSFS) += sysfs.o obj-$(CONFIG_PWM_AB8500) += pwm-ab8500.o +obj-$(CONFIG_PWM_ASPEED_AST2600) += pwm-aspeed-ast2600.o obj-$(CONFIG_PWM_ATMEL) += pwm-atmel.o obj-$(CONFIG_PWM_ATMEL_HLCDC_PWM) += pwm-atmel-hlcdc.o obj-$(CONFIG_PWM_ATMEL_TCB) += pwm-atmel-tcb.o
drivers/pwm/pwm-aspeed-ast2600.c new file +325 -0
325 lines not on this page · raw message
Signature · 1 line
2.25.1
kernel test robot
build botRe: [PATCH 2/3] pwm: Add Aspeed ast2600 PWM support
Thank you for the patch! Perhaps something to improve:
Hi Billy,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on groeck-staging/hwmon-next]
[also build test WARNING on thierry-reding-pwm/for-next lee-mfd/for-mfd-next robh/for-next linus/master v6.1-rc3 next-20221101] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Billy-Tsai/Support-pwm-tach-driver-for-aspeed-ast26xx/20221031-183813 base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next patch link: https://lore.kernel.org/r/20221031103809.20225-3-billy_tsai%40aspeedtech.com patch subject: [PATCH 2/3] pwm: Add Aspeed ast2600 PWM support config: arm64-randconfig-s053-20221101 compiler: aarch64-linux-gcc (GCC) 12.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://github.com/intel-lab-lkp/linux/commit/1e73d9a570e9276911d41cce20e4dcdb0bcdc4d6
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Billy-Tsai/Support-pwm-tach-driver-for-aspeed-ast26xx/20221031-183813
git checkout 1e73d9a570e9276911d41cce20e4dcdb0bcdc4d6
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/perf/ drivers/pwm/
If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <[email protected]>
sparse warnings: (new ones prefixed by >>)
>> drivers/pwm/pwm-aspeed-ast2600.c:255:52: sparse: sparse: Using plain integer as NULL pointer
vim +255 drivers/pwm/pwm-aspeed-ast2600.c
231
232 static int aspeed_pwm_probe(struct platform_device *pdev)
233 {
234 struct device *dev = &pdev->dev;
235 int ret;
236 struct aspeed_pwm_data *priv;
237 struct device_node *np;
238 struct platform_device *parent_dev;
239
240 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
241 if (!priv)
242 return -ENOMEM;
243
244 np = pdev->dev.parent->of_node;
245 if (!of_device_is_compatible(np, "aspeed,ast2600-pwm-tach"))
246 return dev_err_probe(dev, -ENODEV,
247 "Unsupported pwm device binding\n");
248
249 priv->regmap = syscon_node_to_regmap(np);
250 if (IS_ERR(priv->regmap))
251 return dev_err_probe(dev, PTR_ERR(priv->regmap),
252 "Couldn't get regmap\n");
253
254 parent_dev = of_find_device_by_node(np);
> 255 priv->clk = devm_clk_get(&parent_dev->dev, 0);
256 if (IS_ERR(priv->clk))
257 return dev_err_probe(dev, PTR_ERR(priv->clk),
258 "Couldn't get clock\n");
259
260 priv->reset = devm_reset_control_get_shared(&parent_dev->dev, NULL);
261 if (IS_ERR(priv->reset))
262 return dev_err_probe(dev, PTR_ERR(priv->reset),
263 "Couldn't get reset control\n");
264
265 ret = clk_prepare_enable(priv->clk);
266 if (ret)
267 return dev_err_probe(dev, ret, "Couldn't enable clock\n");
268
269 ret = reset_control_deassert(priv->reset);
270 if (ret) {
271 dev_err_probe(dev, ret, "Couldn't deassert reset control\n");
272 goto err_disable_clk;
273 }
274
275 priv->chip.dev = dev;
276 priv->chip.ops = &aspeed_pwm_ops;
277 priv->chip.npwm = PWM_ASPEED_NR_PWMS;
278
279 ret = pwmchip_add(&priv->chip);
280 if (ret < 0) {
281 dev_err_probe(dev, ret, "Failed to add PWM chip\n");
282 goto err_assert_reset;
283 }
284 dev_set_drvdata(dev, priv);
285 return 0;
286 err_assert_reset:
287 reset_control_assert(priv->reset);
288 err_disable_clk:
289 clk_disable_unprepare(priv->clk);
290 return ret;
291 }
292
6,741 lines not shown · raw message
Part of this message is not shown here. View the raw message.
Billy Tsai
reviewerPATCH 3/3 hwmon: Add Aspeed ast2600 TACH support
In reply to Billy TsaiThis patch add the support of Tachometer which can use to monitor the frequency of the input. The tach supports up to 16 channels and it's part function of multi-function device "pwm-tach controller".
--- drivers/hwmon/Kconfig | 9 + drivers/hwmon/Makefile | 1 + drivers/hwmon/tach-aspeed-ast2600.c | 692 ++++++++++++++++++++++++++++ 3 files changed, 702 insertions(+) create mode 100644 drivers/hwmon/tach-aspeed-ast2600.c
drivers/hwmon/Kconfig +9 -0
@@ -397,6 +397,15 @@ config SENSORS_ASPEED This driver can also be built as a module. If so, the module will be called aspeed_pwm_tacho. +config SENSORS_TACH_ASPEED_AST2600 + tristate "ASPEED ast2600 Tachometer support" + select REGMAP + help + This driver provides support for Aspeed ast2600 Tachometer. + + To compile this driver as a module, choose M here: the module + will be called tach-aspeed-ast2600. + config SENSORS_ATXP1 tristate "Attansic ATXP1 VID controller" depends on I2C
drivers/hwmon/Makefile +1 -0
@@ -51,6 +51,7 @@ obj-$(CONFIG_SENSORS_ARM_SCMI) += scmi-hwmon.o obj-$(CONFIG_SENSORS_ARM_SCPI) += scpi-hwmon.o obj-$(CONFIG_SENSORS_AS370) += as370-hwmon.o obj-$(CONFIG_SENSORS_ASC7621) += asc7621.o +obj-$(CONFIG_SENSORS_TACH_ASPEED_AST2600) += tach-aspeed-ast2600.o obj-$(CONFIG_SENSORS_ASPEED) += aspeed-pwm-tacho.o obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o obj-$(CONFIG_SENSORS_AXI_FAN_CONTROL) += axi-fan-control.o
drivers/hwmon/tach-aspeed-ast2600.c new file +692 -0
692 lines not on this page · raw message
Signature · 1 line
2.25.1
Guenter Roeck
maintainerRe: [PATCH 3/3] hwmon: Add Aspeed ast2600 TACH support
Quoted 9 lines · Billy Tsai
This patch add the support of Tachometer which can use to monitor the frequency of the input. The tach supports up to 16 channels and it's part function of multi-function device "pwm-tach controller".
Signed-off-by Billy Tsai <[email protected]>--- drivers/hwmon/Kconfig | 9 + drivers/hwmon/Makefile | 1 + drivers/hwmon/tach-aspeed-ast2600.c | 692 ++++++++++++++++++++++++++++
Please also provide Documentation/hwmon/tach-aspeed-ast2600.rst.
[ ... ]
drivers/hwmon/tach-aspeed-ast2600.c line 645
Quoted 2 lines
drivers/hwmon/tach-aspeed-ast2600.c new file +2
-0+ hwmon =devm_hwmon_device_register_with_groups (dev,"aspeed_tach" , priv, + priv->groups);
Please use the new hwmon api (devm_hwmon_device_register_with_info).
drivers/hwmon/tach-aspeed-ast2600.c line 656
Quoted 11 lines
drivers/hwmon/tach-aspeed-ast2600.c new file +11
-0+ ret =PTR_ERR_OR_ZERO (hwmon); +if (ret) { +dev_err_probe (dev, ret,"Failed to register hwmon device\n" ); + goto err_assert_reset; + } +platform_set_drvdata (pdev, priv); +return 0 ; +err_assert_reset: +reset_control_assert (priv->reset); +err_disable_clk: +clk_disable_unprepare (priv->clk);
You should be able to use devm_clk_get_enabled() to handle the clock. If reset handling has to come first, you could use devm_add_action_or_reset() for it. This way you would not need the remove function, and error cleanup would be much simplified.
Thanks,
Guenter
Quoted 39 lines
drivers/hwmon/tach-aspeed-ast2600.c new file +36
-0+return ret; +} + +static int aspeed_tach_remove (struct platform_device *pdev) +{ +struct aspeed_tach_data *priv =platform_get_drvdata (pdev); + +reset_control_assert (priv->reset); +clk_disable_unprepare (priv->clk); + +return 0 ; +} + +static const struct of_device_id of_stach_match_table[] = { + { + .compatible ="aspeed,ast2600-tach" , + }, + {}, +}; +MODULE_DEVICE_TABLE (of, of_stach_match_table); + +static struct platform_driver aspeed_tach_driver = { + .probe = aspeed_tach_probe, + .remove = aspeed_tach_remove, + .driver = { + .name ="aspeed_tach" , + .of_match_table = of_stach_match_table, + }, +}; + +module_platform_driver (aspeed_tach_driver); + +MODULE_AUTHOR ("Billy Tsai <[email protected]>" ); +MODULE_DESCRIPTION ("Aspeed ast2600 TACH device driver" ); +MODULE_LICENSE ("GPL v2" ); +Signature · 1 line
2.25.1
kernel test robot
build botRe: [PATCH 3/3] hwmon: Add Aspeed ast2600 TACH support
In reply to Billy TsaiThank you for the patch! Perhaps something to improve:
Hi Billy,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on groeck-staging/hwmon-next]
[also build test WARNING on thierry-reding-pwm/for-next lee-mfd/for-mfd-next robh/for-next linus/master v6.1-rc3 next-20221101] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Billy-Tsai/Support-pwm-tach-driver-for-aspeed-ast26xx/20221031-183813 base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next patch link: https://lore.kernel.org/r/20221031103809.20225-4-billy_tsai%40aspeedtech.com patch subject: [PATCH 3/3] hwmon: Add Aspeed ast2600 TACH support config: sparc-randconfig-s052-20221101 compiler: sparc64-linux-gcc (GCC) 12.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://github.com/intel-lab-lkp/linux/commit/34cbef9d62b8b6b352437c2ccaa6467de6524889
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Billy-Tsai/Support-pwm-tach-driver-for-aspeed-ast26xx/20221031-183813
git checkout 34cbef9d62b8b6b352437c2ccaa6467de6524889
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=sparc SHELL=/bin/bash drivers/hwmon/ drivers/media/i2c/
If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <[email protected]>
sparse warnings: (new ones prefixed by >>)
>> drivers/hwmon/tach-aspeed-ast2600.c:615:52: sparse: sparse: Using plain integer as NULL pointer
vim +615 drivers/hwmon/tach-aspeed-ast2600.c
585
586 static int aspeed_tach_probe(struct platform_device *pdev)
587 {
588 struct device *dev = &pdev->dev;
589 struct device_node *np, *child;
590 struct aspeed_tach_data *priv;
591 struct device *hwmon;
592 struct platform_device *parent_dev;
593 int ret;
594
595 np = dev->parent->of_node;
596 if (!of_device_is_compatible(np, "aspeed,ast2600-pwm-tach"))
597 return dev_err_probe(dev, -ENODEV,
598 "Unsupported tach device binding\n");
599
600 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
601 if (!priv)
602 return -ENOMEM;
603 priv->dev = &pdev->dev;
604 priv->tach_channel =
605 devm_kzalloc(dev,
606 TACH_ASPEED_NR_TACHS * sizeof(*priv->tach_channel),
607 GFP_KERNEL);
608
609 priv->regmap = syscon_node_to_regmap(np);
610 if (IS_ERR(priv->regmap)) {
611 dev_err(priv->dev, "Couldn't get regmap\n");
612 return -ENODEV;
613 }
614 parent_dev = of_find_device_by_node(np);
> 615 priv->clk = devm_clk_get(&parent_dev->dev, 0);
616 if (IS_ERR(priv->clk))
617 return dev_err_probe(dev, PTR_ERR(priv->clk),
618 "Couldn't get clock\n");
619
620 priv->reset = devm_reset_control_get_shared(&parent_dev->dev, NULL);
621 if (IS_ERR(priv->reset))
622 return dev_err_probe(dev, PTR_ERR(priv->reset),
623 "Couldn't get reset control\n");
624
625 ret = clk_prepare_enable(priv->clk);
626 if (ret)
627 return dev_err_probe(dev, ret, "Couldn't enable clock\n");
628
629 ret = reset_control_deassert(priv->reset);
630 if (ret) {
631 dev_err_probe(dev, ret, "Couldn't deassert reset control\n");
632 goto err_disable_clk;
633 }
634 for_each_child_of_node(dev->of_node, child) {
635 ret = aspeed_tach_create_fan(dev, child, priv);
636 if (ret) {
637 of_node_put(child);
638 goto err_assert_reset;
639 }
640 }
641
642 priv->groups[0] = &fan_dev_group;
643 priv->groups[1] = NULL;
644 hwmon = devm_hwmon_device_register_with_groups(dev, "aspeed_tach", priv,
645 priv->groups);
646 ret = PTR_ERR_OR_ZERO(hwmon);
647 if (ret) {
648 dev_err_probe(dev, ret, "Failed to register hwmon device\n");
649 goto err_assert_reset;
650 }
651 platform_set_drvdata(pdev, priv);
652 return 0;
653 err_assert_reset:
654 reset_control_assert(priv->reset);
655 err_disable_clk:
656 clk_disable_unprepare(priv->clk);
657 return ret;
658 }
659
7,289 lines not shown · raw message
Part of this message is not shown here. View the raw message.