Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsupported nfc device in lenovo T470 #455

Open
Eik-S opened this issue Oct 4, 2017 · 34 comments

Comments

Projects
None yet
@Eik-S
Copy link

commented Oct 4, 2017

Unfortunately, the nfc module of lenovo T470 is not yet supported.

Neither lsusb is showing the device:
Bus 002 Device 002: ID 0bda:0316 Realtek Semiconductor Corp.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 138a:0097 Validity Sensors, Inc.
Bus 001 Device 004: ID 5986:111c Acer, Inc
Bus 001 Device 002: ID 058f:9540 Alcor Micro Corp. AU9540 Smartcard Reader
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Is there any progress on this?
Thanks.

@totakura

This comment has been minimized.

Copy link

commented Oct 26, 2017

I believe the NFC module is connected via I2C bus. Lets see if it is being detected there; can you install i2c-tools and run

i2cdetect -l
@Eik-S

This comment has been minimized.

Copy link
Author

commented Oct 26, 2017

Output is:

i2c-3	unknown   	DPDDC-A                         	N/A
i2c-1	unknown   	i915 gmbus dpb                  	N/A
i2c-6	unknown   	Synopsys DesignWare I2C adapter 	N/A
i2c-4	unknown   	DPDDC-B                         	N/A
i2c-2	unknown   	i915 gmbus dpd                  	N/A
i2c-0	unknown   	i915 gmbus dpc                  	N/A
i2c-5	unknown   	DPDDC-C                         	N/A
@totakura

This comment has been minimized.

Copy link

commented Nov 6, 2017

My only suspicion is the Synopsis DesignWare I2C adapter; I wonder what that is. The rest are I2C inputs for plug-and-play monitors.

Do you also dual boot Windows? If yes, could you please check the bus under which it is being detected in the device manager?

Edit: The I2C adapter is not NFC

@derTobsch

This comment has been minimized.

Copy link

commented Nov 22, 2017

I have the same problem and my output is

i2c-3	unknown   	DPDDC-A                         	N/A
i2c-1	unknown   	i915 gmbus dpb                  	N/A
i2c-6	unknown   	Synopsys DesignWare I2C adapter 	N/A
i2c-4	unknown   	DPDDC-B                         	N/A
i2c-2	unknown   	i915 gmbus dpd                  	N/A
i2c-0	unknown   	i915 gmbus dpc                  	N/A
i2c-5	unknown   	DPDDC-C                         	N/A

I do not have a dual boot with windows. Only ubuntu 17.10 on a t470s

@derTobsch

This comment has been minimized.

Copy link

commented Nov 27, 2017

if someone needs support or information from the system please ask. It would be nice if there will be a driver for this nfc module.

@lbeltrame

This comment has been minimized.

Copy link

commented Dec 13, 2017

The device manager reports the NFC reader as NXP Semiconductors(Proximity) NXP Near Field Proximity Provider. Its "location" is under an I2C controller, "Serial I/O I2C Intel Host Controller - 9D60" (translated from my Language so it may be different from the English version). The "bus number" in the device manager is 0, the "BIOS name" is "_SB.PCI0.I2C0.NFC1".

The I2C controller listed (Intel Host Controller) is under PCI bus 0, device 21.

I'll keep Windows here for a couple more days before wiping it, so if need be, I can provide more details.

@Roxxor91

This comment has been minimized.

Copy link

commented Jan 17, 2018

Hey! I would like to participate in solving this issue!
From the FRU list (https://download.lenovo.com/parts/ThinkPad/t470_frubom_20170731.pdf) I found that the NFC is this one: https://fccid.io/MCLT77H747/Users-Manual/User-Manual-rev-4-3127142.html
FOXCONN Part No. T77H747.10
-> NFC (NXP NPC300) Module

@tuxflo

This comment has been minimized.

Copy link

commented Jan 20, 2018

The same NFC/smartcard reader is installed in the Lenovo Thinkpad Yoga 260.
Since the driver seems not to work with linux my question is: is the (compiled) Windows version of libnfc able to use the Windows drivers (the device shows status "Usable" in the device manager)?
If yes I would like to try to compile it on my windows system and share the results...

@Coffee2CodeNL

This comment has been minimized.

Copy link

commented Apr 21, 2018

Same story in the T580, also the Foxconn NXP NPC300.

Wish it worked :(

@RaphaelWimmer

This comment has been minimized.

Copy link

commented Jun 12, 2018

Some more details and clarifications:

  • NXP does not have any info on a "NPC300" chip/solution. It seems to me that this is just another name for an NFC chip from the PN7xxx range (or a name for a combination of chip and antenna).
  • NXP does not seem to support libnfc but provides their own libnfc-nci for Linux according to these interesting Webinar slides.
  • There are some tips on compiling the libnfc-nci kernel driver in the Webinar slides and NXP application note AN11697.
  • However, there is a major problem: the chip needs to be enabled (activated) through a GPIO pin that drives VEN high. AFAICT, the device will only appear on the I2C bus if it is activated in this way. Unless you have the schematics for your motherboard, the only way to find out which of the CPU's GPIO pins is connected to the NXP chip is to activate every single one of them and check whether the NXP chip appears on the I2C bus. As lots of other stuff might be connected to these GPIO pins, I'm a little bit hesitant to try this out.
  • It seems that the NXP chips usually have an I2C address of 0x28 or 0x29. So, if the chip is enabled, i2cdetect should detect a device at this address.

The correct way to find out which I2C devices are connected to an I2C bus (and are responding) is the following:

modprobe i2c-dev      # to make the I2C buses available on /dev
i2cdetect -l     # to find all I2C buses 
i2cdetect 0    # to find out which devices are connected to bus i2c-0

This can only tell you the addresses of devices on the bus (e.g., "0x28"), not what they actually are, however.
Despite the warning that "This program can confuse your I2C bus, cause data loss and worse!", probing the I2C bus this way has never caused any problems for me.

Most of the I2C buses you will see with i2cdetect -l belong to the graphics chip (e.g., everything with "DDC" in the name). The most probable bus to find the NFC chip would be the SMBus (i2c-0 smbus SMBus I801 adapter at efa0 SMBus adapter) in my case.

@pccr10001

This comment has been minimized.

Copy link

commented Jun 24, 2018

Hi. I found something from DSDT table in my X1C 6th.
According to the picture, I think 0x0029 is the I2C address, and GPIO lists are the pins definition.
The GPIO pin 0x006C is active high, is it VEN pin?
default
NPC300 datasheet

@RaphaelWimmer

This comment has been minimized.

Copy link

commented Jun 24, 2018

Oh, I didn't know that this can be stored in the DSDT (unfortunately, the DSDT on my HP Elitebook 1030 G2 only contains "0x0000" as pin lists).
I guess GPIO 0x6C is the connected to the IRQ pin of the NFC module which notifies the kernel that a NFC chip has been detected. GPIO 0x27 and 0x64 are probably connected to VEN and DWL_REQ (enable firmware update mode - potentially dangerous to keep enabled).

@jr64

This comment has been minimized.

Copy link

commented Aug 8, 2018

I have a Thinkpad T480s which uses the same NPC300 chip and I partially succeeded getting it to run under Ubuntu 18.04.
Libnfc-nci (https://github.com/NXPNFCLinux/linux_libnfc-nci/) has a mode where it uses /sys/class/gpio to communicate with the hardware. Since that seemed easier to play around with than a kernel module, I decided to start with that.

My DSDT is the same as the one @pccr10001 posted, so I guess the configuration is the same.

I edited the pins in src/halimpl/pn54x/tml/i2c/phTmlNfc_alt.h like this:

 #define I2C_BUS         "/dev/i2c-6"
 #define I2C_ADDRESS     0x29
 #define PIN_INT         360+0x6c
 #define PIN_ENABLE      360+0x64

I got the bus number from ic2detect -l which looks like this:

i2c-3	unknown   	DPDDC-A                         	N/A
i2c-1	unknown   	i915 gmbus dpb                  	N/A
i2c-6	unknown   	Synopsys DesignWare I2C adapter 	N/A
i2c-4	unknown   	DPDDC-B                         	N/A
i2c-2	unknown   	i915 gmbus dpd                  	N/A
i2c-0	unknown   	i915 gmbus dpc                  	N/A
i2c-5	unknown   	DPDDC-C                         	N/A

Bus 6 was the only one that made sense to me and indeed it worked.

The i2c address and ports are from the DSDT, finally the offset 360 is from /sys/class/gpio/gpiochip360/base

Afterwards I configured the library like this (not sure if it is a pn7150 or pn7120 but I guess 7150 because according to data sheets I found the chip supports tags of type 5 which the 7120 does not):

./configure --enable-pn7150 --enable-alt --sysconfdir=/etc

Then I ran make and make install and finally was able to start the demo app:

 sudo ./nfcDemoApp poll
#########################################################################################
##                                       NFC demo                                      ##
#########################################################################################
##                                 Poll mode activated                                 ##
#########################################################################################
                              ... press enter to quit ...

Waiting for a Tag/Device...

	NFC Tag Found

		Type : 		'Type A - Mifare Classic'
		NFCID1 :    	'XX XX XX XX '
		NDEF Content : NO, mode=1, tech=8

		RAW Tag transceive failed
		Type : 		'Type A - Mifare Classic'
		NFCID1 :    	'XX XX XX XX '
		NDEF Content : NO, mode=1, tech=8

		RAW Tag transceive failed
		Type : 		'Type A - Mifare Classic'
		NFCID1 :    	'XX XX XX XX '
		NDEF Content : NO, mode=1, tech=8

		RAW Tag transceive failed
		Type : 		'Type A - Mifare Classic'
		NFCID1 :    	'XX XX XX XX '
		NDEF Content : NO, mode=1, tech=8

		RAW Tag transceive failed
	NFC Tag Lost

Waiting for a Tag/Device...

As you can see it correctly detected the Mifare classic card I tested. I'm not sure if the RAW Tag transceive failed means that something is still not working. Maybe my card is not a standard Mifare Classic but a modified version, I'm not sure and don't have anything else to test.

I guess the next step would be to try to get the proper kernel module to run, it shouldn't be too hard with the configuration already known.

One thing I noticed is that the touchpad does not seem to play well with the nfc driver. whenever I start it, the touchpad becomes laggy, the mouse pointer sometimes jumps around and acceleration seems to stop working. This persists for a few seconds, then everything works again and then it starts being buggy again. This even persists after I stop the nfc demo until I reboot the system. I don't have much experience with i2c so if anyone could point me in the right direction that would be great.

Also I have never worked with NFC before, am I correct in assuming that libnfc and libnfc-nci are not compatible so even if we got it to work, most of the software out there would have to be heavily modified to work on our machines?

@mvdnes

This comment has been minimized.

Copy link

commented Aug 8, 2018

@jr64 I can confirm this also works on my regular T480 with Arch Linux. Same DSDT file, and the i2c bus has the same name altough it is sometimes on /dev/i2c-0 and sometimes on /dev/i2c-1.

The demo app works with poll, and write on a small tag, and share also works with my Android phone.

I would also like to point out the path /sys/bus/i2c/devices/i2c-NXP1001:00/, which is present on my system. Maybe that can be used to determine the i2c bus more reliably.

@pccr10001

This comment has been minimized.

Copy link

commented Aug 9, 2018

@JC64 This solution works on my X1C and card emulation works too, I am using Ubuntu 18.04.1.

@jr64

This comment has been minimized.

Copy link

commented Aug 9, 2018

Update: I just modified the i2c kernel driver (https://github.com/NXPNFCLinux/nxp-pn5xx) to support ACPI and autoconfigure itself. Seems to work fine to me. I'll post the code as soon as I have cleaned it up.

However, this still does not fix the touchpad issues I am experiencing. Does anyone else have this problem? Any ideas how to fix? I'm assuming the touchpad is also connected via i2c and the driver is somehow interfering with it?

@jr64

This comment has been minimized.

Copy link

commented Aug 10, 2018

For anyone interested, I just uploaded the first version of my modified kernel driver: https://github.com/jr64/nxp-pn5xx

@pccr10001

This comment has been minimized.

Copy link

commented Aug 10, 2018

@jr64 Here is the solution of the trackpoint problem.
My trackpoint is working now.
You need the latest kernel to work for RMI bus.

https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_6)#TrackPoint_and_Touchpad_issues

@jr64

This comment has been minimized.

Copy link

commented Aug 10, 2018

@pccr10001 Thanks, that seemed really promising but unfortunately it looks like they put an Elan touchpad and not a Synaptics in the T480s.

To quote from https://patchwork.kernel.org/patch/10330857/:

"- the T480s is using an Elan touchpad, so that's a different story"

Luckily it looks like there is work being done on Elan too (https://patchwork.kernel.org/patch/10324633/) but it's not yet included in the kernel I'm running.

Anyways, at least I'm fairly certain now that the problem is with the touchpad driver and not with the code I wrote for the NFC module.

@jr64

This comment has been minimized.

Copy link

commented Aug 10, 2018

Oh and another funny detail: the only way I found to fix the slow trackpad without rebooting the system is to close and open the notebook. Reloading the psmouse driver seems to do nothing, but putting the device to sleep and waking it up again fixes it permanently (well at least until I use NFC again).

@spielkind

This comment has been minimized.

Copy link

commented Aug 13, 2018

I'm still a bit confused, I compiled the DemoApp with the manual GPIO changes, and it worked:
#########################################################################################
##                                       NFC demo                                      ##
#########################################################################################
##                                 Poll mode activated                                 ##
#########################################################################################
                              ... press enter to quit ...

Waiting for a Tag/Device...

	NFC Tag Found

        Type :         'Type A'
        NFCID1 :    	'04 22 2B C2 B6 46 80 '
		NDEF Content : NO, mode=1, tech=1

	Not a MIFARE card
	NFC Tag Lost

Waiting for a Tag/Device...

I'm on a X280:
/sys/bus/i2c/devices/i2c-NXP1001:00 -> ../../../devices/pci0000:00/0000:00:15.0/i2c_designware.0/i2c-7/i2c-NXP1001:00

But why would I need the kernel module adjusted by @jr64 , and how can I confirm that it worked after loading. Also are there any client tools, beside the demoapp, which work right now?

@jr64

This comment has been minimized.

Copy link

commented Aug 13, 2018

@spielkind The kernel module has two advantages:

  1. it configures itself from ACPI so no need to manually find out the correct GPIO ports
  2. driving GPIO pins from userland through /sys/class/gpio is kind of "hacky", a kernel module is the "proper" variant for such a task. But of course, at the end of the day, both work fine.

As for how to test: if you configure the library with "--enable-i2c" instead of "--enable-alt" it will only work if the kernel modules is loaded.

@blasty

This comment has been minimized.

Copy link

commented Nov 2, 2018

Thanks @jr64 and others for the progress on this. I've gotten this to work (sort of) on a T480s with @jr64's kernel module and libnfc-nci-R2.2. However, with the nfcDemoApp (in poll mode) I have a very poor detection rate of tags, and haven't seen any succesfull NDEF record reading yet. Has anyone experienced similar issues?

Edit: the detection rate for a passport with RFID works a lot better (as opposed to two random RFID-capable bank cards I have), though Im getting different NFCID values etc. every tap. I guess something with the configuration/calibration of the RF stuff is really off.. :-/

@dlezcano

This comment has been minimized.

Copy link

commented Dec 4, 2018

@jr64 : did you plan to upstream the driver ? I tried it on a x280 and it works as far as I can tell. That would be an improvement of the x280 support on Linux.

@dlezcano

This comment has been minimized.

Copy link

commented Dec 4, 2018

I have been throught the upstream kernel and found the following commit:

commit 0a5942c8e1480db4b8ee7a8d643e4945ef2f8fed
Author: Robert Dolca robert.dolca@intel.com
Date: Mon Jan 26 13:13:37 2015 +0200

NFC: Add ACPI support for NXP PN544

Currently there is no support for ACPI.
This patch uses the following configuration:
        - Device id: NXP5440
        - Pin mapping:
                - 0 IRQ pin
                - 1 enable pin
                - 2 firmware pin

Signed-off-by: Robert Dolca <robert.dolca@intel.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

So at this point I assume the ACPI is supported in mainline since 2015. But if we look closely at the ACPI table and match hid we have in this driver:

static const struct acpi_device_id pn544_hci_i2c_acpi_match[] = {
{"NXP5440", 0},
{}
};

But on my x280, the ACPI table is:
[ ... ]
Name (_HID, "NXP1001") // _HID: Hardware ID
[ ... ]
Except I'm missing something, it should be NXP5440.

@dlezcano

This comment has been minimized.

Copy link

commented Dec 4, 2018

dsdt table looks buggy:
acpidump > acpidump
acpixtract -a acpidump
iasl -d dsdt.dat
iasl -tc dsdt.dsl

Intel ACPI Component Architecture
ASL+ Optimizing Compiler/Disassembler version 20180105
Copyright (c) 2000 - 2018 Intel Corporation

Compiler aborting due to parser-detected syntax error(s)
dsdt.dsl 264: Name (SS4, One)
Error 6126 - ^ syntax error, unexpected PARSEOP_NAME

ASL Input: dsdt.dsl - 34418 lines, 1065629 bytes, 15154 keywords
Hex Dump: dsdt.hex - 230 bytes

Compilation complete. 1 Errors, 0 Warnings, 0 Remarks, 0 Optimizations

@dlezcano

This comment has been minimized.

Copy link

commented Dec 4, 2018

And even worse, run:
sudo fwts syntaxcheck -
and admire the result on my beautiful ultra expensive x280.

Test |Pass |Fail |Abort|Warn |Skip |Info |
---------------+-----+-----+-----+-----+-----+-----+
syntaxcheck | 11| 26| | | | |
---------------+-----+-----+-----+-----+-----+-----+
Total: | 11| 26| 0| 0| 0| 0|
---------------+-----+-----+-----+-----+-----+-----+

WTF!

@vvug

This comment has been minimized.

Copy link

commented Feb 11, 2019

@jr64 Same question here. Do you think your driver can be upstreamed? Thanks!

@dileks

This comment has been minimized.

Copy link

commented May 13, 2019

Just want to let you know...

With the patch series "[PATCH v2 00/12] NFC: nxp-nci: clean up and support new ID" (see [1]) I was able to get my NFC chip NXP NFC300 ("NXP1001") run on my Lenovo ThinkPad T470 with the NFC nxp-nci driver shipped with Linux v5.1.1.

Furthermore, I can acces, list and poll with neard (daemon) v0.16 and neard-tools from Debian/buster.

There is no need for nxp-pn5xx driver and libnfc-nci from NXP.

Before this I expermented with jr64 nxp-pn5xx (acpi support) and libnfc-nci from NXP and had sucess with running the demo-app. I saw in the logs:

NxpHal: phNxpNciHal_deriveChipType Hw Version (0x68) Not Found: Setting Default Chip Type : PN548C2
NxpHal: phNxpNciHal_deriveChipType NxpNci > Product : PN548C2

Hope this helps.

UPDATE: Add relevant threads in linux-wireless mailing-list and patchwork

[1] https://patchwork.kernel.org/project/linux-wireless/list/?submitter=33142
[2] https://marc.info/?t=155740978400003&r=1&w=2
[3] https://marc.info/?t=155774435600001&r=1&w=2

@mweinelt

This comment has been minimized.

Copy link

commented May 15, 2019

Cool, I applied the patchset against Linux 5.1.2 and the nfc adapter on my X1 C6 came to live.

With nfctool --poll -d nfc0 it recognizes there is a token (tag0, tag1, ..., tagN), but there is little more information.

I have neard installed but it cannot currently find the default bluetooth adapter to pair a bluetooth headset, but at least it's trying to do that.

@dileks

This comment has been minimized.

Copy link

commented May 16, 2019

@mweinelt
Thanks for testing. Andy is preparing a v3 of his patchset.

What says...?

# rfkill --output ID,TYPE
ID TYPE
 0 bluetooth
 1 nfc
 2 wlan
 3 bluetooth

# rfkill list nfc
1: nfc0: NFC
        Soft blocked: no
        Hard blocked: no
@mweinelt

This comment has been minimized.

Copy link

commented May 16, 2019

Output is the same as yours. Looking forward to v3, but it looks like cleanups only.

@mweinelt

This comment has been minimized.

Copy link

commented May 17, 2019

Not much luck with actually reading NFC tags.

neard[2300]: neard[2300]: NEAR daemon version 0.16
neard[2300]: NEAR daemon version 0.16
neard[2300]: neard[2300]: Could not get Bluetooth default adapter Method "DefaultAdapter" with signature "" on interface "org.bluez.Manager" doesn't exist
neard[2300]: Could not get Bluetooth default adapter Method "DefaultAdapter" with signature "" on interface "org.bluez.Manager" doesn't exist
neard[2300]: neard[2300]: Unknown EIR x03 (len: 17)
neard[2300]: neard[2300]: bt_get_default_adapter failed
neard[2300]: neard[2300]: ndef parsing failed
neard[2300]: Unknown EIR x03 (len: 17)
neard[2300]: bt_get_default_adapter failed
neard[2300]: ndef parsing failed
neard[2300]: neard[2300]: Error while reading NFC bytes
neard[2300]: Error while reading NFC bytes
@mweinelt

This comment has been minimized.

Copy link

commented May 18, 2019

@dileks does reading nfc tags work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.