summaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorAlexander Aring <alex.aring@gmail.com>2015-06-13 16:15:54 -0400
committerMarcel Holtmann <marcel@holtmann.org>2015-06-14 19:22:19 -0400
commite6f7ed9dc1164c2f20bd984e251cf4dd5ff61d2c (patch)
tree00d3ae4b646d2d54b56746ca975edef28c3e74c5 /drivers/net
parent9ff19e6f44e370d9ac20c2cc677724e44d76f2c6 (diff)
at86rf230: add support for sleep state
This patch adds support for sleep state when between stop and start period. In this period the transceiver isn't used by the subsystem, in this time we disable the irq and going into the sleep state. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ieee802154/at86rf230.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 25e1edecc24b..6b31f4708122 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -47,6 +47,8 @@ struct at86rf2xx_chip_data {
47 u16 t_reset_to_off; 47 u16 t_reset_to_off;
48 u16 t_off_to_aack; 48 u16 t_off_to_aack;
49 u16 t_off_to_tx_on; 49 u16 t_off_to_tx_on;
50 u16 t_off_to_sleep;
51 u16 t_sleep_to_off;
50 u16 t_frame; 52 u16 t_frame;
51 u16 t_p_ack; 53 u16 t_p_ack;
52 int rssi_base_val; 54 int rssi_base_val;
@@ -869,13 +871,33 @@ at86rf230_ed(struct ieee802154_hw *hw, u8 *level)
869static int 871static int
870at86rf230_start(struct ieee802154_hw *hw) 872at86rf230_start(struct ieee802154_hw *hw)
871{ 873{
874 struct at86rf230_local *lp = hw->priv;
875
876 if (gpio_is_valid(lp->slp_tr)) {
877 gpio_set_value(lp->slp_tr, 0);
878 usleep_range(lp->data->t_sleep_to_off,
879 lp->data->t_sleep_to_off + 100);
880 }
881
882 enable_irq(lp->spi->irq);
883
872 return at86rf230_sync_state_change(hw->priv, STATE_RX_AACK_ON); 884 return at86rf230_sync_state_change(hw->priv, STATE_RX_AACK_ON);
873} 885}
874 886
875static void 887static void
876at86rf230_stop(struct ieee802154_hw *hw) 888at86rf230_stop(struct ieee802154_hw *hw)
877{ 889{
890 struct at86rf230_local *lp = hw->priv;
891
878 at86rf230_sync_state_change(hw->priv, STATE_FORCE_TRX_OFF); 892 at86rf230_sync_state_change(hw->priv, STATE_FORCE_TRX_OFF);
893
894 disable_irq(lp->spi->irq);
895
896 if (gpio_is_valid(lp->slp_tr)) {
897 gpio_set_value(lp->slp_tr, 1);
898 usleep_range(lp->data->t_off_to_sleep,
899 lp->data->t_off_to_sleep + 10);
900 }
879} 901}
880 902
881static int 903static int
@@ -1241,6 +1263,8 @@ static struct at86rf2xx_chip_data at86rf233_data = {
1241 .t_reset_to_off = 26, 1263 .t_reset_to_off = 26,
1242 .t_off_to_aack = 80, 1264 .t_off_to_aack = 80,
1243 .t_off_to_tx_on = 80, 1265 .t_off_to_tx_on = 80,
1266 .t_off_to_sleep = 35,
1267 .t_sleep_to_off = 210,
1244 .t_frame = 4096, 1268 .t_frame = 4096,
1245 .t_p_ack = 545, 1269 .t_p_ack = 545,
1246 .rssi_base_val = -91, 1270 .rssi_base_val = -91,
@@ -1254,6 +1278,8 @@ static struct at86rf2xx_chip_data at86rf231_data = {
1254 .t_reset_to_off = 37, 1278 .t_reset_to_off = 37,
1255 .t_off_to_aack = 110, 1279 .t_off_to_aack = 110,
1256 .t_off_to_tx_on = 110, 1280 .t_off_to_tx_on = 110,
1281 .t_off_to_sleep = 35,
1282 .t_sleep_to_off = 380,
1257 .t_frame = 4096, 1283 .t_frame = 4096,
1258 .t_p_ack = 545, 1284 .t_p_ack = 545,
1259 .rssi_base_val = -91, 1285 .rssi_base_val = -91,
@@ -1267,6 +1293,8 @@ static struct at86rf2xx_chip_data at86rf212_data = {
1267 .t_reset_to_off = 26, 1293 .t_reset_to_off = 26,
1268 .t_off_to_aack = 200, 1294 .t_off_to_aack = 200,
1269 .t_off_to_tx_on = 200, 1295 .t_off_to_tx_on = 200,
1296 .t_off_to_sleep = 35,
1297 .t_sleep_to_off = 380,
1270 .t_frame = 4096, 1298 .t_frame = 4096,
1271 .t_p_ack = 545, 1299 .t_p_ack = 545,
1272 .rssi_base_val = -100, 1300 .rssi_base_val = -100,
@@ -1640,6 +1668,16 @@ static int at86rf230_probe(struct spi_device *spi)
1640 if (rc) 1668 if (rc)
1641 goto free_dev; 1669 goto free_dev;
1642 1670
1671 /* disable_irq by default and wait for starting hardware */
1672 disable_irq(spi->irq);
1673
1674 /* going into sleep by default */
1675 if (gpio_is_valid(slp_tr)) {
1676 gpio_set_value(slp_tr, 1);
1677 usleep_range(lp->data->t_off_to_sleep,
1678 lp->data->t_off_to_sleep + 10);
1679 }
1680
1643 rc = ieee802154_register_hw(lp->hw); 1681 rc = ieee802154_register_hw(lp->hw);
1644 if (rc) 1682 if (rc)
1645 goto free_dev; 1683 goto free_dev;