From: Alexander Aring <alex.aring@gmail.com>
To: linux-wpan@vger.kernel.org
Cc: kernel@pengutronix.de, Alexander Aring <alex.aring@gmail.com>
Subject: [PATCH bluetooth-next 4/4] at86rf230: add support for sleep state
Date: Sat, 13 Jun 2015 22:15:54 +0200 [thread overview]
Message-ID: <1434226554-1450-4-git-send-email-alex.aring@gmail.com> (raw)
In-Reply-To: <1434226554-1450-1-git-send-email-alex.aring@gmail.com>
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>
---
drivers/net/ieee802154/at86rf230.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 25e1ede..6b31f47 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -47,6 +47,8 @@ struct at86rf2xx_chip_data {
u16 t_reset_to_off;
u16 t_off_to_aack;
u16 t_off_to_tx_on;
+ u16 t_off_to_sleep;
+ u16 t_sleep_to_off;
u16 t_frame;
u16 t_p_ack;
int rssi_base_val;
@@ -869,13 +871,33 @@ at86rf230_ed(struct ieee802154_hw *hw, u8 *level)
static int
at86rf230_start(struct ieee802154_hw *hw)
{
+ struct at86rf230_local *lp = hw->priv;
+
+ if (gpio_is_valid(lp->slp_tr)) {
+ gpio_set_value(lp->slp_tr, 0);
+ usleep_range(lp->data->t_sleep_to_off,
+ lp->data->t_sleep_to_off + 100);
+ }
+
+ enable_irq(lp->spi->irq);
+
return at86rf230_sync_state_change(hw->priv, STATE_RX_AACK_ON);
}
static void
at86rf230_stop(struct ieee802154_hw *hw)
{
+ struct at86rf230_local *lp = hw->priv;
+
at86rf230_sync_state_change(hw->priv, STATE_FORCE_TRX_OFF);
+
+ disable_irq(lp->spi->irq);
+
+ if (gpio_is_valid(lp->slp_tr)) {
+ gpio_set_value(lp->slp_tr, 1);
+ usleep_range(lp->data->t_off_to_sleep,
+ lp->data->t_off_to_sleep + 10);
+ }
}
static int
@@ -1241,6 +1263,8 @@ static struct at86rf2xx_chip_data at86rf233_data = {
.t_reset_to_off = 26,
.t_off_to_aack = 80,
.t_off_to_tx_on = 80,
+ .t_off_to_sleep = 35,
+ .t_sleep_to_off = 210,
.t_frame = 4096,
.t_p_ack = 545,
.rssi_base_val = -91,
@@ -1254,6 +1278,8 @@ static struct at86rf2xx_chip_data at86rf231_data = {
.t_reset_to_off = 37,
.t_off_to_aack = 110,
.t_off_to_tx_on = 110,
+ .t_off_to_sleep = 35,
+ .t_sleep_to_off = 380,
.t_frame = 4096,
.t_p_ack = 545,
.rssi_base_val = -91,
@@ -1267,6 +1293,8 @@ static struct at86rf2xx_chip_data at86rf212_data = {
.t_reset_to_off = 26,
.t_off_to_aack = 200,
.t_off_to_tx_on = 200,
+ .t_off_to_sleep = 35,
+ .t_sleep_to_off = 380,
.t_frame = 4096,
.t_p_ack = 545,
.rssi_base_val = -100,
@@ -1640,6 +1668,16 @@ static int at86rf230_probe(struct spi_device *spi)
if (rc)
goto free_dev;
+ /* disable_irq by default and wait for starting hardware */
+ disable_irq(spi->irq);
+
+ /* going into sleep by default */
+ if (gpio_is_valid(slp_tr)) {
+ gpio_set_value(slp_tr, 1);
+ usleep_range(lp->data->t_off_to_sleep,
+ lp->data->t_off_to_sleep + 10);
+ }
+
rc = ieee802154_register_hw(lp->hw);
if (rc)
goto free_dev;
--
2.4.1
next prev parent reply other threads:[~2015-06-13 20:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-13 20:15 [PATCH bluetooth-next 1/4] mac802154: iface: fix hrtimer cancel on ifdown Alexander Aring
2015-06-13 20:15 ` [PATCH bluetooth-next 2/4] mac802154: iface: flush workqueue before stop Alexander Aring
2015-06-14 23:24 ` Marcel Holtmann
2015-06-13 20:15 ` [PATCH bluetooth-next 3/4] at86rf230: use level high as fallback default Alexander Aring
2015-06-14 23:24 ` Marcel Holtmann
2015-06-13 20:15 ` Alexander Aring [this message]
2015-06-14 23:24 ` [PATCH bluetooth-next 4/4] at86rf230: add support for sleep state Marcel Holtmann
2015-06-14 23:24 ` [PATCH bluetooth-next 1/4] mac802154: iface: fix hrtimer cancel on ifdown Marcel Holtmann
2015-06-20 5:19 ` Lennert Buytenhek
2015-06-20 9:10 ` Alexander Aring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1434226554-1450-4-git-send-email-alex.aring@gmail.com \
--to=alex.aring@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-wpan@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox