总线,设备,设备驱动

来源:互联网 发布:playhome捏脸数据 编辑:程序博客网 时间:2024/04/27 15:02

A bus is a channel between the processor and one or more devices. For the  purposes of the device model, all devices are connected via a bus, even if  it is an internal, virtual, "platform" bus. Buses can plug into each other.  A USB controller is usually a PCI device, for example. The device model  represents the actual connections between buses and the devices they control.  A bus is represented by the bus_type structure. It contains the name, the  default attributes, the bus' methods, PM operations, and the driver core's  private data.


 The device driver-model tracks all of the drivers known to the system.  The main reason for this tracking is to enable the driver core to match  up drivers with new devices. Once drivers are known objects within the  system, however, a number of other things become possible. Device drivers  can export information and configuration variables that are independent  of any specific device.


  At the lowest level, every device in a Linux system is represented by an instance of struct device. The device structure contains the information that the device model core needs to model the system. Most subsystems, however, track additional information about the devices they host. As a  result, it is rare for devices to be represented by bare device structures; instead, that structure, like kobject structures, is usually embedded within a higher-level representation of the device.


 platform_data: Platform data specific to the device.  Example: For devices on custom boards, as typical of embedded and SOC based hardware, Linux often uses platform_data to point to board-specific structures describing devices and how they  are wired.  That can include what ports are available, chip  variants, which GPIO pins act in what additional roles, and so  on.  This shrinks the "Board Support Packages" (BSPs) and  minimizes board-specific #ifdefs in drivers.

自己的一点点理解:

        对于linux系统驱动部分,分层概念用得很广泛,其实质就是类的继承,子类继承父类,子类在父类的基础上扩展各种功能,按扩展功能的不同,分别称称之为不同的子系统。核心的几个基类,如kobject, kset,ktype这三个类,被device,device_driver,bus继承。

        初始化的时候,一般都是初始化的核心基类,然后再初始化子系统,最后初始化具体的某个设备。


背光子系统

电源管理子系统

LED子系统


今天突然懂得了,设备和驱动分开的好处了,例如平台设备和平台驱动,对于同一平台设备,不同的硬件的开发板所提供的设备基地址或者其它资源不同,这些不同,可以在平台设备中体现;而平台驱动部分,则无需关心这部分的不同,或者做出的修改的部分很少很少。