hc
2023-03-15 f8c23d1415aad662de5acfa33671b5d14d2c1300
修复hp / spk自动切换
5 files modified
50 ■■■■■ changed files
kernel/arch/arm64/boot/dts/rockchip/NK-R36S0.dtsi 7 ●●●●● patch | view | raw | blame | history
kernel/drivers/headset_observe/rk_headset.c 10 ●●●●● patch | view | raw | blame | history
kernel/drivers/headset_observe/rk_headset.h 1 ●●●● patch | view | raw | blame | history
kernel/drivers/headset_observe/rockchip_headset_core.c 29 ●●●●● patch | view | raw | blame | history
kernel/drivers/misc/nkio/nk_io_core.c 3 ●●●● patch | view | raw | blame | history
kernel/arch/arm64/boot/dts/rockchip/NK-R36S0.dtsi
....@@ -19,6 +19,7 @@
1919 rk_headset: rk-headset {
2020 compatible = "rockchip_headset";
2121 headset_gpio = <&gpio0 RK_PD5 GPIO_ACTIVE_LOW>;
22
+ spk_ctl_gpio = <&gpio4 RK_PC2 GPIO_ACTIVE_LOW>;//AMP_SD_GPIO4_C2_3V3
2223 pinctrl-names = "default";
2324 pinctrl-0 = <&hp_det>;
2425 };
....@@ -101,7 +102,7 @@
101102 air_mode_4g_gpio = <&gpio1 RK_PB0 GPIO_ACTIVE_HIGH>; //4G_AIR_MODE_GPIO01_B0_3V3
102103 wake_4g_gpio = <&gpio1 RK_PB1 GPIO_ACTIVE_HIGH>; //4G_WAKEUP_GPIO01_B1_3V3
103104 hp_en_gpio = <&gpio3 RK_PA6 GPIO_ACTIVE_HIGH>;//HP_EN_GPIO3_A6_3V3
104
- spk_out_gpio = <&gpio4 RK_PC2 GPIO_ACTIVE_HIGH>;//AMP_SD_GPIO4_C2_3V3
105
+// spk_out_gpio = <&gpio4 RK_PC2 GPIO_ACTIVE_HIGH>;//AMP_SD_GPIO4_C2_3V3
105106 wifi_power_en_gpio = <&gpio3 RK_PC6 GPIO_ACTIVE_HIGH>; //WIFI_PWREN_GPIO3_C6_1V8
106107 // pcie_power_en_gpio = <&gpio0 RK_PD4 GPIO_ACTIVE_HIGH>;//PCIE_PWREN_H_GPIO0_D4
107108 pinctrl-names = "default";
....@@ -543,7 +544,8 @@
543544 // };
544545 headphone {
545546 hp_det: hp-det {
546
- rockchip,pins = <0 RK_PD5 RK_FUNC_GPIO &pcfg_pull_down>;
547
+ rockchip,pins = <0 RK_PD5 RK_FUNC_GPIO &pcfg_pull_down>,
548
+ <4 RK_PC2 RK_FUNC_GPIO &pcfg_pull_down>;
547549 };
548550 };
549551
....@@ -578,7 +580,6 @@
578580 <1 RK_PB0 RK_FUNC_GPIO &pcfg_pull_none>,
579581 <1 RK_PB1 RK_FUNC_GPIO &pcfg_pull_none>,
580582 <3 RK_PA6 RK_FUNC_GPIO &pcfg_pull_none>,
581
- <4 RK_PC2 RK_FUNC_GPIO &pcfg_pull_none>,
582583 <3 RK_PD2 RK_FUNC_GPIO &pcfg_pull_none>,
583584 <3 RK_PD3 RK_FUNC_GPIO &pcfg_pull_none>,
584585 <3 RK_PD4 RK_FUNC_GPIO &pcfg_pull_none>,
kernel/drivers/headset_observe/rk_headset.c
....@@ -153,6 +153,7 @@
153153 {
154154 int level = 0;
155155 int level2 = 0;
156
+ int ret;
156157 struct rk_headset_pdata *pdata = headset_info->pdata;
157158 static unsigned int old_status = 0;
158159
....@@ -182,6 +183,11 @@
182183 headset_info->headset_status ? "in" : "out");
183184 if (headset_info->headset_status == HEADSET_IN) {
184185 headset_info->cur_headset_status = BIT_HEADSET_NO_MIC;
186
+ ret = gpio_direction_output(pdata->spk_ctl_gpio,0);
187
+ if (ret < 0) {
188
+ printk("spk_ctl_gpio set direction fail\n");
189
+ }
190
+
185191 if (pdata->headset_insert_type == HEADSET_IN_HIGH)
186192 irq_set_irq_type(headset_info->irq[HEADSET],
187193 IRQF_TRIGGER_FALLING);
....@@ -196,6 +202,10 @@
196202 goto out;
197203 }
198204 } else if (headset_info->headset_status == HEADSET_OUT) {
205
+ ret = gpio_direction_output(pdata->spk_ctl_gpio,1);
206
+ if (ret < 0) {
207
+ printk("spk_ctl_gpio set direction fail\n");
208
+ }
199209 headset_info->hook_status = HOOK_UP;
200210 if (headset_info->isHook_irq == enable) {
201211 DBG("disable headset_hook irq\n");
kernel/drivers/headset_observe/rk_headset.h
....@@ -11,6 +11,7 @@
1111 struct rk_headset_pdata {
1212 /* heaset about */
1313 unsigned int headset_gpio;
14
+ unsigned int spk_ctl_gpio;
1415 /* Headphones into the state level */
1516 unsigned int headset_insert_type;
1617 /* hook about */
kernel/drivers/headset_observe/rockchip_headset_core.c
....@@ -73,6 +73,35 @@
7373 HEADSET_IN_LOW :
7474 HEADSET_IN_HIGH;
7575 }
76
+
77
+ /* spk-ctl */
78
+ ret = of_get_named_gpio_flags(node, "spk_ctl_gpio", 0, &flags);
79
+ if (ret < 0) {
80
+ dev_err(&pdev->dev, "Can not read property headset_gpio\n");
81
+ goto err;
82
+ } else {
83
+ pdata->spk_ctl_gpio = ret;
84
+ ret = devm_gpio_request(&pdev->dev, pdata->spk_ctl_gpio,
85
+ "spk_ctl_gpio");
86
+ if (ret < 0) {
87
+ dev_err(&pdev->dev, "spk_ctl_gpio request fail\n");
88
+ goto err;
89
+ }
90
+
91
+ ret = gpio_get_value(pdata->headset_gpio);
92
+ printk(" headset_gpio value : %d\n",ret);
93
+ if (ret == 0)
94
+ ret = gpio_direction_output(pdata->spk_ctl_gpio,0);
95
+ else
96
+ ret = gpio_direction_output(pdata->spk_ctl_gpio,1);
97
+ if (ret < 0) {
98
+ dev_err(&pdev->dev,
99
+ "spk_ctl_gpio set direction fail\n");
100
+ goto err;
101
+ }
102
+ }
103
+
104
+
76105 /* hook */
77106 ret = of_get_named_gpio_flags(node, "hook_gpio", 0, &pdata->hook_gpio);
78107 if (ret < 0) {
kernel/drivers/misc/nkio/nk_io_core.c
....@@ -319,7 +319,7 @@
319319 }
320320 }
321321
322
-
322
+/*
323323 //spk_out_gpio
324324 ret = of_get_named_gpio_flags(node, "spk_out_gpio", 0, &flags);
325325 if (ret < 0) {
....@@ -336,6 +336,7 @@
336336 printk("%s() gpio_direction_output spk_out_gpio set ERROR\n", __FUNCTION__);
337337 }
338338 }
339
+*/
339340 //air_mode_4g_gpio
340341 ret = of_get_named_gpio_flags(node, "air_mode_4g_gpio", 0, &flags);
341342 if (ret < 0) {