linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] NFC: nxp-nci: Make firmware GPIO pin optional
@ 2020-11-30 11:04 Schrempf Frieder
  2020-11-30 11:44 ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Schrempf Frieder @ 2020-11-30 11:04 UTC (permalink / raw)
  To: Charles Gorand, Clément Perrochaud, Frieder Schrempf
  Cc: Andy Shevchenko, David S. Miller, devicetree, linux-kernel,
	linux-nfc, netdev, Stephan Gerhold

From: Frieder Schrempf <frieder.schrempf@kontron.de>

There are other NXP NCI compatible NFC controllers such as the PN7150
that use an integrated firmware and therefore do not have a GPIO to
select firmware downloading mode. To support these kind of chips,
let's make the firmware GPIO optional.

Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
 Documentation/devicetree/bindings/net/nfc/nxp-nci.txt | 2 +-
 drivers/nfc/nxp-nci/i2c.c                             | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/nfc/nxp-nci.txt b/Documentation/devicetree/bindings/net/nfc/nxp-nci.txt
index cfaf88998918..cb2385c277d0 100644
--- a/Documentation/devicetree/bindings/net/nfc/nxp-nci.txt
+++ b/Documentation/devicetree/bindings/net/nfc/nxp-nci.txt
@@ -6,11 +6,11 @@ Required properties:
 - reg: address on the bus
 - interrupts: GPIO interrupt to which the chip is connected
 - enable-gpios: Output GPIO pin used for enabling/disabling the chip
-- firmware-gpios: Output GPIO pin used to enter firmware download mode
 
 Optional SoC Specific Properties:
 - pinctrl-names: Contains only one value - "default".
 - pintctrl-0: Specifies the pin control groups used for this controller.
+- firmware-gpios: Output GPIO pin used to enter firmware download mode
 
 Example (for ARM-based BeagleBone with NPC100 NFC controller on I2C2):
 
diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c
index 9f60e4dc5a90..528893686e18 100644
--- a/drivers/nfc/nxp-nci/i2c.c
+++ b/drivers/nfc/nxp-nci/i2c.c
@@ -47,7 +47,8 @@ static int nxp_nci_i2c_set_mode(void *phy_id,
 {
 	struct nxp_nci_i2c_phy *phy = (struct nxp_nci_i2c_phy *) phy_id;
 
-	gpiod_set_value(phy->gpiod_fw, (mode == NXP_NCI_MODE_FW) ? 1 : 0);
+	if (phy->gpiod_fw)
+		gpiod_set_value(phy->gpiod_fw, (mode == NXP_NCI_MODE_FW) ? 1 : 0);
 	gpiod_set_value(phy->gpiod_en, (mode != NXP_NCI_MODE_COLD) ? 1 : 0);
 	usleep_range(10000, 15000);
 
@@ -286,7 +287,7 @@ static int nxp_nci_i2c_probe(struct i2c_client *client,
 		return PTR_ERR(phy->gpiod_en);
 	}
 
-	phy->gpiod_fw = devm_gpiod_get(dev, "firmware", GPIOD_OUT_LOW);
+	phy->gpiod_fw = devm_gpiod_get_optional(dev, "firmware", GPIOD_OUT_LOW);
 	if (IS_ERR(phy->gpiod_fw)) {
 		nfc_err(dev, "Failed to get FW gpio\n");
 		return PTR_ERR(phy->gpiod_fw);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] NFC: nxp-nci: Make firmware GPIO pin optional
  2020-11-30 11:04 [PATCH] NFC: nxp-nci: Make firmware GPIO pin optional Schrempf Frieder
@ 2020-11-30 11:44 ` Andy Shevchenko
  2020-11-30 11:49   ` Frieder Schrempf
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2020-11-30 11:44 UTC (permalink / raw)
  To: Schrempf Frieder
  Cc: Charles Gorand, Clément Perrochaud, David S. Miller,
	devicetree, Linux Kernel Mailing List, linux-nfc, netdev,
	Stephan Gerhold

On Mon, Nov 30, 2020 at 1:06 PM Schrempf Frieder
<frieder.schrempf@kontron.de> wrote:
>
> From: Frieder Schrempf <frieder.schrempf@kontron.de>
>
> There are other NXP NCI compatible NFC controllers such as the PN7150
> that use an integrated firmware and therefore do not have a GPIO to
> select firmware downloading mode. To support these kind of chips,
> let's make the firmware GPIO optional.

...

> -       gpiod_set_value(phy->gpiod_fw, (mode == NXP_NCI_MODE_FW) ? 1 : 0);
> +       if (phy->gpiod_fw)
> +               gpiod_set_value(phy->gpiod_fw, (mode == NXP_NCI_MODE_FW) ? 1 : 0);

This change is not needed.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] NFC: nxp-nci: Make firmware GPIO pin optional
  2020-11-30 11:44 ` Andy Shevchenko
@ 2020-11-30 11:49   ` Frieder Schrempf
  0 siblings, 0 replies; 3+ messages in thread
From: Frieder Schrempf @ 2020-11-30 11:49 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Charles Gorand, Clément Perrochaud, David S. Miller,
	devicetree, Linux Kernel Mailing List, linux-nfc, netdev,
	Stephan Gerhold

On 30.11.20 12:44, Andy Shevchenko wrote:
> On Mon, Nov 30, 2020 at 1:06 PM Schrempf Frieder
> <frieder.schrempf@kontron.de> wrote:
>>
>> From: Frieder Schrempf <frieder.schrempf@kontron.de>
>>
>> There are other NXP NCI compatible NFC controllers such as the PN7150
>> that use an integrated firmware and therefore do not have a GPIO to
>> select firmware downloading mode. To support these kind of chips,
>> let's make the firmware GPIO optional.
> 
> ...
> 
>> -       gpiod_set_value(phy->gpiod_fw, (mode == NXP_NCI_MODE_FW) ? 1 : 0);
>> +       if (phy->gpiod_fw)
>> +               gpiod_set_value(phy->gpiod_fw, (mode == NXP_NCI_MODE_FW) ? 1 : 0);
> 
> This change is not needed.

Indeed, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-30 11:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-30 11:04 [PATCH] NFC: nxp-nci: Make firmware GPIO pin optional Schrempf Frieder
2020-11-30 11:44 ` Andy Shevchenko
2020-11-30 11:49   ` Frieder Schrempf

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).