Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
Add the APDS9960 proximity sensor kernel module
Browse files Browse the repository at this point in the history
The apds9960 device driver needs a GPIO as the IRQ resource,
Add this kernel module to provide the IRQ resource on Galileo boards

Signed-off-by: Yong Li <[email protected]>
  • Loading branch information
yongli3 committed May 12, 2016
1 parent 97f1b0d commit ec3d529
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion recipes-extended/i2c-quark-board/files/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
obj-m := i2c-quark-mpu6050.o
obj-m := i2c-quark-mpu6050.o i2c-quark-apds9960.o
SRC := $(shell pwd)

all:
Expand Down
50 changes: 50 additions & 0 deletions recipes-extended/i2c-quark-board/files/i2c-quark-apds9960.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* APDS9960 I2C sensor test file
* build command: KDIR=/kernel-source/ make
* The kernel config should include CONFIG_APDS9960=m
*/

#include <linux/module.h>
#include <linux/gpio.h>
#include <linux/i2c.h>

#define APDS9960_I2C_ADDR 0x39

/* The IRQ pin is connected to GPIO14=IO3
*/
#define APDS9960_I2C_IRQ 14

static struct i2c_board_info i2c_device = {
I2C_BOARD_INFO("apds9960", APDS9960_I2C_ADDR),
.irq = -1,
};

static struct i2c_client *i2c_client;
static int __init apds9960_init(void)
{
int i = 0;
struct i2c_adapter *adap = NULL;

for (i = 0; i < 10; i++) {
adap = i2c_get_adapter(i);
if (!adap)
return -1;

if (!strcmp(adap->name, "Synopsys DesignWare I2C adapter"))
break;
}

gpio_request_one(16, GPIOF_OUT_INIT_HIGH, "at86rf230-gpio16");
i2c_device.irq = gpio_to_irq(APDS9960_I2C_IRQ);
printk("Create new I2C device on %s \n", adap->name);
i2c_client = i2c_new_device(adap, &i2c_device);
return 0;
}

static void __exit apds9960_exit(void)
{
i2c_unregister_device(i2c_client);
}
MODULE_LICENSE("GPL");
module_init(apds9960_init);
module_exit(apds9960_exit);
1 change: 1 addition & 0 deletions recipes-extended/i2c-quark-board/i2c-quark-board.bb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ inherit module
FILESEXTRAPATHS_prepend := "${THISDIR}/files/:"

SRC_URI = "file://i2c-quark-mpu6050.c \
file://i2c-quark-apds9960.c \
file://Makefile \
"

Expand Down

0 comments on commit ec3d529

Please sign in to comment.