1 // SPDX-License-Identifier: GPL-2.0-only
3 * AT86RF230/RF231 driver
5 * Copyright (C) 2009-2012 Siemens AG
8 * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
9 * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
10 * Alexander Aring <aar@pengutronix.de>
12 #include <linux/kernel.h>
13 #include <linux/module.h>
14 #include <linux/hrtimer.h>
15 #include <linux/jiffies.h>
16 #include <linux/interrupt.h>
17 #include <linux/irq.h>
18 #include <linux/gpio.h>
19 #include <linux/delay.h>
20 #include <linux/spi/spi.h>
21 #include <linux/spi/at86rf230.h>
22 #include <linux/regmap.h>
23 #include <linux/skbuff.h>
24 #include <linux/of_gpio.h>
25 #include <linux/ieee802154.h>
26 #include <linux/debugfs.h>
28 #include <net/mac802154.h>
29 #include <net/cfg802154.h>
31 #include "at86rf230.h"
33 struct at86rf230_local;
34 /* at86rf2xx chip depend data.
35 * All timings are in us.
37 struct at86rf2xx_chip_data {
49 int (*set_channel)(struct at86rf230_local *, u8, u8);
50 int (*set_txpower)(struct at86rf230_local *, s32);
53 #define AT86RF2XX_MAX_BUF (127 + 3)
54 /* tx retries to access the TX_ON state
55 * if it's above then force change will be started.
57 * We assume the max_frame_retries (7) value of 802.15.4 here.
59 #define AT86RF2XX_MAX_TX_RETRIES 7
60 /* We use the recommended 5 minutes timeout to recalibrate */
61 #define AT86RF2XX_CAL_LOOP_TIMEOUT (5 * 60 * HZ)
63 struct at86rf230_state_change {
64 struct at86rf230_local *lp;
68 struct spi_message msg;
69 struct spi_transfer trx;
70 u8 buf[AT86RF2XX_MAX_BUF];
72 void (*complete)(void *context);
79 struct at86rf230_trac {
81 u64 success_data_pending;
82 u64 success_wait_for_ack;
83 u64 channel_access_failure;
88 struct at86rf230_local {
89 struct spi_device *spi;
91 struct ieee802154_hw *hw;
92 struct at86rf2xx_chip_data *data;
93 struct regmap *regmap;
97 struct completion state_complete;
98 struct at86rf230_state_change state;
100 unsigned long cal_timeout;
105 struct sk_buff *tx_skb;
106 struct at86rf230_state_change tx;
108 struct at86rf230_trac trac;
111 #define AT86RF2XX_NUMREGS 0x3F
114 at86rf230_async_state_change(struct at86rf230_local *lp,
115 struct at86rf230_state_change *ctx,
116 const u8 state, void (*complete)(void *context));
119 at86rf230_sleep(struct at86rf230_local *lp)
121 if (gpio_is_valid(lp->slp_tr)) {
122 gpio_set_value(lp->slp_tr, 1);
123 usleep_range(lp->data->t_off_to_sleep,
124 lp->data->t_off_to_sleep + 10);
130 at86rf230_awake(struct at86rf230_local *lp)
132 if (gpio_is_valid(lp->slp_tr)) {
133 gpio_set_value(lp->slp_tr, 0);
134 usleep_range(lp->data->t_sleep_to_off,
135 lp->data->t_sleep_to_off + 100);
141 __at86rf230_write(struct at86rf230_local *lp,
142 unsigned int addr, unsigned int data)
144 bool sleep = lp->sleep;
147 /* awake for register setting if sleep */
151 ret = regmap_write(lp->regmap, addr, data);
153 /* sleep again if was sleeping */
161 __at86rf230_read(struct at86rf230_local *lp,
162 unsigned int addr, unsigned int *data)
164 bool sleep = lp->sleep;
167 /* awake for register setting if sleep */
171 ret = regmap_read(lp->regmap, addr, data);
173 /* sleep again if was sleeping */
181 at86rf230_read_subreg(struct at86rf230_local *lp,
182 unsigned int addr, unsigned int mask,
183 unsigned int shift, unsigned int *data)
187 rc = __at86rf230_read(lp, addr, data);
189 *data = (*data & mask) >> shift;
195 at86rf230_write_subreg(struct at86rf230_local *lp,
196 unsigned int addr, unsigned int mask,
197 unsigned int shift, unsigned int data)
199 bool sleep = lp->sleep;
202 /* awake for register setting if sleep */
206 ret = regmap_update_bits(lp->regmap, addr, mask, data << shift);
208 /* sleep again if was sleeping */
216 at86rf230_slp_tr_rising_edge(struct at86rf230_local *lp)
218 gpio_set_value(lp->slp_tr, 1);
220 gpio_set_value(lp->slp_tr, 0);
224 at86rf230_reg_writeable(struct device *dev, unsigned int reg)
231 case RG_PHY_ED_LEVEL:
247 case RG_SHORT_ADDR_0:
248 case RG_SHORT_ADDR_1:
270 at86rf230_reg_readable(struct device *dev, unsigned int reg)
274 /* all writeable are also readable */
275 rc = at86rf230_reg_writeable(dev, reg);
295 at86rf230_reg_volatile(struct device *dev, unsigned int reg)
297 /* can be changed during runtime */
302 case RG_PHY_ED_LEVEL:
314 at86rf230_reg_precious(struct device *dev, unsigned int reg)
316 /* don't clear irq line on read */
325 static const struct regmap_config at86rf230_regmap_spi_config = {
328 .write_flag_mask = CMD_REG | CMD_WRITE,
329 .read_flag_mask = CMD_REG,
330 .cache_type = REGCACHE_RBTREE,
331 .max_register = AT86RF2XX_NUMREGS,
332 .writeable_reg = at86rf230_reg_writeable,
333 .readable_reg = at86rf230_reg_readable,
334 .volatile_reg = at86rf230_reg_volatile,
335 .precious_reg = at86rf230_reg_precious,
339 at86rf230_async_error_recover_complete(void *context)
341 struct at86rf230_state_change *ctx = context;
342 struct at86rf230_local *lp = ctx->lp;
349 dev_kfree_skb_any(lp->tx_skb);
350 ieee802154_wake_queue(lp->hw);
355 at86rf230_async_error_recover(void *context)
357 struct at86rf230_state_change *ctx = context;
358 struct at86rf230_local *lp = ctx->lp;
365 at86rf230_async_state_change(lp, ctx, STATE_RX_AACK_ON,
366 at86rf230_async_error_recover_complete);
370 at86rf230_async_error(struct at86rf230_local *lp,
371 struct at86rf230_state_change *ctx, int rc)
373 dev_err(&lp->spi->dev, "spi_async error %d\n", rc);
375 at86rf230_async_state_change(lp, ctx, STATE_FORCE_TRX_OFF,
376 at86rf230_async_error_recover);
379 /* Generic function to get some register value in async mode */
381 at86rf230_async_read_reg(struct at86rf230_local *lp, u8 reg,
382 struct at86rf230_state_change *ctx,
383 void (*complete)(void *context))
387 u8 *tx_buf = ctx->buf;
389 tx_buf[0] = (reg & CMD_REG_MASK) | CMD_REG;
390 ctx->msg.complete = complete;
391 rc = spi_async(lp->spi, &ctx->msg);
393 at86rf230_async_error(lp, ctx, rc);
397 at86rf230_async_write_reg(struct at86rf230_local *lp, u8 reg, u8 val,
398 struct at86rf230_state_change *ctx,
399 void (*complete)(void *context))
403 ctx->buf[0] = (reg & CMD_REG_MASK) | CMD_REG | CMD_WRITE;
405 ctx->msg.complete = complete;
406 rc = spi_async(lp->spi, &ctx->msg);
408 at86rf230_async_error(lp, ctx, rc);
412 at86rf230_async_state_assert(void *context)
414 struct at86rf230_state_change *ctx = context;
415 struct at86rf230_local *lp = ctx->lp;
416 const u8 *buf = ctx->buf;
417 const u8 trx_state = buf[1] & TRX_STATE_MASK;
419 /* Assert state change */
420 if (trx_state != ctx->to_state) {
421 /* Special handling if transceiver state is in
422 * STATE_BUSY_RX_AACK and a SHR was detected.
424 if (trx_state == STATE_BUSY_RX_AACK) {
425 /* Undocumented race condition. If we send a state
426 * change to STATE_RX_AACK_ON the transceiver could
427 * change his state automatically to STATE_BUSY_RX_AACK
428 * if a SHR was detected. This is not an error, but we
431 if (ctx->to_state == STATE_RX_AACK_ON)
434 /* If we change to STATE_TX_ON without forcing and
435 * transceiver state is STATE_BUSY_RX_AACK, we wait
436 * 'tFrame + tPAck' receiving time. In this time the
437 * PDU should be received. If the transceiver is still
438 * in STATE_BUSY_RX_AACK, we run a force state change
439 * to STATE_TX_ON. This is a timeout handling, if the
440 * transceiver stucks in STATE_BUSY_RX_AACK.
442 * Additional we do several retries to try to get into
443 * TX_ON state without forcing. If the retries are
444 * higher or equal than AT86RF2XX_MAX_TX_RETRIES we
445 * will do a force change.
447 if (ctx->to_state == STATE_TX_ON ||
448 ctx->to_state == STATE_TRX_OFF) {
449 u8 state = ctx->to_state;
451 if (lp->tx_retry >= AT86RF2XX_MAX_TX_RETRIES)
452 state = STATE_FORCE_TRX_OFF;
455 at86rf230_async_state_change(lp, ctx, state,
461 dev_warn(&lp->spi->dev, "unexcept state change from 0x%02x to 0x%02x. Actual state: 0x%02x\n",
462 ctx->from_state, ctx->to_state, trx_state);
467 ctx->complete(context);
470 static enum hrtimer_restart at86rf230_async_state_timer(struct hrtimer *timer)
472 struct at86rf230_state_change *ctx =
473 container_of(timer, struct at86rf230_state_change, timer);
474 struct at86rf230_local *lp = ctx->lp;
476 at86rf230_async_read_reg(lp, RG_TRX_STATUS, ctx,
477 at86rf230_async_state_assert);
479 return HRTIMER_NORESTART;
482 /* Do state change timing delay. */
484 at86rf230_async_state_delay(void *context)
486 struct at86rf230_state_change *ctx = context;
487 struct at86rf230_local *lp = ctx->lp;
488 struct at86rf2xx_chip_data *c = lp->data;
492 /* The force state changes are will show as normal states in the
493 * state status subregister. We change the to_state to the
494 * corresponding one and remember if it was a force change, this
495 * differs if we do a state change from STATE_BUSY_RX_AACK.
497 switch (ctx->to_state) {
498 case STATE_FORCE_TX_ON:
499 ctx->to_state = STATE_TX_ON;
502 case STATE_FORCE_TRX_OFF:
503 ctx->to_state = STATE_TRX_OFF;
510 switch (ctx->from_state) {
512 switch (ctx->to_state) {
513 case STATE_RX_AACK_ON:
514 tim = c->t_off_to_aack * NSEC_PER_USEC;
515 /* state change from TRX_OFF to RX_AACK_ON to do a
516 * calibration, we need to reset the timeout for the
519 lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT;
521 case STATE_TX_ARET_ON:
523 tim = c->t_off_to_tx_on * NSEC_PER_USEC;
524 /* state change from TRX_OFF to TX_ON or ARET_ON to do
525 * a calibration, we need to reset the timeout for the
528 lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT;
534 case STATE_BUSY_RX_AACK:
535 switch (ctx->to_state) {
538 /* Wait for worst case receiving time if we
539 * didn't make a force change from BUSY_RX_AACK
540 * to TX_ON or TRX_OFF.
543 tim = (c->t_frame + c->t_p_ack) * NSEC_PER_USEC;
551 /* Default value, means RESET state */
553 switch (ctx->to_state) {
555 tim = c->t_reset_to_off * NSEC_PER_USEC;
565 /* Default delay is 1us in the most cases */
567 at86rf230_async_state_timer(&ctx->timer);
571 hrtimer_start(&ctx->timer, tim, HRTIMER_MODE_REL);
575 at86rf230_async_state_change_start(void *context)
577 struct at86rf230_state_change *ctx = context;
578 struct at86rf230_local *lp = ctx->lp;
580 const u8 trx_state = buf[1] & TRX_STATE_MASK;
582 /* Check for "possible" STATE_TRANSITION_IN_PROGRESS */
583 if (trx_state == STATE_TRANSITION_IN_PROGRESS) {
585 at86rf230_async_read_reg(lp, RG_TRX_STATUS, ctx,
586 at86rf230_async_state_change_start);
590 /* Check if we already are in the state which we change in */
591 if (trx_state == ctx->to_state) {
593 ctx->complete(context);
597 /* Set current state to the context of state change */
598 ctx->from_state = trx_state;
600 /* Going into the next step for a state change which do a timing
603 at86rf230_async_write_reg(lp, RG_TRX_STATE, ctx->to_state, ctx,
604 at86rf230_async_state_delay);
608 at86rf230_async_state_change(struct at86rf230_local *lp,
609 struct at86rf230_state_change *ctx,
610 const u8 state, void (*complete)(void *context))
612 /* Initialization for the state change context */
613 ctx->to_state = state;
614 ctx->complete = complete;
615 at86rf230_async_read_reg(lp, RG_TRX_STATUS, ctx,
616 at86rf230_async_state_change_start);
620 at86rf230_sync_state_change_complete(void *context)
622 struct at86rf230_state_change *ctx = context;
623 struct at86rf230_local *lp = ctx->lp;
625 complete(&lp->state_complete);
628 /* This function do a sync framework above the async state change.
629 * Some callbacks of the IEEE 802.15.4 driver interface need to be
630 * handled synchronously.
633 at86rf230_sync_state_change(struct at86rf230_local *lp, unsigned int state)
637 at86rf230_async_state_change(lp, &lp->state, state,
638 at86rf230_sync_state_change_complete);
640 rc = wait_for_completion_timeout(&lp->state_complete,
641 msecs_to_jiffies(100));
643 at86rf230_async_error(lp, &lp->state, -ETIMEDOUT);
651 at86rf230_tx_complete(void *context)
653 struct at86rf230_state_change *ctx = context;
654 struct at86rf230_local *lp = ctx->lp;
656 ieee802154_xmit_complete(lp->hw, lp->tx_skb, false);
661 at86rf230_tx_on(void *context)
663 struct at86rf230_state_change *ctx = context;
664 struct at86rf230_local *lp = ctx->lp;
666 at86rf230_async_state_change(lp, ctx, STATE_RX_AACK_ON,
667 at86rf230_tx_complete);
671 at86rf230_tx_trac_check(void *context)
673 struct at86rf230_state_change *ctx = context;
674 struct at86rf230_local *lp = ctx->lp;
676 if (IS_ENABLED(CONFIG_IEEE802154_AT86RF230_DEBUGFS)) {
677 u8 trac = TRAC_MASK(ctx->buf[1]);
683 case TRAC_SUCCESS_DATA_PENDING:
684 lp->trac.success_data_pending++;
686 case TRAC_CHANNEL_ACCESS_FAILURE:
687 lp->trac.channel_access_failure++;
696 WARN_ONCE(1, "received tx trac status %d\n", trac);
701 at86rf230_async_state_change(lp, ctx, STATE_TX_ON, at86rf230_tx_on);
705 at86rf230_rx_read_frame_complete(void *context)
707 struct at86rf230_state_change *ctx = context;
708 struct at86rf230_local *lp = ctx->lp;
709 const u8 *buf = ctx->buf;
714 if (!ieee802154_is_valid_psdu_len(len)) {
715 dev_vdbg(&lp->spi->dev, "corrupted frame received\n");
716 len = IEEE802154_MTU;
720 skb = dev_alloc_skb(IEEE802154_MTU);
722 dev_vdbg(&lp->spi->dev, "failed to allocate sk_buff\n");
727 skb_put_data(skb, buf + 2, len);
728 ieee802154_rx_irqsafe(lp->hw, skb, lqi);
733 at86rf230_rx_trac_check(void *context)
735 struct at86rf230_state_change *ctx = context;
736 struct at86rf230_local *lp = ctx->lp;
740 if (IS_ENABLED(CONFIG_IEEE802154_AT86RF230_DEBUGFS)) {
741 u8 trac = TRAC_MASK(buf[1]);
747 case TRAC_SUCCESS_WAIT_FOR_ACK:
748 lp->trac.success_wait_for_ack++;
754 WARN_ONCE(1, "received rx trac status %d\n", trac);
760 ctx->trx.len = AT86RF2XX_MAX_BUF;
761 ctx->msg.complete = at86rf230_rx_read_frame_complete;
762 rc = spi_async(lp->spi, &ctx->msg);
765 at86rf230_async_error(lp, ctx, rc);
770 at86rf230_irq_trx_end(void *context)
772 struct at86rf230_state_change *ctx = context;
773 struct at86rf230_local *lp = ctx->lp;
777 at86rf230_async_read_reg(lp, RG_TRX_STATE, ctx,
778 at86rf230_tx_trac_check);
780 at86rf230_async_read_reg(lp, RG_TRX_STATE, ctx,
781 at86rf230_rx_trac_check);
786 at86rf230_irq_status(void *context)
788 struct at86rf230_state_change *ctx = context;
789 struct at86rf230_local *lp = ctx->lp;
790 const u8 *buf = ctx->buf;
793 enable_irq(lp->spi->irq);
795 if (irq & IRQ_TRX_END) {
796 at86rf230_irq_trx_end(ctx);
798 dev_err(&lp->spi->dev, "not supported irq %02x received\n",
805 at86rf230_setup_spi_messages(struct at86rf230_local *lp,
806 struct at86rf230_state_change *state)
809 state->irq = lp->spi->irq;
810 spi_message_init(&state->msg);
811 state->msg.context = state;
813 state->trx.tx_buf = state->buf;
814 state->trx.rx_buf = state->buf;
815 spi_message_add_tail(&state->trx, &state->msg);
816 hrtimer_init(&state->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
817 state->timer.function = at86rf230_async_state_timer;
820 static irqreturn_t at86rf230_isr(int irq, void *data)
822 struct at86rf230_local *lp = data;
823 struct at86rf230_state_change *ctx;
826 disable_irq_nosync(irq);
828 ctx = kzalloc(sizeof(*ctx), GFP_ATOMIC);
834 at86rf230_setup_spi_messages(lp, ctx);
835 /* tell on error handling to free ctx */
838 ctx->buf[0] = (RG_IRQ_STATUS & CMD_REG_MASK) | CMD_REG;
839 ctx->msg.complete = at86rf230_irq_status;
840 rc = spi_async(lp->spi, &ctx->msg);
842 at86rf230_async_error(lp, ctx, rc);
851 at86rf230_write_frame_complete(void *context)
853 struct at86rf230_state_change *ctx = context;
854 struct at86rf230_local *lp = ctx->lp;
858 if (gpio_is_valid(lp->slp_tr))
859 at86rf230_slp_tr_rising_edge(lp);
861 at86rf230_async_write_reg(lp, RG_TRX_STATE, STATE_BUSY_TX, ctx,
866 at86rf230_write_frame(void *context)
868 struct at86rf230_state_change *ctx = context;
869 struct at86rf230_local *lp = ctx->lp;
870 struct sk_buff *skb = lp->tx_skb;
876 buf[0] = CMD_FB | CMD_WRITE;
877 buf[1] = skb->len + 2;
878 memcpy(buf + 2, skb->data, skb->len);
879 ctx->trx.len = skb->len + 2;
880 ctx->msg.complete = at86rf230_write_frame_complete;
881 rc = spi_async(lp->spi, &ctx->msg);
884 at86rf230_async_error(lp, ctx, rc);
889 at86rf230_xmit_tx_on(void *context)
891 struct at86rf230_state_change *ctx = context;
892 struct at86rf230_local *lp = ctx->lp;
894 at86rf230_async_state_change(lp, ctx, STATE_TX_ARET_ON,
895 at86rf230_write_frame);
899 at86rf230_xmit_start(void *context)
901 struct at86rf230_state_change *ctx = context;
902 struct at86rf230_local *lp = ctx->lp;
904 /* check if we change from off state */
905 if (lp->is_tx_from_off)
906 at86rf230_async_state_change(lp, ctx, STATE_TX_ARET_ON,
907 at86rf230_write_frame);
909 at86rf230_async_state_change(lp, ctx, STATE_TX_ON,
910 at86rf230_xmit_tx_on);
914 at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
916 struct at86rf230_local *lp = hw->priv;
917 struct at86rf230_state_change *ctx = &lp->tx;
922 /* After 5 minutes in PLL and the same frequency we run again the
923 * calibration loops which is recommended by at86rf2xx datasheets.
925 * The calibration is initiate by a state change from TRX_OFF
926 * to TX_ON, the lp->cal_timeout should be reinit by state_delay
927 * function then to start in the next 5 minutes.
929 if (time_is_before_jiffies(lp->cal_timeout)) {
930 lp->is_tx_from_off = true;
931 at86rf230_async_state_change(lp, ctx, STATE_TRX_OFF,
932 at86rf230_xmit_start);
934 lp->is_tx_from_off = false;
935 at86rf230_xmit_start(ctx);
942 at86rf230_ed(struct ieee802154_hw *hw, u8 *level)
950 at86rf230_start(struct ieee802154_hw *hw)
952 struct at86rf230_local *lp = hw->priv;
954 /* reset trac stats on start */
955 if (IS_ENABLED(CONFIG_IEEE802154_AT86RF230_DEBUGFS))
956 memset(&lp->trac, 0, sizeof(struct at86rf230_trac));
959 enable_irq(lp->spi->irq);
961 return at86rf230_sync_state_change(lp, STATE_RX_AACK_ON);
965 at86rf230_stop(struct ieee802154_hw *hw)
967 struct at86rf230_local *lp = hw->priv;
970 at86rf230_sync_state_change(lp, STATE_FORCE_TRX_OFF);
972 disable_irq(lp->spi->irq);
974 /* It's recommended to set random new csma_seeds before sleep state.
975 * Makes only sense in the stop callback, not doing this inside of
976 * at86rf230_sleep, this is also used when we don't transmit afterwards
977 * when calling start callback again.
979 get_random_bytes(csma_seed, ARRAY_SIZE(csma_seed));
980 at86rf230_write_subreg(lp, SR_CSMA_SEED_0, csma_seed[0]);
981 at86rf230_write_subreg(lp, SR_CSMA_SEED_1, csma_seed[1]);
987 at86rf23x_set_channel(struct at86rf230_local *lp, u8 page, u8 channel)
989 return at86rf230_write_subreg(lp, SR_CHANNEL, channel);
992 #define AT86RF2XX_MAX_ED_LEVELS 0xF
993 static const s32 at86rf233_ed_levels[AT86RF2XX_MAX_ED_LEVELS + 1] = {
994 -9400, -9200, -9000, -8800, -8600, -8400, -8200, -8000, -7800, -7600,
995 -7400, -7200, -7000, -6800, -6600, -6400,
998 static const s32 at86rf231_ed_levels[AT86RF2XX_MAX_ED_LEVELS + 1] = {
999 -9100, -8900, -8700, -8500, -8300, -8100, -7900, -7700, -7500, -7300,
1000 -7100, -6900, -6700, -6500, -6300, -6100,
1003 static const s32 at86rf212_ed_levels_100[AT86RF2XX_MAX_ED_LEVELS + 1] = {
1004 -10000, -9800, -9600, -9400, -9200, -9000, -8800, -8600, -8400, -8200,
1005 -8000, -7800, -7600, -7400, -7200, -7000,
1008 static const s32 at86rf212_ed_levels_98[AT86RF2XX_MAX_ED_LEVELS + 1] = {
1009 -9800, -9600, -9400, -9200, -9000, -8800, -8600, -8400, -8200, -8000,
1010 -7800, -7600, -7400, -7200, -7000, -6800,
1014 at86rf212_update_cca_ed_level(struct at86rf230_local *lp, int rssi_base_val)
1016 unsigned int cca_ed_thres;
1019 rc = at86rf230_read_subreg(lp, SR_CCA_ED_THRES, &cca_ed_thres);
1023 switch (rssi_base_val) {
1025 lp->hw->phy->supported.cca_ed_levels = at86rf212_ed_levels_98;
1026 lp->hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(at86rf212_ed_levels_98);
1027 lp->hw->phy->cca_ed_level = at86rf212_ed_levels_98[cca_ed_thres];
1030 lp->hw->phy->supported.cca_ed_levels = at86rf212_ed_levels_100;
1031 lp->hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(at86rf212_ed_levels_100);
1032 lp->hw->phy->cca_ed_level = at86rf212_ed_levels_100[cca_ed_thres];
1042 at86rf212_set_channel(struct at86rf230_local *lp, u8 page, u8 channel)
1047 rc = at86rf230_write_subreg(lp, SR_SUB_MODE, 0);
1049 rc = at86rf230_write_subreg(lp, SR_SUB_MODE, 1);
1054 rc = at86rf230_write_subreg(lp, SR_BPSK_QPSK, 0);
1055 lp->data->rssi_base_val = -100;
1057 rc = at86rf230_write_subreg(lp, SR_BPSK_QPSK, 1);
1058 lp->data->rssi_base_val = -98;
1063 rc = at86rf212_update_cca_ed_level(lp, lp->data->rssi_base_val);
1067 /* This sets the symbol_duration according frequency on the 212.
1068 * TODO move this handling while set channel and page in cfg802154.
1069 * We can do that, this timings are according 802.15.4 standard.
1070 * If we do that in cfg802154, this is a more generic calculation.
1072 * This should also protected from ifs_timer. Means cancel timer and
1073 * init with a new value. For now, this is okay.
1077 /* SUB:0 and BPSK:0 -> BPSK-20 */
1078 lp->hw->phy->symbol_duration = 50;
1080 /* SUB:1 and BPSK:0 -> BPSK-40 */
1081 lp->hw->phy->symbol_duration = 25;
1085 /* SUB:0 and BPSK:1 -> OQPSK-100/200/400 */
1086 lp->hw->phy->symbol_duration = 40;
1088 /* SUB:1 and BPSK:1 -> OQPSK-250/500/1000 */
1089 lp->hw->phy->symbol_duration = 16;
1092 lp->hw->phy->lifs_period = IEEE802154_LIFS_PERIOD *
1093 lp->hw->phy->symbol_duration;
1094 lp->hw->phy->sifs_period = IEEE802154_SIFS_PERIOD *
1095 lp->hw->phy->symbol_duration;
1097 return at86rf230_write_subreg(lp, SR_CHANNEL, channel);
1101 at86rf230_channel(struct ieee802154_hw *hw, u8 page, u8 channel)
1103 struct at86rf230_local *lp = hw->priv;
1106 rc = lp->data->set_channel(lp, page, channel);
1108 usleep_range(lp->data->t_channel_switch,
1109 lp->data->t_channel_switch + 10);
1111 lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT;
1116 at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
1117 struct ieee802154_hw_addr_filt *filt,
1118 unsigned long changed)
1120 struct at86rf230_local *lp = hw->priv;
1122 if (changed & IEEE802154_AFILT_SADDR_CHANGED) {
1123 u16 addr = le16_to_cpu(filt->short_addr);
1125 dev_vdbg(&lp->spi->dev, "%s called for saddr\n", __func__);
1126 __at86rf230_write(lp, RG_SHORT_ADDR_0, addr);
1127 __at86rf230_write(lp, RG_SHORT_ADDR_1, addr >> 8);
1130 if (changed & IEEE802154_AFILT_PANID_CHANGED) {
1131 u16 pan = le16_to_cpu(filt->pan_id);
1133 dev_vdbg(&lp->spi->dev, "%s called for pan id\n", __func__);
1134 __at86rf230_write(lp, RG_PAN_ID_0, pan);
1135 __at86rf230_write(lp, RG_PAN_ID_1, pan >> 8);
1138 if (changed & IEEE802154_AFILT_IEEEADDR_CHANGED) {
1141 memcpy(addr, &filt->ieee_addr, 8);
1142 dev_vdbg(&lp->spi->dev, "%s called for IEEE addr\n", __func__);
1143 for (i = 0; i < 8; i++)
1144 __at86rf230_write(lp, RG_IEEE_ADDR_0 + i, addr[i]);
1147 if (changed & IEEE802154_AFILT_PANC_CHANGED) {
1148 dev_vdbg(&lp->spi->dev, "%s called for panc change\n", __func__);
1149 if (filt->pan_coord)
1150 at86rf230_write_subreg(lp, SR_AACK_I_AM_COORD, 1);
1152 at86rf230_write_subreg(lp, SR_AACK_I_AM_COORD, 0);
1158 #define AT86RF23X_MAX_TX_POWERS 0xF
1159 static const s32 at86rf233_powers[AT86RF23X_MAX_TX_POWERS + 1] = {
1160 400, 370, 340, 300, 250, 200, 100, 0, -100, -200, -300, -400, -600,
1164 static const s32 at86rf231_powers[AT86RF23X_MAX_TX_POWERS + 1] = {
1165 300, 280, 230, 180, 130, 70, 0, -100, -200, -300, -400, -500, -700,
1169 #define AT86RF212_MAX_TX_POWERS 0x1F
1170 static const s32 at86rf212_powers[AT86RF212_MAX_TX_POWERS + 1] = {
1171 500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500, -600, -700,
1172 -800, -900, -1000, -1100, -1200, -1300, -1400, -1500, -1600, -1700,
1173 -1800, -1900, -2000, -2100, -2200, -2300, -2400, -2500, -2600,
1177 at86rf23x_set_txpower(struct at86rf230_local *lp, s32 mbm)
1181 for (i = 0; i < lp->hw->phy->supported.tx_powers_size; i++) {
1182 if (lp->hw->phy->supported.tx_powers[i] == mbm)
1183 return at86rf230_write_subreg(lp, SR_TX_PWR_23X, i);
1190 at86rf212_set_txpower(struct at86rf230_local *lp, s32 mbm)
1194 for (i = 0; i < lp->hw->phy->supported.tx_powers_size; i++) {
1195 if (lp->hw->phy->supported.tx_powers[i] == mbm)
1196 return at86rf230_write_subreg(lp, SR_TX_PWR_212, i);
1203 at86rf230_set_txpower(struct ieee802154_hw *hw, s32 mbm)
1205 struct at86rf230_local *lp = hw->priv;
1207 return lp->data->set_txpower(lp, mbm);
1211 at86rf230_set_lbt(struct ieee802154_hw *hw, bool on)
1213 struct at86rf230_local *lp = hw->priv;
1215 return at86rf230_write_subreg(lp, SR_CSMA_LBT_MODE, on);
1219 at86rf230_set_cca_mode(struct ieee802154_hw *hw,
1220 const struct wpan_phy_cca *cca)
1222 struct at86rf230_local *lp = hw->priv;
1225 /* mapping 802.15.4 to driver spec */
1226 switch (cca->mode) {
1227 case NL802154_CCA_ENERGY:
1230 case NL802154_CCA_CARRIER:
1233 case NL802154_CCA_ENERGY_CARRIER:
1235 case NL802154_CCA_OPT_ENERGY_CARRIER_AND:
1238 case NL802154_CCA_OPT_ENERGY_CARRIER_OR:
1249 return at86rf230_write_subreg(lp, SR_CCA_MODE, val);
1253 at86rf230_set_cca_ed_level(struct ieee802154_hw *hw, s32 mbm)
1255 struct at86rf230_local *lp = hw->priv;
1258 for (i = 0; i < hw->phy->supported.cca_ed_levels_size; i++) {
1259 if (hw->phy->supported.cca_ed_levels[i] == mbm)
1260 return at86rf230_write_subreg(lp, SR_CCA_ED_THRES, i);
1267 at86rf230_set_csma_params(struct ieee802154_hw *hw, u8 min_be, u8 max_be,
1270 struct at86rf230_local *lp = hw->priv;
1273 rc = at86rf230_write_subreg(lp, SR_MIN_BE, min_be);
1277 rc = at86rf230_write_subreg(lp, SR_MAX_BE, max_be);
1281 return at86rf230_write_subreg(lp, SR_MAX_CSMA_RETRIES, retries);
1285 at86rf230_set_frame_retries(struct ieee802154_hw *hw, s8 retries)
1287 struct at86rf230_local *lp = hw->priv;
1289 return at86rf230_write_subreg(lp, SR_MAX_FRAME_RETRIES, retries);
1293 at86rf230_set_promiscuous_mode(struct ieee802154_hw *hw, const bool on)
1295 struct at86rf230_local *lp = hw->priv;
1299 rc = at86rf230_write_subreg(lp, SR_AACK_DIS_ACK, 1);
1303 rc = at86rf230_write_subreg(lp, SR_AACK_PROM_MODE, 1);
1307 rc = at86rf230_write_subreg(lp, SR_AACK_PROM_MODE, 0);
1311 rc = at86rf230_write_subreg(lp, SR_AACK_DIS_ACK, 0);
1319 static const struct ieee802154_ops at86rf230_ops = {
1320 .owner = THIS_MODULE,
1321 .xmit_async = at86rf230_xmit,
1323 .set_channel = at86rf230_channel,
1324 .start = at86rf230_start,
1325 .stop = at86rf230_stop,
1326 .set_hw_addr_filt = at86rf230_set_hw_addr_filt,
1327 .set_txpower = at86rf230_set_txpower,
1328 .set_lbt = at86rf230_set_lbt,
1329 .set_cca_mode = at86rf230_set_cca_mode,
1330 .set_cca_ed_level = at86rf230_set_cca_ed_level,
1331 .set_csma_params = at86rf230_set_csma_params,
1332 .set_frame_retries = at86rf230_set_frame_retries,
1333 .set_promiscuous_mode = at86rf230_set_promiscuous_mode,
1336 static struct at86rf2xx_chip_data at86rf233_data = {
1337 .t_sleep_cycle = 330,
1338 .t_channel_switch = 11,
1339 .t_reset_to_off = 26,
1340 .t_off_to_aack = 80,
1341 .t_off_to_tx_on = 80,
1342 .t_off_to_sleep = 35,
1343 .t_sleep_to_off = 1000,
1346 .rssi_base_val = -94,
1347 .set_channel = at86rf23x_set_channel,
1348 .set_txpower = at86rf23x_set_txpower,
1351 static struct at86rf2xx_chip_data at86rf231_data = {
1352 .t_sleep_cycle = 330,
1353 .t_channel_switch = 24,
1354 .t_reset_to_off = 37,
1355 .t_off_to_aack = 110,
1356 .t_off_to_tx_on = 110,
1357 .t_off_to_sleep = 35,
1358 .t_sleep_to_off = 1000,
1361 .rssi_base_val = -91,
1362 .set_channel = at86rf23x_set_channel,
1363 .set_txpower = at86rf23x_set_txpower,
1366 static struct at86rf2xx_chip_data at86rf212_data = {
1367 .t_sleep_cycle = 330,
1368 .t_channel_switch = 11,
1369 .t_reset_to_off = 26,
1370 .t_off_to_aack = 200,
1371 .t_off_to_tx_on = 200,
1372 .t_off_to_sleep = 35,
1373 .t_sleep_to_off = 1000,
1376 .rssi_base_val = -100,
1377 .set_channel = at86rf212_set_channel,
1378 .set_txpower = at86rf212_set_txpower,
1381 static int at86rf230_hw_init(struct at86rf230_local *lp, u8 xtal_trim)
1383 int rc, irq_type, irq_pol = IRQ_ACTIVE_HIGH;
1387 rc = at86rf230_sync_state_change(lp, STATE_FORCE_TRX_OFF);
1391 irq_type = irq_get_trigger_type(lp->spi->irq);
1392 if (irq_type == IRQ_TYPE_EDGE_FALLING ||
1393 irq_type == IRQ_TYPE_LEVEL_LOW)
1394 irq_pol = IRQ_ACTIVE_LOW;
1396 rc = at86rf230_write_subreg(lp, SR_IRQ_POLARITY, irq_pol);
1400 rc = at86rf230_write_subreg(lp, SR_RX_SAFE_MODE, 1);
1404 rc = at86rf230_write_subreg(lp, SR_IRQ_MASK, IRQ_TRX_END);
1408 /* reset values differs in at86rf231 and at86rf233 */
1409 rc = at86rf230_write_subreg(lp, SR_IRQ_MASK_MODE, 0);
1413 get_random_bytes(csma_seed, ARRAY_SIZE(csma_seed));
1414 rc = at86rf230_write_subreg(lp, SR_CSMA_SEED_0, csma_seed[0]);
1417 rc = at86rf230_write_subreg(lp, SR_CSMA_SEED_1, csma_seed[1]);
1421 /* CLKM changes are applied immediately */
1422 rc = at86rf230_write_subreg(lp, SR_CLKM_SHA_SEL, 0x00);
1427 rc = at86rf230_write_subreg(lp, SR_CLKM_CTRL, 0x00);
1430 /* Wait the next SLEEP cycle */
1431 usleep_range(lp->data->t_sleep_cycle,
1432 lp->data->t_sleep_cycle + 100);
1434 /* xtal_trim value is calculated by:
1435 * CL = 0.5 * (CX + CTRIM + CPAR)
1438 * CL = capacitor of used crystal
1439 * CX = connected capacitors at xtal pins
1440 * CPAR = in all at86rf2xx datasheets this is a constant value 3 pF,
1441 * but this is different on each board setup. You need to fine
1442 * tuning this value via CTRIM.
1443 * CTRIM = variable capacitor setting. Resolution is 0.3 pF range is
1447 * atben transceiver:
1451 * CPAR = 3 pF (We assume the magic constant from datasheet)
1454 * (12+0.9+3)/2 = 7.95 which is nearly at 8 pF
1458 * openlabs transceiver:
1462 * CPAR = 3 pF (We assume the magic constant from datasheet)
1465 * (22+4.5+3)/2 = 14.75 which is the nearest value to 16 pF
1469 rc = at86rf230_write_subreg(lp, SR_XTAL_TRIM, xtal_trim);
1473 rc = at86rf230_read_subreg(lp, SR_DVDD_OK, &dvdd);
1477 dev_err(&lp->spi->dev, "DVDD error\n");
1481 /* Force setting slotted operation bit to 0. Sometimes the atben
1482 * sets this bit and I don't know why. We set this always force
1483 * to zero while probing.
1485 return at86rf230_write_subreg(lp, SR_SLOTTED_OPERATION, 0);
1489 at86rf230_get_pdata(struct spi_device *spi, int *rstn, int *slp_tr,
1492 struct at86rf230_platform_data *pdata = spi->dev.platform_data;
1495 if (!IS_ENABLED(CONFIG_OF) || !spi->dev.of_node) {
1499 *rstn = pdata->rstn;
1500 *slp_tr = pdata->slp_tr;
1501 *xtal_trim = pdata->xtal_trim;
1505 *rstn = of_get_named_gpio(spi->dev.of_node, "reset-gpio", 0);
1506 *slp_tr = of_get_named_gpio(spi->dev.of_node, "sleep-gpio", 0);
1507 ret = of_property_read_u8(spi->dev.of_node, "xtal-trim", xtal_trim);
1508 if (ret < 0 && ret != -EINVAL)
1515 at86rf230_detect_device(struct at86rf230_local *lp)
1517 unsigned int part, version, val;
1522 rc = __at86rf230_read(lp, RG_MAN_ID_0, &val);
1527 rc = __at86rf230_read(lp, RG_MAN_ID_1, &val);
1530 man_id |= (val << 8);
1532 rc = __at86rf230_read(lp, RG_PART_NUM, &part);
1536 rc = __at86rf230_read(lp, RG_VERSION_NUM, &version);
1540 if (man_id != 0x001f) {
1541 dev_err(&lp->spi->dev, "Non-Atmel dev found (MAN_ID %02x %02x)\n",
1542 man_id >> 8, man_id & 0xFF);
1546 lp->hw->flags = IEEE802154_HW_TX_OMIT_CKSUM |
1547 IEEE802154_HW_CSMA_PARAMS |
1548 IEEE802154_HW_FRAME_RETRIES | IEEE802154_HW_AFILT |
1549 IEEE802154_HW_PROMISCUOUS;
1551 lp->hw->phy->flags = WPAN_PHY_FLAG_TXPOWER |
1552 WPAN_PHY_FLAG_CCA_ED_LEVEL |
1553 WPAN_PHY_FLAG_CCA_MODE;
1555 lp->hw->phy->supported.cca_modes = BIT(NL802154_CCA_ENERGY) |
1556 BIT(NL802154_CCA_CARRIER) | BIT(NL802154_CCA_ENERGY_CARRIER);
1557 lp->hw->phy->supported.cca_opts = BIT(NL802154_CCA_OPT_ENERGY_CARRIER_AND) |
1558 BIT(NL802154_CCA_OPT_ENERGY_CARRIER_OR);
1560 lp->hw->phy->cca.mode = NL802154_CCA_ENERGY;
1569 lp->data = &at86rf231_data;
1570 lp->hw->phy->supported.channels[0] = 0x7FFF800;
1571 lp->hw->phy->current_channel = 11;
1572 lp->hw->phy->symbol_duration = 16;
1573 lp->hw->phy->supported.tx_powers = at86rf231_powers;
1574 lp->hw->phy->supported.tx_powers_size = ARRAY_SIZE(at86rf231_powers);
1575 lp->hw->phy->supported.cca_ed_levels = at86rf231_ed_levels;
1576 lp->hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(at86rf231_ed_levels);
1580 lp->data = &at86rf212_data;
1581 lp->hw->flags |= IEEE802154_HW_LBT;
1582 lp->hw->phy->supported.channels[0] = 0x00007FF;
1583 lp->hw->phy->supported.channels[2] = 0x00007FF;
1584 lp->hw->phy->current_channel = 5;
1585 lp->hw->phy->symbol_duration = 25;
1586 lp->hw->phy->supported.lbt = NL802154_SUPPORTED_BOOL_BOTH;
1587 lp->hw->phy->supported.tx_powers = at86rf212_powers;
1588 lp->hw->phy->supported.tx_powers_size = ARRAY_SIZE(at86rf212_powers);
1589 lp->hw->phy->supported.cca_ed_levels = at86rf212_ed_levels_100;
1590 lp->hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(at86rf212_ed_levels_100);
1594 lp->data = &at86rf233_data;
1595 lp->hw->phy->supported.channels[0] = 0x7FFF800;
1596 lp->hw->phy->current_channel = 13;
1597 lp->hw->phy->symbol_duration = 16;
1598 lp->hw->phy->supported.tx_powers = at86rf233_powers;
1599 lp->hw->phy->supported.tx_powers_size = ARRAY_SIZE(at86rf233_powers);
1600 lp->hw->phy->supported.cca_ed_levels = at86rf233_ed_levels;
1601 lp->hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(at86rf233_ed_levels);
1609 lp->hw->phy->cca_ed_level = lp->hw->phy->supported.cca_ed_levels[7];
1610 lp->hw->phy->transmit_power = lp->hw->phy->supported.tx_powers[0];
1613 dev_info(&lp->spi->dev, "Detected %s chip version %d\n", chip, version);
1618 #ifdef CONFIG_IEEE802154_AT86RF230_DEBUGFS
1619 static struct dentry *at86rf230_debugfs_root;
1621 static int at86rf230_stats_show(struct seq_file *file, void *offset)
1623 struct at86rf230_local *lp = file->private;
1625 seq_printf(file, "SUCCESS:\t\t%8llu\n", lp->trac.success);
1626 seq_printf(file, "SUCCESS_DATA_PENDING:\t%8llu\n",
1627 lp->trac.success_data_pending);
1628 seq_printf(file, "SUCCESS_WAIT_FOR_ACK:\t%8llu\n",
1629 lp->trac.success_wait_for_ack);
1630 seq_printf(file, "CHANNEL_ACCESS_FAILURE:\t%8llu\n",
1631 lp->trac.channel_access_failure);
1632 seq_printf(file, "NO_ACK:\t\t\t%8llu\n", lp->trac.no_ack);
1633 seq_printf(file, "INVALID:\t\t%8llu\n", lp->trac.invalid);
1636 DEFINE_SHOW_ATTRIBUTE(at86rf230_stats);
1638 static void at86rf230_debugfs_init(struct at86rf230_local *lp)
1640 char debugfs_dir_name[DNAME_INLINE_LEN + 1] = "at86rf230-";
1642 strncat(debugfs_dir_name, dev_name(&lp->spi->dev), DNAME_INLINE_LEN);
1644 at86rf230_debugfs_root = debugfs_create_dir(debugfs_dir_name, NULL);
1646 debugfs_create_file("trac_stats", 0444, at86rf230_debugfs_root, lp,
1647 &at86rf230_stats_fops);
1650 static void at86rf230_debugfs_remove(void)
1652 debugfs_remove_recursive(at86rf230_debugfs_root);
1655 static void at86rf230_debugfs_init(struct at86rf230_local *lp) { }
1656 static void at86rf230_debugfs_remove(void) { }
1659 static int at86rf230_probe(struct spi_device *spi)
1661 struct ieee802154_hw *hw;
1662 struct at86rf230_local *lp;
1663 unsigned int status;
1664 int rc, irq_type, rstn, slp_tr;
1668 dev_err(&spi->dev, "no IRQ specified\n");
1672 rc = at86rf230_get_pdata(spi, &rstn, &slp_tr, &xtal_trim);
1674 dev_err(&spi->dev, "failed to parse platform_data: %d\n", rc);
1678 if (gpio_is_valid(rstn)) {
1679 rc = devm_gpio_request_one(&spi->dev, rstn,
1680 GPIOF_OUT_INIT_HIGH, "rstn");
1685 if (gpio_is_valid(slp_tr)) {
1686 rc = devm_gpio_request_one(&spi->dev, slp_tr,
1687 GPIOF_OUT_INIT_LOW, "slp_tr");
1693 if (gpio_is_valid(rstn)) {
1695 gpio_set_value_cansleep(rstn, 0);
1697 gpio_set_value_cansleep(rstn, 1);
1698 usleep_range(120, 240);
1701 hw = ieee802154_alloc_hw(sizeof(*lp), &at86rf230_ops);
1708 lp->slp_tr = slp_tr;
1709 hw->parent = &spi->dev;
1710 ieee802154_random_extended_addr(&hw->phy->perm_extended_addr);
1712 lp->regmap = devm_regmap_init_spi(spi, &at86rf230_regmap_spi_config);
1713 if (IS_ERR(lp->regmap)) {
1714 rc = PTR_ERR(lp->regmap);
1715 dev_err(&spi->dev, "Failed to allocate register map: %d\n",
1720 at86rf230_setup_spi_messages(lp, &lp->state);
1721 at86rf230_setup_spi_messages(lp, &lp->tx);
1723 rc = at86rf230_detect_device(lp);
1727 init_completion(&lp->state_complete);
1729 spi_set_drvdata(spi, lp);
1731 rc = at86rf230_hw_init(lp, xtal_trim);
1735 /* Read irq status register to reset irq line */
1736 rc = at86rf230_read_subreg(lp, RG_IRQ_STATUS, 0xff, 0, &status);
1740 irq_type = irq_get_trigger_type(spi->irq);
1742 irq_type = IRQF_TRIGGER_HIGH;
1744 rc = devm_request_irq(&spi->dev, spi->irq, at86rf230_isr,
1745 IRQF_SHARED | irq_type, dev_name(&spi->dev), lp);
1749 /* disable_irq by default and wait for starting hardware */
1750 disable_irq(spi->irq);
1752 /* going into sleep by default */
1753 at86rf230_sleep(lp);
1755 at86rf230_debugfs_init(lp);
1757 rc = ieee802154_register_hw(lp->hw);
1764 at86rf230_debugfs_remove();
1766 ieee802154_free_hw(lp->hw);
1771 static void at86rf230_remove(struct spi_device *spi)
1773 struct at86rf230_local *lp = spi_get_drvdata(spi);
1775 /* mask all at86rf230 irq's */
1776 at86rf230_write_subreg(lp, SR_IRQ_MASK, 0);
1777 ieee802154_unregister_hw(lp->hw);
1778 ieee802154_free_hw(lp->hw);
1779 at86rf230_debugfs_remove();
1780 dev_dbg(&spi->dev, "unregistered at86rf230\n");
1783 static const struct of_device_id at86rf230_of_match[] = {
1784 { .compatible = "atmel,at86rf230", },
1785 { .compatible = "atmel,at86rf231", },
1786 { .compatible = "atmel,at86rf233", },
1787 { .compatible = "atmel,at86rf212", },
1790 MODULE_DEVICE_TABLE(of, at86rf230_of_match);
1792 static const struct spi_device_id at86rf230_device_id[] = {
1793 { .name = "at86rf230", },
1794 { .name = "at86rf231", },
1795 { .name = "at86rf233", },
1796 { .name = "at86rf212", },
1799 MODULE_DEVICE_TABLE(spi, at86rf230_device_id);
1801 static struct spi_driver at86rf230_driver = {
1802 .id_table = at86rf230_device_id,
1804 .of_match_table = of_match_ptr(at86rf230_of_match),
1805 .name = "at86rf230",
1807 .probe = at86rf230_probe,
1808 .remove = at86rf230_remove,
1811 module_spi_driver(at86rf230_driver);
1813 MODULE_DESCRIPTION("AT86RF230 Transceiver Driver");
1814 MODULE_LICENSE("GPL v2");