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

media: mt9m114: Set pad-slew-rate

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 '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@mt.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>

authored by

Mathis Foerst and committed by
Hans Verkuil
9db72db2 b541288c

+23 -3
+23 -3
drivers/media/i2c/mt9m114.c
··· 18 18 #include <linux/module.h> 19 19 #include <linux/mutex.h> 20 20 #include <linux/pm_runtime.h> 21 + #include <linux/property.h> 21 22 #include <linux/regmap.h> 22 23 #include <linux/regulator/consumer.h> 23 24 #include <linux/types.h> ··· 43 42 #define MT9M114_RESET_AND_MISC_CONTROL CCI_REG16(0x001a) 44 43 #define MT9M114_RESET_SOC BIT(0) 45 44 #define MT9M114_PAD_SLEW CCI_REG16(0x001e) 45 + #define MT9M114_PAD_SLEW_MIN 0 46 + #define MT9M114_PAD_SLEW_MAX 7 47 + #define MT9M114_PAD_SLEW_DEFAULT 7 46 48 #define MT9M114_PAD_CONTROL CCI_REG16(0x0032) 47 49 48 50 /* XDMA registers */ ··· 392 388 393 389 unsigned int pixrate; 394 390 bool streaming; 391 + u32 pad_slew_rate; 395 392 396 393 /* Pixel Array */ 397 394 struct { ··· 650 645 { MT9M114_CAM_SENSOR_CFG_FINE_INTEG_TIME_MAX, 1459 }, 651 646 { MT9M114_CAM_SENSOR_CFG_FINE_CORRECTION, 96 }, 652 647 { MT9M114_CAM_SENSOR_CFG_REG_0_DATA, 32 }, 653 - 654 - /* Miscellaneous settings */ 655 - { MT9M114_PAD_SLEW, 0x0777 }, 656 648 }; 657 649 658 650 /* ----------------------------------------------------------------------------- ··· 778 776 | 0x8000; 779 777 } 780 778 cci_write(sensor->regmap, MT9M114_CAM_PORT_OUTPUT_CONTROL, value, &ret); 779 + if (ret < 0) 780 + return ret; 781 + 782 + value = sensor->pad_slew_rate 783 + | sensor->pad_slew_rate << 4 784 + | sensor->pad_slew_rate << 8; 785 + cci_write(sensor->regmap, MT9M114_PAD_SLEW, value, &ret); 781 786 if (ret < 0) 782 787 return ret; 783 788 ··· 2389 2380 sensor->bus_cfg.bus_type); 2390 2381 ret = -EINVAL; 2391 2382 goto error; 2383 + } 2384 + 2385 + sensor->pad_slew_rate = MT9M114_PAD_SLEW_DEFAULT; 2386 + device_property_read_u32(&sensor->client->dev, "slew-rate", 2387 + &sensor->pad_slew_rate); 2388 + 2389 + if (sensor->pad_slew_rate < MT9M114_PAD_SLEW_MIN || 2390 + sensor->pad_slew_rate > MT9M114_PAD_SLEW_MAX) { 2391 + dev_err(&sensor->client->dev, "Invalid slew-rate %u\n", 2392 + sensor->pad_slew_rate); 2393 + return -EINVAL; 2392 2394 } 2393 2395 2394 2396 return 0;