Guest User

Untitled

a guest
May 24th, 2018
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.54 KB | None | 0 0
  1. From bd3148174cea71b80c38303c1de579a1c1c96d67 Mon Sep 17 00:00:00 2001
  2. From: stlifey <stlifey@gmail.com>
  3. Date: Mon, 16 Jan 2012 15:03:27 +0800
  4. Subject: [PATCH] enable vwlan1
  5.  
  6. ---
  7. arch/arm/mach-omap2/board-sholes-camera.c | 68 ++++++++++++++++++++++-------
  8. arch/arm/mach-omap2/board-sholes-spi.c | 6 +++
  9. drivers/regulator/core.c | 55 ++++++++---------------
  10. 3 files changed, 78 insertions(+), 51 deletions(-)
  11.  
  12. diff --git a/arch/arm/mach-omap2/board-sholes-camera.c b/arch/arm/mach-omap2/board-sholes-camera.c
  13. index fc65747..df9326c 100644
  14. --- a/arch/arm/mach-omap2/board-sholes-camera.c
  15. +++ b/arch/arm/mach-omap2/board-sholes-camera.c
  16. @@ -1,5 +1,5 @@
  17. /*
  18. - * linux/arch/arm/mach-omap2/board-mapphone-camera.c
  19. + * linux/arch/arm/mach-omap2/board-sholes-camera.c
  20. *
  21. * Copyright (C) 2009 Motorola, Inc.
  22. *
  23. @@ -140,7 +140,8 @@ static struct isp_interface_config mt9p012_if_config = {
  24. static int mt9p012_sensor_power_set(struct device *dev, enum v4l2_power power)
  25. {
  26. static enum v4l2_power previous_power = V4L2_POWER_OFF;
  27. - static struct regulator *regulator;
  28. + static struct regulator *regulator_vcam;
  29. + static struct regulator *regulator_vwlan1;
  30.  
  31. switch (power) {
  32. case V4L2_POWER_OFF:
  33. @@ -148,10 +149,10 @@ static int mt9p012_sensor_power_set(struct device *dev, enum v4l2_power power)
  34. gpio_free(GPIO_MT9P012_RESET);
  35.  
  36. /* Turn off power */
  37. - if (regulator != NULL) {
  38. - regulator_disable(regulator);
  39. - regulator_put(regulator);
  40. - regulator = NULL;
  41. + if (regulator_vcam != NULL) {
  42. + regulator_disable(regulator_vcam);
  43. + regulator_put(regulator_vcam);
  44. + regulator_vcam = NULL;
  45. } else {
  46. sholes_camera_lines_safe_mode();
  47. pr_err("%s: Regulator for vcam is not "\
  48. @@ -159,6 +160,21 @@ static int mt9p012_sensor_power_set(struct device *dev, enum v4l2_power power)
  49. return -EIO;
  50. }
  51.  
  52. + /* Delay 6 msec for vcam to drop (4.7uF to 10uF change) */
  53. + msleep(6);
  54. +
  55. + /* Turn off power */
  56. + if (regulator_vwlan1 != NULL) {
  57. + regulator_disable(regulator_vwlan1);
  58. + regulator_put(regulator_vwlan1);
  59. + regulator_vwlan1 = NULL;
  60. + } else {
  61. + sholes_camera_lines_safe_mode();
  62. + pr_err("%s: Regulator for vwlan1 is not "\
  63. + "initialized\n", __func__);
  64. + return -EIO;
  65. + }
  66. +
  67. /* Release pm constraints */
  68. omap_pm_set_min_bus_tput(dev, OCP_INITIATOR_AGENT, 0);
  69. sholes_camera_lines_safe_mode();
  70. @@ -187,22 +203,42 @@ static int mt9p012_sensor_power_set(struct device *dev, enum v4l2_power power)
  71. /* nRESET is active LOW. set HIGH to release reset */
  72. gpio_set_value(GPIO_MT9P012_RESET, 1);
  73.  
  74. - /* turn on digital power */
  75. - if (regulator != NULL) {
  76. + /* turn on VWLAN1 power */
  77. + if (regulator_vwlan1 != NULL) {
  78. + pr_warning("%s: Already have "\
  79. + "regulator_vwlan1 \n", __func__);
  80. + } else {
  81. + regulator_vwlan1 = regulator_get(NULL, "vwlan1");
  82. + if (IS_ERR(regulator_vwlan1)) {
  83. + pr_err("%s: Cannot get vwlan1 "\
  84. + "regulator_vwlan1, err=%ld\n",
  85. + __func__, PTR_ERR(regulator_vwlan1));
  86. + return PTR_ERR(regulator_vwlan1);
  87. + }
  88. + }
  89. +
  90. + if (regulator_enable(regulator_vwlan1) != 0) {
  91. + pr_err("%s: Cannot enable vcam regulator_vwlan1\n",
  92. + __func__);
  93. + return -EIO;
  94. + }
  95. +
  96. + /* turn on VCAM power */
  97. + if (regulator_vcam != NULL) {
  98. pr_warning("%s: Already have "\
  99. - "regulator\n", __func__);
  100. + "regulator_vcam\n", __func__);
  101. } else {
  102. - regulator = regulator_get(NULL, "vcam");
  103. - if (IS_ERR(regulator)) {
  104. + regulator_vcam = regulator_get(NULL, "vcam");
  105. + if (IS_ERR(regulator_vcam)) {
  106. pr_err("%s: Cannot get vcam "\
  107. - "regulator, err=%ld\n",
  108. - __func__, PTR_ERR(regulator));
  109. - return PTR_ERR(regulator);
  110. + "regulator_vcam, err=%ld\n",
  111. + __func__, PTR_ERR(regulator_vcam));
  112. + return PTR_ERR(regulator_vcam);
  113. }
  114. }
  115.  
  116. - if (regulator_enable(regulator) != 0) {
  117. - pr_err("%s: Cannot enable vcam regulator\n",
  118. + if (regulator_enable(regulator_vcam) != 0) {
  119. + pr_err("%s: Cannot enable vcam regulator_vcam\n",
  120. __func__);
  121. return -EIO;
  122. }
  123. diff --git a/arch/arm/mach-omap2/board-sholes-spi.c b/arch/arm/mach-omap2/board-sholes-spi.c
  124. index 01d557e..fa56d9a 100644
  125. --- a/arch/arm/mach-omap2/board-sholes-spi.c
  126. +++ b/arch/arm/mach-omap2/board-sholes-spi.c
  127. @@ -131,6 +131,10 @@ struct regulator_consumer_supply cpcap_vcsi_consumers[] = {
  128. REGULATOR_CONSUMER("vdds_dsi", &sholes_dss_device.dev),
  129. };
  130.  
  131. +struct regulator_consumer_supply cpcap_vwlan1_consumers[] = {
  132. + REGULATOR_CONSUMER("vwlan1", NULL /* cpcap_cam_device */),
  133. +};
  134. +
  135. struct regulator_consumer_supply cpcap_vwlan2_consumers[] = {
  136. REGULATOR_CONSUMER("vwlan2", NULL /* sd slot */),
  137. };
  138. @@ -256,6 +260,8 @@ static struct regulator_init_data cpcap_regulator[CPCAP_NUM_REGULATORS] = {
  139. .max_uV = 1900000,
  140. .valid_ops_mask = 0,
  141. },
  142. + .num_consumer_supplies = ARRAY_SIZE(cpcap_vwlan1_consumers),
  143. + .consumer_supplies = cpcap_vwlan1_consumers,
  144. },
  145. [CPCAP_VWLAN2] = {
  146. .constraints = {
  147. diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
  148. index c3043f8..5a405e2 100644
  149. --- a/drivers/regulator/core.c
  150. +++ b/drivers/regulator/core.c
  151. @@ -1200,21 +1200,16 @@ void regulator_put(struct regulator *regulator)
  152. }
  153. EXPORT_SYMBOL_GPL(regulator_put);
  154.  
  155. -static int _regulator_can_change_status(struct regulator_dev *rdev)
  156. -{
  157. - if (!rdev->constraints)
  158. - return 0;
  159. -
  160. - if (rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_STATUS)
  161. - return 1;
  162. - else
  163. - return 0;
  164. -}
  165. -
  166. /* locks held by regulator_enable() */
  167. static int _regulator_enable(struct regulator_dev *rdev)
  168. {
  169. - int ret;
  170. + int ret = -EINVAL;
  171. +
  172. + if (!rdev->constraints) {
  173. + printk(KERN_ERR "%s: %s has no constraints\n",
  174. + __func__, rdev->desc->name);
  175. + return ret;
  176. + }
  177.  
  178. /* do we need to enable the supply regulator first */
  179. if (rdev->supply) {
  180. @@ -1227,35 +1222,26 @@ static int _regulator_enable(struct regulator_dev *rdev)
  181. }
  182.  
  183. /* check voltage and requested load before enabling */
  184. - if (rdev->constraints &&
  185. - (rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_DRMS))
  186. - drms_uA_update(rdev);
  187. + if (rdev->desc->ops->enable) {
  188.  
  189. - if (rdev->use_count == 0) {
  190. - /* The regulator may on if it's not switchable or left on */
  191. - ret = _regulator_is_enabled(rdev);
  192. - if (ret == -EINVAL || ret == 0) {
  193. - if (!_regulator_can_change_status(rdev))
  194. - return -EPERM;
  195. -
  196. - if (rdev->desc->ops->enable) {
  197. - ret = rdev->desc->ops->enable(rdev);
  198. - if (ret < 0)
  199. - return ret;
  200. - } else {
  201. - return -EINVAL;
  202. - }
  203. - } else if (ret < 0) {
  204. - printk(KERN_ERR "%s: is_enabled() failed for %s: %d\n",
  205. + if (rdev->constraints &&
  206. + (rdev->constraints->valid_ops_mask &
  207. + REGULATOR_CHANGE_DRMS))
  208. + drms_uA_update(rdev);
  209. +
  210. + ret = rdev->desc->ops->enable(rdev);
  211. + if (ret < 0) {
  212. + printk(KERN_ERR "%s: failed to enable %s: %d\n",
  213. __func__, rdev->desc->name, ret);
  214. return ret;
  215. }
  216. - /* Fallthrough on positive return values - already enabled */
  217. + rdev->use_count++;
  218. + return ret;
  219. }
  220.  
  221. rdev->use_count++;
  222.  
  223. - return 0;
  224. + return ret;
  225. }
  226.  
  227. /**
  228. @@ -1296,8 +1282,7 @@ static int _regulator_disable(struct regulator_dev *rdev)
  229. (rdev->constraints && !rdev->constraints->always_on)) {
  230.  
  231. /* we are last user */
  232. - if (_regulator_can_change_status(rdev) &&
  233. - rdev->desc->ops->disable) {
  234. + if (rdev->desc->ops->disable) {
  235. ret = rdev->desc->ops->disable(rdev);
  236. if (ret < 0) {
  237. printk(KERN_ERR "%s: failed to disable %s\n",
  238. --
  239. 1.7.8.3
Add Comment
Please, Sign In to add comment