When picking out parts for your custom electronics design, it can pay to check up-front for Linux driver support. Writing new drivers for unsupported hardware is time-consuming, introduces risk, and adds complexity to a project.
It’s better to select supported hardware. How can we check if hardware is supported in the first place? First you need to find the exact version of Linux you will be using.
Getting the right Linux Kernel
You might be using a kernel release from kernel.org, but more likely you are using whatever bespoke kernel is provided by your SOC vendor. For example, if you are using an NXP i.MX processor with BSP imx_4.9.88_2.0.0_ga, then you’ll be using this.
You need to make sure you have the exact version of the Linux kernel you will be using. Support is added and removed all the time, there’s no guarantee that the same code will be found in two different versions of the Linux kernel.
Searching for driver support
Now that you have the correct kernel sources, how can you check if a given hardware part number is supported?
The best method is to do a text search for the part number you are looking for. I’ll illustrate this with a few examples.
N.B: in these examples we are using kernel version v5.0-rc1 from kernel.org. To search we will be using ‘git grep,’ this is a very fast command line tool for searching the entire contents of a git repository.
Example 1: S25FL512SAGMFI011 flash
The first thing you might try is searching for the entire part number.
This doesn’t come up with anything. The next step is to search with case-insensitive set on. It’s best to search case-insensitive as the Linux kernel prefers lower-case identifiers for driver names, but you might find clues in either upper or lower case.
Unfortunately this still doesn’t come up with anything. The next thing to try is to remove some of the trailing characters from the part number, as some of these probably refer to packaging, temperature-range, and other things that don’t affect the logical operation of the device, and don’t affect the Linux driver operation.
You can remove characters one-by-one from your search string until you get a match, and then make an informed decision based on the data-sheet and the results to see if your part is supported. Looking at the data-sheet, we can see only the S25FL512S part is relevant to the logical operation of the device.
Now we have some interesting results. The first result is some documentation of the “jedec,spi-nor” device-tree binding. The last result is an entry into a table found in the “spi-nor.c” driver describing some properties of this particular flash-chip.
From this we can deduce that the chip is supported, and can be detected via its JEDEC ID on boot, if the correct device-tree entry is added as described in the documentation from the first result.
Example 2: MCP79411-I/SN real-time clock
Again, searching the entire part number doesn’t reveal anything. Looking at the datasheet, there is a single data-sheet for the MCP79410, MCP79411 and the MCP79412. The only difference is the type of “unique ID” provided in the internal storage of the device. Therefore we could try searching for “MCP7941.”
Again we get some driver results and some documentation on how to add support in via the device-tree.
Sometimes the exact part will not be explicitly supported, but it may be functionally the same as another part, in which case the same driver can be used for both.
If the part is not supported, it’s worth having a copy of the latest Linux kernel sources to cross-reference against. If support has been recently added, you may be able to “backport” the driver to your kernel version.
Sometimes a driver has been written but has not yet been included in the official kernel sources. It may have been submitted to a mailing list, and you may be able to try it out early. In all cases, “Google” can be a great help.
Ville Baillie is a software engineer at ByteSnap Design, an award-winning software and hardware consultancy. He is a graduate of Physics at Warwick University and now specialises in developing device drivers for Embedded Linux applications.