Skip to content

Instantly share code, notes, and snippets.

@adrientetar
Created March 24, 2012 11:35
Show Gist options
  • Save adrientetar/2181376 to your computer and use it in GitHub Desktop.
Save adrientetar/2181376 to your computer and use it in GitHub Desktop.
board-msm7x30.c /BOSCH_BMA150 driver section
#ifdef CONFIG_BOSCH_BMA150
static struct vreg *vreg_gp6;
static int sensors_ldo_enable(void)
{
int rc;
/*
* Enable the VREGs L8(gp7), L15(gp6)
* for I2C communication with sensors.
*/
pr_info("sensors_ldo_enable called!!\n");
vreg_gp7 = vreg_get(NULL, "gp7");
if (IS_ERR(vreg_gp7)) {
pr_err("%s: vreg_get gp7 failed\n", __func__);
rc = PTR_ERR(vreg_gp7);
goto fail_gp7_get;
}
rc = vreg_set_level(vreg_gp7, 1800);
if (rc) {
pr_err("%s: vreg_set_level gp7 failed\n", __func__);
goto fail_gp7_level;
}
rc = vreg_enable(vreg_gp7);
if (rc) {
pr_err("%s: vreg_enable gp7 failed\n", __func__);
goto fail_gp7_level;
}
vreg_gp6 = vreg_get(NULL, "gp6");
if (IS_ERR(vreg_gp6)) {
pr_err("%s: vreg_get gp6 failed\n", __func__);
rc = PTR_ERR(vreg_gp6);
goto fail_gp6_get;
}
rc = vreg_set_level(vreg_gp6, 3050);
if (rc) {
pr_err("%s: vreg_set_level gp6 failed\n", __func__);
goto fail_gp6_level;
}
rc = vreg_enable(vreg_gp6);
if (rc) {
pr_err("%s: vreg_enable gp6 failed\n", __func__);
goto fail_gp6_level;
}
return 0;
fail_gp6_level:
vreg_put(vreg_gp6);
fail_gp6_get:
vreg_disable(vreg_gp7);
fail_gp7_level:
vreg_put(vreg_gp7);
fail_gp7_get:
return rc;
}
static void sensors_ldo_disable(void)
{
pr_info("sensors_ldo_disable called!!\n");
vreg_disable(vreg_gp6);
vreg_put(vreg_gp6);
vreg_disable(vreg_gp7);
vreg_put(vreg_gp7);
}
static struct bma150_platform_data bma150_data = {
.power_on = sensors_ldo_enable,
.power_off = sensors_ldo_disable,
};
static struct i2c_board_info bma150_board_info[] __initdata = {
{
I2C_BOARD_INFO("bma150", 0x38),
.flags = I2C_CLIENT_WAKE,
.irq = MSM_GPIO_TO_INT(BMA150_GPIO_INT),
.platform_data = &bma150_data,
},
};
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment