linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geoffrey Lansberry <geoff@kuvee.com>
To: linux-wireless <linux-wireless@vger.kernel.org>
Cc: Julian Calaby <julian.calaby@gmail.com>,
	Lauro Ramos Venancio <lauro.venancio@openbossa.org>,
	Aloisio Almeida Jr <aloisio.almeida@openbossa.org>,
	Samuel Ortiz <sameo@linux.intel.com>,
	mgreer@animalcreek.com, Justin Bronder <justin@kuvee.com>
Subject: Re: [PATCH 1/4] NFC: trf7970a: Add support for gpio as SS
Date: Tue, 19 Apr 2016 21:24:04 -0400	[thread overview]
Message-ID: <5716DA34.3070201@kuvee.com> (raw)
In-Reply-To: <CAO7Z3WJofeT4agChaZ-NQ5TwrMygdGRhG7myJkNuEb9i_g-Y=A@mail.gmail.com>

As Julian suggests, this is handled by the cs-gpios property, so we will 
drop this patch, but keep the other three active.

Thanks for the suggestion.
>
> On Mon, Apr 18, 2016 at 8:07 PM, Julian Calaby 
> <julian.calaby@gmail.com <mailto:julian.calaby@gmail.com>> wrote:
>
>     Hi Geoff,
>
>     On Tue, Apr 19, 2016 at 5:48 AM, Geoff Lansberry <geoff@kuvee.com
>     <mailto:geoff@kuvee.com>> wrote:
>     > Signed-off-by: Geoff Lansberry <geoff@kuvee.com
>     <mailto:geoff@kuvee.com>>
>
>     Can't you just use the cs-gpios property? This should require no
>     driver changes.
>
>     This is described here:
>
>     https://www.kernel.org/doc/Documentation/devicetree/bindings/spi/spi-bus.txt
>
>     Thanks,
>
>     Julian Calaby
>
>
>     > ---
>     >  .../devicetree/bindings/net/nfc/trf7970a.txt  |  2 ++
>     >  drivers/nfc/trf7970a.c  | 33 ++++++++++++++++++++--
>     >  2 files changed, 33 insertions(+), 2 deletions(-)
>     >
>     > diff --git
>     a/Documentation/devicetree/bindings/net/nfc/trf7970a.txt
>     b/Documentation/devicetree/bindings/net/nfc/trf7970a.txt
>     > index 32b35a0..09c5056 100644
>     > --- a/Documentation/devicetree/bindings/net/nfc/trf7970a.txt
>     > +++ b/Documentation/devicetree/bindings/net/nfc/trf7970a.txt
>     > @@ -7,6 +7,7 @@ Required properties:
>     >  - interrupts: A single interrupt specifier.
>     >  - ti,enable-gpios: Two GPIO entries used for 'EN' and 'EN2'
>     pins on the
>     >    TRF7970A.
>     > +- ti,ss-gpio: GPIO entry used for active low SS (spi slave
>     select) on the TRF7970A
>     >  - vin-supply: Regulator for supply voltage to VIN pin
>     >
>     >  Optional SoC Specific Properties:
>     > @@ -37,6 +38,7 @@ Example (for ARM-based BeagleBone with
>     TRF7970A on SPI1):
>     >                 interrupts = <14 0>;
>     >                 ti,enable-gpios = <&gpio2 2 GPIO_ACTIVE_LOW>,
>     >                                   <&gpio2 5 GPIO_ACTIVE_LOW>;
>     > +               ti,ss-gpio = <&gpio2 4 GPIO_ACTIVE_HIGH>;
>     >                 vin-supply = <&ldo3_reg>;
>     >                 vin-voltage-override = <5000000>;
>     >                 autosuspend-delay = <30000>;
>     > diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c
>     > index 10842b7..2c3530a 100644
>     > --- a/drivers/nfc/trf7970a.c
>     > +++ b/drivers/nfc/trf7970a.c
>     > @@ -450,6 +450,7 @@ struct trf7970a {
>     >         bool adjust_resp_len;
>     >         int                             en2_gpio;
>     >         int                             en_gpio;
>     > +       int                             ss_gpio;
>     >         struct mutex                    lock;
>     >         unsigned int                    timeout;
>     >         bool ignore_timeout;
>     > @@ -462,9 +463,11 @@ static int trf7970a_cmd(struct trf7970a
>     *trf, u8 opcode)
>     >         u8 cmd = TRF7970A_CMD_BIT_CTRL |
>     TRF7970A_CMD_BIT_OPCODE(opcode);
>     >         int ret;
>     >
>     > +       gpio_set_value(trf->ss_gpio, 0);
>     >         dev_dbg(trf->dev, "cmd: 0x%x\n", cmd);
>     >
>     >         ret = spi_write(trf->spi, &cmd, 1);
>     > +       gpio_set_value(trf->ss_gpio, 1);
>     >         if (ret)
>     >                 dev_err(trf->dev, "%s - cmd: 0x%x, ret: %d\n",
>     __func__, cmd,
>     >                                 ret);
>     > @@ -476,7 +479,9 @@ static int trf7970a_read(struct trf7970a
>     *trf, u8 reg, u8 *val)
>     >         u8 addr = TRF7970A_CMD_BIT_RW | reg;
>     >         int ret;
>     >
>     > +       gpio_set_value(trf->ss_gpio, 0);
>     >         ret = spi_write_then_read(trf->spi, &addr, 1, val, 1);
>     > +       gpio_set_value(trf->ss_gpio, 1);
>     >         if (ret)
>     >                 dev_err(trf->dev, "%s - addr: 0x%x, ret: %d\n",
>     __func__, addr,
>     >                                 ret);
>     > @@ -493,6 +498,7 @@ static int trf7970a_read_cont(struct
>     trf7970a *trf, u8 reg, u8 *buf, size_t len)
>     >         struct spi_message m;
>     >         int ret;
>     >
>     > +       gpio_set_value(trf->ss_gpio, 0);
>     >         dev_dbg(trf->dev, "read_cont(0x%x, %zd)\n", addr, len);
>     >
>     >         spi_message_init(&m);
>     > @@ -508,6 +514,7 @@ static int trf7970a_read_cont(struct
>     trf7970a *trf, u8 reg, u8 *buf, size_t len)
>     >         spi_message_add_tail(&t[1], &m);
>     >
>     >         ret = spi_sync(trf->spi, &m);
>     > +       gpio_set_value(trf->ss_gpio, 1);
>     >         if (ret)
>     >                 dev_err(trf->dev, "%s - addr: 0x%x, ret: %d\n",
>     __func__, addr,
>     >                                 ret);
>     > @@ -519,9 +526,11 @@ static int trf7970a_write(struct trf7970a
>     *trf, u8 reg, u8 val)
>     >         u8 buf[2] = { reg, val };
>     >         int ret;
>     >
>     > +       gpio_set_value(trf->ss_gpio, 0);
>     >         dev_dbg(trf->dev, "write(0x%x): 0x%x\n", reg, val);
>     >
>     >         ret = spi_write(trf->spi, buf, 2);
>     > +       gpio_set_value(trf->ss_gpio, 1);
>     >         if (ret)
>     >                 dev_err(trf->dev, "%s - write: 0x%x 0x%x, ret:
>     %d\n", __func__,
>     >                                 buf[0], buf[1], ret);
>     > @@ -535,6 +544,7 @@ static int trf7970a_read_irqstatus(struct
>     trf7970a *trf, u8 *status)
>     >         u8 buf[2];
>     >         u8 addr;
>     >
>     > +       gpio_set_value(trf->ss_gpio, 0);
>     >         addr = TRF7970A_IRQ_STATUS | TRF7970A_CMD_BIT_RW;
>     >
>     >         if (trf->quirks & TRF7970A_QUIRK_IRQ_STATUS_READ) {
>     > @@ -544,6 +554,7 @@ static int trf7970a_read_irqstatus(struct
>     trf7970a *trf, u8 *status)
>     >                 ret = spi_write_then_read(trf->spi, &addr, 1,
>     buf, 1);
>     >         }
>     >
>     > +       gpio_set_value(trf->ss_gpio, 1);
>     >         if (ret)
>     >                 dev_err(trf->dev, "%s - irqstatus: Status read
>     failed: %d\n",
>     >                                 __func__, ret);
>     > @@ -559,6 +570,7 @@ static int trf7970a_read_target_proto(struct
>     trf7970a *trf, u8 *target_proto)
>     >         u8 buf[2];
>     >         u8 addr;
>     >
>     > +       gpio_set_value(trf->ss_gpio, 0);
>     >         addr = TRF79070A_NFC_TARGET_PROTOCOL | TRF7970A_CMD_BIT_RW |
>     >                 TRF7970A_CMD_BIT_CONTINUOUS;
>     >
>     > @@ -569,6 +581,7 @@ static int trf7970a_read_target_proto(struct
>     trf7970a *trf, u8 *target_proto)
>     >         else
>     >                 *target_proto = buf[0];
>     >
>     > +       gpio_set_value(trf->ss_gpio, 1);
>     >         return ret;
>     >  }
>     >
>     > @@ -663,6 +676,7 @@ static int trf7970a_transmit(struct trf7970a
>     *trf, struct sk_buff *skb,
>     >         print_hex_dump_debug("trf7970a tx data: ", DUMP_PREFIX_NONE,
>     >                         16, 1, skb->data, len, false);
>     >
>     > +       gpio_set_value(trf->ss_gpio, 0);
>     >         spi_message_init(&m);
>     >
>     >         memset(&t, 0, sizeof(t));
>     > @@ -679,7 +693,7 @@ static int trf7970a_transmit(struct trf7970a
>     *trf, struct sk_buff *skb,
>     >         if (ret) {
>     >                 dev_err(trf->dev, "%s - Can't send tx data:
>     %d\n", __func__,
>     >                                 ret);
>     > -               return ret;
>     > +               goto out_err;
>     >         }
>     >
>     >         skb_pull(skb, len);
>     > @@ -706,7 +720,9 @@ static int trf7970a_transmit(struct trf7970a
>     *trf, struct sk_buff *skb,
>     >
>     >  schedule_delayed_work(&trf->timeout_work,
>     msecs_to_jiffies(timeout));
>     >
>     > -       return 0;
>     > +out_err:
>     > +       gpio_set_value(trf->ss_gpio, 1);
>     > +       return ret;
>     >  }
>     >
>     >  static void trf7970a_fill_fifo(struct trf7970a *trf)
>     > @@ -2039,6 +2055,19 @@ static int trf7970a_probe(struct
>     spi_device *spi)
>     >                 return ret;
>     >         }
>     >
>     > +       trf->ss_gpio = of_get_named_gpio(np, "ti,ss-gpio", 0);
>     > +       if (!gpio_is_valid(trf->ss_gpio)) {
>     > +               dev_err(trf->dev, "No SS GPIO property\n");
>     > +               return trf->ss_gpio;
>     > +       }
>     > +
>     > +       ret = devm_gpio_request_one(trf->dev, trf->ss_gpio,
>     > +                       GPIOF_DIR_OUT | GPIOF_INIT_HIGH,
>     "trf7970a SS");
>     > +       if (ret) {
>     > +               dev_err(trf->dev, "Can't request SS GPIO: %d\n",
>     ret);
>     > +               return ret;
>     > +       }
>     > +
>     >         if (of_property_read_bool(np, "en2-rf-quirk"))
>     >                 trf->quirks |= TRF7970A_QUIRK_EN2_MUST_STAY_LOW;
>     >
>     > --
>     > 1.9.1
>     >
>     > --
>     > To unsubscribe from this list: send the line "unsubscribe
>     linux-wireless" in
>     > the body of a message to majordomo@vger.kernel.org
>     <mailto:majordomo@vger.kernel.org>
>     > More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
>
>     --
>     Julian Calaby
>
>     Email: julian.calaby@gmail.com <mailto:julian.calaby@gmail.com>
>     Profile: http://www.google.com/profiles/julian.calaby/
>
>
>
>
> -- 
> Geoff Lansberry
>
>
> Engineering Guy
> Kuvée, Inc
> 125 Kingston St., 3rd Floor
> Boston, MA 02111
> 1-617-290-1118 (m)
> geoff.lansberry (skype)
> http://www.kuvee.com
> <http://www.kuvee.com>
>


  parent reply	other threads:[~2016-04-20  1:24 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-18 19:48 [Patch] NFC: trf7970a: Geoff Lansberry
2016-04-18 19:48 ` [PATCH 1/4] NFC: trf7970a: Add support for gpio as SS Geoff Lansberry
2016-04-19  0:07   ` Julian Calaby
     [not found]     ` <CAO7Z3WJofeT4agChaZ-NQ5TwrMygdGRhG7myJkNuEb9i_g-Y=A@mail.gmail.com>
2016-04-20  1:24       ` Geoffrey Lansberry [this message]
2016-04-18 19:48 ` [PATCH 2/4] NFC: trf7970a: add TI recommended write of zero to Register 0x18 Geoff Lansberry
2016-04-18 19:48 ` [PATCH 3/4] NFC: trf7970a: add device tree option for 27MHz clock Geoff Lansberry
2016-04-19  0:11   ` Julian Calaby
2016-04-18 19:48 ` [PATCH 4/4] NFC: trf7970a: Add device tree option of 1.8 Volt IO voltage Geoff Lansberry
2016-04-19  0:12   ` Julian Calaby
2016-04-22  0:01 ` [Patch] NFC: trf7970a: Mark Greer
2016-12-13 22:05   ` Mark Greer
     [not found]     ` <CAO7Z3WJwf80mCqubSYTeK=BHN9sd=mzmL9th4Su-E25de6TmAg@mail.gmail.com>
2016-12-14 15:57       ` Mark Greer
2016-12-14 16:17         ` Geoff Lansberry
2016-12-14 17:10           ` Mark Greer
2016-12-14 18:35             ` Geoff Lansberry
2016-12-14 22:31               ` Mark Greer
2016-12-16  4:52                 ` Mark Greer
2016-12-16 20:35                   ` Mark Greer
2016-12-17 21:19                     ` Geoff Lansberry
2016-12-19  3:07                       ` Mark Greer
2017-02-08 22:53                         ` Mark Greer
2017-02-08 22:56                           ` Mark Greer
2017-02-09 15:54                             ` Geoff Lansberry
2017-02-09 21:27                               ` Mark Greer
2017-02-10  0:41                                 ` Geoff Lansberry
2017-02-10  4:20                                   ` Mark Greer

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=5716DA34.3070201@kuvee.com \
    --to=geoff@kuvee.com \
    --cc=aloisio.almeida@openbossa.org \
    --cc=julian.calaby@gmail.com \
    --cc=justin@kuvee.com \
    --cc=lauro.venancio@openbossa.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=mgreer@animalcreek.com \
    --cc=sameo@linux.intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).