Skip to contentSkip to conversation

ASoC: codecs: Add support for FourSemi FS2104/5S

PATCH Superseded Nick 3 participants 8 messages Jul 18, 2025 – Jul 21, 2025

Subsystems (4)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Nick

author maintainer
#0 lore raw

v3 cover ASoC: codecs: Add support for FourSemi FS2104/5S

v2 -> v3:
.../foursemi,fs2105s.yaml(patch 0002)
- Drop "schema for " in the patch subject
- Delete the description of the property reg
- Restore the property clocks to v1
- Keep the same order as in list of properties

.../Kconfig(patch 0004)
- Write the help of config symbol with at least 4 lines

.../fs210x.c/h(patch 0004)
- Update entries comment to C++ style
- Use linux/gpio/consumer.h instead of linux/of_gpio.h
- Use a private lock instead of a global one
- Delete driver version and log
- Drop checking of pval in fs210x_reg_read
- Drop most of the debug logs and unused codes
- Drop registers dumping in monitor
- Use fsleep instead of usleep_range
- Update mixer to a standard control:
PCM Playback Volume
- Add 2 new standard controls:
DAC Mute Switch: Mute/Unmute
DAC Fade Switch: Fade enable/disable
- Fix errors reported by mixer-test in mixer:
Effect Scene
- Integrate the operation of reset(sdz) pin into chip init/reset
- Add DAPM event for playback:
Start/stop device in DAPM instead of mute_stream Start/stop delay works in mute_stream only
- Drop use_pmdown_time in component driver for DAPM event
- Add dai ops startup:
Report format&sample rates in constraints
- Add dai ops trigger:
Start device in trigger when we can't obtain/control the bclk clock
- Use description words: PROVIDER, comsumer
- Add a sysfs node for monitor period(fs210x->check_interval_ms)
- Do the initialisations of delayed works and clock in i2c probe
- Prevent new work after the device is suspended
- Update regmap cache type to MAPLE
Define volatile registers
- Simplify the logic of getting and setting clock
- Simplify the logic of getting and setting reset gpio
- Use dev_err_probe for error logs
- Remove fs210x_parse_platdata and use fs210x_parse_dts in fs210x_init
- Drop null checking for regmap in i2c probe
- Add a suffix(instances id) to dai name
- Drop compatible of "foursemi,fs2104"
- Drop ifdef CONFIG_OF and of_match_ptr

Nick Li (4):
dt-bindings: vendor-prefixes: Add Shanghai FourSemi Semiconductor

    Co.,Ltd

ASoC: dt-bindings: Add FS2104/5S audio amplifiers
ASoC: codecs: Add library for FourSemi audio amplifiers
ASoC: codecs: Add FourSemi FS2104/5S audio amplifier driver

 .../bindings/sound/foursemi,fs2105s.yaml      |   99 ++
 .../devicetree/bindings/vendor-prefixes.yaml  |    2 +
 sound/soc/codecs/Kconfig                      |   14 +
 sound/soc/codecs/Makefile                     |    4 +
 sound/soc/codecs/fs-amp-lib.c                 |  265 +++
 sound/soc/codecs/fs-amp-lib.h                 |  150 ++
 sound/soc/codecs/fs210x.c                     | 1574 +++++++++++++++++
 sound/soc/codecs/fs210x.h                     |   75 +
 8 files changed, 2183 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/foursemi,fs2105s.yaml
 create mode 100644 sound/soc/codecs/fs-amp-lib.c
 create mode 100644 sound/soc/codecs/fs-amp-lib.h
 create mode 100644 sound/soc/codecs/fs210x.c
 create mode 100644 sound/soc/codecs/fs210x.h

base-commit: ed73a24357531e1747a6e140c329015da6429629

Signature · 1 line
2.39.5
author maintainer
#1 lore raw

PATCH v3 1/4 dt-bindings: vendor-prefixes: Add Shanghai FourSemi Semiconductor Co.,Ltd

From: Nick Li <[email protected]>

Add vendor prefix for Shanghai FourSemi Semiconductor Co.,Ltd

---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index 99e86271c..f692e3b29 100644
@@ -547,6 +547,8 @@ patternProperties:
     description: FocalTech Systems Co.,Ltd
   "^forlinx,.*":
     description: Baoding Forlinx Embedded Technology Co., Ltd.
+  "^foursemi,.*":
+    description: Shanghai FourSemi Semiconductor Co.,Ltd.
   "^freebox,.*":
     description: Freebox SAS
   "^freecom,.*":
Signature · 1 line
2.39.5
maintainer
#2 lore raw

Re: [PATCH v3 1/4] dt-bindings: vendor-prefixes: Add Shanghai FourSemi Semiconductor Co.,Ltd

Quoted 6 lines · Nick

From: Nick Li <[email protected]>

Add vendor prefix for Shanghai FourSemi Semiconductor Co.,Ltd

You are missing Krzysztof's Reviewed-by.

Quoted 3 lines
---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)
author maintainer
#3 lore raw

PATCH v3 2/4 ASoC: dt-bindings: Add FS2104/5S audio amplifiers

In reply to Nick

From: Nick Li <[email protected]>

Add a DT schema for describing FourSemi FS2104/5S audio amplifiers which support both I2S and I2C interface.

---
 .../bindings/sound/foursemi,fs2105s.yaml      | 99 +++++++++++++++++++
 1 file changed, 99 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/foursemi,fs2105s.yaml
Documentation/devicetree/bindings/sound/foursemi,fs2105s.yaml new file +99 -0
new file mode 100644
index 000000000..7391c404a
@@ -0,0 +1,99 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/foursemi,fs2105s.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: FourSemi FS2104/5S Digital Audio Amplifier
+
+maintainers:
+  - Nick Li <[email protected]>
+
+description:
+  The FS2104 is a 15W Inductor-Less, Stereo, Closed-Loop,
+  Digital Input Class-D Power Amplifier with Enhanced Signal Processing.
+  The FS2105S is a 30W Inductor-Less, Stereo, Closed-Loop,
+  Digital Input Class-D Power Amplifier with Enhanced Signal Processing.
+
+properties:
+  compatible:
+    oneOf:
+      - items:
+          - enum:
+              - foursemi,fs2104
+          - const: foursemi,fs2105s
+      - enum:
+          - foursemi,fs2105s
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: The clock of I2S BCLK
+
+  clock-names:
+    items:
+      - const: bclk
+
+  interrupts:
+    maxItems: 1
+
+  '#sound-dai-cells':
+    const: 0
+
+  pvdd-supply:
+    description:
+      Regulator for power supply(PVDD in datasheet).
+
+  dvdd-supply:
+    description:
+      Regulator for digital supply(DVDD in datasheet).
+
+  reset-gpios:
+    maxItems: 1
+    description:
+      It's the SDZ pin in datasheet, the pin is active low,
+      it will power down and reset the chip to shut down state.
+
+  firmware-name:
+    maxItems: 1
+    description: |
+      The firmware(*.bin) contains:
+      a. Register initialization settings
+      b. DSP effect parameters
+      c. Multi-scene sound effect configurations(optional)
+      It's gernerated by FourSemi's tuning tool.
+
+required:
+  - compatible
+  - reg
+  - '#sound-dai-cells'
+  - reset-gpios
+  - firmware-name
+
+allOf:
+  - $ref: dai-common.yaml#
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        audio-codec@68 {
+            compatible = "foursemi,fs2105s";
+            reg = <0x68>;
+            clocks = <&clocks 18>;
+            clock-names = "bclk";
+            #sound-dai-cells = <0>;
+            pvdd-supply = <&pvdd_supply>;
+            dvdd-supply = <&dvdd_supply>;
+            reset-gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
+            firmware-name = "fs2105s-btl-2p0-0s.bin";
+            pinctrl-names = "default";
+            pinctrl-0 = <&fs210x_pins_default>;
+        };
+    };
Signature · 1 line
2.39.5
maintainer Reviewed-by on v3 2/4
#4 lore raw

Re: [PATCH v3 2/4] ASoC: dt-bindings: Add FS2104/5S audio amplifiers

Quoted 11 lines · Nick

From: Nick Li <[email protected]>

Add a DT schema for describing FourSemi FS2104/5S audio amplifiers which support both I2S and I2C interface.

---
 .../bindings/sound/foursemi,fs2105s.yaml      | 99 +++++++++++++++++++
 1 file changed, 99 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/foursemi,fs2105s.yaml
author maintainer
#5 lore raw

PATCH v3 3/4 ASoC: codecs: Add library for FourSemi audio amplifiers

In reply to Nick

From: Nick Li <[email protected]>

This patch adds firmware loading and parsing support for FourSemi audio amplifiers. The library handles firmware file (*.bin) generated by the FourSemi tuning tool, which contains:
- Register initialization settings
- DSP effect parameters
- Multi-scene sound effect switching configurations(optional)

The firmware is required for proper initialization and configuration of FourSemi amplifier devices.

---
 sound/soc/codecs/Kconfig      |   3 +
 sound/soc/codecs/Makefile     |   2 +
 sound/soc/codecs/fs-amp-lib.c | 265 ++++++++++++++++++++++++++++++++++
 sound/soc/codecs/fs-amp-lib.h | 150 +++++++++++++++++++
 4 files changed, 420 insertions(+)
 create mode 100644 sound/soc/codecs/fs-amp-lib.c
 create mode 100644 sound/soc/codecs/fs-amp-lib.h
sound/soc/codecs/Kconfig +3 -0
index 4494e7cd6..6265cc897 100644
@@ -1238,6 +1238,9 @@ config SND_SOC_FRAMER
 	  To compile this driver as a module, choose M here: the module
 	  will be called snd-soc-framer.
 
+config SND_SOC_FS_AMP_LIB
+	select CRC16
+	tristate
 
 config SND_SOC_GTM601
 	tristate 'GTM601 UMTS modem audio codec'
sound/soc/codecs/Makefile +2 -0
index c497d343d..9afce9aa6 100644
@@ -137,6 +137,7 @@ snd-soc-es8328-spi-y := es8328-spi.o
 snd-soc-es8375-y := es8375.o
 snd-soc-es8389-y := es8389.o
 snd-soc-framer-y := framer-codec.o
+snd-soc-fs-amp-lib-y := fs-amp-lib.o
 snd-soc-gtm601-y := gtm601.o
 snd-soc-hdac-hdmi-y := hdac_hdmi.o
 snd-soc-hdac-hda-y := hdac_hda.o
@@ -561,6 +562,7 @@ obj-$(CONFIG_SND_SOC_ES8328_SPI)+= snd-soc-es8328-spi.o
 obj-$(CONFIG_SND_SOC_ES8375)    += snd-soc-es8375.o
 obj-$(CONFIG_SND_SOC_ES8389)    += snd-soc-es8389.o
 obj-$(CONFIG_SND_SOC_FRAMER)	+= snd-soc-framer.o
+obj-$(CONFIG_SND_SOC_FS_AMP_LIB)+= snd-soc-fs-amp-lib.o
 obj-$(CONFIG_SND_SOC_GTM601)    += snd-soc-gtm601.o
 obj-$(CONFIG_SND_SOC_HDAC_HDMI) += snd-soc-hdac-hdmi.o
 obj-$(CONFIG_SND_SOC_HDAC_HDA) += snd-soc-hdac-hda.o
sound/soc/codecs/fs-amp-lib.c new file +265 -0

265 lines not on this page · raw message

sound/soc/codecs/fs-amp-lib.h new file +150 -0

150 lines not on this page · raw message

Signature · 1 line
2.39.5
author maintainer
#6 lore raw

PATCH v3 4/4 ASoC: codecs: Add FourSemi FS2104/5S audio amplifier driver

In reply to Nick

From: Nick Li <[email protected]>

The FS2104/5S are FourSemi digital audio amplifiers
with I2C control. They are Inductor-Less, Stereo, Closed-Loop, Digital Input Class-D Power Amplifiers with Enhanced Signal Processing.

---
 sound/soc/codecs/Kconfig  |   13 +
 sound/soc/codecs/Makefile |    2 +
 sound/soc/codecs/fs210x.c | 1583 +++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/fs210x.h |   75 ++
 4 files changed, 1673 insertions(+)
 create mode 100644 sound/soc/codecs/fs210x.c
 create mode 100644 sound/soc/codecs/fs210x.h
sound/soc/codecs/Kconfig +13 -0
index 6265cc897..8c85f3dbb 100644
@@ -125,6 +125,7 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_ES7134
 	imply SND_SOC_ES7241
 	imply SND_SOC_FRAMER
+	imply SND_SOC_FS210X
 	imply SND_SOC_GTM601
 	imply SND_SOC_HDAC_HDMI
 	imply SND_SOC_HDAC_HDA
@@ -1242,6 +1243,18 @@ config SND_SOC_FS_AMP_LIB
 	select CRC16
 	tristate
 
+config SND_SOC_FS210X
+	tristate 'FourSemi FS2104/5S digital audio amplifier'
+	depends on I2C
+	select GPIOLIB
+	select REGMAP_I2C
+	select SND_SOC_FS_AMP_LIB
+	help
+	  Enable support for FourSemi FS2104/5S digital audio amplifier.
+	  The FS2104/5S are Inductor-Less, Stereo, Closed-Loop,
+	  Digital Input Class-D Power Amplifiers with Enhanced Signal Processing.
+	  The amplifiers support I2C and I2S/TDM.
+
 config SND_SOC_GTM601
 	tristate 'GTM601 UMTS modem audio codec'
 
sound/soc/codecs/Makefile +2 -0
index 9afce9aa6..967e939a4 100644
@@ -138,6 +138,7 @@ snd-soc-es8375-y := es8375.o
 snd-soc-es8389-y := es8389.o
 snd-soc-framer-y := framer-codec.o
 snd-soc-fs-amp-lib-y := fs-amp-lib.o
+snd-soc-fs210x-y := fs210x.o
 snd-soc-gtm601-y := gtm601.o
 snd-soc-hdac-hdmi-y := hdac_hdmi.o
 snd-soc-hdac-hda-y := hdac_hda.o
@@ -563,6 +564,7 @@ obj-$(CONFIG_SND_SOC_ES8375)    += snd-soc-es8375.o
 obj-$(CONFIG_SND_SOC_ES8389)    += snd-soc-es8389.o
 obj-$(CONFIG_SND_SOC_FRAMER)	+= snd-soc-framer.o
 obj-$(CONFIG_SND_SOC_FS_AMP_LIB)+= snd-soc-fs-amp-lib.o
+obj-$(CONFIG_SND_SOC_FS210X)	+= snd-soc-fs210x.o
 obj-$(CONFIG_SND_SOC_GTM601)    += snd-soc-gtm601.o
 obj-$(CONFIG_SND_SOC_HDAC_HDMI) += snd-soc-hdac-hdmi.o
 obj-$(CONFIG_SND_SOC_HDAC_HDA) += snd-soc-hdac-hda.o
sound/soc/codecs/fs210x.c new file +1583 -0

1,583 lines not on this page · raw message

sound/soc/codecs/fs210x.h new file +75 -0

75 lines not on this page · raw message

Signature · 1 line
2.39.5
#7 lore raw

Re: [PATCH v3 4/4] ASoC: codecs: Add FourSemi FS2104/5S audio amplifier driver

kernel test robot noticed the following build warnings:

Hi Nick,

kernel test robot noticed the following build warnings:

[auto build test WARNING on ed73a24357531e1747a6e140c329015da6429629]

url:    https://github.com/intel-lab-lkp/linux/commits/Nick/dt-bindings-vendor-prefixes-Add-Shanghai-FourSemi-Semiconductor-Co-Ltd/20250718-201609
base:   ed73a24357531e1747a6e140c329015da6429629
patch link:    https://lore.kernel.org/r/20250718121221.76957-5-nick.li%40foursemi.com
patch subject: [PATCH v3 4/4] ASoC: codecs: Add FourSemi FS2104/5S audio amplifier driver
config: i386-buildonly-randconfig-004-20250719 (https://download.01.org/0day-ci/archive/20250719/[email protected]/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250719/[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/fs210x.c:1086:2: warning: variable 'ret' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
    1086 |         default:
         |         ^~~~~~~
   sound/soc/codecs/fs210x.c:1092:9: note: uninitialized use occurs here
    1092 |         return ret;
         |                ^~~
>> sound/soc/codecs/fs210x.c:1077:7: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
    1077 |                 if (!fs210x->clk_bclk)
         |                     ^~~~~~~~~~~~~~~~~
   sound/soc/codecs/fs210x.c:1092:9: note: uninitialized use occurs here
    1092 |         return ret;
         |                ^~~
   sound/soc/codecs/fs210x.c:1077:3: note: remove the 'if' if its condition is always false
    1077 |                 if (!fs210x->clk_bclk)
         |                 ^~~~~~~~~~~~~~~~~~~~~~
    1078 |                         break;
         |                         ~~~~~
   sound/soc/codecs/fs210x.c:1062:9: note: initialize the variable 'ret' to silence this warning
    1062 |         int ret;
         |                ^
         |                 = 0

2 warnings generated.

vim +/ret +1086 sound/soc/codecs/fs210x.c

1056
1057 static int fs210x_playback_event(struct snd_soc_dapm_widget *w,
1058 struct snd_kcontrol *kc, int event)
1059 {
1060 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm);
1061 struct fs210x_priv *fs210x = snd_soc_component_get_drvdata(cmpnt);
1062 int ret;
1063
1064 mutex_lock(&fs210x->lock);
1065
1066 if (fs210x->is_suspended) {
1067 mutex_unlock(&fs210x->lock);
1068 return 0;
1069 }
1070
1071 switch (event) {
1072 case SND_SOC_DAPM_PRE_PMU:
1073 /*
1074 * If there is no bclk for us to set the clock output,
1075 * we will enable the device(start_work) in dai trigger.
1076 */

> 1077			if (!fs210x->clk_bclk)
  1078				break;
  1079			fs210x_bclk_set(fs210x, true);
  1080			ret = fs210x_dev_play(fs210x);
  1081			break;
  1082		case SND_SOC_DAPM_POST_PMD:
  1083			ret = fs210x_dev_stop(fs210x);
  1084			fs210x_bclk_set(fs210x, false);
  1085			break;
> 1086		default:

1087 break;
1088 }
1089
1090 mutex_unlock(&fs210x->lock);
1091
1092 return ret;
1093 }
1094

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