1

デバイス ツリーに関する私の理解によると、主な用途の 1 つは、ドライバーからプラットフォーム固有のコードを削除して、複数のプラットフォームをサポートすることです。デバイス ツリーは、1 つのペリフェラルに対して複数の構成をどのように処理しますか?

たとえば、プラットフォーム A で LCD パネル A を使用し、プラットフォーム B で LCD パネル B を使用したい場合、LCD パネル A とパネル B の両方に関連するコードを最終的なバイナリに保持する必要がありますか? その場合、複数のオプションを持つ複数のペリフェラルが存在する場合、バイナリに膨大な追加コードが存在するようです。

4

2 に答える 2

6

For example if I want to use LCD Panel A in Platform A and LCD Panel B in Platform B, So do I need to keep both LCD Panel A and Panel B related code in the final binary?

There are three cases for drivers.

  1. Completely different chip and bus/sub-system.
  2. Same bus/sub-system, but different chip set.
  3. Same bus/sub-system, same chip set, different parameters.

From this you should understand the answer. For an LCD, the driver is usually hosted on the SOC and the panel just changes parameters such as display geometry (1/4 VGA versus 1/2 VGA), timing (50Hz versus 75HZ) and possibly control signals (OE active low/high, active/passive matrix, etc). This is actually handled exceptionally well by the device tree concept.

Prior to device tree, a machine file would pass platform data to the driver; this contains the parameters mentioned above. As the machine file is code, both versions must be contained in the kernel for panel A and panel B. This is not too bad, but for Ubuntu type releases with 1000s of panels, this can be an issue. Previously the boot loader passed a single machine id and this keyed which machine file to use. Now, the device tree is passed by the boot loader and the machine file is generally converted to a device tree structure.

Now, if the machine has different Ethernet controller chips, you can use both device trees and modules to keep the kernel size down. This is the 2nd case mentioned above.

The 3rd case can also be handled with modules. For instance, a wifi driver and an HSDPA modem may be communication mechanisms on different platforms. The 802.11 sub-system can be a module and can the n-gsm code. Further, the HSDPA modem may use USB or a UART, whereas the wifi may use SPI or SDIO. Some of this code may not be able to be convert modules as it may have some tight coupling with the network stack. Generally every effort is made to minimize this overhead.

So generally, the device tree concept is actually reducing code; at least in SDRAM which is a primary resource that is at a premium. NAND flash or other bulk storage may be bigger. You have the option to statically configure the device for a specific piece of hardware. If you intend to support both panels in one image, then device trees are better. In fact, they are better in almost all cases.

于 2013-07-09T14:03:43.807 に答える