简体   繁体   English

不同芯片上的相同Linux驱动程序

[英]Same Linux Drivers on Different Chips

I am newbie on linux driver development. 我是Linux驱动程序开发的新手。 I wonder how same linux drivers work on different chips. 我想知道Linux驱动程序在不同芯片上的工作原理。 For instance, same uart driver work on allwinner and sitara socs?Do allwinner and sitara socs have same uart peripheral? 例如,同样的uart驱动程序在allwinner和sitara socs上工作吗?allwinner和sitara socs是否有相同的uart外围设备?

Basically how things are working is based on layering concept as shown below in Image. 基本上如何工作是基于分层概念,如下图所示。

Kernel source is layered so that we don't have to write it again and again for every system and to increase its re usability. 内核源是分层的,因此我们不必为每个系统反复写入它并增加其可用性。

Approach behind this is, architect depended code on bottom layer, then comes layer of bus drivers (SPI, I2C, etc.) and then comes adapter or device drivers. 这背后的方法是,架构师在底层依赖代码,然后是总线驱动程序层(SPI,I2C等),然后是适配器或设备驱动程序。

So suppose if a board is using company A's NAND Flash over SPI or any similar interface, we can use same device driver for this company A - NAND Flash on any given board, irrespective of whatever SPI apapter present, but only thing need to be concerned is SPI bus driver should be present as platform driver. 因此,如果一块电路板使用公司A的NAND闪存通过SPI或任何类似的接口,我们可以在任何给定电路板上使用相同的设备驱动程序A-NAND Flash,无论SPI存在什么,但只需要关注SPI总线驱动程序应作为平台驱动程序存在。

Here while probing, SPI will give access to the device driver with NAND Flash's Address. 在探测时,SPI将通过NAND Flash的地址访问设备驱动程序。 Here SPI driver knows how to communicate with SPI devices and NAND Flash driver keep on telling to SPI Driver what to transfer to NAND flash and SPI takes responsibility for how to transfer. 这里SPI驱动程序知道如何与SPI设备进行通信,NAND闪存驱动程序继续告诉SPI驱动程序要转移到NAND闪存,SPI负责如何传输。 In this SPI Platform driver may differ with different platforms but NAND Flash driver remains same. 在此SPI平台驱动程序可能因不同平台而异,但NAND闪存驱动程序保持不变。

With this approach same device driver for a device can be used in different systems without any dependencies for hardware specification. 通过这种方法,设备的相同设备驱动程序可以在不同的系统中使用,而不依赖于硬件规范。

Linux内核映射

Well, at first, it doesn't matter what SoC is, or who is the vendor. 好吧,首先,SoC是什么,或者谁是供应商并不重要。 What matters is the UART peripheral only. 重要的是UART外设。 So if the peripheral has got some registers on SoC A and exact same registers on SoC B, both of them can go with the same driver. 因此,如果外设在SoC A上有一些寄存器,并且在SoC B上有相同的寄存器,那么它们都可以使用相同的驱动程序。 The driver would just tell the underlying bus ( which is usually managed by a different subsystem) to write some configuration bits to specified registers for different operations. 驱动程序只是告诉底层总线(通常由不同的子系统管理)将一些配置位写入指定的寄存器以进行不同的操作。 Also, usually if a chip is derived from some old model, simple peripherals like UART remain pretty much the same. 此外,通常如果芯片来自某些旧型号,那么像UART这样的简单外设几乎保持不变。

Next .. If all the Allwiner SoCs has the same UART ? 下一步..如果所有Allwiner SoC都有相同的UART? Not sure about all of them but this here [ https://github.com/allwinner-zh/linux-3.4-sunxi/blob/master/drivers/tty/serial/Kconfig ] suggests that most of the SoCs use the same UARTs. 不确定所有这些但是这里[ https://github.com/allwinner-zh/linux-3.4-sunxi/blob/master/drivers/tty/serial/Kconfig ]表明大多数SoC使用相同的UART 。

And about Sitara Soc, they have shifted to 8250 driver [ http://processors.wiki.ti.com/index.php/Sitara_Linux_UART_-_Switching_to_8250_Driver] , which has been used for many years now. 关于Sitara Soc,他们已经转移到8250司机[ http://processors.wiki.ti.com/index.php/Sitara_Linux_UART_-_Switching_to_8250_Driver] ,这已经使用多年了。 So yeah, since its they (TI) who have decided to this, they will have to maintain backward compatibility in terms of UART. 所以,是的,因为他们(TI)已决定这一点,他们将不得不保持UART方面的向后兼容性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM