diff mbox

[3/8] NFC: NCI: Adds NCI init and reset API for drivers

Message ID 1424772112-27399-4-git-send-email-robert.dolca@intel.com
State Awaiting Upstream, archived
Delegated to: David Miller
Headers show

Commit Message

Robert Dolca Feb. 24, 2015, 10:01 a.m. UTC
In order to communicate with the device during the setup
phase, the driver may need to initialize the device. After
the setup is done the driver should reset the device to leave
it in the same state that it was before the setup function
call.

Signed-off-by: Robert Dolca <robert.dolca@intel.com>
---
 include/net/nfc/nci_core.h |  2 ++
 net/nfc/nci/core.c         | 14 ++++++++++++++
 2 files changed, 16 insertions(+)

Comments

Samuel Ortiz March 26, 2015, 12:29 a.m. UTC | #1
Hi Robert,

On Tue, Feb 24, 2015 at 12:01:47PM +0200, Robert Dolca wrote:
> In order to communicate with the device during the setup
> phase, the driver may need to initialize the device. After
> the setup is done the driver should reset the device to leave
> it in the same state that it was before the setup function
> call.
I would prefer not to export those symbols, but instead introduce a
quirk bitmap to let the NCI core know that your device expects the core
to be initialized before calling the setup ops.
That would be done from nci_open_device().

Cheers,
Samuel.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Robert Dolca March 31, 2015, 2:05 p.m. UTC | #2
On Thu, Mar 26, 2015 at 2:29 AM, Samuel Ortiz <sameo@linux.intel.com> wrote:
> Hi Robert,
>
> On Tue, Feb 24, 2015 at 12:01:47PM +0200, Robert Dolca wrote:
>> In order to communicate with the device during the setup
>> phase, the driver may need to initialize the device. After
>> the setup is done the driver should reset the device to leave
>> it in the same state that it was before the setup function
>> call.
> I would prefer not to export those symbols, but instead introduce a
> quirk bitmap to let the NCI core know that your device expects the core
> to be initialized before calling the setup ops.
> That would be done from nci_open_device().

As part of the initialization / firmware upgrade procedure the driver
needs to reset and initialize the NCI connection multiple times.
Having the connection initialized before calling setup is not enough.

Regards,
Robert
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Samuel Ortiz May 24, 2015, 5:07 p.m. UTC | #3
Hi Robert,

On Tue, Mar 31, 2015 at 05:05:53PM +0300, Robert Dolca wrote:
> On Thu, Mar 26, 2015 at 2:29 AM, Samuel Ortiz <sameo@linux.intel.com> wrote:
> > Hi Robert,
> >
> > On Tue, Feb 24, 2015 at 12:01:47PM +0200, Robert Dolca wrote:
> >> In order to communicate with the device during the setup
> >> phase, the driver may need to initialize the device. After
> >> the setup is done the driver should reset the device to leave
> >> it in the same state that it was before the setup function
> >> call.
> > I would prefer not to export those symbols, but instead introduce a
> > quirk bitmap to let the NCI core know that your device expects the core
> > to be initialized before calling the setup ops.
> > That would be done from nci_open_device().
> 
> As part of the initialization / firmware upgrade procedure the driver
> needs to reset and initialize the NCI connection multiple times.
> Having the connection initialized before calling setup is not enough.
Fair enough, I am ok with exporting those symbols.

BTW after looking at your setup routine, I think this is wrong:

+	/* Load firmware from disk */
+	r = fdp_nci_request_firmware(ndev);
+	if (r)
+		goto error;

You should be able to boot your NFC chipset without a local
patch. If there is one, then you can try patching your device, but
otherwise we should continue with the exisiting one.

Cheers,
Samuel.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h
index 34a6e09..4358d0a 100644
--- a/include/net/nfc/nci_core.h
+++ b/include/net/nfc/nci_core.h
@@ -314,6 +314,8 @@  static inline void *nci_get_drvdata(struct nci_dev *ndev)
 	return ndev->driver_data;
 }
 
+int nci_init(struct nci_dev *ndev);
+int nci_reset(struct nci_dev *ndev);
 void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb);
 void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb);
 void nci_rx_data_packet(struct nci_dev *ndev, struct sk_buff *skb);
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 9605b9c..317b94b 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -458,6 +458,20 @@  static int nci_dev_down(struct nfc_dev *nfc_dev)
 	return nci_close_device(ndev);
 }
 
+int nci_init(struct nci_dev *ndev)
+{
+	return __nci_request(ndev, nci_init_req, 0,
+			  msecs_to_jiffies(NCI_INIT_TIMEOUT));
+}
+EXPORT_SYMBOL(nci_init);
+
+int nci_reset(struct nci_dev *ndev)
+{
+	return __nci_request(ndev, nci_reset_req, 0,
+			     msecs_to_jiffies(NCI_RESET_TIMEOUT));
+}
+EXPORT_SYMBOL(nci_reset);
+
 int nci_set_config(struct nci_dev *ndev, __u8 id, size_t len, __u8 *val)
 {
 	struct nci_set_config_param param;