Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ properties:
description:
MT7986 should contain 3 regions consys, dcm, and sku, in this order.

'#address-cells':
const: 1

'#size-cells':
const: 0

interrupts:
maxItems: 1

Expand Down Expand Up @@ -72,13 +78,23 @@ properties:

ieee80211-freq-limit: true

address: true

local-mac-address: true

mac-address: true

nvmem-cells:
minItems: 1
items:
- description: NVMEM cell with EEPROM
- description: NVMEM cell with the MAC address

nvmem-cell-names:
minItems: 1
items:
- const: eeprom
- const: mac-address

mediatek,eeprom-data:
$ref: /schemas/types.yaml#/definitions/uint32-array
Expand Down Expand Up @@ -213,6 +229,29 @@ properties:
description:
Half-dBm power delta for different numbers of antennas

patternProperties:
'^band@[0-2]+$':
type: object
additionalProperties: false
properties:
reg:
maxItems: 1

address: true
local-mac-address: true
mac-address: true

nvmem-cells:
description: NVMEM cell with the MAC address

nvmem-cell-names:
const: mac-address

required:
- reg

unevaluatedProperties: false

required:
- compatible
- reg
Expand All @@ -225,10 +264,13 @@ examples:
#address-cells = <3>;
#size-cells = <2>;
wifi@0,0 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "mediatek,mt76";
reg = <0x0000 0 0 0 0>;
ieee80211-freq-limit = <5000000 6000000>;
mediatek,mtd-eeprom = <&factory 0x8000>;
nvmem-cells = <&factory_eeprom>;
nvmem-cell-names = "eeprom";
big-endian;

led {
Expand Down Expand Up @@ -257,6 +299,20 @@ examples:
};
};
};

band@0 {
/* 2.4 GHz */
reg = <0>;
nvmem-cells = <&macaddr 0x4>;
nvmem-cell-names = "mac-address";
};

band@1 {
/* 5 GHz */
reg = <1>;
nvmem-cells = <&macaddr 0xa>;
nvmem-cell-names = "mac-address";
};
};
};

Expand Down
20 changes: 18 additions & 2 deletions drivers/net/wireless/mediatek/mt76/eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,25 @@ void
mt76_eeprom_override(struct mt76_phy *phy)
{
struct mt76_dev *dev = phy->dev;
struct device_node *np = dev->dev->of_node;
struct device_node *np = dev->dev->of_node, *band_np;
bool found_mac = false;
u32 reg;
int ret;

for_each_child_of_node(np, band_np) {
ret = of_property_read_u32(band_np, "reg", &reg);
if (ret)
continue;

if (reg == phy->band_idx) {
found_mac = !of_get_mac_address(band_np, phy->macaddr);
of_node_put(band_np);
break;
}
}

of_get_mac_address(np, phy->macaddr);
if (!found_mac)
of_get_mac_address(np, phy->macaddr);

if (!is_valid_ether_addr(phy->macaddr)) {
eth_random_addr(phy->macaddr);
Expand Down