Lines Matching +full:svddio +full:- +full:supply
1 // SPDX-License-Identifier: GPL-2.0-only
22 #include <media/v4l2-async.h>
23 #include <media/v4l2-subdev.h>
45 * struct s5k6a3 - fimc-is sensor data structure
72 [S5K6A3_SUPP_VDDIO] = "svddio",
95 if (mf->code == s5k6a3_formats[i].code) in find_sensor_format()
105 if (code->index >= ARRAY_SIZE(s5k6a3_formats)) in s5k6a3_enum_mbus_code()
106 return -EINVAL; in s5k6a3_enum_mbus_code()
108 code->code = s5k6a3_formats[code->index].code; in s5k6a3_enum_mbus_code()
117 mf->code = fmt->code; in s5k6a3_try_format()
118 mf->field = V4L2_FIELD_NONE; in s5k6a3_try_format()
119 v4l_bound_align_image(&mf->width, S5K6A3_SENSOR_MIN_WIDTH, in s5k6a3_try_format()
121 &mf->height, S5K6A3_SENSOR_MIN_HEIGHT, in s5k6a3_try_format()
132 return &sensor->format; in __s5k6a3_get_format()
142 s5k6a3_try_format(&fmt->format); in s5k6a3_set_fmt()
144 mf = __s5k6a3_get_format(sensor, sd_state, fmt->pad, fmt->which); in s5k6a3_set_fmt()
146 mutex_lock(&sensor->lock); in s5k6a3_set_fmt()
147 *mf = fmt->format; in s5k6a3_set_fmt()
148 mutex_unlock(&sensor->lock); in s5k6a3_set_fmt()
160 mf = __s5k6a3_get_format(sensor, sd_state, fmt->pad, fmt->which); in s5k6a3_get_fmt()
162 mutex_lock(&sensor->lock); in s5k6a3_get_fmt()
163 fmt->format = *mf; in s5k6a3_get_fmt()
164 mutex_unlock(&sensor->lock); in s5k6a3_get_fmt()
176 struct v4l2_mbus_framefmt *format = v4l2_subdev_state_get_format(fh->state, in s5k6a3_open()
180 format->width = S5K6A3_DEFAULT_WIDTH; in s5k6a3_open()
181 format->height = S5K6A3_DEFAULT_HEIGHT; in s5k6a3_open()
195 ret = clk_set_rate(sensor->clock, sensor->clock_frequency); in __s5k6a3_power_on()
199 ret = pm_runtime_get(sensor->dev); in __s5k6a3_power_on()
203 ret = regulator_enable(sensor->supplies[i].consumer); in __s5k6a3_power_on()
207 ret = clk_prepare_enable(sensor->clock); in __s5k6a3_power_on()
212 ret = regulator_enable(sensor->supplies[i].consumer); in __s5k6a3_power_on()
217 gpiod_set_value_cansleep(sensor->gpio_reset, 0); in __s5k6a3_power_on()
219 gpiod_set_value_cansleep(sensor->gpio_reset, 1); in __s5k6a3_power_on()
221 gpiod_set_value_cansleep(sensor->gpio_reset, 0); in __s5k6a3_power_on()
228 clk_disable_unprepare(sensor->clock); in __s5k6a3_power_on()
230 for (--i; i >= 0; --i) in __s5k6a3_power_on()
231 regulator_disable(sensor->supplies[i].consumer); in __s5k6a3_power_on()
233 pm_runtime_put(sensor->dev); in __s5k6a3_power_on()
241 gpiod_set_value_cansleep(sensor->gpio_reset, 1); in __s5k6a3_power_off()
243 for (i = S5K6A3_NUM_SUPPLIES - 1; i >= 0; i--) in __s5k6a3_power_off()
244 regulator_disable(sensor->supplies[i].consumer); in __s5k6a3_power_off()
246 clk_disable_unprepare(sensor->clock); in __s5k6a3_power_off()
247 pm_runtime_put(sensor->dev); in __s5k6a3_power_off()
256 mutex_lock(&sensor->lock); in s5k6a3_s_power()
258 if (sensor->power_count == !on) { in s5k6a3_s_power()
265 sensor->power_count += on ? 1 : -1; in s5k6a3_s_power()
268 mutex_unlock(&sensor->lock); in s5k6a3_s_power()
283 struct device *dev = &client->dev; in s5k6a3_probe()
290 return -ENOMEM; in s5k6a3_probe()
292 mutex_init(&sensor->lock); in s5k6a3_probe()
293 sensor->dev = dev; in s5k6a3_probe()
295 sensor->clock = devm_clk_get(sensor->dev, S5K6A3_CLK_NAME); in s5k6a3_probe()
296 if (IS_ERR(sensor->clock)) in s5k6a3_probe()
297 return PTR_ERR(sensor->clock); in s5k6a3_probe()
299 sensor->gpio_reset = devm_gpiod_get(dev, NULL, GPIOD_OUT_HIGH); in s5k6a3_probe()
300 ret = PTR_ERR_OR_ZERO(sensor->gpio_reset); in s5k6a3_probe()
304 if (of_property_read_u32(dev->of_node, "clock-frequency", in s5k6a3_probe()
305 &sensor->clock_frequency)) { in s5k6a3_probe()
306 sensor->clock_frequency = S5K6A3_DEFAULT_CLK_FREQ; in s5k6a3_probe()
308 sensor->clock_frequency); in s5k6a3_probe()
312 sensor->supplies[i].supply = s5k6a3_supply_names[i]; in s5k6a3_probe()
314 ret = devm_regulator_bulk_get(&client->dev, S5K6A3_NUM_SUPPLIES, in s5k6a3_probe()
315 sensor->supplies); in s5k6a3_probe()
319 sd = &sensor->subdev; in s5k6a3_probe()
321 sensor->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in s5k6a3_probe()
322 sd->internal_ops = &s5k6a3_sd_internal_ops; in s5k6a3_probe()
324 sensor->format.code = s5k6a3_formats[0].code; in s5k6a3_probe()
325 sensor->format.width = S5K6A3_DEFAULT_WIDTH; in s5k6a3_probe()
326 sensor->format.height = S5K6A3_DEFAULT_HEIGHT; in s5k6a3_probe()
328 sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; in s5k6a3_probe()
329 sensor->pad.flags = MEDIA_PAD_FL_SOURCE; in s5k6a3_probe()
330 ret = media_entity_pads_init(&sd->entity, 1, &sensor->pad); in s5k6a3_probe()
340 pm_runtime_disable(&client->dev); in s5k6a3_probe()
341 media_entity_cleanup(&sd->entity); in s5k6a3_probe()
351 pm_runtime_disable(&client->dev); in s5k6a3_remove()
353 media_entity_cleanup(&sd->entity); in s5k6a3_remove()