drivers/net/wireless/ath/ath9k/ahb.c

Source file repositories/reference/linux-study-clean/drivers/net/wireless/ath/ath9k/ahb.c

File Facts

System
Linux kernel
Corpus path
drivers/net/wireless/ath/ath9k/ahb.c
Extension
.c
Size
4051 bytes
Lines
153
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source 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

#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/nl80211.h>
#include <linux/of.h>
#include <linux/platform_device.h>

#include "ath9k.h"

static const struct of_device_id ath9k_of_match_table[] = {
	{ .compatible = "qca,ar9130-wifi", .data = (void *)AR5416_AR9100_DEVID },
	{ .compatible = "qca,ar9330-wifi", .data = (void *)AR9300_DEVID_AR9330 },
	{ .compatible = "qca,ar9340-wifi", .data = (void *)AR9300_DEVID_AR9340 },
	{ .compatible = "qca,qca9530-wifi", .data = (void *)AR9300_DEVID_AR953X },
	{ .compatible = "qca,qca9550-wifi", .data = (void *)AR9300_DEVID_QCA955X },
	{ .compatible = "qca,qca9560-wifi", .data = (void *)AR9300_DEVID_QCA956X },
	{},
};

/* return bus cachesize in 4B word units */
static void ath_ahb_read_cachesize(struct ath_common *common, int *csz)
{
	*csz = L1_CACHE_BYTES >> 2;
}

static bool ath_ahb_eeprom_read(struct ath_common *common, u32 off, u16 *data)
{
	ath_err(common, "%s: eeprom data has to be provided externally\n",
		__func__);
	return false;
}

static const struct ath_bus_ops ath_ahb_bus_ops  = {
	.ath_bus_type = ATH_AHB,
	.read_cachesize = ath_ahb_read_cachesize,
	.eeprom_read = ath_ahb_eeprom_read,
};

static int ath_ahb_probe(struct platform_device *pdev)
{
	struct ieee80211_hw *hw;
	struct ath_softc *sc;
	struct ath_hw *ah;
	void __iomem *mem;
	char hw_name[64];
	u16 dev_id;
	int irq;
	int ret;

	mem = devm_platform_ioremap_resource(pdev, 0);
	if (IS_ERR(mem)) {
		dev_err(&pdev->dev, "ioremap failed\n");
		return PTR_ERR(mem);
	}

	irq = platform_get_irq(pdev, 0);
	if (irq < 0)
		return irq;

	ath9k_fill_chanctx_ops();
	hw = ieee80211_alloc_hw(sizeof(struct ath_softc), &ath9k_ops);
	if (hw == NULL) {
		dev_err(&pdev->dev, "no memory for ieee80211_hw\n");
		return -ENOMEM;
	}

	SET_IEEE80211_DEV(hw, &pdev->dev);
	platform_set_drvdata(pdev, hw);

	sc = hw->priv;
	sc->hw = hw;
	sc->dev = &pdev->dev;
	sc->mem = mem;
	sc->irq = irq;

	ret = request_irq(irq, ath_isr, IRQF_SHARED, "ath9k", sc);
	if (ret) {
		dev_err(&pdev->dev, "request_irq failed\n");
		goto err_free_hw;
	}

	dev_id = (u16)(kernel_ulong_t)of_device_get_match_data(&pdev->dev);
	ret = ath9k_init_device(dev_id, sc, &ath_ahb_bus_ops);
	if (ret) {
		dev_err(&pdev->dev, "failed to initialize device\n");
		goto err_irq;
	}

	ah = sc->sc_ah;
	ath9k_hw_name(ah, hw_name, sizeof(hw_name));
	wiphy_info(hw->wiphy, "%s mem=0x%p, irq=%d\n",

Annotation

Implementation Notes