Skip to contentSkip to conversation

platform/x86: Add Intel ISP dummy driver

PATCH Superseded Hans de Goede 2 participants 3 messages Aug 29, 2018 – Oct 14, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: Add Intel ISP dummy driver

The Image Signal Processor found on Cherry Trail devices is brought up in D0 state on devices which have camera sensors attached to it. The ISP will not enter D3 state again without some massaging of its registers beforehand and the ISP not being in D3 state blocks the SoC from entering S0ix modes.

There was a driver for the ISP in drivers/staging but that got removed again because it never worked. It does not seem likely that a real driver for the ISP will be added to the mainline kernel anytime soon.

This commit adds a dummy driver which contains the necessary magic from the staging driver to powerdown the ISP, so that Cherry Trail devices where the ISP is used will properly use S0ix modes when suspended.

Together with other recent S0ix related fixes this allows S0ix modes to be entered on e.g. a Chuwi Hi8 Pro and a HP x2 210.

---
 MAINTAINERS                            |   6 ++
 drivers/platform/x86/Kconfig           |  12 +++
 drivers/platform/x86/Makefile          |   1 +
 drivers/platform/x86/intel_isp_dummy.c | 119 +++++++++++++++++++++++++
 4 files changed, 138 insertions(+)
 create mode 100644 drivers/platform/x86/intel_isp_dummy.c
MAINTAINERS +6 -0
index dbe7836e4f6b..ae654c69300a 100644
@@ -7258,6 +7258,12 @@ S:	Maintained
 F:	drivers/media/pci/intel/ipu3/
 F:	Documentation/media/uapi/v4l/pixfmt-srggb10-ipu3.rst
 
+INTEL ISP DUMMY DRIVER
+M:	Hans de Goede <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/platform/x86/intel_isp_dummy.c
+
 INTEL IXP4XX QMGR, NPE, ETHERNET and HSS SUPPORT
 M:	Krzysztof Halasa <[email protected]>
 S:	Maintained
drivers/platform/x86/Kconfig +12 -0
index 64c82592d4b6..0ba6fac1d0c9 100644
@@ -1230,6 +1230,18 @@ config I2C_MULTI_INSTANTIATE
 	  To compile this driver as a module, choose M here: the module
 	  will be called i2c-multi-instantiate.
 
+config INTEL_ISP_DUMMY
+	tristate "Intel ISP dummy driver"
+	depends on PCI && IOSF_MBI && PM
+	help
+	  Dummy driver for Intel's Image Signal Processor found on Bay and
+	  Cherry Trail devices. The sole purpose of this driver is to turn
+	  the ISP off (put it in D3) to save power and to allow entering of
+	  S0ix modes.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called intel_isp_dummy.
+
 endif # X86_PLATFORM_DEVICES
 
 config PMC_ATOM
drivers/platform/x86/Makefile +1 -0
index e6d1becf81ce..df854a630a83 100644
@@ -92,3 +92,4 @@ obj-$(CONFIG_MLX_PLATFORM)	+= mlx-platform.o
 obj-$(CONFIG_INTEL_TURBO_MAX_3) += intel_turbo_max_3.o
 obj-$(CONFIG_INTEL_CHTDC_TI_PWRBTN)	+= intel_chtdc_ti_pwrbtn.o
 obj-$(CONFIG_I2C_MULTI_INSTANTIATE)	+= i2c-multi-instantiate.o
+obj-$(CONFIG_INTEL_ISP_DUMMY)	+= intel_isp_dummy.o
drivers/platform/x86/intel_isp_dummy.c new file +119 -0

119 lines not on this page · raw message

Signature · 1 line
2.19.0.rc0
#1 lore raw
Quoted 9 lines · Hans de Goede

The Image Signal Processor found on Cherry Trail devices is brought up in D0 state on devices which have camera sensors attached to it. The ISP will not enter D3 state again without some massaging of its registers beforehand and the ISP not being in D3 state blocks the SoC from entering S0ix modes.

There was a driver for the ISP in drivers/staging but that got removed again because it never worked. It does not seem likely that a real driver for the ISP will be added to the mainline kernel anytime soon.

Quoted 7 lines

This commit adds a dummy driver which contains the necessary magic from the staging driver to powerdown the ISP, so that Cherry Trail devices where the ISP is used will properly use S0ix modes when suspended.

Together with other recent S0ix related fixes this allows S0ix modes to be entered on e.g. a Chuwi Hi8 Pro and a HP x2 210.

Thanks for the patch, my comments below.

Quoted 1 line
 drivers/platform/x86/intel_isp_dummy.c | 119 +++++++++++++++++++++++++

First of all, I would like to see that this is about pm and pm only, so, perhaps

intel_isp_pm ?

OTOH, it would be nice to have less confusing of what ISP we are talking about, so,

intel_atomisp2_pm ?

drivers/platform/x86/Kconfig config I2C_MULTI_INSTANTIATE

Quoted 4 lines
drivers/platform/x86/Kconfig +3 -0
+config INTEL_ISP_DUMMY
+	tristate "Intel ISP dummy driver"
 
+	depends on PCI && IOSF_MBI && PM

If someone decides to port this to kernels where ATOMISP driver is still available, it might be a conflict here. I dunno if it's a good idea to put something like depends !ATOMISP here taking into consideration that it would be staled option.

drivers/platform/x86/intel_isp_dummy.c line 62

Quoted 1 line
drivers/platform/x86/intel_isp_dummy.c new file +1 -0
+	while (1) {

A nit: I would rather put it like

do {
...
} while (time_after(...));

Quoted 12 lines
drivers/platform/x86/intel_isp_dummy.c new file +12 -0
+		/* Wait until ISPSSPM0 bit[25:24] shows 0x3 */
+		iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, ISPSSPM0, &val);
+		val = (val & ISPSSPM0_ISPSSS_MASK) >> ISPSSPM0_ISPSSS_OFFSET;
+		if (val == ISPSSPM0_IUNIT_POWER_OFF)
+			break;
+
+		if (time_after(jiffies, timeout)) {
+			dev_err(&dev->dev, "IUNIT power-off timeout.\n");
+			return -EBUSY;
+		}
+		usleep_range(1000, 2000);
+	}
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw

Hi,

Quoted 14 lines · Andy Shevchenko
Quoted 13 lines · Hans de Goede

The Image Signal Processor found on Cherry Trail devices is brought up in D0 state on devices which have camera sensors attached to it. The ISP will not enter D3 state again without some massaging of its registers beforehand and the ISP not being in D3 state blocks the SoC from entering S0ix modes.

There was a driver for the ISP in drivers/staging but that got removed again because it never worked. It does not seem likely that a real driver for the ISP will be added to the mainline kernel anytime soon.

This commit adds a dummy driver which contains the necessary magic from the staging driver to powerdown the ISP, so that Cherry Trail devices where the ISP is used will properly use S0ix modes when suspended.

Quoted 5 lines
Quoted 3 lines

Together with other recent S0ix related fixes this allows S0ix modes to be entered on e.g. a Chuwi Hi8 Pro and a HP x2 210.

Thanks for the patch, my comments below.

Thank you for the review and sorry for being a bit slow with responding I've been quite busy with other stuff.

Quoted 11 lines
Quoted 1 line
  drivers/platform/x86/intel_isp_dummy.c | 119 +++++++++++++++++++++++++

First of all, I would like to see that this is about pm and pm only, so, perhaps

intel_isp_pm ?

OTOH, it would be nice to have less confusing of what ISP we are talking about, so,

intel_atomisp2_pm ?

Works for me, intel_atomisp2_pm it is for v2 of this patch.

Quoted 9 lines

drivers/platform/x86/Kconfig config I2C_MULTI_INSTANTIATE

Quoted 4 lines
drivers/platform/x86/Kconfig +3 -0
+config INTEL_ISP_DUMMY
+	tristate "Intel ISP dummy driver"
 
+	depends on PCI && IOSF_MBI && PM

If someone decides to port this to kernels where ATOMISP driver is still available, it might be a conflict here. I dunno if it's a good idea to put something like depends !ATOMISP here taking into consideration that it would be staled option.

I don't look adding deps / conflucts on options which are not present upstream, so I'm going to keep this as for v2.

Quoted 8 lines

drivers/platform/x86/intel_isp_dummy.c line 62

Quoted 2 lines
drivers/platform/x86/intel_isp_dummy.c new file +1 -0
+	while (1) {

A nit: I would rather put it like

do {
...
} while (time_after(...));

That would need to be time_before then, since the time check is a timeout and then I would need to re-check the time outside the loop to see if a timeout happened. So I believe it would better to keep this as is.

Quoted 4 lines
Quoted 4 lines
drivers/platform/x86/intel_isp_dummy.c new file +4 -0
+		/* Wait until ISPSSPM0 bit[25:24] shows 0x3 */
+		iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, ISPSSPM0, &val);
+		val = (val & ISPSSPM0_ISPSSS_MASK) >> ISPSSPM0_ISPSSS_OFFSET;
+		if (val == ISPSSPM0_IUNIT_POWER_OFF)
Quoted 9 lines

drivers/platform/x86/intel_isp_dummy.c line 74

Quoted 8 lines
drivers/platform/x86/intel_isp_dummy.c new file +8 -0
+			break;
+
+		if (time_after(jiffies, timeout)) {
+			dev_err(&dev->dev, "IUNIT power-off timeout.\n");
+			return -EBUSY;
+		}
+		usleep_range(1000, 2000);
+	}

Regards,

Hans