123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977 |
- From d07be9c0bd2d2f63326d85c35de3bfcd6f8851d4 Mon Sep 17 00:00:00 2001
- From: Hans de Goede <hdegoede@redhat.com>
- Date: Sun, 10 Oct 2021 20:56:57 +0200
- Subject: [PATCH] ACPI: delay enumeration of devices with a _DEP pointing to an
- INT3472 device
- The clk and regulator frameworks expect clk/regulator consumer-devices
- to have info about the consumed clks/regulators described in the device's
- fw_node.
- To work around cases where this info is not present in the firmware tables,
- which is often the case on x86/ACPI devices, both frameworks allow the
- provider-driver to attach info about consumers to the clks/regulators
- when registering these.
- This causes problems with the probe ordering wrt drivers for consumers
- of these clks/regulators. Since the lookups are only registered when the
- provider-driver binds, trying to get these clks/regulators before then
- results in a -ENOENT error for clks and a dummy regulator for regulators.
- One case where we hit this issue is camera sensors such as e.g. the OV8865
- sensor found on the Microsoft Surface Go. The sensor uses clks, regulators
- and GPIOs provided by a TPS68470 PMIC which is described in an INT3472
- ACPI device. There is special platform code handling this and setting
- platform_data with the necessary consumer info on the MFD cells
- instantiated for the PMIC under: drivers/platform/x86/intel/int3472.
- For this to work properly the ov8865 driver must not bind to the I2C-client
- for the OV8865 sensor until after the TPS68470 PMIC gpio, regulator and
- clk MFD cells have all been fully setup.
- The OV8865 on the Microsoft Surface Go is just one example, all X86
- devices using the Intel IPU3 camera block found on recent Intel SoCs
- have similar issues where there is an INT3472 HID ACPI-device, which
- describes the clks and regulators, and the driver for this INT3472 device
- must be fully initialized before the sensor driver (any sensor driver)
- binds for things to work properly.
- On these devices the ACPI nodes describing the sensors all have a _DEP
- dependency on the matching INT3472 ACPI device (there is one per sensor).
- This allows solving the probe-ordering problem by delaying the enumeration
- (instantiation of the I2C-client in the ov8865 example) of ACPI-devices
- which have a _DEP dependency on an INT3472 device.
- The new acpi_dev_ready_for_enumeration() helper used for this is also
- exported because for devices, which have the enumeration_by_parent flag
- set, the parent-driver will do its own scan of child ACPI devices and
- it will try to enumerate those during its probe(). Code doing this such
- as e.g. the i2c-core-acpi.c code must call this new helper to ensure
- that it too delays the enumeration until all the _DEP dependencies are
- met on devices which have the new honor_deps flag set.
- Signed-off-by: Hans de Goede <hdegoede@redhat.com>
- Patchset: cameras
- ---
- drivers/acpi/scan.c | 3 +++
- 1 file changed, 3 insertions(+)
- diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
- index a0e347f6f97e..167dbf4cf623 100644
- --- a/drivers/acpi/scan.c
- +++ b/drivers/acpi/scan.c
- @@ -2107,6 +2107,9 @@ static acpi_status acpi_bus_check_add_2(acpi_handle handle, u32 lvl_not_used,
-
- static void acpi_default_enumeration(struct acpi_device *device)
- {
- + if (!acpi_dev_ready_for_enumeration(device))
- + return;
- +
- /*
- * Do not enumerate devices with enumeration_by_parent flag set as
- * they will be enumerated by their respective parents.
- --
- 2.42.0
- From 71ad307fa27f57849d6a77a78a7f135e9d89a33a Mon Sep 17 00:00:00 2001
- From: zouxiaoh <xiaohong.zou@intel.com>
- Date: Fri, 25 Jun 2021 08:52:59 +0800
- Subject: [PATCH] iommu: intel-ipu: use IOMMU passthrough mode for Intel IPUs
- Intel IPU(Image Processing Unit) has its own (IO)MMU hardware,
- The IPU driver allocates its own page table that is not mapped
- via the DMA, and thus the Intel IOMMU driver blocks access giving
- this error: DMAR: DRHD: handling fault status reg 3 DMAR:
- [DMA Read] Request device [00:05.0] PASID ffffffff
- fault addr 76406000 [fault reason 06] PTE Read access is not set
- As IPU is not an external facing device which is not risky, so use
- IOMMU passthrough mode for Intel IPUs.
- Change-Id: I6dcccdadac308cf42e20a18e1b593381391e3e6b
- Depends-On: Iacd67578e8c6a9b9ac73285f52b4081b72fb68a6
- Tracked-On: #JIITL8-411
- Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
- Signed-off-by: zouxiaoh <xiaohong.zou@intel.com>
- Signed-off-by: Xu Chongyang <chongyang.xu@intel.com>
- Patchset: cameras
- ---
- drivers/iommu/intel/iommu.c | 30 ++++++++++++++++++++++++++++++
- 1 file changed, 30 insertions(+)
- diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
- index 66e8a5c18fb8..73beca5d7ca9 100644
- --- a/drivers/iommu/intel/iommu.c
- +++ b/drivers/iommu/intel/iommu.c
- @@ -37,6 +37,12 @@
- #define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY)
- #define IS_USB_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_SERIAL_USB)
- #define IS_ISA_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA)
- +#define IS_INTEL_IPU(pdev) ((pdev)->vendor == PCI_VENDOR_ID_INTEL && \
- + ((pdev)->device == 0x9a19 || \
- + (pdev)->device == 0x9a39 || \
- + (pdev)->device == 0x4e19 || \
- + (pdev)->device == 0x465d || \
- + (pdev)->device == 0x1919))
- #define IS_IPTS(pdev) ((pdev)->vendor == PCI_VENDOR_ID_INTEL && \
- ((pdev)->device == 0x9d3e))
- #define IS_AZALIA(pdev) ((pdev)->vendor == 0x8086 && (pdev)->device == 0x3a3e)
- @@ -289,12 +295,14 @@ EXPORT_SYMBOL_GPL(intel_iommu_enabled);
-
- static int dmar_map_gfx = 1;
- static int dmar_map_ipts = 1;
- +static int dmar_map_ipu = 1;
- static int intel_iommu_superpage = 1;
- static int iommu_identity_mapping;
- static int iommu_skip_te_disable;
-
- #define IDENTMAP_GFX 2
- #define IDENTMAP_AZALIA 4
- +#define IDENTMAP_IPU 8
- #define IDENTMAP_IPTS 16
-
- const struct iommu_ops intel_iommu_ops;
- @@ -2635,6 +2643,9 @@ static int device_def_domain_type(struct device *dev)
- if ((iommu_identity_mapping & IDENTMAP_GFX) && IS_GFX_DEVICE(pdev))
- return IOMMU_DOMAIN_IDENTITY;
-
- + if ((iommu_identity_mapping & IDENTMAP_IPU) && IS_INTEL_IPU(pdev))
- + return IOMMU_DOMAIN_IDENTITY;
- +
- if ((iommu_identity_mapping & IDENTMAP_IPTS) && IS_IPTS(pdev))
- return IOMMU_DOMAIN_IDENTITY;
- }
- @@ -3026,6 +3037,9 @@ static int __init init_dmars(void)
- if (!dmar_map_gfx)
- iommu_identity_mapping |= IDENTMAP_GFX;
-
- + if (!dmar_map_ipu)
- + iommu_identity_mapping |= IDENTMAP_IPU;
- +
- if (!dmar_map_ipts)
- iommu_identity_mapping |= IDENTMAP_IPTS;
-
- @@ -4782,6 +4796,18 @@ static void quirk_iommu_igfx(struct pci_dev *dev)
- dmar_map_gfx = 0;
- }
-
- +static void quirk_iommu_ipu(struct pci_dev *dev)
- +{
- + if (!IS_INTEL_IPU(dev))
- + return;
- +
- + if (risky_device(dev))
- + return;
- +
- + pci_info(dev, "Passthrough IOMMU for integrated Intel IPU\n");
- + dmar_map_ipu = 0;
- +}
- +
- static void quirk_iommu_ipts(struct pci_dev *dev)
- {
- if (!IS_IPTS(dev))
- @@ -4793,6 +4819,7 @@ static void quirk_iommu_ipts(struct pci_dev *dev)
- pci_info(dev, "Passthrough IOMMU for IPTS\n");
- dmar_map_ipts = 0;
- }
- +
- /* G4x/GM45 integrated gfx dmar support is totally busted. */
- DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2a40, quirk_iommu_igfx);
- DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e00, quirk_iommu_igfx);
- @@ -4828,6 +4855,9 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1632, quirk_iommu_igfx);
- DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x163A, quirk_iommu_igfx);
- DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x163D, quirk_iommu_igfx);
-
- +/* disable IPU dmar support */
- +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, quirk_iommu_ipu);
- +
- /* disable IPTS dmar support */
- DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x9D3E, quirk_iommu_ipts);
-
- --
- 2.42.0
- From ce2efa0851b6fa4e88f1d59cdd4d95a8989a74d1 Mon Sep 17 00:00:00 2001
- From: Daniel Scally <djrscally@gmail.com>
- Date: Sun, 10 Oct 2021 20:57:02 +0200
- Subject: [PATCH] platform/x86: int3472: Enable I2c daisy chain
- The TPS68470 PMIC has an I2C passthrough mode through which I2C traffic
- can be forwarded to a device connected to the PMIC as though it were
- connected directly to the system bus. Enable this mode when the chip
- is initialised.
- Signed-off-by: Daniel Scally <djrscally@gmail.com>
- Patchset: cameras
- ---
- drivers/platform/x86/intel/int3472/tps68470.c | 7 +++++++
- 1 file changed, 7 insertions(+)
- diff --git a/drivers/platform/x86/intel/int3472/tps68470.c b/drivers/platform/x86/intel/int3472/tps68470.c
- index 5b8d1a9620a5..6a0ff035cf20 100644
- --- a/drivers/platform/x86/intel/int3472/tps68470.c
- +++ b/drivers/platform/x86/intel/int3472/tps68470.c
- @@ -46,6 +46,13 @@ static int tps68470_chip_init(struct device *dev, struct regmap *regmap)
- return ret;
- }
-
- + /* Enable I2C daisy chain */
- + ret = regmap_write(regmap, TPS68470_REG_S_I2C_CTL, 0x03);
- + if (ret) {
- + dev_err(dev, "Failed to enable i2c daisy chain\n");
- + return ret;
- + }
- +
- dev_info(dev, "TPS68470 REVID: 0x%02x\n", version);
-
- return 0;
- --
- 2.42.0
- From 5d384365a6d21ab507243f11dd8f2c3e2633cde9 Mon Sep 17 00:00:00 2001
- From: Daniel Scally <djrscally@gmail.com>
- Date: Thu, 28 Oct 2021 21:55:16 +0100
- Subject: [PATCH] media: i2c: Add driver for DW9719 VCM
- Add a driver for the DW9719 VCM. The driver creates a v4l2 subdevice
- and registers a control to set the desired focus.
- Signed-off-by: Daniel Scally <djrscally@gmail.com>
- Patchset: cameras
- ---
- MAINTAINERS | 7 +
- drivers/media/i2c/Kconfig | 11 +
- drivers/media/i2c/Makefile | 1 +
- drivers/media/i2c/dw9719.c | 425 +++++++++++++++++++++++++++++++++++++
- 4 files changed, 444 insertions(+)
- create mode 100644 drivers/media/i2c/dw9719.c
- diff --git a/MAINTAINERS b/MAINTAINERS
- index 07a9c274c0e2..0ecc68379a3e 100644
- --- a/MAINTAINERS
- +++ b/MAINTAINERS
- @@ -6286,6 +6286,13 @@ T: git git://linuxtv.org/media_tree.git
- F: Documentation/devicetree/bindings/media/i2c/dongwoon,dw9714.yaml
- F: drivers/media/i2c/dw9714.c
-
- +DONGWOON DW9719 LENS VOICE COIL DRIVER
- +M: Daniel Scally <djrscally@gmail.com>
- +L: linux-media@vger.kernel.org
- +S: Maintained
- +T: git git://linuxtv.org/media_tree.git
- +F: drivers/media/i2c/dw9719.c
- +
- DONGWOON DW9768 LENS VOICE COIL DRIVER
- M: Dongchun Zhu <dongchun.zhu@mediatek.com>
- L: linux-media@vger.kernel.org
- diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
- index a34afb5217eb..fbaa2ce7fa3e 100644
- --- a/drivers/media/i2c/Kconfig
- +++ b/drivers/media/i2c/Kconfig
- @@ -828,6 +828,17 @@ config VIDEO_DW9714
- capability. This is designed for linear control of
- voice coil motors, controlled via I2C serial interface.
-
- +config VIDEO_DW9719
- + tristate "DW9719 lens voice coil support"
- + depends on I2C && VIDEO_V4L2
- + select MEDIA_CONTROLLER
- + select VIDEO_V4L2_SUBDEV_API
- + select V4L2_ASYNC
- + help
- + This is a driver for the DW9719 camera lens voice coil.
- + This is designed for linear control of voice coil motors,
- + controlled via I2C serial interface.
- +
- config VIDEO_DW9768
- tristate "DW9768 lens voice coil support"
- depends on I2C && VIDEO_DEV
- diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
- index 0a2933103dd9..b82a07c76388 100644
- --- a/drivers/media/i2c/Makefile
- +++ b/drivers/media/i2c/Makefile
- @@ -30,6 +30,7 @@ obj-$(CONFIG_VIDEO_CS5345) += cs5345.o
- obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o
- obj-$(CONFIG_VIDEO_CX25840) += cx25840/
- obj-$(CONFIG_VIDEO_DW9714) += dw9714.o
- +obj-$(CONFIG_VIDEO_DW9719) += dw9719.o
- obj-$(CONFIG_VIDEO_DW9768) += dw9768.o
- obj-$(CONFIG_VIDEO_DW9807_VCM) += dw9807-vcm.o
- obj-$(CONFIG_VIDEO_ET8EK8) += et8ek8/
- diff --git a/drivers/media/i2c/dw9719.c b/drivers/media/i2c/dw9719.c
- new file mode 100644
- index 000000000000..180b04d2a6b3
- --- /dev/null
- +++ b/drivers/media/i2c/dw9719.c
- @@ -0,0 +1,425 @@
- +// SPDX-License-Identifier: GPL-2.0
- +// Copyright (c) 2012 Intel Corporation
- +
- +/*
- + * Based on linux/modules/camera/drivers/media/i2c/imx/dw9719.c in this repo:
- + * https://github.com/ZenfoneArea/android_kernel_asus_zenfone5
- + */
- +
- +#include <asm/unaligned.h>
- +
- +#include <linux/delay.h>
- +#include <linux/i2c.h>
- +#include <linux/pm_runtime.h>
- +#include <linux/regulator/consumer.h>
- +#include <linux/types.h>
- +
- +#include <media/v4l2-common.h>
- +#include <media/v4l2-ctrls.h>
- +#include <media/v4l2-subdev.h>
- +
- +#define DW9719_MAX_FOCUS_POS 1023
- +#define DW9719_CTRL_STEPS 16
- +#define DW9719_CTRL_DELAY_US 1000
- +#define DELAY_MAX_PER_STEP_NS (1000000 * 1023)
- +
- +#define DW9719_INFO 0
- +#define DW9719_ID 0xF1
- +#define DW9719_CONTROL 2
- +#define DW9719_VCM_CURRENT 3
- +
- +#define DW9719_MODE 6
- +#define DW9719_VCM_FREQ 7
- +
- +#define DW9719_MODE_SAC3 0x40
- +#define DW9719_DEFAULT_VCM_FREQ 0x60
- +#define DW9719_ENABLE_RINGING 0x02
- +
- +#define NUM_REGULATORS 2
- +
- +#define to_dw9719_device(x) container_of(x, struct dw9719_device, sd)
- +
- +struct dw9719_device {
- + struct device *dev;
- + struct i2c_client *client;
- + struct regulator_bulk_data regulators[NUM_REGULATORS];
- + struct v4l2_subdev sd;
- +
- + struct dw9719_v4l2_ctrls {
- + struct v4l2_ctrl_handler handler;
- + struct v4l2_ctrl *focus;
- + } ctrls;
- +};
- +
- +static int dw9719_i2c_rd8(struct i2c_client *client, u8 reg, u8 *val)
- +{
- + struct i2c_msg msg[2];
- + u8 buf[2] = { reg };
- + int ret;
- +
- + msg[0].addr = client->addr;
- + msg[0].flags = 0;
- + msg[0].len = 1;
- + msg[0].buf = buf;
- +
- + msg[1].addr = client->addr;
- + msg[1].flags = I2C_M_RD;
- + msg[1].len = 1;
- + msg[1].buf = &buf[1];
- + *val = 0;
- +
- + ret = i2c_transfer(client->adapter, msg, 2);
- + if (ret < 0)
- + return ret;
- +
- + *val = buf[1];
- +
- + return 0;
- +}
- +
- +static int dw9719_i2c_wr8(struct i2c_client *client, u8 reg, u8 val)
- +{
- + struct i2c_msg msg;
- + int ret;
- +
- + u8 buf[2] = { reg, val };
- +
- + msg.addr = client->addr;
- + msg.flags = 0;
- + msg.len = sizeof(buf);
- + msg.buf = buf;
- +
- + ret = i2c_transfer(client->adapter, &msg, 1);
- +
- + return ret < 0 ? ret : 0;
- +}
- +
- +static int dw9719_i2c_wr16(struct i2c_client *client, u8 reg, u16 val)
- +{
- + struct i2c_msg msg;
- + u8 buf[3] = { reg };
- + int ret;
- +
- + put_unaligned_be16(val, buf + 1);
- +
- + msg.addr = client->addr;
- + msg.flags = 0;
- + msg.len = sizeof(buf);
- + msg.buf = buf;
- +
- + ret = i2c_transfer(client->adapter, &msg, 1);
- +
- + return ret < 0 ? ret : 0;
- +}
- +
- +static int dw9719_detect(struct dw9719_device *dw9719)
- +{
- + int ret;
- + u8 val;
- +
- + ret = dw9719_i2c_rd8(dw9719->client, DW9719_INFO, &val);
- + if (ret < 0)
- + return ret;
- +
- + if (val != DW9719_ID) {
- + dev_err(dw9719->dev, "Failed to detect correct id\n");
- + ret = -ENXIO;
- + }
- +
- + return 0;
- +}
- +
- +static int dw9719_power_down(struct dw9719_device *dw9719)
- +{
- + return regulator_bulk_disable(NUM_REGULATORS, dw9719->regulators);
- +}
- +
- +static int dw9719_power_up(struct dw9719_device *dw9719)
- +{
- + int ret;
- +
- + ret = regulator_bulk_enable(NUM_REGULATORS, dw9719->regulators);
- + if (ret)
- + return ret;
- +
- + /* Jiggle SCL pin to wake up device */
- + ret = dw9719_i2c_wr8(dw9719->client, DW9719_CONTROL, 1);
- +
- + /* Need 100us to transit from SHUTDOWN to STANDBY*/
- + usleep_range(100, 1000);
- +
- + ret = dw9719_i2c_wr8(dw9719->client, DW9719_CONTROL,
- + DW9719_ENABLE_RINGING);
- + if (ret < 0)
- + goto fail_powerdown;
- +
- + ret = dw9719_i2c_wr8(dw9719->client, DW9719_MODE, DW9719_MODE_SAC3);
- + if (ret < 0)
- + goto fail_powerdown;
- +
- + ret = dw9719_i2c_wr8(dw9719->client, DW9719_VCM_FREQ,
- + DW9719_DEFAULT_VCM_FREQ);
- + if (ret < 0)
- + goto fail_powerdown;
- +
- + return 0;
- +
- +fail_powerdown:
- + dw9719_power_down(dw9719);
- + return ret;
- +}
- +
- +static int dw9719_t_focus_abs(struct dw9719_device *dw9719, s32 value)
- +{
- + int ret;
- +
- + value = clamp(value, 0, DW9719_MAX_FOCUS_POS);
- + ret = dw9719_i2c_wr16(dw9719->client, DW9719_VCM_CURRENT, value);
- + if (ret < 0)
- + return ret;
- +
- + return 0;
- +}
- +
- +static int dw9719_set_ctrl(struct v4l2_ctrl *ctrl)
- +{
- + struct dw9719_device *dw9719 = container_of(ctrl->handler,
- + struct dw9719_device,
- + ctrls.handler);
- + int ret;
- +
- + /* Only apply changes to the controls if the device is powered up */
- + if (!pm_runtime_get_if_in_use(dw9719->dev))
- + return 0;
- +
- + switch (ctrl->id) {
- + case V4L2_CID_FOCUS_ABSOLUTE:
- + ret = dw9719_t_focus_abs(dw9719, ctrl->val);
- + break;
- + default:
- + ret = -EINVAL;
- + }
- +
- + pm_runtime_put(dw9719->dev);
- +
- + return ret;
- +}
- +
- +static const struct v4l2_ctrl_ops dw9719_ctrl_ops = {
- + .s_ctrl = dw9719_set_ctrl,
- +};
- +
- +static int __maybe_unused dw9719_suspend(struct device *dev)
- +{
- + struct v4l2_subdev *sd = dev_get_drvdata(dev);
- + struct dw9719_device *dw9719 = to_dw9719_device(sd);
- + int ret;
- + int val;
- +
- + for (val = dw9719->ctrls.focus->val; val >= 0;
- + val -= DW9719_CTRL_STEPS) {
- + ret = dw9719_t_focus_abs(dw9719, val);
- + if (ret)
- + return ret;
- +
- + usleep_range(DW9719_CTRL_DELAY_US, DW9719_CTRL_DELAY_US + 10);
- + }
- +
- + return dw9719_power_down(dw9719);
- +}
- +
- +static int __maybe_unused dw9719_resume(struct device *dev)
- +{
- + struct v4l2_subdev *sd = dev_get_drvdata(dev);
- + struct dw9719_device *dw9719 = to_dw9719_device(sd);
- + int current_focus = dw9719->ctrls.focus->val;
- + int ret;
- + int val;
- +
- + ret = dw9719_power_up(dw9719);
- + if (ret)
- + return ret;
- +
- + for (val = current_focus % DW9719_CTRL_STEPS; val < current_focus;
- + val += DW9719_CTRL_STEPS) {
- + ret = dw9719_t_focus_abs(dw9719, val);
- + if (ret)
- + goto err_power_down;
- +
- + usleep_range(DW9719_CTRL_DELAY_US, DW9719_CTRL_DELAY_US + 10);
- + }
- +
- + return 0;
- +
- +err_power_down:
- + dw9719_power_down(dw9719);
- + return ret;
- +}
- +
- +static int dw9719_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
- +{
- + return pm_runtime_resume_and_get(sd->dev);
- +}
- +
- +static int dw9719_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
- +{
- + pm_runtime_put(sd->dev);
- +
- + return 0;
- +}
- +
- +static const struct v4l2_subdev_internal_ops dw9719_internal_ops = {
- + .open = dw9719_open,
- + .close = dw9719_close,
- +};
- +
- +static int dw9719_init_controls(struct dw9719_device *dw9719)
- +{
- + const struct v4l2_ctrl_ops *ops = &dw9719_ctrl_ops;
- + int ret;
- +
- + ret = v4l2_ctrl_handler_init(&dw9719->ctrls.handler, 1);
- + if (ret)
- + return ret;
- +
- + dw9719->ctrls.focus = v4l2_ctrl_new_std(&dw9719->ctrls.handler, ops,
- + V4L2_CID_FOCUS_ABSOLUTE, 0,
- + DW9719_MAX_FOCUS_POS, 1, 0);
- +
- + if (dw9719->ctrls.handler.error) {
- + dev_err(dw9719->dev, "Error initialising v4l2 ctrls\n");
- + ret = dw9719->ctrls.handler.error;
- + goto err_free_handler;
- + }
- +
- + dw9719->sd.ctrl_handler = &dw9719->ctrls.handler;
- +
- + return ret;
- +
- +err_free_handler:
- + v4l2_ctrl_handler_free(&dw9719->ctrls.handler);
- + return ret;
- +}
- +
- +static const struct v4l2_subdev_ops dw9719_ops = { };
- +
- +static int dw9719_probe(struct i2c_client *client)
- +{
- + struct dw9719_device *dw9719;
- + int ret;
- +
- + dw9719 = devm_kzalloc(&client->dev, sizeof(*dw9719), GFP_KERNEL);
- + if (!dw9719)
- + return -ENOMEM;
- +
- + dw9719->client = client;
- + dw9719->dev = &client->dev;
- +
- + dw9719->regulators[0].supply = "vdd";
- + /*
- + * The DW9719 has only the 1 VDD voltage input, but some PMICs such as
- + * the TPS68470 PMIC have I2C passthrough capability, to disconnect the
- + * sensor's I2C pins from the I2C bus when the sensors VSIO (Sensor-IO)
- + * is off, because some sensors then short these pins to ground;
- + * and the DW9719 might sit behind this passthrough, this it needs to
- + * enable VSIO as that will also enable the I2C passthrough.
- + */
- + dw9719->regulators[1].supply = "vsio";
- +
- + ret = devm_regulator_bulk_get(&client->dev, NUM_REGULATORS,
- + dw9719->regulators);
- + if (ret)
- + return dev_err_probe(&client->dev, ret, "getting regulators\n");
- +
- + v4l2_i2c_subdev_init(&dw9719->sd, client, &dw9719_ops);
- + dw9719->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
- + dw9719->sd.internal_ops = &dw9719_internal_ops;
- +
- + ret = dw9719_init_controls(dw9719);
- + if (ret)
- + return ret;
- +
- + ret = media_entity_pads_init(&dw9719->sd.entity, 0, NULL);
- + if (ret < 0)
- + goto err_free_ctrl_handler;
- +
- + dw9719->sd.entity.function = MEDIA_ENT_F_LENS;
- +
- + /*
- + * We need the driver to work in the event that pm runtime is disable in
- + * the kernel, so power up and verify the chip now. In the event that
- + * runtime pm is disabled this will leave the chip on, so that the lens
- + * will work.
- + */
- +
- + ret = dw9719_power_up(dw9719);
- + if (ret)
- + goto err_cleanup_media;
- +
- + ret = dw9719_detect(dw9719);
- + if (ret)
- + goto err_powerdown;
- +
- + pm_runtime_set_active(&client->dev);
- + pm_runtime_get_noresume(&client->dev);
- + pm_runtime_enable(&client->dev);
- +
- + ret = v4l2_async_register_subdev(&dw9719->sd);
- + if (ret < 0)
- + goto err_pm_runtime;
- +
- + pm_runtime_set_autosuspend_delay(&client->dev, 1000);
- + pm_runtime_use_autosuspend(&client->dev);
- + pm_runtime_put_autosuspend(&client->dev);
- +
- + return ret;
- +
- +err_pm_runtime:
- + pm_runtime_disable(&client->dev);
- + pm_runtime_put_noidle(&client->dev);
- +err_powerdown:
- + dw9719_power_down(dw9719);
- +err_cleanup_media:
- + media_entity_cleanup(&dw9719->sd.entity);
- +err_free_ctrl_handler:
- + v4l2_ctrl_handler_free(&dw9719->ctrls.handler);
- +
- + return ret;
- +}
- +
- +static void dw9719_remove(struct i2c_client *client)
- +{
- + struct v4l2_subdev *sd = i2c_get_clientdata(client);
- + struct dw9719_device *dw9719 = container_of(sd, struct dw9719_device,
- + sd);
- +
- + pm_runtime_disable(&client->dev);
- + v4l2_async_unregister_subdev(sd);
- + v4l2_ctrl_handler_free(&dw9719->ctrls.handler);
- + media_entity_cleanup(&dw9719->sd.entity);
- +}
- +
- +static const struct i2c_device_id dw9719_id_table[] = {
- + { "dw9719" },
- + { }
- +};
- +MODULE_DEVICE_TABLE(i2c, dw9719_id_table);
- +
- +static const struct dev_pm_ops dw9719_pm_ops = {
- + SET_RUNTIME_PM_OPS(dw9719_suspend, dw9719_resume, NULL)
- +};
- +
- +static struct i2c_driver dw9719_i2c_driver = {
- + .driver = {
- + .name = "dw9719",
- + .pm = &dw9719_pm_ops,
- + },
- + .probe_new = dw9719_probe,
- + .remove = dw9719_remove,
- + .id_table = dw9719_id_table,
- +};
- +module_i2c_driver(dw9719_i2c_driver);
- +
- +MODULE_AUTHOR("Daniel Scally <djrscally@gmail.com>");
- +MODULE_DESCRIPTION("DW9719 VCM Driver");
- +MODULE_LICENSE("GPL");
- --
- 2.42.0
- From b4ce4a1930c03eb60e3a4362f0daf5595eabb3c0 Mon Sep 17 00:00:00 2001
- From: Daniel Scally <djrscally@gmail.com>
- Date: Wed, 4 May 2022 23:21:45 +0100
- Subject: [PATCH] media: ipu3-cio2: Move functionality from .complete() to
- .bound()
- Creating links and registering subdev nodes during the .complete()
- callback has the unfortunate effect of preventing all cameras that
- connect to a notifier from working if any one of their drivers fails
- to probe. Moving the functionality from .complete() to .bound() allows
- those camera sensor drivers that did probe correctly to work regardless.
- Signed-off-by: Daniel Scally <djrscally@gmail.com>
- Patchset: cameras
- ---
- drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 65 +++++++------------
- 1 file changed, 23 insertions(+), 42 deletions(-)
- diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
- index 1bbe58b24d99..159f0d6cab8f 100644
- --- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
- +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
- @@ -1383,7 +1383,10 @@ static int cio2_notifier_bound(struct v4l2_async_notifier *notifier,
- {
- struct cio2_device *cio2 = to_cio2_device(notifier);
- struct sensor_async_subdev *s_asd = to_sensor_asd(asd);
- + struct device *dev = &cio2->pci_dev->dev;
- struct cio2_queue *q;
- + unsigned int pad;
- + int ret;
-
- if (cio2->queue[s_asd->csi2.port].sensor)
- return -EBUSY;
- @@ -1394,7 +1397,26 @@ static int cio2_notifier_bound(struct v4l2_async_notifier *notifier,
- q->sensor = sd;
- q->csi_rx_base = cio2->base + CIO2_REG_PIPE_BASE(q->csi2.port);
-
- - return 0;
- + for (pad = 0; pad < q->sensor->entity.num_pads; pad++)
- + if (q->sensor->entity.pads[pad].flags &
- + MEDIA_PAD_FL_SOURCE)
- + break;
- +
- + if (pad == q->sensor->entity.num_pads) {
- + dev_err(dev, "failed to find src pad for %s\n",
- + q->sensor->name);
- + return -ENXIO;
- + }
- +
- + ret = media_create_pad_link(&q->sensor->entity, pad, &q->subdev.entity,
- + CIO2_PAD_SINK, 0);
- + if (ret) {
- + dev_err(dev, "failed to create link for %s\n",
- + q->sensor->name);
- + return ret;
- + }
- +
- + return v4l2_device_register_subdev_nodes(&cio2->v4l2_dev);
- }
-
- /* The .unbind callback */
- @@ -1408,50 +1430,9 @@ static void cio2_notifier_unbind(struct v4l2_async_notifier *notifier,
- cio2->queue[s_asd->csi2.port].sensor = NULL;
- }
-
- -/* .complete() is called after all subdevices have been located */
- -static int cio2_notifier_complete(struct v4l2_async_notifier *notifier)
- -{
- - struct cio2_device *cio2 = to_cio2_device(notifier);
- - struct device *dev = &cio2->pci_dev->dev;
- - struct sensor_async_subdev *s_asd;
- - struct v4l2_async_subdev *asd;
- - struct cio2_queue *q;
- - unsigned int pad;
- - int ret;
- -
- - list_for_each_entry(asd, &cio2->notifier.asd_list, asd_list) {
- - s_asd = to_sensor_asd(asd);
- - q = &cio2->queue[s_asd->csi2.port];
- -
- - for (pad = 0; pad < q->sensor->entity.num_pads; pad++)
- - if (q->sensor->entity.pads[pad].flags &
- - MEDIA_PAD_FL_SOURCE)
- - break;
- -
- - if (pad == q->sensor->entity.num_pads) {
- - dev_err(dev, "failed to find src pad for %s\n",
- - q->sensor->name);
- - return -ENXIO;
- - }
- -
- - ret = media_create_pad_link(
- - &q->sensor->entity, pad,
- - &q->subdev.entity, CIO2_PAD_SINK,
- - 0);
- - if (ret) {
- - dev_err(dev, "failed to create link for %s\n",
- - q->sensor->name);
- - return ret;
- - }
- - }
- -
- - return v4l2_device_register_subdev_nodes(&cio2->v4l2_dev);
- -}
- -
- static const struct v4l2_async_notifier_operations cio2_async_ops = {
- .bound = cio2_notifier_bound,
- .unbind = cio2_notifier_unbind,
- - .complete = cio2_notifier_complete,
- };
-
- static int cio2_parse_firmware(struct cio2_device *cio2)
- --
- 2.42.0
- From 95c34d5d2613b851abbeb9803112090f979b6b55 Mon Sep 17 00:00:00 2001
- From: Daniel Scally <djrscally@gmail.com>
- Date: Thu, 2 Jun 2022 22:15:56 +0100
- Subject: [PATCH] media: ipu3-cio2: Re-add .complete() to ipu3-cio2
- Removing the .complete() callback had some unintended consequences.
- Because the VCM driver is not directly linked to the ipu3-cio2
- driver .bound() never gets called for it, which means its devnode
- is never created if it probes late. Because .complete() waits for
- any sub-notifiers to also be complete it is captured in that call.
- Signed-off-by: Daniel Scally <djrscally@gmail.com>
- Patchset: cameras
- ---
- drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 9 +++++++++
- 1 file changed, 9 insertions(+)
- diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
- index 159f0d6cab8f..0b2abfa0c724 100644
- --- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
- +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
- @@ -1430,9 +1430,18 @@ static void cio2_notifier_unbind(struct v4l2_async_notifier *notifier,
- cio2->queue[s_asd->csi2.port].sensor = NULL;
- }
-
- +/* .complete() is called after all subdevices have been located */
- +static int cio2_notifier_complete(struct v4l2_async_notifier *notifier)
- +{
- + struct cio2_device *cio2 = to_cio2_device(notifier);
- +
- + return v4l2_device_register_subdev_nodes(&cio2->v4l2_dev);
- +}
- +
- static const struct v4l2_async_notifier_operations cio2_async_ops = {
- .bound = cio2_notifier_bound,
- .unbind = cio2_notifier_unbind,
- + .complete = cio2_notifier_complete,
- };
-
- static int cio2_parse_firmware(struct cio2_device *cio2)
- --
- 2.42.0
- From bac0ebe98ba2cf810d2c4d988ac088e3a32a0c78 Mon Sep 17 00:00:00 2001
- From: Maximilian Luz <luzmaximilian@gmail.com>
- Date: Fri, 15 Jul 2022 23:48:00 +0200
- Subject: [PATCH] drivers/media/i2c: Fix DW9719 dependencies
- It should depend on VIDEO_DEV instead of VIDEO_V4L2.
- Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
- Patchset: cameras
- ---
- drivers/media/i2c/Kconfig | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
- diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
- index fbaa2ce7fa3e..7a46ad85dbd4 100644
- --- a/drivers/media/i2c/Kconfig
- +++ b/drivers/media/i2c/Kconfig
- @@ -830,7 +830,7 @@ config VIDEO_DW9714
-
- config VIDEO_DW9719
- tristate "DW9719 lens voice coil support"
- - depends on I2C && VIDEO_V4L2
- + depends on I2C && VIDEO_DEV
- select MEDIA_CONTROLLER
- select VIDEO_V4L2_SUBDEV_API
- select V4L2_ASYNC
- --
- 2.42.0
- From 46dc23e063ec36df32e808356b0de9ffc8a437b1 Mon Sep 17 00:00:00 2001
- From: Daniel Scally <dan.scally@ideasonboard.com>
- Date: Thu, 2 Mar 2023 12:59:39 +0000
- Subject: [PATCH] platform/x86: int3472: Remap reset GPIO for INT347E
- ACPI _HID INT347E represents the OmniVision 7251 camera sensor. The
- driver for this sensor expects a single pin named "enable", but on
- some Microsoft Surface platforms the sensor is assigned a single
- GPIO who's type flag is INT3472_GPIO_TYPE_RESET.
- Remap the GPIO pin's function from "reset" to "enable". This is done
- outside of the existing remap table since it is a more widespread
- discrepancy than that method is designed for. Additionally swap the
- polarity of the pin to match the driver's expectation.
- Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
- Patchset: cameras
- ---
- drivers/platform/x86/intel/int3472/discrete.c | 14 ++++++++++++++
- 1 file changed, 14 insertions(+)
- diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
- index c42c3faa2c32..6f4b8e24eb56 100644
- --- a/drivers/platform/x86/intel/int3472/discrete.c
- +++ b/drivers/platform/x86/intel/int3472/discrete.c
- @@ -108,6 +108,9 @@ static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int347
- {
- const struct int3472_sensor_config *sensor_config;
- char *path = agpio->resource_source.string_ptr;
- + const struct acpi_device_id ov7251_ids[] = {
- + { "INT347E" },
- + };
- struct gpiod_lookup *table_entry;
- struct acpi_device *adev;
- acpi_handle handle;
- @@ -130,6 +133,17 @@ static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int347
- }
- }
-
- + /*
- + * In addition to the function remap table we need to bulk remap the
- + * "reset" GPIO for the OmniVision 7251 sensor, as the driver for that
- + * expects its only GPIO pin to be called "enable" (and to have the
- + * opposite polarity).
- + */
- + if (!strcmp(func, "reset") && !acpi_match_device_ids(int3472->sensor, ov7251_ids)) {
- + func = "enable";
- + polarity = GPIO_ACTIVE_HIGH;
- + }
- +
- /* Functions mapped to NULL should not be mapped to the sensor */
- if (!func)
- return 0;
- --
- 2.42.0
|