[Bugfix][T106BUG-240][autosuspend]add dtr and ring
Only Configure: No
Affected branch: master
Affected module: autosuspend
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: Yes
Change-Id: I0e418715ef4a282d1f0b6ea7aef039bcaf092c5d
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-vehicle_dc_ref.dts b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-vehicle_dc_ref.dts
index 6f7cf69..56fba5c 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-vehicle_dc_ref.dts
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-vehicle_dc_ref.dts
@@ -174,7 +174,7 @@
&xp2xp {
//while using this module,should change gpio
- status = "disabled";
+ status = "okay";//jb.qi change for dtr on 20231204
};
&gpio_key0 {
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3.dtsi b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3.dtsi
index b5d4bc6..3bb759e 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3.dtsi
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3.dtsi
@@ -312,12 +312,11 @@
pinctrl-names = "gpio50", "ext_int3";
pinctrl-0 = <&gpio_50_pins>;
pinctrl-1 = <&ext_int3_pins>;
+ /*jb.qi change for dtr on 20231204 start*/
gpios = <&bgpio 50 GPIO_ACTIVE_HIGH
- &bgpio 53 GPIO_ACTIVE_HIGH
- &bgpio 130 GPIO_ACTIVE_HIGH
- &bgpio 131 GPIO_ACTIVE_HIGH>;
- //interrupt-parent = <&ext8in1>;
- interrupts = <GIC_SPI EX3_INT IRQ_TYPE_EDGE_RISING>;
+ &bgpio 119 GPIO_ACTIVE_HIGH>;
+ interrupts = <GIC_SPI EX3_INT IRQ_TYPE_LEVEL_LOW>;
+ /*jb.qi change for dtr on 20231204 end*/
status = "disabled";
};
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/power_4line/hal_xp2xp.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/power_4line/hal_xp2xp.c
old mode 100644
new mode 100755
index ba40038..5e14b7d
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/power_4line/hal_xp2xp.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/power_4line/hal_xp2xp.c
@@ -59,8 +59,8 @@
#define AP_SLEEP_STATUS 0 /*AP˯Ãßʱ¸ÃÒý½ÅΪ0*/
#define AP_WAKE_STATUS 1 /*AP»½ÐÑʱ¸ÃÒý½ÅΪ1*/
-#define CP_SLEEP_STATUS 0 /*CP˯Ãßʱ¸ÃÒý½ÅΪ0*/
-#define CP_WAKE_STATUS 1 /*CP»½ÐÑʱ¸ÃÒý½ÅΪ1*/
+#define CP_SLEEP_STATUS 1 //jb.q add for dtr on 20231204
+#define CP_WAKE_STATUS 0 //jb.q add for dtr on 20231204
#ifdef BTRUNK_SUPPORT
#define CP_WAKE_AP_INT_SET 1
@@ -77,7 +77,7 @@
#ifndef FALSE
#define FALSE 0
#endif
-#define HAL_XP2XP_PM 0
+#define HAL_XP2XP_PM 1 //jb.qi add for dtr on 20231204
#define XP2XP_DEBUG
@@ -111,7 +111,7 @@
struct hal_xp2xp_dev
-{
+{
struct device *dev;
struct pinctrl *pctrl_wk_int;
struct pinctrl_state *st_gpio;
@@ -127,15 +127,15 @@
int ap_slp_st_gpio;
int wake_ap_gpio;
int wake_me_gpio;
- struct gpio_desc *gd;
+ struct gpio_desc *gd;
- int eint_irq;
+ int eint_irq;
int xp2xp_irq_state;
int wake_cnt;
int sleep_cnt;
struct wakeup_source *xp2xp_ws;
-};
+};
/****************************************************************************
@@ -156,7 +156,7 @@
struct kset *kset_xp2xp;
//struct kset kset_c;
struct kobject *xp2xpkobj = NULL;
-
+
struct hal_xp2xp_dev g_xp2xp = {0};
static struct attribute xp2xp_state_attr =
@@ -195,7 +195,7 @@
static struct sysfs_ops xp2xp_obj_sysops =
{
.show = xp2xp_obj_show,
- .store = xp2xp_obj_store,
+ .store = xp2xp_obj_store,
};
@@ -407,20 +407,21 @@
*
* Others:
********************************************************************************/
+/*jb.qi add for dtr on 20231304 start*/
irqreturn_t xp2xp_wkcp_handler(int irq, void *priv)
{
unsigned long flags;
int gpio_value;
- unsigned int irq_type;
+ unsigned int irq_type;
struct hal_xp2xp_dev *xp2xp_dev = (struct hal_xp2xp_dev *)priv;
-
+
disable_irq_nosync(irq);
- xp2xp_dev->xp2xp_irq_state = 0;
+ xp2xp_dev->xp2xp_irq_state = 0;
gpio_value = 0 ;
- //pm_stay_awake(xp2xp_dev->dev);
+
if(xp2xp_dev->xp2xp_ws){
__pm_wakeup_event(xp2xp_dev->xp2xp_ws, 2000);
- }
+ }
if (pinctrl_select_state(xp2xp_dev->pctrl_wk_int, xp2xp_dev->st_gpio) < 0) {
printk("setting card detect gpio failed\n");
}
@@ -433,26 +434,23 @@
}
if(1 == gpio_value){
- irq_type = IRQF_TRIGGER_FALLING;
- xp2xp_dev->wake_state = 1;
- xp2xp_dev->curr_gpio_value = 1;
- //pm_relax(cdns_dev->dev);
+ irq_type = IRQF_TRIGGER_LOW;
+ printk("gpio_value is 1 , release wakelock\n");
+ pm_relax(g_xp2xp.dev);
}else{
- irq_type = IRQF_TRIGGER_RISING;
- xp2xp_dev->wake_state = 0;
- xp2xp_dev->curr_gpio_value = 0;
+ irq_type = IRQF_TRIGGER_HIGH;
+ printk("gpio_value is 0 , lock wakelock\n");
+ pm_stay_awake(g_xp2xp.dev);
}
if (pinctrl_select_state(xp2xp_dev->pctrl_wk_int, xp2xp_dev->st_int) < 0) {
printk( "setting card detect irq failed\n");
}
-
irq_set_irq_type(irq,irq_type);
-
up(&xp2xp_dev->wk_sem);
- return IRQ_HANDLED;
+ return IRQ_HANDLED;
}
-
+/*jb.qi add for dtr on 20231304 end*/
/*******************************************************************************
* Function:
@@ -667,71 +665,71 @@
}
#if HAL_XP2XP_PM
-
+
static int hal_xp2xp_pm_resume(struct device *dev)
-{
- //pm_stay_awake(dev);
-
+{
+ gpio_direction_output(g_xp2xp.ap_slp_st_gpio, CP_WAKE_STATUS);//jb.q add for dtr on 20231204
pr_info("hal_xp2xp_pm_resume\n");
- return 0;
-}
-
+ return 0;
+}
+
static int hal_xp2xp_pm_suspend(struct device *dev)
-{
- //pm_relax(dev);
+{
+ gpio_direction_output(g_xp2xp.ap_slp_st_gpio, CP_SLEEP_STATUS);//jb.q add for dtr on 20231204
pr_info("hal_xp2xp_pm_suspend\n");
- return 0;
-}
-
+ return 0;
+}
+
static int hal_xp2xp_pm_runtime_resume(struct device *dev)
-{
- /* enable clk and restore regs */
+{
+ /* enable clk and restore regs */
pr_info("hal_xp2xp_pm_runtime_resume\n");
- return 0;
-}
-
+ return 0;
+}
+
static int hal_xp2xp_pm_runtime_suspend(struct device *dev)
-{
- /* backup regs and disable clk */
+{
+ /* backup regs and disable clk */
pr_info("hal_xp2xp_pm_runtime_suspend\n");
- return 0;
-}
-
+ return 0;
+}
+
static int hal_xp2xp_pm_runtime_idle(struct device *dev)
-{
+{
pr_info("hal_xp2xp_pm_runtime_idle\n");
- return 0;
-}
-
+ return 0;
+}
+
static const struct dev_pm_ops hal_xp2xp_pm = {
.resume = hal_xp2xp_pm_resume,
.suspend = hal_xp2xp_pm_suspend,
.runtime_resume = hal_xp2xp_pm_runtime_resume,
.runtime_suspend = hal_xp2xp_pm_runtime_suspend,
.runtime_idle = hal_xp2xp_pm_runtime_idle
-};
-#endif
+};
+#endif
-
+
static const struct of_device_id hal_xp2xp_match[] = {
{ .compatible = "zte,hal_xp2xp", },
- { }
-};
+ { }
+};
-
+
int hal_xp2xp_probe(struct platform_device *pdev)
-{
- int gpio;
- int irq;
- enum of_gpio_flags flags;
+{
+ int gpio;
+ int irq;
+ int gpio_value;//jb.q add for dtr on 20231204
+ enum of_gpio_flags flags;
int ret = 0;
g_xp2xp.dev = &pdev->dev;
sema_init(&g_xp2xp.wk_sem,0);
spin_lock_init(&g_xp2xp.wk_lock);
-
- //device_init_wakeup(&pdev->dev, true);
- //pm_stay_awake(g_xp2xp.dev);
+
+ device_init_wakeup(&pdev->dev, true);//jb.q add for dtr on 20231204
+
g_xp2xp.xp2xp_ws = wakeup_source_register(NULL, "xp2xp");
if(g_xp2xp.xp2xp_ws == NULL){
printk("adb_setup wakeup_source_create fail\n");
@@ -743,11 +741,11 @@
g_xp2xp.pctrl_wk_int = NULL;
ret = -ENOMEM;
goto pinctrl_init_fail;
- }
+ }
g_xp2xp.st_gpio = pinctrl_lookup_state(g_xp2xp.pctrl_wk_int, "gpio50");
if (IS_ERR(g_xp2xp.st_gpio)) {
dev_err(&pdev->dev, "hal_xp2xp_probe: missing st_gpio\n");
- }
+ }
g_xp2xp.st_int = pinctrl_lookup_state(g_xp2xp.pctrl_wk_int, "ext_int3");
if (IS_ERR(g_xp2xp.st_int)) {
dev_err(&pdev->dev, "hal_xp2xp_probe: missing ext_int3\n");
@@ -755,7 +753,7 @@
#if 0
if ( pinctrl_select_state(g_xp2xp.pctrl_wk_int, g_xp2xp.st_gpio) < 0) {
dev_err(&pdev->dev, "hal_xp2xp_probe state0 failed\n");
- }
+ }
#endif
/* eint3 */
if ( pinctrl_select_state(g_xp2xp.pctrl_wk_int, g_xp2xp.st_int) < 0) {
@@ -764,29 +762,51 @@
/* gpio request */
gpio = of_get_gpio_flags(pdev->dev.of_node, 0, &flags);
- if (!gpio_is_valid(gpio)) {
+ if (!gpio_is_valid(gpio)) {
printk("hal_xp2xp_probe gpio 50 no found\n");
ret = -ENODEV;
goto gpio50_init_fail;
- }
- /* pr_info("test gpio :%d flag=0x%x\n", gpio, flags); */
-
+ }
+ /* pr_info("test gpio :%d flag=0x%x\n", gpio, flags); */
g_xp2xp.wake_me_gpio = gpio;
-
g_xp2xp.eint_irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
- printk("wake_me_gpio:%d, eint_irq:%d\n", g_xp2xp.wake_me_gpio, g_xp2xp.eint_irq);
+ printk("wake_me_gpio:%d, eint_irq:%d\n", g_xp2xp.wake_me_gpio, g_xp2xp.eint_irq);
+ /*//jb.q add for dtr on 20231204 start*/
+ if ( pinctrl_select_state(g_xp2xp.pctrl_wk_int, g_xp2xp.st_gpio) < 0) {
+ dev_err(&pdev->dev, "hal_xp2xp_probe state0 failed\n");
+ }
+ spin_lock_irqsave(&g_xp2xp.wk_lock, flags);
+ gpio_value = gpio_get_value(g_xp2xp.wake_me_gpio) ;
+ spin_unlock_irqrestore(&g_xp2xp.wk_lock, flags);
+ if(gpio_value < 0)
+ {
+ printk( "[%s-%d]: gpio get state failed\n",__func__,__LINE__);
+ }
+ if(1 == gpio_value)
+ {
+ pm_relax(g_xp2xp.dev);
+ }
+ else
+ {
+ pm_stay_awake(g_xp2xp.dev);
+ }
+
+ if ( pinctrl_select_state(g_xp2xp.pctrl_wk_int, g_xp2xp.st_int) < 0) {
+ dev_err(&pdev->dev, "hal_xp2xp_probe eint3 failed\n");
+ }
+ /*//jb.q add for dtr on 20231204 end*/
ret = devm_request_threaded_irq(g_xp2xp.dev, g_xp2xp.eint_irq,
xp2xp_wkcp_handler,
NULL, IRQF_ONESHOT,
- "xp2xp_wake int", &g_xp2xp);
-
-
+ "xp2xp_wake int", &g_xp2xp);
+
if(ret<0){
panic("hal_xp2xp_probe request_irq fail, %d", ret);
- }
+ }
+
g_xp2xp.wake_int_thread = kthread_run(xp2xp_wkcp_thread, (void *)&g_xp2xp, "xp2xp_wake_thread");
@@ -794,38 +814,38 @@
printk("Can't start up our thread");
return PTR_ERR(g_xp2xp.wake_int_thread);
}
-
+
enable_irq_wake(g_xp2xp.eint_irq);
-
-#ifdef CONFIG_KERNEL_CONTROL_WAKEUP
+/*jb.q add for dtr on 20231204 start*/
/* gpio request */
- //gpio_53,ap sleep_state
+ //gpio_119,ap sleep_state
gpio = of_get_gpio_flags(pdev->dev.of_node, 1, &flags);
- if (!gpio_is_valid(gpio)) {
+ if (!gpio_is_valid(gpio)) {
printk("hal_xp2xp_probe gpio no found\n");
ret = -ENODEV;
- goto gpio53_init_fail;
- }
- /* pr_info("test gpio :%d flag=0x%x\n", gpio, flags); */
+ goto gpio119_init_fail;
+ }
+ /* pr_info("test gpio :%d flag=0x%x\n", gpio, flags); */
g_xp2xp.ap_slp_st_gpio = gpio;
- gpio_direction_input(g_xp2xp.ap_slp_st_gpio);
-
+ gpio_direction_output(g_xp2xp.ap_slp_st_gpio, CP_SLEEP_STATUS);
+
+#if 0
+
//gpio_130,my sleep_state
gpio = of_get_gpio_flags(pdev->dev.of_node, 2, &flags);
- if (!gpio_is_valid(gpio)) {
+ if (!gpio_is_valid(gpio)) {
printk("hal_xp2xp_probe gpio no found\n");
ret = -ENODEV;
goto gpio130_init_fail;
}
-
- g_xp2xp.my_slp_st_gpio = gpio;
-gpio_direction_output(g_xp2xp.my_slp_st_gpio, CP_SLEEP_STATUS);
+ g_xp2xp.my_slp_st_gpio = gpio;
+ gpio_direction_output(g_xp2xp.my_slp_st_gpio, CP_SLEEP_STATUS);
//gpio_131,wake ap gpio
gpio = of_get_gpio_flags(pdev->dev.of_node, 3, &flags);
- if (!gpio_is_valid(gpio)) {
+ if (!gpio_is_valid(gpio)) {
printk("hal_xp2xp_probe gpio no found\n");
ret = -ENODEV;
goto gpio131_init_fail;
@@ -833,27 +853,30 @@
g_xp2xp.wake_ap_gpio = gpio;
gpio_direction_output(g_xp2xp.my_slp_st_gpio, CP_WAKE_AP_INT_CLEAR);
+ gpio131_init_fail:
+ if(ret){
+ printk("\n");
+ }
+ gpio130_init_fail:
+ if(ret){
+ printk("\n");
+ }
+
+
#endif
+/*jb.q add for dtr on 20231204 end*/
g_xp2xp.wake_cnt = 0;
g_xp2xp.sleep_cnt = 0;
-gpio131_init_fail:
+
+gpio119_init_fail:
if(ret){
- printk("\n");
- }
-gpio130_init_fail:
- if(ret){
- printk("\n");
- }
-
-gpio53_init_fail:
- if(ret){
- printk("\n");
+ printk("gpio 119 init fail\n");//jb.q add for dtr on 20231204
}
gpio50_init_fail:
if(ret){
- printk("\n");
+ printk("gpio 50 init fail\n");//jb.q add for dtr on 20231204
}
pinctrl_init_fail:
@@ -862,19 +885,19 @@
}
wake_source_init_fail:
- //pm_relax(g_xp2xp.dev);
- return ret;
-}
+ //pm_relax(g_xp2xp.dev);
+ return ret;
+}
static struct platform_driver hal_xp2xp_driver = {
.probe = hal_xp2xp_probe,
- .driver = {
+ .driver = {
.name = "hal_xp2xp",
#if HAL_XP2XP_PM
.pm = &hal_xp2xp_pm,
-#endif
+#endif
.of_match_table = hal_xp2xp_match,
- },
+ },
};
@@ -896,7 +919,7 @@
int errCode = -1;
kset_xp2xp_init();
//xp2xp_init_flag = 1;
-
+
ret = platform_driver_register(&hal_xp2xp_driver);
if (ret != 0){
kset_xp2xp_exit();