Skip to contentSkip to conversation

ASoC: Add NTP8918 and NTP8835 codecs support

PATCH Superseded Igor Prusov 4 participants 19 messages Jul 9, 2024 – Sep 21, 2024

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover ASoC: Add NTP8918 and NTP8835 codecs support

This series adds support for two NeoFidelity amplifiers. For both amplifiers vendor provides software for equalizer and filters configuration, which generates firmware files with registers values. Since in both cases those files have same encoding, a common helper module is added to get firmware via request_firmware() API and set registers values.

Igor Prusov (6):
dt-bindings: vendor-prefixes: Add NeoFidelity, Inc
ASoC: codecs: Add NeoFidelity Firmware helpers
ASoC: dt-bindings: Add bindings for NeoFidelity NTP8918
ASoC: codecs: Add NeoFidelity NTP8918 codec
ASoC: dt-bindings: Add bindings for NeoFidelity NTP8835
ASoC: codecs: Add NeoFidelity NTP8835 codec

 .../bindings/sound/neofidelity,ntp8835.yaml   |  65 +++
 .../bindings/sound/neofidelity,ntp8918.yaml   |  63 +++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 sound/soc/codecs/Kconfig                      |  13 +
 sound/soc/codecs/Makefile                     |   6 +
 sound/soc/codecs/ntp8835.c                    | 432 ++++++++++++++++++
 sound/soc/codecs/ntp8918.c                    | 356 +++++++++++++++
 sound/soc/codecs/ntpfw.c                      | 137 ++++++
 sound/soc/codecs/ntpfw.h                      |  23 +
 9 files changed, 1097 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/neofidelity,ntp8835.yaml
 create mode 100644 Documentation/devicetree/bindings/sound/neofidelity,ntp8918.yaml
 create mode 100644 sound/soc/codecs/ntp8835.c
 create mode 100644 sound/soc/codecs/ntp8918.c
 create mode 100644 sound/soc/codecs/ntpfw.c
 create mode 100644 sound/soc/codecs/ntpfw.h
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/6 dt-bindings: vendor-prefixes: Add NeoFidelity, Inc

Add vendor prefix for NeoFidelity, Inc

---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index fbf47f0bacf1..be62a59788b5 100644
@@ -997,6 +997,8 @@ patternProperties:
     description: National Semiconductor
   "^nec,.*":
     description: NEC LCD Technologies, Ltd.
+  "^neofidelity,.*":
+    description: Neofidelity Inc.
   "^neonode,.*":
     description: Neonode Inc.
   "^netgear,.*":
Signature · 1 line
2.34.1
#3 lore raw

PATCH 2/6 ASoC: codecs: Add NeoFidelity Firmware helpers

In reply to Igor Prusov

Add support for loading firmware for NeoFidelity amplifiers.

---
 sound/soc/codecs/Kconfig  |   3 +
 sound/soc/codecs/Makefile |   2 +
 sound/soc/codecs/ntpfw.c  | 137 ++++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/ntpfw.h  |  23 +++++++
 4 files changed, 165 insertions(+)
 create mode 100644 sound/soc/codecs/ntpfw.c
 create mode 100644 sound/soc/codecs/ntpfw.h
sound/soc/codecs/Kconfig +3 -0
index 4afc43d3f71f..9583243f1966 100644
@@ -2492,6 +2492,9 @@ config SND_SOC_NAU8825
 	tristate
 	depends on I2C
 
+config SND_SOC_NTPFW
+	tristate
+
 config SND_SOC_TPA6130A2
 	tristate "Texas Instruments TPA6130A2 headphone amplifier"
 	depends on I2C
sound/soc/codecs/Makefile +2 -0
index b4df22186e25..eae4ab047c72 100644
@@ -183,6 +183,7 @@ snd-soc-nau8821-y := nau8821.o
 snd-soc-nau8822-y := nau8822.o
 snd-soc-nau8824-y := nau8824.o
 snd-soc-nau8825-y := nau8825.o
+snd-soc-ntpfw-y := ntpfw.o
 snd-soc-hdmi-codec-y := hdmi-codec.o
 snd-soc-pcm1681-y := pcm1681.o
 snd-soc-pcm1789-codec-y := pcm1789.o
@@ -575,6 +576,7 @@ obj-$(CONFIG_SND_SOC_NAU8821)   += snd-soc-nau8821.o
 obj-$(CONFIG_SND_SOC_NAU8822)   += snd-soc-nau8822.o
 obj-$(CONFIG_SND_SOC_NAU8824)   += snd-soc-nau8824.o
 obj-$(CONFIG_SND_SOC_NAU8825)   += snd-soc-nau8825.o
+obj-$(CONFIG_SND_SOC_NTPFW)	+= snd-soc-ntpfw.o
 obj-$(CONFIG_SND_SOC_HDMI_CODEC)	+= snd-soc-hdmi-codec.o
 obj-$(CONFIG_SND_SOC_PCM1681)	+= snd-soc-pcm1681.o
 obj-$(CONFIG_SND_SOC_PCM179X)	+= snd-soc-pcm179x-codec.o
sound/soc/codecs/ntpfw.c new file +137 -0

137 lines not on this page · raw message

sound/soc/codecs/ntpfw.h new file +23 -0
new file mode 100644
index 000000000000..1cf10d5480ee
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/**
+ * ntpfw.h - Firmware helper functions for Neofidelity codecs
+ *
+ * Copyright (c) 2024, SaluteDevices. All Rights Reserved.
+ */
+
+#ifndef __NTPFW_H__
+#define __NTPFW_H__
+#include <linux/i2c.h>
+#include <linux/firmware.h>
+
+/**
+ * ntpfw_load - load firmware to amplifier over i2c interface.
+ *
+ * @i2c		Pointer to amplifier's I2C client.
+ * @name	Firmware file name.
+ * @magic	Magic number to validate firmware.
+ * @return	0 or error code upon error.
+ */
+int ntpfw_load(struct i2c_client *i2c, const char *name, const u32 magic);
+
+#endif /* __NTPFW_H__ */
Signature · 1 line
2.34.1
#4 lore raw

PATCH 3/6 ASoC: dt-bindings: Add bindings for NeoFidelity NTP8918

In reply to Igor Prusov

Add dt-bindings for NeoFidelity NTP8918 Amplifier

---
 .../bindings/sound/neofidelity,ntp8918.yaml   | 63 +++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/neofidelity,ntp8918.yaml
Documentation/devicetree/bindings/sound/neofidelity,ntp8918.yaml new file +63 -0
new file mode 100644
index 000000000000..4ca8957309d3
@@ -0,0 +1,63 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/neofidelity,ntp8918.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NeoFidelity NTP8918 Amplifier
+
+maintainers:
+  - Igor Prusov <[email protected]>
+
+description: |
+  The NTP8918 is a single chip full digital audio amplifier
+  including power stage for stereo amplifier system.
+  The NTP8918 is integrated with versatile digital audio signal
+  processing functions, high-performance, high-fidelity fully
+  digital PWM modulator and two high-power full-bridge MOSFET
+  power stages.
+
+allOf:
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+    enum:
+      - neofidelity,ntp8918
+
+  reg:
+    maxItems: 1
+    enum:
+      - 0x2a
+      - 0x2b
+      - 0x2c
+      - 0x2d
+    description: |
+      I2C address of the device.
+
+  reset-gpios:
+    maxItems: 1
+    description: GPIO used to control the state of the device.
+
+  '#sound-dai-cells':
+    enum: [0]
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+   #include <dt-bindings/gpio/gpio.h>
+   i2c {
+     #address-cells = <1>;
+     #size-cells = <0>;
+     ntp8918@54 {
+       compatible = "neofidelity,ntp8918";
+       #sound-dai-cells = <0>;
+       reg = <0x54>;
+       reset-gpios = <&gpio 5 GPIO_ACTIVE_LOW>;
+    };
+   };
Signature · 1 line
2.34.1
#5 lore raw

Re: [PATCH 3/6] ASoC: dt-bindings: Add bindings for NeoFidelity NTP8918

Quoted 8 lines · Igor Prusov

Add dt-bindings for NeoFidelity NTP8918 Amplifier

---
 .../bindings/sound/neofidelity,ntp8918.yaml   | 63 +++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/neofidelity,ntp8918.yaml

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/sound/neofidelity,ntp8918.yaml: properties:reg: 'enum' should not be valid under {'enum': ['const', 'enum', 'exclusiveMaximum', 'exclusiveMinimum', 'minimum', 'maximum', 'multipleOf', 'pattern']}
hint: Scalar and array keywords cannot be mixed
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/sound/neofidelity,ntp8918.yaml: properties:reg: 'anyOf' conditional failed, one must be fixed:
'enum' is not one of ['maxItems', 'description', 'deprecated']
hint: Only "maxItems" is required for a single entry if there are no constraints defined for the values.
Additional properties are not allowed ('enum' was unexpected)
hint: Arrays must be described with a combination of minItems/maxItems/items
'maxItems' is not one of ['description', 'deprecated', 'const', 'enum', 'minimum', 'maximum', 'multipleOf', 'default', '$ref', 'oneOf']
1 is less than the minimum of 2
hint: Arrays must be described with a combination of minItems/maxItems/items
hint: cell array properties must define how many entries and what the entries are when there is more than one entry.
from schema $id: http://devicetree.org/meta-schemas/core.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/sound/neofidelity,ntp8918.example.dtb: ntp8918@54: reg:0:0: 84 is not one of [42, 43, 44, 45]
from schema $id: http://devicetree.org/schemas/sound/neofidelity,ntp8918.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/sound/neofidelity,ntp8918.example.dtb: ntp8918@54: Unevaluated properties are not allowed ('reg' was unexpected)
from schema $id: http://devicetree.org/schemas/sound/neofidelity,ntp8918.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.

#6 lore raw

Re: [PATCH 3/6] ASoC: dt-bindings: Add bindings for NeoFidelity NTP8918

In reply to Igor Prusov
Quoted 8 lines · Igor Prusov

Add dt-bindings for NeoFidelity NTP8918 Amplifier

---
 .../bindings/sound/neofidelity,ntp8918.yaml   | 63 +++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/neofidelity,ntp8918.yaml

This looks like not tested, so limited review follows.

A nit, subject: drop second/last, redundant "bindings". The "dt-bindings" prefix is already stating that these are bindings. See also:
https://elixir.bootlin.com/linux/v6.7-rc8/source/Documentation/devicetree/bindings/submitting-patches.rst#L18

Quoted 1 line

+> +description: |

Do not need '|' unless you need to preserve formatting.

Quoted 14 lines
Documentation/devicetree/bindings/sound/neofidelity,ntp8918.yaml new file +14 -0
+  The NTP8918 is a single chip full digital audio amplifier
+  including power stage for stereo amplifier system.
+  The NTP8918 is integrated with versatile digital audio signal
+  processing functions, high-performance, high-fidelity fully
+  digital PWM modulator and two high-power full-bridge MOSFET
+  power stages.
+
+allOf:
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+    enum:
+      - neofidelity,ntp8918

Documentation/devicetree/bindings/sound/neofidelity,ntp8918.yaml line 36

Quoted 10 lines
Documentation/devicetree/bindings/sound/neofidelity,ntp8918.yaml new file +10 -0
+
+  reg:
+    maxItems: 1
+    enum:
+      - 0x2a
+      - 0x2b
+      - 0x2c
+      - 0x2d
+    description: |
+      I2C address of the device.

Drop description, redundant.

Documentation/devicetree/bindings/sound/neofidelity,ntp8918.yaml line 40

Quoted 4 lines
Documentation/devicetree/bindings/sound/neofidelity,ntp8918.yaml new file +4 -0
+
+  reset-gpios:
+    maxItems: 1
+    description: GPIO used to control the state of the device.

Drop description, redundant.

Documentation/devicetree/bindings/sound/neofidelity,ntp8918.yaml line 43

Quoted 3 lines
Documentation/devicetree/bindings/sound/neofidelity,ntp8918.yaml new file +3 -0
+
+  '#sound-dai-cells':
+    enum: [0]

That's a const

Quoted 4 lines
Documentation/devicetree/bindings/sound/neofidelity,ntp8918.yaml new file +4 -0
+
+required:
+  - compatible
+  - reg

Documentation/devicetree/bindings/sound/neofidelity,ntp8918.yaml line 57

Quoted 10 lines
Documentation/devicetree/bindings/sound/neofidelity,ntp8918.yaml new file +10 -0
+
+unevaluatedProperties: false
+
+examples:
+  - |
+   #include <dt-bindings/gpio/gpio.h>
+   i2c {
+     #address-cells = <1>;
+     #size-cells = <0>;
+     ntp8918@54 {

Node names should be generic. See also an explanation and list of examples (not exhaustive) in DT specification:
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation

Best regards,
Krzysztof

#7 lore raw

PATCH 4/6 ASoC: codecs: Add NeoFidelity NTP8918 codec

In reply to Igor Prusov

The NeoFidelity NTP8918 is a two channel amplifier with mixer and biquad filters.

Datasheet: https://datasheetspdf.com/pdf-down/N/T/P/NTP8918-NeoFidelity.pdf

---
 sound/soc/codecs/Kconfig   |   5 +
 sound/soc/codecs/Makefile  |   2 +
 sound/soc/codecs/ntp8918.c | 356 +++++++++++++++++++++++++++++++++++++
 3 files changed, 363 insertions(+)
 create mode 100644 sound/soc/codecs/ntp8918.c
sound/soc/codecs/Kconfig +5 -0
index 9583243f1966..d16c983fcb7a 100644
@@ -2495,6 +2495,11 @@ config SND_SOC_NAU8825
 config SND_SOC_NTPFW
 	tristate
 
+config SND_SOC_NTP8918
+	select SND_SOC_NTPFW
+	tristate "NeoFidelity NTP8918 amplifier"
+	depends on I2C
+
 config SND_SOC_TPA6130A2
 	tristate "Texas Instruments TPA6130A2 headphone amplifier"
 	depends on I2C
sound/soc/codecs/Makefile +2 -0
index eae4ab047c72..a49ab11a98ec 100644
@@ -183,6 +183,7 @@ snd-soc-nau8821-y := nau8821.o
 snd-soc-nau8822-y := nau8822.o
 snd-soc-nau8824-y := nau8824.o
 snd-soc-nau8825-y := nau8825.o
+snd-soc-ntp8918-y := ntp8918.o
 snd-soc-ntpfw-y := ntpfw.o
 snd-soc-hdmi-codec-y := hdmi-codec.o
 snd-soc-pcm1681-y := pcm1681.o
@@ -576,6 +577,7 @@ obj-$(CONFIG_SND_SOC_NAU8821)   += snd-soc-nau8821.o
 obj-$(CONFIG_SND_SOC_NAU8822)   += snd-soc-nau8822.o
 obj-$(CONFIG_SND_SOC_NAU8824)   += snd-soc-nau8824.o
 obj-$(CONFIG_SND_SOC_NAU8825)   += snd-soc-nau8825.o
+obj-$(CONFIG_SND_SOC_NTP8918)	+= snd-soc-ntp8918.o
 obj-$(CONFIG_SND_SOC_NTPFW)	+= snd-soc-ntpfw.o
 obj-$(CONFIG_SND_SOC_HDMI_CODEC)	+= snd-soc-hdmi-codec.o
 obj-$(CONFIG_SND_SOC_PCM1681)	+= snd-soc-pcm1681.o
sound/soc/codecs/ntp8918.c new file +356 -0

356 lines not on this page · raw message

Signature · 1 line
2.34.1
#8 lore raw

Re: [PATCH 4/6] ASoC: codecs: Add NeoFidelity NTP8918 codec

kernel test robot noticed the following build warnings:

Hi Igor,

kernel test robot noticed the following build warnings:

[auto build test WARNING on broonie-sound/for-next]
[also build test WARNING on robh/for-next linus/master v6.10-rc7 next-20240710] [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/Igor-Prusov/dt-bindings-vendor-prefixes-Add-NeoFidelity-Inc/20240710-145725
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
patch link:    https://lore.kernel.org/r/20240709172834.9785-5-ivprusov%40salutedevices.com
patch subject: [PATCH 4/6] ASoC: codecs: Add NeoFidelity NTP8918 codec
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20240711/[email protected]/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240711/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> sound/soc/codecs/ntpfw.c:14: warning: cannot understand function prototype: 'struct ntpfw_chunk '

vim +14 sound/soc/codecs/ntpfw.c

fa3c817751bfd3 Igor Prusov 2024-07-09 13

fa3c817751bfd3 Igor Prusov 2024-07-09 @14  struct ntpfw_chunk {
fa3c817751bfd3 Igor Prusov 2024-07-09  15  	__be16 length;
fa3c817751bfd3 Igor Prusov 2024-07-09  16  	u8 step;
fa3c817751bfd3 Igor Prusov 2024-07-09  17  	u8 data[];
fa3c817751bfd3 Igor Prusov 2024-07-09  18  } __packed;

fa3c817751bfd3 Igor Prusov 2024-07-09 19

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#9 lore raw

Re: [PATCH 4/6] ASoC: codecs: Add NeoFidelity NTP8918 codec

In reply to Igor Prusov
kernel test robot noticed the following build warnings:

Hi Igor,

kernel test robot noticed the following build warnings:

[auto build test WARNING on broonie-sound/for-next]
[also build test WARNING on robh/for-next linus/master v6.10-rc7 next-20240712] [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/Igor-Prusov/dt-bindings-vendor-prefixes-Add-NeoFidelity-Inc/20240710-145725
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
patch link:    https://lore.kernel.org/r/20240709172834.9785-5-ivprusov%40salutedevices.com
patch subject: [PATCH 4/6] ASoC: codecs: Add NeoFidelity NTP8918 codec
config: sh-randconfig-r111-20240712 (https://download.01.org/0day-ci/archive/20240713/[email protected]/config)
compiler: sh4-linux-gcc (GCC) 14.1.0
reproduce: (https://download.01.org/0day-ci/archive/20240713/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)

>> sound/soc/codecs/ntp8918.c:274:24: sparse: sparse: symbol 'ntp8918_dai_ops' was not declared. Should it be static?

vim +/ntp8918_dai_ops +274 sound/soc/codecs/ntp8918.c

273

 > 274	struct snd_soc_dai_ops ntp8918_dai_ops = {

275 .hw_params = ntp8918_hw_params,
276 .set_fmt = ntp8918_set_fmt,
277 };
278

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#10 lore raw

PATCH 5/6 ASoC: dt-bindings: Add bindings for NeoFidelity NTP8835

In reply to Igor Prusov

Add dt-bindings for NeoFidelity NTP8835C/NTP8835C Amplifiers

---
 .../bindings/sound/neofidelity,ntp8835.yaml   | 65 +++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/neofidelity,ntp8835.yaml
Documentation/devicetree/bindings/sound/neofidelity,ntp8835.yaml new file +65 -0
new file mode 100644
index 000000000000..6dbe0eb2e93d
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/neofidelity,ntp8835.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NeoFidelity NTP8835/NTP8835C Amplifiers
+
+maintainers:
+  - Igor Prusov <[email protected]>
+
+description: |
+  The NTP8835 is a single chip full digital audio amplifier
+  including power stages for stereo amplifier systems.
+  NTP8835 is integrated with versatile digital audio signal
+  processing functions, high-performance, high-fidelity fully
+  digital PWM modulator and two high-power full-bridge MOSFET
+  power stages. NTP8835C has identical programming interface,
+  but has different output signal characteristics.
+
+allOf:
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+    enum:
+      - neofidelity,ntp8835
+      - neofidelity,ntp8835c
+
+  reg:
+    enum:
+      - 0x2a
+      - 0x2b
+      - 0x2c
+      - 0x2d
+    maxItems: 1
+    description: |
+      I2C address of the device.
+
+  reset-gpios:
+    maxItems: 1
+    description: GPIO used to control the state of the device.
+
+  '#sound-dai-cells':
+    enum: [0]
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+   #include <dt-bindings/gpio/gpio.h>
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      ntp8835@56 {
+        compatible = "neofidelity,ntp8835";
+        #sound-dai-cells = <0>;
+        reg = <0x56>;
+        reset-gpios = <&gpio 5 GPIO_ACTIVE_LOW>;
+      };
+    };
Signature · 1 line
2.34.1
#11 lore raw

Re: [PATCH 5/6] ASoC: dt-bindings: Add bindings for NeoFidelity NTP8835

Quoted 8 lines · Igor Prusov

Add dt-bindings for NeoFidelity NTP8835C/NTP8835C Amplifiers

---
 .../bindings/sound/neofidelity,ntp8835.yaml   | 65 +++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/neofidelity,ntp8835.yaml

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/sound/neofidelity,ntp8835.yaml: properties:reg: 'enum' should not be valid under {'enum': ['const', 'enum', 'exclusiveMaximum', 'exclusiveMinimum', 'minimum', 'maximum', 'multipleOf', 'pattern']}
hint: Scalar and array keywords cannot be mixed
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/sound/neofidelity,ntp8835.yaml: properties:reg: 'anyOf' conditional failed, one must be fixed:
'enum' is not one of ['maxItems', 'description', 'deprecated']
hint: Only "maxItems" is required for a single entry if there are no constraints defined for the values.
Additional properties are not allowed ('enum' was unexpected)
hint: Arrays must be described with a combination of minItems/maxItems/items
'maxItems' is not one of ['description', 'deprecated', 'const', 'enum', 'minimum', 'maximum', 'multipleOf', 'default', '$ref', 'oneOf']
1 is less than the minimum of 2
hint: Arrays must be described with a combination of minItems/maxItems/items
hint: cell array properties must define how many entries and what the entries are when there is more than one entry.
from schema $id: http://devicetree.org/meta-schemas/core.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/sound/neofidelity,ntp8835.example.dtb: ntp8835@56: reg:0:0: 86 is not one of [42, 43, 44, 45]
from schema $id: http://devicetree.org/schemas/sound/neofidelity,ntp8835.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/sound/neofidelity,ntp8835.example.dtb: ntp8835@56: Unevaluated properties are not allowed ('reg' was unexpected)
from schema $id: http://devicetree.org/schemas/sound/neofidelity,ntp8835.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.

#12 lore raw

Re: [PATCH 5/6] ASoC: dt-bindings: Add bindings for NeoFidelity NTP8835

In reply to Igor Prusov
Quoted 5 lines · Igor Prusov

Add dt-bindings for NeoFidelity NTP8835C/NTP8835C Amplifiers

---
 .../bindings/sound/neofidelity,ntp8835.yaml   | 65 +++++++++++++++++++

No need for new schema. Just put it - after testing - into previous bindings file.

Best regards,
Krzysztof

#13 lore raw

Re: [PATCH 5/6] ASoC: dt-bindings: Add bindings for NeoFidelity NTP8835

Quoted 9 lines · Krzysztof Kozlowski
Quoted 5 lines · Igor Prusov

Add dt-bindings for NeoFidelity NTP8835C/NTP8835C Amplifiers

---
 .../bindings/sound/neofidelity,ntp8835.yaml   | 65 +++++++++++++++++++

No need for new schema. Just put it - after testing - into previous bindings file.

I am going to add some clocks in next version and there are some differences between amplifiers. 8835 uses separate master clock, 8918 is clocked by BCLK. Is it still better to use same schema with anyOf, or keep them in different files?

Quoted 4 lines

Best regards,
Krzysztof

Signature · 2 lines
Best Regards,
Igor Prusov
#14 lore raw

Re: [PATCH 5/6] ASoC: dt-bindings: Add bindings for NeoFidelity NTP8835

Quoted 8 lines · Igor Prusov
Quoted 7 lines · Krzysztof Kozlowski
Quoted 5 lines · Igor Prusov

Add dt-bindings for NeoFidelity NTP8835C/NTP8835C Amplifiers

---
 .../bindings/sound/neofidelity,ntp8835.yaml   | 65 +++++++++++++++++++
Quoted 7 lines
Quoted 2 lines

No need for new schema. Just put it - after testing - into previous bindings file.

I am going to add some clocks in next version and there are some differences between amplifiers. 8835 uses separate master clock, 8918 is clocked by BCLK. Is it still better to use same schema with anyOf, or keep them in different files?

No clue, that was 2 months ago so I don't have that email in my inbox at all.

Please post complete bindings (regardless whether driver implement it or not), so we can see the differences.

Best regards,
Krzysztof

#15 lore raw

PATCH 6/6 ASoC: codecs: Add NeoFidelity NTP8835 codec

In reply to Igor Prusov

The NeoFidelity NTP8835 adn NTP8835C are 2.1 channel amplifiers with mixer and biquad filters. Both amplifiers have identical programming interfaces but differ in output signal characteristics.

Datasheet: https://www.cpbay.com/Uploads/20210225/6037116a3ea91.pdf
Datasheet: https://www.cpbay.com/Uploads/20210918/61458b2f2631e.pdf

---
 sound/soc/codecs/Kconfig   |   5 +
 sound/soc/codecs/Makefile  |   2 +
 sound/soc/codecs/ntp8835.c | 432 +++++++++++++++++++++++++++++++++++++
 3 files changed, 439 insertions(+)
 create mode 100644 sound/soc/codecs/ntp8835.c
sound/soc/codecs/Kconfig +5 -0
index d16c983fcb7a..2235727f0d41 100644
@@ -2500,6 +2500,11 @@ config SND_SOC_NTP8918
 	tristate "NeoFidelity NTP8918 amplifier"
 	depends on I2C
 
+config SND_SOC_NTP8835
+	select SND_SOC_NTPFW
+	tristate "NeoFidelity NTP8835 and NTP8835C amplifiers"
+	depends on I2C
+
 config SND_SOC_TPA6130A2
 	tristate "Texas Instruments TPA6130A2 headphone amplifier"
 	depends on I2C
sound/soc/codecs/Makefile +2 -0
index a49ab11a98ec..49fc78bc631e 100644
@@ -183,6 +183,7 @@ snd-soc-nau8821-y := nau8821.o
 snd-soc-nau8822-y := nau8822.o
 snd-soc-nau8824-y := nau8824.o
 snd-soc-nau8825-y := nau8825.o
+snd-soc-ntp8835-y := ntp8835.o
 snd-soc-ntp8918-y := ntp8918.o
 snd-soc-ntpfw-y := ntpfw.o
 snd-soc-hdmi-codec-y := hdmi-codec.o
@@ -577,6 +578,7 @@ obj-$(CONFIG_SND_SOC_NAU8821)   += snd-soc-nau8821.o
 obj-$(CONFIG_SND_SOC_NAU8822)   += snd-soc-nau8822.o
 obj-$(CONFIG_SND_SOC_NAU8824)   += snd-soc-nau8824.o
 obj-$(CONFIG_SND_SOC_NAU8825)   += snd-soc-nau8825.o
+obj-$(CONFIG_SND_SOC_NTP8835)	+= snd-soc-ntp8835.o
 obj-$(CONFIG_SND_SOC_NTP8918)	+= snd-soc-ntp8918.o
 obj-$(CONFIG_SND_SOC_NTPFW)	+= snd-soc-ntpfw.o
 obj-$(CONFIG_SND_SOC_HDMI_CODEC)	+= snd-soc-hdmi-codec.o
sound/soc/codecs/ntp8835.c new file +432 -0

432 lines not on this page · raw message

Signature · 1 line
2.34.1
#16 lore raw

Re: [PATCH 6/6] ASoC: codecs: Add NeoFidelity NTP8835 codec

sound/soc/codecs/ntp8835.c line 12

Quoted 10 lines · Igor Prusov

The NeoFidelity NTP8835 adn NTP8835C are 2.1 channel amplifiers with mixer and biquad filters. Both amplifiers have identical programming interfaces but differ in output signal characteristics.

sound/soc/codecs/ntp8835.c new file +4 -0
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>

Where do you use moduleparam?

sound/soc/codecs/ntp8835.c line 14

Quoted 2 lines
sound/soc/codecs/ntp8835.c new file +2 -0
+#include <linux/bits.h>
+#include <linux/gpio.h>

And gpio?

sound/soc/codecs/ntp8835.c line 17

Quoted 3 lines
sound/soc/codecs/ntp8835.c new file +3 -0
+#include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>

And this?

Please clean up the driver first.

Quoted 48 lines
sound/soc/codecs/ntp8835.c new file +48 -0
+#include <linux/reset.h>
+#include <linux/init.h>
+#include <linux/i2c.h>
+#include <linux/regmap.h>
+
+#include <sound/initval.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+#include <sound/soc-component.h>
+#include <sound/tlv.h>
+
+#include "ntpfw.h"
+
+#define NTP8835_FORMATS     (SNDRV_PCM_FMTBIT_S16_LE | \
+			     SNDRV_PCM_FMTBIT_S20_3LE | \
+			     SNDRV_PCM_FMTBIT_S24_LE | \
+			     SNDRV_PCM_FMTBIT_S32_LE)
+
+#define NTP8835_INPUT_FMT			0x0
+#define  NTP8835_INPUT_FMT_MASTER_MODE		BIT(0)
+#define  NTP8835_INPUT_FMT_GSA_MODE		BIT(1)
+#define NTP8835_GSA_FMT				0x1
+#define  NTP8835_GSA_BS_MASK			GENMASK(3, 2)
+#define  NTP8835_GSA_BS(x)			((x) << 2)
+#define  NTP8835_GSA_RIGHT_J			BIT(0)
+#define  NTP8835_GSA_LSB			BIT(1)
+#define NTP8835_SOFT_MUTE			0x26
+#define  NTP8835_SOFT_MUTE_SM1			BIT(0)
+#define  NTP8835_SOFT_MUTE_SM2			BIT(1)
+#define  NTP8835_SOFT_MUTE_SM3			BIT(2)
+#define NTP8835_PWM_SWITCH			0x27
+#define  NTP8835_PWM_SWITCH_POF1		BIT(0)
+#define  NTP8835_PWM_SWITCH_POF2		BIT(1)
+#define  NTP8835_PWM_SWITCH_POF3		BIT(2)
+#define NTP8835_PWM_MASK_CTRL0			0x28
+#define  NTP8835_PWM_MASK_CTRL0_OUT_LOW		BIT(1)
+#define  NTP8835_PWM_MASK_CTRL0_FPMLD		BIT(2)
+#define NTP8835_MASTER_VOL			0x2e
+#define NTP8835_CHNL_A_VOL			0x2f
+#define NTP8835_CHNL_B_VOL			0x30
+#define NTP8835_CHNL_C_VOL			0x31
+#define REG_MAX					NTP8835_CHNL_C_VOL
+
+#define NTP8835_FW_NAME				"eq_8835.bin"
+#define NTP8835_FW_MAGIC			0x38383335	/* "8835" */
+

...

sound/soc/codecs/ntp8835.c line 136

Quoted 9 lines
sound/soc/codecs/ntp8835.c new file +9 -0
+
+static void ntp8835_reset_gpio(struct ntp8835_priv *ntp8835, bool active)
+{
+	if (active) {
+		/*
+		 * According to NTP8835 datasheet, 6.2 Timing Sequence (recommended):
+		 * Deassert for T2 >= 1ms...
+		 */
+		reset_control_deassert(ntp8835->reset);

Explain in comment why do you need to power up device to perform reset... This sounds odd.

sound/soc/codecs/ntp8835.c line 147

Quoted 11 lines
sound/soc/codecs/ntp8835.c new file +11 -0
+		fsleep(1000);
+
+		/* ...Assert for T3 >= 0.1us... */
+		reset_control_assert(ntp8835->reset);
+		fsleep(1);
+
+		/* ...Deassert, and wait for T4 >= 0.5ms before sound on sequence. */
+		reset_control_deassert(ntp8835->reset);
+		fsleep(500);
+	} else {
+		reset_control_assert(ntp8835->reset);

This function is confusing. It is supposed to perform reset and leave the device in active state, but here it leaves the device in reset.

sound/soc/codecs/ntp8835.c line 348

Quoted 2 lines
sound/soc/codecs/ntp8835.c new file +2 -0
+
+static struct snd_soc_dai_driver ntp8835_dai = {

Not const?

sound/soc/codecs/ntp8835.c line 360

Quoted 12 lines
sound/soc/codecs/ntp8835.c new file +12 -0
+	.name = "ntp8835-amplifier",
+	.playback = {
+		.stream_name = "Playback",
+		.channels_min = 1,
+		.channels_max = 3,
+		.rates = SNDRV_PCM_RATE_8000_192000,
+		.formats = NTP8835_FORMATS,
+	},
+	.ops = &ntp8835_dai_ops,
+};
+
+static struct regmap_config ntp8835_regmap = {

Not const?

Judging by weird includes and such simple issues, it looks like you try to upstream downstream or old code. That's not how you are supposed to bring new devices. You expect us to perform review on the same issues we fixed already. Work on newest drivers - take them as template - so you will not repeat the same issues we already fixed.

sound/soc/codecs/ntp8835.c line 373

Quoted 13 lines
sound/soc/codecs/ntp8835.c new file +13 -0
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = REG_MAX,
+	.cache_type = REGCACHE_MAPLE,
+};
+
+static int ntp8835_i2c_probe(struct i2c_client *i2c)
+{
+	struct ntp8835_priv *ntp8835;
+	struct regmap *regmap;
+	int ret;
+
+	ntp8835 = devm_kzalloc(&i2c->dev, sizeof(struct ntp8835_priv), GFP_KERNEL);

sizeof(*)

sound/soc/codecs/ntp8835.c line 379

Quoted 6 lines
sound/soc/codecs/ntp8835.c new file +6 -0
+	if (!ntp8835)
+		return -ENOMEM;
+
+	ntp8835->i2c = i2c;
+
+	ntp8835->reset = devm_reset_control_get_shared(&i2c->dev, NULL);

shared is on purpose?

Quoted 26 lines
sound/soc/codecs/ntp8835.c new file +26 -0
+	if (IS_ERR(ntp8835->reset))
+		return dev_err_probe(&i2c->dev, PTR_ERR(ntp8835->reset),
+				     "Failed to get reset\n");
+
+	ret = reset_control_deassert(ntp8835->reset);
+	if (ret)
+		return dev_err_probe(&i2c->dev, PTR_ERR(ntp8835->reset),
+				     "Failed to deassert reset\n");
+
+	dev_set_drvdata(&i2c->dev, ntp8835);
+
+	ntp8835_reset_gpio(ntp8835, true);
+
+	regmap = devm_regmap_init_i2c(i2c, &ntp8835_regmap);
+	if (IS_ERR(regmap))
+		return dev_err_probe(&i2c->dev, PTR_ERR(regmap),
+				     "Failed to allocate regmap\n");
+
+	ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_ntp8835,
+					      &ntp8835_dai, 1);
+	if (ret)
+		return dev_err_probe(&i2c->dev, ret,
+				     "Failed to register component\n");
+
+	return 0;
+}

sound/soc/codecs/ntp8835.c line 415

Quoted 10 lines
sound/soc/codecs/ntp8835.c new file +10 -0
+
+static const struct i2c_device_id ntp8835_i2c_id[] = {
+	{ "ntp8835", 0 },
+	{}
+};
+MODULE_DEVICE_TABLE(i2c, ntp8835_i2c_id);
+
+static const struct of_device_id ntp8835_of_match[] = {
+	{.compatible = "neofidelity,ntp8835",},
+	{.compatible = "neofidelity,ntp8835c",},

This does not match your i2c IDs, which leads to troubles when matching variants.

Anyway, aren't they compatible?

sound/soc/codecs/ntp8835.c line 424

Quoted 9 lines
sound/soc/codecs/ntp8835.c new file +9 -0
+	{}
+};
+MODULE_DEVICE_TABLE(of, ntp8835_of_match);
+
+static struct i2c_driver ntp8835_i2c_driver = {
+	.probe = ntp8835_i2c_probe,
+	.id_table = ntp8835_i2c_id,
+	.driver = {
+		.name = "NTP8835",

Driver names are lowercase

sound/soc/codecs/ntp8835.c line 432

Quoted 8 lines
sound/soc/codecs/ntp8835.c new file +8 -0
+		.of_match_table = ntp8835_of_match,
+	},
+};
+module_i2c_driver(ntp8835_i2c_driver);
+
+MODULE_AUTHOR("Igor Prusov <[email protected]>");
+MODULE_DESCRIPTION("NTP8835 Audio Amplifier Driver");
+MODULE_LICENSE("GPL");

Best regards,
Krzysztof

#17 lore raw

Re: [PATCH 6/6] ASoC: codecs: Add NeoFidelity NTP8835 codec

Hello Krzysztof,

Thank you for review and apologies for late response. I'm about to send next version with all comments addressed, just wanted to ask some questions before.

Quoted 80 lines · Krzysztof Kozlowski

sound/soc/codecs/ntp8835.c line 12

Quoted 10 lines · Igor Prusov

The NeoFidelity NTP8835 adn NTP8835C are 2.1 channel amplifiers with mixer and biquad filters. Both amplifiers have identical programming interfaces but differ in output signal characteristics.

sound/soc/codecs/ntp8835.c new file +4 -0
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>

Where do you use moduleparam?

sound/soc/codecs/ntp8835.c line 14

Quoted 2 lines
sound/soc/codecs/ntp8835.c new file +2 -0
+#include <linux/bits.h>
+#include <linux/gpio.h>

And gpio?

sound/soc/codecs/ntp8835.c line 17

Quoted 3 lines
sound/soc/codecs/ntp8835.c new file +3 -0
+#include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>

And this?

Please clean up the driver first.

Quoted 48 lines
sound/soc/codecs/ntp8835.c new file +48 -0
+#include <linux/reset.h>
+#include <linux/init.h>
+#include <linux/i2c.h>
+#include <linux/regmap.h>
+
+#include <sound/initval.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+#include <sound/soc-component.h>
+#include <sound/tlv.h>
+
+#include "ntpfw.h"
+
+#define NTP8835_FORMATS     (SNDRV_PCM_FMTBIT_S16_LE | \
+			     SNDRV_PCM_FMTBIT_S20_3LE | \
+			     SNDRV_PCM_FMTBIT_S24_LE | \
+			     SNDRV_PCM_FMTBIT_S32_LE)
+
+#define NTP8835_INPUT_FMT			0x0
+#define  NTP8835_INPUT_FMT_MASTER_MODE		BIT(0)
+#define  NTP8835_INPUT_FMT_GSA_MODE		BIT(1)
+#define NTP8835_GSA_FMT				0x1
+#define  NTP8835_GSA_BS_MASK			GENMASK(3, 2)
+#define  NTP8835_GSA_BS(x)			((x) << 2)
+#define  NTP8835_GSA_RIGHT_J			BIT(0)
+#define  NTP8835_GSA_LSB			BIT(1)
+#define NTP8835_SOFT_MUTE			0x26
+#define  NTP8835_SOFT_MUTE_SM1			BIT(0)
+#define  NTP8835_SOFT_MUTE_SM2			BIT(1)
+#define  NTP8835_SOFT_MUTE_SM3			BIT(2)
+#define NTP8835_PWM_SWITCH			0x27
+#define  NTP8835_PWM_SWITCH_POF1		BIT(0)
+#define  NTP8835_PWM_SWITCH_POF2		BIT(1)
+#define  NTP8835_PWM_SWITCH_POF3		BIT(2)
+#define NTP8835_PWM_MASK_CTRL0			0x28
+#define  NTP8835_PWM_MASK_CTRL0_OUT_LOW		BIT(1)
+#define  NTP8835_PWM_MASK_CTRL0_FPMLD		BIT(2)
+#define NTP8835_MASTER_VOL			0x2e
+#define NTP8835_CHNL_A_VOL			0x2f
+#define NTP8835_CHNL_B_VOL			0x30
+#define NTP8835_CHNL_C_VOL			0x31
+#define REG_MAX					NTP8835_CHNL_C_VOL
+
+#define NTP8835_FW_NAME				"eq_8835.bin"
+#define NTP8835_FW_MAGIC			0x38383335	/* "8835" */
+

...

Quoted 13 lines

sound/soc/codecs/ntp8835.c line 136

Quoted 9 lines
sound/soc/codecs/ntp8835.c new file +9 -0
+
+static void ntp8835_reset_gpio(struct ntp8835_priv *ntp8835, bool active)
+{
+	if (active) {
+		/*
+		 * According to NTP8835 datasheet, 6.2 Timing Sequence (recommended):
+		 * Deassert for T2 >= 1ms...
+		 */
+		reset_control_deassert(ntp8835->reset);

Explain in comment why do you need to power up device to perform reset... This sounds odd.

This sequence comes from device datasheet, for some reason vendor recommends to drive /RESET low for 0.1us during initialization. Datasheet also describes (section 6.3) init sequence with simple reset deassert, but it's called legacy, though it works fine on my board. Do you mean to add more verbose comment than linking to a datasheet?

Quoted 17 lines

sound/soc/codecs/ntp8835.c line 147

Quoted 11 lines
sound/soc/codecs/ntp8835.c new file +11 -0
+		fsleep(1000);
+
+		/* ...Assert for T3 >= 0.1us... */
+		reset_control_assert(ntp8835->reset);
+		fsleep(1);
+
+		/* ...Deassert, and wait for T4 >= 0.5ms before sound on sequence. */
+		reset_control_deassert(ntp8835->reset);
+		fsleep(500);
+	} else {
+		reset_control_assert(ntp8835->reset);

This function is confusing. It is supposed to perform reset and leave the device in active state, but here it leaves the device in reset.

Quoted 5 lines

sound/soc/codecs/ntp8835.c line 348

Quoted 2 lines
sound/soc/codecs/ntp8835.c new file +2 -0
+
+static struct snd_soc_dai_driver ntp8835_dai = {

Not const?

ntp8835_dai is passed to devm_snd_soc_register_component(), which takes non-const parameter.

Quoted 37 lines

sound/soc/codecs/ntp8835.c line 360

Quoted 12 lines
sound/soc/codecs/ntp8835.c new file +12 -0
+	.name = "ntp8835-amplifier",
+	.playback = {
+		.stream_name = "Playback",
+		.channels_min = 1,
+		.channels_max = 3,
+		.rates = SNDRV_PCM_RATE_8000_192000,
+		.formats = NTP8835_FORMATS,
+	},
+	.ops = &ntp8835_dai_ops,
+};
+
+static struct regmap_config ntp8835_regmap = {

Not const?

Judging by weird includes and such simple issues, it looks like you try to upstream downstream or old code. That's not how you are supposed to bring new devices. You expect us to perform review on the same issues we fixed already. Work on newest drivers - take them as template - so you will not repeat the same issues we already fixed.

sound/soc/codecs/ntp8835.c line 373

Quoted 13 lines
sound/soc/codecs/ntp8835.c new file +13 -0
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = REG_MAX,
+	.cache_type = REGCACHE_MAPLE,
+};
+
+static int ntp8835_i2c_probe(struct i2c_client *i2c)
+{
+	struct ntp8835_priv *ntp8835;
+	struct regmap *regmap;
+	int ret;
+
+	ntp8835 = devm_kzalloc(&i2c->dev, sizeof(struct ntp8835_priv), GFP_KERNEL);

sizeof(*)

Quoted 9 lines

sound/soc/codecs/ntp8835.c line 379

Quoted 6 lines
sound/soc/codecs/ntp8835.c new file +6 -0
+	if (!ntp8835)
+		return -ENOMEM;
+
+	ntp8835->i2c = i2c;
+
+	ntp8835->reset = devm_reset_control_get_shared(&i2c->dev, NULL);

shared is on purpose?

Yes, we have a board with two amplifiers sharing same reset line, so shared allows to work around this hardware issue. Is it the wrong approach?

Quoted 40 lines
Quoted 26 lines
sound/soc/codecs/ntp8835.c new file +26 -0
+	if (IS_ERR(ntp8835->reset))
+		return dev_err_probe(&i2c->dev, PTR_ERR(ntp8835->reset),
+				     "Failed to get reset\n");
+
+	ret = reset_control_deassert(ntp8835->reset);
+	if (ret)
+		return dev_err_probe(&i2c->dev, PTR_ERR(ntp8835->reset),
+				     "Failed to deassert reset\n");
+
+	dev_set_drvdata(&i2c->dev, ntp8835);
+
+	ntp8835_reset_gpio(ntp8835, true);
+
+	regmap = devm_regmap_init_i2c(i2c, &ntp8835_regmap);
+	if (IS_ERR(regmap))
+		return dev_err_probe(&i2c->dev, PTR_ERR(regmap),
+				     "Failed to allocate regmap\n");
+
+	ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_ntp8835,
+					      &ntp8835_dai, 1);
+	if (ret)
+		return dev_err_probe(&i2c->dev, ret,
+				     "Failed to register component\n");
+
+	return 0;
+}

sound/soc/codecs/ntp8835.c line 415

Quoted 10 lines
sound/soc/codecs/ntp8835.c new file +10 -0
+
+static const struct i2c_device_id ntp8835_i2c_id[] = {
+	{ "ntp8835", 0 },
+	{}
+};
+MODULE_DEVICE_TABLE(i2c, ntp8835_i2c_id);
+
+static const struct of_device_id ntp8835_of_match[] = {
+	{.compatible = "neofidelity,ntp8835",},
+	{.compatible = "neofidelity,ntp8835c",},

This does not match your i2c IDs, which leads to troubles when matching variants.

Quoted 3 lines

Anyway, aren't they compatible?

They have identical programming interface and only differ in some output signal characteristics. Is it OK use single compatible string in such case?

Quoted 24 lines

sound/soc/codecs/ntp8835.c line 424

Quoted 9 lines
sound/soc/codecs/ntp8835.c new file +9 -0
+	{}
+};
+MODULE_DEVICE_TABLE(of, ntp8835_of_match);
+
+static struct i2c_driver ntp8835_i2c_driver = {
+	.probe = ntp8835_i2c_probe,
+	.id_table = ntp8835_i2c_id,
+	.driver = {
+		.name = "NTP8835",

Driver names are lowercase

sound/soc/codecs/ntp8835.c line 432

Quoted 8 lines
sound/soc/codecs/ntp8835.c new file +8 -0
+		.of_match_table = ntp8835_of_match,
+	},
+};
+module_i2c_driver(ntp8835_i2c_driver);
+
+MODULE_AUTHOR("Igor Prusov <[email protected]>");
+MODULE_DESCRIPTION("NTP8835 Audio Amplifier Driver");
+MODULE_LICENSE("GPL");

Best regards,
Krzysztof

Signature · 2 lines
Best Regards,
Igor Prusov
#18 lore raw

Re: [PATCH 6/6] ASoC: codecs: Add NeoFidelity NTP8835 codec

Quoted 16 lines · Igor Prusov
Quoted 15 lines

sound/soc/codecs/ntp8835.c line 136

Quoted 11 lines
sound/soc/codecs/ntp8835.c new file +9 -0
+
+static void ntp8835_reset_gpio(struct ntp8835_priv *ntp8835, bool active)
+{
+	if (active) {
+		/*
+		 * According to NTP8835 datasheet, 6.2 Timing Sequence (recommended):
+		 * Deassert for T2 >= 1ms...
+		 */
+		reset_control_deassert(ntp8835->reset);

Explain in comment why do you need to power up device to perform reset... This sounds odd.

Quoted 5 lines

This sequence comes from device datasheet, for some reason vendor recommends to drive /RESET low for 0.1us during initialization. Datasheet also describes (section 6.3) init sequence with simple reset deassert, but it's called legacy, though it works fine on my board. Do you mean to add more verbose comment than linking to a datasheet?

I think verbose comment would be better.

Quoted 18 lines
Quoted 18 lines

sound/soc/codecs/ntp8835.c line 147

Quoted 12 lines
sound/soc/codecs/ntp8835.c new file +11 -0
+		fsleep(1000);
+
+		/* ...Assert for T3 >= 0.1us... */
+		reset_control_assert(ntp8835->reset);
+		fsleep(1);
+
+		/* ...Deassert, and wait for T4 >= 0.5ms before sound on sequence. */
+		reset_control_deassert(ntp8835->reset);
+		fsleep(500);
+	} else {
+		reset_control_assert(ntp8835->reset);

This function is confusing. It is supposed to perform reset and leave the device in active state, but here it leaves the device in reset.

Quoted 8 lines
Quoted 5 lines

sound/soc/codecs/ntp8835.c line 348

Quoted 2 lines
sound/soc/codecs/ntp8835.c new file +2 -0
+
+static struct snd_soc_dai_driver ntp8835_dai = {

Not const?

ntp8835_dai is passed to devm_snd_soc_register_component(), which takes non-const parameter.

Right, indeed.

Quoted 48 lines
Quoted 38 lines

sound/soc/codecs/ntp8835.c line 360

Quoted 13 lines
sound/soc/codecs/ntp8835.c new file +12 -0
+	.name = "ntp8835-amplifier",
+	.playback = {
+		.stream_name = "Playback",
+		.channels_min = 1,
+		.channels_max = 3,
+		.rates = SNDRV_PCM_RATE_8000_192000,
+		.formats = NTP8835_FORMATS,
+	},
+	.ops = &ntp8835_dai_ops,
+};
+
+static struct regmap_config ntp8835_regmap = {

Not const?

Judging by weird includes and such simple issues, it looks like you try to upstream downstream or old code. That's not how you are supposed to bring new devices. You expect us to perform review on the same issues we fixed already. Work on newest drivers - take them as template - so you will not repeat the same issues we already fixed.

sound/soc/codecs/ntp8835.c line 373

Quoted 13 lines
sound/soc/codecs/ntp8835.c new file +13 -0
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = REG_MAX,
+	.cache_type = REGCACHE_MAPLE,
+};
+
+static int ntp8835_i2c_probe(struct i2c_client *i2c)
+{
+	struct ntp8835_priv *ntp8835;
+	struct regmap *regmap;
+	int ret;
+
+	ntp8835 = devm_kzalloc(&i2c->dev, sizeof(struct ntp8835_priv), GFP_KERNEL);

sizeof(*)

Quoted 9 lines

sound/soc/codecs/ntp8835.c line 379

Quoted 6 lines
sound/soc/codecs/ntp8835.c new file +6 -0
+	if (!ntp8835)
+		return -ENOMEM;
+
+	ntp8835->i2c = i2c;
+
+	ntp8835->reset = devm_reset_control_get_shared(&i2c->dev, NULL);

shared is on purpose?

Quoted 3 lines

Yes, we have a board with two amplifiers sharing same reset line, so shared allows to work around this hardware issue. Is it the wrong approach?

No, it's ok, I just want to be sure you added this consciously.

Quoted 41 lines
Quoted 41 lines
Quoted 27 lines
sound/soc/codecs/ntp8835.c new file +26 -0
+	if (IS_ERR(ntp8835->reset))
+		return dev_err_probe(&i2c->dev, PTR_ERR(ntp8835->reset),
+				     "Failed to get reset\n");
+
+	ret = reset_control_deassert(ntp8835->reset);
+	if (ret)
+		return dev_err_probe(&i2c->dev, PTR_ERR(ntp8835->reset),
+				     "Failed to deassert reset\n");
+
+	dev_set_drvdata(&i2c->dev, ntp8835);
+
+	ntp8835_reset_gpio(ntp8835, true);
+
+	regmap = devm_regmap_init_i2c(i2c, &ntp8835_regmap);
+	if (IS_ERR(regmap))
+		return dev_err_probe(&i2c->dev, PTR_ERR(regmap),
+				     "Failed to allocate regmap\n");
+
+	ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_ntp8835,
+					      &ntp8835_dai, 1);
+	if (ret)
+		return dev_err_probe(&i2c->dev, ret,
+				     "Failed to register component\n");
+
+	return 0;
+}

sound/soc/codecs/ntp8835.c line 415

Quoted 10 lines
sound/soc/codecs/ntp8835.c new file +10 -0
+
+static const struct i2c_device_id ntp8835_i2c_id[] = {
+	{ "ntp8835", 0 },
+	{}
+};
+MODULE_DEVICE_TABLE(i2c, ntp8835_i2c_id);
+
+static const struct of_device_id ntp8835_of_match[] = {
+	{.compatible = "neofidelity,ntp8835",},
+	{.compatible = "neofidelity,ntp8835c",},

This does not match your i2c IDs, which leads to troubles when matching variants.

Quoted 7 lines
Quoted 3 lines

Anyway, aren't they compatible?

They have identical programming interface and only differ in some output signal characteristics. Is it OK use single compatible string in such case?

Driver should have one compatible (and one entry in i2c device ID). You add the second in the bindings as one followed by fallback. Like this:
https://elixir.bootlin.com/linux/v6.3-rc6/source/Documentation/devicetree/bindings/sound/nvidia,tegra210-ope.yaml#L31

Best regards,
Krzysztof