Skip to contentSkip to conversation

media: atomisp: Clean ups and fixes to make it load on Baytrail

PATCH In review Andy Shevchenko 2 participants 19 messages Jun 26, 2020 – Jun 29, 2020

Subsystems (5)
lore
Share & tools
lore
#1 lore raw

PATCH v2 1/15 media: atomisp: Replace last use of Intel MID APIs

In reply to Andy Shevchenko

Intel MID special header is not in use in this driver. Replace it with a better macro for now on.

---
 .../staging/media/atomisp/include/linux/atomisp_platform.h   | 1 +
 drivers/staging/media/atomisp/pci/atomisp_compat_css20.c     | 5 +----
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/staging/media/atomisp/include/linux/atomisp_platform.h +1 -0
index 873344a02ccf..5a5121d958ed 100644
@@ -250,6 +250,7 @@ const struct atomisp_camera_caps *atomisp_get_default_camera_caps(void);
 #define IS_MFLD	__IS_SOC(INTEL_FAM6_ATOM_SALTWELL_MID)
 #define IS_BYT	__IS_SOC(INTEL_FAM6_ATOM_SILVERMONT)
 #define IS_CHT	__IS_SOC(INTEL_FAM6_ATOM_AIRMONT)
+#define IS_MRFD	__IS_SOC(INTEL_FAM6_ATOM_SILVERMONT_MID)
 #define IS_MOFD	__IS_SOC(INTEL_FAM6_ATOM_AIRMONT_MID)
 
 /* Both CHT and MOFD come with ISP2401 */
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +1 -4
index c1e282a974d0..df352be06474 100644
@@ -33,8 +33,6 @@
 #include "atomisp_ioctl.h"
 #include "atomisp_acc.h"
 
-#include <asm/intel-mid.h>
-
 #include "ia_css_debug.h"
 #include "ia_css_isp_param.h"
 #include "sh_css_hrt.h"
@@ -1966,8 +1964,7 @@ void atomisp_css_input_set_mode(struct atomisp_sub_device *asd,
 			true,
 			0x13000,
 			&size_mem_words) != 0) {
-			if (intel_mid_identify_cpu() ==
-			    INTEL_MID_CPU_CHIP_TANGIER)
+			if (IS_MRFD)
 				size_mem_words = CSS_MIPI_FRAME_BUFFER_SIZE_2;
 			else
 				size_mem_words = CSS_MIPI_FRAME_BUFFER_SIZE_1;
Signature · 1 line
2.27.0
#4 lore raw

PATCH v2 4/15 media: atomisp: don't pass struct device_driver as parameter

In reply to Andy Shevchenko

There is no need to pass a pointer to struct device_driver when we have an access to struct device already.

---
 drivers/staging/media/atomisp/pci/atomisp_drvfs.c | 3 ++-
 drivers/staging/media/atomisp/pci/atomisp_drvfs.h | 2 +-
 drivers/staging/media/atomisp/pci/atomisp_v4l2.c  | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_drvfs.c +2 -1
index fe0e2bfde27f..3711df111fbf 100644
@@ -185,8 +185,9 @@ static void iunit_drvfs_remove_files(struct device_driver *drv)
 		driver_remove_file(drv, &iunit_drvfs_attrs[i]);
 }
 
-int atomisp_drvfs_init(struct device_driver *drv, struct atomisp_device *isp)
+int atomisp_drvfs_init(struct atomisp_device *isp)
 {
+	struct device_driver *drv = isp->dev->driver;
 	int ret;
 
 	iunit_debug.isp = isp;
drivers/staging/media/atomisp/pci/atomisp_drvfs.h +1 -1
index 4911037231fb..8f4cc722b881 100644
@@ -19,7 +19,7 @@
 #ifndef	__ATOMISP_DRVFS_H__
 #define	__ATOMISP_DRVFS_H__
 
-int atomisp_drvfs_init(struct device_driver *drv, struct atomisp_device *isp);
+int atomisp_drvfs_init(struct atomisp_device *isp);
 void atomisp_drvfs_exit(void);
 
 #endif /* __ATOMISP_DRVFS_H__ */
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +1 -1
index fa07cbaf0422..c6996b1f228b 100644
@@ -1838,7 +1838,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
 	isp->firmware = NULL;
 	isp->css_env.isp_css_fw.data = NULL;
 
-	atomisp_drvfs_init(&dev->driver->driver, isp);
+	atomisp_drvfs_init(isp);
 
 	return 0;
 
Signature · 1 line
2.27.0
#3 lore raw

PATCH v2 3/15 media: atomisp: Use proper APIs to find I²C client device by ACPI HID

In reply to Andy Shevchenko

There are specific ACPI and I²C APIs to match device by different parameters, such as ACPI HID, and retrieve an I²C client. Use them instead of home grown approach. Note, it fixes a resource leak as well.

---
 .../media/atomisp/pci/atomisp_gmin_platform.c | 43 ++++++++-----------
 1 file changed, 18 insertions(+), 25 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +18 -25
index 1af9da8acf4c..8acceae189a2 100644
@@ -90,9 +90,9 @@ struct gmin_subdev {
 static struct gmin_subdev gmin_subdevs[MAX_SUBDEVS];
 
 /* ACPI HIDs for the PMICs that could be used by this driver */
-#define PMIC_ACPI_AXP		"INT33F4:00"	/* XPower AXP288 PMIC */
-#define PMIC_ACPI_TI		"INT33F5:00"	/* Dollar Cove TI PMIC */
-#define PMIC_ACPI_CRYSTALCOVE	"INT33FD:00"	/* Crystal Cove PMIC */
+#define PMIC_ACPI_AXP		"INT33F4"	/* XPower AXP288 PMIC */
+#define PMIC_ACPI_TI		"INT33F5"	/* Dollar Cove TI PMIC */
+#define PMIC_ACPI_CRYSTALCOVE	"INT33FD"	/* Crystal Cove PMIC */
 
 #define PMIC_PLATFORM_TI	"intel_soc_pmic_chtdc_ti"
 
@@ -381,34 +381,27 @@ static const guid_t atomisp_dsm_guid = GUID_INIT(0xdc2f6c4f, 0x045b, 0x4f1d,
 #define GMIN_PMC_CLK_NAME 14 /* "pmc_plt_clk_[0..5]" */
 static char gmin_pmc_clk_name[GMIN_PMC_CLK_NAME];
 
-static int gmin_i2c_match_one(struct device *dev, const void *data)
-{
-	const char *name = data;
-	struct i2c_client *client;
-
-	if (dev->type != &i2c_client_type)
-		return 0;
-
-	client = to_i2c_client(dev);
-
-	return (!strcmp(name, client->name));
-}
-
 static struct i2c_client *gmin_i2c_dev_exists(struct device *dev, char *name,
 					      struct i2c_client **client)
 {
+	struct acpi_device *adev;
 	struct device *d;
 
-	while ((d = bus_find_device(&i2c_bus_type, NULL, name,
-				    gmin_i2c_match_one))) {
-		*client = to_i2c_client(d);
-		dev_dbg(dev, "found '%s' at address 0x%02x, adapter %d\n",
-			(*client)->name, (*client)->addr,
-			(*client)->adapter->nr);
-		return *client;
-	}
+	adev = acpi_dev_get_first_match_dev(name, NULL, -1);
+	if (!adev)
+		return NULL;
 
-	return NULL;
+	d = bus_find_device_by_acpi_dev(&i2c_bus_type, adev);
+	acpi_dev_put(adev);
+	if (!d)
+		return NULL;
+
+	*client = i2c_verify_client(d);
+	put_device(d);
+
+	dev_dbg(dev, "found '%s' at address 0x%02x, adapter %d\n",
+		(*client)->name, (*client)->addr, (*client)->adapter->nr);
+	return *client;
 }
 
 static int gmin_i2c_write(struct device *dev, u16 i2c_addr, u8 reg,
Signature · 1 line
2.27.0
#0 lore raw

v2 cover media: atomisp: Clean ups and fixes to make it load on Baytrail

I'm experimenting with it on Baytrail machine and found some issues. Along with fixing them I cleaned up a bit this.

So, after applying I have the following log

# modprobe atomisp
[  116.215056] atomisp: module is from the staging directory, the quality is unknown, you have been warned.
[  116.310077] atomisp-isp2 0000:00:03.0: Detected Baytrail version 15 (ISP2400) on VALLEYVIEW C0 (CR) PLATFORM
[  116.354189] atomisp-isp2 0000:00:03.0: start: 0x50000000
[  116.376888] atomisp-isp2 0000:00:03.0: atomisp mmio base: 0000000027f9eb1f
[  116.401267] ACPI: \: failed to evaluate _DSM (0x1001)
[  116.423479] atomisp-isp2 0000:00:03.0: Failed to find EFI variable 0000:00:03.0_HpllFreq
[  116.449254] atomisp-isp2 0000:00:03.0: HpllFreq: using default (2000)
[  116.473045] atomisp-isp2 0000:00:03.0: ISP HPLL frequency base = 2000 MHz
[  116.770613] atomisp-isp2 0000:00:03.0: Probing Subdev INT33F8:00
[  116.793750] atomisp-isp2 0000:00:03.0: Subdev INT33F8:00 successfully register
[  116.818155] atomisp-isp2 0000:00:03.0: raw_index: -1
[  116.839924] atomisp-isp2 0000:00:03.0: SOC_INDEX: 0
[  116.861622] atomisp-isp2 0000:00:03.0: Probing Subdev INTCF1C:00
[  116.896885] lm3554 i2c-INTCF1C:00: Failed to power on lm3554 LED flash
[  116.920236] atomisp-isp2 0000:00:03.0: Subdev INTCF1C:00 detection fail
[  116.943649] atomisp-isp2 0000:00:03.0: detected 1 camera sensors
[  116.966177] atomisp-isp2 0000:00:03.0: atomisp_csi_lane_config: the portconfig is 2-1-0, CSI_CONTROL is 0x0002009C
[  117.009054] atomisp-isp2 0000:00:03.0: Entity type for entity ATOM ISP CSI2-port0 was not initialized!
[  117.050772] atomisp-isp2 0000:00:03.0: Entity type for entity ATOM ISP CSI2-port1 was not initialized!
[  117.050795] atomisp-isp2 0000:00:03.0: Entity type for entity ATOM ISP CSI2-port2 was not initialized!
[  117.134464] atomisp-isp2 0000:00:03.0: Entity type for entity file_input_subdev was not initialized!
[  117.176572] atomisp-isp2 0000:00:03.0: Entity type for entity tpg_subdev was not initialized!
[  117.202301] atomisp-isp2 0000:00:03.0: Entity type for entity ATOMISP_SUBDEV_0 was not initialized!
[  117.246734] atomisp-isp2 0000:00:03.0: Entity type for entity ATOMISP_SUBDEV_1 was not initialized!
[  117.290990] atomisp-isp2 0000:00:03.0: FILE_INPUT enable, camera_cnt: 1
[  117.314607] atomisp-isp2 0000:00:03.0: TPG detected, camera_cnt: 2
[  117.341386] atomisp-isp2 0000:00:03.0: atomisp_save_iunit_reg
[  117.363735] atomisp-isp2 0000:00:03.0: DFS target frequency=200.
[  117.386272] atomisp-isp2 0000:00:03.0: Programming DFS frequency to 200
[  117.409426] atomisp-isp2 0000:00:03.0: waiting for ISPSSPM1 valid bit to be 0.
[  117.433323] atomisp-isp2 0000:00:03.0: waiting for ISPSSPM1 valid bit to be 0.
[  117.457139] atomisp-isp2 0000:00:03.0: atomisp_ospm_dphy_down
[  117.479800] atomisp-isp2 0000:00:03.0: binary #0  type SP: sp
[  117.502001] atomisp-isp2 0000:00:03.0: binary #1  type ISP (Normal), binary id is  0: isp_copy_var
[  117.542907] atomisp-isp2 0000:00:03.0: binary #2  type ISP (Normal), binary id is  2: isp_vf_pp_full
[  117.584666] atomisp-isp2 0000:00:03.0: binary #3  type ISP (Normal), binary id is  3: isp_vf_pp_opt
[  117.626806] atomisp-isp2 0000:00:03.0: binary #4  type ISP (Normal), binary id is 60: isp_capture_pp_var_bli
[  117.670360] atomisp-isp2 0000:00:03.0: binary #5  type ISP (Normal), binary id is 61: isp_capture_pp_ldc
[  117.713655] atomisp-isp2 0000:00:03.0: binary #6  type ISP (Normal), binary id is  5: isp_capture_pp_var
[  117.757345] atomisp-isp2 0000:00:03.0: binary #7  type ISP (Normal), binary id is  4: isp_yuv_scale_var
[  117.801371] atomisp-isp2 0000:00:03.0: binary #8  type ISP (Normal), binary id is  6: isp_preisp_var
[  117.845621] atomisp-isp2 0000:00:03.0: binary #9  type ISP (Normal), binary id is  7: isp_preisp_var_isp2
[  117.890913] atomisp-isp2 0000:00:03.0: binary #10 type ISP (Normal), binary id is 58: isp_pre_de_var_isp2
[  117.936321] atomisp-isp2 0000:00:03.0: binary #11 type ISP (Normal), binary id is  8: isp_gdc_var
[  117.963840] atomisp-isp2 0000:00:03.0: binary #12 type ISP (Normal), binary id is 11: isp_anr_var
[  117.991190] atomisp-isp2 0000:00:03.0: binary #13 type ISP (Normal), binary id is 12: isp_anr_var_isp2
[  118.035988] atomisp-isp2 0000:00:03.0: binary #14 type ISP (Normal), binary id is  9: isp_postisp_var
[  118.081148] atomisp-isp2 0000:00:03.0: binary #15 type ISP (Normal), binary id is 10: isp_postisp_var_isp2
[  118.127374] atomisp-isp2 0000:00:03.0: binary #16 type ISP (Normal), binary id is 15: isp_preview_dec
[  118.173707] atomisp-isp2 0000:00:03.0: binary #17 type ISP (Normal), binary id is 16: isp_preview_cont_bds125_isp2
[  118.221920] atomisp-isp2 0000:00:03.0: binary #18 type ISP (Normal), binary id is 18: isp_preview_cont_bds150_isp2
[  118.270412] atomisp-isp2 0000:00:03.0: binary #19 type ISP (Normal), binary id is 20: isp_preview_cont_bds200_isp2
[  118.318942] atomisp-isp2 0000:00:03.0: binary #20 type ISP (Normal), binary id is 21: isp_preview_var
[  118.366572] atomisp-isp2 0000:00:03.0: binary #21 type ISP (Normal), binary id is 22: isp_preview_var_isp2
[  118.415086] atomisp-isp2 0000:00:03.0: binary #22 type ISP (Normal), binary id is 27: isp_primary_striped
[  118.464002] atomisp-isp2 0000:00:03.0: binary #23 type ISP (Normal), binary id is 28: isp_primary_striped_isp2
[  118.514097] atomisp-isp2 0000:00:03.0: binary #24 type ISP (Normal), binary id is 24: isp_primary_var
[  118.564053] atomisp-isp2 0000:00:03.0: binary #25 type ISP (Normal), binary id is 25: isp_primary_var_isp2
[  118.615276] atomisp-isp2 0000:00:03.0: binary #26 type ISP (Normal), binary id is 26: isp_primary_small
[  118.666737] atomisp-isp2 0000:00:03.0: binary #27 type ISP (Normal), binary id is 29: isp_primary_8mp
[  118.718346] atomisp-isp2 0000:00:03.0: binary #28 type ISP (Normal), binary id is 30: isp_primary_14mp
[  118.770053] atomisp-isp2 0000:00:03.0: binary #29 type ISP (Normal), binary id is 31: isp_primary_16mp
[  118.821763] atomisp-isp2 0000:00:03.0: binary #30 type ISP (Normal), binary id is 33: isp_primary_isp261_stage0
[  118.874370] atomisp-isp2 0000:00:03.0: binary #31 type ISP (Normal), binary id is 34: isp_primary_isp261_stage1
[  118.926992] atomisp-isp2 0000:00:03.0: binary #32 type ISP (Normal), binary id is 35: isp_primary_isp261_stage2
[  118.979792] atomisp-isp2 0000:00:03.0: binary #33 type ISP (Normal), binary id is 36: isp_primary_isp261_stage3
[  119.032714] atomisp-isp2 0000:00:03.0: binary #34 type ISP (Normal), binary id is 37: isp_primary_isp261_stage4
[  119.085749] atomisp-isp2 0000:00:03.0: binary #35 type ISP (Normal), binary id is 38: isp_primary_isp261_stage5
[  119.139422] atomisp-isp2 0000:00:03.0: binary #36 type ISP (Normal), binary id is 42: isp_video_dz
[  119.192607] atomisp-isp2 0000:00:03.0: binary #37 type ISP (Normal), binary id is 44: isp_video_high
[  119.246768] atomisp-isp2 0000:00:03.0: binary #38 type ISP (Normal), binary id is 45: isp_video_nodz
[  119.301793] atomisp-isp2 0000:00:03.0: binary #39 type ISP (Normal), binary id is 46: isp_video_cont_multibds_isp2_min
[  119.359159] atomisp-isp2 0000:00:03.0: binary #40 type ISP (Normal), binary id is 47: isp_video_cont_bds_300_600_isp2_min
[  119.416880] atomisp-isp2 0000:00:03.0: binary #41 type ISP (Normal), binary id is 49: isp_video_cont_bds150_isp2_min
[  119.474102] atomisp-isp2 0000:00:03.0: binary #42 type ISP (Normal), binary id is 51: isp_video_cont_bds200_isp2_min
[  119.531365] atomisp-isp2 0000:00:03.0: binary #43 type ISP (Normal), binary id is 52: isp_video_cont_nobds_isp2_min
[  119.588595] atomisp-isp2 0000:00:03.0: binary #44 type ISP (Normal), binary id is 53: isp_video_dz_isp2_min
[  119.644981] atomisp-isp2 0000:00:03.0: binary #45 type ISP (Normal), binary id is 54: isp_video_dz_isp2
[  119.701015] atomisp-isp2 0000:00:03.0: binary #46 type ISP (Normal), binary id is 55: isp_video_lp_isp2

Andy Shevchenko (15):
media: atomisp: Replace last use of Intel MID APIs
media: atomisp: move CCK endpoint address to generic header
media: atomisp: Use proper APIs to find I²C client device by ACPI HID
media: atomisp: don't pass struct device_driver as parameter
media: atomisp: Get rid of struct pci_dev in struct atomisp_device
media: atomisp: Unify pdev to be pointer to struct pci_device
media: atomisp: Replace direct access to MMIO with proper helpers
media: atomisp: Drop global atomisp_dev variable (easy cases)
media: atomisp: make platform data more readable
media: atomisp: Don't try to parse unexpected ACPI object type
media: atomisp: Make pointer to PMIC client global
media: atomisp: Refactor PMIC detection to a separate function.
media: atomisp: Provide Gmin subdev as parameter to gmin_subdev_add()
media: atomisp: Get rid of ugly and leaky ACPI handling in
gmin_subdev_add()
media: atomisp: Deduplicate return ret in gmin_i2c_write()

 arch/x86/include/asm/iosf_mbi.h               |   1 +
 .../atomisp/include/linux/atomisp_platform.h  |   1 +
 .../staging/media/atomisp/pci/atomisp-regs.h  |   3 -
 .../staging/media/atomisp/pci/atomisp_acc.c   |   4 +-
 .../staging/media/atomisp/pci/atomisp_cmd.c   |  57 ++--
 .../staging/media/atomisp/pci/atomisp_cmd.h   |   4 +-
 .../media/atomisp/pci/atomisp_compat.h        |   2 -
 .../media/atomisp/pci/atomisp_compat_css20.c  |  64 ++--
 .../media/atomisp/pci/atomisp_compat_css20.h  |   2 +-
 .../staging/media/atomisp/pci/atomisp_drvfs.c |  14 +-
 .../staging/media/atomisp/pci/atomisp_drvfs.h |   2 +-
 .../media/atomisp/pci/atomisp_gmin_platform.c | 220 +++++++-------
 .../media/atomisp/pci/atomisp_internal.h      |   2 +-
 .../staging/media/atomisp/pci/atomisp_ioctl.c |  19 +-
 .../staging/media/atomisp/pci/atomisp_v4l2.c  | 277 ++++++++----------
 15 files changed, 311 insertions(+), 361 deletions(-)
Signature · 1 line
2.27.0
#9 lore raw

PATCH v2 9/15 media: atomisp: make platform data more readable

Add few blank lines to make platform data more readable.

---
 drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +3 -0
index 79cbde65d3c1..fb61274af7e5 100644
@@ -294,6 +294,7 @@ static struct gmin_cfg_var mrd7_vars[] = {
 	{"INT33F8:00_CsiFmt", "13"},
 	{"INT33F8:00_CsiBayer", "0"},
 	{"INT33F8:00_CamClk", "0"},
+
 	{"INT33F9:00_CamType", "1"},
 	{"INT33F9:00_CsiPort", "0"},
 	{"INT33F9:00_CsiLanes", "1"},
@@ -309,6 +310,7 @@ static struct gmin_cfg_var ecs7_vars[] = {
 	{"INT33BE:00_CsiFmt", "13"},
 	{"INT33BE:00_CsiBayer", "2"},
 	{"INT33BE:00_CamClk", "0"},
+
 	{"INT33F0:00_CsiPort", "0"},
 	{"INT33F0:00_CsiLanes", "1"},
 	{"INT33F0:00_CsiFmt", "13"},
@@ -322,6 +324,7 @@ static struct gmin_cfg_var i8880_vars[] = {
 	{"XXOV2680:00_CsiPort", "1"},
 	{"XXOV2680:00_CsiLanes", "1"},
 	{"XXOV2680:00_CamClk", "0"},
+
 	{"XXGC0310:00_CsiPort", "0"},
 	{"XXGC0310:00_CsiLanes", "1"},
 	{"XXGC0310:00_CamClk", "1"},
Signature · 1 line
2.27.0
#2 lore raw

PATCH v2 2/15 media: atomisp: move CCK endpoint address to generic header

In reply to Andy Shevchenko

IOSF MBI header contains a lot of definitions, such as end point addresses of IPs. Move CCK address from AtomISP driver to generic header.

While here, drop unused one.

---
 arch/x86/include/asm/iosf_mbi.h                  | 1 +
 drivers/staging/media/atomisp/pci/atomisp-regs.h | 3 ---
 drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 2 +-
 3 files changed, 2 insertions(+), 4 deletions(-)
arch/x86/include/asm/iosf_mbi.h +1 -0
index 5270ff39b9af..a1911fea8739 100644
@@ -39,6 +39,7 @@
 #define BT_MBI_UNIT_PMC		0x04
 #define BT_MBI_UNIT_GFX		0x06
 #define BT_MBI_UNIT_SMI		0x0C
+#define BT_MBI_UNIT_CCK		0x14
 #define BT_MBI_UNIT_USB		0x43
 #define BT_MBI_UNIT_SATA	0xA3
 #define BT_MBI_UNIT_PCIE	0xA6
drivers/staging/media/atomisp/pci/atomisp-regs.h +0 -3
index de34ee28e390..022997f47121 100644
@@ -20,9 +20,6 @@
 #define ATOMISP_REGS_H
 
 /* common register definitions */
-#define PUNIT_PORT		0x04
-#define CCK_PORT		0x14
-
 #define PCICMDSTS		0x01
 #define INTR			0x0f
 #define MSI_CAPID		0x24
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +1 -1
index d36809a0182c..fa07cbaf0422 100644
@@ -1685,7 +1685,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
 		isp->dfs = &dfs_config_cht;
 		isp->pdev->d3cold_delay = 0;
 
-		iosf_mbi_read(CCK_PORT, MBI_REG_READ, CCK_FUSE_REG_0, &val);
+		iosf_mbi_read(BT_MBI_UNIT_CCK, MBI_REG_READ, CCK_FUSE_REG_0, &val);
 		switch (val & CCK_FUSE_HPLL_FREQ_MASK) {
 		case 0x00:
 			isp->hpll_freq = HPLL_FREQ_800MHZ;
Signature · 1 line
2.27.0
#10 lore raw

PATCH v2 10/15 media: atomisp: Don't try to parse unexpected ACPI object type

In reply to Andy Shevchenko

There are devices with completely different _DSM() format, and accessing object as a package leads to crashes.

Bail out in the case of unexpected object type.

---
 drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +4 -0
index fb61274af7e5..f06c0eb6d288 100644
@@ -959,6 +959,10 @@ static int gmin_get_config_dsm_var(struct device *dev,
 		return -EINVAL;
 	}
 
+	/* Return on unexpected object type */
+	if (obj->type != ACPI_TYPE_PACKAGE)
+		return -EINVAL;
+
 #if 0 /* Just for debugging purposes */
 	for (i = 0; i < obj->package.count; i++) {
 		union acpi_object *cur = &obj->package.elements[i];
Signature · 1 line
2.27.0
#6 lore raw

PATCH v2 6/15 media: atomisp: Unify pdev to be pointer to struct pci_device

In reply to Andy Shevchenko

Unify pdev to be pointer to struct pci_device.

While here, reindent some (touched) lines for better readability.

---
 .../staging/media/atomisp/pci/atomisp_cmd.c   |  24 +-
 .../media/atomisp/pci/atomisp_gmin_platform.c |   6 +-
 .../staging/media/atomisp/pci/atomisp_v4l2.c  | 248 ++++++++----------
 3 files changed, 127 insertions(+), 151 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +12 -12
index 0735df75841f..db3c3542457c 100644
@@ -360,39 +360,39 @@ static void clear_isp_irq(enum hrt_isp_css_irq irq)
 
 void atomisp_msi_irq_init(struct atomisp_device *isp)
 {
-	struct pci_dev *dev = to_pci_dev(isp->dev);
+	struct pci_dev *pdev = to_pci_dev(isp->dev);
 	u32 msg32;
 	u16 msg16;
 
-	pci_read_config_dword(dev, PCI_MSI_CAPID, &msg32);
+	pci_read_config_dword(pdev, PCI_MSI_CAPID, &msg32);
 	msg32 |= 1 << MSI_ENABLE_BIT;
-	pci_write_config_dword(dev, PCI_MSI_CAPID, msg32);
+	pci_write_config_dword(pdev, PCI_MSI_CAPID, msg32);
 
 	msg32 = (1 << INTR_IER) | (1 << INTR_IIR);
-	pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, msg32);
+	pci_write_config_dword(pdev, PCI_INTERRUPT_CTRL, msg32);
 
-	pci_read_config_word(dev, PCI_COMMAND, &msg16);
+	pci_read_config_word(pdev, PCI_COMMAND, &msg16);
 	msg16 |= (PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
 		  PCI_COMMAND_INTX_DISABLE);
-	pci_write_config_word(dev, PCI_COMMAND, msg16);
+	pci_write_config_word(pdev, PCI_COMMAND, msg16);
 }
 
 void atomisp_msi_irq_uninit(struct atomisp_device *isp)
 {
-	struct pci_dev *dev = to_pci_dev(isp->dev);
+	struct pci_dev *pdev = to_pci_dev(isp->dev);
 	u32 msg32;
 	u16 msg16;
 
-	pci_read_config_dword(dev, PCI_MSI_CAPID, &msg32);
+	pci_read_config_dword(pdev, PCI_MSI_CAPID, &msg32);
 	msg32 &=  ~(1 << MSI_ENABLE_BIT);
-	pci_write_config_dword(dev, PCI_MSI_CAPID, msg32);
+	pci_write_config_dword(pdev, PCI_MSI_CAPID, msg32);
 
 	msg32 = 0x0;
-	pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, msg32);
+	pci_write_config_dword(pdev, PCI_INTERRUPT_CTRL, msg32);
 
-	pci_read_config_word(dev, PCI_COMMAND, &msg16);
+	pci_read_config_word(pdev, PCI_COMMAND, &msg16);
 	msg16 &= ~(PCI_COMMAND_MASTER);
-	pci_write_config_word(dev, PCI_COMMAND, msg16);
+	pci_write_config_word(pdev, PCI_COMMAND, msg16);
 }
 
 static void atomisp_sof_event(struct atomisp_sub_device *asd)
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +3 -3
index 8acceae189a2..79cbde65d3c1 100644
@@ -1148,10 +1148,10 @@ EXPORT_SYMBOL_GPL(camera_sensor_csi);
  * trying.  The driver itself does direct calls to the PUNIT to manage
  * ISP power.
  */
-static void isp_pm_cap_fixup(struct pci_dev *dev)
+static void isp_pm_cap_fixup(struct pci_dev *pdev)
 {
-	dev_info(&dev->dev, "Disabling PCI power management on camera ISP\n");
-	dev->pm_cap = 0;
+	dev_info(&pdev->dev, "Disabling PCI power management on camera ISP\n");
+	pdev->pm_cap = 0;
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0f38, isp_pm_cap_fixup);
 
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +112 -136

547 lines not on this page · raw message

Signature · 1 line
2.27.0
#13 lore raw

PATCH v2 13/15 media: atomisp: Provide Gmin subdev as parameter to gmin_subdev_add()

In reply to Andy Shevchenko

Provide Gmin subdev as parameter to gmin_subdev_add() to avoid direct global variable usage.

---
 .../media/atomisp/pci/atomisp_gmin_platform.c | 104 ++++++++----------
 1 file changed, 46 insertions(+), 58 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +46 -58
index 26f200b1ed6d..d0b9d906a563 100644
@@ -459,13 +459,13 @@ static int gmin_pmic_detect(struct v4l2_subdev *subdev)
 	return pmic_id;
 }
 
-static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
+static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev, struct gmin_subdev *gdev)
 {
 	struct i2c_client *client = v4l2_get_subdevdata(subdev);
 	struct device *dev = &client->dev;
 	struct acpi_device *adev;
 	acpi_handle handle;
-	int i, ret;
+	int ret;
 
 	handle = ACPI_HANDLE(dev);
 
@@ -478,13 +478,8 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
 	dev_info(&client->dev, "%s: ACPI detected it on bus ID=%s, HID=%s\n",
 		__func__, acpi_device_bid(adev), acpi_device_hid(adev));
 
-	for (i = 0; i < MAX_SUBDEVS && gmin_subdevs[i].subdev; i++)
-		;
-	if (i >= MAX_SUBDEVS)
-		return NULL;
-
 	if (power) {
-		gmin_subdevs[i].pwm_i2c_addr = power->addr;
+		gdev->pwm_i2c_addr = power->addr;
 		dev_info(dev,
 			 "gmin: power management provided via %s (i2c addr 0x%02x)\n",
 			 pmic_name[pmic_id], power->addr);
@@ -493,28 +488,21 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
 			 pmic_name[pmic_id]);
 	}
 
-	gmin_subdevs[i].subdev = subdev;
-	gmin_subdevs[i].clock_num = gmin_get_var_int(dev, false, "CamClk", 0);
+	gdev->subdev = subdev;
+	gdev->clock_num = gmin_get_var_int(dev, false, "CamClk", 0);
 	/*WA:CHT requires XTAL clock as PLL is not stable.*/
-	gmin_subdevs[i].clock_src = gmin_get_var_int(dev, false, "ClkSrc",
-				    VLV2_CLK_PLL_19P2MHZ);
-	gmin_subdevs[i].csi_port = gmin_get_var_int(dev, false, "CsiPort", 0);
-	gmin_subdevs[i].csi_lanes = gmin_get_var_int(dev, false, "CsiLanes", 1);
+	gdev->clock_src = gmin_get_var_int(dev, false, "ClkSrc", VLV2_CLK_PLL_19P2MHZ);
+	gdev->csi_port = gmin_get_var_int(dev, false, "CsiPort", 0);
+	gdev->csi_lanes = gmin_get_var_int(dev, false, "CsiLanes", 1);
 
 	/* get PMC clock with clock framework */
-	snprintf(gmin_pmc_clk_name,
-		 sizeof(gmin_pmc_clk_name),
-		 "%s_%d", "pmc_plt_clk", gmin_subdevs[i].clock_num);
-
-	gmin_subdevs[i].pmc_clk = devm_clk_get(dev, gmin_pmc_clk_name);
-	if (IS_ERR(gmin_subdevs[i].pmc_clk)) {
-		ret = PTR_ERR(gmin_subdevs[i].pmc_clk);
-
-		dev_err(dev,
-			"Failed to get clk from %s : %d\n",
-			gmin_pmc_clk_name,
-			ret);
+	snprintf(gmin_pmc_clk_name, sizeof(gmin_pmc_clk_name),
+		 "pmc_plt_clk_%d", gdev->clock_num);
 
+	gdev->pmc_clk = devm_clk_get(dev, gmin_pmc_clk_name);
+	if (IS_ERR(gdev->pmc_clk)) {
+		ret = PTR_ERR(gdev->pmc_clk);
+		dev_err(dev, "Failed to get clk from %s: %d\n", gmin_pmc_clk_name, ret);
 		return NULL;
 	}
 
@@ -528,25 +516,25 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
 	 * to disable a clock that has not been enabled,
 	 * we need to enable the clock first.
 	 */
-	ret = clk_prepare_enable(gmin_subdevs[i].pmc_clk);
+	ret = clk_prepare_enable(gdev->pmc_clk);
 	if (!ret)
-		clk_disable_unprepare(gmin_subdevs[i].pmc_clk);
+		clk_disable_unprepare(gdev->pmc_clk);
 
-	gmin_subdevs[i].gpio0 = gpiod_get_index(dev, NULL, 0, GPIOD_OUT_LOW);
-	if (IS_ERR(gmin_subdevs[i].gpio0))
-		gmin_subdevs[i].gpio0 = NULL;
+	gdev->gpio0 = gpiod_get_index(dev, NULL, 0, GPIOD_OUT_LOW);
+	if (IS_ERR(gdev->gpio0))
+		gdev->gpio0 = NULL;
 
-	gmin_subdevs[i].gpio1 = gpiod_get_index(dev, NULL, 1, GPIOD_OUT_LOW);
-	if (IS_ERR(gmin_subdevs[i].gpio1))
-		gmin_subdevs[i].gpio1 = NULL;
+	gdev->gpio1 = gpiod_get_index(dev, NULL, 1, GPIOD_OUT_LOW);
+	if (IS_ERR(gdev->gpio1))
+		gdev->gpio1 = NULL;
 
 	switch (pmic_id) {
 	case PMIC_REGULATOR:
-		gmin_subdevs[i].v1p8_reg = regulator_get(dev, "V1P8SX");
-		gmin_subdevs[i].v2p8_reg = regulator_get(dev, "V2P8SX");
+		gdev->v1p8_reg = regulator_get(dev, "V1P8SX");
+		gdev->v2p8_reg = regulator_get(dev, "V2P8SX");
 
-		gmin_subdevs[i].v1p2_reg = regulator_get(dev, "V1P2A");
-		gmin_subdevs[i].v2p8_vcm_reg = regulator_get(dev, "VPROG4B");
+		gdev->v1p2_reg = regulator_get(dev, "V1P2A");
+		gdev->v2p8_vcm_reg = regulator_get(dev, "VPROG4B");
 
 		/* Note: ideally we would initialize v[12]p8_on to the
 		 * output of regulator_is_enabled(), but sadly that
@@ -558,31 +546,25 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
 		break;
 
 	case PMIC_AXP:
-		gmin_subdevs[i].eldo1_1p8v = gmin_get_var_int(dev, false,
-							      "eldo1_1p8v",
-							      ELDO1_1P8V);
-		gmin_subdevs[i].eldo1_sel_reg = gmin_get_var_int(dev, false,
-								 "eldo1_sel_reg",
-								 ELDO1_SEL_REG);
-		gmin_subdevs[i].eldo1_ctrl_shift = gmin_get_var_int(dev, false,
-								    "eldo1_ctrl_shift",
-								    ELDO1_CTRL_SHIFT);
-		gmin_subdevs[i].eldo2_1p8v = gmin_get_var_int(dev, false,
-							      "eldo2_1p8v",
-							      ELDO2_1P8V);
-		gmin_subdevs[i].eldo2_sel_reg = gmin_get_var_int(dev, false,
-								 "eldo2_sel_reg",
-								 ELDO2_SEL_REG);
-		gmin_subdevs[i].eldo2_ctrl_shift = gmin_get_var_int(dev, false,
-								    "eldo2_ctrl_shift",
-								    ELDO2_CTRL_SHIFT);
+		gdev->eldo1_1p8v = gmin_get_var_int(dev, false, "eldo1_1p8v",
+						    ELDO1_1P8V);
+		gdev->eldo1_sel_reg = gmin_get_var_int(dev, false, "eldo1_sel_reg",
+						       ELDO1_SEL_REG);
+		gdev->eldo1_ctrl_shift = gmin_get_var_int(dev, false, "eldo1_ctrl_shift",
+							  ELDO1_CTRL_SHIFT);
+		gdev->eldo2_1p8v = gmin_get_var_int(dev, false, "eldo2_1p8v",
+						    ELDO2_1P8V);
+		gdev->eldo2_sel_reg = gmin_get_var_int(dev, false, "eldo2_sel_reg",
+						       ELDO2_SEL_REG);
+		gdev->eldo2_ctrl_shift = gmin_get_var_int(dev, false, "eldo2_ctrl_shift",
+							  ELDO2_CTRL_SHIFT);
 		break;
 
 	default:
 		break;
 	}
 
-	return &gmin_subdevs[i];
+	return gdev;
 }
 
 static struct gmin_subdev *find_gmin_subdev(struct v4l2_subdev *subdev)
@@ -593,8 +575,14 @@ static struct gmin_subdev *find_gmin_subdev(struct v4l2_subdev *subdev)
 		if (gmin_subdevs[i].subdev == subdev)
 			return &gmin_subdevs[i];
 
+	for (i = 0; i < MAX_SUBDEVS; i++)
+		if (gmin_subdevs[i].subdev == NULL)
+			break;
+	if (i == MAX_SUBDEVS)
+		return NULL;
+
 	gmin_pmic_detect(subdev);
-	return gmin_subdev_add(subdev);
+	return gmin_subdev_add(subdev, &gmin_subdevs[i]);
 }
 
 static int axp_regulator_set(struct device *dev, struct gmin_subdev *gs,
Signature · 1 line
2.27.0
#14 lore raw

PATCH v2 14/15 media: atomisp: Get rid of ugly and leaky ACPI handling in gmin_subdev_add()

In reply to Andy Shevchenko

First of all ACPI HID is a part of the device name which is printed as a part of the dev_info(dev, ...); line. Second, since the only BID is left, it's a part of ACPI path, which can be printed via %pfw.

Get rid of ugly and leaky ACPI handling in gmin_subdev_add() by replacing it with %pfw.

---
 .../media/atomisp/pci/atomisp_gmin_platform.c       | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +1 -12
index d0b9d906a563..7f9e93a9a4b1 100644
@@ -463,20 +463,9 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev, struct gm
 {
 	struct i2c_client *client = v4l2_get_subdevdata(subdev);
 	struct device *dev = &client->dev;
-	struct acpi_device *adev;
-	acpi_handle handle;
 	int ret;
 
-	handle = ACPI_HANDLE(dev);
-
-	// FIXME: may need to release resources allocated by acpi_bus_get_device()
-	if (!handle || acpi_bus_get_device(handle, &adev)) {
-		dev_err(dev, "Error could not get ACPI device\n");
-		return NULL;
-	}
-
-	dev_info(&client->dev, "%s: ACPI detected it on bus ID=%s, HID=%s\n",
-		__func__, acpi_device_bid(adev), acpi_device_hid(adev));
+	dev_info(&client->dev, "%s: ACPI path is %pfw\n", __func__, dev_fwnode(dev));
 
 	if (power) {
 		gdev->pwm_i2c_addr = power->addr;
Signature · 1 line
2.27.0
#8 lore raw

PATCH v2 8/15 media: atomisp: Drop global atomisp_dev variable (easy cases)

In reply to Andy Shevchenko

Refactor code to avoid use of atomisp_dev global variable where it's easy to achieve.

---
 drivers/staging/media/atomisp/pci/atomisp_acc.c  |  4 ++--
 .../media/atomisp/pci/atomisp_compat_css20.c     | 16 +++++++---------
 .../media/atomisp/pci/atomisp_compat_css20.h     |  2 +-
 .../staging/media/atomisp/pci/atomisp_drvfs.c    | 11 +++++------
 4 files changed, 15 insertions(+), 18 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_acc.c +2 -2
index 76861396ba86..f638d0bd09fe 100644
@@ -355,11 +355,11 @@ int atomisp_acc_map(struct atomisp_sub_device *asd, struct atomisp_acc_map *map)
 
 		pgnr = DIV_ROUND_UP(map->length, PAGE_SIZE);
 		if (pgnr < ((PAGE_ALIGN(map->length)) >> PAGE_SHIFT)) {
-			dev_err(atomisp_dev,
+			dev_err(asd->isp->dev,
 				"user space memory size is less than the expected size..\n");
 			return -ENOMEM;
 		} else if (pgnr > ((PAGE_ALIGN(map->length)) >> PAGE_SHIFT)) {
-			dev_err(atomisp_dev,
+			dev_err(asd->isp->dev,
 				"user space memory size is large than the expected size..\n");
 			return -ENOMEM;
 		}
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +7 -9
index 010b2b19d811..499916bc6aab 100644
@@ -182,10 +182,10 @@ void atomisp_load_uint32(hrt_address addr, uint32_t *data)
 	*data = atomisp_css2_hw_load_32(addr);
 }
 
-static int hmm_get_mmu_base_addr(unsigned int *mmu_base_addr)
+static int hmm_get_mmu_base_addr(struct device *dev, unsigned int *mmu_base_addr)
 {
 	if (!sh_mmu_mrfld.get_pd_base) {
-		dev_err(atomisp_dev, "get mmu base address failed.\n");
+		dev_err(dev, "get mmu base address failed.\n");
 		return -EINVAL;
 	}
 
@@ -840,7 +840,7 @@ int atomisp_css_init(struct atomisp_device *isp)
 	int ret;
 	int err;
 
-	ret = hmm_get_mmu_base_addr(&mmu_base_addr);
+	ret = hmm_get_mmu_base_addr(isp->dev, &mmu_base_addr);
 	if (ret)
 		return ret;
 
@@ -942,7 +942,7 @@ int atomisp_css_resume(struct atomisp_device *isp)
 	unsigned int mmu_base_addr;
 	int ret;
 
-	ret = hmm_get_mmu_base_addr(&mmu_base_addr);
+	ret = hmm_get_mmu_base_addr(isp->dev, &mmu_base_addr);
 	if (ret) {
 		dev_err(isp->dev, "get base address error.\n");
 		return -EINVAL;
@@ -4337,7 +4337,7 @@ static const char * const fw_acc_type_name[] = {
 	[IA_CSS_ACC_STANDALONE] =	"Stand-alone acceleration",
 };
 
-int atomisp_css_dump_blob_infor(void)
+int atomisp_css_dump_blob_infor(struct atomisp_device *isp)
 {
 	struct ia_css_blob_descr *bd = sh_css_blob_info;
 	unsigned int i, nm = sh_css_num_binaries;
@@ -4354,8 +4354,7 @@ int atomisp_css_dump_blob_infor(void)
 	for (i = 0; i < sh_css_num_binaries - NUM_OF_SPS; i++) {
 		switch (bd[i].header.type) {
 		case ia_css_isp_firmware:
-			dev_dbg(atomisp_dev,
-				"Num%2d type %s (%s), binary id is %2d, name is %s\n",
+			dev_dbg(isp->dev, "Num%2d type %s (%s), binary id is %2d, name is %s\n",
 				i + NUM_OF_SPS,
 				fw_type_name[bd[i].header.type],
 				fw_acc_type_name[bd[i].header.info.isp.type],
@@ -4363,8 +4362,7 @@ int atomisp_css_dump_blob_infor(void)
 				bd[i].name);
 			break;
 		default:
-			dev_dbg(atomisp_dev,
-				"Num%2d type %s, name is %s\n",
+			dev_dbg(isp->dev, "Num%2d type %s, name is %s\n",
 				i + NUM_OF_SPS, fw_type_name[bd[i].header.type],
 				bd[i].name);
 		}
drivers/staging/media/atomisp/pci/atomisp_compat_css20.h +1 -1
index 8376aec18e3e..e0601534380f 100644
@@ -153,7 +153,7 @@ int atomisp_css_debug_dump_isp_binary(void);
 
 int atomisp_css_dump_sp_raw_copy_linecount(bool reduced);
 
-int atomisp_css_dump_blob_infor(void);
+int atomisp_css_dump_blob_infor(struct atomisp_device *isp);
 
 void atomisp_css_set_isp_config_id(struct atomisp_sub_device *asd,
 				   uint32_t isp_config_id);
drivers/staging/media/atomisp/pci/atomisp_drvfs.c +5 -6
index 3711df111fbf..f670faf978e6 100644
@@ -62,9 +62,9 @@ static inline int iunit_dump_dbgopt(struct atomisp_device *isp,
 
 	if (opt & OPTION_VALID) {
 		if (opt & OPTION_BIN_LIST) {
-			ret = atomisp_css_dump_blob_infor();
+			ret = atomisp_css_dump_blob_infor(isp);
 			if (ret) {
-				dev_err(atomisp_dev, "%s dump blob infor err[ret:%d]\n",
+				dev_err(isp->dev, "%s dump blob infor err[ret:%d]\n",
 					__func__, ret);
 				goto opt_err;
 			}
@@ -76,7 +76,7 @@ static inline int iunit_dump_dbgopt(struct atomisp_device *isp,
 				atomisp_css_debug_dump_isp_binary();
 			} else {
 				ret = -EPERM;
-				dev_err(atomisp_dev, "%s dump running bin err[ret:%d]\n",
+				dev_err(isp->dev, "%s dump running bin err[ret:%d]\n",
 					__func__, ret);
 				goto opt_err;
 			}
@@ -86,8 +86,7 @@ static inline int iunit_dump_dbgopt(struct atomisp_device *isp,
 			hmm_show_mem_stat(__func__, __LINE__);
 	} else {
 		ret = -EINVAL;
-		dev_err(atomisp_dev, "%s dump nothing[ret=%d]\n", __func__,
-			ret);
+		dev_err(isp->dev, "%s dump nothing[ret=%d]\n", __func__, ret);
 	}
 
 opt_err:
@@ -195,7 +194,7 @@ int atomisp_drvfs_init(struct atomisp_device *isp)
 
 	ret = iunit_drvfs_create_files(iunit_debug.drv);
 	if (ret) {
-		dev_err(atomisp_dev, "drvfs_create_files error: %d\n", ret);
+		dev_err(isp->dev, "drvfs_create_files error: %d\n", ret);
 		iunit_drvfs_remove_files(iunit_debug.drv);
 	}
 
Signature · 1 line
2.27.0
#11 lore raw

PATCH v2 11/15 media: atomisp: Make pointer to PMIC client global

In reply to Andy Shevchenko

When we enumerate second device when PMIC has been successfully detected to AXP, we got into troubles dereferencing NULL pointer. It seems we have to detect PMIC only once because pmic_id is a global variable and code doesn't expect the change of it: Two PMICs on one platform? It's impossible.

Crash excerpt:

[   34.335237] BUG: kernel NULL pointer dereference, address: 0000000000000002
...
[   35.652036] RIP: 0010:gmin_subdev_add.cold+0x32f/0x33e [atomisp_gmin_platform]

So, as a quick fix make power a global variable. In next patches we move PMIC detection to be more independent from subdevices.

---
 drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +3 -2
index f06c0eb6d288..84e9bf1825fa 100644
@@ -437,9 +437,11 @@ static int gmin_i2c_write(struct device *dev, u16 i2c_addr, u8 reg,
 	return ret;
 }
 
+static struct i2c_client *power;
+
 static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
 {
-	struct i2c_client *power = NULL, *client = v4l2_get_subdevdata(subdev);
+	struct i2c_client *client = v4l2_get_subdevdata(subdev);
 	struct acpi_device *adev;
 	acpi_handle handle;
 	struct device *dev;
@@ -570,7 +572,6 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
 		gmin_subdevs[i].eldo2_ctrl_shift = gmin_get_var_int(dev, false,
 								    "eldo2_ctrl_shift",
 								    ELDO2_CTRL_SHIFT);
-		gmin_subdevs[i].pwm_i2c_addr = power->addr;
 		break;
 
 	default:
Signature · 1 line
2.27.0
#7 lore raw

PATCH v2 7/15 media: atomisp: Replace direct access to MMIO with proper helpers

In reply to Andy Shevchenko

We have special helpers to access MMIO. Use them.

---
 .../staging/media/atomisp/pci/atomisp_cmd.c   | 13 +++---
 .../media/atomisp/pci/atomisp_compat.h        |  2 -
 .../media/atomisp/pci/atomisp_compat_css20.c  | 43 ++++++++++---------
 .../media/atomisp/pci/atomisp_internal.h      |  1 +
 .../staging/media/atomisp/pci/atomisp_v4l2.c  | 16 +++----
 5 files changed, 35 insertions(+), 40 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +6 -7
index db3c3542457c..ed01a0987da7 100644
@@ -21,6 +21,7 @@
 #include <linux/firmware.h>
 #include <linux/pci.h>
 #include <linux/interrupt.h>
+#include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/kfifo.h>
 #include <linux/pm_runtime.h>
@@ -669,11 +670,10 @@ bool atomisp_buffers_queued_pipe(struct atomisp_video_pipe *pipe)
 void dump_sp_dmem(struct atomisp_device *isp, unsigned int addr,
 		  unsigned int size)
 {
-	u32 __iomem *io_virt_addr;
 	unsigned int data = 0;
 	unsigned int size32 = DIV_ROUND_UP(size, sizeof(u32));
 
-	dev_dbg(isp->dev, "atomisp_io_base:%p\n", atomisp_io_base);
+	dev_dbg(isp->dev, "atomisp mmio base: %p\n", isp->base);
 	dev_dbg(isp->dev, "%s, addr:0x%x, size: %d, size32: %d\n", __func__,
 		addr, size, size32);
 	if (size32 * 4 + addr > 0x4000) {
@@ -682,13 +682,12 @@ void dump_sp_dmem(struct atomisp_device *isp, unsigned int addr,
 		return;
 	}
 	addr += SP_DMEM_BASE;
-	io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF);
+	addr &= 0x003FFFFF;
 	do {
-		data = *io_virt_addr;
+		data = readl(isp->base + addr);
 		dev_dbg(isp->dev, "%s, \t [0x%x]:0x%x\n", __func__, addr, data);
-		io_virt_addr += sizeof(u32);
-		size32 -= 1;
-	} while (size32 > 0);
+		addr += sizeof(u32);
+	} while (--size32);
 }
 
 static struct videobuf_buffer *atomisp_css_frame_to_vbuf(
drivers/staging/media/atomisp/pci/atomisp_compat.h +0 -2
index b2ed83c2f337..6a2a81a3eb23 100644
@@ -29,8 +29,6 @@ struct atomisp_sub_device;
 struct video_device;
 enum atomisp_input_stream_id;
 
-extern void __iomem *atomisp_io_base;
-
 struct atomisp_metadata_buf {
 	struct ia_css_metadata *metadata;
 	void *md_vptr;
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +23 -20

121 lines not on this page · raw message

drivers/staging/media/atomisp/pci/atomisp_internal.h +1 -0
index 5af9bbce6284..c01db10bb735 100644
@@ -221,6 +221,7 @@ struct atomisp_device {
 	struct media_device media_dev;
 	struct atomisp_platform_data *pdata;
 	void *mmu_l1_base;
+	void __iomem *base;
 	const struct firmware *firmware;
 
 	struct pm_qos_request pm_qos;
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +5 -11
index 731a683e82f1..17ca730aa358 100644
@@ -127,8 +127,6 @@ MODULE_PARM_DESC(pad_h, "extra data for ISP processing");
 
 struct device *atomisp_dev;
 
-void __iomem *atomisp_io_base;
-
 static const struct atomisp_freq_scaling_rule dfs_rules_merr[] = {
 	{
 		.width = ISP_FREQ_RULE_ANY,
@@ -1531,7 +1529,6 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
 	const struct atomisp_platform_data *pdata;
 	struct atomisp_device *isp;
 	unsigned int start;
-	void __iomem *base;
 	int err, val;
 	u32 irq;
 
@@ -1560,13 +1557,6 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
 		goto ioremap_fail;
 	}
 
-	base = pcim_iomap_table(pdev)[ATOM_ISP_PCI_BAR];
-	dev_dbg(&pdev->dev, "base: %p\n", base);
-
-	atomisp_io_base = base;
-
-	dev_dbg(&pdev->dev, "atomisp_io_base: %p\n", atomisp_io_base);
-
 	isp = devm_kzalloc(&pdev->dev, sizeof(*isp), GFP_KERNEL);
 	if (!isp) {
 		err = -ENOMEM;
@@ -1574,9 +1564,12 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
 	}
 
 	isp->dev = &pdev->dev;
+	isp->base = pcim_iomap_table(pdev)[ATOM_ISP_PCI_BAR];
 	isp->sw_contex.power_state = ATOM_ISP_POWER_UP;
 	isp->saved_regs.ispmmadr = start;
 
+	dev_dbg(&pdev->dev, "atomisp mmio base: %p\n", isp->base);
+
 	rt_mutex_init(&isp->mutex);
 	mutex_init(&isp->streamoff_mutex);
 	spin_lock_init(&isp->lock);
@@ -1584,6 +1577,8 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
 	/* This is not a true PCI device on SoC, so the delay is not needed. */
 	pdev->d3_delay = 0;
 
+	pci_set_drvdata(pdev, isp);
+
 	switch (id->device & ATOMISP_PCI_DEVICE_SOC_MASK) {
 	case ATOMISP_PCI_DEVICE_SOC_MRFLD:
 		isp->media_dev.hw_revision =
@@ -1714,7 +1709,6 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
 	}
 
 	pci_set_master(pdev);
-	pci_set_drvdata(pdev, isp);
 
 	err = pci_enable_msi(pdev);
 	if (err) {
Signature · 1 line
2.27.0
#15 lore raw

PATCH v2 15/15 media: atomisp: Deduplicate return ret in gmin_i2c_write()

In reply to Andy Shevchenko

Deduplicate return ret in gmin_i2c_write().

While here, replace 'Kernel' by 'kernel' in the message and reduce amount of LOCs.

---
 .../staging/media/atomisp/pci/atomisp_gmin_platform.c  | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +3 -7
index 7f9e93a9a4b1..11437161ef20 100644
@@ -423,16 +423,12 @@ static int gmin_i2c_write(struct device *dev, u16 i2c_addr, u8 reg,
 		"I2C write, addr: 0x%02x, reg: 0x%02x, value: 0x%02x, mask: 0x%02x\n",
 		i2c_addr, reg, value, mask);
 
-	ret = intel_soc_pmic_exec_mipi_pmic_seq_element(i2c_addr, reg,
-							value, mask);
-
-	if (ret == -EOPNOTSUPP) {
+	ret = intel_soc_pmic_exec_mipi_pmic_seq_element(i2c_addr, reg, value, mask);
+	if (ret == -EOPNOTSUPP)
 		dev_err(dev,
 			"ACPI didn't mapped the OpRegion needed to access I2C address 0x%02x.\n"
-			"Need to compile the Kernel using CONFIG_*_PMIC_OPREGION settings\n",
+			"Need to compile the kernel using CONFIG_*_PMIC_OPREGION settings\n",
 			i2c_addr);
-		return ret;
-	}
 
 	return ret;
 }
Signature · 1 line
2.27.0
#12 lore raw

PATCH v2 12/15 media: atomisp: Refactor PMIC detection to a separate function.

In reply to Andy Shevchenko

Refactor PMIC detection to a separate function. In the future we may move this code somewhere else where it's more suitable.

---
 .../media/atomisp/pci/atomisp_gmin_platform.c | 40 +++++++++++--------
 1 file changed, 23 insertions(+), 17 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +23 -17
index 84e9bf1825fa..26f200b1ed6d 100644
@@ -439,19 +439,34 @@ static int gmin_i2c_write(struct device *dev, u16 i2c_addr, u8 reg,
 
 static struct i2c_client *power;
 
+static int gmin_pmic_detect(struct v4l2_subdev *subdev)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(subdev);
+	struct device *dev = &client->dev;
+
+	if (pmic_id)
+		return pmic_id;
+
+	if (gmin_i2c_dev_exists(dev, PMIC_ACPI_TI, &power))
+		pmic_id = PMIC_TI;
+	else if (gmin_i2c_dev_exists(dev, PMIC_ACPI_AXP, &power))
+		pmic_id = PMIC_AXP;
+	else if (gmin_i2c_dev_exists(dev, PMIC_ACPI_CRYSTALCOVE, &power))
+		pmic_id = PMIC_CRYSTALCOVE;
+	else
+		pmic_id = PMIC_REGULATOR;
+
+	return pmic_id;
+}
+
 static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
 {
 	struct i2c_client *client = v4l2_get_subdevdata(subdev);
+	struct device *dev = &client->dev;
 	struct acpi_device *adev;
 	acpi_handle handle;
-	struct device *dev;
 	int i, ret;
 
-	if (!client)
-		return NULL;
-
-	dev = &client->dev;
-
 	handle = ACPI_HANDLE(dev);
 
 	// FIXME: may need to release resources allocated by acpi_bus_get_device()
@@ -463,17 +478,6 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
 	dev_info(&client->dev, "%s: ACPI detected it on bus ID=%s, HID=%s\n",
 		__func__, acpi_device_bid(adev), acpi_device_hid(adev));
 
-	if (!pmic_id) {
-		if (gmin_i2c_dev_exists(dev, PMIC_ACPI_TI, &power))
-			pmic_id = PMIC_TI;
-		else if (gmin_i2c_dev_exists(dev, PMIC_ACPI_AXP, &power))
-			pmic_id = PMIC_AXP;
-		else if (gmin_i2c_dev_exists(dev, PMIC_ACPI_CRYSTALCOVE, &power))
-			pmic_id = PMIC_CRYSTALCOVE;
-		else
-			pmic_id = PMIC_REGULATOR;
-	}
-
 	for (i = 0; i < MAX_SUBDEVS && gmin_subdevs[i].subdev; i++)
 		;
 	if (i >= MAX_SUBDEVS)
@@ -588,6 +592,8 @@ static struct gmin_subdev *find_gmin_subdev(struct v4l2_subdev *subdev)
 	for (i = 0; i < MAX_SUBDEVS; i++)
 		if (gmin_subdevs[i].subdev == subdev)
 			return &gmin_subdevs[i];
+
+	gmin_pmic_detect(subdev);
 	return gmin_subdev_add(subdev);
 }
 
Signature · 1 line
2.27.0
#5 lore raw

PATCH v2 5/15 media: atomisp: Get rid of struct pci_dev in struct atomisp_device

In reply to Andy Shevchenko

struct atomisp device has struct device and struct pci_dev pointers which are basically duplicates of each other. Drop the latter in favour of the former.

While here, unify pdev to be pointer to struct pci_device and reindent some (touched) lines for better readability.

---
 .../staging/media/atomisp/pci/atomisp_cmd.c   | 24 +++++++++-----
 .../staging/media/atomisp/pci/atomisp_cmd.h   |  4 +--
 .../media/atomisp/pci/atomisp_internal.h      |  1 -
 .../staging/media/atomisp/pci/atomisp_ioctl.c | 19 +++++------
 .../staging/media/atomisp/pci/atomisp_v4l2.c  | 33 ++++++++++---------
 5 files changed, 43 insertions(+), 38 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +15 -9
index 7b936e5a5f03..0735df75841f 100644
@@ -206,6 +206,7 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
 			 enum atomisp_dfs_mode mode,
 			 bool force)
 {
+	struct pci_dev *pdev = to_pci_dev(isp->dev);
 	/* FIXME! Only use subdev[0] status yet */
 	struct atomisp_sub_device *asd = &isp->asd[0];
 	const struct atomisp_dfs_config *dfs;
@@ -219,7 +220,7 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
 		return -EINVAL;
 	}
 
-	if ((isp->pdev->device & ATOMISP_PCI_DEVICE_SOC_MASK) ==
+	if ((pdev->device & ATOMISP_PCI_DEVICE_SOC_MASK) ==
 	    ATOMISP_PCI_DEVICE_SOC_CHT && ATOMISP_USE_YUVPP(asd))
 		isp->dfs = &dfs_config_cht_soc;
 
@@ -357,8 +358,9 @@ static void clear_isp_irq(enum hrt_isp_css_irq irq)
 	irq_clear_all(IRQ0_ID);
 }
 
-void atomisp_msi_irq_init(struct atomisp_device *isp, struct pci_dev *dev)
+void atomisp_msi_irq_init(struct atomisp_device *isp)
 {
+	struct pci_dev *dev = to_pci_dev(isp->dev);
 	u32 msg32;
 	u16 msg16;
 
@@ -375,8 +377,9 @@ void atomisp_msi_irq_init(struct atomisp_device *isp, struct pci_dev *dev)
 	pci_write_config_word(dev, PCI_COMMAND, msg16);
 }
 
-void atomisp_msi_irq_uninit(struct atomisp_device *isp, struct pci_dev *dev)
+void atomisp_msi_irq_uninit(struct atomisp_device *isp)
 {
+	struct pci_dev *dev = to_pci_dev(isp->dev);
 	u32 msg32;
 	u16 msg16;
 
@@ -480,11 +483,12 @@ static void print_csi_rx_errors(enum mipi_port_id port,
 /* Clear irq reg */
 static void clear_irq_reg(struct atomisp_device *isp)
 {
+	struct pci_dev *pdev = to_pci_dev(isp->dev);
 	u32 msg_ret;
 
-	pci_read_config_dword(isp->pdev, PCI_INTERRUPT_CTRL, &msg_ret);
+	pci_read_config_dword(pdev, PCI_INTERRUPT_CTRL, &msg_ret);
 	msg_ret |= 1 << INTR_IIR;
-	pci_write_config_dword(isp->pdev, PCI_INTERRUPT_CTRL, msg_ret);
+	pci_write_config_dword(pdev, PCI_INTERRUPT_CTRL, msg_ret);
 }
 
 static struct atomisp_sub_device *
@@ -1289,6 +1293,7 @@ void atomisp_delayed_init_work(struct work_struct *work)
 
 static void __atomisp_css_recover(struct atomisp_device *isp, bool isp_timeout)
 {
+	struct pci_dev *pdev = to_pci_dev(isp->dev);
 	enum ia_css_pipe_id css_pipe_id;
 	bool stream_restart[MAX_STREAM_NUM] = {0};
 	bool depth_mode = false;
@@ -1372,8 +1377,8 @@ static void __atomisp_css_recover(struct atomisp_device *isp, bool isp_timeout)
 	clear_isp_irq(hrt_isp_css_irq_sp);
 
 	/* Set the SRSE to 3 before resetting */
-	pci_write_config_dword(isp->pdev, PCI_I_CONTROL, isp->saved_regs.i_control |
-			       MRFLD_PCI_I_CONTROL_SRSE_RESET_MASK);
+	pci_write_config_dword(pdev, PCI_I_CONTROL,
+			       isp->saved_regs.i_control | MRFLD_PCI_I_CONTROL_SRSE_RESET_MASK);
 
 	/* reset ISP and restore its state */
 	isp->isp_timeout = true;
@@ -6158,6 +6163,7 @@ int atomisp_set_shading_table(struct atomisp_sub_device *asd,
 /*Turn off ISP dphy */
 int atomisp_ospm_dphy_down(struct atomisp_device *isp)
 {
+	struct pci_dev *pdev = to_pci_dev(isp->dev);
 	unsigned long flags;
 	u32 reg;
 
@@ -6179,9 +6185,9 @@ int atomisp_ospm_dphy_down(struct atomisp_device *isp)
 	 * MRFLD HW design need all CSI ports are disabled before
 	 * powering down the IUNIT.
 	 */
-	pci_read_config_dword(isp->pdev, MRFLD_PCI_CSI_CONTROL, &reg);
+	pci_read_config_dword(pdev, MRFLD_PCI_CSI_CONTROL, &reg);
 	reg |= MRFLD_ALL_CSI_PORTS_OFF_MASK;
-	pci_write_config_dword(isp->pdev, MRFLD_PCI_CSI_CONTROL, reg);
+	pci_write_config_dword(pdev, MRFLD_PCI_CSI_CONTROL, reg);
 	return 0;
 }
 
drivers/staging/media/atomisp/pci/atomisp_cmd.h +2 -2
index 0bde995f1a8d..1c0d464c2ac1 100644
@@ -68,8 +68,8 @@ bool atomisp_buffers_queued_pipe(struct atomisp_video_pipe *pipe);
 /*
  * Interrupt functions
  */
-void atomisp_msi_irq_init(struct atomisp_device *isp, struct pci_dev *dev);
-void atomisp_msi_irq_uninit(struct atomisp_device *isp, struct pci_dev *dev);
+void atomisp_msi_irq_init(struct atomisp_device *isp);
+void atomisp_msi_irq_uninit(struct atomisp_device *isp);
 void atomisp_wdt_work(struct work_struct *work);
 void atomisp_wdt(struct timer_list *t);
 void atomisp_setup_flash(struct atomisp_sub_device *asd);
drivers/staging/media/atomisp/pci/atomisp_internal.h +0 -1
index ff3becd41110..5af9bbce6284 100644
@@ -216,7 +216,6 @@ struct atomisp_sw_contex {
  * ci device struct
  */
 struct atomisp_device {
-	struct pci_dev *pdev;
 	struct device *dev;
 	struct v4l2_device v4l2_dev;
 	struct media_device media_dev;
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +9 -10
index 9404a678fa6f..f8d616f08b51 100644
@@ -549,8 +549,7 @@ static int atomisp_querycap(struct file *file, void *fh,
 
 	strscpy(cap->driver, DRIVER, sizeof(cap->driver));
 	strscpy(cap->card, CARD, sizeof(cap->card));
-	snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s",
-		 pci_name(isp->pdev));
+	snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", dev_name(isp->dev));
 
 	return 0;
 }
@@ -1635,6 +1634,7 @@ static int atomisp_streamon(struct file *file, void *fh,
 	struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
 	struct atomisp_sub_device *asd = pipe->asd;
 	struct atomisp_device *isp = video_get_drvdata(vdev);
+	struct pci_dev *pdev = to_pci_dev(isp->dev);
 	enum ia_css_pipe_id css_pipe_id;
 	unsigned int sensor_start_stream;
 	unsigned int wdt_duration = ATOMISP_ISP_TIMEOUT_DURATION;
@@ -1844,9 +1844,8 @@ static int atomisp_streamon(struct file *file, void *fh,
 	/* Enable the CSI interface on ANN B0/K0 */
 	if (isp->media_dev.hw_revision >= ((ATOMISP_HW_REVISION_ISP2401 <<
 					    ATOMISP_HW_REVISION_SHIFT) | ATOMISP_HW_STEPPING_B0)) {
-		pci_write_config_word(isp->pdev, MRFLD_PCI_CSI_CONTROL,
-				      isp->saved_regs.csi_control |
-				      MRFLD_PCI_CSI_CONTROL_CSI_READY);
+		pci_write_config_word(pdev, MRFLD_PCI_CSI_CONTROL,
+				      isp->saved_regs.csi_control | MRFLD_PCI_CSI_CONTROL_CSI_READY);
 	}
 
 	/* stream on the sensor */
@@ -1891,6 +1890,7 @@ int __atomisp_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
 {
 	struct video_device *vdev = video_devdata(file);
 	struct atomisp_device *isp = video_get_drvdata(vdev);
+	struct pci_dev *pdev = to_pci_dev(isp->dev);
 	struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
 	struct atomisp_sub_device *asd = pipe->asd;
 	struct atomisp_video_pipe *capture_pipe = NULL;
@@ -2076,9 +2076,8 @@ int __atomisp_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
 	/* Disable the CSI interface on ANN B0/K0 */
 	if (isp->media_dev.hw_revision >= ((ATOMISP_HW_REVISION_ISP2401 <<
 					    ATOMISP_HW_REVISION_SHIFT) | ATOMISP_HW_STEPPING_B0)) {
-		pci_write_config_word(isp->pdev, MRFLD_PCI_CSI_CONTROL,
-				      isp->saved_regs.csi_control &
-				      ~MRFLD_PCI_CSI_CONTROL_CSI_READY);
+		pci_write_config_word(pdev, MRFLD_PCI_CSI_CONTROL,
+				      isp->saved_regs.csi_control & ~MRFLD_PCI_CSI_CONTROL_CSI_READY);
 	}
 
 	if (atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_LOW, false))
@@ -2111,8 +2110,8 @@ int __atomisp_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
 		}
 
 		/* disable  PUNIT/ISP acknowlede/handshake - SRSE=3 */
-		pci_write_config_dword(isp->pdev, PCI_I_CONTROL, isp->saved_regs.i_control |
-				       MRFLD_PCI_I_CONTROL_SRSE_RESET_MASK);
+		pci_write_config_dword(pdev, PCI_I_CONTROL,
+				       isp->saved_regs.i_control | MRFLD_PCI_I_CONTROL_SRSE_RESET_MASK);
 		dev_err(isp->dev, "atomisp_reset");
 		atomisp_reset(isp);
 		for (i = 0; i < isp->num_of_streams; i++) {
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +17 -16
index c6996b1f228b..3ae9058b32ec 100644
@@ -512,7 +512,7 @@ void atomisp_acc_unregister(struct atomisp_acc_pipe *video)
 
 static int atomisp_save_iunit_reg(struct atomisp_device *isp)
 {
-	struct pci_dev *dev = isp->pdev;
+	struct pci_dev *dev = to_pci_dev(isp->dev);
 
 	dev_dbg(isp->dev, "%s\n", __func__);
 
@@ -573,7 +573,7 @@ static int atomisp_save_iunit_reg(struct atomisp_device *isp)
 
 static int __maybe_unused atomisp_restore_iunit_reg(struct atomisp_device *isp)
 {
-	struct pci_dev *dev = isp->pdev;
+	struct pci_dev *dev = to_pci_dev(isp->dev);
 
 	dev_dbg(isp->dev, "%s\n", __func__);
 
@@ -619,7 +619,7 @@ static int __maybe_unused atomisp_restore_iunit_reg(struct atomisp_device *isp)
 
 static int atomisp_mrfld_pre_power_down(struct atomisp_device *isp)
 {
-	struct pci_dev *dev = isp->pdev;
+	struct pci_dev *dev = to_pci_dev(isp->dev);
 	u32 irq;
 	unsigned long flags;
 
@@ -679,7 +679,7 @@ static int atomisp_mrfld_pre_power_down(struct atomisp_device *isp)
 	irq &= ~(1 << INTR_IER);
 	pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, irq);
 
-	atomisp_msi_irq_uninit(isp, dev);
+	atomisp_msi_irq_uninit(isp);
 	atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_LOW, true);
 	spin_unlock_irqrestore(&isp->lock, flags);
 
@@ -902,6 +902,7 @@ static int __maybe_unused atomisp_resume(struct device *dev)
 
 int atomisp_csi_lane_config(struct atomisp_device *isp)
 {
+	struct pci_dev *pdev = to_pci_dev(isp->dev);
 	static const struct {
 		u8 code;
 		u8 lanes[MRFLD_PORT_NUM];
@@ -1003,7 +1004,7 @@ int atomisp_csi_lane_config(struct atomisp_device *isp)
 		return -EINVAL;
 	}
 
-	pci_read_config_dword(isp->pdev, MRFLD_PCI_CSI_CONTROL, &csi_control);
+	pci_read_config_dword(pdev, MRFLD_PCI_CSI_CONTROL, &csi_control);
 	csi_control &= ~port_config_mask;
 	csi_control |= (portconfigs[i].code << MRFLD_PORT_CONFIGCODE_SHIFT)
 		       | (portconfigs[i].lanes[0] ? 0 : (1 << MRFLD_PORT1_ENABLE_SHIFT))
@@ -1013,7 +1014,7 @@ int atomisp_csi_lane_config(struct atomisp_device *isp)
 		       | (((1 << portconfigs[i].lanes[1]) - 1) << MRFLD_PORT2_LANES_SHIFT)
 		       | (((1 << portconfigs[i].lanes[2]) - 1) << port3_lanes_shift);
 
-	pci_write_config_dword(isp->pdev, MRFLD_PCI_CSI_CONTROL, csi_control);
+	pci_write_config_dword(pdev, MRFLD_PCI_CSI_CONTROL, csi_control);
 
 	dev_dbg(isp->dev,
 		"%s: the portconfig is %d-%d-%d, CSI_CONTROL is 0x%08X\n",
@@ -1587,7 +1588,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
 		err = -ENOMEM;
 		goto atomisp_dev_alloc_fail;
 	}
-	isp->pdev = dev;
+
 	isp->dev = &dev->dev;
 	isp->sw_contex.power_state = ATOM_ISP_POWER_UP;
 	isp->saved_regs.ispmmadr = start;
@@ -1597,7 +1598,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
 	spin_lock_init(&isp->lock);
 
 	/* This is not a true PCI device on SoC, so the delay is not needed. */
-	isp->pdev->d3_delay = 0;
+	dev->d3_delay = 0;
 
 	switch (id->device & ATOMISP_PCI_DEVICE_SOC_MASK) {
 	case ATOMISP_PCI_DEVICE_SOC_MRFLD:
@@ -1656,7 +1657,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
 		 * in power off. Set d3cold_delay to 0 since default 100ms is not
 		 * necessary.
 		 */
-		isp->pdev->d3cold_delay = 0;
+		dev->d3cold_delay = 0;
 		break;
 	case ATOMISP_PCI_DEVICE_SOC_ANN:
 		isp->media_dev.hw_revision = (
@@ -1666,7 +1667,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
 						 ATOMISP_HW_REVISION_ISP2401_LEGACY
 #endif
 						 << ATOMISP_HW_REVISION_SHIFT);
-		isp->media_dev.hw_revision |= isp->pdev->revision < 2 ?
+		isp->media_dev.hw_revision |= dev->revision < 2 ?
 					      ATOMISP_HW_STEPPING_A0 : ATOMISP_HW_STEPPING_B0;
 		isp->dfs = &dfs_config_merr;
 		isp->hpll_freq = HPLL_FREQ_1600MHZ;
@@ -1679,11 +1680,11 @@ static int atomisp_pci_probe(struct pci_dev *dev,
 						 ATOMISP_HW_REVISION_ISP2401_LEGACY
 #endif
 						 << ATOMISP_HW_REVISION_SHIFT);
-		isp->media_dev.hw_revision |= isp->pdev->revision < 2 ?
+		isp->media_dev.hw_revision |= dev->revision < 2 ?
 					      ATOMISP_HW_STEPPING_A0 : ATOMISP_HW_STEPPING_B0;
 
 		isp->dfs = &dfs_config_cht;
-		isp->pdev->d3cold_delay = 0;
+		dev->d3cold_delay = 0;
 
 		iosf_mbi_read(BT_MBI_UNIT_CCK, MBI_REG_READ, CCK_FUSE_REG_0, &val);
 		switch (val & CCK_FUSE_HPLL_FREQ_MASK) {
@@ -1741,7 +1742,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
 		goto enable_msi_fail;
 	}
 
-	atomisp_msi_irq_init(isp, dev);
+	atomisp_msi_irq_init(isp);
 
 	cpu_latency_qos_add_request(&isp->pm_qos, PM_QOS_DEFAULT_VALUE);
 
@@ -1856,7 +1857,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
 	atomisp_uninitialize_modules(isp);
 initialize_modules_fail:
 	cpu_latency_qos_remove_request(&isp->pm_qos);
-	atomisp_msi_irq_uninit(isp, dev);
+	atomisp_msi_irq_uninit(isp);
 	pci_disable_msi(dev);
 enable_msi_fail:
 fw_validation_fail:
@@ -1877,7 +1878,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
 	irq &= ~(1 << INTR_IER);
 	pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, irq);
 
-	atomisp_msi_irq_uninit(isp, dev);
+	atomisp_msi_irq_uninit(isp);
 
 	atomisp_ospm_dphy_down(isp);
 
@@ -1910,7 +1911,7 @@ static void atomisp_pci_remove(struct pci_dev *dev)
 	pm_runtime_get_noresume(&dev->dev);
 	cpu_latency_qos_remove_request(&isp->pm_qos);
 
-	atomisp_msi_irq_uninit(isp, dev);
+	atomisp_msi_irq_uninit(isp);
 	atomisp_unregister_entities(isp);
 
 	destroy_workqueue(isp->wdt_work_queue);
Signature · 1 line
2.27.0
#16 lore raw
In reply to Andy Shevchenko

Hi Andy,

Em Fri, 26 Jun 2020 15:19:10 +0300
Andy Shevchenko <[email protected]> escreveu:

Quoted 2 lines

I'm experimenting with it on Baytrail machine and found some issues. Along with fixing them I cleaned up a bit this.

Thanks for that! Yeah, I found some issues there myself, although testing on a device with more than one camera is very nice.

I'll apply your patches on the top of my atomisp tree:

https://git.linuxtv.org/mchehab/experimental.git/log/?h=atomisp_v5

On a very quick look, I suspect that some may rise some conflicts, as I did some improvements at the detection logic, in order to get rid of the ugly DMI match stuff when ACPI has what's needed.

Regards,
Mauro

Quoted 103 lines

So, after applying I have the following log

# modprobe atomisp
[  116.215056] atomisp: module is from the staging directory, the quality is unknown, you have been warned.
[  116.310077] atomisp-isp2 0000:00:03.0: Detected Baytrail version 15 (ISP2400) on VALLEYVIEW C0 (CR) PLATFORM
[  116.354189] atomisp-isp2 0000:00:03.0: start: 0x50000000
[  116.376888] atomisp-isp2 0000:00:03.0: atomisp mmio base: 0000000027f9eb1f
[  116.401267] ACPI: \: failed to evaluate _DSM (0x1001)
[  116.423479] atomisp-isp2 0000:00:03.0: Failed to find EFI variable 0000:00:03.0_HpllFreq
[  116.449254] atomisp-isp2 0000:00:03.0: HpllFreq: using default (2000)
[  116.473045] atomisp-isp2 0000:00:03.0: ISP HPLL frequency base = 2000 MHz
[  116.770613] atomisp-isp2 0000:00:03.0: Probing Subdev INT33F8:00
[  116.793750] atomisp-isp2 0000:00:03.0: Subdev INT33F8:00 successfully register
[  116.818155] atomisp-isp2 0000:00:03.0: raw_index: -1
[  116.839924] atomisp-isp2 0000:00:03.0: SOC_INDEX: 0
[  116.861622] atomisp-isp2 0000:00:03.0: Probing Subdev INTCF1C:00
[  116.896885] lm3554 i2c-INTCF1C:00: Failed to power on lm3554 LED flash
[  116.920236] atomisp-isp2 0000:00:03.0: Subdev INTCF1C:00 detection fail
[  116.943649] atomisp-isp2 0000:00:03.0: detected 1 camera sensors
[  116.966177] atomisp-isp2 0000:00:03.0: atomisp_csi_lane_config: the portconfig is 2-1-0, CSI_CONTROL is 0x0002009C
[  117.009054] atomisp-isp2 0000:00:03.0: Entity type for entity ATOM ISP CSI2-port0 was not initialized!
[  117.050772] atomisp-isp2 0000:00:03.0: Entity type for entity ATOM ISP CSI2-port1 was not initialized!
[  117.050795] atomisp-isp2 0000:00:03.0: Entity type for entity ATOM ISP CSI2-port2 was not initialized!
[  117.134464] atomisp-isp2 0000:00:03.0: Entity type for entity file_input_subdev was not initialized!
[  117.176572] atomisp-isp2 0000:00:03.0: Entity type for entity tpg_subdev was not initialized!
[  117.202301] atomisp-isp2 0000:00:03.0: Entity type for entity ATOMISP_SUBDEV_0 was not initialized!
[  117.246734] atomisp-isp2 0000:00:03.0: Entity type for entity ATOMISP_SUBDEV_1 was not initialized!
[  117.290990] atomisp-isp2 0000:00:03.0: FILE_INPUT enable, camera_cnt: 1
[  117.314607] atomisp-isp2 0000:00:03.0: TPG detected, camera_cnt: 2
[  117.341386] atomisp-isp2 0000:00:03.0: atomisp_save_iunit_reg
[  117.363735] atomisp-isp2 0000:00:03.0: DFS target frequency=200.
[  117.386272] atomisp-isp2 0000:00:03.0: Programming DFS frequency to 200
[  117.409426] atomisp-isp2 0000:00:03.0: waiting for ISPSSPM1 valid bit to be 0.
[  117.433323] atomisp-isp2 0000:00:03.0: waiting for ISPSSPM1 valid bit to be 0.
[  117.457139] atomisp-isp2 0000:00:03.0: atomisp_ospm_dphy_down
[  117.479800] atomisp-isp2 0000:00:03.0: binary #0  type SP: sp
[  117.502001] atomisp-isp2 0000:00:03.0: binary #1  type ISP (Normal), binary id is  0: isp_copy_var
[  117.542907] atomisp-isp2 0000:00:03.0: binary #2  type ISP (Normal), binary id is  2: isp_vf_pp_full
[  117.584666] atomisp-isp2 0000:00:03.0: binary #3  type ISP (Normal), binary id is  3: isp_vf_pp_opt
[  117.626806] atomisp-isp2 0000:00:03.0: binary #4  type ISP (Normal), binary id is 60: isp_capture_pp_var_bli
[  117.670360] atomisp-isp2 0000:00:03.0: binary #5  type ISP (Normal), binary id is 61: isp_capture_pp_ldc
[  117.713655] atomisp-isp2 0000:00:03.0: binary #6  type ISP (Normal), binary id is  5: isp_capture_pp_var
[  117.757345] atomisp-isp2 0000:00:03.0: binary #7  type ISP (Normal), binary id is  4: isp_yuv_scale_var
[  117.801371] atomisp-isp2 0000:00:03.0: binary #8  type ISP (Normal), binary id is  6: isp_preisp_var
[  117.845621] atomisp-isp2 0000:00:03.0: binary #9  type ISP (Normal), binary id is  7: isp_preisp_var_isp2
[  117.890913] atomisp-isp2 0000:00:03.0: binary #10 type ISP (Normal), binary id is 58: isp_pre_de_var_isp2
[  117.936321] atomisp-isp2 0000:00:03.0: binary #11 type ISP (Normal), binary id is  8: isp_gdc_var
[  117.963840] atomisp-isp2 0000:00:03.0: binary #12 type ISP (Normal), binary id is 11: isp_anr_var
[  117.991190] atomisp-isp2 0000:00:03.0: binary #13 type ISP (Normal), binary id is 12: isp_anr_var_isp2
[  118.035988] atomisp-isp2 0000:00:03.0: binary #14 type ISP (Normal), binary id is  9: isp_postisp_var
[  118.081148] atomisp-isp2 0000:00:03.0: binary #15 type ISP (Normal), binary id is 10: isp_postisp_var_isp2
[  118.127374] atomisp-isp2 0000:00:03.0: binary #16 type ISP (Normal), binary id is 15: isp_preview_dec
[  118.173707] atomisp-isp2 0000:00:03.0: binary #17 type ISP (Normal), binary id is 16: isp_preview_cont_bds125_isp2
[  118.221920] atomisp-isp2 0000:00:03.0: binary #18 type ISP (Normal), binary id is 18: isp_preview_cont_bds150_isp2
[  118.270412] atomisp-isp2 0000:00:03.0: binary #19 type ISP (Normal), binary id is 20: isp_preview_cont_bds200_isp2
[  118.318942] atomisp-isp2 0000:00:03.0: binary #20 type ISP (Normal), binary id is 21: isp_preview_var
[  118.366572] atomisp-isp2 0000:00:03.0: binary #21 type ISP (Normal), binary id is 22: isp_preview_var_isp2
[  118.415086] atomisp-isp2 0000:00:03.0: binary #22 type ISP (Normal), binary id is 27: isp_primary_striped
[  118.464002] atomisp-isp2 0000:00:03.0: binary #23 type ISP (Normal), binary id is 28: isp_primary_striped_isp2
[  118.514097] atomisp-isp2 0000:00:03.0: binary #24 type ISP (Normal), binary id is 24: isp_primary_var
[  118.564053] atomisp-isp2 0000:00:03.0: binary #25 type ISP (Normal), binary id is 25: isp_primary_var_isp2
[  118.615276] atomisp-isp2 0000:00:03.0: binary #26 type ISP (Normal), binary id is 26: isp_primary_small
[  118.666737] atomisp-isp2 0000:00:03.0: binary #27 type ISP (Normal), binary id is 29: isp_primary_8mp
[  118.718346] atomisp-isp2 0000:00:03.0: binary #28 type ISP (Normal), binary id is 30: isp_primary_14mp
[  118.770053] atomisp-isp2 0000:00:03.0: binary #29 type ISP (Normal), binary id is 31: isp_primary_16mp
[  118.821763] atomisp-isp2 0000:00:03.0: binary #30 type ISP (Normal), binary id is 33: isp_primary_isp261_stage0
[  118.874370] atomisp-isp2 0000:00:03.0: binary #31 type ISP (Normal), binary id is 34: isp_primary_isp261_stage1
[  118.926992] atomisp-isp2 0000:00:03.0: binary #32 type ISP (Normal), binary id is 35: isp_primary_isp261_stage2
[  118.979792] atomisp-isp2 0000:00:03.0: binary #33 type ISP (Normal), binary id is 36: isp_primary_isp261_stage3
[  119.032714] atomisp-isp2 0000:00:03.0: binary #34 type ISP (Normal), binary id is 37: isp_primary_isp261_stage4
[  119.085749] atomisp-isp2 0000:00:03.0: binary #35 type ISP (Normal), binary id is 38: isp_primary_isp261_stage5
[  119.139422] atomisp-isp2 0000:00:03.0: binary #36 type ISP (Normal), binary id is 42: isp_video_dz
[  119.192607] atomisp-isp2 0000:00:03.0: binary #37 type ISP (Normal), binary id is 44: isp_video_high
[  119.246768] atomisp-isp2 0000:00:03.0: binary #38 type ISP (Normal), binary id is 45: isp_video_nodz
[  119.301793] atomisp-isp2 0000:00:03.0: binary #39 type ISP (Normal), binary id is 46: isp_video_cont_multibds_isp2_min
[  119.359159] atomisp-isp2 0000:00:03.0: binary #40 type ISP (Normal), binary id is 47: isp_video_cont_bds_300_600_isp2_min
[  119.416880] atomisp-isp2 0000:00:03.0: binary #41 type ISP (Normal), binary id is 49: isp_video_cont_bds150_isp2_min
[  119.474102] atomisp-isp2 0000:00:03.0: binary #42 type ISP (Normal), binary id is 51: isp_video_cont_bds200_isp2_min
[  119.531365] atomisp-isp2 0000:00:03.0: binary #43 type ISP (Normal), binary id is 52: isp_video_cont_nobds_isp2_min
[  119.588595] atomisp-isp2 0000:00:03.0: binary #44 type ISP (Normal), binary id is 53: isp_video_dz_isp2_min
[  119.644981] atomisp-isp2 0000:00:03.0: binary #45 type ISP (Normal), binary id is 54: isp_video_dz_isp2
[  119.701015] atomisp-isp2 0000:00:03.0: binary #46 type ISP (Normal), binary id is 55: isp_video_lp_isp2

Andy Shevchenko (15):
media: atomisp: Replace last use of Intel MID APIs
media: atomisp: move CCK endpoint address to generic header
media: atomisp: Use proper APIs to find I²C client device by ACPI HID
media: atomisp: don't pass struct device_driver as parameter
media: atomisp: Get rid of struct pci_dev in struct atomisp_device
media: atomisp: Unify pdev to be pointer to struct pci_device
media: atomisp: Replace direct access to MMIO with proper helpers
media: atomisp: Drop global atomisp_dev variable (easy cases)
media: atomisp: make platform data more readable
media: atomisp: Don't try to parse unexpected ACPI object type
media: atomisp: Make pointer to PMIC client global
media: atomisp: Refactor PMIC detection to a separate function.
media: atomisp: Provide Gmin subdev as parameter to gmin_subdev_add()
media: atomisp: Get rid of ugly and leaky ACPI handling in
gmin_subdev_add()
media: atomisp: Deduplicate return ret in gmin_i2c_write()

Quoted 17 lines
 arch/x86/include/asm/iosf_mbi.h               |   1 +
 .../atomisp/include/linux/atomisp_platform.h  |   1 +
 .../staging/media/atomisp/pci/atomisp-regs.h  |   3 -
 .../staging/media/atomisp/pci/atomisp_acc.c   |   4 +-
 .../staging/media/atomisp/pci/atomisp_cmd.c   |  57 ++--
 .../staging/media/atomisp/pci/atomisp_cmd.h   |   4 +-
 .../media/atomisp/pci/atomisp_compat.h        |   2 -
 .../media/atomisp/pci/atomisp_compat_css20.c  |  64 ++--
 .../media/atomisp/pci/atomisp_compat_css20.h  |   2 +-
 .../staging/media/atomisp/pci/atomisp_drvfs.c |  14 +-
 .../staging/media/atomisp/pci/atomisp_drvfs.h |   2 +-
 .../media/atomisp/pci/atomisp_gmin_platform.c | 220 +++++++-------
 .../media/atomisp/pci/atomisp_internal.h      |   2 +-
 .../staging/media/atomisp/pci/atomisp_ioctl.c |  19 +-
 .../staging/media/atomisp/pci/atomisp_v4l2.c  | 277 ++++++++----------
 15 files changed, 311 insertions(+), 361 deletions(-)

Thanks,
Mauro

#17 lore raw

Em Fri, 26 Jun 2020 15:29:53 +0200
Mauro Carvalho Chehab <[email protected]> escreveu:

Quoted 13 lines

Hi Andy,

Em Fri, 26 Jun 2020 15:19:10 +0300
Andy Shevchenko <[email protected]> escreveu:

Quoted 2 lines

I'm experimenting with it on Baytrail machine and found some issues. Along with fixing them I cleaned up a bit this.

Thanks for that! Yeah, I found some issues there myself, although testing on a device with more than one camera is very nice.

I'll apply your patches on the top of my atomisp tree:

Quoted 93 lines

https://git.linuxtv.org/mchehab/experimental.git/log/?h=atomisp_v5

On a very quick look, I suspect that some may rise some conflicts, as I did some improvements at the detection logic, in order to get rid of the ugly DMI match stuff when ACPI has what's needed.

Regards,
Mauro

Quoted 84 lines

So, after applying I have the following log

# modprobe atomisp
[  116.215056] atomisp: module is from the staging directory, the quality is unknown, you have been warned.
[  116.310077] atomisp-isp2 0000:00:03.0: Detected Baytrail version 15 (ISP2400) on VALLEYVIEW C0 (CR) PLATFORM
[  116.354189] atomisp-isp2 0000:00:03.0: start: 0x50000000
[  116.376888] atomisp-isp2 0000:00:03.0: atomisp mmio base: 0000000027f9eb1f
[  116.401267] ACPI: \: failed to evaluate _DSM (0x1001)
[  116.423479] atomisp-isp2 0000:00:03.0: Failed to find EFI variable 0000:00:03.0_HpllFreq
[  116.449254] atomisp-isp2 0000:00:03.0: HpllFreq: using default (2000)
[  116.473045] atomisp-isp2 0000:00:03.0: ISP HPLL frequency base = 2000 MHz
[  116.770613] atomisp-isp2 0000:00:03.0: Probing Subdev INT33F8:00
[  116.793750] atomisp-isp2 0000:00:03.0: Subdev INT33F8:00 successfully register
[  116.818155] atomisp-isp2 0000:00:03.0: raw_index: -1
[  116.839924] atomisp-isp2 0000:00:03.0: SOC_INDEX: 0
[  116.861622] atomisp-isp2 0000:00:03.0: Probing Subdev INTCF1C:00
[  116.896885] lm3554 i2c-INTCF1C:00: Failed to power on lm3554 LED flash
[  116.920236] atomisp-isp2 0000:00:03.0: Subdev INTCF1C:00 detection fail
[  116.943649] atomisp-isp2 0000:00:03.0: detected 1 camera sensors
[  116.966177] atomisp-isp2 0000:00:03.0: atomisp_csi_lane_config: the portconfig is 2-1-0, CSI_CONTROL is 0x0002009C
[  117.009054] atomisp-isp2 0000:00:03.0: Entity type for entity ATOM ISP CSI2-port0 was not initialized!
[  117.050772] atomisp-isp2 0000:00:03.0: Entity type for entity ATOM ISP CSI2-port1 was not initialized!
[  117.050795] atomisp-isp2 0000:00:03.0: Entity type for entity ATOM ISP CSI2-port2 was not initialized!
[  117.134464] atomisp-isp2 0000:00:03.0: Entity type for entity file_input_subdev was not initialized!
[  117.176572] atomisp-isp2 0000:00:03.0: Entity type for entity tpg_subdev was not initialized!
[  117.202301] atomisp-isp2 0000:00:03.0: Entity type for entity ATOMISP_SUBDEV_0 was not initialized!
[  117.246734] atomisp-isp2 0000:00:03.0: Entity type for entity ATOMISP_SUBDEV_1 was not initialized!
[  117.290990] atomisp-isp2 0000:00:03.0: FILE_INPUT enable, camera_cnt: 1
[  117.314607] atomisp-isp2 0000:00:03.0: TPG detected, camera_cnt: 2
[  117.341386] atomisp-isp2 0000:00:03.0: atomisp_save_iunit_reg
[  117.363735] atomisp-isp2 0000:00:03.0: DFS target frequency=200.
[  117.386272] atomisp-isp2 0000:00:03.0: Programming DFS frequency to 200
[  117.409426] atomisp-isp2 0000:00:03.0: waiting for ISPSSPM1 valid bit to be 0.
[  117.433323] atomisp-isp2 0000:00:03.0: waiting for ISPSSPM1 valid bit to be 0.
[  117.457139] atomisp-isp2 0000:00:03.0: atomisp_ospm_dphy_down
[  117.479800] atomisp-isp2 0000:00:03.0: binary #0  type SP: sp
[  117.502001] atomisp-isp2 0000:00:03.0: binary #1  type ISP (Normal), binary id is  0: isp_copy_var
[  117.542907] atomisp-isp2 0000:00:03.0: binary #2  type ISP (Normal), binary id is  2: isp_vf_pp_full
[  117.584666] atomisp-isp2 0000:00:03.0: binary #3  type ISP (Normal), binary id is  3: isp_vf_pp_opt
[  117.626806] atomisp-isp2 0000:00:03.0: binary #4  type ISP (Normal), binary id is 60: isp_capture_pp_var_bli
[  117.670360] atomisp-isp2 0000:00:03.0: binary #5  type ISP (Normal), binary id is 61: isp_capture_pp_ldc
[  117.713655] atomisp-isp2 0000:00:03.0: binary #6  type ISP (Normal), binary id is  5: isp_capture_pp_var
[  117.757345] atomisp-isp2 0000:00:03.0: binary #7  type ISP (Normal), binary id is  4: isp_yuv_scale_var
[  117.801371] atomisp-isp2 0000:00:03.0: binary #8  type ISP (Normal), binary id is  6: isp_preisp_var
[  117.845621] atomisp-isp2 0000:00:03.0: binary #9  type ISP (Normal), binary id is  7: isp_preisp_var_isp2
[  117.890913] atomisp-isp2 0000:00:03.0: binary #10 type ISP (Normal), binary id is 58: isp_pre_de_var_isp2
[  117.936321] atomisp-isp2 0000:00:03.0: binary #11 type ISP (Normal), binary id is  8: isp_gdc_var
[  117.963840] atomisp-isp2 0000:00:03.0: binary #12 type ISP (Normal), binary id is 11: isp_anr_var
[  117.991190] atomisp-isp2 0000:00:03.0: binary #13 type ISP (Normal), binary id is 12: isp_anr_var_isp2
[  118.035988] atomisp-isp2 0000:00:03.0: binary #14 type ISP (Normal), binary id is  9: isp_postisp_var
[  118.081148] atomisp-isp2 0000:00:03.0: binary #15 type ISP (Normal), binary id is 10: isp_postisp_var_isp2
[  118.127374] atomisp-isp2 0000:00:03.0: binary #16 type ISP (Normal), binary id is 15: isp_preview_dec
[  118.173707] atomisp-isp2 0000:00:03.0: binary #17 type ISP (Normal), binary id is 16: isp_preview_cont_bds125_isp2
[  118.221920] atomisp-isp2 0000:00:03.0: binary #18 type ISP (Normal), binary id is 18: isp_preview_cont_bds150_isp2
[  118.270412] atomisp-isp2 0000:00:03.0: binary #19 type ISP (Normal), binary id is 20: isp_preview_cont_bds200_isp2
[  118.318942] atomisp-isp2 0000:00:03.0: binary #20 type ISP (Normal), binary id is 21: isp_preview_var
[  118.366572] atomisp-isp2 0000:00:03.0: binary #21 type ISP (Normal), binary id is 22: isp_preview_var_isp2
[  118.415086] atomisp-isp2 0000:00:03.0: binary #22 type ISP (Normal), binary id is 27: isp_primary_striped
[  118.464002] atomisp-isp2 0000:00:03.0: binary #23 type ISP (Normal), binary id is 28: isp_primary_striped_isp2
[  118.514097] atomisp-isp2 0000:00:03.0: binary #24 type ISP (Normal), binary id is 24: isp_primary_var
[  118.564053] atomisp-isp2 0000:00:03.0: binary #25 type ISP (Normal), binary id is 25: isp_primary_var_isp2
[  118.615276] atomisp-isp2 0000:00:03.0: binary #26 type ISP (Normal), binary id is 26: isp_primary_small
[  118.666737] atomisp-isp2 0000:00:03.0: binary #27 type ISP (Normal), binary id is 29: isp_primary_8mp
[  118.718346] atomisp-isp2 0000:00:03.0: binary #28 type ISP (Normal), binary id is 30: isp_primary_14mp
[  118.770053] atomisp-isp2 0000:00:03.0: binary #29 type ISP (Normal), binary id is 31: isp_primary_16mp
[  118.821763] atomisp-isp2 0000:00:03.0: binary #30 type ISP (Normal), binary id is 33: isp_primary_isp261_stage0
[  118.874370] atomisp-isp2 0000:00:03.0: binary #31 type ISP (Normal), binary id is 34: isp_primary_isp261_stage1
[  118.926992] atomisp-isp2 0000:00:03.0: binary #32 type ISP (Normal), binary id is 35: isp_primary_isp261_stage2
[  118.979792] atomisp-isp2 0000:00:03.0: binary #33 type ISP (Normal), binary id is 36: isp_primary_isp261_stage3
[  119.032714] atomisp-isp2 0000:00:03.0: binary #34 type ISP (Normal), binary id is 37: isp_primary_isp261_stage4
[  119.085749] atomisp-isp2 0000:00:03.0: binary #35 type ISP (Normal), binary id is 38: isp_primary_isp261_stage5
[  119.139422] atomisp-isp2 0000:00:03.0: binary #36 type ISP (Normal), binary id is 42: isp_video_dz
[  119.192607] atomisp-isp2 0000:00:03.0: binary #37 type ISP (Normal), binary id is 44: isp_video_high
[  119.246768] atomisp-isp2 0000:00:03.0: binary #38 type ISP (Normal), binary id is 45: isp_video_nodz
[  119.301793] atomisp-isp2 0000:00:03.0: binary #39 type ISP (Normal), binary id is 46: isp_video_cont_multibds_isp2_min
[  119.359159] atomisp-isp2 0000:00:03.0: binary #40 type ISP (Normal), binary id is 47: isp_video_cont_bds_300_600_isp2_min
[  119.416880] atomisp-isp2 0000:00:03.0: binary #41 type ISP (Normal), binary id is 49: isp_video_cont_bds150_isp2_min
[  119.474102] atomisp-isp2 0000:00:03.0: binary #42 type ISP (Normal), binary id is 51: isp_video_cont_bds200_isp2_min
[  119.531365] atomisp-isp2 0000:00:03.0: binary #43 type ISP (Normal), binary id is 52: isp_video_cont_nobds_isp2_min
[  119.588595] atomisp-isp2 0000:00:03.0: binary #44 type ISP (Normal), binary id is 53: isp_video_dz_isp2_min
[  119.644981] atomisp-isp2 0000:00:03.0: binary #45 type ISP (Normal), binary id is 54: isp_video_dz_isp2
[  119.701015] atomisp-isp2 0000:00:03.0: binary #46 type ISP (Normal), binary id is 55: isp_video_lp_isp2

Ok, I merged the patches on my atomisp tree:

https://git.linuxtv.org/mchehab/experimental.git/log/?h=atomisp_v5

I'll wait for Sakari's review on them (and on my patches) before applying on media master tree.

As some of the stuff here are fixes (and this driver is new for 5.8), I'll probably submit them to v5.8-rc.

Quoted 12 lines
Quoted 12 lines

Andy Shevchenko (15):
media: atomisp: Replace last use of Intel MID APIs
media: atomisp: move CCK endpoint address to generic header
media: atomisp: Use proper APIs to find I²C client device by ACPI HID
media: atomisp: don't pass struct device_driver as parameter
media: atomisp: Get rid of struct pci_dev in struct atomisp_device
media: atomisp: Unify pdev to be pointer to struct pci_device
media: atomisp: Replace direct access to MMIO with proper helpers
media: atomisp: Drop global atomisp_dev variable (easy cases)
media: atomisp: make platform data more readable
media: atomisp: Don't try to parse unexpected ACPI object type

The above patches applied fine.

Quoted 1 line
Quoted 1 line

media: atomisp: Make pointer to PMIC client global

I had to rebase this one, but also applied fine.

Quoted 2 lines
Quoted 2 lines

media: atomisp: Refactor PMIC detection to a separate function.
media: atomisp: Provide Gmin subdev as parameter to gmin_subdev_add()

Could you please rebase those on the top of my atomisp branch?

Quoted 2 lines
Quoted 2 lines

media: atomisp: Get rid of ugly and leaky ACPI handling in
gmin_subdev_add()

The part of the code that used to call acpi_bus_get_device() was already removed by a previous patch on my tree. So, I guess this one may not be needed anymore.

Quoted 1 line
Quoted 1 line

media: atomisp: Deduplicate return ret in gmin_i2c_write()

This one also applied as-is.

Thanks,
Mauro

#18 lore raw
Quoted 8 lines · Mauro Carvalho Chehab

Em Fri, 26 Jun 2020 15:29:53 +0200
Mauro Carvalho Chehab <[email protected]> escreveu:

Quoted 5 lines

Em Fri, 26 Jun 2020 15:19:10 +0300
Andy Shevchenko <[email protected]> escreveu:

Quoted 2 lines

media: atomisp: Refactor PMIC detection to a separate function.
media: atomisp: Provide Gmin subdev as parameter to gmin_subdev_add()

Quoted 8 lines

Could you please rebase those on the top of my atomisp branch?

Quoted 2 lines
Quoted 2 lines

media: atomisp: Get rid of ugly and leaky ACPI handling in
gmin_subdev_add()

The part of the code that used to call acpi_bus_get_device() was already removed by a previous patch on my tree. So, I guess this one may not be needed anymore.

Mentioned above have been rebased and I'm about to send a v2.

Signature · 2 lines
With Best Regards,
Andy Shevchenko