* [PATCH v3 1/5] media: atomisp: Refactor PMIC detection to a separate function
@ 2020-06-29 10:57 Andy Shevchenko
2020-06-29 10:57 ` [PATCH v3 2/5] media: atomisp: Use temporary variable for device in gmin_subdev_add() Andy Shevchenko
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Andy Shevchenko @ 2020-06-29 10:57 UTC (permalink / raw)
To: Mauro Carvalho Chehab, linux-media, Sakari Ailus; +Cc: Andy Shevchenko
Refactor PMIC detection to a separate function. In the future
we may move this code somewhere else where it's more suitable.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
.../media/atomisp/pci/atomisp_gmin_platform.c | 59 +++++++++++--------
1 file changed, 36 insertions(+), 23 deletions(-)
diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
index 3856e164e478..7f846a61858d 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
@@ -478,7 +478,38 @@ static int atomisp_get_acpi_power(struct device *dev, acpi_handle handle)
return clock_num;
}
-static struct i2c_client *power;
+static u8 gmin_get_pmic_id_and_addr(struct device *dev)
+{
+ struct i2c_client *power;
+ static u8 pmic_i2c_addr;
+
+ if (pmic_id)
+ return pmic_i2c_addr;
+
+ 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;
+
+ pmic_i2c_addr = power ? power->addr : 0;
+ return pmic_i2c_addr;
+}
+
+static int gmin_detect_pmic(struct v4l2_subdev *subdev)
+{
+ struct i2c_client *client = v4l2_get_subdevdata(subdev);
+ struct device *dev = &client->dev;
+ u8 pmic_i2c_addr;
+
+ pmic_i2c_addr = gmin_get_pmic_id_and_addr(dev);
+ dev_info(dev, "gmin: power management provided via %s (i2c addr 0x%02x)\n",
+ pmic_name[pmic_id], pmic_i2c_addr);
+ return pmic_i2c_addr;
+}
static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
{
@@ -593,27 +624,6 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
* in order to set clocks and do power management.
*/
- 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;
- }
-
- if (power) {
- gs->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);
- } else {
- dev_info(dev, "gmin: power management provided via %s\n",
- pmic_name[pmic_id]);
- }
-
/*
* According with :
* https://github.com/projectceladon/hardware-intel-kernelflinger/blob/master/doc/fastboot.md
@@ -1066,10 +1076,13 @@ struct camera_sensor_platform_data *gmin_camera_platform_data(
enum atomisp_input_format csi_format,
enum atomisp_bayer_order csi_bayer)
{
- struct gmin_subdev *gs = gmin_subdev_add(subdev);
+ struct gmin_subdev *gs;
+ u8 pmic_i2c_addr = gmin_detect_pmic(subdev);
+ gs = gmin_subdev_add(subdev);
gs->csi_fmt = csi_format;
gs->csi_bayer = csi_bayer;
+ gs->pwm_i2c_addr = pmic_i2c_addr;
if (gs->pmc_clk)
return &pmic_gmin_plat;
--
2.27.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 2/5] media: atomisp: Use temporary variable for device in gmin_subdev_add()
2020-06-29 10:57 [PATCH v3 1/5] media: atomisp: Refactor PMIC detection to a separate function Andy Shevchenko
@ 2020-06-29 10:57 ` Andy Shevchenko
2020-06-29 10:57 ` [PATCH v3 3/5] media: atomisp: Provide Gmin subdev as parameter to gmin_subdev_add() Andy Shevchenko
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2020-06-29 10:57 UTC (permalink / raw)
To: Mauro Carvalho Chehab, linux-media, Sakari Ailus; +Cc: Andy Shevchenko
Use temporary variable for device in gmin_subdev_add().
While here, drop unused temporary variable for device in other places.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
.../media/atomisp/pci/atomisp_gmin_platform.c | 17 ++---------------
1 file changed, 2 insertions(+), 15 deletions(-)
diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
index 7f846a61858d..aa4424a60e92 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
@@ -514,19 +514,14 @@ static int gmin_detect_pmic(struct v4l2_subdev *subdev)
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;
struct gmin_subdev *gs;
acpi_handle handle;
- struct device *dev;
int i, ret, clock_num = -1;
- if (!client)
- return NULL;
-
- dev = &client->dev;
-
handle = ACPI_HANDLE(dev);
- adev = ACPI_COMPANION(&client->dev);
+ adev = ACPI_COMPANION(dev);
dev_info(&client->dev, "%s: ACPI detected it on bus ID=%s, HID=%s\n",
__func__, acpi_device_bid(adev), acpi_device_hid(adev));
@@ -842,12 +837,8 @@ static int gmin_v1p8_ctrl(struct v4l2_subdev *subdev, int on)
{
struct gmin_subdev *gs = find_gmin_subdev(subdev);
int ret;
- struct device *dev;
- struct i2c_client *client = v4l2_get_subdevdata(subdev);
int value;
- dev = &client->dev;
-
if (gs->v1p8_gpio >= 0) {
pr_info("atomisp_gmin_platform: 1.8v power on GPIO %d\n",
gs->v1p8_gpio);
@@ -900,12 +891,8 @@ static int gmin_v2p8_ctrl(struct v4l2_subdev *subdev, int on)
{
struct gmin_subdev *gs = find_gmin_subdev(subdev);
int ret;
- struct device *dev;
- struct i2c_client *client = v4l2_get_subdevdata(subdev);
int value;
- dev = &client->dev;
-
if (gs->v2p8_gpio >= 0) {
pr_info("atomisp_gmin_platform: 2.8v power on GPIO %d\n",
gs->v2p8_gpio);
--
2.27.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 3/5] media: atomisp: Provide Gmin subdev as parameter to gmin_subdev_add()
2020-06-29 10:57 [PATCH v3 1/5] media: atomisp: Refactor PMIC detection to a separate function Andy Shevchenko
2020-06-29 10:57 ` [PATCH v3 2/5] media: atomisp: Use temporary variable for device in gmin_subdev_add() Andy Shevchenko
@ 2020-06-29 10:57 ` Andy Shevchenko
2020-06-29 10:57 ` [PATCH v3 4/5] media: atomisp: Get rid of ACPI specifics in gmin_subdev_add() Andy Shevchenko
2020-06-29 10:57 ` [PATCH v3 5/5] media: atomisp: Clean up non-existing folders from Makefile Andy Shevchenko
3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2020-06-29 10:57 UTC (permalink / raw)
To: Mauro Carvalho Chehab, linux-media, Sakari Ailus; +Cc: Andy Shevchenko
Provide Gmin subdev as parameter to gmin_subdev_add()
to avoid direct global variable usage.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
.../media/atomisp/pci/atomisp_gmin_platform.c | 47 +++++++++----------
1 file changed, 22 insertions(+), 25 deletions(-)
diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
index aa4424a60e92..8e66fe6f407e 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
@@ -511,14 +511,13 @@ static int gmin_detect_pmic(struct v4l2_subdev *subdev)
return pmic_i2c_addr;
}
-static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
+static int gmin_subdev_add(struct gmin_subdev *gs)
{
- struct i2c_client *client = v4l2_get_subdevdata(subdev);
+ struct i2c_client *client = v4l2_get_subdevdata(gs->subdev);
struct device *dev = &client->dev;
struct acpi_device *adev;
- struct gmin_subdev *gs;
acpi_handle handle;
- int i, ret, clock_num = -1;
+ int ret, clock_num = -1;
handle = ACPI_HANDLE(dev);
adev = ACPI_COMPANION(dev);
@@ -526,14 +525,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));
- for (i = 0; i < MAX_SUBDEVS && gmin_subdevs[i].subdev; i++)
- ;
- if (i >= MAX_SUBDEVS)
- return NULL;
-
- gs = &gmin_subdevs[i];
- gs->subdev = subdev;
-
/*
* FIXME:
* WA:CHT requires XTAL clock as PLL is not stable.
@@ -609,8 +600,7 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
acpi_device_can_poweroff(adev)) {
dev_info(dev,
"gmin: power management provided via device PM\n");
-
- return gs;
+ return 0;
}
/*
@@ -643,7 +633,7 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
if (clock_num < 0 || clock_num > MAX_CLK_COUNT) {
dev_err(dev, "Invalid clock number\n");
- return NULL;
+ return -EINVAL;
}
snprintf(gmin_pmc_clk_name, sizeof(gmin_pmc_clk_name),
@@ -652,13 +642,8 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
gs->pmc_clk = devm_clk_get(dev, gmin_pmc_clk_name);
if (IS_ERR(gs->pmc_clk)) {
ret = PTR_ERR(gs->pmc_clk);
-
- dev_err(dev,
- "Failed to get clk from %s : %d\n",
- gmin_pmc_clk_name,
- ret);
-
- return NULL;
+ dev_err(dev, "Failed to get clk from %s: %d\n", gmin_pmc_clk_name, ret);
+ return ret;
}
dev_info(dev, "Will use CLK%d (%s)\n", clock_num, gmin_pmc_clk_name);
@@ -718,7 +703,7 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
break;
}
- return gs;
+ return 0;
}
static struct gmin_subdev *find_gmin_subdev(struct v4l2_subdev *subdev)
@@ -731,6 +716,16 @@ static struct gmin_subdev *find_gmin_subdev(struct v4l2_subdev *subdev)
return NULL;
}
+static struct gmin_subdev *find_free_gmin_subdev_slot(void)
+{
+ unsigned int i;
+
+ for (i = 0; i < MAX_SUBDEVS; i++)
+ if (gmin_subdevs[i].subdev == NULL)
+ return &gmin_subdevs[i];
+ return NULL;
+}
+
static int axp_regulator_set(struct device *dev, struct gmin_subdev *gs,
int sel_reg, u8 setting,
int ctrl_reg, int shift, bool on)
@@ -1063,14 +1058,16 @@ struct camera_sensor_platform_data *gmin_camera_platform_data(
enum atomisp_input_format csi_format,
enum atomisp_bayer_order csi_bayer)
{
- struct gmin_subdev *gs;
u8 pmic_i2c_addr = gmin_detect_pmic(subdev);
+ struct gmin_subdev *gs;
- gs = gmin_subdev_add(subdev);
+ gs = find_free_gmin_subdev_slot();
+ gs->subdev = subdev;
gs->csi_fmt = csi_format;
gs->csi_bayer = csi_bayer;
gs->pwm_i2c_addr = pmic_i2c_addr;
+ gmin_subdev_add(gs);
if (gs->pmc_clk)
return &pmic_gmin_plat;
else
--
2.27.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 4/5] media: atomisp: Get rid of ACPI specifics in gmin_subdev_add()
2020-06-29 10:57 [PATCH v3 1/5] media: atomisp: Refactor PMIC detection to a separate function Andy Shevchenko
2020-06-29 10:57 ` [PATCH v3 2/5] media: atomisp: Use temporary variable for device in gmin_subdev_add() Andy Shevchenko
2020-06-29 10:57 ` [PATCH v3 3/5] media: atomisp: Provide Gmin subdev as parameter to gmin_subdev_add() Andy Shevchenko
@ 2020-06-29 10:57 ` Andy Shevchenko
2020-06-29 10:57 ` [PATCH v3 5/5] media: atomisp: Clean up non-existing folders from Makefile Andy Shevchenko
3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2020-06-29 10:57 UTC (permalink / raw)
To: Mauro Carvalho Chehab, linux-media, Sakari Ailus; +Cc: 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.
Besides that, drop ACPI handle from atomisp_get_acpi_power() parameters.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
.../media/atomisp/pci/atomisp_gmin_platform.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
index 8e66fe6f407e..63a812ac2b43 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
@@ -423,12 +423,13 @@ static int gmin_i2c_write(struct device *dev, u16 i2c_addr, u8 reg,
return ret;
}
-static int atomisp_get_acpi_power(struct device *dev, acpi_handle handle)
+static int atomisp_get_acpi_power(struct device *dev)
{
char name[5];
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
struct acpi_buffer b_name = { sizeof(name), name };
union acpi_object *package, *element;
+ acpi_handle handle = ACPI_HANDLE(dev);
acpi_handle rhandle;
acpi_status status;
int clock_num = -1;
@@ -515,15 +516,10 @@ static int gmin_subdev_add(struct gmin_subdev *gs)
{
struct i2c_client *client = v4l2_get_subdevdata(gs->subdev);
struct device *dev = &client->dev;
- struct acpi_device *adev;
- acpi_handle handle;
+ struct acpi_device *adev = ACPI_COMPANION(dev);
int ret, clock_num = -1;
- handle = ACPI_HANDLE(dev);
- adev = ACPI_COMPANION(dev);
-
- 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(dev, "%s: ACPI path is %pfw\n", __func__, dev_fwnode(dev));
/*
* FIXME:
@@ -625,7 +621,7 @@ static int gmin_subdev_add(struct gmin_subdev *gs)
/* Try first to use ACPI to get the clock resource */
if (acpi_device_power_manageable(adev))
- clock_num = atomisp_get_acpi_power(dev, handle);
+ clock_num = atomisp_get_acpi_power(dev);
/* Fall-back use EFI and/or DMI match */
if (clock_num < 0)
--
2.27.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 5/5] media: atomisp: Clean up non-existing folders from Makefile
2020-06-29 10:57 [PATCH v3 1/5] media: atomisp: Refactor PMIC detection to a separate function Andy Shevchenko
` (2 preceding siblings ...)
2020-06-29 10:57 ` [PATCH v3 4/5] media: atomisp: Get rid of ACPI specifics in gmin_subdev_add() Andy Shevchenko
@ 2020-06-29 10:57 ` Andy Shevchenko
3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2020-06-29 10:57 UTC (permalink / raw)
To: Mauro Carvalho Chehab, linux-media, Sakari Ailus; +Cc: Andy Shevchenko
Compiler is not happy about leftovers:
cc1: warning: .../pci/hrt/: No such file or directory [-Wmissing-include-dirs]
cc1: warning: .../pci/hive_isp_css_include/memory_access/: No such file or directory [-Wmissing-include-dirs]
cc1: warning: .../pci/css_2400_system/hrt/: No such file or directory [-Wmissing-include-dirs]
Drop them from Makefile.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/staging/media/atomisp/Makefile | 5 -----
1 file changed, 5 deletions(-)
diff --git a/drivers/staging/media/atomisp/Makefile b/drivers/staging/media/atomisp/Makefile
index 41a5656da85c..9e5a29c6fb71 100644
--- a/drivers/staging/media/atomisp/Makefile
+++ b/drivers/staging/media/atomisp/Makefile
@@ -182,7 +182,6 @@ INCLUDES += \
-I$(atomisp)/include/hmm/ \
-I$(atomisp)/include/mmu/ \
-I$(atomisp)/pci/ \
- -I$(atomisp)/pci/hrt/ \
-I$(atomisp)/pci/base/circbuf/interface/ \
-I$(atomisp)/pci/base/refcount/interface/ \
-I$(atomisp)/pci/camera/pipe/interface/ \
@@ -192,7 +191,6 @@ INCLUDES += \
-I$(atomisp)/pci/hive_isp_css_include/ \
-I$(atomisp)/pci/hive_isp_css_include/device_access/ \
-I$(atomisp)/pci/hive_isp_css_include/host/ \
- -I$(atomisp)/pci/hive_isp_css_include/memory_access/ \
-I$(atomisp)/pci/hive_isp_css_shared/ \
-I$(atomisp)/pci/hive_isp_css_shared/host/ \
-I$(atomisp)/pci/isp/kernels/ \
@@ -311,9 +309,7 @@ INCLUDES += \
-I$(atomisp)/pci/runtime/tagger/interface/
INCLUDES_byt += \
- -I$(atomisp)/pci/css_2400_system/ \
-I$(atomisp)/pci/css_2400_system/hive/ \
- -I$(atomisp)/pci/css_2400_system/hrt/ \
INCLUDES_cht += \
-I$(atomisp)/pci/css_2401_system/ \
@@ -321,7 +317,6 @@ INCLUDES_cht += \
-I$(atomisp)/pci/css_2401_system/hive/ \
-I$(atomisp)/pci/css_2401_system/hrt/ \
-# -I$(atomisp)/pci/css_2401_system/hrt/ \
# -I$(atomisp)/pci/css_2401_system/hive_isp_css_2401_system_generated/ \
DEFINES := -DHRT_HW -DHRT_ISP_CSS_CUSTOM_HOST -DHRT_USE_VIR_ADDRS -D__HOST__
--
2.27.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-06-29 21:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-29 10:57 [PATCH v3 1/5] media: atomisp: Refactor PMIC detection to a separate function Andy Shevchenko
2020-06-29 10:57 ` [PATCH v3 2/5] media: atomisp: Use temporary variable for device in gmin_subdev_add() Andy Shevchenko
2020-06-29 10:57 ` [PATCH v3 3/5] media: atomisp: Provide Gmin subdev as parameter to gmin_subdev_add() Andy Shevchenko
2020-06-29 10:57 ` [PATCH v3 4/5] media: atomisp: Get rid of ACPI specifics in gmin_subdev_add() Andy Shevchenko
2020-06-29 10:57 ` [PATCH v3 5/5] media: atomisp: Clean up non-existing folders from Makefile Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).