Skip to content

Commit 2323cf3

Browse files
alexaringholtmann
authored andcommitted
mrf24j40: add csma params support
This patch adds supports to change the CSMA parameters. The datasheet doesn't say anything about max_be value. Seems not configurable and we assume the 802.15.4 default. But this value must exists because there is a min_be value. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent 3744161 commit 2323cf3

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

drivers/net/ieee802154/mrf24j40.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,21 @@ static int mrf24j40_handle_rx(struct mrf24j40 *devrec)
776776
return spi_async(devrec->spi, &devrec->rx_msg);
777777
}
778778

779+
static int
780+
mrf24j40_csma_params(struct ieee802154_hw *hw, u8 min_be, u8 max_be,
781+
u8 retries)
782+
{
783+
struct mrf24j40 *devrec = hw->priv;
784+
u8 val;
785+
786+
/* min_be */
787+
val = min_be << 3;
788+
/* csma backoffs */
789+
val |= retries;
790+
791+
return regmap_update_bits(devrec->regmap_short, REG_TXMCR, 0x1f, val);
792+
}
793+
779794
static const struct ieee802154_ops mrf24j40_ops = {
780795
.owner = THIS_MODULE,
781796
.xmit_async = mrf24j40_tx,
@@ -784,6 +799,7 @@ static const struct ieee802154_ops mrf24j40_ops = {
784799
.stop = mrf24j40_stop,
785800
.set_channel = mrf24j40_set_channel,
786801
.set_hw_addr_filt = mrf24j40_filter,
802+
.set_csma_params = mrf24j40_csma_params,
787803
};
788804

789805
static void mrf24j40_intstat_complete(void *context)
@@ -979,6 +995,14 @@ static void mrf24j40_phy_setup(struct mrf24j40 *devrec)
979995
{
980996
ieee802154_random_extended_addr(&devrec->hw->phy->perm_extended_addr);
981997
devrec->hw->phy->current_channel = 11;
998+
999+
/* mrf24j40 supports max_minbe 0 - 3 */
1000+
devrec->hw->phy->supported.max_minbe = 3;
1001+
/* datasheet doesn't say anything about max_be, but we have min_be
1002+
* So we assume the max_be default.
1003+
*/
1004+
devrec->hw->phy->supported.min_maxbe = 5;
1005+
devrec->hw->phy->supported.max_maxbe = 5;
9821006
}
9831007

9841008
static int mrf24j40_probe(struct spi_device *spi)
@@ -1001,7 +1025,8 @@ static int mrf24j40_probe(struct spi_device *spi)
10011025
devrec->hw = hw;
10021026
devrec->hw->parent = &spi->dev;
10031027
devrec->hw->phy->supported.channels[0] = CHANNEL_MASK;
1004-
devrec->hw->flags = IEEE802154_HW_TX_OMIT_CKSUM | IEEE802154_HW_AFILT;
1028+
devrec->hw->flags = IEEE802154_HW_TX_OMIT_CKSUM | IEEE802154_HW_AFILT |
1029+
IEEE802154_HW_CSMA_PARAMS;
10051030

10061031
mrf24j40_setup_tx_spi_messages(devrec);
10071032
mrf24j40_setup_rx_spi_messages(devrec);

0 commit comments

Comments
 (0)