From nobody Wed Oct 09 23:13:47 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XP7x829T4z5Z6Y3; Wed, 09 Oct 2024 23:13:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XP7x80qnPz4jwN; Wed, 9 Oct 2024 23:13:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728515628; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6XwJl/v1jA7D9YdeLo2MOBPu5MIihFG1X07Vz9b2KuA=; b=QuOgOuLPMgecbXBHdF9uMTIx/f3/CVXhSDQ057CEZXnP7Ol1o1xGl19c2WYCZQu0zTAGUH wPaS7UJP5nVkZIPLASCrT/DWom2MRilv0CUZLEbLhwcJBUclGYmpJfcuMXOGl7IKfYZr/S ADNV9YqQDx7DyVDICwuMRHi1uiUgrP7SP2LHh+DzThBkPQ7NC6UuHqnp1Sz1RortzJUjs/ sM06EdAYM1DoUz8akrGbeAI5WaFBbxtUcgMqPb0zHaFWVof4/TsCP5Mtf8xE0WxUGb2jFm Btd9DKrmUvsEvKEsH0LmgQkLiE1ry03KC130zV28vchTtbqinRJ8AY84j6j3ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728515628; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6XwJl/v1jA7D9YdeLo2MOBPu5MIihFG1X07Vz9b2KuA=; b=Fl2kddh+hMZ5CoEt3yfpG1ZCU85TRzr1wS0/3L8PwE6toq1vyid4RNK64auqKU3AZO5LIY MtS0qf6yOB0FI5GMJWPE6AipdWy+5O32ptRROWUa4e546Geu0DqHlZppXgYf+AKyU98NUO RMerKN1u9ZFItABieqhiVyYnISg3EMHqRsULyHFEwtabP6fcCDylBN2X270ul3sca+PorR OJAuUybe9WYW6jvhCb/cBBJePCQarpeARXNcXEUiULs59/fBerRimlRFOMTclxp8P30uUl uew/sVJiZXLbPYwOg+18pAhmWQZnJbvUsege3nE/BEpATgFWiSwWz49qp9bWfg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728515628; a=rsa-sha256; cv=none; b=oSUymS4e/aWQ+v9WgcFk0If84laFZQmJG0vODs0XIqO5/hEFx9HLDSabcIFM7C5z0bV87c NwI2sWZRUJ3TnlJHoP4bkSzEEidRFbUm55HwQ3yc3/N1a5+ci7UQ+/FrCr4oJr1buWolzO zXrpoiOD5SlQxANmhINXebmisxj2Mw6ohHO95T8dV9afK8P6gwc1PvrB2433qg2QqsjMK5 Dl1PX0sjSbSClqkuqbMSoE9WKRUtRk85e6NLPsELxj68+9amCJKFWqzkdvda+YbYu7tBp8 SXCgh/YR2jmaHOa/dvda9STPJtAJFJeZ6iOOoHCyF3B5CvzgF3X12jwHxFOJAg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XP7x80PRYzZ0x; Wed, 9 Oct 2024 23:13:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 499NDlPr044856; Wed, 9 Oct 2024 23:13:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 499NDlnb044853; Wed, 9 Oct 2024 23:13:47 GMT (envelope-from git) Date: Wed, 9 Oct 2024 23:13:47 GMT Message-Id: <202410092313.499NDlnb044853@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: dd4d05b25fcd - stable/14 - mt76: add mt7615 to the pile of buildable drivers List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: dd4d05b25fcde1085d8c2f4543d9edb94ac592f5 Auto-Submitted: auto-generated The branch stable/14 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=dd4d05b25fcde1085d8c2f4543d9edb94ac592f5 commit dd4d05b25fcde1085d8c2f4543d9edb94ac592f5 Author: Bjoern A. Zeeb AuthorDate: 2024-09-04 18:38:05 +0000 Commit: Bjoern A. Zeeb CommitDate: 2024-10-09 19:18:49 +0000 mt76: add mt7615 to the pile of buildable drivers Ignoring page_pools with the few needed adjustments and ignoring 7622 mt7615 seems to build as well. Add it so once we can connect it to the build people can start testing and debugging. (The actual work was done on a newer version of the mt76 drivers but it seems the to-build-changes equally apply here already). Requested by: Radu-Cristian Fotescu (freebsd-wireless, 2024-07-31) Sponsored by: The FreeBSD Foundation (cherry picked from commit 7728586800bd5bb4655cff6d661133ed10cc2ff7) --- sys/contrib/dev/mediatek/mt76/mt7615/eeprom.c | 15 ++++++++++++++ sys/contrib/dev/mediatek/mt76/mt7615/init.c | 6 ++++++ sys/contrib/dev/mediatek/mt76/mt7615/mac.c | 11 +++++++++++ sys/contrib/dev/mediatek/mt76/mt7615/mcu.c | 4 ++++ sys/contrib/dev/mediatek/mt76/mt7615/pci_init.c | 5 +++++ sys/contrib/dev/mediatek/mt76/mt7615/pci_mac.c | 3 +++ sys/modules/mt76/Makefile | 1 + sys/modules/mt76/mt7615/Makefile | 26 +++++++++++++++++++++++++ 8 files changed, 71 insertions(+) diff --git a/sys/contrib/dev/mediatek/mt76/mt7615/eeprom.c b/sys/contrib/dev/mediatek/mt76/mt7615/eeprom.c index ccedea7e8a50..d5ec498aa9ef 100644 --- a/sys/contrib/dev/mediatek/mt76/mt7615/eeprom.c +++ b/sys/contrib/dev/mediatek/mt76/mt7615/eeprom.c @@ -6,6 +6,9 @@ */ #include +#if defined(__FreeBSD__) +#include +#endif #include "mt7615.h" #include "eeprom.h" @@ -63,7 +66,11 @@ static int mt7615_efuse_init(struct mt7615_dev *dev, u32 base) for (i = 0; i + 16 <= len; i += 16) { int ret; +#if defined(__linux__) ret = mt7615_efuse_read(dev, base, i, buf + i); +#elif defined(__FreeBSD__) + ret = mt7615_efuse_read(dev, base, i, (u8 *)buf + i); +#endif if (ret) return ret; } @@ -256,6 +263,7 @@ int mt7615_eeprom_get_power_delta_index(struct mt7615_dev *dev, return MT_EE_5G_RATE_POWER; } +#if defined(__linux__) static void mt7615_apply_cal_free_data(struct mt7615_dev *dev) { static const u16 ical[] = { @@ -311,9 +319,11 @@ static void mt7622_apply_cal_free_data(struct mt7615_dev *dev) eeprom[ical[i]] = otp[ical[i]]; } } +#endif static void mt7615_cal_free_data(struct mt7615_dev *dev) { +#if defined(__linux__) struct device_node *np = dev->mt76.dev->of_node; if (!np || !of_property_read_bool(np, "mediatek,eeprom-merge-otp")) @@ -328,6 +338,7 @@ static void mt7615_cal_free_data(struct mt7615_dev *dev) mt7615_apply_cal_free_data(dev); break; } +#endif } int mt7615_eeprom_init(struct mt7615_dev *dev, u32 addr) @@ -348,7 +359,11 @@ int mt7615_eeprom_init(struct mt7615_dev *dev, u32 addr) } mt7615_eeprom_parse_hw_cap(dev); +#if defined(__linux__) memcpy(dev->mphy.macaddr, dev->mt76.eeprom.data + MT_EE_MAC_ADDR, +#elif defined(__FreeBSD__) + memcpy(dev->mphy.macaddr, (u8 *)dev->mt76.eeprom.data + MT_EE_MAC_ADDR, +#endif ETH_ALEN); mt76_eeprom_override(&dev->mphy); diff --git a/sys/contrib/dev/mediatek/mt76/mt7615/init.c b/sys/contrib/dev/mediatek/mt76/mt7615/init.c index 18a50ccff106..517a9ec9e07f 100644 --- a/sys/contrib/dev/mediatek/mt76/mt7615/init.c +++ b/sys/contrib/dev/mediatek/mt76/mt7615/init.c @@ -15,6 +15,7 @@ #include "mcu.h" #include "eeprom.h" +#if defined(__linux__) static ssize_t mt7615_thermal_show_temp(struct device *dev, struct device_attribute *attr, char *buf) @@ -64,6 +65,7 @@ int mt7615_thermal_init(struct mt7615_dev *dev) return 0; } EXPORT_SYMBOL_GPL(mt7615_thermal_init); +#endif static void mt7615_phy_init(struct mt7615_dev *dev) @@ -566,7 +568,11 @@ int mt7615_register_ext_phy(struct mt7615_dev *dev) * Make the secondary PHY MAC address local without overlapping with * the usual MAC address allocation scheme on multiple virtual interfaces */ +#if defined(__linux__) memcpy(mphy->macaddr, dev->mt76.eeprom.data + MT_EE_MAC_ADDR, +#elif defined(__FreeBSD__) + memcpy(mphy->macaddr, (u8 *)dev->mt76.eeprom.data + MT_EE_MAC_ADDR, +#endif ETH_ALEN); mphy->macaddr[0] |= 2; mphy->macaddr[0] ^= BIT(7); diff --git a/sys/contrib/dev/mediatek/mt76/mt7615/mac.c b/sys/contrib/dev/mediatek/mt76/mt7615/mac.c index 7ba789834e8d..5037104ed1a4 100644 --- a/sys/contrib/dev/mediatek/mt76/mt7615/mac.c +++ b/sys/contrib/dev/mediatek/mt76/mt7615/mac.c @@ -10,6 +10,9 @@ #include #include #include +#if defined(__FreeBSD__) +#include +#endif #include "mt7615.h" #include "../trace.h" #include "../dma.h" @@ -1575,9 +1578,17 @@ mt7615_mac_tx_free_token(struct mt7615_dev *dev, u16 token) mt7615_txwi_free(dev, txwi); } +#if defined(__linux__) static void mt7615_mac_tx_free(struct mt7615_dev *dev, void *data, int len) +#elif defined(__FreeBSD__) +static void mt7615_mac_tx_free(struct mt7615_dev *dev, u8 *data, int len) +#endif { +#if defined(__linux__) struct mt76_connac_tx_free *free = data; +#elif defined(__FreeBSD__) + struct mt76_connac_tx_free *free = (void *)data; +#endif void *tx_token = data + sizeof(*free); void *end = data + len; u8 i, count; diff --git a/sys/contrib/dev/mediatek/mt76/mt7615/mcu.c b/sys/contrib/dev/mediatek/mt76/mt7615/mcu.c index 8d745c9730c7..704faf50f4f9 100644 --- a/sys/contrib/dev/mediatek/mt76/mt7615/mcu.c +++ b/sys/contrib/dev/mediatek/mt76/mt7615/mcu.c @@ -232,9 +232,13 @@ void mt7622_trigger_hif_int(struct mt7615_dev *dev, bool en) if (!is_mt7622(&dev->mt76)) return; +#if defined(__linux__) regmap_update_bits(dev->infracfg, MT_INFRACFG_MISC, MT_INFRACFG_MISC_AP2CONN_WAKE, !en * MT_INFRACFG_MISC_AP2CONN_WAKE); +#elif defined(__FreeBSD__) + panic("%s: LinuxKPI needs regmap\n", __func__); +#endif } EXPORT_SYMBOL_GPL(mt7622_trigger_hif_int); diff --git a/sys/contrib/dev/mediatek/mt76/mt7615/pci_init.c b/sys/contrib/dev/mediatek/mt76/mt7615/pci_init.c index f607eee3fb47..68f628c6f24e 100644 --- a/sys/contrib/dev/mediatek/mt76/mt7615/pci_init.c +++ b/sys/contrib/dev/mediatek/mt76/mt7615/pci_init.c @@ -8,6 +8,9 @@ */ #include +#if defined(__FreeBSD__) +#include +#endif #include "mt7615.h" #include "mac.h" #include "eeprom.h" @@ -92,9 +95,11 @@ int mt7615_register_device(struct mt7615_dev *dev) if (ret) return ret; +#if defined(__linux__) ret = mt7615_thermal_init(dev); if (ret) return ret; +#endif ieee80211_queue_work(mt76_hw(dev), &dev->mcu_work); mt7615_init_txpower(dev, &dev->mphy.sband_2g.sband); diff --git a/sys/contrib/dev/mediatek/mt76/mt7615/pci_mac.c b/sys/contrib/dev/mediatek/mt76/mt7615/pci_mac.c index 0019890fdb78..fe6bd71c7d97 100644 --- a/sys/contrib/dev/mediatek/mt76/mt7615/pci_mac.c +++ b/sys/contrib/dev/mediatek/mt76/mt7615/pci_mac.c @@ -9,6 +9,9 @@ #include #include +#if defined(__FreeBSD__) +#include +#endif #include "mt7615.h" #include "../dma.h" diff --git a/sys/modules/mt76/Makefile b/sys/modules/mt76/Makefile index 95d6e10a6991..89eb22bc3e9a 100644 --- a/sys/modules/mt76/Makefile +++ b/sys/modules/mt76/Makefile @@ -1,5 +1,6 @@ SUBDIR= core +SUBDIR+= mt7615 SUBDIR+= mt7915 SUBDIR+= mt7921 SUBDIR+= mt7996 diff --git a/sys/modules/mt76/mt7615/Makefile b/sys/modules/mt76/mt7615/Makefile new file mode 100644 index 000000000000..6d7cb945a32d --- /dev/null +++ b/sys/modules/mt76/mt7615/Makefile @@ -0,0 +1,26 @@ +DEVDIR= ${SRCTOP}/sys/contrib/dev/mediatek/mt76/mt7615 + +.PATH: ${DEVDIR} + +WITH_DEBUGFS= 0 +WITH_DEV_COREDUMP= 0 + +KMOD= if_mt7615 + +# Common stuff. +SRCS= init.c main.c mac.c mcu.c eeprom.c + +# PCIe (7622_WMAC ignored) +SRCS+= dma.c mmio.c pci.c pci_init.c pci_mac.c + +# USB + SDIO ignored currently. + +.if defined(WITH_DEBUGFS) && ${WITH_DEBUGFS} > 0 +SRCS+= debugfs.c +CFLAGS+= -DCONFIG_MT7915_DEBUGFS=${WITH_DEBUGFS} +.endif + +CFLAGS+= -DKBUILD_MODNAME='"mt7615"' +CFLAGS+= -I${DEVDIR} + +.include