Search code examples
linux-kernelregistrationlinux-device-driveri2c

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). I use LTIB for building the image and 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.

Problem is, I cannot locate this/these file/s. Is their name depending on the linux distribution? Is the same info written somewhere else?


Solution

  • You need to add this to the file supporting the tegra board you are using. In the current 3.0-rc3 kernel (last tag I have checked out), I see these tegra board files (in arch/arm/mach-tegra):

    • board-harmony.c
    • board-paz00.c
    • board-seaboard.c
    • board-trimslice.c

    These files configure the static devices for a given tegra board. Your config file then selects which ones are built. Here are the corresponding config options (from 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). 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.