platform/x86: int3472: Add handshake GPIO function
PATCH 1/1 platform/x86: int3472: Add handshake GPIO function
Handshake pin is used for Lattice MIPI aggregator to enable the camera sensor. After pulled up, recommend to wail ~250ms to get everything ready.
--- drivers/platform/x86/intel/int3472/common.h | 1 + drivers/platform/x86/intel/int3472/discrete.c | 5 +++++ 2 files changed, 6 insertions(+)
drivers/platform/x86/intel/int3472/common.h +1 -0
@@ -23,6 +23,7 @@#define INT3472_GPIO_TYPE_POWER_ENABLE 0x0b#define INT3472_GPIO_TYPE_CLK_ENABLE 0x0c#define INT3472_GPIO_TYPE_PRIVACY_LED 0x0d +#define INT3472_GPIO_TYPE_HANDSHAKE 0x12#define INT3472_PDEV_MAX_NAME_LEN 23#define INT3472_MAX_SENSOR_GPIOS 3
drivers/platform/x86/intel/int3472/discrete.c +5 -0
@@ -111,6 +111,10 @@ static void int3472_get_func_and_polarity(u8 type, const char **func, u32 *polar *func ="power-enable" ; *polarity =GPIO_ACTIVE_HIGH ;break ; +case INT3472_GPIO_TYPE_HANDSHAKE : + *func ="handshake" ; + *polarity =GPIO_ACTIVE_HIGH ; +break ;default : *func ="unknown" ; *polarity =GPIO_ACTIVE_HIGH ;
@@ -201,6 +205,7 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,switch (type) {case INT3472_GPIO_TYPE_RESET :case INT3472_GPIO_TYPE_POWERDOWN : +case INT3472_GPIO_TYPE_HANDSHAKE : ret =skl_int3472_map_gpio_to_sensor (int3472, agpio, func, polarity);if (ret) err_msg ="Failed to map GPIO pin to sensor\n" ;
Signature · 1 line
2.34.1
Hao,
Quoted 3 lines · Hao Yao
Handshake pin is used for Lattice MIPI aggregator to enable the camera sensor. After pulled up, recommend to wail ~250ms to get everything ready.
Is the delay for specific camera or requirement from Lattice. 250ms is bad for camera.
Quoted 44 lines
Signed-off-by Hao Yao <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>--- drivers/platform/x86/intel/int3472/common.h | 1 + drivers/platform/x86/intel/int3472/discrete.c | 5 +++++ 2 files changed, 6 insertions(+)drivers/platform/x86/intel/int3472/common.h +1
-0@@ -23,6 +23,7 @@#define INT3472_GPIO_TYPE_POWER_ENABLE 0x0b#define INT3472_GPIO_TYPE_CLK_ENABLE 0x0c#define INT3472_GPIO_TYPE_PRIVACY_LED 0x0d +#define INT3472_GPIO_TYPE_HANDSHAKE 0x12#define INT3472_PDEV_MAX_NAME_LEN 23#define INT3472_MAX_SENSOR_GPIOS 3drivers/platform/x86/intel/int3472/discrete.c +5
-0@@ -111,6 +111,10 @@ static void int3472_get_func_and_polarity(u8 type, const char **func, u32 *polar *func ="power-enable" ; *polarity =GPIO_ACTIVE_HIGH ;break ; +case INT3472_GPIO_TYPE_HANDSHAKE : + *func ="handshake" ; + *polarity =GPIO_ACTIVE_HIGH ; +break ;default : *func ="unknown" ; *polarity =GPIO_ACTIVE_HIGH ;@@ -201,6 +205,7 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,switch (type) {case INT3472_GPIO_TYPE_RESET :case INT3472_GPIO_TYPE_POWERDOWN : +case INT3472_GPIO_TYPE_HANDSHAKE : ret =skl_int3472_map_gpio_to_sensor (int3472, agpio, func, polarity);if (ret) err_msg ="Failed to map GPIO pin to sensor\n" ;
Signature · 2 lines
Best regards, Bingbu Cao
Thank you Bingbu,
Quoted 10 lines · Bingbu Cao
Hao,
Quoted 3 lines · Hao Yao
Handshake pin is used for Lattice MIPI aggregator to enable the camera sensor. After pulled up, recommend to wail ~250ms to get everything ready.
Is the delay for specific camera or requirement from Lattice. 250ms is bad for camera.
Actually the handshake pin is used by both Altek M1 and Lattice chips. As far as I know, Altek M1 required ~250ms delay while recently Lattice team told me they don't need delay. However I don't know if there were any devices using Altek M1.
Quoted 36 lines
Quoted 36 lines
Signed-off-by Hao Yao <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>--- drivers/platform/x86/intel/int3472/common.h | 1 + drivers/platform/x86/intel/int3472/discrete.c | 5 +++++ 2 files changed, 6 insertions(+)drivers/platform/x86/intel/int3472/common.h +1
-0@@ -23,6 +23,7 @@#define INT3472_GPIO_TYPE_POWER_ENABLE 0x0b#define INT3472_GPIO_TYPE_CLK_ENABLE 0x0c#define INT3472_GPIO_TYPE_PRIVACY_LED 0x0d +#define INT3472_GPIO_TYPE_HANDSHAKE 0x12#define INT3472_PDEV_MAX_NAME_LEN 23#define INT3472_MAX_SENSOR_GPIOS 3drivers/platform/x86/intel/int3472/discrete.c +4
-0@@ -111,6 +111,10 @@ static void int3472_get_func_and_polarity(u8 type, const char **func, u32 *polar *func ="power-enable" ; *polarity =GPIO_ACTIVE_HIGH ;break ; +case INT3472_GPIO_TYPE_HANDSHAKE : + *func ="handshake" ; + *polarity =GPIO_ACTIVE_HIGH ; +break ;default : *func ="unknown" ; *polarity =GPIO_ACTIVE_HIGH ;@@ -201,6 +205,7 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
Quoted 9 lines
drivers/platform/x86/intel/int3472/discrete.c static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, · line 211
Quoted 8 lines
drivers/platform/x86/intel/int3472/discrete.c +1
-0switch (type) {case INT3472_GPIO_TYPE_RESET :case INT3472_GPIO_TYPE_POWERDOWN : +case INT3472_GPIO_TYPE_HANDSHAKE : ret =skl_int3472_map_gpio_to_sensor (int3472, agpio, func, polarity);if (ret) err_msg ="Failed to map GPIO pin to sensor\n" ;
Best Regards,
Hao Yao
Hi,
Quoted 3 lines · Hao Yao
Handshake pin is used for Lattice MIPI aggregator to enable the camera sensor. After pulled up, recommend to wail ~250ms to get everything ready.
If this is a pin on the "Lattice MIPI aggregator" and not on the sensor itself then this really should be modeled as such and should not be registered as a GPIO consumed by the sensor since the actual sensor does not have a handshake pin at all.
Also we really don't want to need to patch all involved sensor drivers to toggle a handshake pin, especially since the sensor itself does not physically have this pin.
Can you explain a bit more:
1. What the "Lattice MIPI aggregator" is
2. What its functions are, does this control reset + pwdn GPIOs for the sensor? Voltages to the sensor? Clk to the sensor ?
3. How the aggregator is connected to both the main CPU/SoC as well as how it is connected to the sensor ? Some example diagram would be really helpful here.
Then with this info in hand we can try to come up with a way how to model this.
Assuming this controls the entire power-up sequence for the sensor then I think it could be modelled as a GPIO regulator. This also allows making the regulator core take care of the necessary delay between setting the GPIO and trying to talk to the sensor.
Regards,
Hans
Quoted 43 lines
Signed-off-by Hao Yao <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>--- drivers/platform/x86/intel/int3472/common.h | 1 + drivers/platform/x86/intel/int3472/discrete.c | 5 +++++ 2 files changed, 6 insertions(+)drivers/platform/x86/intel/int3472/common.h +1
-0@@ -23,6 +23,7 @@#define INT3472_GPIO_TYPE_POWER_ENABLE 0x0b#define INT3472_GPIO_TYPE_CLK_ENABLE 0x0c#define INT3472_GPIO_TYPE_PRIVACY_LED 0x0d +#define INT3472_GPIO_TYPE_HANDSHAKE 0x12#define INT3472_PDEV_MAX_NAME_LEN 23#define INT3472_MAX_SENSOR_GPIOS 3drivers/platform/x86/intel/int3472/discrete.c +5
-0@@ -111,6 +111,10 @@ static void int3472_get_func_and_polarity(u8 type, const char **func, u32 *polar *func ="power-enable" ; *polarity =GPIO_ACTIVE_HIGH ;break ; +case INT3472_GPIO_TYPE_HANDSHAKE : + *func ="handshake" ; + *polarity =GPIO_ACTIVE_HIGH ; +break ;default : *func ="unknown" ; *polarity =GPIO_ACTIVE_HIGH ;@@ -201,6 +205,7 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,switch (type) {case INT3472_GPIO_TYPE_RESET :case INT3472_GPIO_TYPE_POWERDOWN : +case INT3472_GPIO_TYPE_HANDSHAKE : ret =skl_int3472_map_gpio_to_sensor (int3472, agpio, func, polarity);if (ret) err_msg ="Failed to map GPIO pin to sensor\n" ;
Hans,
Sorry for the late response.
The power control logic settings in ACPI table are the same between Windows OS and Linux, so I directly add another "handshake" pin handling to Linux power control driver as what Windows power control driver did.
Quoted 12 lines · Hans de Goede
Hi,
Quoted 4 lines · Hao Yao
Handshake pin is used for Lattice MIPI aggregator to enable the camera sensor. After pulled up, recommend to wail ~250ms to get everything ready.
If this is a pin on the "Lattice MIPI aggregator" andnot on the sensor itself then this really should be modeled as such and should not be registered as a GPIO consumed by the sensor since the actual sensor does not have a handshake pin at all.
Yes. This pin is actually connects to Lattice, not sensor.
Quoted 3 lines
Also we really don't want to need to patch all involved sensor drivers to toggle a handshake pin, especially since the sensor itself does not physically have this pin.
I agree. Adding GPIO pin controlling code in all sensor drivers is not a good idea.
Quoted 3 lines
Can you explain a bit more:
1. What the "Lattice MIPI aggregator" is
It actually manages all MIPI lanes, both RGB and IR cameras. It is something like the iVSC + LJCA combination which are in kernel v6.6 mainline.
Quoted 3 lines
2. What its functions are, does this control reset + pwdn GPIOs for the sensor? Voltages to the sensor? Clk to the sensor ?
It starts outputing MIPI packages when we pull handshake pins high. It also has USB-IO function which can supply virtual I2C and GPIO for host to control the camera (not physically as actually Lattice handles them). I didn't get the schematics, but I believe the GPIOs/Voltages/clocks are all controlled by Lattice.
Quoted 3 lines
3. How the aggregator is connected to both the main CPU/SoC as well as how it is connected to the sensor ? Some example diagram would be really helpful here.
In this case Lattice stands between host SoC and camera sensors. All MIPI lanes from sensor and all reset/power pins are managed by Lattice. Once one of the "handshake" pins on Lattice is pulled high, Lattice start to passthrough MIPI packages from corresponding sensor to host SoC.
Quoted 51 lines
Then with this info in hand we can try to come up with a way how to model this.
Assuming this controls the entire power-up sequence for the sensor then I think it could be modelled as a GPIO regulator. This also allows making the regulator core take care of the necessary delay between setting the GPIO and trying to talk to the sensor.
Regards,
Hans
Quoted 35 lines
Signed-off-by Hao Yao <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>--- drivers/platform/x86/intel/int3472/common.h | 1 + drivers/platform/x86/intel/int3472/discrete.c | 5 +++++ 2 files changed, 6 insertions(+)drivers/platform/x86/intel/int3472/common.h +1
-0@@ -23,6 +23,7 @@#define INT3472_GPIO_TYPE_POWER_ENABLE 0x0b#define INT3472_GPIO_TYPE_CLK_ENABLE 0x0c#define INT3472_GPIO_TYPE_PRIVACY_LED 0x0d +#define INT3472_GPIO_TYPE_HANDSHAKE 0x12#define INT3472_PDEV_MAX_NAME_LEN 23#define INT3472_MAX_SENSOR_GPIOS 3drivers/platform/x86/intel/int3472/discrete.c +4
-0@@ -111,6 +111,10 @@ static void int3472_get_func_and_polarity(u8 type, const char **func, u32 *polar *func ="power-enable" ; *polarity =GPIO_ACTIVE_HIGH ;break ; +case INT3472_GPIO_TYPE_HANDSHAKE : + *func ="handshake" ; + *polarity =GPIO_ACTIVE_HIGH ; +break ;default : *func ="unknown" ; *polarity =GPIO_ACTIVE_HIGH ;
Quoted 9 lines
drivers/platform/x86/intel/int3472/discrete.c static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, · line 211
Quoted 8 lines
drivers/platform/x86/intel/int3472/discrete.c +1
-0@@ -201,6 +205,7 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,switch (type) {case INT3472_GPIO_TYPE_RESET :case INT3472_GPIO_TYPE_POWERDOWN : +case INT3472_GPIO_TYPE_HANDSHAKE : ret =skl_int3472_map_gpio_to_sensor (int3472, agpio, func, polarity);if (ret) err_msg ="Failed to map GPIO pin to sensor\n" ;
Best Regards,
Hao Yao
Hello,
I'm trying to get camera on HP Spectre x360 14-eu0xxx (2024) laptop to work. I was able to make main sensor driver (ov08x40) to play nice with IPU6, INT3472 and libcamera-SoftISP and the resulting image quality is absolutely usable and even surprisingly good.
This laptop also uses this "MIPI aggregator".
Quoted 17 lines
Hi,
Quoted 3 lines · Hao Yao
Handshake pin is used for Lattice MIPI aggregator to enable the camera sensor. After pulled up, recommend to wail ~250ms to get everything ready.
If this is a pin on the "Lattice MIPI aggregator" and not on the sensor itself then this really should be modeled as such and should not be registered as a GPIO consumed by the sensor since the actual sensor does not have a handshake pin at all.
Also we really don't want to need to patch all involved sensor drivers to toggle a handshake pin, especially since the sensor itself does not physically have this pin.
Quoted 6 lines
Can you explain a bit more:
1. What the "Lattice MIPI aggregator" is.
2. What its functions are, does this control reset + pwdn GPIOs for the sensor? Voltages to the sensor? Clk to the sensor ?
It acts like MIPI switch as no MIPI data gets from the sensor to IPU6 if handshake signal is not asserted. Eventually IPU6 times out with "start stream of firmware failed" message. Any further attempts to start streaming lead to a panic.
I2C communication is not affected by the handshake signal but it looks like reset signal is also going through this "MIPI aggregator" as it takes about 150ms for the sensor to reliably start responding via I2C after the reset is deasserted. It should be about few ms if the reset signal was connected to the sensor directly.
Quoted 7 lines
3. How the aggregator is connected to both the main CPU/SoC as well as how it is connected to the sensor ? Some example diagram would be really helpful here.
Then with this info in hand we can try to come up with a way how to model this.
Quoted 6 lines
Assuming this controls the entire power-up sequence for the sensor then I think it could be modelled as a GPIO regulator. This also allows making the regulator core take care of the necessary delay between setting the GPIO and trying to talk to the sensor.
Are there any updates on how this signal should be implemented? For now I'm just applying this patch and asserting it from the sensor driver.
Regards
Quoted 51 lines
Regards,
Hans
Quoted 43 lines
Signed-off-by Hao Yao <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>--- drivers/platform/x86/intel/int3472/common.h | 1 + drivers/platform/x86/intel/int3472/discrete.c | 5 +++++ 2 files changed, 6 insertions(+)drivers/platform/x86/intel/int3472/common.h +1
-0@@ -23,6 +23,7 @@#define INT3472_GPIO_TYPE_POWER_ENABLE 0x0b#define INT3472_GPIO_TYPE_CLK_ENABLE 0x0c#define INT3472_GPIO_TYPE_PRIVACY_LED 0x0d +#define INT3472_GPIO_TYPE_HANDSHAKE 0x12#define INT3472_PDEV_MAX_NAME_LEN 23#define INT3472_MAX_SENSOR_GPIOS 3drivers/platform/x86/intel/int3472/discrete.c +5
-0@@ -111,6 +111,10 @@ static void int3472_get_func_and_polarity(u8 type, const char **func, u32 *polar *func ="power-enable" ; *polarity =GPIO_ACTIVE_HIGH ;break ; +case INT3472_GPIO_TYPE_HANDSHAKE : + *func ="handshake" ; + *polarity =GPIO_ACTIVE_HIGH ; +break ;default : *func ="unknown" ; *polarity =GPIO_ACTIVE_HIGH ;@@ -201,6 +205,7 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,switch (type) {case INT3472_GPIO_TYPE_RESET :case INT3472_GPIO_TYPE_POWERDOWN : +case INT3472_GPIO_TYPE_HANDSHAKE : ret =skl_int3472_map_gpio_to_sensor (int3472, agpio, func, polarity);if (ret) err_msg ="Failed to map GPIO pin to sensor\n" ;