hc
2024-03-22 619f0f87159c5dbd2755b1b0a0eb35784be84e7a
增加支持hp & spk 自动切换
6 files modified
89 ■■■■ changed files
kernel/.gitignore 1 ●●●● patch | view | raw | blame | history
kernel/arch/arm64/boot/dts/rockchip/NK-6A13_V0A.dtsi 37 ●●●● patch | view | raw | blame | history
kernel/drivers/headset_observe/rk_headset.c 11 ●●●●● patch | view | raw | blame | history
kernel/drivers/headset_observe/rk_headset.h 1 ●●●● patch | view | raw | blame | history
kernel/drivers/headset_observe/rk_headset_irq_hook_adc.c 11 ●●●●● patch | view | raw | blame | history
kernel/drivers/headset_observe/rockchip_headset_core.c 28 ●●●●● patch | view | raw | blame | history
kernel/.gitignore
....@@ -44,6 +44,7 @@
4444 *.xz
4545 Module.symvers
4646 modules.builtin
47
+*.modinfo
4748
4849 #
4950 # Top-level generic files
kernel/arch/arm64/boot/dts/rockchip/NK-6A13_V0A.dtsi
....@@ -38,10 +38,10 @@
3838 io-channels = <&saradc 3>;
3939 io-channel-names = "adc-detect";
4040 keyup-threshold-microvolt = <1800000>;
41
- pinctrl-0 = <&hp_det>;
41
+ pinctrl-0 = <&spk_con>;
4242 pinctrl-names = "default";
43
- hp-det-gpio = <&gpio1 RK_PD5 GPIO_ACTIVE_HIGH>;
44
- spk-con-gpio = <&gpio3 RK_PC3 GPIO_ACTIVE_HIGH>;
43
+ //hp-det-gpio = <&gpio1 RK_PD5 GPIO_ACTIVE_LOW>;
44
+ //spk-con-gpio = <&gpio3 RK_PC3 GPIO_ACTIVE_HIGH>;
4545 play-pause-key {
4646 label = "playpause";
4747 linux,code = <164>;
....@@ -132,9 +132,10 @@
132132 };
133133
134134 rk_headset: rk-headset {
135
- status = "disabled";
135
+ status = "okay";
136136 compatible = "rockchip_headset";
137
- headset_gpio = <&gpio1 RK_PD5 GPIO_ACTIVE_LOW>;
137
+ headset_gpio = <&gpio1 RK_PD5 GPIO_ACTIVE_HIGH>;
138
+ spk_ctl_gpio = <&gpio3 RK_PC3 GPIO_ACTIVE_LOW>;
138139 pinctrl-names = "default";
139140 pinctrl-0 = <&hp_det>;
140141 io-channels = <&saradc 3>;
....@@ -389,6 +390,14 @@
389390 &combphy0_ps {
390391 status = "okay";
391392 };
393
+
394
+/*
395
+&usbdrd_dwc3_0 {
396
+ dr_mode = "otg";
397
+ extcon = <&u2phy0>;
398
+ status = "okay";
399
+};
400
+*/
392401
393402 &combphy1_ps {
394403 status = "okay";
....@@ -901,6 +910,10 @@
901910 hp_det: hp-det {
902911 rockchip,pins = <1 RK_PD5 RK_FUNC_GPIO &pcfg_pull_none>;
903912 };
913
+
914
+ spk_con: spk-con {
915
+ rockchip,pins = <3 RK_PC3 RK_FUNC_GPIO &pcfg_pull_none>;
916
+ };
904917 };
905918
906919 hym8563 {
....@@ -1050,12 +1063,6 @@
10501063 vmmc-supply = <&vcc_3v3_sd_s0>;
10511064 };
10521065
1053
-&uart9 {
1054
- status = "okay";
1055
- pinctrl-names = "default";
1056
- pinctrl-0 = <&uart9m0_xfer &uart9m0_ctsn>;
1057
-};
1058
-
10591066 &u2phy0_otg {
10601067 status = "okay";
10611068 };
....@@ -1099,16 +1106,10 @@
10991106 status = "okay";
11001107 };
11011108
1102
-&usbdrd_dwc3_0 {
1103
- dr_mode = "otg";
1104
- extcon = <&u2phy0>;
1105
- status = "okay";
1106
-};
1107
-
11081109 &usbdrd_dwc3_1 {
11091110 dr_mode = "host";
11101111 maximum-speed = "high-speed";
1111
- status = "okay";
1112
+ status = "disabled";
11121113 };
11131114
11141115 &uart1 {
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
....@@ -177,11 +178,15 @@
177178 pr_warn("old_status == headset_info->headset_status\n");
178179 goto out;
179180 }
180
- DBG("(headset in is %s)headset status is %s\n",
181
+ DBG("(troy test headset in is %s)headset status is %s\n",
181182 pdata->headset_insert_type ? "high level" : "low level",
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,1);
187
+ if (ret < 0) {
188
+ printk("spk_ctl_gpio set direction fail\n");
189
+ }
185190 if (pdata->headset_insert_type == HEADSET_IN_HIGH)
186191 irq_set_irq_type(headset_info->irq[HEADSET],
187192 IRQF_TRIGGER_FALLING);
....@@ -196,6 +201,10 @@
196201 goto out;
197202 }
198203 } else if (headset_info->headset_status == HEADSET_OUT) {
204
+ ret = gpio_direction_output(pdata->spk_ctl_gpio,0);
205
+ if (ret < 0) {
206
+ printk("spk_ctl_gpio set direction fail\n");
207
+ }
199208 headset_info->hook_status = HOOK_UP;
200209 if (headset_info->isHook_irq == enable) {
201210 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/rk_headset_irq_hook_adc.c
....@@ -111,6 +111,7 @@
111111 struct rk_headset_pdata *pdata = headset_info->pdata;
112112 static unsigned int old_status = 0;
113113 int i, level = 0;
114
+ int ret;
114115
115116 disable_irq_nosync(headset_info->irq[HEADSET]);
116117 if (headset_info->heatset_irq_working == BUSY ||
....@@ -161,11 +162,15 @@
161162 goto out;
162163 }
163164
164
- pr_info("(headset in is %s)headset status is %s\n",
165
+ pr_info("(myttest headset in is %s)headset status is %s\n",
165166 pdata->headset_insert_type ? "high level" : "low level",
166167 headset_info->headset_status ? "in" : "out");
167168
168169 if (headset_info->headset_status == HEADSET_IN) {
170
+ ret = gpio_direction_output(pdata->spk_ctl_gpio,1);
171
+ if (ret < 0) {
172
+ printk("spk_ctl_gpio set direction fail\n");
173
+ }
169174 if (pdata->chan != 0) {
170175 /* detect Hook key */
171176 schedule_delayed_work(
....@@ -186,6 +191,10 @@
186191 irq_set_irq_type(headset_info->irq[HEADSET],
187192 IRQF_TRIGGER_RISING);
188193 } else if (headset_info->headset_status == HEADSET_OUT) {
194
+ ret = gpio_direction_output(pdata->spk_ctl_gpio,0);
195
+ if (ret < 0) {
196
+ printk("spk_ctl_gpio set direction fail\n");
197
+ }
189198 headset_info->cur_headset_status = HEADSET_OUT;
190199 cancel_delayed_work(&headset_info->hook_work);
191200 if (headset_info->isMic) {
kernel/drivers/headset_observe/rockchip_headset_core.c
....@@ -73,6 +73,34 @@
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
+
76104 /* hook */
77105 ret = of_get_named_gpio_flags(node, "hook_gpio", 0, &pdata->hook_gpio);
78106 if (ret < 0) {