Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From bd3148174cea71b80c38303c1de579a1c1c96d67 Mon Sep 17 00:00:00 2001
- From: stlifey <stlifey@gmail.com>
- Date: Mon, 16 Jan 2012 15:03:27 +0800
- Subject: [PATCH] enable vwlan1
- ---
- arch/arm/mach-omap2/board-sholes-camera.c | 68 ++++++++++++++++++++++-------
- arch/arm/mach-omap2/board-sholes-spi.c | 6 +++
- drivers/regulator/core.c | 55 ++++++++---------------
- 3 files changed, 78 insertions(+), 51 deletions(-)
- diff --git a/arch/arm/mach-omap2/board-sholes-camera.c b/arch/arm/mach-omap2/board-sholes-camera.c
- index fc65747..df9326c 100644
- --- a/arch/arm/mach-omap2/board-sholes-camera.c
- +++ b/arch/arm/mach-omap2/board-sholes-camera.c
- @@ -1,5 +1,5 @@
- /*
- - * linux/arch/arm/mach-omap2/board-mapphone-camera.c
- + * linux/arch/arm/mach-omap2/board-sholes-camera.c
- *
- * Copyright (C) 2009 Motorola, Inc.
- *
- @@ -140,7 +140,8 @@ static struct isp_interface_config mt9p012_if_config = {
- static int mt9p012_sensor_power_set(struct device *dev, enum v4l2_power power)
- {
- static enum v4l2_power previous_power = V4L2_POWER_OFF;
- - static struct regulator *regulator;
- + static struct regulator *regulator_vcam;
- + static struct regulator *regulator_vwlan1;
- switch (power) {
- case V4L2_POWER_OFF:
- @@ -148,10 +149,10 @@ static int mt9p012_sensor_power_set(struct device *dev, enum v4l2_power power)
- gpio_free(GPIO_MT9P012_RESET);
- /* Turn off power */
- - if (regulator != NULL) {
- - regulator_disable(regulator);
- - regulator_put(regulator);
- - regulator = NULL;
- + if (regulator_vcam != NULL) {
- + regulator_disable(regulator_vcam);
- + regulator_put(regulator_vcam);
- + regulator_vcam = NULL;
- } else {
- sholes_camera_lines_safe_mode();
- pr_err("%s: Regulator for vcam is not "\
- @@ -159,6 +160,21 @@ static int mt9p012_sensor_power_set(struct device *dev, enum v4l2_power power)
- return -EIO;
- }
- + /* Delay 6 msec for vcam to drop (4.7uF to 10uF change) */
- + msleep(6);
- +
- + /* Turn off power */
- + if (regulator_vwlan1 != NULL) {
- + regulator_disable(regulator_vwlan1);
- + regulator_put(regulator_vwlan1);
- + regulator_vwlan1 = NULL;
- + } else {
- + sholes_camera_lines_safe_mode();
- + pr_err("%s: Regulator for vwlan1 is not "\
- + "initialized\n", __func__);
- + return -EIO;
- + }
- +
- /* Release pm constraints */
- omap_pm_set_min_bus_tput(dev, OCP_INITIATOR_AGENT, 0);
- sholes_camera_lines_safe_mode();
- @@ -187,22 +203,42 @@ static int mt9p012_sensor_power_set(struct device *dev, enum v4l2_power power)
- /* nRESET is active LOW. set HIGH to release reset */
- gpio_set_value(GPIO_MT9P012_RESET, 1);
- - /* turn on digital power */
- - if (regulator != NULL) {
- + /* turn on VWLAN1 power */
- + if (regulator_vwlan1 != NULL) {
- + pr_warning("%s: Already have "\
- + "regulator_vwlan1 \n", __func__);
- + } else {
- + regulator_vwlan1 = regulator_get(NULL, "vwlan1");
- + if (IS_ERR(regulator_vwlan1)) {
- + pr_err("%s: Cannot get vwlan1 "\
- + "regulator_vwlan1, err=%ld\n",
- + __func__, PTR_ERR(regulator_vwlan1));
- + return PTR_ERR(regulator_vwlan1);
- + }
- + }
- +
- + if (regulator_enable(regulator_vwlan1) != 0) {
- + pr_err("%s: Cannot enable vcam regulator_vwlan1\n",
- + __func__);
- + return -EIO;
- + }
- +
- + /* turn on VCAM power */
- + if (regulator_vcam != NULL) {
- pr_warning("%s: Already have "\
- - "regulator\n", __func__);
- + "regulator_vcam\n", __func__);
- } else {
- - regulator = regulator_get(NULL, "vcam");
- - if (IS_ERR(regulator)) {
- + regulator_vcam = regulator_get(NULL, "vcam");
- + if (IS_ERR(regulator_vcam)) {
- pr_err("%s: Cannot get vcam "\
- - "regulator, err=%ld\n",
- - __func__, PTR_ERR(regulator));
- - return PTR_ERR(regulator);
- + "regulator_vcam, err=%ld\n",
- + __func__, PTR_ERR(regulator_vcam));
- + return PTR_ERR(regulator_vcam);
- }
- }
- - if (regulator_enable(regulator) != 0) {
- - pr_err("%s: Cannot enable vcam regulator\n",
- + if (regulator_enable(regulator_vcam) != 0) {
- + pr_err("%s: Cannot enable vcam regulator_vcam\n",
- __func__);
- return -EIO;
- }
- diff --git a/arch/arm/mach-omap2/board-sholes-spi.c b/arch/arm/mach-omap2/board-sholes-spi.c
- index 01d557e..fa56d9a 100644
- --- a/arch/arm/mach-omap2/board-sholes-spi.c
- +++ b/arch/arm/mach-omap2/board-sholes-spi.c
- @@ -131,6 +131,10 @@ struct regulator_consumer_supply cpcap_vcsi_consumers[] = {
- REGULATOR_CONSUMER("vdds_dsi", &sholes_dss_device.dev),
- };
- +struct regulator_consumer_supply cpcap_vwlan1_consumers[] = {
- + REGULATOR_CONSUMER("vwlan1", NULL /* cpcap_cam_device */),
- +};
- +
- struct regulator_consumer_supply cpcap_vwlan2_consumers[] = {
- REGULATOR_CONSUMER("vwlan2", NULL /* sd slot */),
- };
- @@ -256,6 +260,8 @@ static struct regulator_init_data cpcap_regulator[CPCAP_NUM_REGULATORS] = {
- .max_uV = 1900000,
- .valid_ops_mask = 0,
- },
- + .num_consumer_supplies = ARRAY_SIZE(cpcap_vwlan1_consumers),
- + .consumer_supplies = cpcap_vwlan1_consumers,
- },
- [CPCAP_VWLAN2] = {
- .constraints = {
- diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
- index c3043f8..5a405e2 100644
- --- a/drivers/regulator/core.c
- +++ b/drivers/regulator/core.c
- @@ -1200,21 +1200,16 @@ void regulator_put(struct regulator *regulator)
- }
- EXPORT_SYMBOL_GPL(regulator_put);
- -static int _regulator_can_change_status(struct regulator_dev *rdev)
- -{
- - if (!rdev->constraints)
- - return 0;
- -
- - if (rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_STATUS)
- - return 1;
- - else
- - return 0;
- -}
- -
- /* locks held by regulator_enable() */
- static int _regulator_enable(struct regulator_dev *rdev)
- {
- - int ret;
- + int ret = -EINVAL;
- +
- + if (!rdev->constraints) {
- + printk(KERN_ERR "%s: %s has no constraints\n",
- + __func__, rdev->desc->name);
- + return ret;
- + }
- /* do we need to enable the supply regulator first */
- if (rdev->supply) {
- @@ -1227,35 +1222,26 @@ static int _regulator_enable(struct regulator_dev *rdev)
- }
- /* check voltage and requested load before enabling */
- - if (rdev->constraints &&
- - (rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_DRMS))
- - drms_uA_update(rdev);
- + if (rdev->desc->ops->enable) {
- - if (rdev->use_count == 0) {
- - /* The regulator may on if it's not switchable or left on */
- - ret = _regulator_is_enabled(rdev);
- - if (ret == -EINVAL || ret == 0) {
- - if (!_regulator_can_change_status(rdev))
- - return -EPERM;
- -
- - if (rdev->desc->ops->enable) {
- - ret = rdev->desc->ops->enable(rdev);
- - if (ret < 0)
- - return ret;
- - } else {
- - return -EINVAL;
- - }
- - } else if (ret < 0) {
- - printk(KERN_ERR "%s: is_enabled() failed for %s: %d\n",
- + if (rdev->constraints &&
- + (rdev->constraints->valid_ops_mask &
- + REGULATOR_CHANGE_DRMS))
- + drms_uA_update(rdev);
- +
- + ret = rdev->desc->ops->enable(rdev);
- + if (ret < 0) {
- + printk(KERN_ERR "%s: failed to enable %s: %d\n",
- __func__, rdev->desc->name, ret);
- return ret;
- }
- - /* Fallthrough on positive return values - already enabled */
- + rdev->use_count++;
- + return ret;
- }
- rdev->use_count++;
- - return 0;
- + return ret;
- }
- /**
- @@ -1296,8 +1282,7 @@ static int _regulator_disable(struct regulator_dev *rdev)
- (rdev->constraints && !rdev->constraints->always_on)) {
- /* we are last user */
- - if (_regulator_can_change_status(rdev) &&
- - rdev->desc->ops->disable) {
- + if (rdev->desc->ops->disable) {
- ret = rdev->desc->ops->disable(rdev);
- if (ret < 0) {
- printk(KERN_ERR "%s: failed to disable %s\n",
- --
- 1.7.8.3
Add Comment
Please, Sign In to add comment