简体   繁体   English

为 Linux 驱动程序添加设备数据结构和注册

[英]Adding device data structures and registration for Linux driver

I am adding a gyro/accel driver (Invensense MPU3050), available here to my kernel (LPC Linux).我正在添加一个陀螺仪/加速度驱动程序 (Invensense MPU3050), 我的 kernel (LPC Linux) 上可用。 I use LTIB for building the image and rootfs.我使用 LTIB 来构建映像和 rootfs。

I manage in adding all files and the driver is available and compiles perfectly.我设法添加了所有文件,并且驱动程序可用并且可以完美编译。 Now I need to add a mpu3050_platform_data structure in the i2c_board_info_structure in the "board-generic.c" file ( README ) and then register it adding some lines in the same "board-generic.c" file.现在我需要在“board-generic.c”文件( README )的 i2c_board_info_structure 中添加一个 mpu3050_platform_data 结构,然后在同一个“board-generic.c”文件中添加一些行来注册它。

Problem is, I cannot locate this/these file/s.问题是,我找不到这个/这些文件/s。 Is their name depending on the linux distribution?他们的名字是否取决于 linux 分布? Is the same info written somewhere else?相同的信息是否写在其他地方?

You need to add this to the file supporting the tegra board you are using.您需要将此添加到支持您正在使用的 tegra 板的文件中。 In the current 3.0-rc3 kernel (last tag I have checked out), I see these tegra board files (in arch/arm/mach-tegra):在当前的 3.0-rc3 kernel(我检查的最后一个标签)中,我看到了这些 tegra 板文件(在 arch/arm/mach-tegra 中):

  • board-harmony.c板和谐.c
  • board-paz00.c板-paz00.c
  • board-seaboard.c板-seaboard.c
  • board-trimslice.c板-trimslice.c

These files configure the static devices for a given tegra board.这些文件为给定的 tegra 板配置 static 器件。 Your config file then selects which ones are built.然后,您的配置文件会选择构建哪些配置文件。 Here are the corresponding config options (from arch/arm/mach-tegra/Kconfig):以下是相应的配置选项(来自 arch/arm/mach-tegra/Kconfig):

comment "Tegra board type"

config MACH_HARMONY
       bool "Harmony board"
       select MACH_HAS_SND_SOC_TEGRA_WM8903
       help
         Support for nVidia Harmony development platform

config MACH_KAEN
       bool "Kaen board"
       select MACH_SEABOARD
       select MACH_HAS_SND_SOC_TEGRA_WM8903
       help
         Support for the Kaen version of Seaboard

config MACH_PAZ00
       bool "Paz00 board"
       help
         Support for the Toshiba AC100/Dynabook AZ netbook

config MACH_SEABOARD
       bool "Seaboard board"
       select MACH_HAS_SND_SOC_TEGRA_WM8903
       help
         Support for nVidia Seaboard development platform. It will
     also be included for some of the derivative boards that
     have large similarities with the seaboard design.

config MACH_TRIMSLICE
       bool "TrimSlice board"
       select TEGRA_PCI
       help
         Support for CompuLab TrimSlice platform

config MACH_WARIO
       bool "Wario board"
       select MACH_SEABOARD
       help
         Support for the Wario version of Seaboard

Your build system (LTIB) certainly defines one of these config macros (CONFIG_MACH_HARMONY for instance).您的构建系统 (LTIB) 肯定定义了这些配置宏之一(例如 CONFIG_MACH_HARMONY)。 Look at your config file, see which one is enabled, and add the declaration of your i2c device in the corresponding board-xxx.c file.查看您的配置文件,查看启用了哪个,然后在相应的 board-xxx.c 文件中添加您的 i2c 设备的声明。

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

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