Hi,
In the arch/arm/mach-bcm2708/bcm2708.c file in your kernel you should have a array called bcm2708_spi_devices. This array contains all the SPI devices that are registered to the SPI master on the RPI. You need to add the ADXL345 to that list as described in the ADXL345 Linux driver documentation.
E.g. something like this:
#include <linux/input.h> #include <linux/input/adxl34x.h> static const struct adxl34x_platform_data adxl34x_info = { .x_axis_offset = 0, .y_axis_offset = 0, .z_axis_offset = 0, .tap_threshold = 0x31, .tap_duration = 0x10, .tap_latency = 0x60, .tap_window = 0xF0, .tap_axis_control = ADXL_TAP_X_EN | ADXL_TAP_Y_EN | ADXL_TAP_Z_EN, .act_axis_control = 0xFF, .activity_threshold = 5, .inactivity_threshold = 3, .inactivity_time = 4, .free_fall_threshold = 0x7, .free_fall_time = 0x20, .data_rate = 0x8, .data_range = ADXL_FULL_RES, .ev_type = EV_ABS, .ev_code_x = ABS_X, /* EV_REL */ .ev_code_y = ABS_Y, /* EV_REL */ .ev_code_z = ABS_Z, /* EV_REL */ .ev_code_tap = {BTN_TOUCH, BTN_TOUCH, BTN_TOUCH}, /* EV_KEY x,y,z */ /* .ev_code_ff = KEY_F,*/ /* EV_KEY */ /* .ev_code_act_inactivity = KEY_A,*/ /* EV_KEY */ .power_mode = ADXL_AUTO_SLEEP | ADXL_LINK, .fifo_mode = ADXL_FIFO_STREAM, .orientation_enable = ADXL_EN_ORIENTATION_3D, .deadzone_angle = ADXL_DEADZONE_ANGLE_10p8, .divisor_length = ADXL_LP_FILTER_DIVISOR_16, /* EV_KEY {+Z, +Y, +X, -X, -Y, -Z} */ .ev_codes_orient_3d = {BTN_Z, BTN_Y, BTN_X, BTN_A, BTN_B, BTN_C}, }; static struct spi_board_info bcm2708_spi_devices[] = { ... { .modalias = "adxl34x", .platform_data = &adxl34x_info, .irq = IRQ_HERE, .max_speed_hz = 5000000, .bus_num = 0, .chip_select = CHIP_SELECT_HERE, .mode = SPI_MODE_3, }, };
IRQ and chipselect number need to be configured according to the pins you connect them to.
- Lars