};
};
- csi_pins_default: csi-pins-default {
- csi-pins-default {
- starfive,pins = <PAD_GPIO10>;
- starfive,pinmux = <PAD_GPIO10_FUNC_SEL 0>;
- starfive,pin-ioconfig = <IO(GPIO_IE(1))>;
- starfive,pin-gpio-dout = <GPO_LOW>;
- starfive,pin-gpio-doen = <OEN_LOW>;
- };
- };
-
- csi_pins_pwup: csi-pins-pwup {
- csi-pins-pwup {
- starfive,pins = <PAD_GPIO10>;
- starfive,pinmux = <PAD_GPIO10_FUNC_SEL 0>;
- starfive,pin-ioconfig = <IO(GPIO_IE(1))>;
- starfive,pin-gpio-dout = <GPO_HIGH>;
- starfive,pin-gpio-doen = <OEN_LOW>;
- };
- };
-
- csi_pins_pwdn: csi-pins-pwdn {
- csi-pins-pwdn {
- starfive,pins = <PAD_GPIO10>;
- starfive,pinmux = <PAD_GPIO10_FUNC_SEL 0>;
- starfive,pin-ioconfig = <IO(GPIO_IE(1))>;
- starfive,pin-gpio-dout = <GPO_LOW>;
- starfive,pin-gpio-doen = <OEN_LOW>;
- };
- };
-
mmc0_pins: mmc0-pins {
mmc0-pins-rest {
starfive,pins = <PAD_GPIO22>;
#include <media/v4l2-event.h>
#include <media/v4l2-fwnode.h>
#include <media/v4l2-mediabus.h>
-#include <linux/pinctrl/pinctrl.h>
#include <asm/unaligned.h>
#define IMX219_REG_VALUE_08BIT 1
},
};
-struct sensor_pinctrl_info {
- struct pinctrl *pinctrl;
- struct pinctrl_state *power_up;
- struct pinctrl_state *power_down;
- bool use_pinctrl;
-};
-
struct imx219 {
struct v4l2_subdev sd;
struct media_pad pad;
/* Streaming on/off */
int streaming;
-
- struct sensor_pinctrl_info imx219_pctrl;
};
-int imx219_sensor_pinctrl_init(
- struct sensor_pinctrl_info *sensor_pctrl, struct device *dev)
-{
- sensor_pctrl->pinctrl = devm_pinctrl_get(dev);
- if (IS_ERR_OR_NULL(sensor_pctrl->pinctrl)) {
- pr_err("Getting pinctrl handle failed\n");
- return -EINVAL;
- }
-
- sensor_pctrl->power_up
- = pinctrl_lookup_state(sensor_pctrl->pinctrl, "power_up");
- if (IS_ERR_OR_NULL(sensor_pctrl->power_up)) {
- pr_err("Failed to get the power_up pinctrl handle\n");
- return -EINVAL;
- }
-
- sensor_pctrl->power_down
- = pinctrl_lookup_state(sensor_pctrl->pinctrl, "power_down");
- if (IS_ERR_OR_NULL(sensor_pctrl->power_down)) {
- pr_err("Failed to get the power_down pinctrl handle\n");
- return -EINVAL;
- }
-
- sensor_pctrl->use_pinctrl = true;
-
- return 0;
-}
-
static inline struct imx219 *to_imx219(struct v4l2_subdev *_sd)
{
return container_of(_sd, struct imx219, sd);
{
struct v4l2_subdev *sd = dev_get_drvdata(dev);
struct imx219 *imx219 = to_imx219(sd);
- struct sensor_pinctrl_info *sensor_pctrl = &imx219->imx219_pctrl;
int ret;
ret = regulator_bulk_enable(IMX219_NUM_SUPPLIES, imx219->supplies);
goto reg_off;
}
- if (sensor_pctrl->use_pinctrl) {
- ret = pinctrl_select_state(
- sensor_pctrl->pinctrl,
- sensor_pctrl->power_up);
- if (ret)
- pr_err("cannot set pin to power up\n");
- } else
- gpiod_set_value_cansleep(imx219->reset_gpio, 1);
-
+ gpiod_set_value_cansleep(imx219->reset_gpio, 1);
usleep_range(IMX219_XCLR_MIN_DELAY_US,
IMX219_XCLR_MIN_DELAY_US + IMX219_XCLR_DELAY_RANGE_US);
{
struct v4l2_subdev *sd = dev_get_drvdata(dev);
struct imx219 *imx219 = to_imx219(sd);
- struct sensor_pinctrl_info *sensor_pctrl = &imx219->imx219_pctrl;
- int ret;
-
- if (sensor_pctrl->use_pinctrl) {
- ret = pinctrl_select_state(
- sensor_pctrl->pinctrl,
- sensor_pctrl->power_down);
- if (ret)
- pr_err("cannot set pin to power_down\n");
- } else
- gpiod_set_value_cansleep(imx219->reset_gpio, 0);
+ gpiod_set_value_cansleep(imx219->reset_gpio, 0);
regulator_bulk_disable(IMX219_NUM_SUPPLIES, imx219->supplies);
clk_disable_unprepare(imx219->xclk);
return ret;
}
- ret = imx219_sensor_pinctrl_init(&imx219->imx219_pctrl, dev);
- if (ret) {
- pr_err("Can't get pinctrl, use gpio to ctrl\n");
- /* Request optional enable pin */
- imx219->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
- imx219->imx219_pctrl.use_pinctrl = false;
- }
+ /* Request optional enable pin */
+ imx219->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
/*
* The sensor must be powered for imx219_identify_module()