drivers/net/ieee802154/at86rf230.c

Source file repositories/reference/linux-study-clean/drivers/net/ieee802154/at86rf230.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ieee802154/at86rf230.c
Extension
.c
Size
40125 bytes
Lines
1675
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

struct at86rf2xx_chip_data {
	u16 t_sleep_cycle;
	u16 t_channel_switch;
	u16 t_reset_to_off;
	u16 t_off_to_aack;
	u16 t_off_to_tx_on;
	u16 t_off_to_sleep;
	u16 t_sleep_to_off;
	u16 t_frame;
	u16 t_p_ack;
	int rssi_base_val;

	int (*set_channel)(struct at86rf230_local *, u8, u8);
	int (*set_txpower)(struct at86rf230_local *, s32);
};

#define AT86RF2XX_MAX_BUF		(127 + 3)
/* tx retries to access the TX_ON state
 * if it's above then force change will be started.
 *
 * We assume the max_frame_retries (7) value of 802.15.4 here.
 */
#define AT86RF2XX_MAX_TX_RETRIES	7
/* We use the recommended 5 minutes timeout to recalibrate */
#define AT86RF2XX_CAL_LOOP_TIMEOUT	(5 * 60 * HZ)

struct at86rf230_state_change {
	struct at86rf230_local *lp;
	int irq;

	struct hrtimer timer;
	struct spi_message msg;
	struct spi_transfer trx;
	u8 buf[AT86RF2XX_MAX_BUF];

	void (*complete)(void *context);
	u8 from_state;
	u8 to_state;
	int trac;

	bool free;
};

struct at86rf230_local {
	struct spi_device *spi;

	struct ieee802154_hw *hw;
	struct at86rf2xx_chip_data *data;
	struct regmap *regmap;
	struct gpio_desc *slp_tr;
	bool sleep;

	struct completion state_complete;
	struct at86rf230_state_change state;

	unsigned long cal_timeout;
	bool is_tx;
	bool is_tx_from_off;
	bool was_tx;
	u8 tx_retry;
	struct sk_buff *tx_skb;
	struct at86rf230_state_change tx;
};

#define AT86RF2XX_NUMREGS 0x3F

static void
at86rf230_async_state_change(struct at86rf230_local *lp,
			     struct at86rf230_state_change *ctx,
			     const u8 state, void (*complete)(void *context));

static inline void
at86rf230_sleep(struct at86rf230_local *lp)
{
	if (lp->slp_tr) {
		gpiod_set_value(lp->slp_tr, 1);
		usleep_range(lp->data->t_off_to_sleep,
			     lp->data->t_off_to_sleep + 10);
		lp->sleep = true;
	}
}

static inline void
at86rf230_awake(struct at86rf230_local *lp)
{
	if (lp->slp_tr) {
		gpiod_set_value(lp->slp_tr, 0);
		usleep_range(lp->data->t_sleep_to_off,
			     lp->data->t_sleep_to_off + 100);
		lp->sleep = false;

Annotation

Implementation Notes