Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: atomisp: place all gpio parsing together

Instead of parsing GPIO for two exceptions inside the logic
which would be trying to use the GPIO, move the init code
to the routine which adds a new gmin device.

Move the notes to it too, as this helps to identify where
those two GPIO settings are used, explaining why they're
defaulting to -1 when not found.

Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

+40 -46
+40 -46
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
··· 83 83 bool v1p2_on; 84 84 bool v2p8_vcm_on; 85 85 86 + int v1p8_gpio; 87 + int v2p8_gpio; 88 + 86 89 u8 pwm_i2c_addr; 87 90 88 91 /* For PMIC AXP */ ··· 124 121 static const struct atomisp_platform_data pdata = { 125 122 .subdevs = pdata_subdevs, 126 123 }; 127 - 128 - /* 129 - * Something of a hack. The ECS E7 board drives camera 2.8v from an 130 - * external regulator instead of the PMIC. There's a gmin_CamV2P8 131 - * config variable that specifies the GPIO to handle this particular 132 - * case, but this needs a broader architecture for handling camera 133 - * power. 134 - */ 135 - enum { V2P8_GPIO_UNSET = -2, V2P8_GPIO_NONE = -1 }; 136 - static int v2p8_gpio = V2P8_GPIO_UNSET; 137 - 138 - /* 139 - * Something of a hack. The CHT RVP board drives camera 1.8v from an 140 - * external regulator instead of the PMIC just like ECS E7 board, see the 141 - * comments above. 142 - */ 143 - enum { V1P8_GPIO_UNSET = -2, V1P8_GPIO_NONE = -1 }; 144 - static int v1p8_gpio = V1P8_GPIO_UNSET; 145 124 146 125 static LIST_HEAD(vcm_devices); 147 126 static DEFINE_MUTEX(vcm_lock); ··· 534 549 dev_info(dev, "will handle gpio1 via ACPI\n"); 535 550 536 551 /* 552 + * Those are used only when there is an external regulator apart 553 + * from the PMIC that would be providing power supply, like on the 554 + * two cases below: 555 + * 556 + * The ECS E7 board drives camera 2.8v from an external regulator 557 + * instead of the PMIC. There's a gmin_CamV2P8 config variable 558 + * that specifies the GPIO to handle this particular case, 559 + * but this needs a broader architecture for handling camera power. 560 + * 561 + * The CHT RVP board drives camera 1.8v from an* external regulator 562 + * instead of the PMIC just like ECS E7 board. 563 + */ 564 + 565 + gs->v1p8_gpio = gmin_get_var_int(dev, true, "V1P8GPIO", -1); 566 + gs->v2p8_gpio = gmin_get_var_int(dev, true, "V2P8GPIO", -1); 567 + 568 + /* 537 569 * FIXME: 538 570 * 539 571 * The ACPI handling code checks for the _PR? tables in order to ··· 832 830 833 831 dev = &client->dev; 834 832 835 - if (v1p8_gpio == V1P8_GPIO_UNSET) { 836 - v1p8_gpio = gmin_get_var_int(dev, true, 837 - "V1P8GPIO", V1P8_GPIO_NONE); 838 - if (v1p8_gpio != V1P8_GPIO_NONE) { 839 - pr_info("atomisp_gmin_platform: 1.8v power on GPIO %d\n", 840 - v1p8_gpio); 841 - ret = gpio_request(v1p8_gpio, "camera_v1p8_en"); 842 - if (!ret) 843 - ret = gpio_direction_output(v1p8_gpio, 0); 844 - if (ret) 845 - pr_err("V1P8 GPIO initialization failed\n"); 846 - } 833 + if (gs->v1p8_gpio >= 0) { 834 + pr_info("atomisp_gmin_platform: 1.8v power on GPIO %d\n", 835 + gs->v1p8_gpio); 836 + ret = gpio_request(gs->v1p8_gpio, "camera_v1p8_en"); 837 + if (!ret) 838 + ret = gpio_direction_output(gs->v1p8_gpio, 0); 839 + if (ret) 840 + pr_err("V1P8 GPIO initialization failed\n"); 847 841 } 848 842 849 843 if (!gs || gs->v1p8_on == on) 850 844 return 0; 851 845 gs->v1p8_on = on; 852 846 853 - if (v1p8_gpio >= 0) 854 - gpio_set_value(v1p8_gpio, on); 847 + if (gs->v1p8_gpio >= 0) 848 + gpio_set_value(gs->v1p8_gpio, on); 855 849 856 850 if (gs->v1p8_reg) { 857 851 regulator_set_voltage(gs->v1p8_reg, 1800000, 1800000); ··· 890 892 891 893 dev = &client->dev; 892 894 893 - if (v2p8_gpio == V2P8_GPIO_UNSET) { 894 - v2p8_gpio = gmin_get_var_int(dev, true, 895 - "V2P8GPIO", V2P8_GPIO_NONE); 896 - if (v2p8_gpio != V2P8_GPIO_NONE) { 897 - pr_info("atomisp_gmin_platform: 2.8v power on GPIO %d\n", 898 - v2p8_gpio); 899 - ret = gpio_request(v2p8_gpio, "camera_v2p8"); 900 - if (!ret) 901 - ret = gpio_direction_output(v2p8_gpio, 0); 902 - if (ret) 903 - pr_err("V2P8 GPIO initialization failed\n"); 904 - } 895 + if (gs->v2p8_gpio >= 0) { 896 + pr_info("atomisp_gmin_platform: 2.8v power on GPIO %d\n", 897 + gs->v2p8_gpio); 898 + ret = gpio_request(gs->v2p8_gpio, "camera_v2p8"); 899 + if (!ret) 900 + ret = gpio_direction_output(gs->v2p8_gpio, 0); 901 + if (ret) 902 + pr_err("V2P8 GPIO initialization failed\n"); 905 903 } 906 904 907 905 if (!gs || gs->v2p8_on == on) 908 906 return 0; 909 907 gs->v2p8_on = on; 910 908 911 - if (v2p8_gpio >= 0) 912 - gpio_set_value(v2p8_gpio, on); 909 + if (gs->v2p8_gpio >= 0) 910 + gpio_set_value(gs->v2p8_gpio, on); 913 911 914 912 if (gs->v2p8_reg) { 915 913 regulator_set_voltage(gs->v2p8_reg, 2900000, 2900000);