From nobody Fri Sep 13 00:20:34 2024 X-Original-To: dev-commits-src-main@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 4X4Zhf4dQwz5V2vY; Fri, 13 Sep 2024 00:20:34 +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 4X4Zhf3wb3z4ZFF; Fri, 13 Sep 2024 00:20:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726186834; 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=H/9s464BDypJwBprBcZ1KmAznf85QPKI4P/CdUxa/5U=; b=Ghx5NSr0LPvTJecrLr6MGBSfyn/vuzr8i3qwgxE9mdGs1XSTrI8Y+5anEB0lSYbOHfB1gb xHb+SoUYhvVt6DtV9yrfFfRySOa33ma/oUJLJ/tTXm80d7oGZI+ZohvTxzzcIAmgXWM511 /KtBH1HfmtG8fY4FwdWAD/xmv36zmsNhSwi9jCayY7u42Jsp3KH05qts7kZ0v0FchJK4CS jideZ7FKLl/madvsd1FtU/DUgfQF2q1GZS4pRo7hNOZdPW/VkoqTZGuVnPWonN0o2cfZrQ ISyD+PNJvJiDLntZfRIMh8uBm8RCa4MDlkOeYhy/guXBPyHvx/OEJJG3Cpcgvw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1726186834; a=rsa-sha256; cv=none; b=Tn7gcBaBs0zJ+BF388p2gmcj0ccGAuV264oB/7Rh8exEIRy46iMWcfpNnvl8PyWN4fAkkA Uij44gjbiRmdhtH7qBHVHRSRu1pN3XBUe3aQiME61P5VsaT7GoT3x0eSKOCOf8NYQ1c7Sm eL/Z+L9sPDGMjJK6HpBKr6NU8j3JIw1TVQ5FI67wSjgblLjWWcT5n2ZJ94V0lOnal6r6n3 ErhVkeXva0XyfHi/mUZE+gbIqDXlXk6vvYV9Ga/tGTe/YYj5j74z1Io0gQh/XJ879eguOJ l959YRGa/ugJqNbUVS+G2Zv3HTYBAtTs5VJ+IQOolip2sftKEC8WHnIzshf2Zw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726186834; 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=H/9s464BDypJwBprBcZ1KmAznf85QPKI4P/CdUxa/5U=; b=V4p/xHi9OrOznGFYeYkggbfI8zM1bvHkemkfD3BCF4wYcTBJn5iIiceRmrpseacEalKNYH xCJ6RDe4U1ql6iLL6Su5bwCEsB7kGDGeGp04SY1y5qgE1g34wyusAs1Ua/TNDwo5PUqqPc eyT19jGe0vvAQFR+pTZbz3PqFsKIAb6Rm1Lz0cQKxwx905YgUmZ8lhsmr1ewG7j2SEQ6MN 7RIVJ/RGKbh1FVSCjoZkOMhWdPHmqxm1RLIkdv39LW0anlHPUWYiIHpoQGLx6FUgCGoZys Q4QLypW6lEEjyBnQ4+I3oqZOyv+d3Ii/kJDkTpaQ65yrC6UyLRiGgjMA8YQNLw== 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 4X4Zhf3QK9zLbD; Fri, 13 Sep 2024 00:20:34 +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 48D0KYhq048368; Fri, 13 Sep 2024 00:20:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48D0KYJc048364; Fri, 13 Sep 2024 00:20:34 GMT (envelope-from git) Date: Fri, 13 Sep 2024 00:20:34 GMT Message-Id: <202409130020.48D0KYJc048364@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 7728586800bd - main - mt76: add mt7615 to the pile of buildable drivers List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 7728586800bd5bb4655cff6d661133ed10cc2ff7 Auto-Submitted: auto-generated The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=7728586800bd5bb4655cff6d661133ed10cc2ff7 commit 7728586800bd5bb4655cff6d661133ed10cc2ff7 Author: Bjoern A. Zeeb AuthorDate: 2024-09-04 18:38:05 +0000 Commit: Bjoern A. Zeeb CommitDate: 2024-09-13 00:18:02 +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 MFC after: 3 days --- 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 fbc9265c9127..f75427acf4f5 100644 --- a/sys/modules/mt76/Makefile +++ b/sys/modules/mt76/Makefile @@ -1,4 +1,5 @@ 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