2 * AT86RF230/RF231 driver
4 * Copyright (C) 2009-2012 Siemens AG
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
17 * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
18 * Alexander Aring <aar@pengutronix.de>
20 #include <linux/kernel.h>
21 #include <linux/module.h>
22 #include <linux/hrtimer.h>
23 #include <linux/jiffies.h>
24 #include <linux/interrupt.h>
25 #include <linux/irq.h>
26 #include <linux/gpio.h>
27 #include <linux/delay.h>
28 #include <linux/spi/spi.h>
29 #include <linux/spi/at86rf230.h>
30 #include <linux/regmap.h>
31 #include <linux/skbuff.h>
32 #include <linux/of_gpio.h>
33 #include <linux/ieee802154.h>
34 #include <linux/debugfs.h>
36 #include <net/mac802154.h>
37 #include <net/cfg802154.h>
39 #include "at86rf230.h"
41 struct at86rf230_local;
42 /* at86rf2xx chip depend data.
43 * All timings are in us.
45 struct at86rf2xx_chip_data {
57 int (*set_channel)(struct at86rf230_local *, u8, u8);
58 int (*set_txpower)(struct at86rf230_local *, s32);
61 #define AT86RF2XX_MAX_BUF (127 + 3)
62 /* tx retries to access the TX_ON state
63 * if it's above then force change will be started.
65 * We assume the max_frame_retries (7) value of 802.15.4 here.
67 #define AT86RF2XX_MAX_TX_RETRIES 7
68 /* We use the recommended 5 minutes timeout to recalibrate */
69 #define AT86RF2XX_CAL_LOOP_TIMEOUT (5 * 60 * HZ)
71 struct at86rf230_state_change {
72 struct at86rf230_local *lp;
76 struct spi_message msg;
77 struct spi_transfer trx;
78 u8 buf[AT86RF2XX_MAX_BUF];
80 void (*complete)(void *context);
87 struct at86rf230_trac {
89 u64 success_data_pending;
90 u64 success_wait_for_ack;
91 u64 channel_access_failure;
96 struct at86rf230_local {
97 struct spi_device *spi;
99 struct ieee802154_hw *hw;
100 struct at86rf2xx_chip_data *data;
101 struct regmap *regmap;
105 struct completion state_complete;
106 struct at86rf230_state_change state;
108 unsigned long cal_timeout;
113 struct sk_buff *tx_skb;
114 struct at86rf230_state_change tx;
116 struct at86rf230_trac trac;
119 #define AT86RF2XX_NUMREGS 0x3F
122 at86rf230_async_state_change(struct at86rf230_local *lp,
123 struct at86rf230_state_change *ctx,
124 const u8 state, void (*complete)(void *context));
127 at86rf230_sleep(struct at86rf230_local *lp)
129 if (gpio_is_valid(lp->slp_tr)) {
130 gpio_set_value(lp->slp_tr, 1);
131 usleep_range(lp->data->t_off_to_sleep,
132 lp->data->t_off_to_sleep + 10);
138 at86rf230_awake(struct at86rf230_local *lp)
140 if (gpio_is_valid(lp->slp_tr)) {
141 gpio_set_value(lp->slp_tr, 0);
142 usleep_range(lp->data->t_sleep_to_off,
143 lp->data->t_sleep_to_off + 100);
149 __at86rf230_write(struct at86rf230_local *lp,
150 unsigned int addr, unsigned int data)
152 bool sleep = lp->sleep;
155 /* awake for register setting if sleep */
159 ret = regmap_write(lp->regmap, addr, data);
161 /* sleep again if was sleeping */
169 __at86rf230_read(struct at86rf230_local *lp,
170 unsigned int addr, unsigned int *data)
172 bool sleep = lp->sleep;
175 /* awake for register setting if sleep */
179 ret = regmap_read(lp->regmap, addr, data);
181 /* sleep again if was sleeping */
189 at86rf230_read_subreg(struct at86rf230_local *lp,
190 unsigned int addr, unsigned int mask,
191 unsigned int shift, unsigned int *data)
195 rc = __at86rf230_read(lp, addr, data);
197 *data = (*data & mask) >> shift;
203 at86rf230_write_subreg(struct at86rf230_local *lp,
204 unsigned int addr, unsigned int mask,
205 unsigned int shift, unsigned int data)
207 bool sleep = lp->sleep;
210 /* awake for register setting if sleep */
214 ret = regmap_update_bits(lp->regmap, addr, mask, data << shift);
216 /* sleep again if was sleeping */
224 at86rf230_slp_tr_rising_edge(struct at86rf230_local *lp)
226 gpio_set_value(lp->slp_tr, 1);
228 gpio_set_value(lp->slp_tr, 0);
232 at86rf230_reg_writeable(struct device *dev, unsigned int reg)
239 case RG_PHY_ED_LEVEL:
255 case RG_SHORT_ADDR_0:
256 case RG_SHORT_ADDR_1:
278 at86rf230_reg_readable(struct device *dev, unsigned int reg)
282 /* all writeable are also readable */
283 rc = at86rf230_reg_writeable(dev, reg);
303 at86rf230_reg_volatile(struct device *dev, unsigned int reg)
305 /* can be changed during runtime */
310 case RG_PHY_ED_LEVEL:
322 at86rf230_reg_precious(struct device *dev, unsigned int reg)
324 /* don't clear irq line on read */
333 static const struct regmap_config at86rf230_regmap_spi_config = {
336 .write_flag_mask = CMD_REG | CMD_WRITE,
337 .read_flag_mask = CMD_REG,
338 .cache_type = REGCACHE_RBTREE,
339 .max_register = AT86RF2XX_NUMREGS,
340 .writeable_reg = at86rf230_reg_writeable,
341 .readable_reg = at86rf230_reg_readable,
342 .volatile_reg = at86rf230_reg_volatile,
343 .precious_reg = at86rf230_reg_precious,
347 at86rf230_async_error_recover_complete(void *context)
349 struct at86rf230_state_change *ctx = context;
350 struct at86rf230_local *lp = ctx->lp;
357 dev_kfree_skb_any(lp->tx_skb);
358 ieee802154_wake_queue(lp->hw);
363 at86rf230_async_error_recover(void *context)
365 struct at86rf230_state_change *ctx = context;
366 struct at86rf230_local *lp = ctx->lp;
373 at86rf230_async_state_change(lp, ctx, STATE_RX_AACK_ON,
374 at86rf230_async_error_recover_complete);
378 at86rf230_async_error(struct at86rf230_local *lp,
379 struct at86rf230_state_change *ctx, int rc)
381 dev_err(&lp->spi->dev, "spi_async error %d\n", rc);
383 at86rf230_async_state_change(lp, ctx, STATE_FORCE_TRX_OFF,
384 at86rf230_async_error_recover);
387 /* Generic function to get some register value in async mode */
389 at86rf230_async_read_reg(struct at86rf230_local *lp, u8 reg,
390 struct at86rf230_state_change *ctx,
391 void (*complete)(void *context))
395 u8 *tx_buf = ctx->buf;
397 tx_buf[0] = (reg & CMD_REG_MASK) | CMD_REG;
398 ctx->msg.complete = complete;
399 rc = spi_async(lp->spi, &ctx->msg);
401 at86rf230_async_error(lp, ctx, rc);
405 at86rf230_async_write_reg(struct at86rf230_local *lp, u8 reg, u8 val,
406 struct at86rf230_state_change *ctx,
407 void (*complete)(void *context))
411 ctx->buf[0] = (reg & CMD_REG_MASK) | CMD_REG | CMD_WRITE;
413 ctx->msg.complete = complete;
414 rc = spi_async(lp->spi, &ctx->msg);
416 at86rf230_async_error(lp, ctx, rc);
420 at86rf230_async_state_assert(void *context)
422 struct at86rf230_state_change *ctx = context;
423 struct at86rf230_local *lp = ctx->lp;
424 const u8 *buf = ctx->buf;
425 const u8 trx_state = buf[1] & TRX_STATE_MASK;
427 /* Assert state change */
428 if (trx_state != ctx->to_state) {
429 /* Special handling if transceiver state is in
430 * STATE_BUSY_RX_AACK and a SHR was detected.
432 if (trx_state == STATE_BUSY_RX_AACK) {
433 /* Undocumented race condition. If we send a state
434 * change to STATE_RX_AACK_ON the transceiver could
435 * change his state automatically to STATE_BUSY_RX_AACK
436 * if a SHR was detected. This is not an error, but we
439 if (ctx->to_state == STATE_RX_AACK_ON)
442 /* If we change to STATE_TX_ON without forcing and
443 * transceiver state is STATE_BUSY_RX_AACK, we wait
444 * 'tFrame + tPAck' receiving time. In this time the
445 * PDU should be received. If the transceiver is still
446 * in STATE_BUSY_RX_AACK, we run a force state change
447 * to STATE_TX_ON. This is a timeout handling, if the
448 * transceiver stucks in STATE_BUSY_RX_AACK.
450 * Additional we do several retries to try to get into
451 * TX_ON state without forcing. If the retries are
452 * higher or equal than AT86RF2XX_MAX_TX_RETRIES we
453 * will do a force change.
455 if (ctx->to_state == STATE_TX_ON ||
456 ctx->to_state == STATE_TRX_OFF) {
457 u8 state = ctx->to_state;
459 if (lp->tx_retry >= AT86RF2XX_MAX_TX_RETRIES)
460 state = STATE_FORCE_TRX_OFF;
463 at86rf230_async_state_change(lp, ctx, state,
469 dev_warn(&lp->spi->dev, "unexcept state change from 0x%02x to 0x%02x. Actual state: 0x%02x\n",
470 ctx->from_state, ctx->to_state, trx_state);
475 ctx->complete(context);
478 static enum hrtimer_restart at86rf230_async_state_timer(struct hrtimer *timer)
480 struct at86rf230_state_change *ctx =
481 container_of(timer, struct at86rf230_state_change, timer);
482 struct at86rf230_local *lp = ctx->lp;
484 at86rf230_async_read_reg(lp, RG_TRX_STATUS, ctx,
485 at86rf230_async_state_assert);
487 return HRTIMER_NORESTART;
490 /* Do state change timing delay. */
492 at86rf230_async_state_delay(void *context)
494 struct at86rf230_state_change *ctx = context;
495 struct at86rf230_local *lp = ctx->lp;
496 struct at86rf2xx_chip_data *c = lp->data;
500 /* The force state changes are will show as normal states in the
501 * state status subregister. We change the to_state to the
502 * corresponding one and remember if it was a force change, this
503 * differs if we do a state change from STATE_BUSY_RX_AACK.
505 switch (ctx->to_state) {
506 case STATE_FORCE_TX_ON:
507 ctx->to_state = STATE_TX_ON;
510 case STATE_FORCE_TRX_OFF:
511 ctx->to_state = STATE_TRX_OFF;
518 switch (ctx->from_state) {
520 switch (ctx->to_state) {
521 case STATE_RX_AACK_ON:
522 tim = ktime_set(0, c->t_off_to_aack * NSEC_PER_USEC);
523 /* state change from TRX_OFF to RX_AACK_ON to do a
524 * calibration, we need to reset the timeout for the
527 lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT;
529 case STATE_TX_ARET_ON:
531 tim = ktime_set(0, c->t_off_to_tx_on * NSEC_PER_USEC);
532 /* state change from TRX_OFF to TX_ON or ARET_ON to do
533 * a calibration, we need to reset the timeout for the
536 lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT;
542 case STATE_BUSY_RX_AACK:
543 switch (ctx->to_state) {
546 /* Wait for worst case receiving time if we
547 * didn't make a force change from BUSY_RX_AACK
548 * to TX_ON or TRX_OFF.
551 tim = ktime_set(0, (c->t_frame + c->t_p_ack) *
560 /* Default value, means RESET state */
562 switch (ctx->to_state) {
564 tim = ktime_set(0, c->t_reset_to_off * NSEC_PER_USEC);
574 /* Default delay is 1us in the most cases */
576 at86rf230_async_state_timer(&ctx->timer);
580 hrtimer_start(&ctx->timer, tim, HRTIMER_MODE_REL);
584 at86rf230_async_state_change_start(void *context)
586 struct at86rf230_state_change *ctx = context;
587 struct at86rf230_local *lp = ctx->lp;
589 const u8 trx_state = buf[1] & TRX_STATE_MASK;
591 /* Check for "possible" STATE_TRANSITION_IN_PROGRESS */
592 if (trx_state == STATE_TRANSITION_IN_PROGRESS) {
594 at86rf230_async_read_reg(lp, RG_TRX_STATUS, ctx,
595 at86rf230_async_state_change_start);
599 /* Check if we already are in the state which we change in */
600 if (trx_state == ctx->to_state) {
602 ctx->complete(context);
606 /* Set current state to the context of state change */
607 ctx->from_state = trx_state;
609 /* Going into the next step for a state change which do a timing
612 at86rf230_async_write_reg(lp, RG_TRX_STATE, ctx->to_state, ctx,
613 at86rf230_async_state_delay);
617 at86rf230_async_state_change(struct at86rf230_local *lp,
618 struct at86rf230_state_change *ctx,
619 const u8 state, void (*complete)(void *context))
621 /* Initialization for the state change context */
622 ctx->to_state = state;
623 ctx->complete = complete;
624 at86rf230_async_read_reg(lp, RG_TRX_STATUS, ctx,
625 at86rf230_async_state_change_start);
629 at86rf230_sync_state_change_complete(void *context)
631 struct at86rf230_state_change *ctx = context;
632 struct at86rf230_local *lp = ctx->lp;
634 complete(&lp->state_complete);
637 /* This function do a sync framework above the async state change.
638 * Some callbacks of the IEEE 802.15.4 driver interface need to be
639 * handled synchronously.
642 at86rf230_sync_state_change(struct at86rf230_local *lp, unsigned int state)
646 at86rf230_async_state_change(lp, &lp->state, state,
647 at86rf230_sync_state_change_complete);
649 rc = wait_for_completion_timeout(&lp->state_complete,
650 msecs_to_jiffies(100));
652 at86rf230_async_error(lp, &lp->state, -ETIMEDOUT);
660 at86rf230_tx_complete(void *context)
662 struct at86rf230_state_change *ctx = context;
663 struct at86rf230_local *lp = ctx->lp;
665 ieee802154_xmit_complete(lp->hw, lp->tx_skb, false);
670 at86rf230_tx_on(void *context)
672 struct at86rf230_state_change *ctx = context;
673 struct at86rf230_local *lp = ctx->lp;
675 at86rf230_async_state_change(lp, ctx, STATE_RX_AACK_ON,
676 at86rf230_tx_complete);
680 at86rf230_tx_trac_check(void *context)
682 struct at86rf230_state_change *ctx = context;
683 struct at86rf230_local *lp = ctx->lp;
685 if (IS_ENABLED(CONFIG_IEEE802154_AT86RF230_DEBUGFS)) {
686 u8 trac = TRAC_MASK(ctx->buf[1]);
692 case TRAC_SUCCESS_DATA_PENDING:
693 lp->trac.success_data_pending++;
695 case TRAC_CHANNEL_ACCESS_FAILURE:
696 lp->trac.channel_access_failure++;
705 WARN_ONCE(1, "received tx trac status %d\n", trac);
710 at86rf230_async_state_change(lp, ctx, STATE_TX_ON, at86rf230_tx_on);
714 at86rf230_rx_read_frame_complete(void *context)
716 struct at86rf230_state_change *ctx = context;
717 struct at86rf230_local *lp = ctx->lp;
718 const u8 *buf = ctx->buf;
723 if (!ieee802154_is_valid_psdu_len(len)) {
724 dev_vdbg(&lp->spi->dev, "corrupted frame received\n");
725 len = IEEE802154_MTU;
729 skb = dev_alloc_skb(IEEE802154_MTU);
731 dev_vdbg(&lp->spi->dev, "failed to allocate sk_buff\n");
736 memcpy(skb_put(skb, len), buf + 2, len);
737 ieee802154_rx_irqsafe(lp->hw, skb, lqi);
742 at86rf230_rx_trac_check(void *context)
744 struct at86rf230_state_change *ctx = context;
745 struct at86rf230_local *lp = ctx->lp;
749 if (IS_ENABLED(CONFIG_IEEE802154_AT86RF230_DEBUGFS)) {
750 u8 trac = TRAC_MASK(buf[1]);
756 case TRAC_SUCCESS_WAIT_FOR_ACK:
757 lp->trac.success_wait_for_ack++;
763 WARN_ONCE(1, "received rx trac status %d\n", trac);
769 ctx->trx.len = AT86RF2XX_MAX_BUF;
770 ctx->msg.complete = at86rf230_rx_read_frame_complete;
771 rc = spi_async(lp->spi, &ctx->msg);
774 at86rf230_async_error(lp, ctx, rc);
779 at86rf230_irq_trx_end(void *context)
781 struct at86rf230_state_change *ctx = context;
782 struct at86rf230_local *lp = ctx->lp;
786 at86rf230_async_read_reg(lp, RG_TRX_STATE, ctx,
787 at86rf230_tx_trac_check);
789 at86rf230_async_read_reg(lp, RG_TRX_STATE, ctx,
790 at86rf230_rx_trac_check);
795 at86rf230_irq_status(void *context)
797 struct at86rf230_state_change *ctx = context;
798 struct at86rf230_local *lp = ctx->lp;
799 const u8 *buf = ctx->buf;
802 enable_irq(lp->spi->irq);
804 if (irq & IRQ_TRX_END) {
805 at86rf230_irq_trx_end(ctx);
807 dev_err(&lp->spi->dev, "not supported irq %02x received\n",
814 at86rf230_setup_spi_messages(struct at86rf230_local *lp,
815 struct at86rf230_state_change *state)
818 state->irq = lp->spi->irq;
819 spi_message_init(&state->msg);
820 state->msg.context = state;
822 state->trx.tx_buf = state->buf;
823 state->trx.rx_buf = state->buf;
824 spi_message_add_tail(&state->trx, &state->msg);
825 hrtimer_init(&state->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
826 state->timer.function = at86rf230_async_state_timer;
829 static irqreturn_t at86rf230_isr(int irq, void *data)
831 struct at86rf230_local *lp = data;
832 struct at86rf230_state_change *ctx;
835 disable_irq_nosync(irq);
837 ctx = kzalloc(sizeof(*ctx), GFP_ATOMIC);
843 at86rf230_setup_spi_messages(lp, ctx);
844 /* tell on error handling to free ctx */
847 ctx->buf[0] = (RG_IRQ_STATUS & CMD_REG_MASK) | CMD_REG;
848 ctx->msg.complete = at86rf230_irq_status;
849 rc = spi_async(lp->spi, &ctx->msg);
851 at86rf230_async_error(lp, ctx, rc);
860 at86rf230_write_frame_complete(void *context)
862 struct at86rf230_state_change *ctx = context;
863 struct at86rf230_local *lp = ctx->lp;
867 if (gpio_is_valid(lp->slp_tr))
868 at86rf230_slp_tr_rising_edge(lp);
870 at86rf230_async_write_reg(lp, RG_TRX_STATE, STATE_BUSY_TX, ctx,
875 at86rf230_write_frame(void *context)
877 struct at86rf230_state_change *ctx = context;
878 struct at86rf230_local *lp = ctx->lp;
879 struct sk_buff *skb = lp->tx_skb;
885 buf[0] = CMD_FB | CMD_WRITE;
886 buf[1] = skb->len + 2;
887 memcpy(buf + 2, skb->data, skb->len);
888 ctx->trx.len = skb->len + 2;
889 ctx->msg.complete = at86rf230_write_frame_complete;
890 rc = spi_async(lp->spi, &ctx->msg);
893 at86rf230_async_error(lp, ctx, rc);
898 at86rf230_xmit_tx_on(void *context)
900 struct at86rf230_state_change *ctx = context;
901 struct at86rf230_local *lp = ctx->lp;
903 at86rf230_async_state_change(lp, ctx, STATE_TX_ARET_ON,
904 at86rf230_write_frame);
908 at86rf230_xmit_start(void *context)
910 struct at86rf230_state_change *ctx = context;
911 struct at86rf230_local *lp = ctx->lp;
913 /* check if we change from off state */
914 if (lp->is_tx_from_off)
915 at86rf230_async_state_change(lp, ctx, STATE_TX_ARET_ON,
916 at86rf230_write_frame);
918 at86rf230_async_state_change(lp, ctx, STATE_TX_ON,
919 at86rf230_xmit_tx_on);
923 at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
925 struct at86rf230_local *lp = hw->priv;
926 struct at86rf230_state_change *ctx = &lp->tx;
931 /* After 5 minutes in PLL and the same frequency we run again the
932 * calibration loops which is recommended by at86rf2xx datasheets.
934 * The calibration is initiate by a state change from TRX_OFF
935 * to TX_ON, the lp->cal_timeout should be reinit by state_delay
936 * function then to start in the next 5 minutes.
938 if (time_is_before_jiffies(lp->cal_timeout)) {
939 lp->is_tx_from_off = true;
940 at86rf230_async_state_change(lp, ctx, STATE_TRX_OFF,
941 at86rf230_xmit_start);
943 lp->is_tx_from_off = false;
944 at86rf230_xmit_start(ctx);
951 at86rf230_ed(struct ieee802154_hw *hw, u8 *level)
959 at86rf230_start(struct ieee802154_hw *hw)
961 struct at86rf230_local *lp = hw->priv;
963 /* reset trac stats on start */
964 if (IS_ENABLED(CONFIG_IEEE802154_AT86RF230_DEBUGFS))
965 memset(&lp->trac, 0, sizeof(struct at86rf230_trac));
968 enable_irq(lp->spi->irq);
970 return at86rf230_sync_state_change(lp, STATE_RX_AACK_ON);
974 at86rf230_stop(struct ieee802154_hw *hw)
976 struct at86rf230_local *lp = hw->priv;
979 at86rf230_sync_state_change(lp, STATE_FORCE_TRX_OFF);
981 disable_irq(lp->spi->irq);
983 /* It's recommended to set random new csma_seeds before sleep state.
984 * Makes only sense in the stop callback, not doing this inside of
985 * at86rf230_sleep, this is also used when we don't transmit afterwards
986 * when calling start callback again.
988 get_random_bytes(csma_seed, ARRAY_SIZE(csma_seed));
989 at86rf230_write_subreg(lp, SR_CSMA_SEED_0, csma_seed[0]);
990 at86rf230_write_subreg(lp, SR_CSMA_SEED_1, csma_seed[1]);
996 at86rf23x_set_channel(struct at86rf230_local *lp, u8 page, u8 channel)
998 return at86rf230_write_subreg(lp, SR_CHANNEL, channel);
1001 #define AT86RF2XX_MAX_ED_LEVELS 0xF
1002 static const s32 at86rf23x_ed_levels[AT86RF2XX_MAX_ED_LEVELS + 1] = {
1003 -9100, -8900, -8700, -8500, -8300, -8100, -7900, -7700, -7500, -7300,
1004 -7100, -6900, -6700, -6500, -6300, -6100,
1007 static const s32 at86rf212_ed_levels_100[AT86RF2XX_MAX_ED_LEVELS + 1] = {
1008 -10000, -9800, -9600, -9400, -9200, -9000, -8800, -8600, -8400, -8200,
1009 -8000, -7800, -7600, -7400, -7200, -7000,
1012 static const s32 at86rf212_ed_levels_98[AT86RF2XX_MAX_ED_LEVELS + 1] = {
1013 -9800, -9600, -9400, -9200, -9000, -8800, -8600, -8400, -8200, -8000,
1014 -7800, -7600, -7400, -7200, -7000, -6800,
1018 at86rf212_update_cca_ed_level(struct at86rf230_local *lp, int rssi_base_val)
1020 unsigned int cca_ed_thres;
1023 rc = at86rf230_read_subreg(lp, SR_CCA_ED_THRES, &cca_ed_thres);
1027 switch (rssi_base_val) {
1029 lp->hw->phy->supported.cca_ed_levels = at86rf212_ed_levels_98;
1030 lp->hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(at86rf212_ed_levels_98);
1031 lp->hw->phy->cca_ed_level = at86rf212_ed_levels_98[cca_ed_thres];
1034 lp->hw->phy->supported.cca_ed_levels = at86rf212_ed_levels_100;
1035 lp->hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(at86rf212_ed_levels_100);
1036 lp->hw->phy->cca_ed_level = at86rf212_ed_levels_100[cca_ed_thres];
1046 at86rf212_set_channel(struct at86rf230_local *lp, u8 page, u8 channel)
1051 rc = at86rf230_write_subreg(lp, SR_SUB_MODE, 0);
1053 rc = at86rf230_write_subreg(lp, SR_SUB_MODE, 1);
1058 rc = at86rf230_write_subreg(lp, SR_BPSK_QPSK, 0);
1059 lp->data->rssi_base_val = -100;
1061 rc = at86rf230_write_subreg(lp, SR_BPSK_QPSK, 1);
1062 lp->data->rssi_base_val = -98;
1067 rc = at86rf212_update_cca_ed_level(lp, lp->data->rssi_base_val);
1071 /* This sets the symbol_duration according frequency on the 212.
1072 * TODO move this handling while set channel and page in cfg802154.
1073 * We can do that, this timings are according 802.15.4 standard.
1074 * If we do that in cfg802154, this is a more generic calculation.
1076 * This should also protected from ifs_timer. Means cancel timer and
1077 * init with a new value. For now, this is okay.
1081 /* SUB:0 and BPSK:0 -> BPSK-20 */
1082 lp->hw->phy->symbol_duration = 50;
1084 /* SUB:1 and BPSK:0 -> BPSK-40 */
1085 lp->hw->phy->symbol_duration = 25;
1089 /* SUB:0 and BPSK:1 -> OQPSK-100/200/400 */
1090 lp->hw->phy->symbol_duration = 40;
1092 /* SUB:1 and BPSK:1 -> OQPSK-250/500/1000 */
1093 lp->hw->phy->symbol_duration = 16;
1096 lp->hw->phy->lifs_period = IEEE802154_LIFS_PERIOD *
1097 lp->hw->phy->symbol_duration;
1098 lp->hw->phy->sifs_period = IEEE802154_SIFS_PERIOD *
1099 lp->hw->phy->symbol_duration;
1101 return at86rf230_write_subreg(lp, SR_CHANNEL, channel);
1105 at86rf230_channel(struct ieee802154_hw *hw, u8 page, u8 channel)
1107 struct at86rf230_local *lp = hw->priv;
1110 rc = lp->data->set_channel(lp, page, channel);
1112 usleep_range(lp->data->t_channel_switch,
1113 lp->data->t_channel_switch + 10);
1115 lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT;
1120 at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
1121 struct ieee802154_hw_addr_filt *filt,
1122 unsigned long changed)
1124 struct at86rf230_local *lp = hw->priv;
1126 if (changed & IEEE802154_AFILT_SADDR_CHANGED) {
1127 u16 addr = le16_to_cpu(filt->short_addr);
1129 dev_vdbg(&lp->spi->dev, "%s called for saddr\n", __func__);
1130 __at86rf230_write(lp, RG_SHORT_ADDR_0, addr);
1131 __at86rf230_write(lp, RG_SHORT_ADDR_1, addr >> 8);
1134 if (changed & IEEE802154_AFILT_PANID_CHANGED) {
1135 u16 pan = le16_to_cpu(filt->pan_id);
1137 dev_vdbg(&lp->spi->dev, "%s called for pan id\n", __func__);
1138 __at86rf230_write(lp, RG_PAN_ID_0, pan);
1139 __at86rf230_write(lp, RG_PAN_ID_1, pan >> 8);
1142 if (changed & IEEE802154_AFILT_IEEEADDR_CHANGED) {
1145 memcpy(addr, &filt->ieee_addr, 8);
1146 dev_vdbg(&lp->spi->dev, "%s called for IEEE addr\n", __func__);
1147 for (i = 0; i < 8; i++)
1148 __at86rf230_write(lp, RG_IEEE_ADDR_0 + i, addr[i]);
1151 if (changed & IEEE802154_AFILT_PANC_CHANGED) {
1152 dev_vdbg(&lp->spi->dev, "%s called for panc change\n", __func__);
1153 if (filt->pan_coord)
1154 at86rf230_write_subreg(lp, SR_AACK_I_AM_COORD, 1);
1156 at86rf230_write_subreg(lp, SR_AACK_I_AM_COORD, 0);
1162 #define AT86RF23X_MAX_TX_POWERS 0xF
1163 static const s32 at86rf233_powers[AT86RF23X_MAX_TX_POWERS + 1] = {
1164 400, 370, 340, 300, 250, 200, 100, 0, -100, -200, -300, -400, -600,
1168 static const s32 at86rf231_powers[AT86RF23X_MAX_TX_POWERS + 1] = {
1169 300, 280, 230, 180, 130, 70, 0, -100, -200, -300, -400, -500, -700,
1173 #define AT86RF212_MAX_TX_POWERS 0x1F
1174 static const s32 at86rf212_powers[AT86RF212_MAX_TX_POWERS + 1] = {
1175 500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500, -600, -700,
1176 -800, -900, -1000, -1100, -1200, -1300, -1400, -1500, -1600, -1700,
1177 -1800, -1900, -2000, -2100, -2200, -2300, -2400, -2500, -2600,
1181 at86rf23x_set_txpower(struct at86rf230_local *lp, s32 mbm)
1185 for (i = 0; i < lp->hw->phy->supported.tx_powers_size; i++) {
1186 if (lp->hw->phy->supported.tx_powers[i] == mbm)
1187 return at86rf230_write_subreg(lp, SR_TX_PWR_23X, i);
1194 at86rf212_set_txpower(struct at86rf230_local *lp, s32 mbm)
1198 for (i = 0; i < lp->hw->phy->supported.tx_powers_size; i++) {
1199 if (lp->hw->phy->supported.tx_powers[i] == mbm)
1200 return at86rf230_write_subreg(lp, SR_TX_PWR_212, i);
1207 at86rf230_set_txpower(struct ieee802154_hw *hw, s32 mbm)
1209 struct at86rf230_local *lp = hw->priv;
1211 return lp->data->set_txpower(lp, mbm);
1215 at86rf230_set_lbt(struct ieee802154_hw *hw, bool on)
1217 struct at86rf230_local *lp = hw->priv;
1219 return at86rf230_write_subreg(lp, SR_CSMA_LBT_MODE, on);
1223 at86rf230_set_cca_mode(struct ieee802154_hw *hw,
1224 const struct wpan_phy_cca *cca)
1226 struct at86rf230_local *lp = hw->priv;
1229 /* mapping 802.15.4 to driver spec */
1230 switch (cca->mode) {
1231 case NL802154_CCA_ENERGY:
1234 case NL802154_CCA_CARRIER:
1237 case NL802154_CCA_ENERGY_CARRIER:
1239 case NL802154_CCA_OPT_ENERGY_CARRIER_AND:
1242 case NL802154_CCA_OPT_ENERGY_CARRIER_OR:
1253 return at86rf230_write_subreg(lp, SR_CCA_MODE, val);
1257 at86rf230_set_cca_ed_level(struct ieee802154_hw *hw, s32 mbm)
1259 struct at86rf230_local *lp = hw->priv;
1262 for (i = 0; i < hw->phy->supported.cca_ed_levels_size; i++) {
1263 if (hw->phy->supported.cca_ed_levels[i] == mbm)
1264 return at86rf230_write_subreg(lp, SR_CCA_ED_THRES, i);
1271 at86rf230_set_csma_params(struct ieee802154_hw *hw, u8 min_be, u8 max_be,
1274 struct at86rf230_local *lp = hw->priv;
1277 rc = at86rf230_write_subreg(lp, SR_MIN_BE, min_be);
1281 rc = at86rf230_write_subreg(lp, SR_MAX_BE, max_be);
1285 return at86rf230_write_subreg(lp, SR_MAX_CSMA_RETRIES, retries);
1289 at86rf230_set_frame_retries(struct ieee802154_hw *hw, s8 retries)
1291 struct at86rf230_local *lp = hw->priv;
1293 return at86rf230_write_subreg(lp, SR_MAX_FRAME_RETRIES, retries);
1297 at86rf230_set_promiscuous_mode(struct ieee802154_hw *hw, const bool on)
1299 struct at86rf230_local *lp = hw->priv;
1303 rc = at86rf230_write_subreg(lp, SR_AACK_DIS_ACK, 1);
1307 rc = at86rf230_write_subreg(lp, SR_AACK_PROM_MODE, 1);
1311 rc = at86rf230_write_subreg(lp, SR_AACK_PROM_MODE, 0);
1315 rc = at86rf230_write_subreg(lp, SR_AACK_DIS_ACK, 0);
1323 static const struct ieee802154_ops at86rf230_ops = {
1324 .owner = THIS_MODULE,
1325 .xmit_async = at86rf230_xmit,
1327 .set_channel = at86rf230_channel,
1328 .start = at86rf230_start,
1329 .stop = at86rf230_stop,
1330 .set_hw_addr_filt = at86rf230_set_hw_addr_filt,
1331 .set_txpower = at86rf230_set_txpower,
1332 .set_lbt = at86rf230_set_lbt,
1333 .set_cca_mode = at86rf230_set_cca_mode,
1334 .set_cca_ed_level = at86rf230_set_cca_ed_level,
1335 .set_csma_params = at86rf230_set_csma_params,
1336 .set_frame_retries = at86rf230_set_frame_retries,
1337 .set_promiscuous_mode = at86rf230_set_promiscuous_mode,
1340 static struct at86rf2xx_chip_data at86rf233_data = {
1341 .t_sleep_cycle = 330,
1342 .t_channel_switch = 11,
1343 .t_reset_to_off = 26,
1344 .t_off_to_aack = 80,
1345 .t_off_to_tx_on = 80,
1346 .t_off_to_sleep = 35,
1347 .t_sleep_to_off = 1000,
1350 .rssi_base_val = -91,
1351 .set_channel = at86rf23x_set_channel,
1352 .set_txpower = at86rf23x_set_txpower,
1355 static struct at86rf2xx_chip_data at86rf231_data = {
1356 .t_sleep_cycle = 330,
1357 .t_channel_switch = 24,
1358 .t_reset_to_off = 37,
1359 .t_off_to_aack = 110,
1360 .t_off_to_tx_on = 110,
1361 .t_off_to_sleep = 35,
1362 .t_sleep_to_off = 1000,
1365 .rssi_base_val = -91,
1366 .set_channel = at86rf23x_set_channel,
1367 .set_txpower = at86rf23x_set_txpower,
1370 static struct at86rf2xx_chip_data at86rf212_data = {
1371 .t_sleep_cycle = 330,
1372 .t_channel_switch = 11,
1373 .t_reset_to_off = 26,
1374 .t_off_to_aack = 200,
1375 .t_off_to_tx_on = 200,
1376 .t_off_to_sleep = 35,
1377 .t_sleep_to_off = 1000,
1380 .rssi_base_val = -100,
1381 .set_channel = at86rf212_set_channel,
1382 .set_txpower = at86rf212_set_txpower,
1385 static int at86rf230_hw_init(struct at86rf230_local *lp, u8 xtal_trim)
1387 int rc, irq_type, irq_pol = IRQ_ACTIVE_HIGH;
1391 rc = at86rf230_sync_state_change(lp, STATE_FORCE_TRX_OFF);
1395 irq_type = irq_get_trigger_type(lp->spi->irq);
1396 if (irq_type == IRQ_TYPE_EDGE_FALLING ||
1397 irq_type == IRQ_TYPE_LEVEL_LOW)
1398 irq_pol = IRQ_ACTIVE_LOW;
1400 rc = at86rf230_write_subreg(lp, SR_IRQ_POLARITY, irq_pol);
1404 rc = at86rf230_write_subreg(lp, SR_RX_SAFE_MODE, 1);
1408 rc = at86rf230_write_subreg(lp, SR_IRQ_MASK, IRQ_TRX_END);
1412 /* reset values differs in at86rf231 and at86rf233 */
1413 rc = at86rf230_write_subreg(lp, SR_IRQ_MASK_MODE, 0);
1417 get_random_bytes(csma_seed, ARRAY_SIZE(csma_seed));
1418 rc = at86rf230_write_subreg(lp, SR_CSMA_SEED_0, csma_seed[0]);
1421 rc = at86rf230_write_subreg(lp, SR_CSMA_SEED_1, csma_seed[1]);
1425 /* CLKM changes are applied immediately */
1426 rc = at86rf230_write_subreg(lp, SR_CLKM_SHA_SEL, 0x00);
1431 rc = at86rf230_write_subreg(lp, SR_CLKM_CTRL, 0x00);
1434 /* Wait the next SLEEP cycle */
1435 usleep_range(lp->data->t_sleep_cycle,
1436 lp->data->t_sleep_cycle + 100);
1438 /* xtal_trim value is calculated by:
1439 * CL = 0.5 * (CX + CTRIM + CPAR)
1442 * CL = capacitor of used crystal
1443 * CX = connected capacitors at xtal pins
1444 * CPAR = in all at86rf2xx datasheets this is a constant value 3 pF,
1445 * but this is different on each board setup. You need to fine
1446 * tuning this value via CTRIM.
1447 * CTRIM = variable capacitor setting. Resolution is 0.3 pF range is
1451 * atben transceiver:
1455 * CPAR = 3 pF (We assume the magic constant from datasheet)
1458 * (12+0.9+3)/2 = 7.95 which is nearly at 8 pF
1462 * openlabs transceiver:
1466 * CPAR = 3 pF (We assume the magic constant from datasheet)
1469 * (22+4.5+3)/2 = 14.75 which is the nearest value to 16 pF
1473 rc = at86rf230_write_subreg(lp, SR_XTAL_TRIM, xtal_trim);
1477 rc = at86rf230_read_subreg(lp, SR_DVDD_OK, &dvdd);
1481 dev_err(&lp->spi->dev, "DVDD error\n");
1485 /* Force setting slotted operation bit to 0. Sometimes the atben
1486 * sets this bit and I don't know why. We set this always force
1487 * to zero while probing.
1489 return at86rf230_write_subreg(lp, SR_SLOTTED_OPERATION, 0);
1493 at86rf230_get_pdata(struct spi_device *spi, int *rstn, int *slp_tr,
1496 struct at86rf230_platform_data *pdata = spi->dev.platform_data;
1499 if (!IS_ENABLED(CONFIG_OF) || !spi->dev.of_node) {
1503 *rstn = pdata->rstn;
1504 *slp_tr = pdata->slp_tr;
1505 *xtal_trim = pdata->xtal_trim;
1509 *rstn = of_get_named_gpio(spi->dev.of_node, "reset-gpio", 0);
1510 *slp_tr = of_get_named_gpio(spi->dev.of_node, "sleep-gpio", 0);
1511 ret = of_property_read_u8(spi->dev.of_node, "xtal-trim", xtal_trim);
1512 if (ret < 0 && ret != -EINVAL)
1519 at86rf230_detect_device(struct at86rf230_local *lp)
1521 unsigned int part, version, val;
1526 rc = __at86rf230_read(lp, RG_MAN_ID_0, &val);
1531 rc = __at86rf230_read(lp, RG_MAN_ID_1, &val);
1534 man_id |= (val << 8);
1536 rc = __at86rf230_read(lp, RG_PART_NUM, &part);
1540 rc = __at86rf230_read(lp, RG_VERSION_NUM, &version);
1544 if (man_id != 0x001f) {
1545 dev_err(&lp->spi->dev, "Non-Atmel dev found (MAN_ID %02x %02x)\n",
1546 man_id >> 8, man_id & 0xFF);
1550 lp->hw->flags = IEEE802154_HW_TX_OMIT_CKSUM |
1551 IEEE802154_HW_CSMA_PARAMS |
1552 IEEE802154_HW_FRAME_RETRIES | IEEE802154_HW_AFILT |
1553 IEEE802154_HW_PROMISCUOUS;
1555 lp->hw->phy->flags = WPAN_PHY_FLAG_TXPOWER |
1556 WPAN_PHY_FLAG_CCA_ED_LEVEL |
1557 WPAN_PHY_FLAG_CCA_MODE;
1559 lp->hw->phy->supported.cca_modes = BIT(NL802154_CCA_ENERGY) |
1560 BIT(NL802154_CCA_CARRIER) | BIT(NL802154_CCA_ENERGY_CARRIER);
1561 lp->hw->phy->supported.cca_opts = BIT(NL802154_CCA_OPT_ENERGY_CARRIER_AND) |
1562 BIT(NL802154_CCA_OPT_ENERGY_CARRIER_OR);
1564 lp->hw->phy->supported.cca_ed_levels = at86rf23x_ed_levels;
1565 lp->hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(at86rf23x_ed_levels);
1567 lp->hw->phy->cca.mode = NL802154_CCA_ENERGY;
1576 lp->data = &at86rf231_data;
1577 lp->hw->phy->supported.channels[0] = 0x7FFF800;
1578 lp->hw->phy->current_channel = 11;
1579 lp->hw->phy->symbol_duration = 16;
1580 lp->hw->phy->supported.tx_powers = at86rf231_powers;
1581 lp->hw->phy->supported.tx_powers_size = ARRAY_SIZE(at86rf231_powers);
1585 lp->data = &at86rf212_data;
1586 lp->hw->flags |= IEEE802154_HW_LBT;
1587 lp->hw->phy->supported.channels[0] = 0x00007FF;
1588 lp->hw->phy->supported.channels[2] = 0x00007FF;
1589 lp->hw->phy->current_channel = 5;
1590 lp->hw->phy->symbol_duration = 25;
1591 lp->hw->phy->supported.lbt = NL802154_SUPPORTED_BOOL_BOTH;
1592 lp->hw->phy->supported.tx_powers = at86rf212_powers;
1593 lp->hw->phy->supported.tx_powers_size = ARRAY_SIZE(at86rf212_powers);
1594 lp->hw->phy->supported.cca_ed_levels = at86rf212_ed_levels_100;
1595 lp->hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(at86rf212_ed_levels_100);
1599 lp->data = &at86rf233_data;
1600 lp->hw->phy->supported.channels[0] = 0x7FFF800;
1601 lp->hw->phy->current_channel = 13;
1602 lp->hw->phy->symbol_duration = 16;
1603 lp->hw->phy->supported.tx_powers = at86rf233_powers;
1604 lp->hw->phy->supported.tx_powers_size = ARRAY_SIZE(at86rf233_powers);
1612 lp->hw->phy->cca_ed_level = lp->hw->phy->supported.cca_ed_levels[7];
1613 lp->hw->phy->transmit_power = lp->hw->phy->supported.tx_powers[0];
1616 dev_info(&lp->spi->dev, "Detected %s chip version %d\n", chip, version);
1621 #ifdef CONFIG_IEEE802154_AT86RF230_DEBUGFS
1622 static struct dentry *at86rf230_debugfs_root;
1624 static int at86rf230_stats_show(struct seq_file *file, void *offset)
1626 struct at86rf230_local *lp = file->private;
1628 seq_printf(file, "SUCCESS:\t\t%8llu\n", lp->trac.success);
1629 seq_printf(file, "SUCCESS_DATA_PENDING:\t%8llu\n",
1630 lp->trac.success_data_pending);
1631 seq_printf(file, "SUCCESS_WAIT_FOR_ACK:\t%8llu\n",
1632 lp->trac.success_wait_for_ack);
1633 seq_printf(file, "CHANNEL_ACCESS_FAILURE:\t%8llu\n",
1634 lp->trac.channel_access_failure);
1635 seq_printf(file, "NO_ACK:\t\t\t%8llu\n", lp->trac.no_ack);
1636 seq_printf(file, "INVALID:\t\t%8llu\n", lp->trac.invalid);
1640 static int at86rf230_stats_open(struct inode *inode, struct file *file)
1642 return single_open(file, at86rf230_stats_show, inode->i_private);
1645 static const struct file_operations at86rf230_stats_fops = {
1646 .open = at86rf230_stats_open,
1648 .llseek = seq_lseek,
1649 .release = single_release,
1652 static int at86rf230_debugfs_init(struct at86rf230_local *lp)
1654 char debugfs_dir_name[DNAME_INLINE_LEN + 1] = "at86rf230-";
1655 struct dentry *stats;
1657 strncat(debugfs_dir_name, dev_name(&lp->spi->dev), DNAME_INLINE_LEN);
1659 at86rf230_debugfs_root = debugfs_create_dir(debugfs_dir_name, NULL);
1660 if (!at86rf230_debugfs_root)
1663 stats = debugfs_create_file("trac_stats", S_IRUGO,
1664 at86rf230_debugfs_root, lp,
1665 &at86rf230_stats_fops);
1672 static void at86rf230_debugfs_remove(void)
1674 debugfs_remove_recursive(at86rf230_debugfs_root);
1677 static int at86rf230_debugfs_init(struct at86rf230_local *lp) { return 0; }
1678 static void at86rf230_debugfs_remove(void) { }
1681 static int at86rf230_probe(struct spi_device *spi)
1683 struct ieee802154_hw *hw;
1684 struct at86rf230_local *lp;
1685 unsigned int status;
1686 int rc, irq_type, rstn, slp_tr;
1690 dev_err(&spi->dev, "no IRQ specified\n");
1694 rc = at86rf230_get_pdata(spi, &rstn, &slp_tr, &xtal_trim);
1696 dev_err(&spi->dev, "failed to parse platform_data: %d\n", rc);
1700 if (gpio_is_valid(rstn)) {
1701 rc = devm_gpio_request_one(&spi->dev, rstn,
1702 GPIOF_OUT_INIT_HIGH, "rstn");
1707 if (gpio_is_valid(slp_tr)) {
1708 rc = devm_gpio_request_one(&spi->dev, slp_tr,
1709 GPIOF_OUT_INIT_LOW, "slp_tr");
1715 if (gpio_is_valid(rstn)) {
1717 gpio_set_value(rstn, 0);
1719 gpio_set_value(rstn, 1);
1720 usleep_range(120, 240);
1723 hw = ieee802154_alloc_hw(sizeof(*lp), &at86rf230_ops);
1730 lp->slp_tr = slp_tr;
1731 hw->parent = &spi->dev;
1732 ieee802154_random_extended_addr(&hw->phy->perm_extended_addr);
1734 lp->regmap = devm_regmap_init_spi(spi, &at86rf230_regmap_spi_config);
1735 if (IS_ERR(lp->regmap)) {
1736 rc = PTR_ERR(lp->regmap);
1737 dev_err(&spi->dev, "Failed to allocate register map: %d\n",
1742 at86rf230_setup_spi_messages(lp, &lp->state);
1743 at86rf230_setup_spi_messages(lp, &lp->tx);
1745 rc = at86rf230_detect_device(lp);
1749 init_completion(&lp->state_complete);
1751 spi_set_drvdata(spi, lp);
1753 rc = at86rf230_hw_init(lp, xtal_trim);
1757 /* Read irq status register to reset irq line */
1758 rc = at86rf230_read_subreg(lp, RG_IRQ_STATUS, 0xff, 0, &status);
1762 irq_type = irq_get_trigger_type(spi->irq);
1764 irq_type = IRQF_TRIGGER_HIGH;
1766 rc = devm_request_irq(&spi->dev, spi->irq, at86rf230_isr,
1767 IRQF_SHARED | irq_type, dev_name(&spi->dev), lp);
1771 /* disable_irq by default and wait for starting hardware */
1772 disable_irq(spi->irq);
1774 /* going into sleep by default */
1775 at86rf230_sleep(lp);
1777 rc = at86rf230_debugfs_init(lp);
1781 rc = ieee802154_register_hw(lp->hw);
1788 at86rf230_debugfs_remove();
1790 ieee802154_free_hw(lp->hw);
1795 static int at86rf230_remove(struct spi_device *spi)
1797 struct at86rf230_local *lp = spi_get_drvdata(spi);
1799 /* mask all at86rf230 irq's */
1800 at86rf230_write_subreg(lp, SR_IRQ_MASK, 0);
1801 ieee802154_unregister_hw(lp->hw);
1802 ieee802154_free_hw(lp->hw);
1803 at86rf230_debugfs_remove();
1804 dev_dbg(&spi->dev, "unregistered at86rf230\n");
1809 static const struct of_device_id at86rf230_of_match[] = {
1810 { .compatible = "atmel,at86rf230", },
1811 { .compatible = "atmel,at86rf231", },
1812 { .compatible = "atmel,at86rf233", },
1813 { .compatible = "atmel,at86rf212", },
1816 MODULE_DEVICE_TABLE(of, at86rf230_of_match);
1818 static const struct spi_device_id at86rf230_device_id[] = {
1819 { .name = "at86rf230", },
1820 { .name = "at86rf231", },
1821 { .name = "at86rf233", },
1822 { .name = "at86rf212", },
1825 MODULE_DEVICE_TABLE(spi, at86rf230_device_id);
1827 static struct spi_driver at86rf230_driver = {
1828 .id_table = at86rf230_device_id,
1830 .of_match_table = of_match_ptr(at86rf230_of_match),
1831 .name = "at86rf230",
1833 .probe = at86rf230_probe,
1834 .remove = at86rf230_remove,
1837 module_spi_driver(at86rf230_driver);
1839 MODULE_DESCRIPTION("AT86RF230 Transceiver Driver");
1840 MODULE_LICENSE("GPL v2");