* [PATCH 0/6] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras
@ 2026-11-23 11:07 Hikmah Gumelar
2026-11-23 11:08 ` [PATCH 1/6] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent Hikmah Gumelar
` (6 more replies)
0 siblings, 7 replies; 17+ messages in thread
From: Hikmah Gumelar @ 2026-11-23 11:07 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Bjorn Andersson, Konrad Dybcio, Michael Turquette,
Stephen Boyd, Brian Masney, Sakari Ailus
Cc: Hikmah Gumelar, linux-media, devicetree, linux-kernel,
linux-arm-msm, linux-clk
This series enables both the front (Samsung S5K5E8) and rear (OmniVision
OV12A10) MIPI CSI-2 cameras on the Xiaomi Mi A1 (msm8953-xiaomi-tissot):
- Fix the 100 MHz parent entry in ftbl_csi_phytimer_clk_src so
gcc_camss_csi0phytimer_clk enables properly on MSM8953.
- Add Devicetree binding schemas and V4L2 subdev drivers for the Samsung
S5K5E8 and OmniVision OV12A10 CMOS image sensors.
- Wire up CAMSS, CCI, CSIPHY0/CSIPHY2, and both camera sensors in
msm8953-xiaomi-tissot.dts.
Tested on Xiaomi Mi A1 (tissot) using libcamera SimpleISP and GNOME Snapshot.
Hikmah Gumelar (6):
clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent
media: dt-bindings: media: i2c: add Samsung S5K5E8
media: i2c: add s5k5e8 image sensor driver
media: dt-bindings: media: i2c: add OmniVision OV12A10
media: i2c: add ov12a10 image sensor driver
arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras
.../bindings/media/i2c/ovti,ov12a10.yaml | 115 +++
.../bindings/media/i2c/samsung,s5k5e8.yaml | 103 +++
.../boot/dts/qcom/msm8953-xiaomi-tissot.dts | 114 +++
drivers/clk/qcom/gcc-msm8953.c | 2 +-
drivers/media/i2c/Kconfig | 26 +
drivers/media/i2c/Makefile | 2 +
drivers/media/i2c/ov12a10.c | 720 ++++++++++++++++++
drivers/media/i2c/s5k5e8.c | 500 ++++++++++++
8 files changed, 1581 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml
create mode 100644 Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml
create mode 100644 drivers/media/i2c/ov12a10.c
create mode 100644 drivers/media/i2c/s5k5e8.c
--
2.47.3
^ permalink raw reply [flat|nested] 17+ messages in thread* [PATCH 1/6] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent 2026-11-23 11:07 [PATCH 0/6] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar @ 2026-11-23 11:08 ` Hikmah Gumelar 2026-11-23 11:08 ` [PATCH 2/6] media: dt-bindings: media: i2c: add Samsung S5K5E8 Hikmah Gumelar ` (5 subsequent siblings) 6 siblings, 0 replies; 17+ messages in thread From: Hikmah Gumelar @ 2026-11-23 11:08 UTC (permalink / raw) To: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Michael Turquette, Stephen Boyd, Brian Masney, Sakari Ailus Cc: Hikmah Gumelar, linux-media, devicetree, linux-kernel, linux-arm-msm, linux-clk The 100 MHz entry in ftbl_csi_phytimer_clk_src selects P_GPLL0_DIV2 with a divider of 4, which leaves gcc_camss_csi0phytimer_clk stuck off on MSM8953 platforms such as Xiaomi Mi A1 (tissot). Switch the 100 MHz parent to P_GPLL0 with a divider of 8 (800 MHz / 8 = 100 MHz), matching the 200 MHz and 266.67 MHz entries. Signed-off-by: Hikmah Gumelar <hikmahgumelar@gmail.com> --- drivers/clk/qcom/gcc-msm8953.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/qcom/gcc-msm8953.c b/drivers/clk/qcom/gcc-msm8953.c index c4ec9950ab68..3987cab327b4 100644 --- a/drivers/clk/qcom/gcc-msm8953.c +++ b/drivers/clk/qcom/gcc-msm8953.c @@ -964,7 +964,7 @@ static struct clk_rcg2 csi2p_clk_src = { }; static const struct freq_tbl ftbl_csi_phytimer_clk_src[] = { - F(100000000, P_GPLL0_DIV2, 4, 0, 0), + F(100000000, P_GPLL0, 8, 0, 0), F(200000000, P_GPLL0, 4, 0, 0), F(266670000, P_GPLL0, 3, 0, 0), { } -- 2.47.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 2/6] media: dt-bindings: media: i2c: add Samsung S5K5E8 2026-11-23 11:07 [PATCH 0/6] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar 2026-11-23 11:08 ` [PATCH 1/6] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent Hikmah Gumelar @ 2026-11-23 11:08 ` Hikmah Gumelar 2026-11-23 11:08 ` [PATCH 3/6] media: i2c: add s5k5e8 image sensor driver Hikmah Gumelar ` (4 subsequent siblings) 6 siblings, 0 replies; 17+ messages in thread From: Hikmah Gumelar @ 2026-11-23 11:08 UTC (permalink / raw) To: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Michael Turquette, Stephen Boyd, Brian Masney, Sakari Ailus Cc: Hikmah Gumelar, linux-media, devicetree, linux-kernel, linux-arm-msm, linux-clk Add Devicetree binding schema for the Samsung S5K5E8 5-megapixel MIPI CSI-2 CMOS image sensor. Signed-off-by: Hikmah Gumelar <hikmahgumelar@gmail.com> --- .../bindings/media/i2c/samsung,s5k5e8.yaml | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml diff --git a/Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml b/Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml new file mode 100644 index 000000000000..0e440209c3fd --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml @@ -0,0 +1,103 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org +$schema: http://devicetree.org + +title: Samsung S5K5E8 1/5-inch 5Mp CMOS Image Sensor + +maintainers: + - Hikmah Gumelar <hikmahgumelar@gmail.com> + +description: + Samsung S5K5E8 is a 1/5-inch 5-megapixel CMOS active-pixel digital image + sensor with a 2-lane MIPI CSI-2 interface and I2C control bus. + +allOf: + - $ref: /schemas/media/video-interface-devices.yaml# + +properties: + compatible: + const: samsung,s5k5e8 + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + reset-gpios: + description: Active-low reset GPIO. + maxItems: 1 + + avdd-supply: + description: Analog power supply (2.8V). + + dvdd-supply: + description: Digital core power supply (1.2V). + + dovdd-supply: + description: Digital I/O power supply (1.8V). + + port: + $ref: /schemas/graph.yaml#/$defs/port-base + additionalProperties: false + + properties: + endpoint: + $ref: /schemas/media/video-interfaces.yaml# + unevaluatedProperties: false + + properties: + data-lanes: + items: + - const: 0 + - const: 1 + + link-frequencies: true + + required: + - data-lanes + - link-frequencies + + required: + - endpoint + +required: + - compatible + - reg + - clocks + - avdd-supply + - dvdd-supply + - dovdd-supply + - port + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + camera-sensor@2d { + compatible = "samsung,s5k5e8"; + reg = <0x2d>; + clocks = <&camss_mclk1>; + reset-gpios = <&tlmm 129 GPIO_ACTIVE_LOW>; + avdd-supply = <&pm8953_l22>; + dvdd-supply = <&pm8953_l23>; + dovdd-supply = <&pm8953_l6>; + + port { + endpoint { + data-lanes = <0 1>; + remote-endpoint = <&csiphy2_ep>; + link-frequencies = /bits/ 64 <418000000>; + }; + }; + }; + }; +... -- 2.47.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 3/6] media: i2c: add s5k5e8 image sensor driver 2026-11-23 11:07 [PATCH 0/6] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar 2026-11-23 11:08 ` [PATCH 1/6] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent Hikmah Gumelar 2026-11-23 11:08 ` [PATCH 2/6] media: dt-bindings: media: i2c: add Samsung S5K5E8 Hikmah Gumelar @ 2026-11-23 11:08 ` Hikmah Gumelar 2026-11-23 11:08 ` [PATCH 4/6] media: dt-bindings: media: i2c: add OmniVision OV12A10 Hikmah Gumelar ` (3 subsequent siblings) 6 siblings, 0 replies; 17+ messages in thread From: Hikmah Gumelar @ 2026-11-23 11:08 UTC (permalink / raw) To: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Michael Turquette, Stephen Boyd, Brian Masney, Sakari Ailus Cc: Hikmah Gumelar, linux-media, devicetree, linux-kernel, linux-arm-msm, linux-clk Add V4L2 subdev driver for the Samsung S5K5E8 5MP MIPI CSI-2 image sensor supporting 2592x1944 raw10 capture. Signed-off-by: Hikmah Gumelar <hikmahgumelar@gmail.com> --- drivers/media/i2c/Kconfig | 13 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/s5k5e8.c | 500 +++++++++++++++++++++++++++++++++++++ 3 files changed, 514 insertions(+) create mode 100644 drivers/media/i2c/s5k5e8.c diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index e9e405ac94e4..3a0a041a4c2b 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig @@ -805,6 +805,19 @@ config VIDEO_S5K3M5 To compile this driver as a module, choose M here: the module will be called s5k3m5. +config VIDEO_S5K5E8 + tristate "Samsung S5K5E8 sensor support" + depends on I2C && VIDEO_DEV + select MEDIA_CONTROLLER + select VIDEO_V4L2_SUBDEV_API + select V4L2_FWNODE + help + This is a Video4Linux2 sensor driver for the Samsung + S5K5E8 camera. + + To compile this driver as a module, choose M here: the + module will be called s5k5e8. + config VIDEO_S5K5BAF tristate "Samsung S5K5BAF sensor support" help diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile index 393927f55e05..f93d7205817d 100644 --- a/drivers/media/i2c/Makefile +++ b/drivers/media/i2c/Makefile @@ -130,6 +130,7 @@ obj-$(CONFIG_VIDEO_SIMPLE_LENS) += simple-lens.o obj-$(CONFIG_VIDEO_S5C73M3) += s5c73m3/ obj-$(CONFIG_VIDEO_S5K2XX) += s5k2xx.o obj-$(CONFIG_VIDEO_S5K3M5) += s5k3m5.o +obj-$(CONFIG_VIDEO_S5K5E8) += s5k5e8.o obj-$(CONFIG_VIDEO_S5K5BAF) += s5k5baf.o obj-$(CONFIG_VIDEO_S5K6A3) += s5k6a3.o obj-$(CONFIG_VIDEO_S5KJN1) += s5kjn1.o diff --git a/drivers/media/i2c/s5k5e8.c b/drivers/media/i2c/s5k5e8.c new file mode 100644 index 000000000000..26a8d2410e9d --- /dev/null +++ b/drivers/media/i2c/s5k5e8.c @@ -0,0 +1,500 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/gpio/consumer.h> +#include <linux/i2c.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/pm_runtime.h> +#include <linux/regulator/consumer.h> +#include <linux/unaligned.h> +#include <media/v4l2-ctrls.h> +#include <media/v4l2-device.h> +#include <media/v4l2-fwnode.h> + +#define S5K5E8_CHIP_ID_REG 0x0000 +#define S5K5E8_CHIP_ID 0x5e80 +#define S5K5E8_REG_MODE_SELECT 0x0100 +#define S5K5E8_MODE_STANDBY 0x00 +#define S5K5E8_MODE_STREAMING 0x01 +#define S5K5E8_REG_VTS 0x0340 +#define S5K5E8_REG_EXPOSURE 0x0202 +#define S5K5E8_REG_ANALOG_GAIN 0x0204 +#define S5K5E8_REG_TEST_PATTERN 0x0600 +#define S5K5E8_XVCLK_FREQ 24000000 +#define S5K5E8_LINK_FREQ_418MHZ 418000000ULL +#define S5K5E8_PIXEL_RATE 167200000ULL + +struct s5k5e8_reg { u16 address; +u8 val; +}; +struct s5k5e8_mode { + u32 width, height, hts_def, vts_def, vts_min, num_regs; + const struct s5k5e8_reg *regs; +}; + +static const char * const s5k5e8_supply_names[] = { "avdd", "dvdd", "dovdd" }; +#define S5K5E8_NUM_SUPPLIES ARRAY_SIZE(s5k5e8_supply_names) + +static const struct s5k5e8_reg s5k5e8_common_regs[] = { + { 0x0100, 0x00 }, { 0x3906, 0x7e }, { 0x3c01, 0x0f }, { 0x3c14, 0x00 }, + { 0x3235, 0x08 }, { 0x3063, 0x2e }, { 0x307a, 0x10 }, { 0x307b, 0x0e }, + { 0x3079, 0x20 }, { 0x3070, 0x05 }, { 0x3067, 0x06 }, { 0x3071, 0x62 }, + { 0x3072, 0x16 }, { 0x3203, 0x43 }, { 0x3205, 0x43 }, { 0x320b, 0x42 }, + { 0x3007, 0x00 }, { 0x3008, 0x14 }, { 0x3020, 0x58 }, { 0x300d, 0x34 }, + { 0x300e, 0x17 }, { 0x3021, 0x02 }, { 0x3010, 0x59 }, { 0x3002, 0x01 }, + { 0x3005, 0x01 }, { 0x3008, 0x04 }, { 0x300f, 0x70 }, { 0x3010, 0x69 }, + { 0x3017, 0x10 }, { 0x3019, 0x19 }, { 0x300c, 0x62 }, { 0x3064, 0x10 }, + { 0x3c08, 0x0e }, { 0x3c09, 0x10 }, { 0x3c31, 0x0d }, { 0x3c32, 0xac }, +}; + +static const struct s5k5e8_reg s5k5e8_2592x1944_regs[] = { + { 0x0100, 0x00 }, { 0x0136, 0x18 }, { 0x0137, 0x00 }, { 0x0305, 0x06 }, + { 0x0306, 0x18 }, { 0x0307, 0xa8 }, { 0x0308, 0x34 }, { 0x0309, 0x42 }, + { 0x3c1f, 0x00 }, { 0x3c17, 0x00 }, { 0x3c0b, 0x04 }, { 0x3c1c, 0x47 }, + { 0x3c1d, 0x15 }, { 0x3c14, 0x04 }, { 0x3c16, 0x00 }, { 0x0820, 0x03 }, + { 0x0821, 0x44 }, { 0x0114, 0x01 }, { 0x0344, 0x00 }, { 0x0345, 0x08 }, + { 0x0346, 0x00 }, { 0x0347, 0x08 }, { 0x0348, 0x0a }, { 0x0349, 0x27 }, + { 0x034a, 0x07 }, { 0x034b, 0x9f }, { 0x034c, 0x0a }, { 0x034d, 0x20 }, + { 0x034e, 0x07 }, { 0x034f, 0x98 }, { 0x0900, 0x00 }, { 0x0901, 0x00 }, + { 0x0381, 0x01 }, { 0x0383, 0x01 }, { 0x0385, 0x01 }, { 0x0387, 0x01 }, + { 0x0340, 0x07 }, { 0x0341, 0xb0 }, { 0x0342, 0x0b }, { 0x0343, 0x28 }, + { 0x0200, 0x00 }, { 0x0201, 0x00 }, { 0x0202, 0x03 }, { 0x0203, 0xde }, + { 0x3303, 0x02 }, { 0x3400, 0x00 }, { 0x323b, 0x02 }, { 0x3301, 0x00 }, + { 0x3321, 0x04 }, { 0x3306, 0x00 }, { 0x3307, 0x08 }, { 0x3308, 0x0a }, + { 0x3309, 0x27 }, { 0x330a, 0x01 }, { 0x330b, 0x01 }, { 0x330e, 0x00 }, + { 0x330f, 0x08 }, { 0x3310, 0x07 }, { 0x3311, 0x9f }, { 0x3312, 0x01 }, + { 0x3313, 0x01 }, +}; + +static const struct s5k5e8_mode supported_modes[] = { + { + .width = 2592, .height = 1944, .hts_def = 2856, + .vts_def = 1968, .vts_min = 1968, + .num_regs = ARRAY_SIZE(s5k5e8_2592x1944_regs), + .regs = s5k5e8_2592x1944_regs, + }, +}; + +static const s64 link_freq_menu_items[] = { S5K5E8_LINK_FREQ_418MHZ }; + +struct s5k5e8 { + struct device *dev; + struct v4l2_subdev sd; + struct media_pad pad; + struct clk *xvclk; + struct gpio_desc *reset_gpio; + struct regulator_bulk_data supplies[S5K5E8_NUM_SUPPLIES]; + struct v4l2_ctrl_handler ctrl_handler; + struct v4l2_ctrl *link_freq, *pixel_rate, *vblank, *hblank, *exposure; + const struct s5k5e8_mode *cur_mode; + /* Serialize access to sensor registers and streaming state */ + struct mutex mutex; + bool streaming; +}; + +static inline struct s5k5e8 *to_s5k5e8(struct v4l2_subdev *sd) +{ + return container_of(sd, struct s5k5e8, sd); +} + +static int s5k5e8_read_reg(struct s5k5e8 *s5k5e8, u16 reg, u32 len, u32 *val) +{ + struct i2c_client *client = v4l2_get_subdevdata(&s5k5e8->sd); + struct i2c_msg msgs[2]; + u8 addr_buf[2], data_buf[4] = { 0 }; + int ret; + + put_unaligned_be16(reg, addr_buf); + msgs[0].addr = client->addr; + msgs[0].flags = 0; + msgs[0].len = 2; + msgs[0].buf = addr_buf; + msgs[1].addr = client->addr; + msgs[1].flags = I2C_M_RD; + msgs[1].len = len; + msgs[1].buf = &data_buf[4 - len]; + ret = i2c_transfer(client->adapter, msgs, 2); + if (ret != 2) + return ret < 0 ? ret : -EIO; + *val = get_unaligned_be32(data_buf); + return 0; +} + +static int s5k5e8_write_reg(struct s5k5e8 *s5k5e8, u16 reg, u32 len, u32 val) +{ + struct i2c_client *client = v4l2_get_subdevdata(&s5k5e8->sd); + u8 buf[6]; + int ret; + + put_unaligned_be16(reg, buf); + put_unaligned_be32(val << (8 * (4 - len)), buf + 2); + ret = i2c_master_send(client, buf, len + 2); + return ret == len + 2 ? 0 : (ret < 0 ? ret : -EIO); +} + +static int s5k5e8_write_regs(struct s5k5e8 *s5k5e8, const struct s5k5e8_reg *regs, u32 len) +{ + u32 i; + int ret; + + for (i = 0; i < len; i++) { + ret = s5k5e8_write_reg(s5k5e8, regs[i].address, 1, regs[i].val); + if (ret) + return ret; + } + return 0; +} + +static int s5k5e8_power_on(struct device *dev) +{ + struct s5k5e8 *s5k5e8 = to_s5k5e8(dev_get_drvdata(dev)); + int ret = regulator_bulk_enable(S5K5E8_NUM_SUPPLIES, s5k5e8->supplies); + + if (ret) + return ret; + ret = clk_prepare_enable(s5k5e8->xvclk); + if (ret) { + regulator_bulk_disable(S5K5E8_NUM_SUPPLIES, s5k5e8->supplies); + return ret; + } + if (s5k5e8->reset_gpio) { + gpiod_set_value_cansleep(s5k5e8->reset_gpio, 1); + usleep_range(1000, 2000); + gpiod_set_value_cansleep(s5k5e8->reset_gpio, 0); + usleep_range(3000, 5000); + } + return 0; +} + +static int s5k5e8_power_off(struct device *dev) +{ + struct s5k5e8 *s5k5e8 = to_s5k5e8(dev_get_drvdata(dev)); + + if (s5k5e8->reset_gpio) + gpiod_set_value_cansleep(s5k5e8->reset_gpio, 1); + clk_disable_unprepare(s5k5e8->xvclk); + regulator_bulk_disable(S5K5E8_NUM_SUPPLIES, s5k5e8->supplies); + return 0; +} + +static int s5k5e8_set_ctrl(struct v4l2_ctrl *ctrl) +{ + struct s5k5e8 *s5k5e8 = container_of(ctrl->handler, struct s5k5e8, ctrl_handler); + int ret = 0; + + if (!pm_runtime_get_if_in_use(s5k5e8->dev)) + return 0; + switch (ctrl->id) { + case V4L2_CID_ANALOGUE_GAIN: + ret = s5k5e8_write_reg(s5k5e8, S5K5E8_REG_ANALOG_GAIN, 2, ctrl->val); + break; + case V4L2_CID_EXPOSURE: + ret = s5k5e8_write_reg(s5k5e8, S5K5E8_REG_EXPOSURE, 2, ctrl->val); + break; + case V4L2_CID_VBLANK: + ret = s5k5e8_write_reg(s5k5e8, S5K5E8_REG_VTS, 2, + s5k5e8->cur_mode->height + ctrl->val); + break; + case V4L2_CID_TEST_PATTERN: + ret = s5k5e8_write_reg(s5k5e8, S5K5E8_REG_TEST_PATTERN, 2, ctrl->val); + break; + } + pm_runtime_put(s5k5e8->dev); + return ret; +} + +static const struct v4l2_ctrl_ops s5k5e8_ctrl_ops = { .s_ctrl = s5k5e8_set_ctrl }; +static const char * const s5k5e8_test_pattern_menu[] = { + "Disabled", + "Solid Color", + "100% Color Bars", + "Fade to Grey", + "PN9", +}; + +static int s5k5e8_init_controls(struct s5k5e8 *s5k5e8) +{ + struct v4l2_fwnode_device_properties props; + struct v4l2_ctrl_handler *hdl = &s5k5e8->ctrl_handler; + s64 hblank = s5k5e8->cur_mode->hts_def - s5k5e8->cur_mode->width; + int ret = v4l2_ctrl_handler_init(hdl, 8); + + if (ret) + return ret; + hdl->lock = &s5k5e8->mutex; + s5k5e8->link_freq = v4l2_ctrl_new_int_menu(hdl, &s5k5e8_ctrl_ops, V4L2_CID_LINK_FREQ, + 0, 0, link_freq_menu_items); + if (s5k5e8->link_freq) + s5k5e8->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; + s5k5e8->pixel_rate = v4l2_ctrl_new_std(hdl, &s5k5e8_ctrl_ops, V4L2_CID_PIXEL_RATE, + S5K5E8_PIXEL_RATE, S5K5E8_PIXEL_RATE, 1, S5K5E8_PIXEL_RATE); + s5k5e8->vblank = v4l2_ctrl_new_std(hdl, &s5k5e8_ctrl_ops, V4L2_CID_VBLANK, 24, + 0x7fff - s5k5e8->cur_mode->height, 1, 24); + s5k5e8->hblank = v4l2_ctrl_new_std(hdl, &s5k5e8_ctrl_ops, V4L2_CID_HBLANK, hblank, + hblank, 1, hblank); + if (s5k5e8->hblank) + s5k5e8->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; + v4l2_ctrl_new_std(hdl, &s5k5e8_ctrl_ops, V4L2_CID_ANALOGUE_GAIN, 0x20, 0x200, 1, 0x60); + s5k5e8->exposure = v4l2_ctrl_new_std(hdl, &s5k5e8_ctrl_ops, V4L2_CID_EXPOSURE, 4, 1964, + 1, 1960); + v4l2_ctrl_new_std_menu_items(hdl, &s5k5e8_ctrl_ops, V4L2_CID_TEST_PATTERN, 4, 0, 0, + s5k5e8_test_pattern_menu); + if (hdl->error) { + ret = hdl->error; + goto err; + } + ret = v4l2_fwnode_device_parse(s5k5e8->dev, &props); + if (ret) + goto err; + ret = v4l2_ctrl_new_fwnode_properties(hdl, &s5k5e8_ctrl_ops, &props); + if (ret) + goto err; + s5k5e8->sd.ctrl_handler = hdl; + return 0; +err: + v4l2_ctrl_handler_free(hdl); + return ret; +} + +static void s5k5e8_update_pad_format(const struct s5k5e8_mode *mode, + struct v4l2_mbus_framefmt *fmt) +{ + fmt->width = mode->width; + fmt->height = mode->height; + fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10; + fmt->field = V4L2_FIELD_NONE; + fmt->colorspace = V4L2_COLORSPACE_SRGB; +} + +static int s5k5e8_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_format *fmt) +{ + struct s5k5e8 *s5k5e8 = to_s5k5e8(sd); + + fmt->format = (fmt->which == V4L2_SUBDEV_FORMAT_TRY) ? *v4l2_subdev_state_get_format(sd_state, + fmt->pad) : fmt->format; + if (fmt->which != V4L2_SUBDEV_FORMAT_TRY) + s5k5e8_update_pad_format(s5k5e8->cur_mode, &fmt->format); + return 0; +} + +static int s5k5e8_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_format *fmt) +{ + struct s5k5e8 *s5k5e8 = to_s5k5e8(sd); + + s5k5e8_update_pad_format(&supported_modes[0], &fmt->format); + if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) + *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; + else + s5k5e8->cur_mode = &supported_modes[0]; + + return 0; +} + +static int s5k5e8_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_mbus_code_enum *code) +{ + if (code->index > 0) + return -EINVAL; + code->code = MEDIA_BUS_FMT_SGRBG10_1X10; + return 0; +} + +static int s5k5e8_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_frame_size_enum *fse) +{ + if (fse->index >= ARRAY_SIZE(supported_modes) || + fse->code != MEDIA_BUS_FMT_SGRBG10_1X10) + return -EINVAL; + fse->min_width = fse->max_width = supported_modes[fse->index].width; + fse->min_height = fse->max_height = supported_modes[fse->index].height; + return 0; +} + +static int s5k5e8_set_stream(struct v4l2_subdev *sd, int enable) +{ + struct s5k5e8 *s5k5e8 = to_s5k5e8(sd); + int ret = 0; + + mutex_lock(&s5k5e8->mutex); + if (s5k5e8->streaming == enable) { + mutex_unlock(&s5k5e8->mutex); + return 0; + } + if (enable) { + ret = pm_runtime_resume_and_get(s5k5e8->dev); + if (ret < 0) + goto out; + ret = s5k5e8_write_regs(s5k5e8, s5k5e8_common_regs, + ARRAY_SIZE(s5k5e8_common_regs)); + if (!ret) + ret = s5k5e8_write_regs(s5k5e8, s5k5e8->cur_mode->regs, + s5k5e8->cur_mode->num_regs); + if (!ret) + ret = __v4l2_ctrl_handler_setup(s5k5e8->sd.ctrl_handler); + if (!ret) { + static const struct s5k5e8_reg stream_on_regs[] = { + { 0x3c16, 0x00 }, + { 0x3c0d, 0x04 }, + { 0x0100, 0x01 }, + { 0x3c22, 0x00 }, + { 0x3c22, 0x00 }, + { 0x3c0d, 0x00 }, + }; + msleep(80); + ret = s5k5e8_write_regs(s5k5e8, stream_on_regs, + ARRAY_SIZE(stream_on_regs)); + } + if (ret) { + pm_runtime_put(s5k5e8->dev); + goto out; + } + } else { + s5k5e8_write_reg(s5k5e8, S5K5E8_REG_MODE_SELECT, 1, S5K5E8_MODE_STANDBY); + pm_runtime_put(s5k5e8->dev); + } + s5k5e8->streaming = enable; +out: + mutex_unlock(&s5k5e8->mutex); + return ret; +} + +static int s5k5e8_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) +{ + struct s5k5e8 *s5k5e8 = to_s5k5e8(sd); + + mutex_lock(&s5k5e8->mutex); + s5k5e8_update_pad_format(&supported_modes[0], v4l2_subdev_state_get_format(fh->state, 0)); + mutex_unlock(&s5k5e8->mutex); + return 0; +} + +static const struct v4l2_subdev_video_ops s5k5e8_video_ops = { .s_stream = s5k5e8_set_stream }; + +static int s5k5e8_get_selection(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_selection *sel) +{ + switch (sel->target) { + case V4L2_SEL_TGT_CROP: + case V4L2_SEL_TGT_CROP_DEFAULT: + case V4L2_SEL_TGT_CROP_BOUNDS: + case V4L2_SEL_TGT_NATIVE_SIZE: + sel->r.left = 0; + sel->r.top = 0; + sel->r.width = 2592; + sel->r.height = 1944; + return 0; + default: + return -EINVAL; + } +} + +static const struct v4l2_subdev_pad_ops s5k5e8_pad_ops = { + .get_selection = s5k5e8_get_selection, + .set_fmt = s5k5e8_set_format, .get_fmt = s5k5e8_get_format, + .enum_mbus_code = s5k5e8_enum_mbus_code, .enum_frame_size = s5k5e8_enum_frame_size, +}; +static const struct v4l2_subdev_ops s5k5e8_subdev_ops = { + .video = &s5k5e8_video_ops, + .pad = &s5k5e8_pad_ops, +}; +static const struct media_entity_operations s5k5e8_entity_ops = { + .link_validate = v4l2_subdev_link_validate, +}; +static const struct v4l2_subdev_internal_ops s5k5e8_internal_ops = { .open = s5k5e8_open }; + +static int s5k5e8_probe(struct i2c_client *client) +{ + struct device *dev = &client->dev; + struct s5k5e8 *s5k5e8; + u32 val = 0; + unsigned int i; + int ret; + + s5k5e8 = devm_kzalloc(dev, sizeof(*s5k5e8), GFP_KERNEL); + if (!s5k5e8) + return -ENOMEM; + s5k5e8->dev = dev; + v4l2_i2c_subdev_init(&s5k5e8->sd, client, &s5k5e8_subdev_ops); + s5k5e8->xvclk = devm_v4l2_sensor_clk_get(dev, NULL); + if (IS_ERR(s5k5e8->xvclk)) + return dev_err_probe(dev, PTR_ERR(s5k5e8->xvclk), "xvclk\n"); + clk_set_rate(s5k5e8->xvclk, S5K5E8_XVCLK_FREQ); + s5k5e8->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(s5k5e8->reset_gpio)) + return dev_err_probe(dev, PTR_ERR(s5k5e8->reset_gpio), "reset\n"); + for (i = 0; i < S5K5E8_NUM_SUPPLIES; i++) + s5k5e8->supplies[i].supply = s5k5e8_supply_names[i]; + ret = devm_regulator_bulk_get(dev, S5K5E8_NUM_SUPPLIES, s5k5e8->supplies); + if (ret) + return dev_err_probe(dev, ret, "regulators\n"); + ret = s5k5e8_power_on(dev); + if (ret) + return ret; + ret = s5k5e8_read_reg(s5k5e8, S5K5E8_CHIP_ID_REG, 2, &val); + if (ret || val != S5K5E8_CHIP_ID) { + dev_err(dev, "failed to identify s5k5e8 (ret=%d, id=0x%x)\n", ret, val); + ret = ret ? ret : -ENXIO; + goto err_power; + } + dev_info(dev, "identified Samsung S5K5E8 sensor (0x%04x)\n", val); + mutex_init(&s5k5e8->mutex); + s5k5e8->cur_mode = &supported_modes[0]; + ret = s5k5e8_init_controls(s5k5e8); + if (ret) + goto err_mutex; + s5k5e8->sd.internal_ops = &s5k5e8_internal_ops; + s5k5e8->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; + s5k5e8->sd.entity.ops = &s5k5e8_entity_ops; + s5k5e8->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; + s5k5e8->pad.flags = MEDIA_PAD_FL_SOURCE; + ret = media_entity_pads_init(&s5k5e8->sd.entity, 1, &s5k5e8->pad); + if (ret) + goto err_ctrl; + s5k5e8->sd.state_lock = &s5k5e8->mutex; + ret = v4l2_subdev_init_finalize(&s5k5e8->sd); + if (ret) + goto err_media; + ret = v4l2_async_register_subdev_sensor(&s5k5e8->sd); + if (ret) + goto err_media; + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + pm_runtime_idle(dev); + return 0; +err_media: media_entity_cleanup(&s5k5e8->sd.entity); +err_ctrl: v4l2_ctrl_handler_free(s5k5e8->sd.ctrl_handler); +err_mutex: mutex_destroy(&s5k5e8->mutex); +err_power: s5k5e8_power_off(dev); + return ret; +} + +static void s5k5e8_remove(struct i2c_client *client) +{ + struct v4l2_subdev *sd = i2c_get_clientdata(client); + struct s5k5e8 *s5k5e8 = to_s5k5e8(sd); + + v4l2_async_unregister_subdev(sd); + media_entity_cleanup(&sd->entity); + v4l2_ctrl_handler_free(sd->ctrl_handler); + mutex_destroy(&s5k5e8->mutex); + pm_runtime_disable(&client->dev); + if (!pm_runtime_status_suspended(&client->dev)) + s5k5e8_power_off(&client->dev); + pm_runtime_set_suspended(&client->dev); +} + +static const struct dev_pm_ops s5k5e8_pm_ops = { SET_RUNTIME_PM_OPS(s5k5e8_power_off, + s5k5e8_power_on, NULL) }; +static const struct of_device_id s5k5e8_of_match[] = { { .compatible = "samsung,s5k5e8" }, { } }; +MODULE_DEVICE_TABLE(of, s5k5e8_of_match); +static struct i2c_driver s5k5e8_i2c_driver = { + .driver = { .name = "s5k5e8", .pm = &s5k5e8_pm_ops, .of_match_table = s5k5e8_of_match }, + .probe = s5k5e8_probe, .remove = s5k5e8_remove, +}; +module_i2c_driver(s5k5e8_i2c_driver); +MODULE_DESCRIPTION("Samsung S5K5E8 5MP sensor driver"); +MODULE_LICENSE("GPL"); -- 2.47.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 4/6] media: dt-bindings: media: i2c: add OmniVision OV12A10 2026-11-23 11:07 [PATCH 0/6] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar ` (2 preceding siblings ...) 2026-11-23 11:08 ` [PATCH 3/6] media: i2c: add s5k5e8 image sensor driver Hikmah Gumelar @ 2026-11-23 11:08 ` Hikmah Gumelar 2026-11-23 11:08 ` [PATCH 5/6] media: i2c: add ov12a10 image sensor driver Hikmah Gumelar ` (2 subsequent siblings) 6 siblings, 0 replies; 17+ messages in thread From: Hikmah Gumelar @ 2026-11-23 11:08 UTC (permalink / raw) To: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Michael Turquette, Stephen Boyd, Brian Masney, Sakari Ailus Cc: Hikmah Gumelar, linux-media, devicetree, linux-kernel, linux-arm-msm, linux-clk Add Devicetree binding schema for the OmniVision OV12A10 12-megapixel MIPI CSI-2 CMOS image sensor. Signed-off-by: Hikmah Gumelar <hikmahgumelar@gmail.com> --- .../bindings/media/i2c/ovti,ov12a10.yaml | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml diff --git a/Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml b/Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml new file mode 100644 index 000000000000..6919277c2b3f --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml @@ -0,0 +1,115 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org +$schema: http://devicetree.org + +title: OmniVision OV12A10 1/2.8-inch 12Mp CMOS Image Sensor + +maintainers: + - Hikmah Gumelar <hikmahgumelar@gmail.com> + +description: + OmniVision OV12A10 is a 1/2.8-inch 12-megapixel CMOS active-pixel digital + image sensor with a 4-lane MIPI CSI-2 interface and I2C control bus. + +allOf: + - $ref: /schemas/media/video-interface-devices.yaml# + +properties: + compatible: + const: ovti,ov12a10 + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + reset-gpios: + description: Active-low reset GPIO. + maxItems: 1 + + pwdn-gpios: + description: Active-low power-down GPIO. + maxItems: 1 + + vana-gpios: + description: Active-high analog power enable GPIO. + maxItems: 1 + + avdd-supply: + description: Analog power supply (2.8V). + + dvdd-supply: + description: Digital core power supply (1.2V). + + dovdd-supply: + description: Digital I/O power supply (1.8V). + + port: + $ref: /schemas/graph.yaml#/$defs/port-base + additionalProperties: false + + properties: + endpoint: + $ref: /schemas/media/video-interfaces.yaml# + unevaluatedProperties: false + + properties: + data-lanes: + items: + - const: 0 + - const: 1 + - const: 2 + - const: 3 + + link-frequencies: true + + required: + - data-lanes + - link-frequencies + + required: + - endpoint + +required: + - compatible + - reg + - clocks + - avdd-supply + - dvdd-supply + - dovdd-supply + - port + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + camera-sensor@10 { + compatible = "ovti,ov12a10"; + reg = <0x10>; + clocks = <&camss_mclk0>; + reset-gpios = <&tlmm 33 GPIO_ACTIVE_LOW>; + pwdn-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + vana-gpios = <&tlmm 62 GPIO_ACTIVE_HIGH>; + avdd-supply = <&pm8953_l22>; + dvdd-supply = <&pm8953_l2>; + dovdd-supply = <&pm8953_l6>; + + port { + endpoint { + data-lanes = <0 1 2 3>; + remote-endpoint = <&csiphy0_ep>; + link-frequencies = /bits/ 64 <216000000>; + }; + }; + }; + }; +... -- 2.47.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 5/6] media: i2c: add ov12a10 image sensor driver 2026-11-23 11:07 [PATCH 0/6] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar ` (3 preceding siblings ...) 2026-11-23 11:08 ` [PATCH 4/6] media: dt-bindings: media: i2c: add OmniVision OV12A10 Hikmah Gumelar @ 2026-11-23 11:08 ` Hikmah Gumelar 2026-11-23 11:08 ` [PATCH 6/6] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar 2026-11-23 12:35 ` [PATCH v2 0/7] " Hikmah Gumelar 6 siblings, 0 replies; 17+ messages in thread From: Hikmah Gumelar @ 2026-11-23 11:08 UTC (permalink / raw) To: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Michael Turquette, Stephen Boyd, Brian Masney, Sakari Ailus Cc: Hikmah Gumelar, linux-media, devicetree, linux-kernel, linux-arm-msm, linux-clk Add V4L2 subdev driver for the OmniVision OV12A10 12MP MIPI CSI-2 image sensor supporting 1280x720 binned raw10 capture. Signed-off-by: Hikmah Gumelar <hikmahgumelar@gmail.com> --- drivers/media/i2c/Kconfig | 13 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/ov12a10.c | 720 ++++++++++++++++++++++++++++++++++++ 3 files changed, 734 insertions(+) create mode 100644 drivers/media/i2c/ov12a10.c diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index 3a0a041a4c2b..fd2928de223d 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig @@ -454,6 +454,19 @@ config VIDEO_OV08X40 To compile this driver as a module, choose M here: the module will be called ov08x40. +config VIDEO_OV12A10 + tristate "OmniVision OV12A10 sensor support" + depends on I2C && VIDEO_DEV + select MEDIA_CONTROLLER + select VIDEO_V4L2_SUBDEV_API + select V4L2_FWNODE + help + This is a Video4Linux2 sensor driver for the OmniVision + OV12A10 camera. + + To compile this driver as a module, choose M here: the + module will be called ov12a10. + config VIDEO_OV13858 tristate "OmniVision OV13858 sensor support" help diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile index f93d7205817d..27830499333f 100644 --- a/drivers/media/i2c/Makefile +++ b/drivers/media/i2c/Makefile @@ -91,6 +91,7 @@ obj-$(CONFIG_VIDEO_OV02C10) += ov02c10.o obj-$(CONFIG_VIDEO_OV02E10) += ov02e10.o obj-$(CONFIG_VIDEO_OV08D10) += ov08d10.o obj-$(CONFIG_VIDEO_OV08X40) += ov08x40.o +obj-$(CONFIG_VIDEO_OV12A10) += ov12a10.o obj-$(CONFIG_VIDEO_OV13858) += ov13858.o obj-$(CONFIG_VIDEO_OV13B10) += ov13b10.o obj-$(CONFIG_VIDEO_OV2640) += ov2640.o diff --git a/drivers/media/i2c/ov12a10.c b/drivers/media/i2c/ov12a10.c new file mode 100644 index 000000000000..87823fe8fbe1 --- /dev/null +++ b/drivers/media/i2c/ov12a10.c @@ -0,0 +1,720 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/gpio/consumer.h> +#include <linux/i2c.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/pm_runtime.h> +#include <linux/regulator/consumer.h> +#include <linux/unaligned.h> +#include <media/v4l2-ctrls.h> +#include <media/v4l2-device.h> +#include <media/v4l2-fwnode.h> + +#define OV12A10_CHIP_ID_REG 0x300a +#define OV12A10_CHIP_ID 0x5612 +#define OV12A10_REG_MODE_SELECT 0x0100 +#define OV12A10_MODE_STANDBY 0x00 +#define OV12A10_MODE_STREAMING 0x01 +#define OV12A10_REG_VTS 0x380e +#define OV12A10_REG_EXPOSURE 0x3501 +#define OV12A10_REG_ANALOG_GAIN 0x3508 +#define OV12A10_REG_TEST_PATTERN 0x5080 +#define OV12A10_XVCLK_FREQ 24000000 +#define OV12A10_LINK_FREQ_216MHZ 216000000ULL +#define OV12A10_PIXEL_RATE 144000000ULL + +struct ov12a10_reg { u16 address; +u8 val; +}; +struct ov12a10_mode { + u32 width, height, hts_def, vts_def, vts_min, num_regs; + const struct ov12a10_reg *regs; +}; + +static const char * const ov12a10_supply_names[] = { "avdd", "dvdd", "dovdd" }; +#define OV12A10_NUM_SUPPLIES ARRAY_SIZE(ov12a10_supply_names) + +static const struct ov12a10_reg ov12a10_common_regs[] = { + { 0x0103, 0x01 }, + { 0x0302, 0x49 }, + { 0x0303, 0x00 }, + { 0x0304, 0x00 }, + { 0x0305, 0x01 }, + { 0x0312, 0x11 }, + { 0x030b, 0x06 }, + { 0x030c, 0x02 }, + { 0x030d, 0x88 }, + { 0x030e, 0x02 }, + { 0x0313, 0x05 }, + { 0x3002, 0x21 }, + { 0x3012, 0x40 }, + { 0x3013, 0x72 }, + { 0x3016, 0x72 }, + { 0x301b, 0xd0 }, + { 0x301d, 0xf0 }, + { 0x301f, 0xd0 }, + { 0x3021, 0x23 }, + { 0x3022, 0x01 }, + { 0x3106, 0x15 }, + { 0x3107, 0x23 }, + { 0x3500, 0x00 }, + { 0x3501, 0xd0 }, + { 0x3502, 0x00 }, + { 0x3505, 0x83 }, + { 0x3508, 0x02 }, + { 0x3509, 0x00 }, + { 0x3600, 0x43 }, + { 0x3611, 0x8a }, + { 0x3613, 0x97 }, + { 0x3620, 0x80 }, + { 0x3624, 0x2c }, + { 0x3625, 0xa0 }, + { 0x3626, 0x00 }, + { 0x3631, 0x60 }, + { 0x3632, 0x00 }, + { 0x3641, 0x80 }, + { 0x3642, 0x12 }, + { 0x3644, 0x78 }, + { 0x3645, 0xa7 }, + { 0x364e, 0x44 }, + { 0x364f, 0x44 }, + { 0x3650, 0x11 }, + { 0x3654, 0x00 }, + { 0x3657, 0x31 }, + { 0x3659, 0x0c }, + { 0x365f, 0x07 }, + { 0x3661, 0x17 }, + { 0x3662, 0x17 }, + { 0x3663, 0x17 }, + { 0x3664, 0x17 }, + { 0x3666, 0x08 }, + { 0x366b, 0x20 }, + { 0x366c, 0xa4 }, + { 0x366d, 0x20 }, + { 0x366e, 0xa4 }, + { 0x3680, 0x00 }, + { 0x3714, 0x24 }, + { 0x371a, 0x3e }, + { 0x3737, 0x04 }, + { 0x3739, 0x12 }, + { 0x3765, 0x20 }, + { 0x3767, 0x00 }, + { 0x37a1, 0x3e }, + { 0x37a8, 0x4d }, + { 0x37ab, 0x2c }, + { 0x37c2, 0x04 }, + { 0x37d8, 0x03 }, + { 0x37d9, 0x0c }, + { 0x37e0, 0x00 }, + { 0x37e1, 0x0a }, + { 0x37e2, 0x14 }, + { 0x37e3, 0x04 }, + { 0x37e4, 0x2a }, + { 0x37e5, 0x03 }, + { 0x37e6, 0x04 }, + { 0x3800, 0x00 }, + { 0x3801, 0x00 }, + { 0x3802, 0x00 }, + { 0x3803, 0x00 }, + { 0x3804, 0x10 }, + { 0x3805, 0x0f }, + { 0x3806, 0x0c }, + { 0x3807, 0x0f }, + { 0x3808, 0x10 }, + { 0x3809, 0x00 }, + { 0x380a, 0x0c }, + { 0x380b, 0x00 }, + { 0x380c, 0x04 }, + { 0x380d, 0x28 }, + { 0x380e, 0x0d }, + { 0x380f, 0x12 }, + { 0x3811, 0x0a }, + { 0x3813, 0x08 }, + { 0x3814, 0x01 }, + { 0x3815, 0x01 }, + { 0x3816, 0x01 }, + { 0x3817, 0x01 }, + { 0x3820, 0xa8 }, + { 0x3821, 0x00 }, + { 0x3822, 0x91 }, + { 0x3823, 0x18 }, + { 0x3826, 0x00 }, + { 0x3827, 0x00 }, + { 0x3829, 0x03 }, + { 0x3832, 0x08 }, + { 0x3833, 0x30 }, + { 0x3c80, 0x00 }, + { 0x3c87, 0x01 }, + { 0x3c8c, 0x1a }, + { 0x3c8d, 0x68 }, + { 0x3c97, 0x02 }, + { 0x3cc0, 0x40 }, + { 0x3cc1, 0x54 }, + { 0x3cc2, 0x34 }, + { 0x3cc3, 0x04 }, + { 0x3cc4, 0x00 }, + { 0x3cc5, 0x00 }, + { 0x3cc6, 0x00 }, + { 0x3cc7, 0x00 }, + { 0x3cc8, 0x00 }, + { 0x3cc9, 0x00 }, + { 0x3d8c, 0x73 }, + { 0x3d8d, 0xc0 }, + { 0x4001, 0x2b }, + { 0x4008, 0x02 }, + { 0x4009, 0x0f }, + { 0x4011, 0xff }, + { 0x4013, 0x08 }, + { 0x4014, 0x08 }, + { 0x4015, 0x08 }, + { 0x4017, 0x08 }, + { 0x401a, 0x58 }, + { 0x4050, 0x04 }, + { 0x4051, 0x0b }, + { 0x405e, 0x20 }, + { 0x4501, 0x00 }, + { 0x4503, 0x00 }, + { 0x450a, 0x04 }, + { 0x4601, 0x30 }, + { 0x4800, 0x24 }, + { 0x481f, 0x30 }, + { 0x4837, 0x0d }, + { 0x483c, 0x0f }, + { 0x484b, 0x01 }, + { 0x4d00, 0x05 }, + { 0x4d01, 0x19 }, + { 0x4d02, 0xfd }, + { 0x4d03, 0xd1 }, + { 0x4d04, 0xff }, + { 0x4d05, 0xff }, + { 0x5000, 0x09 }, + { 0x5001, 0x42 }, + { 0x5002, 0x45 }, + { 0x5005, 0x00 }, + { 0x5081, 0x04 }, + { 0x5180, 0x00 }, + { 0x5181, 0x10 }, + { 0x5182, 0x02 }, + { 0x5183, 0x0f }, + { 0x5185, 0x6c }, + { 0x5200, 0x03 }, + { 0x5203, 0x7c }, + { 0x5204, 0x1f }, + { 0x5205, 0x41 }, + { 0x520b, 0x07 }, + { 0x520c, 0x0f }, + { 0x0300, 0x02 }, + { 0x0302, 0x53 }, + { 0x380c, 0x04 }, + { 0x380d, 0x90 }, + { 0x380e, 0x0c }, + { 0x380f, 0xe6 }, + { 0x4837, 0x10 }, +}; + +static const struct ov12a10_reg ov12a10_1280x720_regs[] = { + { 0x0300, 0x06 }, + { 0x0301, 0x02 }, + { 0x0302, 0x48 }, + { 0x0307, 0x01 }, + { 0x0303, 0x01 }, + { 0x030b, 0x06 }, + { 0x030c, 0x02 }, + { 0x030d, 0x88 }, + { 0x0312, 0x11 }, + { 0x0313, 0x09 }, + { 0x3642, 0x10 }, + { 0x3666, 0x00 }, + { 0x366b, 0xa4 }, + { 0x366c, 0x20 }, + { 0x366d, 0xa4 }, + { 0x366e, 0x20 }, + { 0x3714, 0x28 }, + { 0x371a, 0x3e }, + { 0x3737, 0x08 }, + { 0x3739, 0x20 }, + { 0x37c2, 0x14 }, + { 0x37d9, 0x0c }, + { 0x37e3, 0x08 }, + { 0x37e4, 0x36 }, + { 0x37e6, 0x08 }, + { 0x3800, 0x03 }, + { 0x3801, 0x20 }, + { 0x3802, 0x03 }, + { 0x3803, 0x68 }, + { 0x3804, 0x0d }, + { 0x3805, 0x3f }, + { 0x3806, 0x09 }, + { 0x3807, 0x27 }, + { 0x3808, 0x05 }, + { 0x3809, 0x00 }, + { 0x380a, 0x02 }, + { 0x380b, 0xd0 }, + { 0x380c, 0x04 }, + { 0x380d, 0x28 }, + { 0x380e, 0x03 }, + { 0x380f, 0x4c }, + { 0x3810, 0x00 }, + { 0x3811, 0x08 }, + { 0x3813, 0x08 }, + { 0x3814, 0x03 }, + { 0x3816, 0x03 }, + { 0x3820, 0xab }, + { 0x4009, 0x0d }, + { 0x4050, 0x04 }, + { 0x4051, 0x0b }, + { 0x4501, 0x00 }, + { 0x4837, 0x1b }, + { 0x5001, 0x42 }, + { 0x5002, 0x45 }, + { 0x3501, 0x34 }, + { 0x3502, 0x00 }, + { 0x4800, 0x24 }, +}; + +static const struct ov12a10_mode supported_modes[] = { + { + .width = 1280, .height = 720, .hts_def = 1440, + .vts_def = 3376, .vts_min = 844, + .num_regs = ARRAY_SIZE(ov12a10_1280x720_regs), + .regs = ov12a10_1280x720_regs, + }, +}; + +static const s64 link_freq_menu_items[] = { OV12A10_LINK_FREQ_216MHZ }; + +struct ov12a10 { + struct device *dev; + struct v4l2_subdev sd; + struct media_pad pad; + struct clk *xvclk; + struct gpio_desc *reset_gpio, *vana_gpio, *pwdn_gpio; + struct regulator_bulk_data supplies[OV12A10_NUM_SUPPLIES]; + struct v4l2_ctrl_handler ctrl_handler; + struct v4l2_ctrl *link_freq, *pixel_rate, *vblank, *hblank, *exposure; + const struct ov12a10_mode *cur_mode; + /* Serialize access to sensor registers and streaming state */ + struct mutex mutex; + bool streaming; +}; + +static inline struct ov12a10 *to_ov12a10(struct v4l2_subdev *sd) +{ + return container_of(sd, struct ov12a10, sd); +} + +static int ov12a10_read_reg(struct ov12a10 *ov12a10, u16 reg, u32 len, u32 *val) +{ + struct i2c_client *client = v4l2_get_subdevdata(&ov12a10->sd); + struct i2c_msg msgs[2]; + u8 addr_buf[2], data_buf[4] = { 0 }; + int ret; + + put_unaligned_be16(reg, addr_buf); + msgs[0].addr = client->addr; + msgs[0].flags = 0; + msgs[0].len = 2; + msgs[0].buf = addr_buf; + msgs[1].addr = client->addr; + msgs[1].flags = I2C_M_RD; + msgs[1].len = len; + msgs[1].buf = &data_buf[4 - len]; + ret = i2c_transfer(client->adapter, msgs, 2); + if (ret != 2) + return ret < 0 ? ret : -EIO; + *val = get_unaligned_be32(data_buf); + return 0; +} + +static int ov12a10_write_reg(struct ov12a10 *ov12a10, u16 reg, u32 len, u32 val) +{ + struct i2c_client *client = v4l2_get_subdevdata(&ov12a10->sd); + u8 buf[6]; + int ret; + + put_unaligned_be16(reg, buf); + put_unaligned_be32(val << (8 * (4 - len)), buf + 2); + ret = i2c_master_send(client, buf, len + 2); + return ret == len + 2 ? 0 : (ret < 0 ? ret : -EIO); +} + +static int ov12a10_write_regs(struct ov12a10 *ov12a10, const struct ov12a10_reg *regs, u32 len) +{ + u32 i; + int ret; + + for (i = 0; i < len; i++) { + ret = ov12a10_write_reg(ov12a10, regs[i].address, 1, regs[i].val); + if (!ret && regs[i].address == 0x0103) + usleep_range(5000, 6000); + if (ret) + return ret; + } + return 0; +} + +static int ov12a10_power_on(struct device *dev) +{ + struct ov12a10 *ov12a10 = to_ov12a10(dev_get_drvdata(dev)); + int ret; + + if (ov12a10->vana_gpio) + gpiod_set_value_cansleep(ov12a10->vana_gpio, 1); + + ret = regulator_bulk_enable(OV12A10_NUM_SUPPLIES, ov12a10->supplies); + if (ret) + return ret; + + ret = clk_prepare_enable(ov12a10->xvclk); + if (ret) { + regulator_bulk_disable(OV12A10_NUM_SUPPLIES, ov12a10->supplies); + return ret; + } + + msleep(35); + if (ov12a10->pwdn_gpio) + gpiod_set_value_cansleep(ov12a10->pwdn_gpio, 0); + if (ov12a10->reset_gpio) { + gpiod_set_value_cansleep(ov12a10->reset_gpio, 1); + usleep_range(3000, 5000); + gpiod_set_value_cansleep(ov12a10->reset_gpio, 0); + msleep(35); + } + return 0; +} + +static int ov12a10_power_off(struct device *dev) +{ + struct ov12a10 *ov12a10 = to_ov12a10(dev_get_drvdata(dev)); + + if (ov12a10->reset_gpio) + gpiod_set_value_cansleep(ov12a10->reset_gpio, 1); + if (ov12a10->pwdn_gpio) + gpiod_set_value_cansleep(ov12a10->pwdn_gpio, 1); + if (ov12a10->vana_gpio) + gpiod_set_value_cansleep(ov12a10->vana_gpio, 0); + clk_disable_unprepare(ov12a10->xvclk); + regulator_bulk_disable(OV12A10_NUM_SUPPLIES, ov12a10->supplies); + return 0; +} + +static int ov12a10_set_ctrl(struct v4l2_ctrl *ctrl) +{ + struct ov12a10 *ov12a10 = container_of(ctrl->handler, struct ov12a10, ctrl_handler); + int ret = 0; + + if (!pm_runtime_get_if_in_use(ov12a10->dev)) + return 0; + switch (ctrl->id) { + case V4L2_CID_ANALOGUE_GAIN: + ret = ov12a10_write_reg(ov12a10, OV12A10_REG_ANALOG_GAIN, 2, ctrl->val); + break; + case V4L2_CID_EXPOSURE: + ret = ov12a10_write_reg(ov12a10, 0x3500, 3, ctrl->val << 4); + break; + case V4L2_CID_VBLANK: + ret = ov12a10_write_reg(ov12a10, OV12A10_REG_VTS, 2, + ov12a10->cur_mode->height + ctrl->val); + break; + case V4L2_CID_TEST_PATTERN: + ret = ov12a10_write_reg(ov12a10, OV12A10_REG_TEST_PATTERN, 1, ctrl->val); + break; + } + pm_runtime_put(ov12a10->dev); + return ret; +} + +static const struct v4l2_ctrl_ops ov12a10_ctrl_ops = { .s_ctrl = ov12a10_set_ctrl }; +static const char * const ov12a10_test_pattern_menu[] = { + "Disabled", + "Solid Color", + "100% Color Bars", + "Fade to Grey", + "PN9", +}; + +static int ov12a10_init_controls(struct ov12a10 *ov12a10) +{ + struct v4l2_fwnode_device_properties props; + struct v4l2_ctrl_handler *hdl = &ov12a10->ctrl_handler; + s64 hblank = ov12a10->cur_mode->hts_def - ov12a10->cur_mode->width; + int ret = v4l2_ctrl_handler_init(hdl, 8); + + if (ret) + return ret; + hdl->lock = &ov12a10->mutex; + ov12a10->link_freq = v4l2_ctrl_new_int_menu(hdl, &ov12a10_ctrl_ops, V4L2_CID_LINK_FREQ, + 0, 0, link_freq_menu_items); + if (ov12a10->link_freq) + ov12a10->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; + ov12a10->pixel_rate = v4l2_ctrl_new_std(hdl, &ov12a10_ctrl_ops, V4L2_CID_PIXEL_RATE, + OV12A10_PIXEL_RATE, OV12A10_PIXEL_RATE, 1, OV12A10_PIXEL_RATE); + ov12a10->vblank = v4l2_ctrl_new_std(hdl, &ov12a10_ctrl_ops, V4L2_CID_VBLANK, 124, + 0x7fff - ov12a10->cur_mode->height, 1, 2656); + ov12a10->hblank = v4l2_ctrl_new_std(hdl, &ov12a10_ctrl_ops, V4L2_CID_HBLANK, hblank, + hblank, 1, hblank); + if (ov12a10->hblank) + ov12a10->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; + v4l2_ctrl_new_std(hdl, &ov12a10_ctrl_ops, V4L2_CID_ANALOGUE_GAIN, 0x80, 0x7ff, 1, 0x300); + ov12a10->exposure = v4l2_ctrl_new_std(hdl, &ov12a10_ctrl_ops, V4L2_CID_EXPOSURE, 4, + 3360, 1, 2400); + v4l2_ctrl_new_std_menu_items(hdl, &ov12a10_ctrl_ops, V4L2_CID_TEST_PATTERN, 4, 0, 0, + ov12a10_test_pattern_menu); + if (hdl->error) { + ret = hdl->error; + goto err; + } + ret = v4l2_fwnode_device_parse(ov12a10->dev, &props); + if (ret) + goto err; + ret = v4l2_ctrl_new_fwnode_properties(hdl, &ov12a10_ctrl_ops, &props); + if (ret) + goto err; + ov12a10->sd.ctrl_handler = hdl; + return 0; +err: + v4l2_ctrl_handler_free(hdl); + return ret; +} + +static void ov12a10_update_pad_format(const struct ov12a10_mode *mode, + struct v4l2_mbus_framefmt *fmt) +{ + fmt->width = mode->width; + fmt->height = mode->height; + fmt->code = MEDIA_BUS_FMT_SRGGB10_1X10; + fmt->field = V4L2_FIELD_NONE; + fmt->colorspace = V4L2_COLORSPACE_SRGB; +} + +static int ov12a10_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_format *fmt) +{ + struct ov12a10 *ov12a10 = to_ov12a10(sd); + + fmt->format = (fmt->which == V4L2_SUBDEV_FORMAT_TRY) ? *v4l2_subdev_state_get_format(sd_state, + fmt->pad) : fmt->format; + if (fmt->which != V4L2_SUBDEV_FORMAT_TRY) + ov12a10_update_pad_format(ov12a10->cur_mode, &fmt->format); + return 0; +} + +static int ov12a10_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_format *fmt) +{ + struct ov12a10 *ov12a10 = to_ov12a10(sd); + + ov12a10_update_pad_format(&supported_modes[0], &fmt->format); + if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) + *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; + else + ov12a10->cur_mode = &supported_modes[0]; + + return 0; +} + +static int ov12a10_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_mbus_code_enum *code) +{ + if (code->index > 0) + return -EINVAL; + code->code = MEDIA_BUS_FMT_SRGGB10_1X10; + return 0; +} + +static int ov12a10_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_frame_size_enum *fse) +{ + if (fse->index >= ARRAY_SIZE(supported_modes) || + fse->code != MEDIA_BUS_FMT_SRGGB10_1X10) + return -EINVAL; + fse->min_width = fse->max_width = supported_modes[fse->index].width; + fse->min_height = fse->max_height = supported_modes[fse->index].height; + return 0; +} + +static int ov12a10_set_stream(struct v4l2_subdev *sd, int enable) +{ + struct ov12a10 *ov12a10 = to_ov12a10(sd); + int ret = 0; + + mutex_lock(&ov12a10->mutex); + if (ov12a10->streaming == enable) { + mutex_unlock(&ov12a10->mutex); + return 0; + } + if (enable) { + ret = pm_runtime_resume_and_get(ov12a10->dev); + if (ret < 0) + goto out; + ret = ov12a10_write_regs(ov12a10, ov12a10_common_regs, + ARRAY_SIZE(ov12a10_common_regs)); + if (!ret) + ret = ov12a10_write_regs(ov12a10, ov12a10->cur_mode->regs, + ov12a10->cur_mode->num_regs); + if (!ret) + ret = __v4l2_ctrl_handler_setup(ov12a10->sd.ctrl_handler); + if (!ret) { + static const struct ov12a10_reg stream_on_regs[] = { + { 0x0100, 0x01 }, + }; + usleep_range(10000, 12000); + ret = ov12a10_write_regs(ov12a10, stream_on_regs, + ARRAY_SIZE(stream_on_regs)); + } + if (ret) { + pm_runtime_put(ov12a10->dev); + goto out; + } + } else { + ov12a10_write_reg(ov12a10, OV12A10_REG_MODE_SELECT, 1, OV12A10_MODE_STANDBY); + pm_runtime_put(ov12a10->dev); + } + ov12a10->streaming = enable; +out: + mutex_unlock(&ov12a10->mutex); + return ret; +} + +static int ov12a10_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) +{ + struct ov12a10 *ov12a10 = to_ov12a10(sd); + + mutex_lock(&ov12a10->mutex); + ov12a10_update_pad_format(&supported_modes[0], v4l2_subdev_state_get_format(fh->state, + 0)); + mutex_unlock(&ov12a10->mutex); + return 0; +} + +static const struct v4l2_subdev_video_ops ov12a10_video_ops = { .s_stream = ov12a10_set_stream }; + +static int ov12a10_get_selection(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_selection *sel) +{ + switch (sel->target) { + case V4L2_SEL_TGT_CROP: + case V4L2_SEL_TGT_CROP_DEFAULT: + case V4L2_SEL_TGT_CROP_BOUNDS: + case V4L2_SEL_TGT_NATIVE_SIZE: + sel->r.left = 0; + sel->r.top = 0; + sel->r.width = 1280; + sel->r.height = 720; + return 0; + default: + return -EINVAL; + } +} + +static const struct v4l2_subdev_pad_ops ov12a10_pad_ops = { + .get_selection = ov12a10_get_selection, + .set_fmt = ov12a10_set_format, .get_fmt = ov12a10_get_format, + .enum_mbus_code = ov12a10_enum_mbus_code, .enum_frame_size = ov12a10_enum_frame_size, +}; +static const struct v4l2_subdev_ops ov12a10_subdev_ops = { + .video = &ov12a10_video_ops, + .pad = &ov12a10_pad_ops, +}; +static const struct media_entity_operations ov12a10_entity_ops = { + .link_validate = v4l2_subdev_link_validate, +}; +static const struct v4l2_subdev_internal_ops ov12a10_internal_ops = { .open = ov12a10_open }; + +static int ov12a10_probe(struct i2c_client *client) +{ + struct device *dev = &client->dev; + struct ov12a10 *ov12a10; + u32 val = 0; + unsigned int i; + int ret; + + ov12a10 = devm_kzalloc(dev, sizeof(*ov12a10), GFP_KERNEL); + if (!ov12a10) + return -ENOMEM; + ov12a10->dev = dev; + v4l2_i2c_subdev_init(&ov12a10->sd, client, &ov12a10_subdev_ops); + ov12a10->xvclk = devm_v4l2_sensor_clk_get(dev, NULL); + if (IS_ERR(ov12a10->xvclk)) + return dev_err_probe(dev, PTR_ERR(ov12a10->xvclk), "xvclk\n"); + clk_set_rate(ov12a10->xvclk, OV12A10_XVCLK_FREQ); + ov12a10->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); + ov12a10->vana_gpio = devm_gpiod_get_optional(dev, "vana", GPIOD_OUT_LOW); + ov12a10->pwdn_gpio = devm_gpiod_get_optional(dev, "pwdn", GPIOD_OUT_HIGH); + if (IS_ERR(ov12a10->reset_gpio)) + return dev_err_probe(dev, PTR_ERR(ov12a10->reset_gpio), "reset\n"); + for (i = 0; i < OV12A10_NUM_SUPPLIES; i++) + ov12a10->supplies[i].supply = ov12a10_supply_names[i]; + ret = devm_regulator_bulk_get(dev, OV12A10_NUM_SUPPLIES, ov12a10->supplies); + if (ret) + return dev_err_probe(dev, ret, "regulators\n"); + ret = ov12a10_power_on(dev); + if (ret) + return ret; + ret = ov12a10_read_reg(ov12a10, OV12A10_CHIP_ID_REG, 2, &val); + if (ret || val != OV12A10_CHIP_ID) { + dev_err(dev, "failed to identify ov12a10 (ret=%d, id=0x%04x)\n", ret, val); + ret = ret ? ret : -ENXIO; + goto err_power; + } + dev_info(dev, "identified OmniVision OV12A10 sensor (0x%04x)\n", val); + mutex_init(&ov12a10->mutex); + ov12a10->cur_mode = &supported_modes[0]; + ret = ov12a10_init_controls(ov12a10); + if (ret) + goto err_mutex; + ov12a10->sd.internal_ops = &ov12a10_internal_ops; + ov12a10->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; + ov12a10->sd.entity.ops = &ov12a10_entity_ops; + ov12a10->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; + ov12a10->pad.flags = MEDIA_PAD_FL_SOURCE; + ret = media_entity_pads_init(&ov12a10->sd.entity, 1, &ov12a10->pad); + if (ret) + goto err_ctrl; + ov12a10->sd.state_lock = &ov12a10->mutex; + ret = v4l2_subdev_init_finalize(&ov12a10->sd); + if (ret) + goto err_media; + ret = v4l2_async_register_subdev_sensor(&ov12a10->sd); + if (ret) + goto err_media; + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + pm_runtime_idle(dev); + return 0; +err_media: media_entity_cleanup(&ov12a10->sd.entity); +err_ctrl: v4l2_ctrl_handler_free(ov12a10->sd.ctrl_handler); +err_mutex: mutex_destroy(&ov12a10->mutex); +err_power: ov12a10_power_off(dev); + return ret; +} + +static void ov12a10_remove(struct i2c_client *client) +{ + struct v4l2_subdev *sd = i2c_get_clientdata(client); + struct ov12a10 *ov12a10 = to_ov12a10(sd); + + v4l2_async_unregister_subdev(sd); + media_entity_cleanup(&sd->entity); + v4l2_ctrl_handler_free(sd->ctrl_handler); + mutex_destroy(&ov12a10->mutex); + pm_runtime_disable(&client->dev); + if (!pm_runtime_status_suspended(&client->dev)) + ov12a10_power_off(&client->dev); + pm_runtime_set_suspended(&client->dev); +} + +static const struct dev_pm_ops ov12a10_pm_ops = { SET_RUNTIME_PM_OPS(ov12a10_power_off, + ov12a10_power_on, NULL) }; +static const struct of_device_id ov12a10_of_match[] = { { .compatible = "ovti,ov12a10" }, { } }; +MODULE_DEVICE_TABLE(of, ov12a10_of_match); +static struct i2c_driver ov12a10_i2c_driver = { + .driver = { .name = "ov12a10", .pm = &ov12a10_pm_ops, .of_match_table = ov12a10_of_match }, + .probe = ov12a10_probe, .remove = ov12a10_remove, +}; +module_i2c_driver(ov12a10_i2c_driver); +MODULE_DESCRIPTION("Samsung OV12A10 5MP sensor driver"); +MODULE_LICENSE("GPL"); -- 2.47.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 6/6] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras 2026-11-23 11:07 [PATCH 0/6] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar ` (4 preceding siblings ...) 2026-11-23 11:08 ` [PATCH 5/6] media: i2c: add ov12a10 image sensor driver Hikmah Gumelar @ 2026-11-23 11:08 ` Hikmah Gumelar 2026-11-23 12:35 ` [PATCH v2 0/7] " Hikmah Gumelar 6 siblings, 0 replies; 17+ messages in thread From: Hikmah Gumelar @ 2026-11-23 11:08 UTC (permalink / raw) To: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Michael Turquette, Stephen Boyd, Brian Masney, Sakari Ailus Cc: Hikmah Gumelar, linux-media, devicetree, linux-kernel, linux-arm-msm, linux-clk Enable the CAMSS, CCI, CSIPHY0/CSIPHY2 ports, and the OmniVision OV12A10 rear camera and Samsung S5K5E8 front camera on Xiaomi Mi A1 (tissot). Signed-off-by: Hikmah Gumelar <hikmahgumelar@gmail.com> --- .../boot/dts/qcom/msm8953-xiaomi-tissot.dts | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts b/arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts index 8ba7982fcd81..40a14301ee3f 100644 --- a/arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts +++ b/arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts @@ -271,6 +271,20 @@ headphones_amp_default: headphones-switch-default-state { bias-disable; output-low; }; + + cam_sensor_rear_default: cam-sensor-rear-default-state { + pins = "gpio33", "gpio39", "gpio62"; + function = "gpio"; + bias-disable; + drive-strength = <2>; + }; + + cam_sensor_front_default: cam-sensor-front-default-state { + pins = "gpio129"; + function = "gpio"; + bias-disable; + drive-strength = <2>; + }; }; &uart_0 { @@ -288,3 +302,103 @@ &wcd_codec { qcom,mbhc-vthreshold-high = <91 259 488 488 488>; qcom,mbhc-vthreshold-low = <91 259 488 488 488>; }; + +&camss { + status = "okay"; + vdda-supply = <&pm8953_s3>; + + ports { + port@0 { + reg = <0>; + csiphy0_ep: endpoint { + clock-lanes = <7>; + data-lanes = <0 1 2 3>; + remote-endpoint = <&rear_cam_ep>; + }; + }; + + port@2 { + reg = <2>; + csiphy2_ep: endpoint { + clock-lanes = <7>; + data-lanes = <0 1>; + remote-endpoint = <&front_cam_ep>; + }; + }; + }; +}; + +&cci { + pinctrl-names = "default"; + pinctrl-0 = <&cci0_default>, + <&cci1_default>, + <&camss_mclk0_default>, + <&camss_mclk1_default>, + <&camss_mclk2_default>; + + status = "okay"; +}; + +&cci_i2c0 { + camera-sensor@10 { + compatible = "ovti,ov12a10"; + reg = <0x10>; + clocks = <&gcc GCC_CAMSS_MCLK0_CLK>; + pinctrl-0 = <&cam_sensor_rear_default>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 33 GPIO_ACTIVE_LOW>; + pwdn-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + vana-gpios = <&tlmm 62 GPIO_ACTIVE_HIGH>; + avdd-supply = <&pm8953_l22>; + dvdd-supply = <&pm8953_l2>; + dovdd-supply = <&pm8953_l6>; + rotation = <270>; + orientation = <1>; + status = "okay"; + port { + rear_cam_ep: endpoint { + data-lanes = <0 1 2 3>; + remote-endpoint = <&csiphy0_ep>; + link-frequencies = /bits/ 64 <216000000>; + }; + }; + }; +}; + +&cci_i2c1 { + camera-sensor@2d { + compatible = "samsung,s5k5e8"; + reg = <0x2d>; + + clocks = <&gcc GCC_CAMSS_MCLK1_CLK>; + pinctrl-0 = <&cam_sensor_front_default>; + pinctrl-names = "default"; + + reset-gpios = <&tlmm 129 GPIO_ACTIVE_LOW>; + + avdd-supply = <&pm8953_l22>; + dvdd-supply = <&pm8953_l23>; + dovdd-supply = <&pm8953_l6>; + rotation = <90>; + orientation = <0>; + + status = "okay"; + + port { + front_cam_ep: endpoint { + data-lanes = <0 1>; + remote-endpoint = <&csiphy2_ep>; + link-frequencies = /bits/ 64 <418000000>; + }; + }; + }; +}; + +&pm8953_l23 { + regulator-min-microvolt = <1200000>; +}; + +&pm8953_l2 { + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1225000>; +}; -- 2.47.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 0/7] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras 2026-11-23 11:07 [PATCH 0/6] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar ` (5 preceding siblings ...) 2026-11-23 11:08 ` [PATCH 6/6] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar @ 2026-11-23 12:35 ` Hikmah Gumelar 2026-11-23 12:35 ` [PATCH v2 1/7] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent Hikmah Gumelar ` (6 more replies) 6 siblings, 7 replies; 17+ messages in thread From: Hikmah Gumelar @ 2026-11-23 12:35 UTC (permalink / raw) To: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Abel Vesa, Stephen Boyd, Brian Masney, Jerome Brunet, Sakari Ailus Cc: Hikmah Gumelar, linux-media, devicetree, linux-kernel, linux-arm-msm, linux-clk Enable both the front (Samsung S5K5E8) and rear (OmniVision OV12A10) MIPI CSI-2 cameras on Xiaomi Mi A1 (msm8953-xiaomi-tissot). Changes in v2: - Rebased onto linux-media/media-committers.git next branch. - Updated set_fmt and get_selection pad ops signatures for v7.4-rc. - Added the missing MSM8953 SoC CAMSS node and MCLK pinctrl states to msm8953.dtsi so the board DTB builds cleanly on upstream. Hikmah Gumelar (7): clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent media: dt-bindings: media: i2c: add Samsung S5K5E8 media: i2c: add s5k5e8 image sensor driver media: dt-bindings: media: i2c: add OmniVision OV12A10 media: i2c: add ov12a10 image sensor driver arm64: dts: qcom: msm8953: add CAMSS node and MCLK pinctrl states arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras .../bindings/media/i2c/ovti,ov12a10.yaml | 115 +++ .../bindings/media/i2c/samsung,s5k5e8.yaml | 103 +++ .../boot/dts/qcom/msm8953-xiaomi-tissot.dts | 114 +++ arch/arm64/boot/dts/qcom/msm8953.dtsi | 155 ++++ drivers/clk/qcom/gcc-msm8953.c | 2 +- drivers/media/i2c/Kconfig | 18 + drivers/media/i2c/Makefile | 2 + drivers/media/i2c/ov12a10.c | 720 ++++++++++++++++++ drivers/media/i2c/s5k5e8.c | 500 ++++++++++++ 9 files changed, 1728 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml create mode 100644 Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml create mode 100644 drivers/media/i2c/ov12a10.c create mode 100644 drivers/media/i2c/s5k5e8.c -- 2.47.3 ^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 1/7] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent 2026-11-23 12:35 ` [PATCH v2 0/7] " Hikmah Gumelar @ 2026-11-23 12:35 ` Hikmah Gumelar 2026-11-23 12:35 ` [PATCH v2 2/7] media: dt-bindings: media: i2c: add Samsung S5K5E8 Hikmah Gumelar ` (5 subsequent siblings) 6 siblings, 0 replies; 17+ messages in thread From: Hikmah Gumelar @ 2026-11-23 12:35 UTC (permalink / raw) To: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Abel Vesa, Stephen Boyd, Brian Masney, Jerome Brunet, Sakari Ailus Cc: Hikmah Gumelar, linux-media, devicetree, linux-kernel, linux-arm-msm, linux-clk The 100 MHz entry in ftbl_csi_phytimer_clk_src selects P_GPLL0_DIV2 with a divider of 4, which leaves gcc_camss_csi0phytimer_clk stuck off on MSM8953 platforms such as Xiaomi Mi A1 (tissot). Switch the 100 MHz parent to P_GPLL0 with a divider of 8 (800 MHz / 8 = 100 MHz), matching the 200 MHz and 266.67 MHz entries. Signed-off-by: Hikmah Gumelar <hikmahgumelar@gmail.com> --- drivers/clk/qcom/gcc-msm8953.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/qcom/gcc-msm8953.c b/drivers/clk/qcom/gcc-msm8953.c index 8fe1d3e42144..8aec5600e837 100644 --- a/drivers/clk/qcom/gcc-msm8953.c +++ b/drivers/clk/qcom/gcc-msm8953.c @@ -964,7 +964,7 @@ static struct clk_rcg2 csi2p_clk_src = { }; static const struct freq_tbl ftbl_csi_phytimer_clk_src[] = { - F(100000000, P_GPLL0_DIV2, 4, 0, 0), + F(100000000, P_GPLL0, 8, 0, 0), F(200000000, P_GPLL0, 4, 0, 0), F(266670000, P_GPLL0, 3, 0, 0), { } -- 2.47.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 2/7] media: dt-bindings: media: i2c: add Samsung S5K5E8 2026-11-23 12:35 ` [PATCH v2 0/7] " Hikmah Gumelar 2026-11-23 12:35 ` [PATCH v2 1/7] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent Hikmah Gumelar @ 2026-11-23 12:35 ` Hikmah Gumelar 2026-11-23 12:35 ` [PATCH v2 3/7] media: i2c: add s5k5e8 image sensor driver Hikmah Gumelar ` (4 subsequent siblings) 6 siblings, 0 replies; 17+ messages in thread From: Hikmah Gumelar @ 2026-11-23 12:35 UTC (permalink / raw) To: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Abel Vesa, Stephen Boyd, Brian Masney, Jerome Brunet, Sakari Ailus Cc: Hikmah Gumelar, linux-media, devicetree, linux-kernel, linux-arm-msm, linux-clk Add Devicetree binding schema for the Samsung S5K5E8 5-megapixel MIPI CSI-2 CMOS image sensor. Signed-off-by: Hikmah Gumelar <hikmahgumelar@gmail.com> --- .../bindings/media/i2c/samsung,s5k5e8.yaml | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml diff --git a/Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml b/Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml new file mode 100644 index 000000000000..0e440209c3fd --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/samsung,s5k5e8.yaml @@ -0,0 +1,103 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org +$schema: http://devicetree.org + +title: Samsung S5K5E8 1/5-inch 5Mp CMOS Image Sensor + +maintainers: + - Hikmah Gumelar <hikmahgumelar@gmail.com> + +description: + Samsung S5K5E8 is a 1/5-inch 5-megapixel CMOS active-pixel digital image + sensor with a 2-lane MIPI CSI-2 interface and I2C control bus. + +allOf: + - $ref: /schemas/media/video-interface-devices.yaml# + +properties: + compatible: + const: samsung,s5k5e8 + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + reset-gpios: + description: Active-low reset GPIO. + maxItems: 1 + + avdd-supply: + description: Analog power supply (2.8V). + + dvdd-supply: + description: Digital core power supply (1.2V). + + dovdd-supply: + description: Digital I/O power supply (1.8V). + + port: + $ref: /schemas/graph.yaml#/$defs/port-base + additionalProperties: false + + properties: + endpoint: + $ref: /schemas/media/video-interfaces.yaml# + unevaluatedProperties: false + + properties: + data-lanes: + items: + - const: 0 + - const: 1 + + link-frequencies: true + + required: + - data-lanes + - link-frequencies + + required: + - endpoint + +required: + - compatible + - reg + - clocks + - avdd-supply + - dvdd-supply + - dovdd-supply + - port + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + camera-sensor@2d { + compatible = "samsung,s5k5e8"; + reg = <0x2d>; + clocks = <&camss_mclk1>; + reset-gpios = <&tlmm 129 GPIO_ACTIVE_LOW>; + avdd-supply = <&pm8953_l22>; + dvdd-supply = <&pm8953_l23>; + dovdd-supply = <&pm8953_l6>; + + port { + endpoint { + data-lanes = <0 1>; + remote-endpoint = <&csiphy2_ep>; + link-frequencies = /bits/ 64 <418000000>; + }; + }; + }; + }; +... -- 2.47.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 3/7] media: i2c: add s5k5e8 image sensor driver 2026-11-23 12:35 ` [PATCH v2 0/7] " Hikmah Gumelar 2026-11-23 12:35 ` [PATCH v2 1/7] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent Hikmah Gumelar 2026-11-23 12:35 ` [PATCH v2 2/7] media: dt-bindings: media: i2c: add Samsung S5K5E8 Hikmah Gumelar @ 2026-11-23 12:35 ` Hikmah Gumelar 2026-11-23 13:56 ` Uwe Kleine-König 2026-11-23 12:35 ` [PATCH v2 4/7] media: dt-bindings: media: i2c: add OmniVision OV12A10 Hikmah Gumelar ` (3 subsequent siblings) 6 siblings, 1 reply; 17+ messages in thread From: Hikmah Gumelar @ 2026-11-23 12:35 UTC (permalink / raw) To: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Abel Vesa, Stephen Boyd, Brian Masney, Jerome Brunet, Sakari Ailus Cc: Hikmah Gumelar, linux-media, devicetree, linux-kernel, linux-arm-msm, linux-clk Signed-off-by: Hikmah Gumelar <hikmahgumelar@gmail.com> --- drivers/media/i2c/Kconfig | 9 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/s5k5e8.c | 500 +++++++++++++++++++++++++++++++++++++ 3 files changed, 510 insertions(+) create mode 100644 drivers/media/i2c/s5k5e8.c diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index 162b8ea02601..095a911c5043 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig @@ -879,6 +879,15 @@ config VIDEO_S5K3M5 To compile this driver as a module, choose M here: the module will be called s5k3m5. +config VIDEO_S5K5E8 + tristate "Samsung S5K5E8 sensor support" + depends on I2C && VIDEO_DEV + select MEDIA_CONTROLLER + select VIDEO_V4L2_SUBDEV_API + select V4L2_FWNODE + help + V4L2 sensor driver for Samsung S5K5E8. + config VIDEO_S5K5BAF tristate "Samsung S5K5BAF sensor support" help diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile index a750942e9c62..bdcb8f34aca3 100644 --- a/drivers/media/i2c/Makefile +++ b/drivers/media/i2c/Makefile @@ -136,6 +136,7 @@ obj-$(CONFIG_VIDEO_RDACM21) += rdacm21.o obj-$(CONFIG_VIDEO_RJ54N1) += rj54n1cb0c.o obj-$(CONFIG_VIDEO_S5C73M3) += s5c73m3/ obj-$(CONFIG_VIDEO_S5K3M5) += s5k3m5.o +obj-$(CONFIG_VIDEO_S5K5E8) += s5k5e8.o obj-$(CONFIG_VIDEO_S5K5BAF) += s5k5baf.o obj-$(CONFIG_VIDEO_S5K6A3) += s5k6a3.o obj-$(CONFIG_VIDEO_S5KJN1) += s5kjn1.o diff --git a/drivers/media/i2c/s5k5e8.c b/drivers/media/i2c/s5k5e8.c new file mode 100644 index 000000000000..80931e5a1c6b --- /dev/null +++ b/drivers/media/i2c/s5k5e8.c @@ -0,0 +1,500 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/gpio/consumer.h> +#include <linux/i2c.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/pm_runtime.h> +#include <linux/regulator/consumer.h> +#include <linux/unaligned.h> +#include <media/v4l2-ctrls.h> +#include <media/v4l2-device.h> +#include <media/v4l2-fwnode.h> + +#define S5K5E8_CHIP_ID_REG 0x0000 +#define S5K5E8_CHIP_ID 0x5e80 +#define S5K5E8_REG_MODE_SELECT 0x0100 +#define S5K5E8_MODE_STANDBY 0x00 +#define S5K5E8_MODE_STREAMING 0x01 +#define S5K5E8_REG_VTS 0x0340 +#define S5K5E8_REG_EXPOSURE 0x0202 +#define S5K5E8_REG_ANALOG_GAIN 0x0204 +#define S5K5E8_REG_TEST_PATTERN 0x0600 +#define S5K5E8_XVCLK_FREQ 24000000 +#define S5K5E8_LINK_FREQ_418MHZ 418000000ULL +#define S5K5E8_PIXEL_RATE 167200000ULL + +struct s5k5e8_reg { u16 address; +u8 val; +}; +struct s5k5e8_mode { + u32 width, height, hts_def, vts_def, vts_min, num_regs; + const struct s5k5e8_reg *regs; +}; + +static const char * const s5k5e8_supply_names[] = { "avdd", "dvdd", "dovdd" }; +#define S5K5E8_NUM_SUPPLIES ARRAY_SIZE(s5k5e8_supply_names) + +static const struct s5k5e8_reg s5k5e8_common_regs[] = { + { 0x0100, 0x00 }, { 0x3906, 0x7e }, { 0x3c01, 0x0f }, { 0x3c14, 0x00 }, + { 0x3235, 0x08 }, { 0x3063, 0x2e }, { 0x307a, 0x10 }, { 0x307b, 0x0e }, + { 0x3079, 0x20 }, { 0x3070, 0x05 }, { 0x3067, 0x06 }, { 0x3071, 0x62 }, + { 0x3072, 0x16 }, { 0x3203, 0x43 }, { 0x3205, 0x43 }, { 0x320b, 0x42 }, + { 0x3007, 0x00 }, { 0x3008, 0x14 }, { 0x3020, 0x58 }, { 0x300d, 0x34 }, + { 0x300e, 0x17 }, { 0x3021, 0x02 }, { 0x3010, 0x59 }, { 0x3002, 0x01 }, + { 0x3005, 0x01 }, { 0x3008, 0x04 }, { 0x300f, 0x70 }, { 0x3010, 0x69 }, + { 0x3017, 0x10 }, { 0x3019, 0x19 }, { 0x300c, 0x62 }, { 0x3064, 0x10 }, + { 0x3c08, 0x0e }, { 0x3c09, 0x10 }, { 0x3c31, 0x0d }, { 0x3c32, 0xac }, +}; + +static const struct s5k5e8_reg s5k5e8_2592x1944_regs[] = { + { 0x0100, 0x00 }, { 0x0136, 0x18 }, { 0x0137, 0x00 }, { 0x0305, 0x06 }, + { 0x0306, 0x18 }, { 0x0307, 0xa8 }, { 0x0308, 0x34 }, { 0x0309, 0x42 }, + { 0x3c1f, 0x00 }, { 0x3c17, 0x00 }, { 0x3c0b, 0x04 }, { 0x3c1c, 0x47 }, + { 0x3c1d, 0x15 }, { 0x3c14, 0x04 }, { 0x3c16, 0x00 }, { 0x0820, 0x03 }, + { 0x0821, 0x44 }, { 0x0114, 0x01 }, { 0x0344, 0x00 }, { 0x0345, 0x08 }, + { 0x0346, 0x00 }, { 0x0347, 0x08 }, { 0x0348, 0x0a }, { 0x0349, 0x27 }, + { 0x034a, 0x07 }, { 0x034b, 0x9f }, { 0x034c, 0x0a }, { 0x034d, 0x20 }, + { 0x034e, 0x07 }, { 0x034f, 0x98 }, { 0x0900, 0x00 }, { 0x0901, 0x00 }, + { 0x0381, 0x01 }, { 0x0383, 0x01 }, { 0x0385, 0x01 }, { 0x0387, 0x01 }, + { 0x0340, 0x07 }, { 0x0341, 0xb0 }, { 0x0342, 0x0b }, { 0x0343, 0x28 }, + { 0x0200, 0x00 }, { 0x0201, 0x00 }, { 0x0202, 0x03 }, { 0x0203, 0xde }, + { 0x3303, 0x02 }, { 0x3400, 0x00 }, { 0x323b, 0x02 }, { 0x3301, 0x00 }, + { 0x3321, 0x04 }, { 0x3306, 0x00 }, { 0x3307, 0x08 }, { 0x3308, 0x0a }, + { 0x3309, 0x27 }, { 0x330a, 0x01 }, { 0x330b, 0x01 }, { 0x330e, 0x00 }, + { 0x330f, 0x08 }, { 0x3310, 0x07 }, { 0x3311, 0x9f }, { 0x3312, 0x01 }, + { 0x3313, 0x01 }, +}; + +static const struct s5k5e8_mode supported_modes[] = { + { + .width = 2592, .height = 1944, .hts_def = 2856, + .vts_def = 1968, .vts_min = 1968, + .num_regs = ARRAY_SIZE(s5k5e8_2592x1944_regs), + .regs = s5k5e8_2592x1944_regs, + }, +}; + +static const s64 link_freq_menu_items[] = { S5K5E8_LINK_FREQ_418MHZ }; + +struct s5k5e8 { + struct device *dev; + struct v4l2_subdev sd; + struct media_pad pad; + struct clk *xvclk; + struct gpio_desc *reset_gpio; + struct regulator_bulk_data supplies[S5K5E8_NUM_SUPPLIES]; + struct v4l2_ctrl_handler ctrl_handler; + struct v4l2_ctrl *link_freq, *pixel_rate, *vblank, *hblank, *exposure; + const struct s5k5e8_mode *cur_mode; + /* Serialize access to sensor registers and streaming state */ + struct mutex mutex; + bool streaming; +}; + +static inline struct s5k5e8 *to_s5k5e8(struct v4l2_subdev *sd) +{ + return container_of(sd, struct s5k5e8, sd); +} + +static int s5k5e8_read_reg(struct s5k5e8 *s5k5e8, u16 reg, u32 len, u32 *val) +{ + struct i2c_client *client = v4l2_get_subdevdata(&s5k5e8->sd); + struct i2c_msg msgs[2]; + u8 addr_buf[2], data_buf[4] = { 0 }; + int ret; + + put_unaligned_be16(reg, addr_buf); + msgs[0].addr = client->addr; + msgs[0].flags = 0; + msgs[0].len = 2; + msgs[0].buf = addr_buf; + msgs[1].addr = client->addr; + msgs[1].flags = I2C_M_RD; + msgs[1].len = len; + msgs[1].buf = &data_buf[4 - len]; + ret = i2c_transfer(client->adapter, msgs, 2); + if (ret != 2) + return ret < 0 ? ret : -EIO; + *val = get_unaligned_be32(data_buf); + return 0; +} + +static int s5k5e8_write_reg(struct s5k5e8 *s5k5e8, u16 reg, u32 len, u32 val) +{ + struct i2c_client *client = v4l2_get_subdevdata(&s5k5e8->sd); + u8 buf[6]; + int ret; + + put_unaligned_be16(reg, buf); + put_unaligned_be32(val << (8 * (4 - len)), buf + 2); + ret = i2c_master_send(client, buf, len + 2); + return ret == len + 2 ? 0 : (ret < 0 ? ret : -EIO); +} + +static int s5k5e8_write_regs(struct s5k5e8 *s5k5e8, const struct s5k5e8_reg *regs, u32 len) +{ + u32 i; + int ret; + + for (i = 0; i < len; i++) { + ret = s5k5e8_write_reg(s5k5e8, regs[i].address, 1, regs[i].val); + if (ret) + return ret; + } + return 0; +} + +static int s5k5e8_power_on(struct device *dev) +{ + struct s5k5e8 *s5k5e8 = to_s5k5e8(dev_get_drvdata(dev)); + int ret = regulator_bulk_enable(S5K5E8_NUM_SUPPLIES, s5k5e8->supplies); + + if (ret) + return ret; + ret = clk_prepare_enable(s5k5e8->xvclk); + if (ret) { + regulator_bulk_disable(S5K5E8_NUM_SUPPLIES, s5k5e8->supplies); + return ret; + } + if (s5k5e8->reset_gpio) { + gpiod_set_value_cansleep(s5k5e8->reset_gpio, 1); + usleep_range(1000, 2000); + gpiod_set_value_cansleep(s5k5e8->reset_gpio, 0); + usleep_range(3000, 5000); + } + return 0; +} + +static int s5k5e8_power_off(struct device *dev) +{ + struct s5k5e8 *s5k5e8 = to_s5k5e8(dev_get_drvdata(dev)); + + if (s5k5e8->reset_gpio) + gpiod_set_value_cansleep(s5k5e8->reset_gpio, 1); + clk_disable_unprepare(s5k5e8->xvclk); + regulator_bulk_disable(S5K5E8_NUM_SUPPLIES, s5k5e8->supplies); + return 0; +} + +static int s5k5e8_set_ctrl(struct v4l2_ctrl *ctrl) +{ + struct s5k5e8 *s5k5e8 = container_of(ctrl->handler, struct s5k5e8, ctrl_handler); + int ret = 0; + + if (!pm_runtime_get_if_in_use(s5k5e8->dev)) + return 0; + switch (ctrl->id) { + case V4L2_CID_ANALOGUE_GAIN: + ret = s5k5e8_write_reg(s5k5e8, S5K5E8_REG_ANALOG_GAIN, 2, ctrl->val); + break; + case V4L2_CID_EXPOSURE: + ret = s5k5e8_write_reg(s5k5e8, S5K5E8_REG_EXPOSURE, 2, ctrl->val); + break; + case V4L2_CID_VBLANK: + ret = s5k5e8_write_reg(s5k5e8, S5K5E8_REG_VTS, 2, + s5k5e8->cur_mode->height + ctrl->val); + break; + case V4L2_CID_TEST_PATTERN: + ret = s5k5e8_write_reg(s5k5e8, S5K5E8_REG_TEST_PATTERN, 2, ctrl->val); + break; + } + pm_runtime_put(s5k5e8->dev); + return ret; +} + +static const struct v4l2_ctrl_ops s5k5e8_ctrl_ops = { .s_ctrl = s5k5e8_set_ctrl }; +static const char * const s5k5e8_test_pattern_menu[] = { + "Disabled", + "Solid Color", + "100% Color Bars", + "Fade to Grey", + "PN9", +}; + +static int s5k5e8_init_controls(struct s5k5e8 *s5k5e8) +{ + struct v4l2_fwnode_device_properties props; + struct v4l2_ctrl_handler *hdl = &s5k5e8->ctrl_handler; + s64 hblank = s5k5e8->cur_mode->hts_def - s5k5e8->cur_mode->width; + int ret = v4l2_ctrl_handler_init(hdl, 8); + + if (ret) + return ret; + hdl->lock = &s5k5e8->mutex; + s5k5e8->link_freq = v4l2_ctrl_new_int_menu(hdl, &s5k5e8_ctrl_ops, V4L2_CID_LINK_FREQ, + 0, 0, link_freq_menu_items); + if (s5k5e8->link_freq) + s5k5e8->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; + s5k5e8->pixel_rate = v4l2_ctrl_new_std(hdl, &s5k5e8_ctrl_ops, V4L2_CID_PIXEL_RATE, + S5K5E8_PIXEL_RATE, S5K5E8_PIXEL_RATE, 1, S5K5E8_PIXEL_RATE); + s5k5e8->vblank = v4l2_ctrl_new_std(hdl, &s5k5e8_ctrl_ops, V4L2_CID_VBLANK, 24, + 0x7fff - s5k5e8->cur_mode->height, 1, 24); + s5k5e8->hblank = v4l2_ctrl_new_std(hdl, &s5k5e8_ctrl_ops, V4L2_CID_HBLANK, hblank, + hblank, 1, hblank); + if (s5k5e8->hblank) + s5k5e8->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; + v4l2_ctrl_new_std(hdl, &s5k5e8_ctrl_ops, V4L2_CID_ANALOGUE_GAIN, 0x20, 0x200, 1, 0x60); + s5k5e8->exposure = v4l2_ctrl_new_std(hdl, &s5k5e8_ctrl_ops, V4L2_CID_EXPOSURE, 4, 1964, + 1, 1960); + v4l2_ctrl_new_std_menu_items(hdl, &s5k5e8_ctrl_ops, V4L2_CID_TEST_PATTERN, 4, 0, 0, + s5k5e8_test_pattern_menu); + if (hdl->error) { + ret = hdl->error; + goto err; + } + ret = v4l2_fwnode_device_parse(s5k5e8->dev, &props); + if (ret) + goto err; + ret = v4l2_ctrl_new_fwnode_properties(hdl, &s5k5e8_ctrl_ops, &props); + if (ret) + goto err; + s5k5e8->sd.ctrl_handler = hdl; + return 0; +err: + v4l2_ctrl_handler_free(hdl); + return ret; +} + +static void s5k5e8_update_pad_format(const struct s5k5e8_mode *mode, + struct v4l2_mbus_framefmt *fmt) +{ + fmt->width = mode->width; + fmt->height = mode->height; + fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10; + fmt->field = V4L2_FIELD_NONE; + fmt->colorspace = V4L2_COLORSPACE_SRGB; +} + +static int s5k5e8_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_format *fmt) +{ + struct s5k5e8 *s5k5e8 = to_s5k5e8(sd); + + fmt->format = (fmt->which == V4L2_SUBDEV_FORMAT_TRY) ? *v4l2_subdev_state_get_format(sd_state, + fmt->pad) : fmt->format; + if (fmt->which != V4L2_SUBDEV_FORMAT_TRY) + s5k5e8_update_pad_format(s5k5e8->cur_mode, &fmt->format); + return 0; +} + +static int s5k5e8_set_format(struct v4l2_subdev *sd, const struct v4l2_subdev_client_info *ci, struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_format *fmt) +{ + struct s5k5e8 *s5k5e8 = to_s5k5e8(sd); + + s5k5e8_update_pad_format(&supported_modes[0], &fmt->format); + if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) + *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; + else + s5k5e8->cur_mode = &supported_modes[0]; + + return 0; +} + +static int s5k5e8_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_mbus_code_enum *code) +{ + if (code->index > 0) + return -EINVAL; + code->code = MEDIA_BUS_FMT_SGRBG10_1X10; + return 0; +} + +static int s5k5e8_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_frame_size_enum *fse) +{ + if (fse->index >= ARRAY_SIZE(supported_modes) || + fse->code != MEDIA_BUS_FMT_SGRBG10_1X10) + return -EINVAL; + fse->min_width = fse->max_width = supported_modes[fse->index].width; + fse->min_height = fse->max_height = supported_modes[fse->index].height; + return 0; +} + +static int s5k5e8_set_stream(struct v4l2_subdev *sd, int enable) +{ + struct s5k5e8 *s5k5e8 = to_s5k5e8(sd); + int ret = 0; + + mutex_lock(&s5k5e8->mutex); + if (s5k5e8->streaming == enable) { + mutex_unlock(&s5k5e8->mutex); + return 0; + } + if (enable) { + ret = pm_runtime_resume_and_get(s5k5e8->dev); + if (ret < 0) + goto out; + ret = s5k5e8_write_regs(s5k5e8, s5k5e8_common_regs, + ARRAY_SIZE(s5k5e8_common_regs)); + if (!ret) + ret = s5k5e8_write_regs(s5k5e8, s5k5e8->cur_mode->regs, + s5k5e8->cur_mode->num_regs); + if (!ret) + ret = __v4l2_ctrl_handler_setup(s5k5e8->sd.ctrl_handler); + if (!ret) { + static const struct s5k5e8_reg stream_on_regs[] = { + { 0x3c16, 0x00 }, + { 0x3c0d, 0x04 }, + { 0x0100, 0x01 }, + { 0x3c22, 0x00 }, + { 0x3c22, 0x00 }, + { 0x3c0d, 0x00 }, + }; + msleep(80); + ret = s5k5e8_write_regs(s5k5e8, stream_on_regs, + ARRAY_SIZE(stream_on_regs)); + } + if (ret) { + pm_runtime_put(s5k5e8->dev); + goto out; + } + } else { + s5k5e8_write_reg(s5k5e8, S5K5E8_REG_MODE_SELECT, 1, S5K5E8_MODE_STANDBY); + pm_runtime_put(s5k5e8->dev); + } + s5k5e8->streaming = enable; +out: + mutex_unlock(&s5k5e8->mutex); + return ret; +} + +static int s5k5e8_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) +{ + struct s5k5e8 *s5k5e8 = to_s5k5e8(sd); + + mutex_lock(&s5k5e8->mutex); + s5k5e8_update_pad_format(&supported_modes[0], v4l2_subdev_state_get_format(fh->state, 0)); + mutex_unlock(&s5k5e8->mutex); + return 0; +} + +static const struct v4l2_subdev_video_ops s5k5e8_video_ops = { .s_stream = s5k5e8_set_stream }; + +static int s5k5e8_get_selection(struct v4l2_subdev *sd, const struct v4l2_subdev_client_info *ci, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_selection *sel) +{ + switch (sel->target) { + case V4L2_SEL_TGT_CROP: + case V4L2_SEL_TGT_CROP_DEFAULT: + case V4L2_SEL_TGT_CROP_BOUNDS: + case V4L2_SEL_TGT_NATIVE_SIZE: + sel->r.left = 0; + sel->r.top = 0; + sel->r.width = 2592; + sel->r.height = 1944; + return 0; + default: + return -EINVAL; + } +} + +static const struct v4l2_subdev_pad_ops s5k5e8_pad_ops = { + .get_selection = s5k5e8_get_selection, + .set_fmt = s5k5e8_set_format, .get_fmt = s5k5e8_get_format, + .enum_mbus_code = s5k5e8_enum_mbus_code, .enum_frame_size = s5k5e8_enum_frame_size, +}; +static const struct v4l2_subdev_ops s5k5e8_subdev_ops = { + .video = &s5k5e8_video_ops, + .pad = &s5k5e8_pad_ops, +}; +static const struct media_entity_operations s5k5e8_entity_ops = { + .link_validate = v4l2_subdev_link_validate, +}; +static const struct v4l2_subdev_internal_ops s5k5e8_internal_ops = { .open = s5k5e8_open }; + +static int s5k5e8_probe(struct i2c_client *client) +{ + struct device *dev = &client->dev; + struct s5k5e8 *s5k5e8; + u32 val = 0; + unsigned int i; + int ret; + + s5k5e8 = devm_kzalloc(dev, sizeof(*s5k5e8), GFP_KERNEL); + if (!s5k5e8) + return -ENOMEM; + s5k5e8->dev = dev; + v4l2_i2c_subdev_init(&s5k5e8->sd, client, &s5k5e8_subdev_ops); + s5k5e8->xvclk = devm_v4l2_sensor_clk_get(dev, NULL); + if (IS_ERR(s5k5e8->xvclk)) + return dev_err_probe(dev, PTR_ERR(s5k5e8->xvclk), "xvclk\n"); + clk_set_rate(s5k5e8->xvclk, S5K5E8_XVCLK_FREQ); + s5k5e8->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(s5k5e8->reset_gpio)) + return dev_err_probe(dev, PTR_ERR(s5k5e8->reset_gpio), "reset\n"); + for (i = 0; i < S5K5E8_NUM_SUPPLIES; i++) + s5k5e8->supplies[i].supply = s5k5e8_supply_names[i]; + ret = devm_regulator_bulk_get(dev, S5K5E8_NUM_SUPPLIES, s5k5e8->supplies); + if (ret) + return dev_err_probe(dev, ret, "regulators\n"); + ret = s5k5e8_power_on(dev); + if (ret) + return ret; + ret = s5k5e8_read_reg(s5k5e8, S5K5E8_CHIP_ID_REG, 2, &val); + if (ret || val != S5K5E8_CHIP_ID) { + dev_err(dev, "failed to identify s5k5e8 (ret=%d, id=0x%x)\n", ret, val); + ret = ret ? ret : -ENXIO; + goto err_power; + } + dev_info(dev, "identified Samsung S5K5E8 sensor (0x%04x)\n", val); + mutex_init(&s5k5e8->mutex); + s5k5e8->cur_mode = &supported_modes[0]; + ret = s5k5e8_init_controls(s5k5e8); + if (ret) + goto err_mutex; + s5k5e8->sd.internal_ops = &s5k5e8_internal_ops; + s5k5e8->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; + s5k5e8->sd.entity.ops = &s5k5e8_entity_ops; + s5k5e8->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; + s5k5e8->pad.flags = MEDIA_PAD_FL_SOURCE; + ret = media_entity_pads_init(&s5k5e8->sd.entity, 1, &s5k5e8->pad); + if (ret) + goto err_ctrl; + s5k5e8->sd.state_lock = &s5k5e8->mutex; + ret = v4l2_subdev_init_finalize(&s5k5e8->sd); + if (ret) + goto err_media; + ret = v4l2_async_register_subdev_sensor(&s5k5e8->sd); + if (ret) + goto err_media; + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + pm_runtime_idle(dev); + return 0; +err_media: media_entity_cleanup(&s5k5e8->sd.entity); +err_ctrl: v4l2_ctrl_handler_free(s5k5e8->sd.ctrl_handler); +err_mutex: mutex_destroy(&s5k5e8->mutex); +err_power: s5k5e8_power_off(dev); + return ret; +} + +static void s5k5e8_remove(struct i2c_client *client) +{ + struct v4l2_subdev *sd = i2c_get_clientdata(client); + struct s5k5e8 *s5k5e8 = to_s5k5e8(sd); + + v4l2_async_unregister_subdev(sd); + media_entity_cleanup(&sd->entity); + v4l2_ctrl_handler_free(sd->ctrl_handler); + mutex_destroy(&s5k5e8->mutex); + pm_runtime_disable(&client->dev); + if (!pm_runtime_status_suspended(&client->dev)) + s5k5e8_power_off(&client->dev); + pm_runtime_set_suspended(&client->dev); +} + +static const struct dev_pm_ops s5k5e8_pm_ops = { SET_RUNTIME_PM_OPS(s5k5e8_power_off, + s5k5e8_power_on, NULL) }; +static const struct of_device_id s5k5e8_of_match[] = { { .compatible = "samsung,s5k5e8" }, { } }; +MODULE_DEVICE_TABLE(of, s5k5e8_of_match); +static struct i2c_driver s5k5e8_i2c_driver = { + .driver = { .name = "s5k5e8", .pm = &s5k5e8_pm_ops, .of_match_table = s5k5e8_of_match }, + .probe = s5k5e8_probe, .remove = s5k5e8_remove, +}; +module_i2c_driver(s5k5e8_i2c_driver); +MODULE_DESCRIPTION("Samsung S5K5E8 5MP sensor driver"); +MODULE_LICENSE("GPL"); -- 2.47.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH v2 3/7] media: i2c: add s5k5e8 image sensor driver 2026-11-23 12:35 ` [PATCH v2 3/7] media: i2c: add s5k5e8 image sensor driver Hikmah Gumelar @ 2026-11-23 13:56 ` Uwe Kleine-König 2026-11-23 14:14 ` Hikmah Gumelar 0 siblings, 1 reply; 17+ messages in thread From: Uwe Kleine-König @ 2026-11-23 13:56 UTC (permalink / raw) To: Hikmah Gumelar Cc: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Abel Vesa, Stephen Boyd, Brian Masney, Jerome Brunet, Sakari Ailus, linux-media, devicetree, linux-kernel, linux-arm-msm, linux-clk [-- Attachment #1: Type: text/plain, Size: 8825 bytes --] Hello, On Mon, Nov 23, 2026 at 07:35:42PM +0700, Hikmah Gumelar wrote: > diff --git a/drivers/media/i2c/s5k5e8.c b/drivers/media/i2c/s5k5e8.c > new file mode 100644 > index 000000000000..80931e5a1c6b > --- /dev/null > +++ b/drivers/media/i2c/s5k5e8.c > @@ -0,0 +1,500 @@ > +// SPDX-License-Identifier: GPL-2.0 > +#include <linux/clk.h> > +#include <linux/delay.h> > +#include <linux/gpio/consumer.h> > +#include <linux/i2c.h> > +#include <linux/mod_devicetable.h> <linux/i2c.h> already provides of_device_id, so please drop <linux/mod_devicetable.h> (which adds a lot of unneeded dependencies). > +#include <linux/module.h> > +#include <linux/pm_runtime.h> > +#include <linux/regulator/consumer.h> > +#include <linux/unaligned.h> > +#include <media/v4l2-ctrls.h> > +#include <media/v4l2-device.h> > +#include <media/v4l2-fwnode.h> > + > +#define S5K5E8_CHIP_ID_REG 0x0000 > +#define S5K5E8_CHIP_ID 0x5e80 > +#define S5K5E8_REG_MODE_SELECT 0x0100 > +#define S5K5E8_MODE_STANDBY 0x00 > +#define S5K5E8_MODE_STREAMING 0x01 > +#define S5K5E8_REG_VTS 0x0340 > +#define S5K5E8_REG_EXPOSURE 0x0202 > +#define S5K5E8_REG_ANALOG_GAIN 0x0204 > +#define S5K5E8_REG_TEST_PATTERN 0x0600 > +#define S5K5E8_XVCLK_FREQ 24000000 > +#define S5K5E8_LINK_FREQ_418MHZ 418000000ULL > +#define S5K5E8_PIXEL_RATE 167200000ULL > + > +struct s5k5e8_reg { u16 address; > +u8 val; > +}; > +struct s5k5e8_mode { > + u32 width, height, hts_def, vts_def, vts_min, num_regs; > + const struct s5k5e8_reg *regs; > +}; > + > +static const char * const s5k5e8_supply_names[] = { "avdd", "dvdd", "dovdd" }; > +#define S5K5E8_NUM_SUPPLIES ARRAY_SIZE(s5k5e8_supply_names) > + > +static const struct s5k5e8_reg s5k5e8_common_regs[] = { > + { 0x0100, 0x00 }, { 0x3906, 0x7e }, { 0x3c01, 0x0f }, { 0x3c14, 0x00 }, > + { 0x3235, 0x08 }, { 0x3063, 0x2e }, { 0x307a, 0x10 }, { 0x307b, 0x0e }, > + { 0x3079, 0x20 }, { 0x3070, 0x05 }, { 0x3067, 0x06 }, { 0x3071, 0x62 }, > + { 0x3072, 0x16 }, { 0x3203, 0x43 }, { 0x3205, 0x43 }, { 0x320b, 0x42 }, > + { 0x3007, 0x00 }, { 0x3008, 0x14 }, { 0x3020, 0x58 }, { 0x300d, 0x34 }, > + { 0x300e, 0x17 }, { 0x3021, 0x02 }, { 0x3010, 0x59 }, { 0x3002, 0x01 }, > + { 0x3005, 0x01 }, { 0x3008, 0x04 }, { 0x300f, 0x70 }, { 0x3010, 0x69 }, > + { 0x3017, 0x10 }, { 0x3019, 0x19 }, { 0x300c, 0x62 }, { 0x3064, 0x10 }, > + { 0x3c08, 0x0e }, { 0x3c09, 0x10 }, { 0x3c31, 0x0d }, { 0x3c32, 0xac }, > +}; > + > +static const struct s5k5e8_reg s5k5e8_2592x1944_regs[] = { > + { 0x0100, 0x00 }, { 0x0136, 0x18 }, { 0x0137, 0x00 }, { 0x0305, 0x06 }, > + { 0x0306, 0x18 }, { 0x0307, 0xa8 }, { 0x0308, 0x34 }, { 0x0309, 0x42 }, > + { 0x3c1f, 0x00 }, { 0x3c17, 0x00 }, { 0x3c0b, 0x04 }, { 0x3c1c, 0x47 }, > + { 0x3c1d, 0x15 }, { 0x3c14, 0x04 }, { 0x3c16, 0x00 }, { 0x0820, 0x03 }, > + { 0x0821, 0x44 }, { 0x0114, 0x01 }, { 0x0344, 0x00 }, { 0x0345, 0x08 }, > + { 0x0346, 0x00 }, { 0x0347, 0x08 }, { 0x0348, 0x0a }, { 0x0349, 0x27 }, > + { 0x034a, 0x07 }, { 0x034b, 0x9f }, { 0x034c, 0x0a }, { 0x034d, 0x20 }, > + { 0x034e, 0x07 }, { 0x034f, 0x98 }, { 0x0900, 0x00 }, { 0x0901, 0x00 }, > + { 0x0381, 0x01 }, { 0x0383, 0x01 }, { 0x0385, 0x01 }, { 0x0387, 0x01 }, > + { 0x0340, 0x07 }, { 0x0341, 0xb0 }, { 0x0342, 0x0b }, { 0x0343, 0x28 }, > + { 0x0200, 0x00 }, { 0x0201, 0x00 }, { 0x0202, 0x03 }, { 0x0203, 0xde }, > + { 0x3303, 0x02 }, { 0x3400, 0x00 }, { 0x323b, 0x02 }, { 0x3301, 0x00 }, > + { 0x3321, 0x04 }, { 0x3306, 0x00 }, { 0x3307, 0x08 }, { 0x3308, 0x0a }, > + { 0x3309, 0x27 }, { 0x330a, 0x01 }, { 0x330b, 0x01 }, { 0x330e, 0x00 }, > + { 0x330f, 0x08 }, { 0x3310, 0x07 }, { 0x3311, 0x9f }, { 0x3312, 0x01 }, > + { 0x3313, 0x01 }, > +}; Is this a reverse engineered table of initial register values? A comment would be awesome. > +static const struct s5k5e8_mode supported_modes[] = { > + { > + .width = 2592, .height = 1944, .hts_def = 2856, > + .vts_def = 1968, .vts_min = 1968, > + .num_regs = ARRAY_SIZE(s5k5e8_2592x1944_regs), > + .regs = s5k5e8_2592x1944_regs, > + }, > +}; > + > [...] > +static int s5k5e8_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, > + struct v4l2_subdev_frame_size_enum *fse) > +{ > + if (fse->index >= ARRAY_SIZE(supported_modes) || > + fse->code != MEDIA_BUS_FMT_SGRBG10_1X10) > + return -EINVAL; ARRAY_SIZE(supported_modes) is one. Does supported_modes really need to be an array? > + fse->min_width = fse->max_width = supported_modes[fse->index].width; > + fse->min_height = fse->max_height = supported_modes[fse->index].height; > + return 0; > +} > + > [...] > +static int s5k5e8_probe(struct i2c_client *client) > +{ > + struct device *dev = &client->dev; > + struct s5k5e8 *s5k5e8; > + u32 val = 0; > + unsigned int i; > + int ret; > + > + s5k5e8 = devm_kzalloc(dev, sizeof(*s5k5e8), GFP_KERNEL); > + if (!s5k5e8) > + return -ENOMEM; > + s5k5e8->dev = dev; > + v4l2_i2c_subdev_init(&s5k5e8->sd, client, &s5k5e8_subdev_ops); > + s5k5e8->xvclk = devm_v4l2_sensor_clk_get(dev, NULL); > + if (IS_ERR(s5k5e8->xvclk)) > + return dev_err_probe(dev, PTR_ERR(s5k5e8->xvclk), "xvclk\n"); > + clk_set_rate(s5k5e8->xvclk, S5K5E8_XVCLK_FREQ); > + s5k5e8->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); > + if (IS_ERR(s5k5e8->reset_gpio)) > + return dev_err_probe(dev, PTR_ERR(s5k5e8->reset_gpio), "reset\n"); > + for (i = 0; i < S5K5E8_NUM_SUPPLIES; i++) > + s5k5e8->supplies[i].supply = s5k5e8_supply_names[i]; > + ret = devm_regulator_bulk_get(dev, S5K5E8_NUM_SUPPLIES, s5k5e8->supplies); > + if (ret) > + return dev_err_probe(dev, ret, "regulators\n"); > + ret = s5k5e8_power_on(dev); > + if (ret) > + return ret; > + ret = s5k5e8_read_reg(s5k5e8, S5K5E8_CHIP_ID_REG, 2, &val); > + if (ret || val != S5K5E8_CHIP_ID) { > + dev_err(dev, "failed to identify s5k5e8 (ret=%d, id=0x%x)\n", ret, val); Use dev_err_probe() for error messages in the probe function. > + ret = ret ? ret : -ENXIO; > + goto err_power; > + } > + dev_info(dev, "identified Samsung S5K5E8 sensor (0x%04x)\n", val); Degrade to dev_dbg() or drop. Once the driver is considered ok, messages of this kind only clutter the kernel log with very little value and add to the boot time. > + mutex_init(&s5k5e8->mutex); > + s5k5e8->cur_mode = &supported_modes[0]; > + ret = s5k5e8_init_controls(s5k5e8); > + if (ret) > + goto err_mutex; > + s5k5e8->sd.internal_ops = &s5k5e8_internal_ops; > + s5k5e8->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; > + s5k5e8->sd.entity.ops = &s5k5e8_entity_ops; > + s5k5e8->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; > + s5k5e8->pad.flags = MEDIA_PAD_FL_SOURCE; > + ret = media_entity_pads_init(&s5k5e8->sd.entity, 1, &s5k5e8->pad); > + if (ret) > + goto err_ctrl; Use newlines to separate function call + its error handling from the other code. > + s5k5e8->sd.state_lock = &s5k5e8->mutex; > + ret = v4l2_subdev_init_finalize(&s5k5e8->sd); > + if (ret) > + goto err_media; > + ret = v4l2_async_register_subdev_sensor(&s5k5e8->sd); > + if (ret) > + goto err_media; > + pm_runtime_set_active(dev); > + pm_runtime_enable(dev); > + pm_runtime_idle(dev); > + return 0; > +err_media: media_entity_cleanup(&s5k5e8->sd.entity); > +err_ctrl: v4l2_ctrl_handler_free(s5k5e8->sd.ctrl_handler); > +err_mutex: mutex_destroy(&s5k5e8->mutex); > +err_power: s5k5e8_power_off(dev); A label should be on its own line. > + return ret; > +} > + > +static void s5k5e8_remove(struct i2c_client *client) > +{ > + struct v4l2_subdev *sd = i2c_get_clientdata(client); > + struct s5k5e8 *s5k5e8 = to_s5k5e8(sd); > + > + v4l2_async_unregister_subdev(sd); > + media_entity_cleanup(&sd->entity); > + v4l2_ctrl_handler_free(sd->ctrl_handler); > + mutex_destroy(&s5k5e8->mutex); > + pm_runtime_disable(&client->dev); > + if (!pm_runtime_status_suspended(&client->dev)) > + s5k5e8_power_off(&client->dev); > + pm_runtime_set_suspended(&client->dev); > +} > + > +static const struct dev_pm_ops s5k5e8_pm_ops = { SET_RUNTIME_PM_OPS(s5k5e8_power_off, > + s5k5e8_power_on, NULL) }; This looks strange. I'd add a \n before SET_RUNTIME_PM_OPS. In general align continuation lines to the previous opening brace or parenthesis. > +static const struct of_device_id s5k5e8_of_match[] = { { .compatible = "samsung,s5k5e8" }, { } }; Please fix the layout of this struct. It should look like: static const struct of_device_id s5k5e8_of_match[] = { { .compatible = "samsung,s5k5e8" }, { } }; > +MODULE_DEVICE_TABLE(of, s5k5e8_of_match); > +static struct i2c_driver s5k5e8_i2c_driver = { > + .driver = { .name = "s5k5e8", .pm = &s5k5e8_pm_ops, .of_match_table = s5k5e8_of_match }, > + .probe = s5k5e8_probe, .remove = s5k5e8_remove, This also lacks newlines. > +}; > +module_i2c_driver(s5k5e8_i2c_driver); > +MODULE_DESCRIPTION("Samsung S5K5E8 5MP sensor driver"); > +MODULE_LICENSE("GPL"); The same critics apply to (at least) patch #5, too. Best regards Uwe [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 3/7] media: i2c: add s5k5e8 image sensor driver 2026-11-23 13:56 ` Uwe Kleine-König @ 2026-11-23 14:14 ` Hikmah Gumelar 0 siblings, 0 replies; 17+ messages in thread From: Hikmah Gumelar @ 2026-11-23 14:14 UTC (permalink / raw) To: Uwe Kleine-König Cc: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Abel Vesa, Stephen Boyd, Brian Masney, Jerome Brunet, Sakari Ailus, linux-media, devicetree, linux-kernel, linux-arm-msm, linux-clk Hi Uwe, Thanks for the review! I had just sent out v3 right before seeing your feedback; I will drop <linux/mod_devicetable.h> from both s5k5e8.c and ov12a10.c in v4 along with any further review comments on v3. Best regards, Hikmah Pada Sen, 23 Nov 2026 pukul 20.56 Uwe Kleine-König <u.kleine-koenig@baylibre.com> menulis: > > Hello, > > On Mon, Nov 23, 2026 at 07:35:42PM +0700, Hikmah Gumelar wrote: > > diff --git a/drivers/media/i2c/s5k5e8.c b/drivers/media/i2c/s5k5e8.c > > new file mode 100644 > > index 000000000000..80931e5a1c6b > > --- /dev/null > > +++ b/drivers/media/i2c/s5k5e8.c > > @@ -0,0 +1,500 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +#include <linux/clk.h> > > +#include <linux/delay.h> > > +#include <linux/gpio/consumer.h> > > +#include <linux/i2c.h> > > +#include <linux/mod_devicetable.h> > > <linux/i2c.h> already provides of_device_id, so please drop > <linux/mod_devicetable.h> (which adds a lot of unneeded dependencies). > > > +#include <linux/module.h> > > +#include <linux/pm_runtime.h> > > +#include <linux/regulator/consumer.h> > > +#include <linux/unaligned.h> > > +#include <media/v4l2-ctrls.h> > > +#include <media/v4l2-device.h> > > +#include <media/v4l2-fwnode.h> > > + > > +#define S5K5E8_CHIP_ID_REG 0x0000 > > +#define S5K5E8_CHIP_ID 0x5e80 > > +#define S5K5E8_REG_MODE_SELECT 0x0100 > > +#define S5K5E8_MODE_STANDBY 0x00 > > +#define S5K5E8_MODE_STREAMING 0x01 > > +#define S5K5E8_REG_VTS 0x0340 > > +#define S5K5E8_REG_EXPOSURE 0x0202 > > +#define S5K5E8_REG_ANALOG_GAIN 0x0204 > > +#define S5K5E8_REG_TEST_PATTERN 0x0600 > > +#define S5K5E8_XVCLK_FREQ 24000000 > > +#define S5K5E8_LINK_FREQ_418MHZ 418000000ULL > > +#define S5K5E8_PIXEL_RATE 167200000ULL > > + > > +struct s5k5e8_reg { u16 address; > > +u8 val; > > +}; > > +struct s5k5e8_mode { > > + u32 width, height, hts_def, vts_def, vts_min, num_regs; > > + const struct s5k5e8_reg *regs; > > +}; > > + > > +static const char * const s5k5e8_supply_names[] = { "avdd", "dvdd", "dovdd" }; > > +#define S5K5E8_NUM_SUPPLIES ARRAY_SIZE(s5k5e8_supply_names) > > + > > +static const struct s5k5e8_reg s5k5e8_common_regs[] = { > > + { 0x0100, 0x00 }, { 0x3906, 0x7e }, { 0x3c01, 0x0f }, { 0x3c14, 0x00 }, > > + { 0x3235, 0x08 }, { 0x3063, 0x2e }, { 0x307a, 0x10 }, { 0x307b, 0x0e }, > > + { 0x3079, 0x20 }, { 0x3070, 0x05 }, { 0x3067, 0x06 }, { 0x3071, 0x62 }, > > + { 0x3072, 0x16 }, { 0x3203, 0x43 }, { 0x3205, 0x43 }, { 0x320b, 0x42 }, > > + { 0x3007, 0x00 }, { 0x3008, 0x14 }, { 0x3020, 0x58 }, { 0x300d, 0x34 }, > > + { 0x300e, 0x17 }, { 0x3021, 0x02 }, { 0x3010, 0x59 }, { 0x3002, 0x01 }, > > + { 0x3005, 0x01 }, { 0x3008, 0x04 }, { 0x300f, 0x70 }, { 0x3010, 0x69 }, > > + { 0x3017, 0x10 }, { 0x3019, 0x19 }, { 0x300c, 0x62 }, { 0x3064, 0x10 }, > > + { 0x3c08, 0x0e }, { 0x3c09, 0x10 }, { 0x3c31, 0x0d }, { 0x3c32, 0xac }, > > +}; > > + > > +static const struct s5k5e8_reg s5k5e8_2592x1944_regs[] = { > > + { 0x0100, 0x00 }, { 0x0136, 0x18 }, { 0x0137, 0x00 }, { 0x0305, 0x06 }, > > + { 0x0306, 0x18 }, { 0x0307, 0xa8 }, { 0x0308, 0x34 }, { 0x0309, 0x42 }, > > + { 0x3c1f, 0x00 }, { 0x3c17, 0x00 }, { 0x3c0b, 0x04 }, { 0x3c1c, 0x47 }, > > + { 0x3c1d, 0x15 }, { 0x3c14, 0x04 }, { 0x3c16, 0x00 }, { 0x0820, 0x03 }, > > + { 0x0821, 0x44 }, { 0x0114, 0x01 }, { 0x0344, 0x00 }, { 0x0345, 0x08 }, > > + { 0x0346, 0x00 }, { 0x0347, 0x08 }, { 0x0348, 0x0a }, { 0x0349, 0x27 }, > > + { 0x034a, 0x07 }, { 0x034b, 0x9f }, { 0x034c, 0x0a }, { 0x034d, 0x20 }, > > + { 0x034e, 0x07 }, { 0x034f, 0x98 }, { 0x0900, 0x00 }, { 0x0901, 0x00 }, > > + { 0x0381, 0x01 }, { 0x0383, 0x01 }, { 0x0385, 0x01 }, { 0x0387, 0x01 }, > > + { 0x0340, 0x07 }, { 0x0341, 0xb0 }, { 0x0342, 0x0b }, { 0x0343, 0x28 }, > > + { 0x0200, 0x00 }, { 0x0201, 0x00 }, { 0x0202, 0x03 }, { 0x0203, 0xde }, > > + { 0x3303, 0x02 }, { 0x3400, 0x00 }, { 0x323b, 0x02 }, { 0x3301, 0x00 }, > > + { 0x3321, 0x04 }, { 0x3306, 0x00 }, { 0x3307, 0x08 }, { 0x3308, 0x0a }, > > + { 0x3309, 0x27 }, { 0x330a, 0x01 }, { 0x330b, 0x01 }, { 0x330e, 0x00 }, > > + { 0x330f, 0x08 }, { 0x3310, 0x07 }, { 0x3311, 0x9f }, { 0x3312, 0x01 }, > > + { 0x3313, 0x01 }, > > +}; > > Is this a reverse engineered table of initial register values? A comment > would be awesome. > > > +static const struct s5k5e8_mode supported_modes[] = { > > + { > > + .width = 2592, .height = 1944, .hts_def = 2856, > > + .vts_def = 1968, .vts_min = 1968, > > + .num_regs = ARRAY_SIZE(s5k5e8_2592x1944_regs), > > + .regs = s5k5e8_2592x1944_regs, > > + }, > > +}; > > + > > [...] > > +static int s5k5e8_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, > > + struct v4l2_subdev_frame_size_enum *fse) > > +{ > > + if (fse->index >= ARRAY_SIZE(supported_modes) || > > + fse->code != MEDIA_BUS_FMT_SGRBG10_1X10) > > + return -EINVAL; > > ARRAY_SIZE(supported_modes) is one. Does supported_modes really need to > be an array? > > > + fse->min_width = fse->max_width = supported_modes[fse->index].width; > > + fse->min_height = fse->max_height = supported_modes[fse->index].height; > > + return 0; > > +} > > + > > [...] > > +static int s5k5e8_probe(struct i2c_client *client) > > +{ > > + struct device *dev = &client->dev; > > + struct s5k5e8 *s5k5e8; > > + u32 val = 0; > > + unsigned int i; > > + int ret; > > + > > + s5k5e8 = devm_kzalloc(dev, sizeof(*s5k5e8), GFP_KERNEL); > > + if (!s5k5e8) > > + return -ENOMEM; > > + s5k5e8->dev = dev; > > + v4l2_i2c_subdev_init(&s5k5e8->sd, client, &s5k5e8_subdev_ops); > > + s5k5e8->xvclk = devm_v4l2_sensor_clk_get(dev, NULL); > > + if (IS_ERR(s5k5e8->xvclk)) > > + return dev_err_probe(dev, PTR_ERR(s5k5e8->xvclk), "xvclk\n"); > > + clk_set_rate(s5k5e8->xvclk, S5K5E8_XVCLK_FREQ); > > + s5k5e8->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); > > + if (IS_ERR(s5k5e8->reset_gpio)) > > + return dev_err_probe(dev, PTR_ERR(s5k5e8->reset_gpio), "reset\n"); > > + for (i = 0; i < S5K5E8_NUM_SUPPLIES; i++) > > + s5k5e8->supplies[i].supply = s5k5e8_supply_names[i]; > > + ret = devm_regulator_bulk_get(dev, S5K5E8_NUM_SUPPLIES, s5k5e8->supplies); > > + if (ret) > > + return dev_err_probe(dev, ret, "regulators\n"); > > + ret = s5k5e8_power_on(dev); > > + if (ret) > > + return ret; > > + ret = s5k5e8_read_reg(s5k5e8, S5K5E8_CHIP_ID_REG, 2, &val); > > + if (ret || val != S5K5E8_CHIP_ID) { > > + dev_err(dev, "failed to identify s5k5e8 (ret=%d, id=0x%x)\n", ret, val); > > Use dev_err_probe() for error messages in the probe function. > > > + ret = ret ? ret : -ENXIO; > > + goto err_power; > > + } > > + dev_info(dev, "identified Samsung S5K5E8 sensor (0x%04x)\n", val); > > Degrade to dev_dbg() or drop. Once the driver is considered ok, messages > of this kind only clutter the kernel log with very little value and add > to the boot time. > > > + mutex_init(&s5k5e8->mutex); > > + s5k5e8->cur_mode = &supported_modes[0]; > > + ret = s5k5e8_init_controls(s5k5e8); > > + if (ret) > > + goto err_mutex; > > + s5k5e8->sd.internal_ops = &s5k5e8_internal_ops; > > + s5k5e8->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; > > + s5k5e8->sd.entity.ops = &s5k5e8_entity_ops; > > + s5k5e8->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; > > + s5k5e8->pad.flags = MEDIA_PAD_FL_SOURCE; > > + ret = media_entity_pads_init(&s5k5e8->sd.entity, 1, &s5k5e8->pad); > > + if (ret) > > + goto err_ctrl; > > Use newlines to separate function call + its error handling from the > other code. > > > + s5k5e8->sd.state_lock = &s5k5e8->mutex; > > + ret = v4l2_subdev_init_finalize(&s5k5e8->sd); > > + if (ret) > > + goto err_media; > > + ret = v4l2_async_register_subdev_sensor(&s5k5e8->sd); > > + if (ret) > > + goto err_media; > > + pm_runtime_set_active(dev); > > + pm_runtime_enable(dev); > > + pm_runtime_idle(dev); > > + return 0; > > +err_media: media_entity_cleanup(&s5k5e8->sd.entity); > > +err_ctrl: v4l2_ctrl_handler_free(s5k5e8->sd.ctrl_handler); > > +err_mutex: mutex_destroy(&s5k5e8->mutex); > > +err_power: s5k5e8_power_off(dev); > > A label should be on its own line. > > > + return ret; > > +} > > + > > +static void s5k5e8_remove(struct i2c_client *client) > > +{ > > + struct v4l2_subdev *sd = i2c_get_clientdata(client); > > + struct s5k5e8 *s5k5e8 = to_s5k5e8(sd); > > + > > + v4l2_async_unregister_subdev(sd); > > + media_entity_cleanup(&sd->entity); > > + v4l2_ctrl_handler_free(sd->ctrl_handler); > > + mutex_destroy(&s5k5e8->mutex); > > + pm_runtime_disable(&client->dev); > > + if (!pm_runtime_status_suspended(&client->dev)) > > + s5k5e8_power_off(&client->dev); > > + pm_runtime_set_suspended(&client->dev); > > +} > > + > > +static const struct dev_pm_ops s5k5e8_pm_ops = { SET_RUNTIME_PM_OPS(s5k5e8_power_off, > > + s5k5e8_power_on, NULL) }; > > This looks strange. I'd add a \n before SET_RUNTIME_PM_OPS. In general > align continuation lines to the previous opening brace or parenthesis. > > > +static const struct of_device_id s5k5e8_of_match[] = { { .compatible = "samsung,s5k5e8" }, { } }; > > Please fix the layout of this struct. It should look like: > > static const struct of_device_id s5k5e8_of_match[] = { > { .compatible = "samsung,s5k5e8" }, > { } > }; > > > > +MODULE_DEVICE_TABLE(of, s5k5e8_of_match); > > +static struct i2c_driver s5k5e8_i2c_driver = { > > + .driver = { .name = "s5k5e8", .pm = &s5k5e8_pm_ops, .of_match_table = s5k5e8_of_match }, > > + .probe = s5k5e8_probe, .remove = s5k5e8_remove, > > This also lacks newlines. > > > +}; > > +module_i2c_driver(s5k5e8_i2c_driver); > > +MODULE_DESCRIPTION("Samsung S5K5E8 5MP sensor driver"); > > +MODULE_LICENSE("GPL"); > > The same critics apply to (at least) patch #5, too. > > Best regards > Uwe -- Best regards, Hikmah Gumelar ^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 4/7] media: dt-bindings: media: i2c: add OmniVision OV12A10 2026-11-23 12:35 ` [PATCH v2 0/7] " Hikmah Gumelar ` (2 preceding siblings ...) 2026-11-23 12:35 ` [PATCH v2 3/7] media: i2c: add s5k5e8 image sensor driver Hikmah Gumelar @ 2026-11-23 12:35 ` Hikmah Gumelar 2026-11-23 12:35 ` [PATCH v2 5/7] media: i2c: add ov12a10 image sensor driver Hikmah Gumelar ` (2 subsequent siblings) 6 siblings, 0 replies; 17+ messages in thread From: Hikmah Gumelar @ 2026-11-23 12:35 UTC (permalink / raw) To: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Abel Vesa, Stephen Boyd, Brian Masney, Jerome Brunet, Sakari Ailus Cc: Hikmah Gumelar, linux-media, devicetree, linux-kernel, linux-arm-msm, linux-clk Add Devicetree binding schema for the OmniVision OV12A10 12-megapixel MIPI CSI-2 CMOS image sensor. Signed-off-by: Hikmah Gumelar <hikmahgumelar@gmail.com> --- .../bindings/media/i2c/ovti,ov12a10.yaml | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml diff --git a/Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml b/Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml new file mode 100644 index 000000000000..6919277c2b3f --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/ovti,ov12a10.yaml @@ -0,0 +1,115 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org +$schema: http://devicetree.org + +title: OmniVision OV12A10 1/2.8-inch 12Mp CMOS Image Sensor + +maintainers: + - Hikmah Gumelar <hikmahgumelar@gmail.com> + +description: + OmniVision OV12A10 is a 1/2.8-inch 12-megapixel CMOS active-pixel digital + image sensor with a 4-lane MIPI CSI-2 interface and I2C control bus. + +allOf: + - $ref: /schemas/media/video-interface-devices.yaml# + +properties: + compatible: + const: ovti,ov12a10 + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + reset-gpios: + description: Active-low reset GPIO. + maxItems: 1 + + pwdn-gpios: + description: Active-low power-down GPIO. + maxItems: 1 + + vana-gpios: + description: Active-high analog power enable GPIO. + maxItems: 1 + + avdd-supply: + description: Analog power supply (2.8V). + + dvdd-supply: + description: Digital core power supply (1.2V). + + dovdd-supply: + description: Digital I/O power supply (1.8V). + + port: + $ref: /schemas/graph.yaml#/$defs/port-base + additionalProperties: false + + properties: + endpoint: + $ref: /schemas/media/video-interfaces.yaml# + unevaluatedProperties: false + + properties: + data-lanes: + items: + - const: 0 + - const: 1 + - const: 2 + - const: 3 + + link-frequencies: true + + required: + - data-lanes + - link-frequencies + + required: + - endpoint + +required: + - compatible + - reg + - clocks + - avdd-supply + - dvdd-supply + - dovdd-supply + - port + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + camera-sensor@10 { + compatible = "ovti,ov12a10"; + reg = <0x10>; + clocks = <&camss_mclk0>; + reset-gpios = <&tlmm 33 GPIO_ACTIVE_LOW>; + pwdn-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + vana-gpios = <&tlmm 62 GPIO_ACTIVE_HIGH>; + avdd-supply = <&pm8953_l22>; + dvdd-supply = <&pm8953_l2>; + dovdd-supply = <&pm8953_l6>; + + port { + endpoint { + data-lanes = <0 1 2 3>; + remote-endpoint = <&csiphy0_ep>; + link-frequencies = /bits/ 64 <216000000>; + }; + }; + }; + }; +... -- 2.47.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 5/7] media: i2c: add ov12a10 image sensor driver 2026-11-23 12:35 ` [PATCH v2 0/7] " Hikmah Gumelar ` (3 preceding siblings ...) 2026-11-23 12:35 ` [PATCH v2 4/7] media: dt-bindings: media: i2c: add OmniVision OV12A10 Hikmah Gumelar @ 2026-11-23 12:35 ` Hikmah Gumelar 2026-11-23 12:35 ` [PATCH v2 6/7] arm64: dts: qcom: msm8953: add CAMSS node and MCLK pinctrl states Hikmah Gumelar 2026-11-23 12:35 ` [PATCH v2 7/7] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar 6 siblings, 0 replies; 17+ messages in thread From: Hikmah Gumelar @ 2026-11-23 12:35 UTC (permalink / raw) To: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Abel Vesa, Stephen Boyd, Brian Masney, Jerome Brunet, Sakari Ailus Cc: Hikmah Gumelar, linux-media, devicetree, linux-kernel, linux-arm-msm, linux-clk Signed-off-by: Hikmah Gumelar <hikmahgumelar@gmail.com> --- drivers/media/i2c/Kconfig | 9 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/ov12a10.c | 720 ++++++++++++++++++++++++++++++++++++ 3 files changed, 730 insertions(+) create mode 100644 drivers/media/i2c/ov12a10.c diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index 095a911c5043..280c8ba9a215 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig @@ -538,6 +538,15 @@ config VIDEO_OV08X40 To compile this driver as a module, choose M here: the module will be called ov08x40. +config VIDEO_OV12A10 + tristate "OmniVision OV12A10 sensor support" + depends on I2C && VIDEO_DEV + select MEDIA_CONTROLLER + select VIDEO_V4L2_SUBDEV_API + select V4L2_FWNODE + help + V4L2 sensor driver for OmniVision OV12A10. + config VIDEO_OV13858 tristate "OmniVision OV13858 sensor support" help diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile index bdcb8f34aca3..8148ee872a31 100644 --- a/drivers/media/i2c/Makefile +++ b/drivers/media/i2c/Makefile @@ -99,6 +99,7 @@ obj-$(CONFIG_VIDEO_OV02E10) += ov02e10.o obj-$(CONFIG_VIDEO_OV05C10) += ov05c10.o obj-$(CONFIG_VIDEO_OV08D10) += ov08d10.o obj-$(CONFIG_VIDEO_OV08X40) += ov08x40.o +obj-$(CONFIG_VIDEO_OV12A10) += ov12a10.o obj-$(CONFIG_VIDEO_OV13858) += ov13858.o obj-$(CONFIG_VIDEO_OV13B10) += ov13b10.o obj-$(CONFIG_VIDEO_OV2640) += ov2640.o diff --git a/drivers/media/i2c/ov12a10.c b/drivers/media/i2c/ov12a10.c new file mode 100644 index 000000000000..ce2e01bc67e0 --- /dev/null +++ b/drivers/media/i2c/ov12a10.c @@ -0,0 +1,720 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/gpio/consumer.h> +#include <linux/i2c.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/pm_runtime.h> +#include <linux/regulator/consumer.h> +#include <linux/unaligned.h> +#include <media/v4l2-ctrls.h> +#include <media/v4l2-device.h> +#include <media/v4l2-fwnode.h> + +#define OV12A10_CHIP_ID_REG 0x300a +#define OV12A10_CHIP_ID 0x5612 +#define OV12A10_REG_MODE_SELECT 0x0100 +#define OV12A10_MODE_STANDBY 0x00 +#define OV12A10_MODE_STREAMING 0x01 +#define OV12A10_REG_VTS 0x380e +#define OV12A10_REG_EXPOSURE 0x3501 +#define OV12A10_REG_ANALOG_GAIN 0x3508 +#define OV12A10_REG_TEST_PATTERN 0x5080 +#define OV12A10_XVCLK_FREQ 24000000 +#define OV12A10_LINK_FREQ_216MHZ 216000000ULL +#define OV12A10_PIXEL_RATE 144000000ULL + +struct ov12a10_reg { u16 address; +u8 val; +}; +struct ov12a10_mode { + u32 width, height, hts_def, vts_def, vts_min, num_regs; + const struct ov12a10_reg *regs; +}; + +static const char * const ov12a10_supply_names[] = { "avdd", "dvdd", "dovdd" }; +#define OV12A10_NUM_SUPPLIES ARRAY_SIZE(ov12a10_supply_names) + +static const struct ov12a10_reg ov12a10_common_regs[] = { + { 0x0103, 0x01 }, + { 0x0302, 0x49 }, + { 0x0303, 0x00 }, + { 0x0304, 0x00 }, + { 0x0305, 0x01 }, + { 0x0312, 0x11 }, + { 0x030b, 0x06 }, + { 0x030c, 0x02 }, + { 0x030d, 0x88 }, + { 0x030e, 0x02 }, + { 0x0313, 0x05 }, + { 0x3002, 0x21 }, + { 0x3012, 0x40 }, + { 0x3013, 0x72 }, + { 0x3016, 0x72 }, + { 0x301b, 0xd0 }, + { 0x301d, 0xf0 }, + { 0x301f, 0xd0 }, + { 0x3021, 0x23 }, + { 0x3022, 0x01 }, + { 0x3106, 0x15 }, + { 0x3107, 0x23 }, + { 0x3500, 0x00 }, + { 0x3501, 0xd0 }, + { 0x3502, 0x00 }, + { 0x3505, 0x83 }, + { 0x3508, 0x02 }, + { 0x3509, 0x00 }, + { 0x3600, 0x43 }, + { 0x3611, 0x8a }, + { 0x3613, 0x97 }, + { 0x3620, 0x80 }, + { 0x3624, 0x2c }, + { 0x3625, 0xa0 }, + { 0x3626, 0x00 }, + { 0x3631, 0x60 }, + { 0x3632, 0x00 }, + { 0x3641, 0x80 }, + { 0x3642, 0x12 }, + { 0x3644, 0x78 }, + { 0x3645, 0xa7 }, + { 0x364e, 0x44 }, + { 0x364f, 0x44 }, + { 0x3650, 0x11 }, + { 0x3654, 0x00 }, + { 0x3657, 0x31 }, + { 0x3659, 0x0c }, + { 0x365f, 0x07 }, + { 0x3661, 0x17 }, + { 0x3662, 0x17 }, + { 0x3663, 0x17 }, + { 0x3664, 0x17 }, + { 0x3666, 0x08 }, + { 0x366b, 0x20 }, + { 0x366c, 0xa4 }, + { 0x366d, 0x20 }, + { 0x366e, 0xa4 }, + { 0x3680, 0x00 }, + { 0x3714, 0x24 }, + { 0x371a, 0x3e }, + { 0x3737, 0x04 }, + { 0x3739, 0x12 }, + { 0x3765, 0x20 }, + { 0x3767, 0x00 }, + { 0x37a1, 0x3e }, + { 0x37a8, 0x4d }, + { 0x37ab, 0x2c }, + { 0x37c2, 0x04 }, + { 0x37d8, 0x03 }, + { 0x37d9, 0x0c }, + { 0x37e0, 0x00 }, + { 0x37e1, 0x0a }, + { 0x37e2, 0x14 }, + { 0x37e3, 0x04 }, + { 0x37e4, 0x2a }, + { 0x37e5, 0x03 }, + { 0x37e6, 0x04 }, + { 0x3800, 0x00 }, + { 0x3801, 0x00 }, + { 0x3802, 0x00 }, + { 0x3803, 0x00 }, + { 0x3804, 0x10 }, + { 0x3805, 0x0f }, + { 0x3806, 0x0c }, + { 0x3807, 0x0f }, + { 0x3808, 0x10 }, + { 0x3809, 0x00 }, + { 0x380a, 0x0c }, + { 0x380b, 0x00 }, + { 0x380c, 0x04 }, + { 0x380d, 0x28 }, + { 0x380e, 0x0d }, + { 0x380f, 0x12 }, + { 0x3811, 0x0a }, + { 0x3813, 0x08 }, + { 0x3814, 0x01 }, + { 0x3815, 0x01 }, + { 0x3816, 0x01 }, + { 0x3817, 0x01 }, + { 0x3820, 0xa8 }, + { 0x3821, 0x00 }, + { 0x3822, 0x91 }, + { 0x3823, 0x18 }, + { 0x3826, 0x00 }, + { 0x3827, 0x00 }, + { 0x3829, 0x03 }, + { 0x3832, 0x08 }, + { 0x3833, 0x30 }, + { 0x3c80, 0x00 }, + { 0x3c87, 0x01 }, + { 0x3c8c, 0x1a }, + { 0x3c8d, 0x68 }, + { 0x3c97, 0x02 }, + { 0x3cc0, 0x40 }, + { 0x3cc1, 0x54 }, + { 0x3cc2, 0x34 }, + { 0x3cc3, 0x04 }, + { 0x3cc4, 0x00 }, + { 0x3cc5, 0x00 }, + { 0x3cc6, 0x00 }, + { 0x3cc7, 0x00 }, + { 0x3cc8, 0x00 }, + { 0x3cc9, 0x00 }, + { 0x3d8c, 0x73 }, + { 0x3d8d, 0xc0 }, + { 0x4001, 0x2b }, + { 0x4008, 0x02 }, + { 0x4009, 0x0f }, + { 0x4011, 0xff }, + { 0x4013, 0x08 }, + { 0x4014, 0x08 }, + { 0x4015, 0x08 }, + { 0x4017, 0x08 }, + { 0x401a, 0x58 }, + { 0x4050, 0x04 }, + { 0x4051, 0x0b }, + { 0x405e, 0x20 }, + { 0x4501, 0x00 }, + { 0x4503, 0x00 }, + { 0x450a, 0x04 }, + { 0x4601, 0x30 }, + { 0x4800, 0x24 }, + { 0x481f, 0x30 }, + { 0x4837, 0x0d }, + { 0x483c, 0x0f }, + { 0x484b, 0x01 }, + { 0x4d00, 0x05 }, + { 0x4d01, 0x19 }, + { 0x4d02, 0xfd }, + { 0x4d03, 0xd1 }, + { 0x4d04, 0xff }, + { 0x4d05, 0xff }, + { 0x5000, 0x09 }, + { 0x5001, 0x42 }, + { 0x5002, 0x45 }, + { 0x5005, 0x00 }, + { 0x5081, 0x04 }, + { 0x5180, 0x00 }, + { 0x5181, 0x10 }, + { 0x5182, 0x02 }, + { 0x5183, 0x0f }, + { 0x5185, 0x6c }, + { 0x5200, 0x03 }, + { 0x5203, 0x7c }, + { 0x5204, 0x1f }, + { 0x5205, 0x41 }, + { 0x520b, 0x07 }, + { 0x520c, 0x0f }, + { 0x0300, 0x02 }, + { 0x0302, 0x53 }, + { 0x380c, 0x04 }, + { 0x380d, 0x90 }, + { 0x380e, 0x0c }, + { 0x380f, 0xe6 }, + { 0x4837, 0x10 }, +}; + +static const struct ov12a10_reg ov12a10_1280x720_regs[] = { + { 0x0300, 0x06 }, + { 0x0301, 0x02 }, + { 0x0302, 0x48 }, + { 0x0307, 0x01 }, + { 0x0303, 0x01 }, + { 0x030b, 0x06 }, + { 0x030c, 0x02 }, + { 0x030d, 0x88 }, + { 0x0312, 0x11 }, + { 0x0313, 0x09 }, + { 0x3642, 0x10 }, + { 0x3666, 0x00 }, + { 0x366b, 0xa4 }, + { 0x366c, 0x20 }, + { 0x366d, 0xa4 }, + { 0x366e, 0x20 }, + { 0x3714, 0x28 }, + { 0x371a, 0x3e }, + { 0x3737, 0x08 }, + { 0x3739, 0x20 }, + { 0x37c2, 0x14 }, + { 0x37d9, 0x0c }, + { 0x37e3, 0x08 }, + { 0x37e4, 0x36 }, + { 0x37e6, 0x08 }, + { 0x3800, 0x03 }, + { 0x3801, 0x20 }, + { 0x3802, 0x03 }, + { 0x3803, 0x68 }, + { 0x3804, 0x0d }, + { 0x3805, 0x3f }, + { 0x3806, 0x09 }, + { 0x3807, 0x27 }, + { 0x3808, 0x05 }, + { 0x3809, 0x00 }, + { 0x380a, 0x02 }, + { 0x380b, 0xd0 }, + { 0x380c, 0x04 }, + { 0x380d, 0x28 }, + { 0x380e, 0x03 }, + { 0x380f, 0x4c }, + { 0x3810, 0x00 }, + { 0x3811, 0x08 }, + { 0x3813, 0x08 }, + { 0x3814, 0x03 }, + { 0x3816, 0x03 }, + { 0x3820, 0xab }, + { 0x4009, 0x0d }, + { 0x4050, 0x04 }, + { 0x4051, 0x0b }, + { 0x4501, 0x00 }, + { 0x4837, 0x1b }, + { 0x5001, 0x42 }, + { 0x5002, 0x45 }, + { 0x3501, 0x34 }, + { 0x3502, 0x00 }, + { 0x4800, 0x24 }, +}; + +static const struct ov12a10_mode supported_modes[] = { + { + .width = 1280, .height = 720, .hts_def = 1440, + .vts_def = 3376, .vts_min = 844, + .num_regs = ARRAY_SIZE(ov12a10_1280x720_regs), + .regs = ov12a10_1280x720_regs, + }, +}; + +static const s64 link_freq_menu_items[] = { OV12A10_LINK_FREQ_216MHZ }; + +struct ov12a10 { + struct device *dev; + struct v4l2_subdev sd; + struct media_pad pad; + struct clk *xvclk; + struct gpio_desc *reset_gpio, *vana_gpio, *pwdn_gpio; + struct regulator_bulk_data supplies[OV12A10_NUM_SUPPLIES]; + struct v4l2_ctrl_handler ctrl_handler; + struct v4l2_ctrl *link_freq, *pixel_rate, *vblank, *hblank, *exposure; + const struct ov12a10_mode *cur_mode; + /* Serialize access to sensor registers and streaming state */ + struct mutex mutex; + bool streaming; +}; + +static inline struct ov12a10 *to_ov12a10(struct v4l2_subdev *sd) +{ + return container_of(sd, struct ov12a10, sd); +} + +static int ov12a10_read_reg(struct ov12a10 *ov12a10, u16 reg, u32 len, u32 *val) +{ + struct i2c_client *client = v4l2_get_subdevdata(&ov12a10->sd); + struct i2c_msg msgs[2]; + u8 addr_buf[2], data_buf[4] = { 0 }; + int ret; + + put_unaligned_be16(reg, addr_buf); + msgs[0].addr = client->addr; + msgs[0].flags = 0; + msgs[0].len = 2; + msgs[0].buf = addr_buf; + msgs[1].addr = client->addr; + msgs[1].flags = I2C_M_RD; + msgs[1].len = len; + msgs[1].buf = &data_buf[4 - len]; + ret = i2c_transfer(client->adapter, msgs, 2); + if (ret != 2) + return ret < 0 ? ret : -EIO; + *val = get_unaligned_be32(data_buf); + return 0; +} + +static int ov12a10_write_reg(struct ov12a10 *ov12a10, u16 reg, u32 len, u32 val) +{ + struct i2c_client *client = v4l2_get_subdevdata(&ov12a10->sd); + u8 buf[6]; + int ret; + + put_unaligned_be16(reg, buf); + put_unaligned_be32(val << (8 * (4 - len)), buf + 2); + ret = i2c_master_send(client, buf, len + 2); + return ret == len + 2 ? 0 : (ret < 0 ? ret : -EIO); +} + +static int ov12a10_write_regs(struct ov12a10 *ov12a10, const struct ov12a10_reg *regs, u32 len) +{ + u32 i; + int ret; + + for (i = 0; i < len; i++) { + ret = ov12a10_write_reg(ov12a10, regs[i].address, 1, regs[i].val); + if (!ret && regs[i].address == 0x0103) + usleep_range(5000, 6000); + if (ret) + return ret; + } + return 0; +} + +static int ov12a10_power_on(struct device *dev) +{ + struct ov12a10 *ov12a10 = to_ov12a10(dev_get_drvdata(dev)); + int ret; + + if (ov12a10->vana_gpio) + gpiod_set_value_cansleep(ov12a10->vana_gpio, 1); + + ret = regulator_bulk_enable(OV12A10_NUM_SUPPLIES, ov12a10->supplies); + if (ret) + return ret; + + ret = clk_prepare_enable(ov12a10->xvclk); + if (ret) { + regulator_bulk_disable(OV12A10_NUM_SUPPLIES, ov12a10->supplies); + return ret; + } + + msleep(35); + if (ov12a10->pwdn_gpio) + gpiod_set_value_cansleep(ov12a10->pwdn_gpio, 0); + if (ov12a10->reset_gpio) { + gpiod_set_value_cansleep(ov12a10->reset_gpio, 1); + usleep_range(3000, 5000); + gpiod_set_value_cansleep(ov12a10->reset_gpio, 0); + msleep(35); + } + return 0; +} + +static int ov12a10_power_off(struct device *dev) +{ + struct ov12a10 *ov12a10 = to_ov12a10(dev_get_drvdata(dev)); + + if (ov12a10->reset_gpio) + gpiod_set_value_cansleep(ov12a10->reset_gpio, 1); + if (ov12a10->pwdn_gpio) + gpiod_set_value_cansleep(ov12a10->pwdn_gpio, 1); + if (ov12a10->vana_gpio) + gpiod_set_value_cansleep(ov12a10->vana_gpio, 0); + clk_disable_unprepare(ov12a10->xvclk); + regulator_bulk_disable(OV12A10_NUM_SUPPLIES, ov12a10->supplies); + return 0; +} + +static int ov12a10_set_ctrl(struct v4l2_ctrl *ctrl) +{ + struct ov12a10 *ov12a10 = container_of(ctrl->handler, struct ov12a10, ctrl_handler); + int ret = 0; + + if (!pm_runtime_get_if_in_use(ov12a10->dev)) + return 0; + switch (ctrl->id) { + case V4L2_CID_ANALOGUE_GAIN: + ret = ov12a10_write_reg(ov12a10, OV12A10_REG_ANALOG_GAIN, 2, ctrl->val); + break; + case V4L2_CID_EXPOSURE: + ret = ov12a10_write_reg(ov12a10, 0x3500, 3, ctrl->val << 4); + break; + case V4L2_CID_VBLANK: + ret = ov12a10_write_reg(ov12a10, OV12A10_REG_VTS, 2, + ov12a10->cur_mode->height + ctrl->val); + break; + case V4L2_CID_TEST_PATTERN: + ret = ov12a10_write_reg(ov12a10, OV12A10_REG_TEST_PATTERN, 1, ctrl->val); + break; + } + pm_runtime_put(ov12a10->dev); + return ret; +} + +static const struct v4l2_ctrl_ops ov12a10_ctrl_ops = { .s_ctrl = ov12a10_set_ctrl }; +static const char * const ov12a10_test_pattern_menu[] = { + "Disabled", + "Solid Color", + "100% Color Bars", + "Fade to Grey", + "PN9", +}; + +static int ov12a10_init_controls(struct ov12a10 *ov12a10) +{ + struct v4l2_fwnode_device_properties props; + struct v4l2_ctrl_handler *hdl = &ov12a10->ctrl_handler; + s64 hblank = ov12a10->cur_mode->hts_def - ov12a10->cur_mode->width; + int ret = v4l2_ctrl_handler_init(hdl, 8); + + if (ret) + return ret; + hdl->lock = &ov12a10->mutex; + ov12a10->link_freq = v4l2_ctrl_new_int_menu(hdl, &ov12a10_ctrl_ops, V4L2_CID_LINK_FREQ, + 0, 0, link_freq_menu_items); + if (ov12a10->link_freq) + ov12a10->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; + ov12a10->pixel_rate = v4l2_ctrl_new_std(hdl, &ov12a10_ctrl_ops, V4L2_CID_PIXEL_RATE, + OV12A10_PIXEL_RATE, OV12A10_PIXEL_RATE, 1, OV12A10_PIXEL_RATE); + ov12a10->vblank = v4l2_ctrl_new_std(hdl, &ov12a10_ctrl_ops, V4L2_CID_VBLANK, 124, + 0x7fff - ov12a10->cur_mode->height, 1, 2656); + ov12a10->hblank = v4l2_ctrl_new_std(hdl, &ov12a10_ctrl_ops, V4L2_CID_HBLANK, hblank, + hblank, 1, hblank); + if (ov12a10->hblank) + ov12a10->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; + v4l2_ctrl_new_std(hdl, &ov12a10_ctrl_ops, V4L2_CID_ANALOGUE_GAIN, 0x80, 0x7ff, 1, 0x300); + ov12a10->exposure = v4l2_ctrl_new_std(hdl, &ov12a10_ctrl_ops, V4L2_CID_EXPOSURE, 4, + 3360, 1, 2400); + v4l2_ctrl_new_std_menu_items(hdl, &ov12a10_ctrl_ops, V4L2_CID_TEST_PATTERN, 4, 0, 0, + ov12a10_test_pattern_menu); + if (hdl->error) { + ret = hdl->error; + goto err; + } + ret = v4l2_fwnode_device_parse(ov12a10->dev, &props); + if (ret) + goto err; + ret = v4l2_ctrl_new_fwnode_properties(hdl, &ov12a10_ctrl_ops, &props); + if (ret) + goto err; + ov12a10->sd.ctrl_handler = hdl; + return 0; +err: + v4l2_ctrl_handler_free(hdl); + return ret; +} + +static void ov12a10_update_pad_format(const struct ov12a10_mode *mode, + struct v4l2_mbus_framefmt *fmt) +{ + fmt->width = mode->width; + fmt->height = mode->height; + fmt->code = MEDIA_BUS_FMT_SRGGB10_1X10; + fmt->field = V4L2_FIELD_NONE; + fmt->colorspace = V4L2_COLORSPACE_SRGB; +} + +static int ov12a10_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_format *fmt) +{ + struct ov12a10 *ov12a10 = to_ov12a10(sd); + + fmt->format = (fmt->which == V4L2_SUBDEV_FORMAT_TRY) ? *v4l2_subdev_state_get_format(sd_state, + fmt->pad) : fmt->format; + if (fmt->which != V4L2_SUBDEV_FORMAT_TRY) + ov12a10_update_pad_format(ov12a10->cur_mode, &fmt->format); + return 0; +} + +static int ov12a10_set_format(struct v4l2_subdev *sd, const struct v4l2_subdev_client_info *ci, struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_format *fmt) +{ + struct ov12a10 *ov12a10 = to_ov12a10(sd); + + ov12a10_update_pad_format(&supported_modes[0], &fmt->format); + if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) + *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; + else + ov12a10->cur_mode = &supported_modes[0]; + + return 0; +} + +static int ov12a10_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_mbus_code_enum *code) +{ + if (code->index > 0) + return -EINVAL; + code->code = MEDIA_BUS_FMT_SRGGB10_1X10; + return 0; +} + +static int ov12a10_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_frame_size_enum *fse) +{ + if (fse->index >= ARRAY_SIZE(supported_modes) || + fse->code != MEDIA_BUS_FMT_SRGGB10_1X10) + return -EINVAL; + fse->min_width = fse->max_width = supported_modes[fse->index].width; + fse->min_height = fse->max_height = supported_modes[fse->index].height; + return 0; +} + +static int ov12a10_set_stream(struct v4l2_subdev *sd, int enable) +{ + struct ov12a10 *ov12a10 = to_ov12a10(sd); + int ret = 0; + + mutex_lock(&ov12a10->mutex); + if (ov12a10->streaming == enable) { + mutex_unlock(&ov12a10->mutex); + return 0; + } + if (enable) { + ret = pm_runtime_resume_and_get(ov12a10->dev); + if (ret < 0) + goto out; + ret = ov12a10_write_regs(ov12a10, ov12a10_common_regs, + ARRAY_SIZE(ov12a10_common_regs)); + if (!ret) + ret = ov12a10_write_regs(ov12a10, ov12a10->cur_mode->regs, + ov12a10->cur_mode->num_regs); + if (!ret) + ret = __v4l2_ctrl_handler_setup(ov12a10->sd.ctrl_handler); + if (!ret) { + static const struct ov12a10_reg stream_on_regs[] = { + { 0x0100, 0x01 }, + }; + usleep_range(10000, 12000); + ret = ov12a10_write_regs(ov12a10, stream_on_regs, + ARRAY_SIZE(stream_on_regs)); + } + if (ret) { + pm_runtime_put(ov12a10->dev); + goto out; + } + } else { + ov12a10_write_reg(ov12a10, OV12A10_REG_MODE_SELECT, 1, OV12A10_MODE_STANDBY); + pm_runtime_put(ov12a10->dev); + } + ov12a10->streaming = enable; +out: + mutex_unlock(&ov12a10->mutex); + return ret; +} + +static int ov12a10_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) +{ + struct ov12a10 *ov12a10 = to_ov12a10(sd); + + mutex_lock(&ov12a10->mutex); + ov12a10_update_pad_format(&supported_modes[0], v4l2_subdev_state_get_format(fh->state, + 0)); + mutex_unlock(&ov12a10->mutex); + return 0; +} + +static const struct v4l2_subdev_video_ops ov12a10_video_ops = { .s_stream = ov12a10_set_stream }; + +static int ov12a10_get_selection(struct v4l2_subdev *sd, const struct v4l2_subdev_client_info *ci, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_selection *sel) +{ + switch (sel->target) { + case V4L2_SEL_TGT_CROP: + case V4L2_SEL_TGT_CROP_DEFAULT: + case V4L2_SEL_TGT_CROP_BOUNDS: + case V4L2_SEL_TGT_NATIVE_SIZE: + sel->r.left = 0; + sel->r.top = 0; + sel->r.width = 1280; + sel->r.height = 720; + return 0; + default: + return -EINVAL; + } +} + +static const struct v4l2_subdev_pad_ops ov12a10_pad_ops = { + .get_selection = ov12a10_get_selection, + .set_fmt = ov12a10_set_format, .get_fmt = ov12a10_get_format, + .enum_mbus_code = ov12a10_enum_mbus_code, .enum_frame_size = ov12a10_enum_frame_size, +}; +static const struct v4l2_subdev_ops ov12a10_subdev_ops = { + .video = &ov12a10_video_ops, + .pad = &ov12a10_pad_ops, +}; +static const struct media_entity_operations ov12a10_entity_ops = { + .link_validate = v4l2_subdev_link_validate, +}; +static const struct v4l2_subdev_internal_ops ov12a10_internal_ops = { .open = ov12a10_open }; + +static int ov12a10_probe(struct i2c_client *client) +{ + struct device *dev = &client->dev; + struct ov12a10 *ov12a10; + u32 val = 0; + unsigned int i; + int ret; + + ov12a10 = devm_kzalloc(dev, sizeof(*ov12a10), GFP_KERNEL); + if (!ov12a10) + return -ENOMEM; + ov12a10->dev = dev; + v4l2_i2c_subdev_init(&ov12a10->sd, client, &ov12a10_subdev_ops); + ov12a10->xvclk = devm_v4l2_sensor_clk_get(dev, NULL); + if (IS_ERR(ov12a10->xvclk)) + return dev_err_probe(dev, PTR_ERR(ov12a10->xvclk), "xvclk\n"); + clk_set_rate(ov12a10->xvclk, OV12A10_XVCLK_FREQ); + ov12a10->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); + ov12a10->vana_gpio = devm_gpiod_get_optional(dev, "vana", GPIOD_OUT_LOW); + ov12a10->pwdn_gpio = devm_gpiod_get_optional(dev, "pwdn", GPIOD_OUT_HIGH); + if (IS_ERR(ov12a10->reset_gpio)) + return dev_err_probe(dev, PTR_ERR(ov12a10->reset_gpio), "reset\n"); + for (i = 0; i < OV12A10_NUM_SUPPLIES; i++) + ov12a10->supplies[i].supply = ov12a10_supply_names[i]; + ret = devm_regulator_bulk_get(dev, OV12A10_NUM_SUPPLIES, ov12a10->supplies); + if (ret) + return dev_err_probe(dev, ret, "regulators\n"); + ret = ov12a10_power_on(dev); + if (ret) + return ret; + ret = ov12a10_read_reg(ov12a10, OV12A10_CHIP_ID_REG, 2, &val); + if (ret || val != OV12A10_CHIP_ID) { + dev_err(dev, "failed to identify ov12a10 (ret=%d, id=0x%04x)\n", ret, val); + ret = ret ? ret : -ENXIO; + goto err_power; + } + dev_info(dev, "identified OmniVision OV12A10 sensor (0x%04x)\n", val); + mutex_init(&ov12a10->mutex); + ov12a10->cur_mode = &supported_modes[0]; + ret = ov12a10_init_controls(ov12a10); + if (ret) + goto err_mutex; + ov12a10->sd.internal_ops = &ov12a10_internal_ops; + ov12a10->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; + ov12a10->sd.entity.ops = &ov12a10_entity_ops; + ov12a10->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; + ov12a10->pad.flags = MEDIA_PAD_FL_SOURCE; + ret = media_entity_pads_init(&ov12a10->sd.entity, 1, &ov12a10->pad); + if (ret) + goto err_ctrl; + ov12a10->sd.state_lock = &ov12a10->mutex; + ret = v4l2_subdev_init_finalize(&ov12a10->sd); + if (ret) + goto err_media; + ret = v4l2_async_register_subdev_sensor(&ov12a10->sd); + if (ret) + goto err_media; + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + pm_runtime_idle(dev); + return 0; +err_media: media_entity_cleanup(&ov12a10->sd.entity); +err_ctrl: v4l2_ctrl_handler_free(ov12a10->sd.ctrl_handler); +err_mutex: mutex_destroy(&ov12a10->mutex); +err_power: ov12a10_power_off(dev); + return ret; +} + +static void ov12a10_remove(struct i2c_client *client) +{ + struct v4l2_subdev *sd = i2c_get_clientdata(client); + struct ov12a10 *ov12a10 = to_ov12a10(sd); + + v4l2_async_unregister_subdev(sd); + media_entity_cleanup(&sd->entity); + v4l2_ctrl_handler_free(sd->ctrl_handler); + mutex_destroy(&ov12a10->mutex); + pm_runtime_disable(&client->dev); + if (!pm_runtime_status_suspended(&client->dev)) + ov12a10_power_off(&client->dev); + pm_runtime_set_suspended(&client->dev); +} + +static const struct dev_pm_ops ov12a10_pm_ops = { SET_RUNTIME_PM_OPS(ov12a10_power_off, + ov12a10_power_on, NULL) }; +static const struct of_device_id ov12a10_of_match[] = { { .compatible = "ovti,ov12a10" }, { } }; +MODULE_DEVICE_TABLE(of, ov12a10_of_match); +static struct i2c_driver ov12a10_i2c_driver = { + .driver = { .name = "ov12a10", .pm = &ov12a10_pm_ops, .of_match_table = ov12a10_of_match }, + .probe = ov12a10_probe, .remove = ov12a10_remove, +}; +module_i2c_driver(ov12a10_i2c_driver); +MODULE_DESCRIPTION("OmniVision OV12A10 12MP sensor driver"); +MODULE_LICENSE("GPL"); -- 2.47.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 6/7] arm64: dts: qcom: msm8953: add CAMSS node and MCLK pinctrl states 2026-11-23 12:35 ` [PATCH v2 0/7] " Hikmah Gumelar ` (4 preceding siblings ...) 2026-11-23 12:35 ` [PATCH v2 5/7] media: i2c: add ov12a10 image sensor driver Hikmah Gumelar @ 2026-11-23 12:35 ` Hikmah Gumelar 2026-11-23 12:35 ` [PATCH v2 7/7] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar 6 siblings, 0 replies; 17+ messages in thread From: Hikmah Gumelar @ 2026-11-23 12:35 UTC (permalink / raw) To: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Abel Vesa, Stephen Boyd, Brian Masney, Jerome Brunet, Sakari Ailus Cc: Hikmah Gumelar, linux-media, devicetree, linux-kernel, linux-arm-msm, linux-clk Add the camera subsystem (CAMSS) node and MCLK0/1/2 pin control states to the Qualcomm MSM8953 SoC Devicetree. Signed-off-by: Hikmah Gumelar <hikmahgumelar@gmail.com> --- arch/arm64/boot/dts/qcom/msm8953.dtsi | 155 ++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/msm8953.dtsi b/arch/arm64/boot/dts/qcom/msm8953.dtsi index 753167c3f861..2e64fb8bbb2e 100644 --- a/arch/arm64/boot/dts/qcom/msm8953.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8953.dtsi @@ -902,6 +902,27 @@ sdc1_cmd_off: sdc1-cmd-off-state { drive-strength = <2>; }; + camss_mclk0_default: camss-mclk0-default-state { + pins = "gpio26"; + function = "cam_mclk"; + drive-strength = <2>; + bias-disable; + }; + + camss_mclk1_default: camss-mclk1-default-state { + pins = "gpio27"; + function = "cam_mclk"; + drive-strength = <2>; + bias-disable; + }; + + camss_mclk2_default: camss-mclk2-default-state { + pins = "gpio28"; + function = "cam_mclk"; + drive-strength = <2>; + bias-disable; + }; + sdc1_data_on: sdc1-data-on-state { pins = "sdc1_data"; bias-pull-up; @@ -1257,6 +1278,140 @@ cci_i2c1: i2c-bus@1 { }; }; + camss: camss@1b00020 { + compatible = "qcom,msm8953-camss"; + + reg = <0x1b00020 0x10>, + <0x1b30000 0x100>, + <0x1b30400 0x100>, + <0x1b30800 0x100>, + <0x1b34000 0x1000>, + <0x1b00030 0x4>, + <0x1b35000 0x1000>, + <0x1b00038 0x4>, + <0x1b36000 0x1000>, + <0x1b00040 0x4>, + <0x1b31000 0x500>, + <0x1b10000 0x1000>, + <0x1b14000 0x1000>; + reg-names = "csi_clk_mux", + "csid0", + "csid1", + "csid2", + "csiphy0", + "csiphy0_clk_mux", + "csiphy1", + "csiphy1_clk_mux", + "csiphy2", + "csiphy2_clk_mux", + "ispif", + "vfe0", + "vfe1"; + + clocks = <&gcc GCC_CAMSS_AHB_CLK>, + <&gcc GCC_CAMSS_CSI0_CLK>, + <&gcc GCC_CAMSS_CSI0_AHB_CLK>, + <&gcc GCC_CAMSS_CSI0PHY_CLK>, + <&gcc GCC_CAMSS_CSI0PIX_CLK>, + <&gcc GCC_CAMSS_CSI0RDI_CLK>, + <&gcc GCC_CAMSS_CSI1_CLK>, + <&gcc GCC_CAMSS_CSI1_AHB_CLK>, + <&gcc GCC_CAMSS_CSI1PHY_CLK>, + <&gcc GCC_CAMSS_CSI1PIX_CLK>, + <&gcc GCC_CAMSS_CSI1RDI_CLK>, + <&gcc GCC_CAMSS_CSI2_CLK>, + <&gcc GCC_CAMSS_CSI2_AHB_CLK>, + <&gcc GCC_CAMSS_CSI2PHY_CLK>, + <&gcc GCC_CAMSS_CSI2PIX_CLK>, + <&gcc GCC_CAMSS_CSI2RDI_CLK>, + <&gcc GCC_CAMSS_CSI_VFE0_CLK>, + <&gcc GCC_CAMSS_CSI_VFE1_CLK>, + <&gcc GCC_CAMSS_CSI0PHYTIMER_CLK>, + <&gcc GCC_CAMSS_CSI1PHYTIMER_CLK>, + <&gcc GCC_CAMSS_CSI2PHYTIMER_CLK>, + <&gcc GCC_CAMSS_ISPIF_AHB_CLK>, + <&gcc GCC_CAMSS_MICRO_AHB_CLK>, + <&gcc GCC_CAMSS_TOP_AHB_CLK>, + <&gcc GCC_CAMSS_VFE0_CLK>, + <&gcc GCC_CAMSS_VFE0_AHB_CLK>, + <&gcc GCC_CAMSS_VFE0_AXI_CLK>, + <&gcc GCC_CAMSS_VFE1_CLK>, + <&gcc GCC_CAMSS_VFE1_AHB_CLK>, + <&gcc GCC_CAMSS_VFE1_AXI_CLK>; + clock-names = "ahb", + "csi0", + "csi0_ahb", + "csi0_phy", + "csi0_pix", + "csi0_rdi", + "csi1", + "csi1_ahb", + "csi1_phy", + "csi1_pix", + "csi1_rdi", + "csi2", + "csi2_ahb", + "csi2_phy", + "csi2_pix", + "csi2_rdi", + "csi_vfe0", + "csi_vfe1", + "csiphy0_timer", + "csiphy1_timer", + "csiphy2_timer", + "ispif_ahb", + "micro_ahb", + "top_ahb", + "vfe0", + "vfe0_ahb", + "vfe0_axi", + "vfe1", + "vfe1_ahb", + "vfe1_axi"; + + interrupts = <GIC_SPI 51 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 52 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 153 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 78 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 79 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 315 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 55 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 57 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 29 IRQ_TYPE_EDGE_RISING>; + interrupt-names = "csid0", + "csid1", + "csid2", + "csiphy0", + "csiphy1", + "csiphy2", + "ispif", + "vfe0", + "vfe1"; + + iommus = <&apps_iommu 0x14>; + + interconnects = <&snoc_mm MAS_VFE0 RPM_ACTIVE_TAG + &bimc SLV_EBI RPM_ACTIVE_TAG>, + <&snoc_mm MAS_VFE1 RPM_ACTIVE_TAG + &bimc SLV_EBI RPM_ACTIVE_TAG>, + <&bimc MAS_APPS_PROC RPM_ACTIVE_TAG + &pcnoc SLV_CAMERA_SS_CFG RPM_ACTIVE_TAG>; + interconnect-names = "cam_vfe0_mem", + "cam_vfe1_mem", + "cam_ahb"; + + power-domains = <&gcc VFE0_GDSC>, + <&gcc VFE1_GDSC>; + power-domain-names = "vfe0", "vfe1"; + + status = "disabled"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + }; + }; + gpu: gpu@1c00000 { compatible = "qcom,adreno-506.0", "qcom,adreno"; reg = <0x01c00000 0x40000>; -- 2.47.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 7/7] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras 2026-11-23 12:35 ` [PATCH v2 0/7] " Hikmah Gumelar ` (5 preceding siblings ...) 2026-11-23 12:35 ` [PATCH v2 6/7] arm64: dts: qcom: msm8953: add CAMSS node and MCLK pinctrl states Hikmah Gumelar @ 2026-11-23 12:35 ` Hikmah Gumelar 6 siblings, 0 replies; 17+ messages in thread From: Hikmah Gumelar @ 2026-11-23 12:35 UTC (permalink / raw) To: Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Konrad Dybcio, Abel Vesa, Stephen Boyd, Brian Masney, Jerome Brunet, Sakari Ailus Cc: Hikmah Gumelar, linux-media, devicetree, linux-kernel, linux-arm-msm, linux-clk Enable the CAMSS, CCI, CSIPHY0/CSIPHY2 ports, and the OmniVision OV12A10 rear camera and Samsung S5K5E8 front camera on Xiaomi Mi A1 (tissot). Signed-off-by: Hikmah Gumelar <hikmahgumelar@gmail.com> --- .../boot/dts/qcom/msm8953-xiaomi-tissot.dts | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts b/arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts index fccb9c4360ca..5d4fd7f42042 100644 --- a/arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts +++ b/arch/arm64/boot/dts/qcom/msm8953-xiaomi-tissot.dts @@ -308,6 +308,20 @@ ts_int_default: ts-int-default-state { drive-strength = <2>; bias-pull-up; }; + + cam_sensor_rear_default: cam-sensor-rear-default-state { + pins = "gpio33", "gpio39", "gpio62"; + function = "gpio"; + bias-disable; + drive-strength = <2>; + }; + + cam_sensor_front_default: cam-sensor-front-default-state { + pins = "gpio129"; + function = "gpio"; + bias-disable; + drive-strength = <2>; + }; }; &uart_0 { @@ -325,3 +339,103 @@ &usb3_dwc3 { /delete-property/ usb-role-switch; dr_mode = "peripheral"; }; + +&camss { + status = "okay"; + vdda-supply = <&pm8953_s3>; + + ports { + port@0 { + reg = <0>; + csiphy0_ep: endpoint { + clock-lanes = <7>; + data-lanes = <0 1 2 3>; + remote-endpoint = <&rear_cam_ep>; + }; + }; + + port@2 { + reg = <2>; + csiphy2_ep: endpoint { + clock-lanes = <7>; + data-lanes = <0 1>; + remote-endpoint = <&front_cam_ep>; + }; + }; + }; +}; + +&cci { + pinctrl-names = "default"; + pinctrl-0 = <&cci0_default>, + <&cci1_default>, + <&camss_mclk0_default>, + <&camss_mclk1_default>, + <&camss_mclk2_default>; + + status = "okay"; +}; + +&cci_i2c0 { + camera-sensor@10 { + compatible = "ovti,ov12a10"; + reg = <0x10>; + clocks = <&gcc GCC_CAMSS_MCLK0_CLK>; + pinctrl-0 = <&cam_sensor_rear_default>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 33 GPIO_ACTIVE_LOW>; + pwdn-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + vana-gpios = <&tlmm 62 GPIO_ACTIVE_HIGH>; + avdd-supply = <&pm8953_l22>; + dvdd-supply = <&pm8953_l2>; + dovdd-supply = <&pm8953_l6>; + rotation = <270>; + orientation = <1>; + status = "okay"; + port { + rear_cam_ep: endpoint { + data-lanes = <0 1 2 3>; + remote-endpoint = <&csiphy0_ep>; + link-frequencies = /bits/ 64 <216000000>; + }; + }; + }; +}; + +&cci_i2c1 { + camera-sensor@2d { + compatible = "samsung,s5k5e8"; + reg = <0x2d>; + + clocks = <&gcc GCC_CAMSS_MCLK1_CLK>; + pinctrl-0 = <&cam_sensor_front_default>; + pinctrl-names = "default"; + + reset-gpios = <&tlmm 129 GPIO_ACTIVE_LOW>; + + avdd-supply = <&pm8953_l22>; + dvdd-supply = <&pm8953_l23>; + dovdd-supply = <&pm8953_l6>; + rotation = <90>; + orientation = <0>; + + status = "okay"; + + port { + front_cam_ep: endpoint { + data-lanes = <0 1>; + remote-endpoint = <&csiphy2_ep>; + link-frequencies = /bits/ 64 <418000000>; + }; + }; + }; +}; + +&pm8953_l23 { + regulator-min-microvolt = <1200000>; +}; + +&pm8953_l2 { + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1225000>; +}; -- 2.47.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
end of thread, other threads:[~2026-11-23 14:14 UTC | newest] Thread overview: 17+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-23 11:07 [PATCH 0/6] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar 2026-11-23 11:08 ` [PATCH 1/6] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent Hikmah Gumelar 2026-11-23 11:08 ` [PATCH 2/6] media: dt-bindings: media: i2c: add Samsung S5K5E8 Hikmah Gumelar 2026-11-23 11:08 ` [PATCH 3/6] media: i2c: add s5k5e8 image sensor driver Hikmah Gumelar 2026-11-23 11:08 ` [PATCH 4/6] media: dt-bindings: media: i2c: add OmniVision OV12A10 Hikmah Gumelar 2026-11-23 11:08 ` [PATCH 5/6] media: i2c: add ov12a10 image sensor driver Hikmah Gumelar 2026-11-23 11:08 ` [PATCH 6/6] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar 2026-11-23 12:35 ` [PATCH v2 0/7] " Hikmah Gumelar 2026-11-23 12:35 ` [PATCH v2 1/7] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent Hikmah Gumelar 2026-11-23 12:35 ` [PATCH v2 2/7] media: dt-bindings: media: i2c: add Samsung S5K5E8 Hikmah Gumelar 2026-11-23 12:35 ` [PATCH v2 3/7] media: i2c: add s5k5e8 image sensor driver Hikmah Gumelar 2026-11-23 13:56 ` Uwe Kleine-König 2026-11-23 14:14 ` Hikmah Gumelar 2026-11-23 12:35 ` [PATCH v2 4/7] media: dt-bindings: media: i2c: add OmniVision OV12A10 Hikmah Gumelar 2026-11-23 12:35 ` [PATCH v2 5/7] media: i2c: add ov12a10 image sensor driver Hikmah Gumelar 2026-11-23 12:35 ` [PATCH v2 6/7] arm64: dts: qcom: msm8953: add CAMSS node and MCLK pinctrl states Hikmah Gumelar 2026-11-23 12:35 ` [PATCH v2 7/7] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox