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
This commit is contained in:
Bjoern A. Zeeb 2024-09-04 18:38:05 +00:00
parent becd0079c0
commit 7728586800
8 changed files with 71 additions and 0 deletions

View file

@ -6,6 +6,9 @@
*/
#include <linux/of.h>
#if defined(__FreeBSD__)
#include <linux/delay.h>
#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);

View file

@ -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);

View file

@ -10,6 +10,9 @@
#include <linux/devcoredump.h>
#include <linux/etherdevice.h>
#include <linux/timekeeping.h>
#if defined(__FreeBSD__)
#include <linux/delay.h>
#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;

View file

@ -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);

View file

@ -8,6 +8,9 @@
*/
#include <linux/etherdevice.h>
#if defined(__FreeBSD__)
#include <linux/delay.h>
#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);

View file

@ -9,6 +9,9 @@
#include <linux/etherdevice.h>
#include <linux/timekeeping.h>
#if defined(__FreeBSD__)
#include <linux/delay.h>
#endif
#include "mt7615.h"
#include "../dma.h"

View file

@ -1,4 +1,5 @@
SUBDIR= core
SUBDIR+= mt7615
SUBDIR+= mt7915
SUBDIR+= mt7921
SUBDIR+= mt7996

View file

@ -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 <bsd.kmod.mk>