The MT9M114 supports the different slew rates (0 to 7) on the output pads. At the moment, this is hardcoded to 7 (the fastest rate). The user might want to change this values due to EMC requirements. Read the 'pad-slew-rate' from the DT and configure the pad slew rates of the output pads accordingly in mt9m114_initialize(). Remove the hardcoded slew rate setting from the mt9m114_init table. Signed-off-by: Mathis Foerst <mathis.foerst@xxxxxx> --- drivers/media/i2c/mt9m114.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c index f96f6c010e1b..327384e8427d 100644 --- a/drivers/media/i2c/mt9m114.c +++ b/drivers/media/i2c/mt9m114.c @@ -42,6 +42,9 @@ #define MT9M114_RESET_AND_MISC_CONTROL CCI_REG16(0x001a) #define MT9M114_RESET_SOC BIT(0) #define MT9M114_PAD_SLEW CCI_REG16(0x001e) +#define MT9M114_PAD_SLEW_MIN 0x00 +#define MT9M114_PAD_SLEW_MAX 0x07 +#define MT9M114_PAD_SLEW_DEFAULT 0x07 #define MT9M114_PAD_CONTROL CCI_REG16(0x0032) /* XDMA registers */ @@ -388,6 +391,7 @@ struct mt9m114 { unsigned int pixrate; bool streaming; + u8 pad_slew_rate; /* Pixel Array */ struct { @@ -645,9 +649,6 @@ static const struct cci_reg_sequence mt9m114_init[] = { { MT9M114_CAM_SENSOR_CFG_FINE_INTEG_TIME_MAX, 1459 }, { MT9M114_CAM_SENSOR_CFG_FINE_CORRECTION, 96 }, { MT9M114_CAM_SENSOR_CFG_REG_0_DATA, 32 }, - - /* Miscellaneous settings */ - { MT9M114_PAD_SLEW, 0x0777 }, }; /* ----------------------------------------------------------------------------- @@ -778,6 +779,13 @@ static int mt9m114_initialize(struct mt9m114 *sensor) if (ret < 0) return ret; + value = sensor->pad_slew_rate | + sensor->pad_slew_rate << 4 | + sensor->pad_slew_rate << 8; + cci_write(sensor->regmap, MT9M114_PAD_SLEW, value, &ret); + if (ret < 0) + return ret; + ret = mt9m114_set_state(sensor, MT9M114_SYS_STATE_ENTER_CONFIG_CHANGE); if (ret < 0) return ret; @@ -2363,6 +2371,7 @@ static int mt9m114_parse_dt(struct mt9m114 *sensor) struct fwnode_handle *fwnode = dev_fwnode(&sensor->client->dev); struct fwnode_handle *ep; struct device_node *dev_node = sensor->client->dev.of_node; + u8 slew_rate; int ret; ep = fwnode_graph_get_next_endpoint(fwnode, NULL); @@ -2393,6 +2402,11 @@ static int mt9m114_parse_dt(struct mt9m114 *sensor) sensor->bypass_pll = of_property_read_bool(dev_node, "bypass-pll"); + ret = of_property_read_u8(dev_node, "pad-slew-rate", &slew_rate); + if (ret || slew_rate < MT9M114_PAD_SLEW_MIN || slew_rate > MT9M114_PAD_SLEW_MAX) + slew_rate = MT9M114_PAD_SLEW_DEFAULT; + sensor->pad_slew_rate = slew_rate; + return 0; error: -- 2.34.1