162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * AT86RF230/RF231 driver
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (C) 2009-2012 Siemens AG
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Written by:
862306a36Sopenharmony_ci * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
962306a36Sopenharmony_ci * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
1062306a36Sopenharmony_ci */
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#ifndef _AT86RF230_H
1362306a36Sopenharmony_ci#define _AT86RF230_H
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#define RG_TRX_STATUS	(0x01)
1662306a36Sopenharmony_ci#define SR_TRX_STATUS		0x01, 0x1f, 0
1762306a36Sopenharmony_ci#define SR_RESERVED_01_3	0x01, 0x20, 5
1862306a36Sopenharmony_ci#define SR_CCA_STATUS		0x01, 0x40, 6
1962306a36Sopenharmony_ci#define SR_CCA_DONE		0x01, 0x80, 7
2062306a36Sopenharmony_ci#define RG_TRX_STATE	(0x02)
2162306a36Sopenharmony_ci#define SR_TRX_CMD		0x02, 0x1f, 0
2262306a36Sopenharmony_ci#define SR_TRAC_STATUS		0x02, 0xe0, 5
2362306a36Sopenharmony_ci#define RG_TRX_CTRL_0	(0x03)
2462306a36Sopenharmony_ci#define SR_CLKM_CTRL		0x03, 0x07, 0
2562306a36Sopenharmony_ci#define SR_CLKM_SHA_SEL		0x03, 0x08, 3
2662306a36Sopenharmony_ci#define SR_PAD_IO_CLKM		0x03, 0x30, 4
2762306a36Sopenharmony_ci#define SR_PAD_IO		0x03, 0xc0, 6
2862306a36Sopenharmony_ci#define RG_TRX_CTRL_1	(0x04)
2962306a36Sopenharmony_ci#define SR_IRQ_POLARITY		0x04, 0x01, 0
3062306a36Sopenharmony_ci#define SR_IRQ_MASK_MODE	0x04, 0x02, 1
3162306a36Sopenharmony_ci#define SR_SPI_CMD_MODE		0x04, 0x0c, 2
3262306a36Sopenharmony_ci#define SR_RX_BL_CTRL		0x04, 0x10, 4
3362306a36Sopenharmony_ci#define SR_TX_AUTO_CRC_ON	0x04, 0x20, 5
3462306a36Sopenharmony_ci#define SR_IRQ_2_EXT_EN		0x04, 0x40, 6
3562306a36Sopenharmony_ci#define SR_PA_EXT_EN		0x04, 0x80, 7
3662306a36Sopenharmony_ci#define RG_PHY_TX_PWR	(0x05)
3762306a36Sopenharmony_ci#define SR_TX_PWR_23X		0x05, 0x0f, 0
3862306a36Sopenharmony_ci#define SR_PA_LT_230		0x05, 0x30, 4
3962306a36Sopenharmony_ci#define SR_PA_BUF_LT_230	0x05, 0xc0, 6
4062306a36Sopenharmony_ci#define SR_TX_PWR_212		0x05, 0x1f, 0
4162306a36Sopenharmony_ci#define SR_GC_PA_212		0x05, 0x60, 5
4262306a36Sopenharmony_ci#define SR_PA_BOOST_LT_212	0x05, 0x80, 7
4362306a36Sopenharmony_ci#define RG_PHY_RSSI	(0x06)
4462306a36Sopenharmony_ci#define SR_RSSI			0x06, 0x1f, 0
4562306a36Sopenharmony_ci#define SR_RND_VALUE		0x06, 0x60, 5
4662306a36Sopenharmony_ci#define SR_RX_CRC_VALID		0x06, 0x80, 7
4762306a36Sopenharmony_ci#define RG_PHY_ED_LEVEL	(0x07)
4862306a36Sopenharmony_ci#define SR_ED_LEVEL		0x07, 0xff, 0
4962306a36Sopenharmony_ci#define RG_PHY_CC_CCA	(0x08)
5062306a36Sopenharmony_ci#define SR_CHANNEL		0x08, 0x1f, 0
5162306a36Sopenharmony_ci#define SR_CCA_MODE		0x08, 0x60, 5
5262306a36Sopenharmony_ci#define SR_CCA_REQUEST		0x08, 0x80, 7
5362306a36Sopenharmony_ci#define RG_CCA_THRES	(0x09)
5462306a36Sopenharmony_ci#define SR_CCA_ED_THRES		0x09, 0x0f, 0
5562306a36Sopenharmony_ci#define SR_RESERVED_09_1	0x09, 0xf0, 4
5662306a36Sopenharmony_ci#define RG_RX_CTRL	(0x0a)
5762306a36Sopenharmony_ci#define SR_PDT_THRES		0x0a, 0x0f, 0
5862306a36Sopenharmony_ci#define SR_RESERVED_0a_1	0x0a, 0xf0, 4
5962306a36Sopenharmony_ci#define RG_SFD_VALUE	(0x0b)
6062306a36Sopenharmony_ci#define SR_SFD_VALUE		0x0b, 0xff, 0
6162306a36Sopenharmony_ci#define RG_TRX_CTRL_2	(0x0c)
6262306a36Sopenharmony_ci#define SR_OQPSK_DATA_RATE	0x0c, 0x03, 0
6362306a36Sopenharmony_ci#define SR_SUB_MODE		0x0c, 0x04, 2
6462306a36Sopenharmony_ci#define SR_BPSK_QPSK		0x0c, 0x08, 3
6562306a36Sopenharmony_ci#define SR_OQPSK_SUB1_RC_EN	0x0c, 0x10, 4
6662306a36Sopenharmony_ci#define SR_RESERVED_0c_5	0x0c, 0x60, 5
6762306a36Sopenharmony_ci#define SR_RX_SAFE_MODE		0x0c, 0x80, 7
6862306a36Sopenharmony_ci#define RG_ANT_DIV	(0x0d)
6962306a36Sopenharmony_ci#define SR_ANT_CTRL		0x0d, 0x03, 0
7062306a36Sopenharmony_ci#define SR_ANT_EXT_SW_EN	0x0d, 0x04, 2
7162306a36Sopenharmony_ci#define SR_ANT_DIV_EN		0x0d, 0x08, 3
7262306a36Sopenharmony_ci#define SR_RESERVED_0d_2	0x0d, 0x70, 4
7362306a36Sopenharmony_ci#define SR_ANT_SEL		0x0d, 0x80, 7
7462306a36Sopenharmony_ci#define RG_IRQ_MASK	(0x0e)
7562306a36Sopenharmony_ci#define SR_IRQ_MASK		0x0e, 0xff, 0
7662306a36Sopenharmony_ci#define RG_IRQ_STATUS	(0x0f)
7762306a36Sopenharmony_ci#define SR_IRQ_0_PLL_LOCK	0x0f, 0x01, 0
7862306a36Sopenharmony_ci#define SR_IRQ_1_PLL_UNLOCK	0x0f, 0x02, 1
7962306a36Sopenharmony_ci#define SR_IRQ_2_RX_START	0x0f, 0x04, 2
8062306a36Sopenharmony_ci#define SR_IRQ_3_TRX_END	0x0f, 0x08, 3
8162306a36Sopenharmony_ci#define SR_IRQ_4_CCA_ED_DONE	0x0f, 0x10, 4
8262306a36Sopenharmony_ci#define SR_IRQ_5_AMI		0x0f, 0x20, 5
8362306a36Sopenharmony_ci#define SR_IRQ_6_TRX_UR		0x0f, 0x40, 6
8462306a36Sopenharmony_ci#define SR_IRQ_7_BAT_LOW	0x0f, 0x80, 7
8562306a36Sopenharmony_ci#define RG_VREG_CTRL	(0x10)
8662306a36Sopenharmony_ci#define SR_RESERVED_10_6	0x10, 0x03, 0
8762306a36Sopenharmony_ci#define SR_DVDD_OK		0x10, 0x04, 2
8862306a36Sopenharmony_ci#define SR_DVREG_EXT		0x10, 0x08, 3
8962306a36Sopenharmony_ci#define SR_RESERVED_10_3	0x10, 0x30, 4
9062306a36Sopenharmony_ci#define SR_AVDD_OK		0x10, 0x40, 6
9162306a36Sopenharmony_ci#define SR_AVREG_EXT		0x10, 0x80, 7
9262306a36Sopenharmony_ci#define RG_BATMON	(0x11)
9362306a36Sopenharmony_ci#define SR_BATMON_VTH		0x11, 0x0f, 0
9462306a36Sopenharmony_ci#define SR_BATMON_HR		0x11, 0x10, 4
9562306a36Sopenharmony_ci#define SR_BATMON_OK		0x11, 0x20, 5
9662306a36Sopenharmony_ci#define SR_RESERVED_11_1	0x11, 0xc0, 6
9762306a36Sopenharmony_ci#define RG_XOSC_CTRL	(0x12)
9862306a36Sopenharmony_ci#define SR_XTAL_TRIM		0x12, 0x0f, 0
9962306a36Sopenharmony_ci#define SR_XTAL_MODE		0x12, 0xf0, 4
10062306a36Sopenharmony_ci#define RG_RX_SYN	(0x15)
10162306a36Sopenharmony_ci#define SR_RX_PDT_LEVEL		0x15, 0x0f, 0
10262306a36Sopenharmony_ci#define SR_RESERVED_15_2	0x15, 0x70, 4
10362306a36Sopenharmony_ci#define SR_RX_PDT_DIS		0x15, 0x80, 7
10462306a36Sopenharmony_ci#define RG_XAH_CTRL_1	(0x17)
10562306a36Sopenharmony_ci#define SR_RESERVED_17_8	0x17, 0x01, 0
10662306a36Sopenharmony_ci#define SR_AACK_PROM_MODE	0x17, 0x02, 1
10762306a36Sopenharmony_ci#define SR_AACK_ACK_TIME	0x17, 0x04, 2
10862306a36Sopenharmony_ci#define SR_RESERVED_17_5	0x17, 0x08, 3
10962306a36Sopenharmony_ci#define SR_AACK_UPLD_RES_FT	0x17, 0x10, 4
11062306a36Sopenharmony_ci#define SR_AACK_FLTR_RES_FT	0x17, 0x20, 5
11162306a36Sopenharmony_ci#define SR_CSMA_LBT_MODE	0x17, 0x40, 6
11262306a36Sopenharmony_ci#define SR_RESERVED_17_1	0x17, 0x80, 7
11362306a36Sopenharmony_ci#define RG_FTN_CTRL	(0x18)
11462306a36Sopenharmony_ci#define SR_RESERVED_18_2	0x18, 0x7f, 0
11562306a36Sopenharmony_ci#define SR_FTN_START		0x18, 0x80, 7
11662306a36Sopenharmony_ci#define RG_PLL_CF	(0x1a)
11762306a36Sopenharmony_ci#define SR_RESERVED_1a_2	0x1a, 0x7f, 0
11862306a36Sopenharmony_ci#define SR_PLL_CF_START		0x1a, 0x80, 7
11962306a36Sopenharmony_ci#define RG_PLL_DCU	(0x1b)
12062306a36Sopenharmony_ci#define SR_RESERVED_1b_3	0x1b, 0x3f, 0
12162306a36Sopenharmony_ci#define SR_RESERVED_1b_2	0x1b, 0x40, 6
12262306a36Sopenharmony_ci#define SR_PLL_DCU_START	0x1b, 0x80, 7
12362306a36Sopenharmony_ci#define RG_PART_NUM	(0x1c)
12462306a36Sopenharmony_ci#define SR_PART_NUM		0x1c, 0xff, 0
12562306a36Sopenharmony_ci#define RG_VERSION_NUM	(0x1d)
12662306a36Sopenharmony_ci#define SR_VERSION_NUM		0x1d, 0xff, 0
12762306a36Sopenharmony_ci#define RG_MAN_ID_0	(0x1e)
12862306a36Sopenharmony_ci#define SR_MAN_ID_0		0x1e, 0xff, 0
12962306a36Sopenharmony_ci#define RG_MAN_ID_1	(0x1f)
13062306a36Sopenharmony_ci#define SR_MAN_ID_1		0x1f, 0xff, 0
13162306a36Sopenharmony_ci#define RG_SHORT_ADDR_0	(0x20)
13262306a36Sopenharmony_ci#define SR_SHORT_ADDR_0		0x20, 0xff, 0
13362306a36Sopenharmony_ci#define RG_SHORT_ADDR_1	(0x21)
13462306a36Sopenharmony_ci#define SR_SHORT_ADDR_1		0x21, 0xff, 0
13562306a36Sopenharmony_ci#define RG_PAN_ID_0	(0x22)
13662306a36Sopenharmony_ci#define SR_PAN_ID_0		0x22, 0xff, 0
13762306a36Sopenharmony_ci#define RG_PAN_ID_1	(0x23)
13862306a36Sopenharmony_ci#define SR_PAN_ID_1		0x23, 0xff, 0
13962306a36Sopenharmony_ci#define RG_IEEE_ADDR_0	(0x24)
14062306a36Sopenharmony_ci#define SR_IEEE_ADDR_0		0x24, 0xff, 0
14162306a36Sopenharmony_ci#define RG_IEEE_ADDR_1	(0x25)
14262306a36Sopenharmony_ci#define SR_IEEE_ADDR_1		0x25, 0xff, 0
14362306a36Sopenharmony_ci#define RG_IEEE_ADDR_2	(0x26)
14462306a36Sopenharmony_ci#define SR_IEEE_ADDR_2		0x26, 0xff, 0
14562306a36Sopenharmony_ci#define RG_IEEE_ADDR_3	(0x27)
14662306a36Sopenharmony_ci#define SR_IEEE_ADDR_3		0x27, 0xff, 0
14762306a36Sopenharmony_ci#define RG_IEEE_ADDR_4	(0x28)
14862306a36Sopenharmony_ci#define SR_IEEE_ADDR_4		0x28, 0xff, 0
14962306a36Sopenharmony_ci#define RG_IEEE_ADDR_5	(0x29)
15062306a36Sopenharmony_ci#define SR_IEEE_ADDR_5		0x29, 0xff, 0
15162306a36Sopenharmony_ci#define RG_IEEE_ADDR_6	(0x2a)
15262306a36Sopenharmony_ci#define SR_IEEE_ADDR_6		0x2a, 0xff, 0
15362306a36Sopenharmony_ci#define RG_IEEE_ADDR_7	(0x2b)
15462306a36Sopenharmony_ci#define SR_IEEE_ADDR_7		0x2b, 0xff, 0
15562306a36Sopenharmony_ci#define RG_XAH_CTRL_0	(0x2c)
15662306a36Sopenharmony_ci#define SR_SLOTTED_OPERATION	0x2c, 0x01, 0
15762306a36Sopenharmony_ci#define SR_MAX_CSMA_RETRIES	0x2c, 0x0e, 1
15862306a36Sopenharmony_ci#define SR_MAX_FRAME_RETRIES	0x2c, 0xf0, 4
15962306a36Sopenharmony_ci#define RG_CSMA_SEED_0	(0x2d)
16062306a36Sopenharmony_ci#define SR_CSMA_SEED_0		0x2d, 0xff, 0
16162306a36Sopenharmony_ci#define RG_CSMA_SEED_1	(0x2e)
16262306a36Sopenharmony_ci#define SR_CSMA_SEED_1		0x2e, 0x07, 0
16362306a36Sopenharmony_ci#define SR_AACK_I_AM_COORD	0x2e, 0x08, 3
16462306a36Sopenharmony_ci#define SR_AACK_DIS_ACK		0x2e, 0x10, 4
16562306a36Sopenharmony_ci#define SR_AACK_SET_PD		0x2e, 0x20, 5
16662306a36Sopenharmony_ci#define SR_AACK_FVN_MODE	0x2e, 0xc0, 6
16762306a36Sopenharmony_ci#define RG_CSMA_BE	(0x2f)
16862306a36Sopenharmony_ci#define SR_MIN_BE		0x2f, 0x0f, 0
16962306a36Sopenharmony_ci#define SR_MAX_BE		0x2f, 0xf0, 4
17062306a36Sopenharmony_ci
17162306a36Sopenharmony_ci#define CMD_REG		0x80
17262306a36Sopenharmony_ci#define CMD_REG_MASK	0x3f
17362306a36Sopenharmony_ci#define CMD_WRITE	0x40
17462306a36Sopenharmony_ci#define CMD_FB		0x20
17562306a36Sopenharmony_ci
17662306a36Sopenharmony_ci#define IRQ_BAT_LOW	BIT(7)
17762306a36Sopenharmony_ci#define IRQ_TRX_UR	BIT(6)
17862306a36Sopenharmony_ci#define IRQ_AMI		BIT(5)
17962306a36Sopenharmony_ci#define IRQ_CCA_ED	BIT(4)
18062306a36Sopenharmony_ci#define IRQ_TRX_END	BIT(3)
18162306a36Sopenharmony_ci#define IRQ_RX_START	BIT(2)
18262306a36Sopenharmony_ci#define IRQ_PLL_UNL	BIT(1)
18362306a36Sopenharmony_ci#define IRQ_PLL_LOCK	BIT(0)
18462306a36Sopenharmony_ci
18562306a36Sopenharmony_ci#define IRQ_ACTIVE_HIGH	0
18662306a36Sopenharmony_ci#define IRQ_ACTIVE_LOW	1
18762306a36Sopenharmony_ci
18862306a36Sopenharmony_ci#define STATE_P_ON		0x00	/* BUSY */
18962306a36Sopenharmony_ci#define STATE_BUSY_RX		0x01
19062306a36Sopenharmony_ci#define STATE_BUSY_TX		0x02
19162306a36Sopenharmony_ci#define STATE_FORCE_TRX_OFF	0x03
19262306a36Sopenharmony_ci#define STATE_FORCE_TX_ON	0x04	/* IDLE */
19362306a36Sopenharmony_ci/* 0x05 */				/* INVALID_PARAMETER */
19462306a36Sopenharmony_ci#define STATE_RX_ON		0x06
19562306a36Sopenharmony_ci/* 0x07 */				/* SUCCESS */
19662306a36Sopenharmony_ci#define STATE_TRX_OFF		0x08
19762306a36Sopenharmony_ci#define STATE_TX_ON		0x09
19862306a36Sopenharmony_ci/* 0x0a - 0x0e */			/* 0x0a - UNSUPPORTED_ATTRIBUTE */
19962306a36Sopenharmony_ci#define STATE_SLEEP		0x0F
20062306a36Sopenharmony_ci#define STATE_PREP_DEEP_SLEEP	0x10
20162306a36Sopenharmony_ci#define STATE_BUSY_RX_AACK	0x11
20262306a36Sopenharmony_ci#define STATE_BUSY_TX_ARET	0x12
20362306a36Sopenharmony_ci#define STATE_RX_AACK_ON	0x16
20462306a36Sopenharmony_ci#define STATE_TX_ARET_ON	0x19
20562306a36Sopenharmony_ci#define STATE_RX_ON_NOCLK	0x1C
20662306a36Sopenharmony_ci#define STATE_RX_AACK_ON_NOCLK	0x1D
20762306a36Sopenharmony_ci#define STATE_BUSY_RX_AACK_NOCLK 0x1E
20862306a36Sopenharmony_ci#define STATE_TRANSITION_IN_PROGRESS 0x1F
20962306a36Sopenharmony_ci
21062306a36Sopenharmony_ci#define TRX_STATE_MASK		(0x1F)
21162306a36Sopenharmony_ci#define TRAC_MASK(x)		((x & 0xe0) >> 5)
21262306a36Sopenharmony_ci
21362306a36Sopenharmony_ci#define TRAC_SUCCESS			0
21462306a36Sopenharmony_ci#define TRAC_SUCCESS_DATA_PENDING	1
21562306a36Sopenharmony_ci#define TRAC_SUCCESS_WAIT_FOR_ACK	2
21662306a36Sopenharmony_ci#define TRAC_CHANNEL_ACCESS_FAILURE	3
21762306a36Sopenharmony_ci#define TRAC_NO_ACK			5
21862306a36Sopenharmony_ci#define TRAC_INVALID			7
21962306a36Sopenharmony_ci
22062306a36Sopenharmony_ci#endif /* !_AT86RF230_H */
221