drivers/net/wireless/mediatek/mt76/mt7925/regd.c

Source file repositories/reference/linux-study-clean/drivers/net/wireless/mediatek/mt76/mt7925/regd.c

File Facts

System
Linux kernel
Corpus path
drivers/net/wireless/mediatek/mt76/mt7925/regd.c
Extension
.c
Size
6288 bytes
Lines
267
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: BSD-3-Clause-Clear
/* Copyright (C) 2025 MediaTek Inc. */

#include "mt7925.h"
#include "regd.h"
#include "mcu.h"

static bool mt7925_disable_clc;
module_param_named(disable_clc, mt7925_disable_clc, bool, 0644);
MODULE_PARM_DESC(disable_clc, "disable CLC support");

bool mt7925_regd_clc_supported(struct mt792x_dev *dev)
{
	if (mt7925_disable_clc ||
	    mt76_is_usb(&dev->mt76))
		return false;

	return true;
}

void mt7925_regd_be_ctrl(struct mt792x_dev *dev, u8 *alpha2)
{
	struct mt792x_phy *phy = &dev->phy;
	struct mt7925_clc_rule_v2 *rule;
	struct mt7925_clc *clc;
	bool old = dev->has_eht, new = true;
	u32 mtcl_conf = mt792x_acpi_get_mtcl_conf(&dev->phy, alpha2);
	u8 *pos;

	if (mtcl_conf != MT792X_ACPI_MTCL_INVALID &&
	    (((mtcl_conf >> 4) & 0x3) == 0)) {
		new = false;
		goto out;
	}

	if (!phy->clc[MT792x_CLC_BE_CTRL])
		goto out;

	clc = (struct mt7925_clc *)phy->clc[MT792x_CLC_BE_CTRL];
	pos = clc->data;

	while (1) {
		rule = (struct mt7925_clc_rule_v2 *)pos;

		if (rule->alpha2[0] == alpha2[0] &&
		    rule->alpha2[1] == alpha2[1]) {
			new = false;
			break;
		}

		/* Check the last one */
		if (rule->flag & BIT(0))
			break;

		pos += sizeof(*rule);
	}

out:
	if (old == new)
		return;

	dev->has_eht = new;
	mt7925_set_stream_he_eht_caps(phy);
}

static void
mt7925_regd_channel_update(struct wiphy *wiphy, struct mt792x_dev *dev)
{
#define IS_UNII_INVALID(idx, sfreq, efreq, cfreq) \
	(!(dev->phy.clc_chan_conf & BIT(idx)) && (cfreq) >= (sfreq) && (cfreq) <= (efreq))
#define MT7925_UNII_59G_IS_VALID	0x1
#define MT7925_UNII_6G_IS_VALID	0x1e
	struct ieee80211_supported_band *sband;
	struct mt76_dev *mdev = &dev->mt76;
	struct ieee80211_channel *ch;
	u32 mtcl_conf = mt792x_acpi_get_mtcl_conf(&dev->phy, mdev->alpha2);
	int i;

	if (mtcl_conf != MT792X_ACPI_MTCL_INVALID) {
		if ((mtcl_conf & 0x3) == 0)
			dev->phy.clc_chan_conf &= ~MT7925_UNII_59G_IS_VALID;
		if (((mtcl_conf >> 2) & 0x3) == 0)
			dev->phy.clc_chan_conf &= ~MT7925_UNII_6G_IS_VALID;
	}

	sband = wiphy->bands[NL80211_BAND_2GHZ];
	if (!sband)
		return;

	for (i = 0; i < sband->n_channels; i++) {

Annotation

Implementation Notes