diff mbox series

[v4,9/9] wifi: rtw88: Add support for the SDIO based RTL8821CS chipset

Message ID 20230403202440.276757-10-martin.blumenstingl@googlemail.com (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show
Series rtw88: Add SDIO support | expand

Commit Message

Martin Blumenstingl April 3, 2023, 8:24 p.m. UTC
Wire up RTL8821CS chipset support using the new rtw88 SDIO HCI code as
well as the existing RTL8821C chipset code.

Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
Changes since v3:
- add Ping-Ke's reviewed-by

Changes since v2:
- sort includes alphabetically as suggested by Ping-Ke
- add missing #include "main.h" (after it has been removed from sdio.h
  in patch 2 from this series)

Changes since v1:
- use /* ... */ style for copyright comments


 drivers/net/wireless/realtek/rtw88/Kconfig    | 11 ++++++
 drivers/net/wireless/realtek/rtw88/Makefile   |  3 ++
 .../net/wireless/realtek/rtw88/rtw8821cs.c    | 36 +++++++++++++++++++
 3 files changed, 50 insertions(+)
 create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8821cs.c

Comments

Chris Morgan April 4, 2023, 5:38 p.m. UTC | #1
On Mon, Apr 03, 2023 at 10:24:40PM +0200, Martin Blumenstingl wrote:
> Wire up RTL8821CS chipset support using the new rtw88 SDIO HCI code as
> well as the existing RTL8821C chipset code.
> 
> Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---

Unfortunately this version isn't working for me currently. When I try
to probe the driver I get an error of "mac power on failed". After some
debugging it looks like there are some SDIO bits in the
rtw_pwr_seq_parser() function that are missing, causing it to return
-EINVAL. I tried to add those specific bits back based on your latest
github, but then I get additonal errors like "failed to read efuse map"
and other errors. I'm wondering if there are bits that might be missing
for the rtl8821cs in this revision.

Thank you,
Chris Morgan.

> Changes since v3:
> - add Ping-Ke's reviewed-by
> 
> Changes since v2:
> - sort includes alphabetically as suggested by Ping-Ke
> - add missing #include "main.h" (after it has been removed from sdio.h
>   in patch 2 from this series)
> 
> Changes since v1:
> - use /* ... */ style for copyright comments
> 
> 
>  drivers/net/wireless/realtek/rtw88/Kconfig    | 11 ++++++
>  drivers/net/wireless/realtek/rtw88/Makefile   |  3 ++
>  .../net/wireless/realtek/rtw88/rtw8821cs.c    | 36 +++++++++++++++++++
>  3 files changed, 50 insertions(+)
>  create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8821cs.c
> 
> diff --git a/drivers/net/wireless/realtek/rtw88/Kconfig b/drivers/net/wireless/realtek/rtw88/Kconfig
> index 6b65da81127f..29eb2f8e0eb7 100644
> --- a/drivers/net/wireless/realtek/rtw88/Kconfig
> +++ b/drivers/net/wireless/realtek/rtw88/Kconfig
> @@ -133,6 +133,17 @@ config RTW88_8821CE
>  
>  	  802.11ac PCIe wireless network adapter
>  
> +config RTW88_8821CS
> +	tristate "Realtek 8821CS SDIO wireless network adapter"
> +	depends on MMC
> +	select RTW88_CORE
> +	select RTW88_SDIO
> +	select RTW88_8821C
> +	help
> +	  Select this option will enable support for 8821CS chipset
> +
> +	  802.11ac SDIO wireless network adapter
> +
>  config RTW88_8821CU
>  	tristate "Realtek 8821CU USB wireless network adapter"
>  	depends on USB
> diff --git a/drivers/net/wireless/realtek/rtw88/Makefile b/drivers/net/wireless/realtek/rtw88/Makefile
> index 6105c2745bda..82979b30ae8d 100644
> --- a/drivers/net/wireless/realtek/rtw88/Makefile
> +++ b/drivers/net/wireless/realtek/rtw88/Makefile
> @@ -59,6 +59,9 @@ rtw88_8821c-objs		:= rtw8821c.o rtw8821c_table.o
>  obj-$(CONFIG_RTW88_8821CE)	+= rtw88_8821ce.o
>  rtw88_8821ce-objs		:= rtw8821ce.o
>  
> +obj-$(CONFIG_RTW88_8821CS)	+= rtw88_8821cs.o
> +rtw88_8821cs-objs		:= rtw8821cs.o
> +
>  obj-$(CONFIG_RTW88_8821CU)	+= rtw88_8821cu.o
>  rtw88_8821cu-objs		:= rtw8821cu.o
>  
> diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821cs.c b/drivers/net/wireless/realtek/rtw88/rtw8821cs.c
> new file mode 100644
> index 000000000000..a359413369a4
> --- /dev/null
> +++ b/drivers/net/wireless/realtek/rtw88/rtw8821cs.c
> @@ -0,0 +1,36 @@
> +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
> +/* Copyright(c) Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> + */
> +
> +#include <linux/mmc/sdio_func.h>
> +#include <linux/mmc/sdio_ids.h>
> +#include <linux/module.h>
> +#include "main.h"
> +#include "rtw8821c.h"
> +#include "sdio.h"
> +
> +static const struct sdio_device_id rtw_8821cs_id_table[] =  {
> +	{
> +		SDIO_DEVICE(SDIO_VENDOR_ID_REALTEK,
> +			    SDIO_DEVICE_ID_REALTEK_RTW8821CS),
> +		.driver_data = (kernel_ulong_t)&rtw8821c_hw_spec,
> +	},
> +	{}
> +};
> +MODULE_DEVICE_TABLE(sdio, rtw_8821cs_id_table);
> +
> +static struct sdio_driver rtw_8821cs_driver = {
> +	.name = "rtw_8821cs",
> +	.probe = rtw_sdio_probe,
> +	.remove = rtw_sdio_remove,
> +	.id_table = rtw_8821cs_id_table,
> +	.drv = {
> +		.pm = &rtw_sdio_pm_ops,
> +		.shutdown = rtw_sdio_shutdown,
> +	}
> +};
> +module_sdio_driver(rtw_8821cs_driver);
> +
> +MODULE_AUTHOR("Martin Blumenstingl <martin.blumenstingl@googlemail.com>");
> +MODULE_DESCRIPTION("Realtek 802.11ac wireless 8821cs driver");
> +MODULE_LICENSE("Dual BSD/GPL");
Chris Morgan April 4, 2023, 6:16 p.m. UTC | #2
Please disregard. I was building against linux main not wireless-next.
I have tested and it appears to be working well, even suspend works now.

On Tue, Apr 4, 2023 at 12:38 PM Chris Morgan <macroalpha82@gmail.com> wrote:
>
> On Mon, Apr 03, 2023 at 10:24:40PM +0200, Martin Blumenstingl wrote:
> > Wire up RTL8821CS chipset support using the new rtw88 SDIO HCI code as
> > well as the existing RTL8821C chipset code.
> >
> > Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
> > Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> > ---
>
> Unfortunately this version isn't working for me currently. When I try
> to probe the driver I get an error of "mac power on failed". After some
> debugging it looks like there are some SDIO bits in the
> rtw_pwr_seq_parser() function that are missing, causing it to return
> -EINVAL. I tried to add those specific bits back based on your latest
> github, but then I get additonal errors like "failed to read efuse map"
> and other errors. I'm wondering if there are bits that might be missing
> for the rtl8821cs in this revision.
>
> Thank you,
> Chris Morgan.
>
> > Changes since v3:
> > - add Ping-Ke's reviewed-by
> >
> > Changes since v2:
> > - sort includes alphabetically as suggested by Ping-Ke
> > - add missing #include "main.h" (after it has been removed from sdio.h
> >   in patch 2 from this series)
> >
> > Changes since v1:
> > - use /* ... */ style for copyright comments
> >
> >
> >  drivers/net/wireless/realtek/rtw88/Kconfig    | 11 ++++++
> >  drivers/net/wireless/realtek/rtw88/Makefile   |  3 ++
> >  .../net/wireless/realtek/rtw88/rtw8821cs.c    | 36 +++++++++++++++++++
> >  3 files changed, 50 insertions(+)
> >  create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8821cs.c
> >
> > diff --git a/drivers/net/wireless/realtek/rtw88/Kconfig b/drivers/net/wireless/realtek/rtw88/Kconfig
> > index 6b65da81127f..29eb2f8e0eb7 100644
> > --- a/drivers/net/wireless/realtek/rtw88/Kconfig
> > +++ b/drivers/net/wireless/realtek/rtw88/Kconfig
> > @@ -133,6 +133,17 @@ config RTW88_8821CE
> >
> >         802.11ac PCIe wireless network adapter
> >
> > +config RTW88_8821CS
> > +     tristate "Realtek 8821CS SDIO wireless network adapter"
> > +     depends on MMC
> > +     select RTW88_CORE
> > +     select RTW88_SDIO
> > +     select RTW88_8821C
> > +     help
> > +       Select this option will enable support for 8821CS chipset
> > +
> > +       802.11ac SDIO wireless network adapter
> > +
> >  config RTW88_8821CU
> >       tristate "Realtek 8821CU USB wireless network adapter"
> >       depends on USB
> > diff --git a/drivers/net/wireless/realtek/rtw88/Makefile b/drivers/net/wireless/realtek/rtw88/Makefile
> > index 6105c2745bda..82979b30ae8d 100644
> > --- a/drivers/net/wireless/realtek/rtw88/Makefile
> > +++ b/drivers/net/wireless/realtek/rtw88/Makefile
> > @@ -59,6 +59,9 @@ rtw88_8821c-objs            := rtw8821c.o rtw8821c_table.o
> >  obj-$(CONFIG_RTW88_8821CE)   += rtw88_8821ce.o
> >  rtw88_8821ce-objs            := rtw8821ce.o
> >
> > +obj-$(CONFIG_RTW88_8821CS)   += rtw88_8821cs.o
> > +rtw88_8821cs-objs            := rtw8821cs.o
> > +
> >  obj-$(CONFIG_RTW88_8821CU)   += rtw88_8821cu.o
> >  rtw88_8821cu-objs            := rtw8821cu.o
> >
> > diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821cs.c b/drivers/net/wireless/realtek/rtw88/rtw8821cs.c
> > new file mode 100644
> > index 000000000000..a359413369a4
> > --- /dev/null
> > +++ b/drivers/net/wireless/realtek/rtw88/rtw8821cs.c
> > @@ -0,0 +1,36 @@
> > +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
> > +/* Copyright(c) Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> > + */
> > +
> > +#include <linux/mmc/sdio_func.h>
> > +#include <linux/mmc/sdio_ids.h>
> > +#include <linux/module.h>
> > +#include "main.h"
> > +#include "rtw8821c.h"
> > +#include "sdio.h"
> > +
> > +static const struct sdio_device_id rtw_8821cs_id_table[] =  {
> > +     {
> > +             SDIO_DEVICE(SDIO_VENDOR_ID_REALTEK,
> > +                         SDIO_DEVICE_ID_REALTEK_RTW8821CS),
> > +             .driver_data = (kernel_ulong_t)&rtw8821c_hw_spec,
> > +     },
> > +     {}
> > +};
> > +MODULE_DEVICE_TABLE(sdio, rtw_8821cs_id_table);
> > +
> > +static struct sdio_driver rtw_8821cs_driver = {
> > +     .name = "rtw_8821cs",
> > +     .probe = rtw_sdio_probe,
> > +     .remove = rtw_sdio_remove,
> > +     .id_table = rtw_8821cs_id_table,
> > +     .drv = {
> > +             .pm = &rtw_sdio_pm_ops,
> > +             .shutdown = rtw_sdio_shutdown,
> > +     }
> > +};
> > +module_sdio_driver(rtw_8821cs_driver);
> > +
> > +MODULE_AUTHOR("Martin Blumenstingl <martin.blumenstingl@googlemail.com>");
> > +MODULE_DESCRIPTION("Realtek 802.11ac wireless 8821cs driver");
> > +MODULE_LICENSE("Dual BSD/GPL");
Martin Blumenstingl April 4, 2023, 9:27 p.m. UTC | #3
Hello Chris,

On Tue, Apr 4, 2023 at 8:16 PM Chris Morgan <macroalpha82@gmail.com> wrote:
>
> Please disregard. I was building against linux main not wireless-next.
> I have tested and it appears to be working well, even suspend works now.
Thanks for this update - this is great news!
It's good to hear that suspend is now also working fine for you.

It would be awesome if I could get a Tested-by for this patch. This
works by replying to the patch with a line that consists of
"Tested-by: your name <your email address>". See [0] for an example.


Best regards,
Martin


[0] https://lore.kernel.org/linux-wireless/4a76b5fe-c3d6-de44-c627-3f48fafdd905@lwfinger.net/
Chris Morgan April 5, 2023, 3:02 p.m. UTC | #4
On Tue, Apr 04, 2023 at 11:27:49PM +0200, Martin Blumenstingl wrote:
> Hello Chris,
> 
> On Tue, Apr 4, 2023 at 8:16 PM Chris Morgan <macroalpha82@gmail.com> wrote:
> >
> > Please disregard. I was building against linux main not wireless-next.
> > I have tested and it appears to be working well, even suspend works now.
> Thanks for this update - this is great news!
> It's good to hear that suspend is now also working fine for you.
> 
> It would be awesome if I could get a Tested-by for this patch. This
> works by replying to the patch with a line that consists of
> "Tested-by: your name <your email address>". See [0] for an example.

Sorry, bad manners on my part.

Tested-by: Chris Morgan <macromorgan@hotmail.com>

> 
> 
> Best regards,
> Martin
> 
> 
> [0] https://lore.kernel.org/linux-wireless/4a76b5fe-c3d6-de44-c627-3f48fafdd905@lwfinger.net/
Martin Blumenstingl April 5, 2023, 7:51 p.m. UTC | #5
On Wed, Apr 5, 2023 at 5:02 PM Chris Morgan <macroalpha82@gmail.com> wrote:
>
> On Tue, Apr 04, 2023 at 11:27:49PM +0200, Martin Blumenstingl wrote:
> > Hello Chris,
> >
> > On Tue, Apr 4, 2023 at 8:16 PM Chris Morgan <macroalpha82@gmail.com> wrote:
> > >
> > > Please disregard. I was building against linux main not wireless-next.
> > > I have tested and it appears to be working well, even suspend works now.
> > Thanks for this update - this is great news!
> > It's good to hear that suspend is now also working fine for you.
> >
> > It would be awesome if I could get a Tested-by for this patch. This
> > works by replying to the patch with a line that consists of
> > "Tested-by: your name <your email address>". See [0] for an example.
>
> Sorry, bad manners on my part.
>
> Tested-by: Chris Morgan <macromorgan@hotmail.com>
awesome - thank you! I'll include that in v5
diff mbox series

Patch

diff --git a/drivers/net/wireless/realtek/rtw88/Kconfig b/drivers/net/wireless/realtek/rtw88/Kconfig
index 6b65da81127f..29eb2f8e0eb7 100644
--- a/drivers/net/wireless/realtek/rtw88/Kconfig
+++ b/drivers/net/wireless/realtek/rtw88/Kconfig
@@ -133,6 +133,17 @@  config RTW88_8821CE
 
 	  802.11ac PCIe wireless network adapter
 
+config RTW88_8821CS
+	tristate "Realtek 8821CS SDIO wireless network adapter"
+	depends on MMC
+	select RTW88_CORE
+	select RTW88_SDIO
+	select RTW88_8821C
+	help
+	  Select this option will enable support for 8821CS chipset
+
+	  802.11ac SDIO wireless network adapter
+
 config RTW88_8821CU
 	tristate "Realtek 8821CU USB wireless network adapter"
 	depends on USB
diff --git a/drivers/net/wireless/realtek/rtw88/Makefile b/drivers/net/wireless/realtek/rtw88/Makefile
index 6105c2745bda..82979b30ae8d 100644
--- a/drivers/net/wireless/realtek/rtw88/Makefile
+++ b/drivers/net/wireless/realtek/rtw88/Makefile
@@ -59,6 +59,9 @@  rtw88_8821c-objs		:= rtw8821c.o rtw8821c_table.o
 obj-$(CONFIG_RTW88_8821CE)	+= rtw88_8821ce.o
 rtw88_8821ce-objs		:= rtw8821ce.o
 
+obj-$(CONFIG_RTW88_8821CS)	+= rtw88_8821cs.o
+rtw88_8821cs-objs		:= rtw8821cs.o
+
 obj-$(CONFIG_RTW88_8821CU)	+= rtw88_8821cu.o
 rtw88_8821cu-objs		:= rtw8821cu.o
 
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821cs.c b/drivers/net/wireless/realtek/rtw88/rtw8821cs.c
new file mode 100644
index 000000000000..a359413369a4
--- /dev/null
+++ b/drivers/net/wireless/realtek/rtw88/rtw8821cs.c
@@ -0,0 +1,36 @@ 
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
+/* Copyright(c) Martin Blumenstingl <martin.blumenstingl@googlemail.com>
+ */
+
+#include <linux/mmc/sdio_func.h>
+#include <linux/mmc/sdio_ids.h>
+#include <linux/module.h>
+#include "main.h"
+#include "rtw8821c.h"
+#include "sdio.h"
+
+static const struct sdio_device_id rtw_8821cs_id_table[] =  {
+	{
+		SDIO_DEVICE(SDIO_VENDOR_ID_REALTEK,
+			    SDIO_DEVICE_ID_REALTEK_RTW8821CS),
+		.driver_data = (kernel_ulong_t)&rtw8821c_hw_spec,
+	},
+	{}
+};
+MODULE_DEVICE_TABLE(sdio, rtw_8821cs_id_table);
+
+static struct sdio_driver rtw_8821cs_driver = {
+	.name = "rtw_8821cs",
+	.probe = rtw_sdio_probe,
+	.remove = rtw_sdio_remove,
+	.id_table = rtw_8821cs_id_table,
+	.drv = {
+		.pm = &rtw_sdio_pm_ops,
+		.shutdown = rtw_sdio_shutdown,
+	}
+};
+module_sdio_driver(rtw_8821cs_driver);
+
+MODULE_AUTHOR("Martin Blumenstingl <martin.blumenstingl@googlemail.com>");
+MODULE_DESCRIPTION("Realtek 802.11ac wireless 8821cs driver");
+MODULE_LICENSE("Dual BSD/GPL");