From: Lachlan Hodges <lachlan.hodges@morsemicro.com>
To: johannes@sipsolutions.net,
Lachlan Hodges <lachlan.hodges@morsemicro.com>,
Dan Callaghan <dan.callaghan@morsemicro.com>,
Arien Judge <arien.judge@morsemicro.com>
Cc: ayman.grais@morsemicro.com, linux-wireless@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH wireless-next v3 07/33] wifi: mm81x: add core.c
Date: Fri, 26 Jun 2026 16:29:03 +1000 [thread overview]
Message-ID: <20260626063014.1275235-8-lachlan.hodges@morsemicro.com> (raw)
In-Reply-To: <20260626063014.1275235-1-lachlan.hodges@morsemicro.com>
(Patches split per file for review, will be a single commit alongside
SDIO ids once review is complete. See cover letter for more
information)
Signed-off-by: Lachlan Hodges <lachlan.hodges@morsemicro.com>
---
drivers/net/wireless/morsemicro/mm81x/core.c | 142 +++++++++++++++++++
1 file changed, 142 insertions(+)
create mode 100644 drivers/net/wireless/morsemicro/mm81x/core.c
diff --git a/drivers/net/wireless/morsemicro/mm81x/core.c b/drivers/net/wireless/morsemicro/mm81x/core.c
new file mode 100644
index 000000000000..33548a6aea6c
--- /dev/null
+++ b/drivers/net/wireless/morsemicro/mm81x/core.c
@@ -0,0 +1,142 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2017-2026 Morse Micro
+ */
+#include <linux/module.h>
+#include "core.h"
+#include "bus.h"
+#include "hif.h"
+#include "mac.h"
+
+static int mm81x_core_attach_regs(struct mm81x *mors)
+{
+ int ret = 0;
+
+ mm81x_claim_bus(mors);
+ ret = mm81x_reg32_read(mors, MM8108_REG_CHIP_ID, &mors->chip_id);
+ mm81x_release_bus(mors);
+
+ if (ret < 0) {
+ dev_err(mors->dev, "failed to read chip id %d", ret);
+ return ret;
+ }
+
+ switch (mors->chip_id) {
+ case (MM8108B2_ID):
+ mors->regs = &mm8108_regs;
+ mors->hif.ops = &mm81x_yaps_ops;
+ break;
+ default:
+ return -ENODEV;
+ }
+
+ return ret;
+}
+
+static char *mm81x_core_get_revision_string(u32 chip_id)
+{
+ u8 chip_rev = MM81X_DEVICE_GET_CHIP_REV(chip_id);
+
+ switch (chip_rev) {
+ case MM8108B2_REV:
+ return MM8108B2_REV_STRING;
+ default:
+ return "??";
+ }
+}
+
+static void mm81x_core_init_mac_addr(struct mm81x *mors)
+{
+ int ret = mm81x_hw_otp_get_mac_addr(mors);
+
+ if (ret || !is_valid_ether_addr(mors->macaddr))
+ eth_random_addr(mors->macaddr);
+}
+
+char *mm81x_core_get_fw_path(u32 chip_id)
+{
+ return kasprintf(GFP_KERNEL,
+ MM81X_FW_DIR "/" MM8108_FW_BASE
+ "%s" FW_ROM_LINKED_STRING MM81X_FW_EXT,
+ mm81x_core_get_revision_string(chip_id));
+}
+EXPORT_SYMBOL_GPL(mm81x_core_get_fw_path);
+
+struct mm81x *mm81x_core_alloc(size_t priv_size, struct device *dev)
+{
+ return mm81x_mac_alloc(priv_size, dev);
+}
+EXPORT_SYMBOL_GPL(mm81x_core_alloc);
+
+int mm81x_core_init(struct mm81x *mors)
+{
+ int ret;
+
+ set_bit(MM81X_STATE_CHIP_UNRESPONSIVE, &mors->state_flags);
+ set_bit(MM81X_STATE_RELOAD_FW_AFTER_START, &mors->state_flags);
+
+ mm81x_core_init_mac_addr(mors);
+
+ ret = mm81x_core_attach_regs(mors);
+ if (ret)
+ return ret;
+
+ mors->chip_wq = create_singlethread_workqueue("chip_wq");
+ if (!mors->chip_wq)
+ return -ENOMEM;
+
+ mors->net_wq = create_singlethread_workqueue("net_wq");
+ if (!mors->net_wq) {
+ ret = -ENOMEM;
+ goto err_chip_wq;
+ }
+
+ ret = mm81x_hif_init(mors);
+ if (ret)
+ goto err_wqs;
+
+ return 0;
+
+err_wqs:
+ flush_workqueue(mors->net_wq);
+ destroy_workqueue(mors->net_wq);
+
+err_chip_wq:
+ flush_workqueue(mors->chip_wq);
+ destroy_workqueue(mors->chip_wq);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(mm81x_core_init);
+
+int mm81x_core_register(struct mm81x *mors)
+{
+ return mm81x_mac_register(mors);
+}
+EXPORT_SYMBOL_GPL(mm81x_core_register);
+
+void mm81x_core_unregister(struct mm81x *mors)
+{
+ mm81x_mac_unregister(mors);
+}
+EXPORT_SYMBOL_GPL(mm81x_core_unregister);
+
+void mm81x_core_deinit(struct mm81x *mors)
+{
+ mm81x_hif_finish(mors);
+ flush_workqueue(mors->net_wq);
+ destroy_workqueue(mors->net_wq);
+ flush_workqueue(mors->chip_wq);
+ destroy_workqueue(mors->chip_wq);
+}
+EXPORT_SYMBOL_GPL(mm81x_core_deinit);
+
+void mm81x_core_free(struct mm81x *mors)
+{
+ mm81x_mac_free(mors);
+}
+EXPORT_SYMBOL_GPL(mm81x_core_free);
+
+MODULE_AUTHOR("Morse Micro");
+MODULE_DESCRIPTION("Driver support for Morse Micro MM81X core");
+MODULE_LICENSE("Dual BSD/GPL");
--
2.43.0
next prev parent reply other threads:[~2026-06-26 6:31 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 6:28 [PATCH wireless-next v3 00/33] wifi: mm81x: add mm81x driver Lachlan Hodges
2026-06-26 6:28 ` [PATCH wireless-next v3 01/33] wifi: cfg80211: introduce helper to get S1G primary width Lachlan Hodges
2026-06-26 6:28 ` [PATCH wireless-next v3 02/33] wifi: ieee80211: introduce generic KHZ_TO_HZ helper Lachlan Hodges
2026-06-26 6:28 ` [PATCH wireless-next v3 03/33] wifi: mm81x: add bus.h Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 04/33] wifi: mm81x: add command.c Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 05/33] wifi: mm81x: add command_defs.h Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 06/33] wifi: mm81x: add command.h Lachlan Hodges
2026-06-26 6:29 ` Lachlan Hodges [this message]
2026-06-26 6:29 ` [PATCH wireless-next v3 08/33] wifi: mm81x: add core.h Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 09/33] wifi: mm81x: add fw.c Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 10/33] wifi: mm81x: add fw.h Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 11/33] wifi: mm81x: add hif.h Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 12/33] wifi: mm81x: add hw.c Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 13/33] wifi: mm81x: add hw.h Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 14/33] wifi: mm81x: add mac.c Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 15/33] wifi: mm81x: add mac.h Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 16/33] wifi: mm81x: add mmrc.c Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 17/33] wifi: mm81x: add mmrc.h Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 18/33] wifi: mm81x: add ps.c Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 19/33] wifi: mm81x: add ps.h Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 20/33] wifi: mm81x: add rate_code.h Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 21/33] wifi: mm81x: add rc.c Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 22/33] wifi: mm81x: add rc.h Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 23/33] mmc: sdio: add Morse Micro vendor ids Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 24/33] wifi: mm81x: add sdio.c Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 25/33] wifi: mm81x: add skbq.c Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 26/33] wifi: mm81x: add skbq.h Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 27/33] wifi: mm81x: add usb.c Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 28/33] wifi: mm81x: add yaps.c Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 29/33] wifi: mm81x: add yaps.h Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 30/33] wifi: mm81x: add yaps_hw.c Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 31/33] wifi: mm81x: add yaps_hw.h Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 32/33] wifi: mm81x: add Kconfig and Makefile Lachlan Hodges
2026-06-26 6:29 ` [PATCH wireless-next v3 33/33] wifi: mm81x: add MAINTAINERS entry Lachlan Hodges
2026-06-29 0:13 ` [PATCH wireless-next v3 00/33] wifi: mm81x: add mm81x driver Lachlan Hodges
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260626063014.1275235-8-lachlan.hodges@morsemicro.com \
--to=lachlan.hodges@morsemicro.com \
--cc=arien.judge@morsemicro.com \
--cc=ayman.grais@morsemicro.com \
--cc=dan.callaghan@morsemicro.com \
--cc=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox