Commit 111d5c47 authored by Kalle Valo's avatar Kalle Valo
Browse files

Merge tag 'mt76-for-kvalo-2023-07-31' of https://github.com/nbd168/wireless

mt76 patches for 6.6

* fixes
* preparation for mt7925 support
* mt7981 support
parents f5343efd 6c0570bc
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ properties:
      - mediatek,mt76
      - mediatek,mt7628-wmac
      - mediatek,mt7622-wmac
      - mediatek,mt7981-wmac
      - mediatek,mt7986-wmac

  reg:
@@ -71,6 +72,14 @@ properties:

  ieee80211-freq-limit: true

  nvmem-cells:
    items:
      - description: NVMEM cell with EEPROM

  nvmem-cell-names:
    items:
      - const: eeprom

  mediatek,eeprom-data:
    $ref: /schemas/types.yaml#/definitions/uint32-array
    description:
@@ -84,6 +93,7 @@ properties:
          - description: offset containing EEPROM data
    description:
      Phandle to a MTD partition + offset containing EEPROM data
    deprecated: true

  big-endian:
    $ref: /schemas/types.yaml#/definitions/flag
@@ -258,7 +268,8 @@ examples:
      interrupt-parent = <&cpuintc>;
      interrupts = <6>;

      mediatek,mtd-eeprom = <&factory 0x0>;
      nvmem-cells = <&eeprom>;
      nvmem-cell-names = "eeprom";
    };

  - |
+8 −0
Original line number Diff line number Diff line
@@ -29,6 +29,14 @@ config MT76_CONNAC_LIB
	tristate
	select MT76_CORE

config MT792x_LIB
	tristate
	select MT76_CONNAC_LIB

config MT792x_USB
	tristate
	select MT76_USB

source "drivers/net/wireless/mediatek/mt76/mt76x0/Kconfig"
source "drivers/net/wireless/mediatek/mt76/mt76x2/Kconfig"
source "drivers/net/wireless/mediatek/mt76/mt7603/Kconfig"
+9 −1
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@ obj-$(CONFIG_MT76_SDIO) += mt76-sdio.o
obj-$(CONFIG_MT76x02_LIB) += mt76x02-lib.o
obj-$(CONFIG_MT76x02_USB) += mt76x02-usb.o
obj-$(CONFIG_MT76_CONNAC_LIB) += mt76-connac-lib.o
obj-$(CONFIG_MT792x_LIB) += mt792x-lib.o
obj-$(CONFIG_MT792x_USB) += mt792x-usb.o

mt76-y := \
	mmio.o util.o trace.o dma.o mac80211.o debugfs.o eeprom.o \
@@ -19,6 +21,7 @@ mt76-sdio-y := sdio.o sdio_txrx.o
CFLAGS_trace.o := -I$(src)
CFLAGS_usb_trace.o := -I$(src)
CFLAGS_mt76x02_trace.o := -I$(src)
CFLAGS_mt792x_trace.o := -I$(src)

mt76x02-lib-y := mt76x02_util.o mt76x02_mac.o mt76x02_mcu.o \
		 mt76x02_eeprom.o mt76x02_phy.o mt76x02_mmio.o \
@@ -27,7 +30,12 @@ mt76x02-lib-y := mt76x02_util.o mt76x02_mac.o mt76x02_mcu.o \

mt76x02-usb-y := mt76x02_usb_mcu.o mt76x02_usb_core.o

mt76-connac-lib-y := mt76_connac_mcu.o mt76_connac_mac.o
mt76-connac-lib-y := mt76_connac_mcu.o mt76_connac_mac.o mt76_connac3_mac.o

mt792x-lib-y := mt792x_core.o mt792x_mac.o mt792x_trace.o \
		mt792x_debugfs.o mt792x_dma.o
mt792x-lib-$(CONFIG_ACPI) += mt792x_acpi_sar.o
mt792x-usb-y := mt792x_usb.o

obj-$(CONFIG_MT76x0_COMMON) += mt76x0/
obj-$(CONFIG_MT76x2_COMMON) += mt76x2/
+6 −0
Original line number Diff line number Diff line
@@ -466,6 +466,9 @@ mt76_dma_tx_queue_skb_raw(struct mt76_dev *dev, struct mt76_queue *q,
	struct mt76_queue_buf buf = {};
	dma_addr_t addr;

	if (test_bit(MT76_MCU_RESET, &dev->phy.state))
		goto error;

	if (q->queued + 1 >= q->ndesc - 1)
		goto error;

@@ -507,6 +510,9 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q,
	dma_addr_t addr;
	u8 *txwi;

	if (test_bit(MT76_RESET, &dev->phy.state))
		goto free_skb;

	t = mt76_get_txwi(dev);
	if (!t)
		goto free_skb;
+71 −16
Original line number Diff line number Diff line
@@ -6,27 +6,20 @@
#include <linux/of_net.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/nvmem-consumer.h>
#include <linux/etherdevice.h>
#include "mt76.h"

int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len)
static int mt76_get_of_eeprom_data(struct mt76_dev *dev, void *eep, int len)
{
#if defined(CONFIG_OF) && defined(CONFIG_MTD)
	struct device_node *np = dev->dev->of_node;
	struct mtd_info *mtd;
	const __be32 *list;
	const void *data;
	const char *part;
	phandle phandle;
	int size;
	size_t retlen;
	int ret;

	if (!np)
	data = of_get_property(np, "mediatek,eeprom-data", &size);
	if (!data)
		return -ENOENT;

	data = of_get_property(np, "mediatek,eeprom-data", &size);
	if (data) {
	if (size > len)
		return -EINVAL;

@@ -35,6 +28,18 @@ int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len)
	return 0;
}

static int mt76_get_of_epprom_from_mtd(struct mt76_dev *dev, void *eep, int offset, int len)
{
#ifdef CONFIG_MTD
	struct device_node *np = dev->dev->of_node;
	struct mtd_info *mtd;
	const __be32 *list;
	const char *part;
	phandle phandle;
	size_t retlen;
	int size;
	int ret;

	list = of_get_property(np, "mediatek,mtd-eeprom", &size);
	if (!list)
		return -ENOENT;
@@ -100,6 +105,56 @@ int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len)
	return -ENOENT;
#endif
}

static int mt76_get_of_epprom_from_nvmem(struct mt76_dev *dev, void *eep, int len)
{
	struct device_node *np = dev->dev->of_node;
	struct nvmem_cell *cell;
	const void *data;
	size_t retlen;
	int ret = 0;

	cell = of_nvmem_cell_get(np, "eeprom");
	if (IS_ERR(cell))
		return PTR_ERR(cell);

	data = nvmem_cell_read(cell, &retlen);
	nvmem_cell_put(cell);

	if (IS_ERR(data))
		return PTR_ERR(data);

	if (retlen < len) {
		ret = -EINVAL;
		goto exit;
	}

	memcpy(eep, data, len);

exit:
	kfree(data);

	return ret;
}

int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len)
{
	struct device_node *np = dev->dev->of_node;
	int ret;

	if (!np)
		return -ENOENT;

	ret = mt76_get_of_eeprom_data(dev, eep, len);
	if (!ret)
		return 0;

	ret = mt76_get_of_epprom_from_mtd(dev, eep, offset, len);
	if (!ret)
		return 0;

	return mt76_get_of_epprom_from_nvmem(dev, eep, len);
}
EXPORT_SYMBOL_GPL(mt76_get_of_eeprom);

void
Loading