Re: [PATCH] platform/x86: amd: Add ISP platform info

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Pratap,

Thank you for your patch.

On 28-Feb-25 18:02, Pratap Nirujogi wrote:
> Add ov05c i2c boardinfo and GPIO pin info for AMD ISP platform.
> 
> Details of the resources added:
> 
> - Added i2c bus number for AMD ISP platform is 99.
> - Added GPIO 85 to allow ISP driver to enable and disable ISP access.
> - Added GPIO 0 to allow sensor driver to enable and disable sensor module.
> 
> Signed-off-by: Pratap Nirujogi <pratap.nirujogi@xxxxxxx>
> ---
>  drivers/platform/x86/amd/Kconfig   | 11 +++++
>  drivers/platform/x86/amd/Makefile  |  1 +
>  drivers/platform/x86/amd/amd_isp.c | 72 ++++++++++++++++++++++++++++++
>  3 files changed, 84 insertions(+)
>  create mode 100644 drivers/platform/x86/amd/amd_isp.c
> 
> diff --git a/drivers/platform/x86/amd/Kconfig b/drivers/platform/x86/amd/Kconfig
> index c3e086ea64fc..4b373edd750d 100644
> --- a/drivers/platform/x86/amd/Kconfig
> +++ b/drivers/platform/x86/amd/Kconfig
> @@ -32,3 +32,14 @@ config AMD_WBRF
>  
>  	  This mechanism will only be activated on platforms that advertise a
>  	  need for it.
> +
> +config AMD_ISP_PLATFORM
> +	bool "AMD platform with ISP4 that supports Camera sensor device"
> +	depends on I2C && X86_64 && AMD_ISP4
> +	help
> +	  For AMD platform that support Image signal processor generation 4, it
> +	  is necessary to add platform specific camera sensor module board info
> +	  which includes the sensor driver device id and the i2c address.
> +
> +	  If you have a AMD platform that support ISP4 and with a sensor
> +	  connected to it, say Y here
> diff --git a/drivers/platform/x86/amd/Makefile b/drivers/platform/x86/amd/Makefile
> index 56f62fc9c97b..0d89e2d4f7e6 100644
> --- a/drivers/platform/x86/amd/Makefile
> +++ b/drivers/platform/x86/amd/Makefile
> @@ -10,3 +10,4 @@ obj-$(CONFIG_AMD_PMC)		+= pmc/
>  obj-$(CONFIG_AMD_HSMP)		+= hsmp/
>  obj-$(CONFIG_AMD_PMF)		+= pmf/
>  obj-$(CONFIG_AMD_WBRF)		+= wbrf.o
> +obj-$(CONFIG_AMD_ISP_PLATFORM)	+= amd_isp.o
> diff --git a/drivers/platform/x86/amd/amd_isp.c b/drivers/platform/x86/amd/amd_isp.c
> new file mode 100644
> index 000000000000..751f209e9509
> --- /dev/null
> +++ b/drivers/platform/x86/amd/amd_isp.c
> @@ -0,0 +1,72 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright 2025 Advanced Micro Devices, Inc.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> + * OTHER DEALINGS IN THE SOFTWARE.
> + */
> +
> +#include <linux/init.h>
> +#include <linux/i2c.h>
> +#include <linux/kernel.h>
> +#include <linux/gpio/machine.h>
> +
> +#define AMDISP_I2C_BUS		99

I'm not a fan of using static i2c-bus numbers for this. static bus numbers are
something of the past and we typically do not use these on x86 anymore.

Using this static number + i2c_register_board_info() also requires this code
to be builtin rather then modular which is also undesirable.

For a more dynamic way of manually adding i2c-devices see:

https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/platform/x86/dell/dell-lis3lv02d.c

But a better question here is why instantiate the sensor i2c device
manually at all.

ACPI has a standardized way to describe I2C-clients which tyically
is used for all I2C devices on ACPI platforms like I2C touchscreens /
touchpads / audio-codecs / accelerometers / etc.
I don't see why the camera sensor on AMD platforms is so special that
it could not be described in ACPI using an ACPI child-device of the
i2c-controller with a ACPI resource (_CRS entry) of the I2cSerialBusV2()
type.

Likewise the sensor enable GPIO should also be described in the ACPI
table as a Gpio type resource in the same _CRS table.

Can you run acpidump -o acpidump.txt on a laptop with this camera
sensor and send me the acpidupm.txt offlist ? Please run this
on a production hardware laptop model using production firmware.

I suspect that Windows will also be using the ACPI description
for the sensor so we really should figure out what Windows is doing
here.

As Mario mentioned we cannot just assume that the GPIOs +
sensor address and model are valid for all laptops. Ideally we should
be getting this information from ACPI rather then hardcoding it
in the kernel.

> +
> +static struct gpiod_lookup_table isp_gpio_table = {
> +	.dev_id = "amd_isp_capture",
> +	.table = {
> +		GPIO_LOOKUP("AMDI0030:00", 85, "enable_isp", GPIO_ACTIVE_HIGH),
> +		{ }
> +	},
> +};

This too really should be an Gpio() type ACPI resource on the ACPI device
node for the ISP.

How/where is this "amd_isp_capture" device created ?

Regards,

Hans


> +
> +static struct gpiod_lookup_table isp_sensor_gpio_table = {
> +	.dev_id = "ov05c",
> +	.table = {
> +		GPIO_LOOKUP("amdisp-pinctrl", 0, "sensor0_enable", GPIO_ACTIVE_HIGH),
> +		{ }
> +	},
> +};
> +
> +static struct i2c_board_info sensor_info = {
> +	.dev_name = "ov05c",
> +	I2C_BOARD_INFO("ov05c", 0x10),
> +};
> +
> +static int __init amd_isp_init(void)
> +{
> +	int ret;
> +
> +	gpiod_add_lookup_table(&isp_gpio_table);
> +	gpiod_add_lookup_table(&isp_sensor_gpio_table);
> +
> +	ret = i2c_register_board_info(AMDISP_I2C_BUS, &sensor_info, 1);
> +	if (ret)
> +		pr_err("%s: cannot register i2c board devices:%s",
> +		       __func__, sensor_info.dev_name);
> +
> +	return ret;
> +}
> +
> +arch_initcall(amd_isp_init);
> +
> +MODULE_AUTHOR("Benjamin Chan <benjamin.chan@xxxxxxx>");
> +MODULE_AUTHOR("Pratap Nirujogi <pratap.nirujogi@xxxxxxx>");
> +MODULE_DESCRIPTION("AMD ISP Platform parameters");
> +MODULE_LICENSE("GPL and additional rights");





[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux