diff --git a/sys/contrib/dev/mediatek/mt76/mt7615/eeprom.c b/sys/contrib/dev/mediatek/mt76/mt7615/eeprom.c index ccedea7e8a5..d5ec498aa9e 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 18a50ccff10..517a9ec9e07 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 7ba789834e8..5037104ed1a 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 8d745c9730c..704faf50f4f 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 f607eee3fb4..68f628c6f24 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 0019890fdb7..fe6bd71c7d9 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 fbc9265c912..f75427acf4f 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 00000000000..6d7cb945a32 --- /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