Skip to content

Comments

Restore RK3308 Ethernet and audio functionality#9413

Merged
brentr merged 2 commits intoarmbian:mainfrom
brentr:restoreRK3308patches
Feb 18, 2026
Merged

Restore RK3308 Ethernet and audio functionality#9413
brentr merged 2 commits intoarmbian:mainfrom
brentr:restoreRK3308patches

Conversation

@brentr
Copy link
Collaborator

@brentr brentr commented Feb 18, 2026

Description

@EvilOlaf
Recent commits into rockchip64-6.19 have broken caused the following problems:

  1. 10Mbit Ethernet fails to connect on the SOC's NIC
  2. The SOC's analog codec is no longer recognized

This patch reverts 32f3b7c
to restore proper 10Mbit Ethernet
It also reverts 8002936
as this feature adds <100 bytes to the kernel to aid in debug of GPIO drive issues

Getting the analog audio to compile under the 6.19 kernel required only minimal edits to the existing RK3308 vendor acodec patch. Many other acodec drivers were similarly effected.
As with the others, the removed snd_soc_kcontrol_component() was simply replaced with
snd_kcontrol_chip() This may not be the "best" solution, but there are many other drivers in the kernel that have taken this approach. It's still my hope that this vendor driver will eventually disappear. Unfortunately, the upstream driver STILL lacks support for the variant of the RK3308 used by all Radaxa boards.

GitHub issue reference:
Jira reference number [AR-9999]

How Has This Been Tested?

Built "edge" image with Debian trixie for a v1.3 Radxa RockPI-S
Verify 10Mbit Ethernet failed beforehand, but works with this patch.
Similarly verified missing audio beforehand, but works after this patch.

Checklist:

Please delete options that are not relevant.

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

Summary by CodeRabbit

  • Bug Fixes
    • RK3308 audio codec driver updated for kernel 6.19 compatibility with improved vendor implementation
    • Enhanced ADC/DAC register handling and audio filter configurations
    • License updated to GPL v2

and 8002936
because:
The ...fix-10mbit-ethernet patch is still necessary
Without it, the RK3308 does not connect via DHCP to 10-mbit Ethernets

The ...pinctl-slow-mux patch still compiles without error
It is <100 bytes and helps debugging GPIO issues.

I don't understand why above patches were flagged as "broken"
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

📝 Walkthrough

Walkthrough

This patch reverts the RK3308 Acodec driver to vendor code for kernel 6.19, updating the codec driver implementation, switching kernel control access patterns, refreshing register definitions and configurations, and introducing a new public provider header. Module licensing updated from "GPL" to "GPL v2".

Changes

Cohort / File(s) Summary
Codec Driver Core
sound/soc/codecs/rk3308_codec.c, sound/soc/codecs/rk3308_codec.h
Large-scale refactoring reverting to vendor implementation: replaced snd_soc_kcontrol_component with snd_kcontrol_chip for control access patterns, updated ADC/DAC register handling, I2S mode and HPF configurations, refreshed bitfield definitions and constants, changed MODULE_LICENSE from "GPL" to "GPL v2".
New Public API
sound/soc/codecs/rk3308_codec_provider.h
New public header introduced to expand provider API exposure.
Device Tree Bindings
arch/dts/...rk3308...dtsi
Updated codec node structure (codec@ff560000 block) and related braces to reflect binding changes and controller structure adjustments.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 The codec hops back home today,
To vendor ways, the old-time way,
With controls reborn and patterns renewed,
GPL v2's now in the mood,
Fresh registers dance, the driver's rerouted! 🎵

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title mentions 'Ethernet and audio functionality' but the changeset only contains audio codec driver changes. Ethernet functionality is not addressed in the provided patch file. Update the title to focus on the actual changes: e.g., 'Restore RK3308 audio codec functionality for kernel 6.19' or check if Ethernet changes are included in other files not shown in the summary.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added Needs review Seeking for review Hardware Hardware related like kernel, U-Boot, ... Patches Patches related to kernel, U-Boot, ... labels Feb 18, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
patch/kernel/archive/rockchip64-6.19/rk3308-acodec-vendor-driver.patch (3)

5054-5075: ⚠️ Potential issue | 🟡 Minor

Add bounds checks in sysfs adc_grps_store.
Line 5071/5074 accept arbitrary values and can push used_adc_grps or loopback_grp beyond array bounds, risking OOB access in later loops.

🔧 Proposed fix
 	if (adc_type == 'n')
-		rk3308->used_adc_grps = grps;
-	else if (adc_type == 'l')
-		rk3308->loopback_grp = grps;
+	{
+		if (grps < 1 || grps > ADC_LR_GROUP_MAX)
+			return -EINVAL;
+		rk3308->used_adc_grps = grps;
+	}
+	else if (adc_type == 'l')
+	{
+		if (grps != NOT_USED &&
+		    (grps < 0 || grps >= ADC_LR_GROUP_MAX))
+			return -EINVAL;
+		rk3308->loopback_grp = grps;
+	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@patch/kernel/archive/rockchip64-6.19/rk3308-acodec-vendor-driver.patch`
around lines 5054 - 5075, The sysfs setter adc_grps_store parses adc_type and
grps into rk3308->used_adc_grps or rk3308->loopback_grp without bounds checking,
allowing OOB indices later; update adc_grps_store (in struct rk3308_codec_priv
context) to validate that grps is within the valid range (e.g., 0 <= grps <
MAX_ADC_GRPS or <= ARRAY_SIZE(whatever array) - 1) before assigning, return
-EINVAL on invalid input and log a clear dev_err including the bad value and
expected range; also handle non-recognized adc_type by returning -EINVAL.

3249-3262: ⚠️ Potential issue | 🟠 Major

Fix DAC ramp-down sequence (wrong register & range).
Line 3249 uses ADC register/mask and loops to 0x7f, but the comment and power-on path indicate DAC_ANA_CON14[3:0] should ramp 0x1→0xf. As written, DAC VCM won’t ramp down correctly for version B and ADC gets touched instead.

🔧 Proposed fix
-		for (v = 0x1; v <= 0x7f; v++) {
-			regmap_update_bits(rk3308->regmap,
-					   RK3308_ADC_ANA_CON10(0),
-					   RK3308_ADC_CURRENT_CHARGE_MSK,
-					   v);
+		for (v = 0x1; v <= 0xf; v++) {
+			regmap_update_bits(rk3308->regmap,
+					   RK3308_DAC_ANA_CON14,
+					   RK3308_DAC_CURRENT_CHARGE_MSK,
+					   v);
 			udelay(200);
 		}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@patch/kernel/archive/rockchip64-6.19/rk3308-acodec-vendor-driver.patch`
around lines 3249 - 3262, The ramp-down loop for rk3308 version B is writing the
ADC register and using ADC mask; change the loop to target the DAC register and
mask and constrain the range to 0x1→0xf: replace RK3308_ADC_ANA_CON10 and
RK3308_ADC_CURRENT_CHARGE_MSK used in regmap_update_bits with the DAC
equivalents (e.g. RK3308_DAC_ANA_CON14 and the DAC VCM mask constant) and
iterate v from 0x1 to 0xf (keeping the udelay(200) per step) so the DAC VCM is
ramped correctly for codec_ver == ACODEC_VERSION_B while leaving the surrounding
logic unchanged.

5919-5928: ⚠️ Potential issue | 🟠 Major

Cancel delayed work + clear exported callback on remove.
Line 5919 removes the platform driver without cancelling hpdet_work/loopback_work. This can run after teardown and touch freed state. Also, the exported rk3308_codec_set_jack_detect_cb should be cleared to avoid a stale function pointer after module unload.

🔧 Proposed fix
 static void rk3308_platform_remove(struct platform_device *pdev)
 {
 	struct rk3308_codec_priv *rk3308 =
 		(struct rk3308_codec_priv *)platform_get_drvdata(pdev);
 
+	cancel_delayed_work_sync(&rk3308->hpdet_work);
+	cancel_delayed_work_sync(&rk3308->loopback_work);
+	rk3308_codec_set_jack_detect_cb = NULL;
+
 	clk_disable_unprepare(rk3308->mclk_rx);
 	clk_disable_unprepare(rk3308->mclk_tx);
 	clk_disable_unprepare(rk3308->pclk);
 	device_unregister(&rk3308->dev);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@patch/kernel/archive/rockchip64-6.19/rk3308-acodec-vendor-driver.patch`
around lines 5919 - 5928, In rk3308_platform_remove, stop and cancel the
driver's delayed/queued works and clear the exported jack callback to avoid
use-after-free/stale pointers: retrieve the private via
platform_get_drvdata(rk3308) in rk3308_platform_remove, call
cancel_delayed_work_sync(&rk3308->hpdet_work) and
cancel_delayed_work_sync(&rk3308->loopback_work) (or cancel_work_sync if they
are plain works), then set the exported callback rk3308_codec_set_jack_detect_cb
to NULL before unregistering the device and disabling clocks
(rk3308_platform_remove, rk3308->hpdet_work, rk3308->loopback_work,
rk3308_codec_set_jack_detect_cb, clk_disable_unprepare, device_unregister).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@patch/kernel/archive/rockchip64-6.19/rk3308-acodec-vendor-driver.patch`:
- Around line 5054-5075: The sysfs setter adc_grps_store parses adc_type and
grps into rk3308->used_adc_grps or rk3308->loopback_grp without bounds checking,
allowing OOB indices later; update adc_grps_store (in struct rk3308_codec_priv
context) to validate that grps is within the valid range (e.g., 0 <= grps <
MAX_ADC_GRPS or <= ARRAY_SIZE(whatever array) - 1) before assigning, return
-EINVAL on invalid input and log a clear dev_err including the bad value and
expected range; also handle non-recognized adc_type by returning -EINVAL.
- Around line 3249-3262: The ramp-down loop for rk3308 version B is writing the
ADC register and using ADC mask; change the loop to target the DAC register and
mask and constrain the range to 0x1→0xf: replace RK3308_ADC_ANA_CON10 and
RK3308_ADC_CURRENT_CHARGE_MSK used in regmap_update_bits with the DAC
equivalents (e.g. RK3308_DAC_ANA_CON14 and the DAC VCM mask constant) and
iterate v from 0x1 to 0xf (keeping the udelay(200) per step) so the DAC VCM is
ramped correctly for codec_ver == ACODEC_VERSION_B while leaving the surrounding
logic unchanged.
- Around line 5919-5928: In rk3308_platform_remove, stop and cancel the driver's
delayed/queued works and clear the exported jack callback to avoid
use-after-free/stale pointers: retrieve the private via
platform_get_drvdata(rk3308) in rk3308_platform_remove, call
cancel_delayed_work_sync(&rk3308->hpdet_work) and
cancel_delayed_work_sync(&rk3308->loopback_work) (or cancel_work_sync if they
are plain works), then set the exported callback rk3308_codec_set_jack_detect_cb
to NULL before unregistering the device and disabling clocks
(rk3308_platform_remove, rk3308->hpdet_work, rk3308->loopback_work,
rk3308_codec_set_jack_detect_cb, clk_disable_unprepare, device_unregister).

@brentr brentr changed the title Restore rk3308patches Restore RK3308 Ethernet and audio functionality Feb 18, 2026
@EvilOlaf
Copy link
Member

Great. Thanks for fixing those.

@github-actions
Copy link
Contributor

✅ This PR has been reviewed and approved — all set for merge!

@github-actions github-actions bot added Ready to merge Reviewed, tested and ready for merge and removed Needs review Seeking for review labels Feb 18, 2026
@brentr brentr merged commit b2ef84c into armbian:main Feb 18, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

02 Milestone: First quarter release Hardware Hardware related like kernel, U-Boot, ... Patches Patches related to kernel, U-Boot, ... Ready to merge Reviewed, tested and ready for merge size/medium PR with more then 50 and less then 250 lines

Development

Successfully merging this pull request may close these issues.

2 participants