misc: servo-pwm: driver for controlling servo motors via PWM
Subsystems (3)
PATCH v2 1/3 misc: servo-pwm: driver for controlling servo motors via PWM
This patch adds a simple driver to control servo motor position via PWM signal.
The driver allows to set the angle from userspace, while min/max positions duty cycle and the motor degrees aperture are defined in the dts.
--- MAINTAINERS | 6 ++ drivers/misc/Kconfig | 11 +++ drivers/misc/Makefile | 1 + drivers/misc/servo-pwm.c | 149 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 167 insertions(+) create mode 100644 drivers/misc/servo-pwm.c
MAINTAINERS +6 -0
@@ -8737,6 +8737,12 @@ F: Documentation/devicetree/bindings/power/power?domain* F: drivers/base/power/domain*.c F: include/linux/pm_domain.h +GENERIC PWM SERVO DRIVER +M: "Angelo Compagnucci" <[email protected]> +L: [email protected] +S: Maintained +F: drivers/misc/servo-pwm.c + GENERIC RESISTIVE TOUCHSCREEN ADC DRIVER M: Eugen Hristev <[email protected]> L: [email protected]
drivers/misc/Kconfig +11 -0
@@ -518,6 +518,17 @@ config VCPU_STALL_DETECTOR If you do not intend to run this kernel as a guest, say N. +config SERVO_PWM + tristate "Servo motor positioning" + depends on PWM + help + Driver to control generic servo motor positioning. + Writing to the "angle" device attribute, the motor will move to + the angle position. + + To compile this driver as a module, choose M here: the module + will be called servo-pwm. + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
@@ -64,3 +64,4 @@ obj-$(CONFIG_HI6421V600_IRQ) += hi6421v600-irq.o obj-$(CONFIG_OPEN_DICE) += open-dice.o obj-$(CONFIG_GP_PCI1XXXX) += mchp_pci1xxxx/ obj-$(CONFIG_VCPU_STALL_DETECTOR) += vcpu_stall_detector.o +obj-$(CONFIG_SERVO_PWM) += servo-pwm.o
drivers/misc/servo-pwm.c new file +149 -0
149 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v2 2/3 misc: servo-pwm: Add sysfs entries to control motor angle
Servo motor can be moved between 0 and degrees angle.
Add 'angle' sysfs attribute:
*read*: Current motor position.
*write*: Moves the motor to the position.
Add 'degrees' sysfs attribute:
*read*: how many degrees the motor can move
--- .../ABI/testing/sysfs-driver-servo-pwm | 20 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 21 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-driver-servo-pwm
Documentation/ABI/testing/sysfs-driver-servo-pwm new file +20 -0
@@ -0,0 +1,20 @@ +What: /sys/devices/platform/servo*/angle +Date: Feb 2023 +Contact: Angelo Compagnucci <[email protected]> +Description: + (RW) read or write servo motor position angle. + Servo motor can move between 0 and max degrees angle. + As soon the vale is written, the motor will move to the selected + angle. Reading the value gives the motor position. +Users: any user space application which wants to move the servo + motor position. + +What: /sys/devices/platform/servo*/degrees +Date: Feb 2023 +Contact: Angelo Compagnucci <[email protected]> +Description: + (RO) read the servo motor movement degrees. + Servo motor can move between 0 and max degrees angle. + Reading the value gives the motor max degrees angle supported. +Users: any user space application which wants to know the max degrees + angle motor supports.
MAINTAINERS +1 -0
@@ -8741,6 +8741,7 @@ GENERIC PWM SERVO DRIVER M: "Angelo Compagnucci" <[email protected]> L: [email protected] S: Maintained +F: Documentation/ABI/testing/sysfs-driver-servo-pwm F: drivers/misc/servo-pwm.c GENERIC RESISTIVE TOUCHSCREEN ADC DRIVER
Signature · 1 line
2.34.1
PATCH v2 3/3 dt-bindings: leds: servo-pwm: Add new bindings for servo-pwm
In reply to Angelo CompagnucciThis binding describes the binding for controlling servo motors through pwm.
--- .../devicetree/bindings/misc/servo-pwm.yaml | 59 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 60 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/servo-pwm.yaml
Documentation/devicetree/bindings/misc/servo-pwm.yaml new file +59 -0
@@ -0,0 +1,59 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/misc/servo-pwm.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Servo motor connected to PWM + +maintainers: + - Angelo Compagnucci <[email protected]> + +description: + Each servo is represented as a servo-pwm device. + The 20ms period is the accepted standard and so most of the motors + support it, while the positioning min/max duty cycle or the motor + degrees aperture vary lot between manufacturers. + The most common type of servo (SG90) has 180 degrees of movement + and moves between 0.5ms and 2.5ms duty cycle. + +properties: + compatible: + const: servo-pwm + +patternProperties: + properties: + pwms: + maxItems: 1 + + pwm-names: true + + degrees: + description: + How many degrees the motor can move. + $ref: /schemas/types.yaml#/definitions/uint32 + + duty-min: + description: + Duty cycle for position the motor at 0 degrees. + $ref: /schemas/types.yaml#/definitions/uint32 + + duty-max: + description: + Duty cycle for positioning the motor at "degrees" angle. + $ref: /schemas/types.yaml#/definitions/uint32 + +additionalProperties: false + +examples: + - | + + servo: servo@0 { + compatible = "servo-pwm"; + pwms = <&pwm 0 20000000 0>; + degrees = <180>; + duty-min = <500000>; + duty-max = <2500000>; + }; + +...
MAINTAINERS +1 -0
@@ -8742,6 +8742,7 @@ M: "Angelo Compagnucci" <[email protected]> L: [email protected] S: Maintained F: Documentation/ABI/testing/sysfs-driver-servo-pwm +F: Documentation/devicetree/bindings/misc/servo-pwm.yaml F: drivers/misc/servo-pwm.c GENERIC RESISTIVE TOUCHSCREEN ADC DRIVER
Signature · 1 line
2.34.1
Rob Herring
maintainerRe: [PATCH v2 3/3] dt-bindings: leds: servo-pwm: Add new bindings for servo-pwm
Quoted 10 lines · Angelo Compagnucci
This binding describes the binding for controlling servo motors through pwm.
Signed-off-by Angelo Compagnucci <[email protected]>--- .../devicetree/bindings/misc/servo-pwm.yaml | 59 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 60 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/servo-pwm.yaml
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/misc/servo-pwm.yaml: patternProperties: 'properties' should not be valid under {'$ref': '#/definitions/json-schema-prop-names'}
hint: A json-schema keyword was found instead of a DT property name.
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/misc/servo-pwm.yaml: patternProperties:properties: 'anyOf' conditional failed, one must be fixed:
'pwms' is not one of ['$ref', 'additionalItems', 'additionalProperties', 'allOf', 'anyOf', 'const', 'contains', 'default', 'dependencies', 'dependentRequired', 'dependentSchemas', 'deprecated', 'description', 'else', 'enum', 'exclusiveMaximum', 'exclusiveMinimum', 'items', 'if', 'minItems', 'minimum', 'maxItems', 'maximum', 'multipleOf', 'not', 'oneOf', 'pattern', 'patternProperties', 'properties', 'required', 'then', 'typeSize', 'unevaluatedProperties', 'uniqueItems'] 'type' was expected
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/misc/servo-pwm.yaml: patternProperties:properties: 'anyOf' conditional failed, one must be fixed:
'pwm-names' is not one of ['$ref', 'additionalItems', 'additionalProperties', 'allOf', 'anyOf', 'const', 'contains', 'default', 'dependencies', 'dependentRequired', 'dependentSchemas', 'deprecated', 'description', 'else', 'enum', 'exclusiveMaximum', 'exclusiveMinimum', 'items', 'if', 'minItems', 'minimum', 'maxItems', 'maximum', 'multipleOf', 'not', 'oneOf', 'pattern', 'patternProperties', 'properties', 'required', 'then', 'typeSize', 'unevaluatedProperties', 'uniqueItems'] 'type' was expected
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/misc/servo-pwm.yaml: patternProperties:properties: 'anyOf' conditional failed, one must be fixed:
'degrees' is not one of ['$ref', 'additionalItems', 'additionalProperties', 'allOf', 'anyOf', 'const', 'contains', 'default', 'dependencies', 'dependentRequired', 'dependentSchemas', 'deprecated', 'description', 'else', 'enum', 'exclusiveMaximum', 'exclusiveMinimum', 'items', 'if', 'minItems', 'minimum', 'maxItems', 'maximum', 'multipleOf', 'not', 'oneOf', 'pattern', 'patternProperties', 'properties', 'required', 'then', 'typeSize', 'unevaluatedProperties', 'uniqueItems'] 'type' was expected
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/misc/servo-pwm.yaml: patternProperties:properties: 'anyOf' conditional failed, one must be fixed:
'duty-min' is not one of ['$ref', 'additionalItems', 'additionalProperties', 'allOf', 'anyOf', 'const', 'contains', 'default', 'dependencies', 'dependentRequired', 'dependentSchemas', 'deprecated', 'description', 'else', 'enum', 'exclusiveMaximum', 'exclusiveMinimum', 'items', 'if', 'minItems', 'minimum', 'maxItems', 'maximum', 'multipleOf', 'not', 'oneOf', 'pattern', 'patternProperties', 'properties', 'required', 'then', 'typeSize', 'unevaluatedProperties', 'uniqueItems'] 'type' was expected
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/misc/servo-pwm.yaml: patternProperties:properties: 'anyOf' conditional failed, one must be fixed:
'duty-max' is not one of ['$ref', 'additionalItems', 'additionalProperties', 'allOf', 'anyOf', 'const', 'contains', 'default', 'dependencies', 'dependentRequired', 'dependentSchemas', 'deprecated', 'description', 'else', 'enum', 'exclusiveMaximum', 'exclusiveMinimum', 'items', 'if', 'minItems', 'minimum', 'maxItems', 'maximum', 'multipleOf', 'not', 'oneOf', 'pattern', 'patternProperties', 'properties', 'required', 'then', 'typeSize', 'unevaluatedProperties', 'uniqueItems'] 'type' was expected
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
Documentation/devicetree/bindings/misc/servo-pwm.example.dts:19.24-25.11: Warning (unit_address_vs_reg): /example-0/servo@0: node has a unit name, but no reg or ranges property
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/misc/servo-pwm.example.dtb: servo@0: 'degrees', 'duty-max', 'duty-min', 'pwms' do not match any of the regexes: 'pinctrl-[0-9]+', 'properties'
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/misc/servo-pwm.yaml
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
Rob Herring
maintainerRe: [PATCH v2 3/3] dt-bindings: leds: servo-pwm: Add new bindings for servo-pwm
In reply to Angelo CompagnucciQuoted 35 lines · Angelo Compagnucci
This binding describes the binding for controlling servo motors through pwm.
Signed-off-by Angelo Compagnucci <[email protected]>--- .../devicetree/bindings/misc/servo-pwm.yaml | 59 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 60 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/servo-pwm.yamlDocumentation/devicetree/bindings/misc/servo-pwm.yaml new file +19
-0@@ -0,0 +1,59 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/misc/servo-pwm.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Servo motor connected to PWM + +maintainers: + - Angelo Compagnucci <[email protected]> + +description: + Each servo is represented as a servo-pwm device. + The 20ms period is the accepted standard and so most of the motors + support it, while the positioning min/max duty cycle or the motor + degrees aperture vary lot between manufacturers. + The most common type of servo (SG90) has 180 degrees of movement + and moves between 0.5ms and 2.5ms duty cycle. +
Documentation/devicetree/bindings/misc/servo-pwm.yaml line 29
Quoted 10 lines
Documentation/devicetree/bindings/misc/servo-pwm.yaml new file +10
-0+properties: + compatible: + const: servo-pwm + +patternProperties: + properties: + pwms: + maxItems: 1 + + pwm-names: true
Drop. '-names' is for when there is more than 1.
Documentation/devicetree/bindings/misc/servo-pwm.yaml line 31
Quoted 2 lines
Documentation/devicetree/bindings/misc/servo-pwm.yaml new file +2
-0+ + degrees:
Kind of vague: servo-degrees
Documentation/devicetree/bindings/misc/servo-pwm.yaml line 34
Quoted 3 lines
Documentation/devicetree/bindings/misc/servo-pwm.yaml new file +3
-0+ description: + How many degrees the motor can move. + $ref: /schemas/types.yaml#/definitions/uint32
0-2^32 are valid degrees?
Documentation/devicetree/bindings/misc/servo-pwm.yaml line 38
Quoted 4 lines
Documentation/devicetree/bindings/misc/servo-pwm.yaml new file +4
-0+ + duty-min: + description: + Duty cycle for position the motor at 0 degrees.
Units are ms? percent? Use standard unit suffix.
Quoted 36 lines
Documentation/devicetree/bindings/misc/servo-pwm.yaml new file +21
-0+ $ref: /schemas/types.yaml#/definitions/uint32 + + duty-max: + description: + Duty cycle for positioning the motor at "degrees" angle. + $ref: /schemas/types.yaml#/definitions/uint32 + +additionalProperties: false + +examples: + - | + + servo: servo@0 { + compatible = "servo-pwm"; + pwms = <&pwm 0 20000000 0>; + degrees = <180>; + duty-min = <500000>; + duty-max = <2500000>; + }; + +...MAINTAINERS +1
-0@@ -8742,6 +8742,7 @@ M: "Angelo Compagnucci" <[email protected]> L: [email protected] S: Maintained F: Documentation/ABI/testing/sysfs-driver-servo-pwm +F: Documentation/devicetree/bindings/misc/servo-pwm.yaml F: drivers/misc/servo-pwm.c GENERIC RESISTIVE TOUCHSCREEN ADC DRIVERSignature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerQuoted 6 lines · Angelo Compagnucci
This patch adds a simple driver to control servo motor position via PWM signal.
The driver allows to set the angle from userspace, while min/max positions duty cycle and the motor degrees aperture are defined in the dts.
Quoted 6 lines
Signed-off-by Angelo Compagnucci <[email protected]>--- MAINTAINERS | 6 ++ drivers/misc/Kconfig | 11 +++ drivers/misc/Makefile | 1 + drivers/misc/servo-pwm.c | 149 +++++++++++++++++++++++++++++++++++++++
You add sysfs files but do not document them in Documentation/ABI/ which is required. Please do so in your next version of this patch.
drivers/misc/servo-pwm.c line 84
Quoted 6 lines
drivers/misc/servo-pwm.c new file +6
-0+static ssize_t degrees_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct servo_pwm_data *data =dev_get_drvdata (dev); + +return snprintf (buf,PAGE_SIZE ,"%u\n" , data->degrees);
sysfs_emit() please.
thanks,
greg k-h
Quoted 15 lines · Greg Kroah-Hartman
Quoted 6 lines · Angelo Compagnucci
This patch adds a simple driver to control servo motor position via PWM signal.
The driver allows to set the angle from userspace, while min/max positions duty cycle and the motor degrees aperture are defined in the dts.Quoted 6 lines
Signed-off-by Angelo Compagnucci <[email protected]>--- MAINTAINERS | 6 ++ drivers/misc/Kconfig | 11 +++ drivers/misc/Makefile | 1 + drivers/misc/servo-pwm.c | 149 +++++++++++++++++++++++++++++++++++++++
Quoted 2 lines
You add sysfs files but do not document them in
Documentation/ABI/which is required. Please do so in your next version of this patch.
https://patchwork.ozlabs.org/project/linux-pwm/patch/[email protected]/
This patch [2/3] should do what you're asking.
Quoted 9 lines
drivers/misc/servo-pwm.c line 84
Quoted 7 lines
drivers/misc/servo-pwm.c new file +6
-0+static ssize_t degrees_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct servo_pwm_data *data =dev_get_drvdata (dev); + +return snprintf (buf,PAGE_SIZE ,"%u\n" , data->degrees);
sysfs_emit()please.
Will do.
Quoted 4 lines
thanks,
greg k-h
Signature · 16 lines
Angelo Compagnucci Software Engineer [email protected] __________________________________ Amarula Solutions SRL Via le Canevare 30, 31100 Treviso, Veneto, IT T. +39 (0)42 243 5310 [email protected] www.amarulasolutions.com [`as] https://www.amarulasolutions.com|
A message that is not in the archive (sent off-list or not yet received): CA+_SqVYMZ7MErNr-HrbHj-=Q-5u1PizHQ_6TFkTOxB5=E8+9Dg@mail.gmail.com
Greg Kroah-Hartman
maintainerQuoted 17 lines · Angelo Compagnucci
Quoted 14 lines · Greg Kroah-Hartman
Quoted 12 lines · Angelo Compagnucci
This patch adds a simple driver to control servo motor position via PWM signal.
The driver allows to set the angle from userspace, while min/max positions duty cycle and the motor degrees aperture are defined in the dts.Signed-off-by Angelo Compagnucci <[email protected]>--- MAINTAINERS | 6 ++ drivers/misc/Kconfig | 11 +++ drivers/misc/Makefile | 1 + drivers/misc/servo-pwm.c | 149 +++++++++++++++++++++++++++++++++++++++
Quoted 7 lines
Quoted 3 lines
You add sysfs files but do not document them in
Documentation/ABI/which is required. Please do so in your next version of this patch.https://patchwork.ozlabs.org/project/linux-pwm/patch/[email protected]/
This patch [2/3] should do what you're asking.
Why was I only cc:ed on this one patch?
confused,
greg k-h
Quoted 23 lines · Greg Kroah-Hartman
Quoted 21 lines · Angelo Compagnucci
Quoted 17 lines · Greg Kroah-Hartman
Quoted 6 lines · Angelo Compagnucci
This patch adds a simple driver to control servo motor position via PWM signal.
The driver allows to set the angle from userspace, while min/max positions duty cycle and the motor degrees aperture are defined in the dts.Quoted 6 lines
Signed-off-by Angelo Compagnucci <[email protected]>--- MAINTAINERS | 6 ++ drivers/misc/Kconfig | 11 +++ drivers/misc/Makefile | 1 + drivers/misc/servo-pwm.c | 149 +++++++++++++++++++++++++++++++++++++++You add sysfs files but do not document them in
Documentation/ABI/which is required. Please do so in your next version of this patch.
Quoted 5 lines
Quoted 3 lines
https://patchwork.ozlabs.org/project/linux-pwm/patch/[email protected]/
This patch [2/3] should do what you're asking.
Why was I only cc:ed on this one patch?
It looks like get_maintainers.pl only select you for some patches.
Quoted 4 lines
confused,
greg k-h
Signature · 16 lines
Angelo Compagnucci Software Engineer [email protected] __________________________________ Amarula Solutions SRL Via le Canevare 30, 31100 Treviso, Veneto, IT T. +39 (0)42 243 5310 [email protected] www.amarulasolutions.com [`as] https://www.amarulasolutions.com|
Greg Kroah-Hartman
maintainerQuoted 6 lines · Angelo Compagnucci
This patch adds a simple driver to control servo motor position via PWM signal.
The driver allows to set the angle from userspace, while min/max positions duty cycle and the motor degrees aperture are defined in the dts.
Quoted 9 lines
Signed-off-by Angelo Compagnucci <[email protected]>--- MAINTAINERS | 6 ++ drivers/misc/Kconfig | 11 +++ drivers/misc/Makefile | 1 + drivers/misc/servo-pwm.c | 149 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 167 insertions(+) create mode 100644 drivers/misc/servo-pwm.c
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree.
You are receiving this message because of the following common error(s) as indicated below:
- This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/process/submitting-patches.rst for what needs to be done here to properly describe this.
If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers.
thanks,
greg k-h's patch email bot