All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Aring <alex.aring@gmail.com>
To: Brad Campbell <bradjc5@gmail.com>
Cc: linux-wpan@vger.kernel.org
Subject: Re: [PATCHv2 2/2] cc2520: Add support for CC2591 amplifier.
Date: Tue, 17 Mar 2015 09:03:04 +0100	[thread overview]
Message-ID: <20150317080301.GA1303@omega> (raw)
In-Reply-To: <1426544203-60585-3-git-send-email-bradjc5@gmail.com>

Hi,

On Mon, Mar 16, 2015 at 06:16:43PM -0400, Brad Campbell wrote:
> The TI CC2521 is an RF power amplifier that is designed to interface
> with the CC2520. Conveniently, it directly interfaces with the CC2520
> and does not require any pins to be connected to a
> microcontroller/processor. Adding a CC2591 increases the CC2520's range,
> which is useful for border router and other wall-powered applications.
> 
> Using the CC2591 with the CC2520 requires configuring the CC2520 GPIOs
> that are connected to the CC2591 to correctly set the CC2591 into TX and
> RX modes. Further, TI recommends that the CC2520_TXPOWER and
> CC2520_AGCCTRL1 registers are set differently to maximize the CC2591's
> performance. These settings are covered in TI Application Note AN065.
> 
> This patch adds an optional `amplified` field to the cc2520 entry in the
> device tree. If present, the CC2520 will be configured to operate with a
> CC2591.
> 
> The expected pin mapping is:
> CC2520 GPIO0 --> CC2591 EN
> CC2520 GPIO5 --> CC2591 PAEN
> 
> Signed-off-by: Brad Campbell <bradjc5@gmail.com>
> ---
>  .../devicetree/bindings/net/ieee802154/cc2520.txt  |  4 ++
>  drivers/net/ieee802154/cc2520.c                    | 55 ++++++++++++++++++----
>  include/linux/spi/cc2520.h                         |  1 +
>  3 files changed, 52 insertions(+), 8 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/net/ieee802154/cc2520.txt b/Documentation/devicetree/bindings/net/ieee802154/cc2520.txt
> index 0071883..fb6d49f 100644
> --- a/Documentation/devicetree/bindings/net/ieee802154/cc2520.txt
> +++ b/Documentation/devicetree/bindings/net/ieee802154/cc2520.txt
> @@ -13,11 +13,15 @@ Required properties:
>  	- cca-gpio:		GPIO spec for the CCA pin
>  	- vreg-gpio:		GPIO spec for the VREG pin
>  	- reset-gpio:		GPIO spec for the RESET pin
> +Optional properties:
> +	- amplified:		include if the CC2520 is connected to a CC2591 amplifier
> +
>  Example:
>  	cc2520@0 {
>  		compatible = "ti,cc2520";
>  		reg = <0>;
>  		spi-max-frequency = <4000000>;
> +		amplified;
>  		pinctrl-names = "default";
>  		pinctrl-0 = <&cc2520_cape_pins>;
>  		fifo-gpio = <&gpio1 18 0>;
> diff --git a/drivers/net/ieee802154/cc2520.c b/drivers/net/ieee802154/cc2520.c
> index 275e6fb..0639af6 100644
> --- a/drivers/net/ieee802154/cc2520.c
> +++ b/drivers/net/ieee802154/cc2520.c
> @@ -736,6 +736,8 @@ static int cc2520_get_platform_data(struct spi_device *spi,
>  	pdata->vreg = of_get_named_gpio(np, "vreg-gpio", 0);
>  	pdata->reset = of_get_named_gpio(np, "reset-gpio", 0);
>  
> +	pdata->amplified = of_property_read_bool(np, "amplified");
> +
>  	return 0;
>  }
>  
> @@ -744,6 +746,11 @@ static int cc2520_hw_init(struct cc2520_private *priv)
>  	u8 status = 0, state = 0xff;
>  	int ret;
>  	int timeout = 100;
> +	struct cc2520_platform_data pdata;
> +
> +	ret = cc2520_get_platform_data(priv->spi, &pdata);
> +	if (ret)
> +		goto err_ret;
>  
>  	ret = cc2520_read_register(priv, CC2520_FSMSTAT1, &state);
>  	if (ret)
> @@ -766,11 +773,47 @@ static int cc2520_hw_init(struct cc2520_private *priv)
>  
>  	dev_vdbg(&priv->spi->dev, "oscillator brought up\n");
>  
> -	/* Registers default value: section 28.1 in Datasheet */
> -	ret = cc2520_write_register(priv, CC2520_TXPOWER, 0xF7);
> -	if (ret)
> -		goto err_ret;
> +	/* If the CC2520 is connected to a CC2591 amplifier, we must both
> +	 * configure GPIOs on the CC2520 to correctly configure the CC2591
> +	 * and change a couple settings of the CC2520 to work with the
> +	 * amplifier. See section 8 page 17 of TI application note AN065.
> +	 * http://www.ti.com/lit/an/swra229a/swra229a.pdf
> +	 */
> +	if (pdata.amplified == 1) {

just if (pdata.amplified) here.

- Alex

      reply	other threads:[~2015-03-17  8:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-16 22:16 [PATCHv2 0/2] cc2520: add support for CC2591 Brad Campbell
2015-03-16 22:16 ` [PATCHv2 1/2] cc2520: Do not store platform_data in spi_device Brad Campbell
2015-03-17  8:06   ` Alexander Aring
2015-03-16 22:16 ` [PATCHv2 2/2] cc2520: Add support for CC2591 amplifier Brad Campbell
2015-03-17  8:03   ` Alexander Aring [this message]

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=20150317080301.GA1303@omega \
    --to=alex.aring@gmail.com \
    --cc=bradjc5@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.