Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ancora_sensors: opensource libsensors #87

Open
wants to merge 3 commits into
base: cm-12.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions arch/arm/mach-msm/board-ancora_tmo.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static struct platform_device ion_dev;

#ifdef CONFIG_OPTICAL_GP2A
#define PMIC_GPIO_PROX_EN 15 /* PMIC GPIO 16 */
#define MSM_GPIO_PS_VOUT 118// [HSS]125 for Test
#define PMIC_GPIO_PS_VOUT 118// [HSS]125 for Test
#endif

#define ADV7520_I2C_ADDR 0x39
Expand Down Expand Up @@ -518,10 +518,10 @@ static struct platform_device sec_device_jack = {
#ifdef CONFIG_OPTICAL_GP2A
static int __init opt_gp2a_gpio_init(void)
{
if (gpio_tlmm_config(GPIO_CFG(MSM_GPIO_PS_VOUT, 0, GPIO_CFG_INPUT,
if (gpio_tlmm_config(GPIO_CFG(PMIC_GPIO_PS_VOUT, 0, GPIO_CFG_INPUT,
GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE))
pr_err("[HSS] %s: gpio_tlmm_config (gpio=%d) failed\n",
__func__, MSM_GPIO_PS_VOUT);
__func__, PMIC_GPIO_PS_VOUT);

return 0;
}
Expand Down Expand Up @@ -3583,9 +3583,22 @@ static struct i2c_board_info opt_i2c_borad_info[] = {
},
};

struct opt_gp2a_platform_data {
int gp2a_irq;
int gp2a_gpio;
};

static struct opt_gp2a_platform_data opt_gp2a_data = {
.gp2a_irq = MSM_GPIO_TO_INT(PMIC_GPIO_PS_VOUT),
.gp2a_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_PROX_EN),
};

static struct platform_device opt_gp2a = {
.name = "gp2a-opt",
.id = -1,
.dev = {
.platform_data = &opt_gp2a_data,
},
};
#endif /* CONFIG_OPTICAL_GP2A */

Expand Down
40 changes: 24 additions & 16 deletions drivers/sensors_ancora/bma_accel_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ static const struct file_operations bma_fops = {
.unlocked_ioctl = bma_acc_ioctl,
};


static struct bma_acc_private_data *bma_acc_private_data = NULL;
static struct bma_acc_private_data *bma_acc_get_data(void) {return bma_acc_private_data;}
static void bma_acc_set_data(struct bma_acc_private_data *data) {bma_acc_private_data = data;}
Expand Down Expand Up @@ -433,9 +434,9 @@ static int bma_acc_set_enable(struct bma_acc_driver *driver, int enable)
if (bma_acc_ischg_enable(driver, enable)) {
if (enable) {
driver->set_enable(enable);
// schedule_delayed_work(&data->work, delay_to_jiffies(delay) + 1);
schedule_delayed_work(&data->work, delay_to_jiffies(delay) + 1);
} else {
// cancel_delayed_work_sync(&data->work);
cancel_delayed_work_sync(&data->work);
driver->set_enable(enable);
}
}
Expand All @@ -455,9 +456,9 @@ static int bma_acc_set_delay(struct bma_acc_driver *driver, int delay)
delay = delay / 1000000; // [HSS]Convert from ns to ms

if (driver->get_enable()) {
// cancel_delayed_work_sync(&data->work);
cancel_delayed_work_sync(&data->work);
driver->set_delay(actual_delay(delay));
// schedule_delayed_work(&data->work, delay_to_jiffies(delay) + 1);
schedule_delayed_work(&data->work, delay_to_jiffies(delay) + 1);
} else {
driver->set_delay(actual_delay(delay));
}
Expand Down Expand Up @@ -564,10 +565,15 @@ static int bma_acc_input_init(struct bma_acc_private_data *data)
if (!dev) {
return -ENOMEM;
}
dev->name = "accelerometer";
dev->name = "accelerometer_sensor";
dev->id.bustype = BUS_I2C;

input_set_capability(dev, EV_ABS, ABS_MISC);
input_set_capability(dev, EV_ABS, ABS_X);
input_set_capability(dev, EV_ABS, ABS_Y);
input_set_capability(dev, EV_ABS, ABS_Z);

input_set_abs_params(dev, ABS_MISC, 0, (1<<31), 0, 0);
input_set_abs_params(dev, ABS_X, ABSMIN_2G, ABSMAX_2G, 0, 0);
input_set_abs_params(dev, ABS_Y, ABSMIN_2G, ABSMAX_2G, 0, 0);
input_set_abs_params(dev, ABS_Z, ABSMIN_2G, ABSMAX_2G, 0, 0);
Expand All @@ -582,6 +588,7 @@ static int bma_acc_input_init(struct bma_acc_private_data *data)

return 0;
}

static int bma_acc_misc_init(struct bma_acc_private_data *data)
{
struct miscdevice *dev= &(data->bma_acc_device);
Expand Down Expand Up @@ -778,7 +785,7 @@ static ssize_t bma_acc_private_data_show(struct device *dev,
struct bma_acc_data accel;

mutex_lock(&data->data_mutex);
bma_acc_measure(data->driver, &accel);
accel = data->last;
mutex_unlock(&data->data_mutex);

return sprintf(buf, "%d %d %d\n", accel.raw.v[0], accel.raw.v[1], accel.raw.v[2]);
Expand Down Expand Up @@ -1002,7 +1009,7 @@ static void bma_acc_work_func(struct work_struct *work)
struct bma_acc_private_data, work);
struct bma_acc_data accel;
unsigned long delay = delay_to_jiffies(bma_acc_get_delay(data->driver));
printk("[diony] bma_acc_work_func.\n");

accel.xyz.v[0] = accel.xyz.v[1] = accel.xyz.v[2] = 0;
bma_acc_measure(data->driver, &accel);

Expand All @@ -1015,7 +1022,7 @@ static void bma_acc_work_func(struct work_struct *work)
data->last = accel;
mutex_unlock(&data->data_mutex);

// schedule_delayed_work(&data->work, delay);
schedule_delayed_work(&data->work, delay);
}

static int bma_acc_probe(struct i2c_client *client, const struct i2c_device_id *id)
Expand Down Expand Up @@ -1049,12 +1056,12 @@ static int bma_acc_probe(struct i2c_client *client, const struct i2c_device_id *
}

/* Setup driver interface */
//INIT_DELAYED_WORK(&data->work, bma_acc_work_func);
INIT_DELAYED_WORK(&data->work, bma_acc_work_func);




/* Setup input device interface */
/* Setup input device interface */
err = bma_acc_input_init(data);
if (err < 0) {
goto ERR3;
Expand All @@ -1065,8 +1072,9 @@ static int bma_acc_probe(struct i2c_client *client, const struct i2c_device_id *
if (err < 0) {
goto ERR4;
}
/* Sensor HAL expects to find /dev/accelerometer */
err = bma_acc_misc_init(data);

/* Sensor(AKM8975) HAL(Libakm) expects to find /dev/accelerometer */
err = bma_acc_misc_init(data);
if (err < 0) {
goto ERR5;
}
Expand Down Expand Up @@ -1109,7 +1117,7 @@ static int bma_acc_suspend(struct i2c_client *client, pm_message_t mesg)
if (data->suspend == 0) {
data->suspend_enable = bma_acc_get_enable(driver);
if (data->suspend_enable) {
// cancel_delayed_work_sync(&data->work);
cancel_delayed_work_sync(&data->work);
bma_acc_set_enable(driver, 0);
}
}
Expand All @@ -1131,7 +1139,7 @@ static int bma_acc_resume(struct i2c_client *client)
if (data->suspend == 1) {
if (data->suspend_enable) {
delay = bma_acc_get_delay(driver);
// schedule_delayed_work(&data->work, delay_to_jiffies(delay) + 1);
schedule_delayed_work(&data->work, delay_to_jiffies(delay) + 1);
bma_acc_set_enable(driver, 1);
}
}
Expand All @@ -1151,7 +1159,7 @@ MODULE_DEVICE_TABLE(i2c, bma_acc_id);

struct i2c_driver bma_acc_driver = {
.driver = {
.name = "accelerometer",
.name = BMA_ACC_KERNEL_NAME,
.owner = THIS_MODULE,
},
.probe = bma_acc_probe,
Expand All @@ -1178,4 +1186,4 @@ module_exit(bma_acc_exit);

MODULE_DESCRIPTION("accelerometer kernel driver");
MODULE_LICENSE("GPL");
MODULE_VERSION(BMA_ACC_KERNEL_VERSION);
MODULE_VERSION(BMA_ACC_KERNEL_VERSION);
Loading