mbox series

[0/9] rtw88: Add support for RTL8723CS/RTL8703B

Message ID 20240202121050.977223-1-fiona.klute@gmx.de (mailing list archive)
Headers show
Series rtw88: Add support for RTL8723CS/RTL8703B | expand

Message

Fiona Klute Feb. 2, 2024, 12:10 p.m. UTC
This patch set adds a driver for RTL8723CS, which is used in the
Pinephone and a few other devices. It is a combined wifi/bluetooth
device, the wifi part is called RTL8703B. There is already a mainline
driver for the bluetooth part. RTL8703B is similar to the RTL8723D
chip already supported by rtw88. I've been using the out-of-tree
rtl8723cs driver as reference.

Station and monitor mode work well enough for daily use on my
Pinephone, I have not tested other modes yet. WOW firmware is
declared, but WOW isn't implemented yet. RX rates stay fairly low
still.

Ping-Ke Shih kindly offered to add the required s-o-b for the firmware
and help get it into linux-firmware when it's time, for testing now
please see the code I used to extract firmware from the out-of-tree
driver [1].

I'm trying to follow the "one file per patch" rule for new drivers
while integrating with the existing rtw88 code, please let me know if
I should split it differently. I'll be including a few questions for
reviewers in the relevant patch mails.

Thanks to Ping-Ke Shih for advice, and Ondřej Jirman for debug logs!

Requests for testers:

* I do not have any 8723d device. I made sure rtw88_8723d still
  compiles, testing would be very welcome to make sure I didn't break
  anything while moving common code to rtw8723x.

* Does anyone actually get the "unexpected cck agc report type"
  warning? The out-of-tree driver also logs a warning and handles the
  3 bit LNA index in that case, but the code could be simpler without
  the workaround if it isn't needed.

* I've found mentions of RTL8703BS devices online which seem to be
  wifi-only SDIO devices using RTL8703B, and posts telling people they
  need to use the rtl8723cs driver to make them work. If anyone has
  one of those I'd be curious if this driver works with it.

[1] https://github.com/airtower-luna/rtw8703b-fw-extractor

Fiona Klute (9):
  wifi: rtw88: Shared module for rtw8723x devices
  wifi: rtw88: Debug output for rtw8723x EFUSE
  wifi: rtw88: Add definitions for 8703b chip
  wifi: rtw88: Add rtw8703b.h
  wifi: rtw88: Add rtw8703b.c
  wifi: rtw88: Add rtw8703b_tables.h
  wifi: rtw88: Add rtw8703b_tables.c
  wifi: rtw88: Reset 8703b firmware before download
  wifi: rtw88: SDIO device driver for RTL8723CS

 drivers/net/wireless/realtek/rtw88/Kconfig    |   22 +
 drivers/net/wireless/realtek/rtw88/Makefile   |    9 +
 drivers/net/wireless/realtek/rtw88/mac.c      |    6 +
 drivers/net/wireless/realtek/rtw88/main.h     |    3 +
 drivers/net/wireless/realtek/rtw88/rtw8703b.c | 2106 +++++++++++++++++
 drivers/net/wireless/realtek/rtw88/rtw8703b.h |   62 +
 .../wireless/realtek/rtw88/rtw8703b_tables.c  |  901 +++++++
 .../wireless/realtek/rtw88/rtw8703b_tables.h  |   14 +
 .../net/wireless/realtek/rtw88/rtw8723cs.c    |   34 +
 drivers/net/wireless/realtek/rtw88/rtw8723d.c |  673 +-----
 drivers/net/wireless/realtek/rtw88/rtw8723d.h |  269 +--
 drivers/net/wireless/realtek/rtw88/rtw8723x.c |  720 ++++++
 drivers/net/wireless/realtek/rtw88/rtw8723x.h |  517 ++++
 include/linux/mmc/sdio_ids.h                  |    1 +
 14 files changed, 4437 insertions(+), 900 deletions(-)
 create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8703b.c
 create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8703b.h
 create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8703b_tables.c
 create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8703b_tables.h
 create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8723cs.c
 create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8723x.c
 create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8723x.h

--
2.43.0

Comments

Dmitry Antipov Feb. 2, 2024, 1:13 p.m. UTC | #1
On 2/2/24 15:10, Fiona Klute wrote:

> This patch set adds a driver for RTL8723CS, which is used in the
> Pinephone and a few other devices. It is a combined wifi/bluetooth
> device, the wifi part is called RTL8703B. There is already a mainline
> driver for the bluetooth part. RTL8703B is similar to the RTL8723D
> chip already supported by rtw88. I've been using the out-of-tree
> rtl8723cs driver as reference.

On top of wireless-next (17903a283593), I'm seeing:

drivers/net/wireless/realtek/rtw88/mac.c: In function '__rtw_download_firmware_legacy':
drivers/net/wireless/realtek/rtw88/mac.c:940:33: error: 'RTW_CHIP_TYPE_8703B' undeclared
(first use in this function); did you mean 'RTW_CHIP_TYPE_8723D'?
   940 |         if (rtwdev->chip->id == RTW_CHIP_TYPE_8703B &&
       |                                 ^~~~~~~~~~~~~~~~~~~
       |                                 RTW_CHIP_TYPE_8723D
drivers/net/wireless/realtek/rtw88/mac.c:940:33: note: each undeclared identifier is
reported only once for each function it appears in

It seems that 'enum rtw_chip_type' has missing an entry.

Dmitry
Fiona Klute Feb. 2, 2024, 1:27 p.m. UTC | #2
Am 02.02.24 um 14:13 schrieb Dmitry Antipov:
> On 2/2/24 15:10, Fiona Klute wrote:
>
>> This patch set adds a driver for RTL8723CS, which is used in the
>> Pinephone and a few other devices. It is a combined wifi/bluetooth
>> device, the wifi part is called RTL8703B. There is already a mainline
>> driver for the bluetooth part. RTL8703B is similar to the RTL8723D
>> chip already supported by rtw88. I've been using the out-of-tree
>> rtl8723cs driver as reference.
>
> On top of wireless-next (17903a283593), I'm seeing:
>
> drivers/net/wireless/realtek/rtw88/mac.c: In function
> '__rtw_download_firmware_legacy':
> drivers/net/wireless/realtek/rtw88/mac.c:940:33: error:
> 'RTW_CHIP_TYPE_8703B' undeclared
> (first use in this function); did you mean 'RTW_CHIP_TYPE_8723D'?
>    940 |         if (rtwdev->chip->id == RTW_CHIP_TYPE_8703B &&
>        |                                 ^~~~~~~~~~~~~~~~~~~
>        |                                 RTW_CHIP_TYPE_8723D
> drivers/net/wireless/realtek/rtw88/mac.c:940:33: note: each undeclared
> identifier is
> reported only once for each function it appears in
>
> It seems that 'enum rtw_chip_type' has missing an entry.

That definition should have been added to main.h by patch 3 ("wifi:
rtw88: Add definitions for 8703b chip"). Was there some issue with
applying that one?
Dmitry Antipov Feb. 2, 2024, 1:54 p.m. UTC | #3
On 2/2/24 16:27, Fiona Klute wrote:

> That definition should have been added to main.h by patch 3 ("wifi:
> rtw88: Add definitions for 8703b chip"). Was there some issue with
> applying that one?

Ugh, indeed :-(. Should say sorry for this.

The only minor issue actually is:

drivers/net/wireless/realtek/rtw88/rtw8723x.c:314:6: warning: no previous
prototype for function '__rtw8723x_cfg_ldo25' [-Wmissing-prototypes]
   314 | void __rtw8723x_cfg_ldo25(struct rtw_dev *rtwdev, bool enable)
       |      ^
drivers/net/wireless/realtek/rtw88/rtw8723x.c:314:1: note: declare 'static'
if the function is not intended to be used outside of this translation unit
   314 | void __rtw8723x_cfg_ldo25(struct rtw_dev *rtwdev, bool enable)
       | ^
       | static

Dmitry
Fiona Klute Feb. 2, 2024, 2:13 p.m. UTC | #4
Am 02.02.24 um 14:54 schrieb Dmitry Antipov:
> The only minor issue actually is:
>
> drivers/net/wireless/realtek/rtw88/rtw8723x.c:314:6: warning: no previous
> prototype for function '__rtw8723x_cfg_ldo25' [-Wmissing-prototypes]
>    314 | void __rtw8723x_cfg_ldo25(struct rtw_dev *rtwdev, bool enable)
>        |      ^
> drivers/net/wireless/realtek/rtw88/rtw8723x.c:314:1: note: declare 'static'
> if the function is not intended to be used outside of this translation unit
>    314 | void __rtw8723x_cfg_ldo25(struct rtw_dev *rtwdev, bool enable)
>        | ^
>        | static

Looks like I forgot a static there, will fix that in the next version.
Thank you!

Fiona
Pavel Machek Feb. 2, 2024, 8:19 p.m. UTC | #5
Hi!

> Ping-Ke Shih kindly offered to add the required s-o-b for the firmware
> and help get it into linux-firmware when it's time, for testing now
> please see the code I used to extract firmware from the out-of-tree
> driver [1].

Can I get you to apply this?

So far I got driver to insert, but I did not have firmware
installed. That should be ok on next reboot.

Best regards,
								Pavel

diff --git a/Makefile b/Makefile
index 1f8e8b6..fbc1f14 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,10 @@ firmware_files = rtw8703b_ap_fw.bin \
 
 all: $(firmware_files)
 
+install: $(firmware_files)
+	sudo mkdir /lib/firmware/rtw88/
+	sudo cp $(firmware_files) /lib/firmware/rtw88/
+
 %.o: %.c
 	gcc -fPIC -DCONFIG_RTL8703B -c -o $@ $<
Pavel Machek Feb. 2, 2024, 8:44 p.m. UTC | #6
Hi!

> This patch set adds a driver for RTL8723CS, which is used in the
> Pinephone and a few other devices. It is a combined wifi/bluetooth
> device, the wifi part is called RTL8703B. There is already a mainline
> driver for the bluetooth part. RTL8703B is similar to the RTL8723D
> chip already supported by rtw88. I've been using the out-of-tree
> rtl8723cs driver as reference.

I've installed in on PinePhone with v6.8-rc1, got firmware, and it
simply started working (maybe with slightly reduced performance, but I
did not check). In fact, I'm sending this email using the new driver.

Tested-by: Pavel Machek <pavel@ucw.cz>

Thank you!

Best regards,
								Pavel
Pavel Machek Feb. 2, 2024, 8:52 p.m. UTC | #7
Hi!

> This patch set adds a driver for RTL8723CS, which is used in the
> Pinephone and a few other devices. It is a combined wifi/bluetooth
> device, the wifi part is called RTL8703B. There is already a mainline
> driver for the bluetooth part. RTL8703B is similar to the RTL8723D
> chip already supported by rtw88. I've been using the out-of-tree
> rtl8723cs driver as reference.

I tried compiling *23cs into kernel (not modular), but that one fails,
with "multiple definition of rtw8723x_iqk_backup_path_ctrl" and
similar. Sorry, can't cut&paste right now, but it should be easy to
reproduce and fix.

Best regards,
								Pavel
Fiona Klute Feb. 3, 2024, 12:36 a.m. UTC | #8
Am 02.02.24 um 21:19 schrieb Pavel Machek:
> Can I get you to apply this?

Done, good idea!

> diff --git a/Makefile b/Makefile
> index 1f8e8b6..fbc1f14 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -7,6 +7,10 @@ firmware_files = rtw8703b_ap_fw.bin \
>
>   all: $(firmware_files)
>
> +install: $(firmware_files)
> +	sudo mkdir /lib/firmware/rtw88/
> +	sudo cp $(firmware_files) /lib/firmware/rtw88/
> +
>   %.o: %.c
>   	gcc -fPIC -DCONFIG_RTL8703B -c -o $@ $<
>
>
Fiona Klute Feb. 3, 2024, 11:33 a.m. UTC | #9
Am 02.02.24 um 21:52 schrieb Pavel Machek:
> I tried compiling *23cs into kernel (not modular), but that one fails,
> with "multiple definition of rtw8723x_iqk_backup_path_ctrl" and
> similar. Sorry, can't cut&paste right now, but it should be easy to
> reproduce and fix.

The IQK helper functions need to marked as static, after that (and
adding firmware to the initramfs) the built-in driver works. Queued for
v2, thank you!

Best regards,
Fiona