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;
112 struct sk_buff *tx_skb;
113 struct at86rf230_state_change tx;
115 struct at86rf230_trac trac;
118 #define AT86RF2XX_NUMREGS 0x3F
121 at86rf230_async_state_change(struct at86rf230_local *lp,
122 struct at86rf230_state_change *ctx,
123 const u8 state, void (*complete)(void *context));
126 at86rf230_sleep(struct at86rf230_local *lp)
128 if (gpio_is_valid(lp->slp_tr)) {
129 gpio_set_value(lp->slp_tr, 1);
130 usleep_range(lp->data->t_off_to_sleep,
131 lp->data->t_off_to_sleep + 10);
137 at86rf230_awake(struct at86rf230_local *lp)
139 if (gpio_is_valid(lp->slp_tr)) {
140 gpio_set_value(lp->slp_tr, 0);
141 usleep_range(lp->data->t_sleep_to_off,
142 lp->data->t_sleep_to_off + 100);
148 __at86rf230_write(struct at86rf230_local *lp,
149 unsigned int addr, unsigned int data)
151 bool sleep = lp->sleep;
154 /* awake for register setting if sleep */
158 ret = regmap_write(lp->regmap, addr, data);
160 /* sleep again if was sleeping */
168 __at86rf230_read(struct at86rf230_local *lp,
169 unsigned int addr, unsigned int *data)
171 bool sleep = lp->sleep;
174 /* awake for register setting if sleep */
178 ret = regmap_read(lp->regmap, addr, data);
180 /* sleep again if was sleeping */
188 at86rf230_read_subreg(struct at86rf230_local *lp,
189 unsigned int addr, unsigned int mask,
190 unsigned int shift, unsigned int *data)
194 rc = __at86rf230_read(lp, addr, data);
196 *data = (*data & mask) >> shift;
202 at86rf230_write_subreg(struct at86rf230_local *lp,
203 unsigned int addr, unsigned int mask,
204 unsigned int shift, unsigned int data)
206 bool sleep = lp->sleep;
209 /* awake for register setting if sleep */
213 ret = regmap_update_bits(lp->regmap, addr, mask, data << shift);
215 /* sleep again if was sleeping */
223 at86rf230_slp_tr_rising_edge(struct at86rf230_local *lp)
225 gpio_set_value(lp->slp_tr, 1);
227 gpio_set_value(lp->slp_tr, 0);
231 at86rf230_reg_writeable(struct device *dev, unsigned int reg)
238 case RG_PHY_ED_LEVEL:
254 case RG_SHORT_ADDR_0:
255 case RG_SHORT_ADDR_1:
277 at86rf230_reg_readable(struct device *dev, unsigned int reg)
281 /* all writeable are also readable */
282 rc = at86rf230_reg_writeable(dev, reg);
302 at86rf230_reg_volatile(struct device *dev, unsigned int reg)
304 /* can be changed during runtime */
309 case RG_PHY_ED_LEVEL:
321 at86rf230_reg_precious(struct device *dev, unsigned int reg)
323 /* don't clear irq line on read */
332 static const struct regmap_config at86rf230_regmap_spi_config = {
335 .write_flag_mask = CMD_REG | CMD_WRITE,
336 .read_flag_mask = CMD_REG,
337 .cache_type = REGCACHE_RBTREE,
338 .max_register = AT86RF2XX_NUMREGS,
339 .writeable_reg = at86rf230_reg_writeable,
340 .readable_reg = at86rf230_reg_readable,
341 .volatile_reg = at86rf230_reg_volatile,
342 .precious_reg = at86rf230_reg_precious,
346 at86rf230_async_error_recover(void *context)
348 struct at86rf230_state_change *ctx = context;
349 struct at86rf230_local *lp = ctx->lp;
352 at86rf230_async_state_change(lp, ctx, STATE_RX_AACK_ON, NULL);
353 ieee802154_wake_queue(lp->hw);
359 at86rf230_async_error(struct at86rf230_local *lp,
360 struct at86rf230_state_change *ctx, int rc)
362 dev_err(&lp->spi->dev, "spi_async error %d\n", rc);
364 at86rf230_async_state_change(lp, ctx, STATE_FORCE_TRX_OFF,
365 at86rf230_async_error_recover);
368 /* Generic function to get some register value in async mode */
370 at86rf230_async_read_reg(struct at86rf230_local *lp, u8 reg,
371 struct at86rf230_state_change *ctx,
372 void (*complete)(void *context))
376 u8 *tx_buf = ctx->buf;
378 tx_buf[0] = (reg & CMD_REG_MASK) | CMD_REG;
379 ctx->msg.complete = complete;
380 rc = spi_async(lp->spi, &ctx->msg);
382 at86rf230_async_error(lp, ctx, rc);
386 at86rf230_async_write_reg(struct at86rf230_local *lp, u8 reg, u8 val,
387 struct at86rf230_state_change *ctx,
388 void (*complete)(void *context))
392 ctx->buf[0] = (reg & CMD_REG_MASK) | CMD_REG | CMD_WRITE;
394 ctx->msg.complete = complete;
395 rc = spi_async(lp->spi, &ctx->msg);
397 at86rf230_async_error(lp, ctx, rc);
401 at86rf230_async_state_assert(void *context)
403 struct at86rf230_state_change *ctx = context;
404 struct at86rf230_local *lp = ctx->lp;
405 const u8 *buf = ctx->buf;
406 const u8 trx_state = buf[1] & TRX_STATE_MASK;
408 /* Assert state change */
409 if (trx_state != ctx->to_state) {
410 /* Special handling if transceiver state is in
411 * STATE_BUSY_RX_AACK and a SHR was detected.
413 if (trx_state == STATE_BUSY_RX_AACK) {
414 /* Undocumented race condition. If we send a state
415 * change to STATE_RX_AACK_ON the transceiver could
416 * change his state automatically to STATE_BUSY_RX_AACK
417 * if a SHR was detected. This is not an error, but we
420 if (ctx->to_state == STATE_RX_AACK_ON)
423 /* If we change to STATE_TX_ON without forcing and
424 * transceiver state is STATE_BUSY_RX_AACK, we wait
425 * 'tFrame + tPAck' receiving time. In this time the
426 * PDU should be received. If the transceiver is still
427 * in STATE_BUSY_RX_AACK, we run a force state change
428 * to STATE_TX_ON. This is a timeout handling, if the
429 * transceiver stucks in STATE_BUSY_RX_AACK.
431 * Additional we do several retries to try to get into
432 * TX_ON state without forcing. If the retries are
433 * higher or equal than AT86RF2XX_MAX_TX_RETRIES we
434 * will do a force change.
436 if (ctx->to_state == STATE_TX_ON ||
437 ctx->to_state == STATE_TRX_OFF) {
438 u8 state = ctx->to_state;
440 if (lp->tx_retry >= AT86RF2XX_MAX_TX_RETRIES)
441 state = STATE_FORCE_TRX_OFF;
444 at86rf230_async_state_change(lp, ctx, state,
450 dev_warn(&lp->spi->dev, "unexcept state change from 0x%02x to 0x%02x. Actual state: 0x%02x\n",
451 ctx->from_state, ctx->to_state, trx_state);
456 ctx->complete(context);
459 static enum hrtimer_restart at86rf230_async_state_timer(struct hrtimer *timer)
461 struct at86rf230_state_change *ctx =
462 container_of(timer, struct at86rf230_state_change, timer);
463 struct at86rf230_local *lp = ctx->lp;
465 at86rf230_async_read_reg(lp, RG_TRX_STATUS, ctx,
466 at86rf230_async_state_assert);
468 return HRTIMER_NORESTART;
471 /* Do state change timing delay. */
473 at86rf230_async_state_delay(void *context)
475 struct at86rf230_state_change *ctx = context;
476 struct at86rf230_local *lp = ctx->lp;
477 struct at86rf2xx_chip_data *c = lp->data;
481 /* The force state changes are will show as normal states in the
482 * state status subregister. We change the to_state to the
483 * corresponding one and remember if it was a force change, this
484 * differs if we do a state change from STATE_BUSY_RX_AACK.
486 switch (ctx->to_state) {
487 case STATE_FORCE_TX_ON:
488 ctx->to_state = STATE_TX_ON;
491 case STATE_FORCE_TRX_OFF:
492 ctx->to_state = STATE_TRX_OFF;
499 switch (ctx->from_state) {
501 switch (ctx->to_state) {
502 case STATE_RX_AACK_ON:
503 tim = ktime_set(0, c->t_off_to_aack * NSEC_PER_USEC);
504 /* state change from TRX_OFF to RX_AACK_ON to do a
505 * calibration, we need to reset the timeout for the
508 lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT;
510 case STATE_TX_ARET_ON:
512 tim = ktime_set(0, c->t_off_to_tx_on * NSEC_PER_USEC);
513 /* state change from TRX_OFF to TX_ON or ARET_ON to do
514 * a calibration, we need to reset the timeout for the
517 lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT;
523 case STATE_BUSY_RX_AACK:
524 switch (ctx->to_state) {
527 /* Wait for worst case receiving time if we
528 * didn't make a force change from BUSY_RX_AACK
529 * to TX_ON or TRX_OFF.
532 tim = ktime_set(0, (c->t_frame + c->t_p_ack) *
541 /* Default value, means RESET state */
543 switch (ctx->to_state) {
545 tim = ktime_set(0, c->t_reset_to_off * NSEC_PER_USEC);
555 /* Default delay is 1us in the most cases */
557 at86rf230_async_state_timer(&ctx->timer);
561 hrtimer_start(&ctx->timer, tim, HRTIMER_MODE_REL);
565 at86rf230_async_state_change_start(void *context)
567 struct at86rf230_state_change *ctx = context;
568 struct at86rf230_local *lp = ctx->lp;
570 const u8 trx_state = buf[1] & TRX_STATE_MASK;
572 /* Check for "possible" STATE_TRANSITION_IN_PROGRESS */
573 if (trx_state == STATE_TRANSITION_IN_PROGRESS) {
575 at86rf230_async_read_reg(lp, RG_TRX_STATUS, ctx,
576 at86rf230_async_state_change_start);
580 /* Check if we already are in the state which we change in */
581 if (trx_state == ctx->to_state) {
583 ctx->complete(context);
587 /* Set current state to the context of state change */
588 ctx->from_state = trx_state;
590 /* Going into the next step for a state change which do a timing
593 at86rf230_async_write_reg(lp, RG_TRX_STATE, ctx->to_state, ctx,
594 at86rf230_async_state_delay);
598 at86rf230_async_state_change(struct at86rf230_local *lp,
599 struct at86rf230_state_change *ctx,
600 const u8 state, void (*complete)(void *context))
602 /* Initialization for the state change context */
603 ctx->to_state = state;
604 ctx->complete = complete;
605 at86rf230_async_read_reg(lp, RG_TRX_STATUS, ctx,
606 at86rf230_async_state_change_start);
610 at86rf230_sync_state_change_complete(void *context)
612 struct at86rf230_state_change *ctx = context;
613 struct at86rf230_local *lp = ctx->lp;
615 complete(&lp->state_complete);
618 /* This function do a sync framework above the async state change.
619 * Some callbacks of the IEEE 802.15.4 driver interface need to be
620 * handled synchronously.
623 at86rf230_sync_state_change(struct at86rf230_local *lp, unsigned int state)
627 at86rf230_async_state_change(lp, &lp->state, state,
628 at86rf230_sync_state_change_complete);
630 rc = wait_for_completion_timeout(&lp->state_complete,
631 msecs_to_jiffies(100));
633 at86rf230_async_error(lp, &lp->state, -ETIMEDOUT);
641 at86rf230_tx_complete(void *context)
643 struct at86rf230_state_change *ctx = context;
644 struct at86rf230_local *lp = ctx->lp;
646 ieee802154_xmit_complete(lp->hw, lp->tx_skb, false);
651 at86rf230_tx_on(void *context)
653 struct at86rf230_state_change *ctx = context;
654 struct at86rf230_local *lp = ctx->lp;
656 at86rf230_async_state_change(lp, ctx, STATE_RX_AACK_ON,
657 at86rf230_tx_complete);
661 at86rf230_tx_trac_check(void *context)
663 struct at86rf230_state_change *ctx = context;
664 struct at86rf230_local *lp = ctx->lp;
666 if (IS_ENABLED(CONFIG_IEEE802154_AT86RF230_DEBUGFS)) {
667 u8 trac = TRAC_MASK(ctx->buf[1]);
673 case TRAC_SUCCESS_DATA_PENDING:
674 lp->trac.success_data_pending++;
676 case TRAC_CHANNEL_ACCESS_FAILURE:
677 lp->trac.channel_access_failure++;
686 WARN_ONCE(1, "received tx trac status %d\n", trac);
691 at86rf230_async_state_change(lp, ctx, STATE_TX_ON, at86rf230_tx_on);
695 at86rf230_rx_read_frame_complete(void *context)
697 struct at86rf230_state_change *ctx = context;
698 struct at86rf230_local *lp = ctx->lp;
699 const u8 *buf = ctx->buf;
704 if (!ieee802154_is_valid_psdu_len(len)) {
705 dev_vdbg(&lp->spi->dev, "corrupted frame received\n");
706 len = IEEE802154_MTU;
710 skb = dev_alloc_skb(IEEE802154_MTU);
712 dev_vdbg(&lp->spi->dev, "failed to allocate sk_buff\n");
717 memcpy(skb_put(skb, len), buf + 2, len);
718 ieee802154_rx_irqsafe(lp->hw, skb, lqi);
723 at86rf230_rx_trac_check(void *context)
725 struct at86rf230_state_change *ctx = context;
726 struct at86rf230_local *lp = ctx->lp;
730 if (IS_ENABLED(CONFIG_IEEE802154_AT86RF230_DEBUGFS)) {
731 u8 trac = TRAC_MASK(buf[1]);
737 case TRAC_SUCCESS_WAIT_FOR_ACK:
738 lp->trac.success_wait_for_ack++;
744 WARN_ONCE(1, "received rx trac status %d\n", trac);
750 ctx->trx.len = AT86RF2XX_MAX_BUF;
751 ctx->msg.complete = at86rf230_rx_read_frame_complete;
752 rc = spi_async(lp->spi, &ctx->msg);
755 at86rf230_async_error(lp, ctx, rc);
760 at86rf230_irq_trx_end(void *context)
762 struct at86rf230_state_change *ctx = context;
763 struct at86rf230_local *lp = ctx->lp;
767 at86rf230_async_read_reg(lp, RG_TRX_STATE, ctx,
768 at86rf230_tx_trac_check);
770 at86rf230_async_read_reg(lp, RG_TRX_STATE, ctx,
771 at86rf230_rx_trac_check);
776 at86rf230_irq_status(void *context)
778 struct at86rf230_state_change *ctx = context;
779 struct at86rf230_local *lp = ctx->lp;
780 const u8 *buf = ctx->buf;
783 enable_irq(lp->spi->irq);
785 if (irq & IRQ_TRX_END) {
786 at86rf230_irq_trx_end(ctx);
788 dev_err(&lp->spi->dev, "not supported irq %02x received\n",
795 at86rf230_setup_spi_messages(struct at86rf230_local *lp,
796 struct at86rf230_state_change *state)
799 state->irq = lp->spi->irq;
800 spi_message_init(&state->msg);
801 state->msg.context = state;
803 state->trx.tx_buf = state->buf;
804 state->trx.rx_buf = state->buf;
805 spi_message_add_tail(&state->trx, &state->msg);
806 hrtimer_init(&state->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
807 state->timer.function = at86rf230_async_state_timer;
810 static irqreturn_t at86rf230_isr(int irq, void *data)
812 struct at86rf230_local *lp = data;
813 struct at86rf230_state_change *ctx;
816 disable_irq_nosync(irq);
818 ctx = kzalloc(sizeof(*ctx), GFP_ATOMIC);
824 at86rf230_setup_spi_messages(lp, ctx);
825 /* tell on error handling to free ctx */
828 ctx->buf[0] = (RG_IRQ_STATUS & CMD_REG_MASK) | CMD_REG;
829 ctx->msg.complete = at86rf230_irq_status;
830 rc = spi_async(lp->spi, &ctx->msg);
832 at86rf230_async_error(lp, ctx, rc);
841 at86rf230_write_frame_complete(void *context)
843 struct at86rf230_state_change *ctx = context;
844 struct at86rf230_local *lp = ctx->lp;
848 if (gpio_is_valid(lp->slp_tr))
849 at86rf230_slp_tr_rising_edge(lp);
851 at86rf230_async_write_reg(lp, RG_TRX_STATE, STATE_BUSY_TX, ctx,
856 at86rf230_write_frame(void *context)
858 struct at86rf230_state_change *ctx = context;
859 struct at86rf230_local *lp = ctx->lp;
860 struct sk_buff *skb = lp->tx_skb;
866 buf[0] = CMD_FB | CMD_WRITE;
867 buf[1] = skb->len + 2;
868 memcpy(buf + 2, skb->data, skb->len);
869 ctx->trx.len = skb->len + 2;
870 ctx->msg.complete = at86rf230_write_frame_complete;
871 rc = spi_async(lp->spi, &ctx->msg);
874 at86rf230_async_error(lp, ctx, rc);
879 at86rf230_xmit_tx_on(void *context)
881 struct at86rf230_state_change *ctx = context;
882 struct at86rf230_local *lp = ctx->lp;
884 at86rf230_async_state_change(lp, ctx, STATE_TX_ARET_ON,
885 at86rf230_write_frame);
889 at86rf230_xmit_start(void *context)
891 struct at86rf230_state_change *ctx = context;
892 struct at86rf230_local *lp = ctx->lp;
894 /* check if we change from off state */
895 if (lp->is_tx_from_off) {
896 lp->is_tx_from_off = false;
897 at86rf230_async_state_change(lp, ctx, STATE_TX_ARET_ON,
898 at86rf230_write_frame);
900 at86rf230_async_state_change(lp, ctx, STATE_TX_ON,
901 at86rf230_xmit_tx_on);
906 at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
908 struct at86rf230_local *lp = hw->priv;
909 struct at86rf230_state_change *ctx = &lp->tx;
914 /* After 5 minutes in PLL and the same frequency we run again the
915 * calibration loops which is recommended by at86rf2xx datasheets.
917 * The calibration is initiate by a state change from TRX_OFF
918 * to TX_ON, the lp->cal_timeout should be reinit by state_delay
919 * function then to start in the next 5 minutes.
921 if (time_is_before_jiffies(lp->cal_timeout)) {
922 lp->is_tx_from_off = true;
923 at86rf230_async_state_change(lp, ctx, STATE_TRX_OFF,
924 at86rf230_xmit_start);
926 at86rf230_xmit_start(ctx);
933 at86rf230_ed(struct ieee802154_hw *hw, u8 *level)
941 at86rf230_start(struct ieee802154_hw *hw)
943 struct at86rf230_local *lp = hw->priv;
945 /* reset trac stats on start */
946 if (IS_ENABLED(CONFIG_IEEE802154_AT86RF230_DEBUGFS))
947 memset(&lp->trac, 0, sizeof(struct at86rf230_trac));
950 enable_irq(lp->spi->irq);
952 return at86rf230_sync_state_change(lp, STATE_RX_AACK_ON);
956 at86rf230_stop(struct ieee802154_hw *hw)
958 struct at86rf230_local *lp = hw->priv;
961 at86rf230_sync_state_change(lp, STATE_FORCE_TRX_OFF);
963 disable_irq(lp->spi->irq);
965 /* It's recommended to set random new csma_seeds before sleep state.
966 * Makes only sense in the stop callback, not doing this inside of
967 * at86rf230_sleep, this is also used when we don't transmit afterwards
968 * when calling start callback again.
970 get_random_bytes(csma_seed, ARRAY_SIZE(csma_seed));
971 at86rf230_write_subreg(lp, SR_CSMA_SEED_0, csma_seed[0]);
972 at86rf230_write_subreg(lp, SR_CSMA_SEED_1, csma_seed[1]);
978 at86rf23x_set_channel(struct at86rf230_local *lp, u8 page, u8 channel)
980 return at86rf230_write_subreg(lp, SR_CHANNEL, channel);
983 #define AT86RF2XX_MAX_ED_LEVELS 0xF
984 static const s32 at86rf23x_ed_levels[AT86RF2XX_MAX_ED_LEVELS + 1] = {
985 -9100, -8900, -8700, -8500, -8300, -8100, -7900, -7700, -7500, -7300,
986 -7100, -6900, -6700, -6500, -6300, -6100,
989 static const s32 at86rf212_ed_levels_100[AT86RF2XX_MAX_ED_LEVELS + 1] = {
990 -10000, -9800, -9600, -9400, -9200, -9000, -8800, -8600, -8400, -8200,
991 -8000, -7800, -7600, -7400, -7200, -7000,
994 static const s32 at86rf212_ed_levels_98[AT86RF2XX_MAX_ED_LEVELS + 1] = {
995 -9800, -9600, -9400, -9200, -9000, -8800, -8600, -8400, -8200, -8000,
996 -7800, -7600, -7400, -7200, -7000, -6800,
1000 at86rf212_update_cca_ed_level(struct at86rf230_local *lp, int rssi_base_val)
1002 unsigned int cca_ed_thres;
1005 rc = at86rf230_read_subreg(lp, SR_CCA_ED_THRES, &cca_ed_thres);
1009 switch (rssi_base_val) {
1011 lp->hw->phy->supported.cca_ed_levels = at86rf212_ed_levels_98;
1012 lp->hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(at86rf212_ed_levels_98);
1013 lp->hw->phy->cca_ed_level = at86rf212_ed_levels_98[cca_ed_thres];
1016 lp->hw->phy->supported.cca_ed_levels = at86rf212_ed_levels_100;
1017 lp->hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(at86rf212_ed_levels_100);
1018 lp->hw->phy->cca_ed_level = at86rf212_ed_levels_100[cca_ed_thres];
1028 at86rf212_set_channel(struct at86rf230_local *lp, u8 page, u8 channel)
1033 rc = at86rf230_write_subreg(lp, SR_SUB_MODE, 0);
1035 rc = at86rf230_write_subreg(lp, SR_SUB_MODE, 1);
1040 rc = at86rf230_write_subreg(lp, SR_BPSK_QPSK, 0);
1041 lp->data->rssi_base_val = -100;
1043 rc = at86rf230_write_subreg(lp, SR_BPSK_QPSK, 1);
1044 lp->data->rssi_base_val = -98;
1049 rc = at86rf212_update_cca_ed_level(lp, lp->data->rssi_base_val);
1053 /* This sets the symbol_duration according frequency on the 212.
1054 * TODO move this handling while set channel and page in cfg802154.
1055 * We can do that, this timings are according 802.15.4 standard.
1056 * If we do that in cfg802154, this is a more generic calculation.
1058 * This should also protected from ifs_timer. Means cancel timer and
1059 * init with a new value. For now, this is okay.
1063 /* SUB:0 and BPSK:0 -> BPSK-20 */
1064 lp->hw->phy->symbol_duration = 50;
1066 /* SUB:1 and BPSK:0 -> BPSK-40 */
1067 lp->hw->phy->symbol_duration = 25;
1071 /* SUB:0 and BPSK:1 -> OQPSK-100/200/400 */
1072 lp->hw->phy->symbol_duration = 40;
1074 /* SUB:1 and BPSK:1 -> OQPSK-250/500/1000 */
1075 lp->hw->phy->symbol_duration = 16;
1078 lp->hw->phy->lifs_period = IEEE802154_LIFS_PERIOD *
1079 lp->hw->phy->symbol_duration;
1080 lp->hw->phy->sifs_period = IEEE802154_SIFS_PERIOD *
1081 lp->hw->phy->symbol_duration;
1083 return at86rf230_write_subreg(lp, SR_CHANNEL, channel);
1087 at86rf230_channel(struct ieee802154_hw *hw, u8 page, u8 channel)
1089 struct at86rf230_local *lp = hw->priv;
1092 rc = lp->data->set_channel(lp, page, channel);
1094 usleep_range(lp->data->t_channel_switch,
1095 lp->data->t_channel_switch + 10);
1097 lp->cal_timeout = jiffies + AT86RF2XX_CAL_LOOP_TIMEOUT;
1102 at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
1103 struct ieee802154_hw_addr_filt *filt,
1104 unsigned long changed)
1106 struct at86rf230_local *lp = hw->priv;
1108 if (changed & IEEE802154_AFILT_SADDR_CHANGED) {
1109 u16 addr = le16_to_cpu(filt->short_addr);
1111 dev_vdbg(&lp->spi->dev, "%s called for saddr\n", __func__);
1112 __at86rf230_write(lp, RG_SHORT_ADDR_0, addr);
1113 __at86rf230_write(lp, RG_SHORT_ADDR_1, addr >> 8);
1116 if (changed & IEEE802154_AFILT_PANID_CHANGED) {
1117 u16 pan = le16_to_cpu(filt->pan_id);
1119 dev_vdbg(&lp->spi->dev, "%s called for pan id\n", __func__);
1120 __at86rf230_write(lp, RG_PAN_ID_0, pan);
1121 __at86rf230_write(lp, RG_PAN_ID_1, pan >> 8);
1124 if (changed & IEEE802154_AFILT_IEEEADDR_CHANGED) {
1127 memcpy(addr, &filt->ieee_addr, 8);
1128 dev_vdbg(&lp->spi->dev, "%s called for IEEE addr\n", __func__);
1129 for (i = 0; i < 8; i++)
1130 __at86rf230_write(lp, RG_IEEE_ADDR_0 + i, addr[i]);
1133 if (changed & IEEE802154_AFILT_PANC_CHANGED) {
1134 dev_vdbg(&lp->spi->dev, "%s called for panc change\n", __func__);
1135 if (filt->pan_coord)
1136 at86rf230_write_subreg(lp, SR_AACK_I_AM_COORD, 1);
1138 at86rf230_write_subreg(lp, SR_AACK_I_AM_COORD, 0);
1144 #define AT86RF23X_MAX_TX_POWERS 0xF
1145 static const s32 at86rf233_powers[AT86RF23X_MAX_TX_POWERS + 1] = {
1146 400, 370, 340, 300, 250, 200, 100, 0, -100, -200, -300, -400, -600,
1150 static const s32 at86rf231_powers[AT86RF23X_MAX_TX_POWERS + 1] = {
1151 300, 280, 230, 180, 130, 70, 0, -100, -200, -300, -400, -500, -700,
1155 #define AT86RF212_MAX_TX_POWERS 0x1F
1156 static const s32 at86rf212_powers[AT86RF212_MAX_TX_POWERS + 1] = {
1157 500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500, -600, -700,
1158 -800, -900, -1000, -1100, -1200, -1300, -1400, -1500, -1600, -1700,
1159 -1800, -1900, -2000, -2100, -2200, -2300, -2400, -2500, -2600,
1163 at86rf23x_set_txpower(struct at86rf230_local *lp, s32 mbm)
1167 for (i = 0; i < lp->hw->phy->supported.tx_powers_size; i++) {
1168 if (lp->hw->phy->supported.tx_powers[i] == mbm)
1169 return at86rf230_write_subreg(lp, SR_TX_PWR_23X, i);
1176 at86rf212_set_txpower(struct at86rf230_local *lp, s32 mbm)
1180 for (i = 0; i < lp->hw->phy->supported.tx_powers_size; i++) {
1181 if (lp->hw->phy->supported.tx_powers[i] == mbm)
1182 return at86rf230_write_subreg(lp, SR_TX_PWR_212, i);
1189 at86rf230_set_txpower(struct ieee802154_hw *hw, s32 mbm)
1191 struct at86rf230_local *lp = hw->priv;
1193 return lp->data->set_txpower(lp, mbm);
1197 at86rf230_set_lbt(struct ieee802154_hw *hw, bool on)
1199 struct at86rf230_local *lp = hw->priv;
1201 return at86rf230_write_subreg(lp, SR_CSMA_LBT_MODE, on);
1205 at86rf230_set_cca_mode(struct ieee802154_hw *hw,
1206 const struct wpan_phy_cca *cca)
1208 struct at86rf230_local *lp = hw->priv;
1211 /* mapping 802.15.4 to driver spec */
1212 switch (cca->mode) {
1213 case NL802154_CCA_ENERGY:
1216 case NL802154_CCA_CARRIER:
1219 case NL802154_CCA_ENERGY_CARRIER:
1221 case NL802154_CCA_OPT_ENERGY_CARRIER_AND:
1224 case NL802154_CCA_OPT_ENERGY_CARRIER_OR:
1235 return at86rf230_write_subreg(lp, SR_CCA_MODE, val);
1239 at86rf230_set_cca_ed_level(struct ieee802154_hw *hw, s32 mbm)
1241 struct at86rf230_local *lp = hw->priv;
1244 for (i = 0; i < hw->phy->supported.cca_ed_levels_size; i++) {
1245 if (hw->phy->supported.cca_ed_levels[i] == mbm)
1246 return at86rf230_write_subreg(lp, SR_CCA_ED_THRES, i);
1253 at86rf230_set_csma_params(struct ieee802154_hw *hw, u8 min_be, u8 max_be,
1256 struct at86rf230_local *lp = hw->priv;
1259 rc = at86rf230_write_subreg(lp, SR_MIN_BE, min_be);
1263 rc = at86rf230_write_subreg(lp, SR_MAX_BE, max_be);
1267 return at86rf230_write_subreg(lp, SR_MAX_CSMA_RETRIES, retries);
1271 at86rf230_set_frame_retries(struct ieee802154_hw *hw, s8 retries)
1273 struct at86rf230_local *lp = hw->priv;
1275 return at86rf230_write_subreg(lp, SR_MAX_FRAME_RETRIES, retries);
1279 at86rf230_set_promiscuous_mode(struct ieee802154_hw *hw, const bool on)
1281 struct at86rf230_local *lp = hw->priv;
1285 rc = at86rf230_write_subreg(lp, SR_AACK_DIS_ACK, 1);
1289 rc = at86rf230_write_subreg(lp, SR_AACK_PROM_MODE, 1);
1293 rc = at86rf230_write_subreg(lp, SR_AACK_PROM_MODE, 0);
1297 rc = at86rf230_write_subreg(lp, SR_AACK_DIS_ACK, 0);
1305 static const struct ieee802154_ops at86rf230_ops = {
1306 .owner = THIS_MODULE,
1307 .xmit_async = at86rf230_xmit,
1309 .set_channel = at86rf230_channel,
1310 .start = at86rf230_start,
1311 .stop = at86rf230_stop,
1312 .set_hw_addr_filt = at86rf230_set_hw_addr_filt,
1313 .set_txpower = at86rf230_set_txpower,
1314 .set_lbt = at86rf230_set_lbt,
1315 .set_cca_mode = at86rf230_set_cca_mode,
1316 .set_cca_ed_level = at86rf230_set_cca_ed_level,
1317 .set_csma_params = at86rf230_set_csma_params,
1318 .set_frame_retries = at86rf230_set_frame_retries,
1319 .set_promiscuous_mode = at86rf230_set_promiscuous_mode,
1322 static struct at86rf2xx_chip_data at86rf233_data = {
1323 .t_sleep_cycle = 330,
1324 .t_channel_switch = 11,
1325 .t_reset_to_off = 26,
1326 .t_off_to_aack = 80,
1327 .t_off_to_tx_on = 80,
1328 .t_off_to_sleep = 35,
1329 .t_sleep_to_off = 210,
1332 .rssi_base_val = -91,
1333 .set_channel = at86rf23x_set_channel,
1334 .set_txpower = at86rf23x_set_txpower,
1337 static struct at86rf2xx_chip_data at86rf231_data = {
1338 .t_sleep_cycle = 330,
1339 .t_channel_switch = 24,
1340 .t_reset_to_off = 37,
1341 .t_off_to_aack = 110,
1342 .t_off_to_tx_on = 110,
1343 .t_off_to_sleep = 35,
1344 .t_sleep_to_off = 380,
1347 .rssi_base_val = -91,
1348 .set_channel = at86rf23x_set_channel,
1349 .set_txpower = at86rf23x_set_txpower,
1352 static struct at86rf2xx_chip_data at86rf212_data = {
1353 .t_sleep_cycle = 330,
1354 .t_channel_switch = 11,
1355 .t_reset_to_off = 26,
1356 .t_off_to_aack = 200,
1357 .t_off_to_tx_on = 200,
1358 .t_off_to_sleep = 35,
1359 .t_sleep_to_off = 380,
1362 .rssi_base_val = -100,
1363 .set_channel = at86rf212_set_channel,
1364 .set_txpower = at86rf212_set_txpower,
1367 static int at86rf230_hw_init(struct at86rf230_local *lp, u8 xtal_trim)
1369 int rc, irq_type, irq_pol = IRQ_ACTIVE_HIGH;
1373 rc = at86rf230_sync_state_change(lp, STATE_FORCE_TRX_OFF);
1377 irq_type = irq_get_trigger_type(lp->spi->irq);
1378 if (irq_type == IRQ_TYPE_EDGE_FALLING ||
1379 irq_type == IRQ_TYPE_LEVEL_LOW)
1380 irq_pol = IRQ_ACTIVE_LOW;
1382 rc = at86rf230_write_subreg(lp, SR_IRQ_POLARITY, irq_pol);
1386 rc = at86rf230_write_subreg(lp, SR_RX_SAFE_MODE, 1);
1390 rc = at86rf230_write_subreg(lp, SR_IRQ_MASK, IRQ_TRX_END);
1394 /* reset values differs in at86rf231 and at86rf233 */
1395 rc = at86rf230_write_subreg(lp, SR_IRQ_MASK_MODE, 0);
1399 get_random_bytes(csma_seed, ARRAY_SIZE(csma_seed));
1400 rc = at86rf230_write_subreg(lp, SR_CSMA_SEED_0, csma_seed[0]);
1403 rc = at86rf230_write_subreg(lp, SR_CSMA_SEED_1, csma_seed[1]);
1407 /* CLKM changes are applied immediately */
1408 rc = at86rf230_write_subreg(lp, SR_CLKM_SHA_SEL, 0x00);
1413 rc = at86rf230_write_subreg(lp, SR_CLKM_CTRL, 0x00);
1416 /* Wait the next SLEEP cycle */
1417 usleep_range(lp->data->t_sleep_cycle,
1418 lp->data->t_sleep_cycle + 100);
1420 /* xtal_trim value is calculated by:
1421 * CL = 0.5 * (CX + CTRIM + CPAR)
1424 * CL = capacitor of used crystal
1425 * CX = connected capacitors at xtal pins
1426 * CPAR = in all at86rf2xx datasheets this is a constant value 3 pF,
1427 * but this is different on each board setup. You need to fine
1428 * tuning this value via CTRIM.
1429 * CTRIM = variable capacitor setting. Resolution is 0.3 pF range is
1433 * atben transceiver:
1437 * CPAR = 3 pF (We assume the magic constant from datasheet)
1440 * (12+0.9+3)/2 = 7.95 which is nearly at 8 pF
1444 * openlabs transceiver:
1448 * CPAR = 3 pF (We assume the magic constant from datasheet)
1451 * (22+4.5+3)/2 = 14.75 which is the nearest value to 16 pF
1455 rc = at86rf230_write_subreg(lp, SR_XTAL_TRIM, xtal_trim);
1459 rc = at86rf230_read_subreg(lp, SR_DVDD_OK, &dvdd);
1463 dev_err(&lp->spi->dev, "DVDD error\n");
1467 /* Force setting slotted operation bit to 0. Sometimes the atben
1468 * sets this bit and I don't know why. We set this always force
1469 * to zero while probing.
1471 return at86rf230_write_subreg(lp, SR_SLOTTED_OPERATION, 0);
1475 at86rf230_get_pdata(struct spi_device *spi, int *rstn, int *slp_tr,
1478 struct at86rf230_platform_data *pdata = spi->dev.platform_data;
1481 if (!IS_ENABLED(CONFIG_OF) || !spi->dev.of_node) {
1485 *rstn = pdata->rstn;
1486 *slp_tr = pdata->slp_tr;
1487 *xtal_trim = pdata->xtal_trim;
1491 *rstn = of_get_named_gpio(spi->dev.of_node, "reset-gpio", 0);
1492 *slp_tr = of_get_named_gpio(spi->dev.of_node, "sleep-gpio", 0);
1493 ret = of_property_read_u8(spi->dev.of_node, "xtal-trim", xtal_trim);
1494 if (ret < 0 && ret != -EINVAL)
1501 at86rf230_detect_device(struct at86rf230_local *lp)
1503 unsigned int part, version, val;
1508 rc = __at86rf230_read(lp, RG_MAN_ID_0, &val);
1513 rc = __at86rf230_read(lp, RG_MAN_ID_1, &val);
1516 man_id |= (val << 8);
1518 rc = __at86rf230_read(lp, RG_PART_NUM, &part);
1522 rc = __at86rf230_read(lp, RG_VERSION_NUM, &version);
1526 if (man_id != 0x001f) {
1527 dev_err(&lp->spi->dev, "Non-Atmel dev found (MAN_ID %02x %02x)\n",
1528 man_id >> 8, man_id & 0xFF);
1532 lp->hw->flags = IEEE802154_HW_TX_OMIT_CKSUM |
1533 IEEE802154_HW_CSMA_PARAMS |
1534 IEEE802154_HW_FRAME_RETRIES | IEEE802154_HW_AFILT |
1535 IEEE802154_HW_PROMISCUOUS;
1537 lp->hw->phy->flags = WPAN_PHY_FLAG_TXPOWER |
1538 WPAN_PHY_FLAG_CCA_ED_LEVEL |
1539 WPAN_PHY_FLAG_CCA_MODE;
1541 lp->hw->phy->supported.cca_modes = BIT(NL802154_CCA_ENERGY) |
1542 BIT(NL802154_CCA_CARRIER) | BIT(NL802154_CCA_ENERGY_CARRIER);
1543 lp->hw->phy->supported.cca_opts = BIT(NL802154_CCA_OPT_ENERGY_CARRIER_AND) |
1544 BIT(NL802154_CCA_OPT_ENERGY_CARRIER_OR);
1546 lp->hw->phy->supported.cca_ed_levels = at86rf23x_ed_levels;
1547 lp->hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(at86rf23x_ed_levels);
1549 lp->hw->phy->cca.mode = NL802154_CCA_ENERGY;
1558 lp->data = &at86rf231_data;
1559 lp->hw->phy->supported.channels[0] = 0x7FFF800;
1560 lp->hw->phy->current_channel = 11;
1561 lp->hw->phy->symbol_duration = 16;
1562 lp->hw->phy->supported.tx_powers = at86rf231_powers;
1563 lp->hw->phy->supported.tx_powers_size = ARRAY_SIZE(at86rf231_powers);
1567 lp->data = &at86rf212_data;
1568 lp->hw->flags |= IEEE802154_HW_LBT;
1569 lp->hw->phy->supported.channels[0] = 0x00007FF;
1570 lp->hw->phy->supported.channels[2] = 0x00007FF;
1571 lp->hw->phy->current_channel = 5;
1572 lp->hw->phy->symbol_duration = 25;
1573 lp->hw->phy->supported.lbt = NL802154_SUPPORTED_BOOL_BOTH;
1574 lp->hw->phy->supported.tx_powers = at86rf212_powers;
1575 lp->hw->phy->supported.tx_powers_size = ARRAY_SIZE(at86rf212_powers);
1576 lp->hw->phy->supported.cca_ed_levels = at86rf212_ed_levels_100;
1577 lp->hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(at86rf212_ed_levels_100);
1581 lp->data = &at86rf233_data;
1582 lp->hw->phy->supported.channels[0] = 0x7FFF800;
1583 lp->hw->phy->current_channel = 13;
1584 lp->hw->phy->symbol_duration = 16;
1585 lp->hw->phy->supported.tx_powers = at86rf233_powers;
1586 lp->hw->phy->supported.tx_powers_size = ARRAY_SIZE(at86rf233_powers);
1594 lp->hw->phy->cca_ed_level = lp->hw->phy->supported.cca_ed_levels[7];
1595 lp->hw->phy->transmit_power = lp->hw->phy->supported.tx_powers[0];
1598 dev_info(&lp->spi->dev, "Detected %s chip version %d\n", chip, version);
1603 #ifdef CONFIG_IEEE802154_AT86RF230_DEBUGFS
1604 static struct dentry *at86rf230_debugfs_root;
1606 static int at86rf230_stats_show(struct seq_file *file, void *offset)
1608 struct at86rf230_local *lp = file->private;
1610 seq_printf(file, "SUCCESS:\t\t%8llu\n", lp->trac.success);
1611 seq_printf(file, "SUCCESS_DATA_PENDING:\t%8llu\n",
1612 lp->trac.success_data_pending);
1613 seq_printf(file, "SUCCESS_WAIT_FOR_ACK:\t%8llu\n",
1614 lp->trac.success_wait_for_ack);
1615 seq_printf(file, "CHANNEL_ACCESS_FAILURE:\t%8llu\n",
1616 lp->trac.channel_access_failure);
1617 seq_printf(file, "NO_ACK:\t\t\t%8llu\n", lp->trac.no_ack);
1618 seq_printf(file, "INVALID:\t\t%8llu\n", lp->trac.invalid);
1622 static int at86rf230_stats_open(struct inode *inode, struct file *file)
1624 return single_open(file, at86rf230_stats_show, inode->i_private);
1627 static const struct file_operations at86rf230_stats_fops = {
1628 .open = at86rf230_stats_open,
1630 .llseek = seq_lseek,
1631 .release = single_release,
1634 static int at86rf230_debugfs_init(struct at86rf230_local *lp)
1636 char debugfs_dir_name[DNAME_INLINE_LEN + 1] = "at86rf230-";
1637 struct dentry *stats;
1639 strncat(debugfs_dir_name, dev_name(&lp->spi->dev), DNAME_INLINE_LEN);
1641 at86rf230_debugfs_root = debugfs_create_dir(debugfs_dir_name, NULL);
1642 if (!at86rf230_debugfs_root)
1645 stats = debugfs_create_file("trac_stats", S_IRUGO,
1646 at86rf230_debugfs_root, lp,
1647 &at86rf230_stats_fops);
1654 static void at86rf230_debugfs_remove(void)
1656 debugfs_remove_recursive(at86rf230_debugfs_root);
1659 static int at86rf230_debugfs_init(struct at86rf230_local *lp) { return 0; }
1660 static void at86rf230_debugfs_remove(void) { }
1663 static int at86rf230_probe(struct spi_device *spi)
1665 struct ieee802154_hw *hw;
1666 struct at86rf230_local *lp;
1667 unsigned int status;
1668 int rc, irq_type, rstn, slp_tr;
1672 dev_err(&spi->dev, "no IRQ specified\n");
1676 rc = at86rf230_get_pdata(spi, &rstn, &slp_tr, &xtal_trim);
1678 dev_err(&spi->dev, "failed to parse platform_data: %d\n", rc);
1682 if (gpio_is_valid(rstn)) {
1683 rc = devm_gpio_request_one(&spi->dev, rstn,
1684 GPIOF_OUT_INIT_HIGH, "rstn");
1689 if (gpio_is_valid(slp_tr)) {
1690 rc = devm_gpio_request_one(&spi->dev, slp_tr,
1691 GPIOF_OUT_INIT_LOW, "slp_tr");
1697 if (gpio_is_valid(rstn)) {
1699 gpio_set_value(rstn, 0);
1701 gpio_set_value(rstn, 1);
1702 usleep_range(120, 240);
1705 hw = ieee802154_alloc_hw(sizeof(*lp), &at86rf230_ops);
1712 lp->slp_tr = slp_tr;
1713 hw->parent = &spi->dev;
1714 ieee802154_random_extended_addr(&hw->phy->perm_extended_addr);
1716 lp->regmap = devm_regmap_init_spi(spi, &at86rf230_regmap_spi_config);
1717 if (IS_ERR(lp->regmap)) {
1718 rc = PTR_ERR(lp->regmap);
1719 dev_err(&spi->dev, "Failed to allocate register map: %d\n",
1724 at86rf230_setup_spi_messages(lp, &lp->state);
1725 at86rf230_setup_spi_messages(lp, &lp->tx);
1727 rc = at86rf230_detect_device(lp);
1731 init_completion(&lp->state_complete);
1733 spi_set_drvdata(spi, lp);
1735 rc = at86rf230_hw_init(lp, xtal_trim);
1739 /* Read irq status register to reset irq line */
1740 rc = at86rf230_read_subreg(lp, RG_IRQ_STATUS, 0xff, 0, &status);
1744 irq_type = irq_get_trigger_type(spi->irq);
1746 irq_type = IRQF_TRIGGER_HIGH;
1748 rc = devm_request_irq(&spi->dev, spi->irq, at86rf230_isr,
1749 IRQF_SHARED | irq_type, dev_name(&spi->dev), lp);
1753 /* disable_irq by default and wait for starting hardware */
1754 disable_irq(spi->irq);
1756 /* going into sleep by default */
1757 at86rf230_sleep(lp);
1759 rc = at86rf230_debugfs_init(lp);
1763 rc = ieee802154_register_hw(lp->hw);
1770 at86rf230_debugfs_remove();
1772 ieee802154_free_hw(lp->hw);
1777 static int at86rf230_remove(struct spi_device *spi)
1779 struct at86rf230_local *lp = spi_get_drvdata(spi);
1781 /* mask all at86rf230 irq's */
1782 at86rf230_write_subreg(lp, SR_IRQ_MASK, 0);
1783 ieee802154_unregister_hw(lp->hw);
1784 ieee802154_free_hw(lp->hw);
1785 at86rf230_debugfs_remove();
1786 dev_dbg(&spi->dev, "unregistered at86rf230\n");
1791 static const struct of_device_id at86rf230_of_match[] = {
1792 { .compatible = "atmel,at86rf230", },
1793 { .compatible = "atmel,at86rf231", },
1794 { .compatible = "atmel,at86rf233", },
1795 { .compatible = "atmel,at86rf212", },
1798 MODULE_DEVICE_TABLE(of, at86rf230_of_match);
1800 static const struct spi_device_id at86rf230_device_id[] = {
1801 { .name = "at86rf230", },
1802 { .name = "at86rf231", },
1803 { .name = "at86rf233", },
1804 { .name = "at86rf212", },
1807 MODULE_DEVICE_TABLE(spi, at86rf230_device_id);
1809 static struct spi_driver at86rf230_driver = {
1810 .id_table = at86rf230_device_id,
1812 .of_match_table = of_match_ptr(at86rf230_of_match),
1813 .name = "at86rf230",
1815 .probe = at86rf230_probe,
1816 .remove = at86rf230_remove,
1819 module_spi_driver(at86rf230_driver);
1821 MODULE_DESCRIPTION("AT86RF230 Transceiver Driver");
1822 MODULE_LICENSE("GPL v2");