.. | .. |
---|
1 | | -/*
|
---|
2 | | - * Copyright (C) 2014 Rockchip Corporation.
|
---|
3 | | - *
|
---|
4 | | - * This software is licensed under the terms of the GNU General Public
|
---|
5 | | - * License version 2, as published by the Free Software Foundation, and
|
---|
6 | | - * may be copied, distributed, and modified under those terms.
|
---|
7 | | - *
|
---|
8 | | - * This program is distributed in the hope that it will be useful,
|
---|
9 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
11 | | - * GNU General Public License for more details.
|
---|
12 | | - *
|
---|
13 | | - */
|
---|
14 | 1 | #include <linux/module.h>
|
---|
15 | | -#include <linux/moduleparam.h>
|
---|
16 | | -#include <linux/init.h>
|
---|
17 | | -#include <linux/delay.h>
|
---|
18 | | -#include <linux/pm.h>
|
---|
19 | | -#include <linux/i2c.h>
|
---|
20 | | -#include <linux/spi/spi.h>
|
---|
21 | | -#include <linux/platform_device.h>
|
---|
22 | | -#include <linux/errno.h>
|
---|
23 | 2 | #include <linux/err.h>
|
---|
24 | | -#include <linux/debugfs.h>
|
---|
25 | | -#include <linux/of_gpio.h>
|
---|
26 | 3 | #include <linux/gpio.h>
|
---|
27 | | -#include <linux/iio/consumer.h>
|
---|
28 | | -#include <linux/of.h>
|
---|
29 | | -#include "nkio.h"
|
---|
30 | | -
|
---|
31 | | -/* Debug */
|
---|
32 | | -#if 1
|
---|
33 | | -#define DBG(x...) printk(x)
|
---|
34 | | -#else
|
---|
35 | | -#define DBG(x...) do { } while (0)
|
---|
36 | | -#endif
|
---|
37 | | -
|
---|
38 | | -struct nk_io_pdata *NKpdata_info;
|
---|
39 | | -u32 op0_enable,op1_enable,op2_enable,op3_enable,op4_enable,op5_enable,mic_enable;
|
---|
40 | | -u32 ip0_enable,ip1_enable,ip2_enable,ip3_enable,ip4_enable,ip5_enable;
|
---|
41 | | -u32 module_enable;
|
---|
42 | | -//static struct class *nk_class;
|
---|
43 | | -
|
---|
44 | | -
|
---|
45 | | -
|
---|
46 | | -void Audio_SET(int i);
|
---|
47 | | -
|
---|
48 | | - void Audio_SET(int i)
|
---|
49 | | - {
|
---|
50 | | - if(i==11){
|
---|
51 | | - gpio_direction_output(NKpdata_info->audio_switch_gpio, 1);
|
---|
52 | | - printk("Audio_SET ENABLE------andy\n");
|
---|
53 | | - }else{
|
---|
54 | | - gpio_direction_output(NKpdata_info->audio_switch_gpio, 0);
|
---|
55 | | - printk("Audio_SET DISABLE------andy\n");
|
---|
56 | | - }
|
---|
57 | | - }
|
---|
58 | | - EXPORT_SYMBOL_GPL(Audio_SET);
|
---|
59 | | -
|
---|
60 | | -static int nk_io_control_probe(struct platform_device *pdev)
|
---|
61 | | -{
|
---|
62 | | - struct device_node *node = pdev->dev.of_node;
|
---|
63 | | - struct nk_io_pdata *pdata;
|
---|
64 | | - int ret;
|
---|
65 | | -
|
---|
66 | | -
|
---|
67 | | - enum of_gpio_flags flags;
|
---|
68 | | -
|
---|
69 | | - printk(" #######nk_io_control_probe####### \n");
|
---|
70 | | -
|
---|
71 | | - pdata = kzalloc(sizeof(struct nk_io_pdata), GFP_KERNEL);
|
---|
72 | | - if (pdata == NULL) {
|
---|
73 | | - printk("%s failed to allocate driver data\n",__FUNCTION__);
|
---|
74 | | - return -ENOMEM;
|
---|
75 | | - }
|
---|
76 | | - memset(pdata,0,sizeof(struct nk_io_pdata));
|
---|
77 | | -
|
---|
78 | | - //vcc_5v_io
|
---|
79 | | - ret = of_get_named_gpio_flags(node, "vcc_5v_io", 0, &flags);
|
---|
80 | | - if (ret < 0) {
|
---|
81 | | - printk("%s() Can not read property vcc_5v_io\n", __FUNCTION__);
|
---|
82 | | - goto err;
|
---|
83 | | - } else {
|
---|
84 | | - pdata->vcc_5v_io = ret;
|
---|
85 | | - ret = devm_gpio_request(&pdev->dev, pdata->vcc_5v_io, "vcc_5v_io");
|
---|
86 | | - if(ret < 0){
|
---|
87 | | - printk("%s() devm_gpio_request vcc_5v_io request ERROR\n", __FUNCTION__);
|
---|
88 | | - goto err;
|
---|
89 | | - }
|
---|
90 | | -
|
---|
91 | | - ret = gpio_direction_output(pdata->vcc_5v_io,1);
|
---|
92 | | - if(ret < 0){
|
---|
93 | | - printk("%s() gpio_direction_input vcc_5v_io set ERROR\n", __FUNCTION__);
|
---|
94 | | - goto err;
|
---|
95 | | - }
|
---|
96 | | - }
|
---|
97 | | -#if 0
|
---|
98 | | - //vcc3_io_en_gpio
|
---|
99 | | - ret = of_get_named_gpio_flags(node, "vcc3_io_en_gpio", 0, &flags);
|
---|
100 | | - if (ret < 0) {
|
---|
101 | | - printk("%s() Can not read property vcc3_io_en_gpio\n", __FUNCTION__);
|
---|
102 | | - goto err;
|
---|
103 | | - } else {
|
---|
104 | | - pdata->vcc3_io_en_gpio = ret;
|
---|
105 | | - ret = devm_gpio_request(&pdev->dev, pdata->vcc3_io_en_gpio, "vcc3_io_en_gpio");
|
---|
106 | | - if(ret < 0){
|
---|
107 | | - printk("%s() devm_gpio_request vcc3_io_en_gpio request ERROR\n", __FUNCTION__);
|
---|
108 | | - goto err;
|
---|
109 | | - }
|
---|
110 | | -
|
---|
111 | | - ret = gpio_direction_output(pdata->vcc3_io_en_gpio,1);
|
---|
112 | | - if(ret < 0){
|
---|
113 | | - printk("%s() gpio_direction_output vcc3_io_en_gpio set ERROR\n", __FUNCTION__);
|
---|
114 | | - goto err;
|
---|
115 | | - }
|
---|
116 | | - }
|
---|
117 | | -#endif
|
---|
118 | | - //vcc_12v_io
|
---|
119 | | - ret = of_get_named_gpio_flags(node, "vcc_12v_io", 0, &flags);
|
---|
120 | | - if (ret < 0) {
|
---|
121 | | - printk("%s() Can not read property vcc_12v_io\n", __FUNCTION__);
|
---|
122 | | - goto err;
|
---|
123 | | - } else {
|
---|
124 | | - pdata->vcc_12v_io = ret;
|
---|
125 | | - ret = devm_gpio_request(&pdev->dev, pdata->vcc_12v_io, "vcc_12v_io");
|
---|
126 | | - if(ret < 0){
|
---|
127 | | - printk("%s() devm_gpio_request vcc_12v_io request ERROR\n", __FUNCTION__);
|
---|
128 | | - goto err;
|
---|
129 | | - }
|
---|
130 | | -
|
---|
131 | | - ret = gpio_direction_output(pdata->vcc_12v_io,1);
|
---|
132 | | - if(ret < 0){
|
---|
133 | | - printk("%s() gpio_direction_input vcc_12v_io set ERROR\n", __FUNCTION__);
|
---|
134 | | - goto err;
|
---|
135 | | - }
|
---|
136 | | - }
|
---|
137 | | -
|
---|
138 | | -
|
---|
139 | | - //hub_host2_5V_rest_gpio
|
---|
140 | | - ret = of_get_named_gpio_flags(node, "hub_host2_5V_rest_gpio", 0, &flags);
|
---|
141 | | - if (ret < 0) {
|
---|
142 | | - printk("%s() Can not read property hub_host2_5V_rest_gpio\n", __FUNCTION__);
|
---|
143 | | - goto err;
|
---|
144 | | - } else {
|
---|
145 | | - pdata->hub_host2_5V_rest_gpio = ret;
|
---|
146 | | - ret = devm_gpio_request(&pdev->dev, pdata->hub_host2_5V_rest_gpio, "hub_host2_5V_rest_gpio");
|
---|
147 | | - if(ret < 0){
|
---|
148 | | - printk("%s() devm_gpio_request hub_host2_5V_rest_gpio request ERROR\n", __FUNCTION__);
|
---|
149 | | - goto err;
|
---|
150 | | - }
|
---|
151 | | -
|
---|
152 | | - ret = gpio_direction_output(pdata->hub_host2_5V_rest_gpio,0);
|
---|
153 | | - if(ret < 0){
|
---|
154 | | - printk("%s() gpio_direction_input hub_host2_5V_rest_gpio set ERROR\n", __FUNCTION__);
|
---|
155 | | - goto err;
|
---|
156 | | - }
|
---|
157 | | - msleep(800);
|
---|
158 | | - ret = gpio_direction_output(pdata->hub_host2_5V_rest_gpio,1);
|
---|
159 | | - if(ret < 0){
|
---|
160 | | - printk("%s() gpio_direction_input hub_host2_5V_rest_gpio set ERROR\n", __FUNCTION__);
|
---|
161 | | - goto err;
|
---|
162 | | - }
|
---|
163 | | - }
|
---|
164 | | -
|
---|
165 | | - //hub_host3_5v_gpio
|
---|
166 | | - ret = of_get_named_gpio_flags(node, "hub_host3_5v_gpio", 0, &flags);
|
---|
167 | | - if (ret < 0) {
|
---|
168 | | - printk("%s() Can not read property hub_host3_5v_gpio\n", __FUNCTION__);
|
---|
169 | | - goto err;
|
---|
170 | | - } else {
|
---|
171 | | - pdata->hub_host3_5v_gpio = ret;
|
---|
172 | | - gpio_free(ret);
|
---|
173 | | - ret = devm_gpio_request(&pdev->dev, pdata->hub_host3_5v_gpio, "hub_host3_5v_gpio");
|
---|
174 | | - if(ret < 0){
|
---|
175 | | - printk("%s() devm_gpio_request hub_host3_5v_gpio request ERROR\n", __FUNCTION__);
|
---|
176 | | - goto err;
|
---|
177 | | - }
|
---|
178 | | -
|
---|
179 | | - ret = gpio_direction_output(pdata->hub_host3_5v_gpio,1);
|
---|
180 | | - if(ret < 0){
|
---|
181 | | - printk("%s() gpio_direction_input hub_host3_5v_gpio set ERROR\n", __FUNCTION__);
|
---|
182 | | - goto err;
|
---|
183 | | - }
|
---|
184 | | - }
|
---|
185 | | -#if 0
|
---|
186 | | - //hub_host3_5V_rest_gpio
|
---|
187 | | - ret = of_get_named_gpio_flags(node, "hub_host3_5V_rest_gpio", 0, &flags);
|
---|
188 | | - if (ret < 0) {
|
---|
189 | | - printk("%s() Can not read property hub_host3_5V_rest_gpio\n", __FUNCTION__);
|
---|
190 | | - goto err;
|
---|
191 | | - } else {
|
---|
192 | | - pdata->hub_host3_5V_rest_gpio = ret;
|
---|
193 | | - ret = devm_gpio_request(&pdev->dev, pdata->hub_host3_5V_rest_gpio, "hub_host3_5V_rest_gpio");
|
---|
194 | | - if(ret < 0){
|
---|
195 | | - printk("%s() devm_gpio_request hub_host3_5V_rest_gpio request ERROR\n", __FUNCTION__);
|
---|
196 | | - goto err;
|
---|
197 | | - }
|
---|
198 | | -
|
---|
199 | | - ret = gpio_direction_output(pdata->hub_host3_5V_rest_gpio,0);
|
---|
200 | | - if(ret < 0){
|
---|
201 | | - printk("%s() gpio_direction_input hub_host3_5V_rest_gpio set ERROR\n", __FUNCTION__);
|
---|
202 | | - goto err;
|
---|
203 | | - }
|
---|
204 | | - msleep(800);
|
---|
205 | | - ret = gpio_direction_output(pdata->hub_host3_5V_rest_gpio,1);
|
---|
206 | | - if(ret < 0){
|
---|
207 | | - printk("%s() gpio_direction_input hub_host3_5V_rest_gpio set ERROR\n", __FUNCTION__);
|
---|
208 | | - goto err;
|
---|
209 | | - }
|
---|
210 | | - }
|
---|
211 | | -#endif
|
---|
212 | | - //wake_4g_gpio
|
---|
213 | | - ret = of_get_named_gpio_flags(node, "wake_4g_gpio", 0, &flags);
|
---|
214 | | - if (ret < 0) {
|
---|
215 | | - printk("%s() Can not read property wake_4g_gpio\n", __FUNCTION__);
|
---|
216 | | - } else {
|
---|
217 | | - pdata->wake_4g_gpio = ret;
|
---|
218 | | -
|
---|
219 | | - ret = devm_gpio_request(&pdev->dev, pdata->wake_4g_gpio, "wake_4g_gpio");
|
---|
220 | | - if(ret < 0){
|
---|
221 | | - printk("%s() devm_gpio_request wake_4g_gpio request ERROR\n", __FUNCTION__);
|
---|
222 | | - }
|
---|
223 | | - ret = gpio_direction_output(pdata->wake_4g_gpio,0);
|
---|
224 | | - if(ret < 0){
|
---|
225 | | - printk("%s() gpio_direction_input wake_4g_gpio set ERROR\n", __FUNCTION__);
|
---|
226 | | - }
|
---|
227 | | - }
|
---|
228 | | -
|
---|
229 | | -
|
---|
230 | | - //reset_4g_gpio
|
---|
231 | | - ret = of_get_named_gpio_flags(node, "reset_4g_gpio", 0, &flags);
|
---|
232 | | - if (ret < 0) {
|
---|
233 | | - printk("%s() Can not read property reset_4g_gpio\n", __FUNCTION__);
|
---|
234 | | - } else {
|
---|
235 | | - pdata->reset_4g_gpio = ret;
|
---|
236 | | -
|
---|
237 | | - ret = devm_gpio_request(&pdev->dev, pdata->reset_4g_gpio, "reset_4g_gpio");
|
---|
238 | | - if(ret < 0){
|
---|
239 | | - printk("%s() devm_gpio_request reset_4g_gpio request ERROR\n", __FUNCTION__);
|
---|
240 | | - }
|
---|
241 | | - ret = gpio_direction_output(pdata->reset_4g_gpio,1);
|
---|
242 | | - if(ret < 0){
|
---|
243 | | - printk("%s() gpio_direction_input reset_4g_gpio set ERROR\n", __FUNCTION__);
|
---|
244 | | - goto err;
|
---|
245 | | - }
|
---|
246 | | - msleep(800);
|
---|
247 | | - ret = gpio_direction_output(pdata->reset_4g_gpio,0);
|
---|
248 | | - if(ret < 0){
|
---|
249 | | - printk("%s() gpio_direction_input reset_4g_gpio set ERROR\n", __FUNCTION__);
|
---|
250 | | -
|
---|
251 | | - }
|
---|
252 | | - }
|
---|
253 | | -
|
---|
254 | | - //en_4g_gpio
|
---|
255 | | - ret = of_get_named_gpio_flags(node, "en_4g_gpio", 0, &flags);
|
---|
256 | | - if (ret < 0) {
|
---|
257 | | - printk("%s() Can not read property en_4g_gpio\n", __FUNCTION__);
|
---|
258 | | - } else {
|
---|
259 | | - pdata->en_4g_gpio = ret;
|
---|
260 | | -
|
---|
261 | | - ret = devm_gpio_request(&pdev->dev, pdata->en_4g_gpio, "en_4g_gpio");
|
---|
262 | | - if(ret < 0){
|
---|
263 | | - printk("%s() devm_gpio_request en_4g_gpio request ERROR\n", __FUNCTION__);
|
---|
264 | | - }
|
---|
265 | | - ret = gpio_direction_output(pdata->en_4g_gpio,1);
|
---|
266 | | - if(ret < 0){
|
---|
267 | | - printk("%s() gpio_direction_output en_4g_gpio set ERROR\n", __FUNCTION__);
|
---|
268 | | - }
|
---|
269 | | - }
|
---|
270 | | -
|
---|
271 | | - //hp_en_gpio
|
---|
272 | | - ret = of_get_named_gpio_flags(node, "hp_en_gpio", 0, &flags);
|
---|
273 | | - if (ret < 0) {
|
---|
274 | | - printk("%s() Can not read property hp_en_gpio\n", __FUNCTION__);
|
---|
275 | | - } else {
|
---|
276 | | - pdata->hp_en_gpio = ret;
|
---|
277 | | -
|
---|
278 | | - ret = devm_gpio_request(&pdev->dev, pdata->hp_en_gpio, "hp_en_gpio");
|
---|
279 | | - if(ret < 0){
|
---|
280 | | - printk("%s() devm_gpio_request hp_en_gpio request ERROR\n", __FUNCTION__);
|
---|
281 | | - }
|
---|
282 | | - ret = gpio_direction_output(pdata->hp_en_gpio,1);
|
---|
283 | | - if(ret < 0){
|
---|
284 | | - printk("%s() gpio_direction_output hp_en_gpio set ERROR\n", __FUNCTION__);
|
---|
285 | | - }
|
---|
286 | | - }
|
---|
287 | | -#if 0
|
---|
288 | | - //pcie_power_en_gpio
|
---|
289 | | - ret = of_get_named_gpio_flags(node, "pcie_power_en_gpio", 0, &flags);
|
---|
290 | | - if (ret < 0) {
|
---|
291 | | - printk("%s() Can not read property pcie_power_en_gpio\n", __FUNCTION__);
|
---|
292 | | - } else {
|
---|
293 | | - pdata->pcie_power_en_gpio = ret;
|
---|
294 | | -
|
---|
295 | | - ret = devm_gpio_request(&pdev->dev, pdata->pcie_power_en_gpio, "pcie_power_en_gpio");
|
---|
296 | | - if(ret < 0){
|
---|
297 | | - printk("%s() devm_gpio_request pcie_power_en_gpio request ERROR\n", __FUNCTION__);
|
---|
298 | | - }
|
---|
299 | | - ret = gpio_direction_output(pdata->pcie_power_en_gpio,1);
|
---|
300 | | - if(ret < 0){
|
---|
301 | | - printk("%s() gpio_direction_output pcie_power_en_gpio set ERROR\n", __FUNCTION__);
|
---|
302 | | - }
|
---|
303 | | - }
|
---|
304 | | -#endif
|
---|
305 | | - //wifi_power_en_gpio
|
---|
306 | | - ret = of_get_named_gpio_flags(node, "wifi_power_en_gpio", 0, &flags);
|
---|
307 | | - if (ret < 0) {
|
---|
308 | | - printk("%s() Can not read property wifi_power_en_gpio\n", __FUNCTION__);
|
---|
309 | | - } else {
|
---|
310 | | - pdata->wifi_power_en_gpio = ret;
|
---|
311 | | -
|
---|
312 | | - ret = devm_gpio_request(&pdev->dev, pdata->wifi_power_en_gpio, "wifi_power_en_gpio");
|
---|
313 | | - if(ret < 0){
|
---|
314 | | - printk("%s() devm_gpio_request wifi_power_en_gpio request ERROR\n", __FUNCTION__);
|
---|
315 | | - }
|
---|
316 | | - ret = gpio_direction_output(pdata->wifi_power_en_gpio,1);
|
---|
317 | | - if(ret < 0){
|
---|
318 | | - printk("%s() gpio_direction_output wifi_power_en_gpio set ERROR\n", __FUNCTION__);
|
---|
319 | | - }
|
---|
320 | | - }
|
---|
321 | | -
|
---|
322 | | -/*
|
---|
323 | | - //spk_out_gpio
|
---|
324 | | - ret = of_get_named_gpio_flags(node, "spk_out_gpio", 0, &flags);
|
---|
325 | | - if (ret < 0) {
|
---|
326 | | - printk("%s() Can not read property spk_out_gpio\n", __FUNCTION__);
|
---|
327 | | - } else {
|
---|
328 | | - pdata->spk_out_gpio = ret;
|
---|
329 | | -
|
---|
330 | | - ret = devm_gpio_request(&pdev->dev, pdata->spk_out_gpio, "spk_out_gpio");
|
---|
331 | | - if(ret < 0){
|
---|
332 | | - printk("%s() devm_gpio_request spk_out_gpio request ERROR\n", __FUNCTION__);
|
---|
333 | | - }
|
---|
334 | | - ret = gpio_direction_output(pdata->spk_out_gpio,0);
|
---|
335 | | - if(ret < 0){
|
---|
336 | | - printk("%s() gpio_direction_output spk_out_gpio set ERROR\n", __FUNCTION__);
|
---|
337 | | - }
|
---|
338 | | - }
|
---|
339 | | -*/
|
---|
340 | | - //air_mode_4g_gpio
|
---|
341 | | - ret = of_get_named_gpio_flags(node, "air_mode_4g_gpio", 0, &flags);
|
---|
342 | | - if (ret < 0) {
|
---|
343 | | - printk("%s() Can not read property air_mode_4g_gpio\n", __FUNCTION__);
|
---|
344 | | - } else {
|
---|
345 | | - pdata->air_mode_4g_gpio = ret;
|
---|
346 | | -
|
---|
347 | | - ret = devm_gpio_request(&pdev->dev, pdata->air_mode_4g_gpio, "air_mode_4g_gpio");
|
---|
348 | | - if(ret < 0){
|
---|
349 | | - printk("%s() devm_gpio_request air_mode_4g_gpio request ERROR\n", __FUNCTION__);
|
---|
350 | | - }
|
---|
351 | | - ret = gpio_direction_output(pdata->air_mode_4g_gpio,0);
|
---|
352 | | - if(ret < 0){
|
---|
353 | | - printk("%s() gpio_direction_input air_mode_4g_gpio set ERROR\n", __FUNCTION__);
|
---|
354 | | - }
|
---|
355 | | - }
|
---|
356 | | -
|
---|
357 | | -
|
---|
358 | | -/*
|
---|
359 | | - //edp_power_supply_gpio;
|
---|
360 | | - ret = of_get_named_gpio_flags(node, "edp_power_supply_gpio", 0, &flags);
|
---|
361 | | - if (ret < 0) {
|
---|
362 | | - printk("%s() Can not read property edp_power_supply_gpio\n", __FUNCTION__);
|
---|
363 | | - } else {
|
---|
364 | | - pdata->edp_power_supply_gpio = ret;
|
---|
365 | | -
|
---|
366 | | - ret = devm_gpio_request(&pdev->dev, pdata->edp_power_supply_gpio, "edp_power_supply_gpio");
|
---|
367 | | - if(ret < 0){
|
---|
368 | | - printk("%s() devm_gpio_request edp_power_supply_gpio request ERROR\n", __FUNCTION__);
|
---|
369 | | - }
|
---|
370 | | -
|
---|
371 | | - ret = gpio_direction_output(pdata->edp_power_supply_gpio,1);
|
---|
372 | | - if(ret < 0){
|
---|
373 | | - printk("%s() gpio_direction_input edp_power_supply_gpio set ERROR\n", __FUNCTION__);
|
---|
374 | | - }
|
---|
375 | | - }
|
---|
376 | | -
|
---|
377 | | - //edp_enable-gpio;
|
---|
378 | | - ret = of_get_named_gpio_flags(node, "edp_enable_gpio", 0, &flags);
|
---|
379 | | - if (ret < 0) {
|
---|
380 | | - printk("%s() Can not read property edp_enable_gpio\n", __FUNCTION__);
|
---|
381 | | - } else {
|
---|
382 | | - pdata->edp_enable_gpio = ret;
|
---|
383 | | -
|
---|
384 | | - ret = devm_gpio_request(&pdev->dev, pdata->edp_enable_gpio, "edp_enable_gpio");
|
---|
385 | | - if(ret < 0){
|
---|
386 | | - printk("%s() devm_gpio_request edp_enable_gpio request ERROR\n", __FUNCTION__);
|
---|
387 | | - }
|
---|
388 | | -
|
---|
389 | | - ret = gpio_direction_output(pdata->edp_enable_gpio,1);
|
---|
390 | | - if(ret < 0){
|
---|
391 | | - printk("%s() gpio_direction_input edp_enable_gpio set ERROR\n", __FUNCTION__);
|
---|
392 | | - }
|
---|
393 | | - }
|
---|
394 | | -
|
---|
395 | | - //lcd_bk_en_gpio;
|
---|
396 | | - ret = of_get_named_gpio_flags(node, "lcd_bk_en_gpio", 0, &flags);
|
---|
397 | | - if (ret < 0) {
|
---|
398 | | - printk("%s() Can not read property lcd_bk_en_gpio\n", __FUNCTION__);
|
---|
399 | | - } else {
|
---|
400 | | - pdata->lcd_bk_en_gpio = ret;
|
---|
401 | | -
|
---|
402 | | - ret = devm_gpio_request(&pdev->dev, pdata->lcd_bk_en_gpio, "lcd_bk_en_gpio");
|
---|
403 | | - if(ret < 0){
|
---|
404 | | - printk("%s() devm_gpio_request lcd_bk_en_gpio request ERROR\n", __FUNCTION__);
|
---|
405 | | - }
|
---|
406 | | -
|
---|
407 | | - ret = gpio_direction_output(pdata->lcd_bk_en_gpio,1);
|
---|
408 | | - if(ret < 0){
|
---|
409 | | - printk("%s() gpio_direction_output lcd_bk_en_gpio set ERROR\n", __FUNCTION__);
|
---|
410 | | - }
|
---|
411 | | - }
|
---|
412 | | -
|
---|
413 | | - //lcd_pwblk_gpio;
|
---|
414 | | - ret = of_get_named_gpio_flags(node, "lcd_pwblk_gpio", 0, &flags);
|
---|
415 | | - if (ret < 0) {
|
---|
416 | | - printk("%s() Can not read property lcd_pwblk_gpio\n", __FUNCTION__);
|
---|
417 | | - } else {
|
---|
418 | | - pdata->lcd_pwblk_gpio = ret;
|
---|
419 | | -
|
---|
420 | | - ret = devm_gpio_request(&pdev->dev, pdata->lcd_pwblk_gpio, "lcd_pwblk_gpio");
|
---|
421 | | - if(ret < 0){
|
---|
422 | | - printk("%s() devm_gpio_request lcd_pwblk_gpio request ERROR\n", __FUNCTION__);
|
---|
423 | | - }
|
---|
424 | | -
|
---|
425 | | - ret = gpio_direction_output(pdata->lcd_pwblk_gpio,1);
|
---|
426 | | - if(ret < 0){
|
---|
427 | | - printk("%s() gpio_direction_output lcd_pwblk_gpio set ERROR\n", __FUNCTION__);
|
---|
428 | | - }
|
---|
429 | | - }
|
---|
430 | | -
|
---|
431 | | -
|
---|
432 | | - //edp_set_pixel-s
|
---|
433 | | - ret = of_get_named_gpio_flags(node, "edp_reset", 0, &flags);
|
---|
434 | | - if (ret < 0) {
|
---|
435 | | - printk("%s() Can not read property edp_reset\n", __FUNCTION__);
|
---|
436 | | - goto err;
|
---|
437 | | - }
|
---|
438 | | -
|
---|
439 | | - reset_pin = ret;
|
---|
440 | | -
|
---|
441 | | -// enable lvds
|
---|
442 | | - ret = of_get_named_gpio_flags(node, "edp_gpio0", 0, &flags);
|
---|
443 | | - if (ret < 0) {
|
---|
444 | | - printk("%s() Can not read property edp_gpio0\n", __FUNCTION__);
|
---|
445 | | - goto err;
|
---|
446 | | - }
|
---|
447 | | - gpio0 = ret;
|
---|
448 | | -
|
---|
449 | | -
|
---|
450 | | -
|
---|
451 | | - ret = of_get_named_gpio_flags(node, "edp_gpio1", 0, &flags);
|
---|
452 | | - if (ret < 0) {
|
---|
453 | | - printk("%s() Can not read property edp_gpio1\n", __FUNCTION__);
|
---|
454 | | - goto err;
|
---|
455 | | - }
|
---|
456 | | -
|
---|
457 | | - gpio1 = ret;
|
---|
458 | | -
|
---|
459 | | - ret = of_get_named_gpio_flags(node, "edp_gpio2", 0, &flags);
|
---|
460 | | - if (ret < 0) {
|
---|
461 | | - printk("%s() Can not read property edp_gpio2\n", __FUNCTION__);
|
---|
462 | | - goto err;
|
---|
463 | | - }
|
---|
464 | | -
|
---|
465 | | - gpio2 = ret;
|
---|
466 | | -
|
---|
467 | | - ret = of_get_named_gpio_flags(node, "edp_gpio3", 0, &flags);
|
---|
468 | | - if (ret < 0) {
|
---|
469 | | - printk("%s() Can not read property edp_gpio3\n", __FUNCTION__);
|
---|
470 | | - goto err;
|
---|
471 | | - }
|
---|
472 | | -
|
---|
473 | | - gpio3 = ret;
|
---|
474 | | -
|
---|
475 | | -
|
---|
476 | | - ret = devm_gpio_request(&pdev->dev, reset_pin, "edp_reset");
|
---|
477 | | - if(ret < 0){
|
---|
478 | | - printk("%s() devm_gpio_request edp_reset request ERROR\n", __FUNCTION__);
|
---|
479 | | - goto err;
|
---|
480 | | - }
|
---|
481 | | -
|
---|
482 | | -
|
---|
483 | | - ret = devm_gpio_request(&pdev->dev, gpio0, "edp_gpio0");
|
---|
484 | | - if(ret < 0){
|
---|
485 | | - printk("%s() devm_gpio_request edp_gpio0 request ERROR\n", __FUNCTION__);
|
---|
486 | | - goto err;
|
---|
487 | | - }
|
---|
488 | | -
|
---|
489 | | - ret = devm_gpio_request(&pdev->dev, gpio1, "edp_gpio1");
|
---|
490 | | - if(ret < 0){
|
---|
491 | | - printk("%s() devm_gpio_request edp_gpio1 request ERROR\n", __FUNCTION__);
|
---|
492 | | - goto err;
|
---|
493 | | - }
|
---|
494 | | -
|
---|
495 | | - ret = devm_gpio_request(&pdev->dev, gpio2, "edp_gpio2");
|
---|
496 | | - if(ret < 0){
|
---|
497 | | - printk("%s() devm_gpio_request edp_gpio2 request ERROR\n", __FUNCTION__);
|
---|
498 | | - goto err;
|
---|
499 | | - }
|
---|
500 | | -
|
---|
501 | | - ret = devm_gpio_request(&pdev->dev, gpio3, "edp_gpio3");
|
---|
502 | | - if(ret < 0){
|
---|
503 | | - printk("%s() devm_gpio_request edp_gpio3 request ERROR\n", __FUNCTION__);
|
---|
504 | | - goto err;
|
---|
505 | | - }
|
---|
506 | | -
|
---|
507 | | - ret = of_property_read_u32(node, "nodka_lvds", &lvds_index);
|
---|
508 | | - if (ret < 0){
|
---|
509 | | - printk("%s() Can not read property nodka_lvds\n", __FUNCTION__);
|
---|
510 | | - }
|
---|
511 | | -
|
---|
512 | | - printk("nodka_lvds_index = %d\n",lvds_index);
|
---|
513 | | -
|
---|
514 | | - while ( i < 4 ){
|
---|
515 | | - if ( lvds_index > 0)
|
---|
516 | | - lvds_gpio[i] = lvds_index%2;
|
---|
517 | | - else
|
---|
518 | | - lvds_gpio[i] = 0;
|
---|
519 | | - printk("lvds_gpio[%d]=%d\n",i,lvds_gpio[i]);
|
---|
520 | | - lvds_index = lvds_index/2;
|
---|
521 | | - i++;
|
---|
522 | | - }
|
---|
523 | | -
|
---|
524 | | - gpio_direction_output(reset_pin, 0);
|
---|
525 | | - usleep_range(80000, 100000);
|
---|
526 | | - gpio_direction_output(reset_pin, 1);
|
---|
527 | | - usleep_range(80000, 100000);
|
---|
528 | | -
|
---|
529 | | - gpio_direction_output(gpio0, lvds_gpio[0]);
|
---|
530 | | - gpio_direction_output(gpio1, lvds_gpio[1]);
|
---|
531 | | - gpio_direction_output(gpio2, lvds_gpio[2]);
|
---|
532 | | - gpio_direction_output(gpio3, lvds_gpio[3]);
|
---|
533 | | -
|
---|
534 | | -
|
---|
535 | | - gpio_direction_output(reset_pin, 0);
|
---|
536 | | - usleep_range(80000, 100000);
|
---|
537 | | - gpio_direction_output(reset_pin, 1);
|
---|
538 | | - usleep_range(80000, 100000);
|
---|
539 | | -*/
|
---|
540 | | - printk(" #######nk_io_control_probe end####### \n");
|
---|
541 | | - return 0;
|
---|
542 | | -
|
---|
543 | | -err:
|
---|
544 | | - kfree(pdata);
|
---|
545 | | - return ret;
|
---|
546 | | -}
|
---|
547 | | -
|
---|
548 | | -
|
---|
549 | | -static int nk_io_control_remove(struct platform_device *pdev)
|
---|
550 | | -{
|
---|
551 | | - if(NKpdata_info)
|
---|
552 | | - kfree(NKpdata_info);
|
---|
553 | | - return 0;
|
---|
554 | | -}
|
---|
555 | | -
|
---|
556 | | -static int nk_io_control_suspend(struct platform_device *pdev, pm_message_t state)
|
---|
557 | | -{
|
---|
558 | | - int ret;
|
---|
559 | | - struct nk_io_pdata *pdata;
|
---|
560 | | - printk("nk_suspend !!!!\n");
|
---|
561 | | -#if 0
|
---|
562 | | - ret = gpio_get_value(8);
|
---|
563 | | - printk("vcc12v gpio value : %d\n",ret);
|
---|
564 | | - usleep_range(80000, 100000);
|
---|
565 | | - gpio_set_value(8,0);
|
---|
566 | | - ret = gpio_get_value(8);
|
---|
567 | | - printk("vcc12v gpio value : %d\n",ret);
|
---|
568 | | -#endif
|
---|
569 | | -#if 0
|
---|
570 | | - ret = gpio_get_value(21);
|
---|
571 | | - printk("hub_host3_5v_gpio value : %d\n",ret);
|
---|
572 | | - usleep_range(80000, 100000);
|
---|
573 | | - gpio_set_value(21,0);
|
---|
574 | | - ret = gpio_get_value(21);
|
---|
575 | | - printk("hub_host3_5v_gpio value : %d\n",ret);
|
---|
576 | | - //enable = 0;
|
---|
577 | | - //LED_SET(0);
|
---|
578 | | -#endif
|
---|
579 | | - return 0;
|
---|
580 | | -}
|
---|
581 | | -
|
---|
582 | | -static int nk_io_control_resume(struct platform_device *pdev)
|
---|
583 | | -{
|
---|
584 | | - return 0;
|
---|
585 | | -}
|
---|
586 | | -
|
---|
587 | | -static const struct of_device_id nk_io_control_of_match[] = {
|
---|
588 | | - { .compatible = "nk_io_control", },
|
---|
589 | | - {},
|
---|
| 4 | +#include <linux/kernel.h>
|
---|
| 5 | +#include <linux/of_gpio.h>
|
---|
| 6 | +#include <linux/of_platform.h>
|
---|
| 7 | +#include <linux/delay.h>
|
---|
| 8 | +#include <linux/input.h>
|
---|
| 9 | +#include <linux/proc_fs.h>
|
---|
| 10 | +#include <linux/kernel.h>
|
---|
| 11 | +#include <linux/init.h>
|
---|
| 12 | +#include <asm/uaccess.h>
|
---|
| 13 | +#include <linux/string.h>
|
---|
| 14 | +#include <linux/uaccess.h>
|
---|
| 15 | +
|
---|
| 16 | +#define GPIO_FUNCTION_OUTPUT 0
|
---|
| 17 | +#define GPIO_FUNCTION_INPUT 1
|
---|
| 18 | +#define GPIO_FUNCTION_RESET 3
|
---|
| 19 | +
|
---|
| 20 | +static int flash_flag = 0;
|
---|
| 21 | +
|
---|
| 22 | +struct ndj_gpio {
|
---|
| 23 | + int gpio_num; //gpui num
|
---|
| 24 | + int action; //gpio flag
|
---|
| 25 | + int gpio_event; //input only
|
---|
| 26 | + int send_mode; //input only
|
---|
| 27 | + int gpio_function; //gpio function,i/o
|
---|
| 28 | + int gpio_ctrl;
|
---|
| 29 | + char *gpio_name;
|
---|
590 | 30 | };
|
---|
591 | | -MODULE_DEVICE_TABLE(of, nk_io_control_of_match);
|
---|
592 | | -
|
---|
593 | | -static struct platform_driver nk_io_control_driver = {
|
---|
594 | | - .probe = nk_io_control_probe,
|
---|
595 | | - .remove = nk_io_control_remove,
|
---|
596 | | - .resume = nk_io_control_resume,
|
---|
597 | | - .suspend = nk_io_control_suspend,
|
---|
598 | | - .driver = {
|
---|
599 | | - .name = "nk_io_control",
|
---|
600 | | - .owner = THIS_MODULE,
|
---|
601 | | - .of_match_table = of_match_ptr(nk_io_control_of_match),
|
---|
602 | | - },
|
---|
| 31 | +
|
---|
| 32 | +struct ndj_gpio_data {
|
---|
| 33 | + struct ndj_gpio ndj_gpio_num[20];
|
---|
| 34 | + struct input_dev *input;
|
---|
| 35 | + struct timer_list mytimer;
|
---|
| 36 | + int gpio_dts_num;
|
---|
603 | 37 | };
|
---|
604 | | -
|
---|
605 | | -static int __init nk_io_control_init(void)
|
---|
| 38 | +
|
---|
| 39 | +static struct ndj_gpio_data *gpio_data = NULL;
|
---|
| 40 | +static int event_flag = 0;
|
---|
| 41 | +static int open_now = 0;
|
---|
| 42 | +static char* file_name = NULL;
|
---|
| 43 | +
|
---|
| 44 | +static int gpio_open(struct inode *inode, struct file *file)
|
---|
606 | 45 | {
|
---|
607 | | - platform_driver_register(&nk_io_control_driver);
|
---|
608 | | - return 0;
|
---|
| 46 | + struct dentry* dent = file->f_path.dentry;
|
---|
| 47 | + int i = 0;
|
---|
| 48 | +
|
---|
| 49 | + file_name = (char*)(dent->d_name.name);
|
---|
| 50 | +
|
---|
| 51 | + for (i = 0; i < gpio_data->gpio_dts_num; i++){
|
---|
| 52 | + if(!strcmp(file_name,gpio_data->ndj_gpio_num[i].gpio_name)){
|
---|
| 53 | + open_now = i;
|
---|
| 54 | + }
|
---|
| 55 | + }
|
---|
| 56 | + return 0;
|
---|
609 | 57 | }
|
---|
610 | | -
|
---|
611 | | -static void __exit nk_io_control_exit(void)
|
---|
| 58 | +
|
---|
| 59 | +static ssize_t gpio_write(struct file *file, const char *buffer,size_t count, loff_t *data)
|
---|
612 | 60 | {
|
---|
613 | | - platform_driver_unregister(&nk_io_control_driver);
|
---|
| 61 | + char buf[2]={0};
|
---|
| 62 | + char s1[]="1";
|
---|
| 63 | +
|
---|
| 64 | + if(copy_from_user(&buf[0],buffer,1)){
|
---|
| 65 | + printk("failed to copy data to kernel space\n");
|
---|
| 66 | + return -EFAULT;
|
---|
| 67 | + }
|
---|
| 68 | +
|
---|
| 69 | + if(!strcmp(buf,s1)){
|
---|
| 70 | + gpio_direction_output(gpio_data->ndj_gpio_num[open_now].gpio_num,1);
|
---|
| 71 | + //printk("%s write 1 succeed\n",gpio_data->ndj_gpio_num[open_now].gpio_name);
|
---|
| 72 | + }else{
|
---|
| 73 | + gpio_direction_output(gpio_data->ndj_gpio_num[open_now].gpio_num,0);
|
---|
| 74 | + //printk("%s write 0 succeed\n",gpio_data->ndj_gpio_num[open_now].gpio_name);
|
---|
| 75 | + }
|
---|
| 76 | + return count;
|
---|
614 | 77 | }
|
---|
615 | | -
|
---|
616 | | -subsys_initcall(nk_io_control_init);
|
---|
617 | | -
|
---|
618 | | -//late_initcall(nk_io_control_init);
|
---|
619 | | -MODULE_DESCRIPTION("nk io Core Driver");
|
---|
| 78 | +
|
---|
| 79 | +
|
---|
| 80 | +static ssize_t gpio_read(struct file *file, char __user * buffer, size_t count, loff_t *data)
|
---|
| 81 | +{
|
---|
| 82 | + int gpio_val = 0;
|
---|
| 83 | + int len = 0;
|
---|
| 84 | + char s[10] = {0};
|
---|
| 85 | +
|
---|
| 86 | + if(*data)
|
---|
| 87 | + return 0;
|
---|
| 88 | +
|
---|
| 89 | + gpio_val = gpio_get_value(gpio_data->ndj_gpio_num[open_now].gpio_num);
|
---|
| 90 | + //printk("get %s value %d\n",gpio_data->ndj_gpio_num[open_now].gpio_name,gpio_val);
|
---|
| 91 | +
|
---|
| 92 | + len = sprintf(s+len, "%d\n",gpio_val);
|
---|
| 93 | +
|
---|
| 94 | + return simple_read_from_buffer(buffer, count, data, s, 2);
|
---|
| 95 | +}
|
---|
| 96 | +
|
---|
| 97 | +
|
---|
| 98 | +static const struct file_operations gpio_ops = {
|
---|
| 99 | + .owner = THIS_MODULE,
|
---|
| 100 | + .open = gpio_open,
|
---|
| 101 | + .write = gpio_write,
|
---|
| 102 | + .read = gpio_read,
|
---|
| 103 | +};
|
---|
| 104 | +
|
---|
| 105 | +static int ndj_gpio_probe(struct platform_device *pdev) {
|
---|
| 106 | + struct device_node *np = pdev->dev.of_node;
|
---|
| 107 | + struct device_node *child_np;
|
---|
| 108 | + struct device *dev = &pdev->dev;
|
---|
| 109 | + static struct proc_dir_entry *root_entry_gpio;
|
---|
| 110 | + enum of_gpio_flags gpio_flags;
|
---|
| 111 | + int ret = 0;
|
---|
| 112 | + int gpio_cnt = 0;
|
---|
| 113 | + char gpio_name_num[20];
|
---|
| 114 | + int gpio_in_cnt = 0;
|
---|
| 115 | + int cnt =0;
|
---|
| 116 | + int lvds_index = 0;
|
---|
| 117 | + int gpio0, gpio1, gpio2, gpio3;
|
---|
| 118 | + int i=0;
|
---|
| 119 | + enum of_gpio_flags flags;
|
---|
| 120 | +
|
---|
| 121 | + gpio_data = devm_kzalloc(&pdev->dev, sizeof(struct ndj_gpio_data),GFP_KERNEL);
|
---|
| 122 | + if (!gpio_data) {
|
---|
| 123 | + dev_err(&pdev->dev, "failed to allocate memory\n");
|
---|
| 124 | + return -ENOMEM;
|
---|
| 125 | + }
|
---|
| 126 | +
|
---|
| 127 | + gpio_data->gpio_dts_num = of_get_child_count(np);
|
---|
| 128 | +// printk("ndj_gpio prepare build %d gpio\n",gpio_data->gpio_dts_num);
|
---|
| 129 | +
|
---|
| 130 | + if (gpio_data->gpio_dts_num == 0){
|
---|
| 131 | + dev_info(&pdev->dev, "no gpio defined\n");
|
---|
| 132 | + }
|
---|
| 133 | +
|
---|
| 134 | + /* create node */
|
---|
| 135 | + root_entry_gpio = proc_mkdir("ndj_gpio", NULL);
|
---|
| 136 | +
|
---|
| 137 | + for_each_child_of_node(np, child_np)
|
---|
| 138 | + {
|
---|
| 139 | + /* parse dts */
|
---|
| 140 | + gpio_data->ndj_gpio_num[gpio_cnt].gpio_num = of_get_named_gpio_flags(child_np, "gpio_num", 0, &gpio_flags);
|
---|
| 141 | + if (!gpio_is_valid(gpio_data->ndj_gpio_num[gpio_cnt].gpio_num)){
|
---|
| 142 | + return -1;
|
---|
| 143 | + }
|
---|
| 144 | +
|
---|
| 145 | + gpio_data->ndj_gpio_num[gpio_cnt].gpio_name = (char*)child_np -> name;
|
---|
| 146 | + gpio_data->ndj_gpio_num[gpio_cnt].action = gpio_flags;
|
---|
| 147 | + gpio_data->ndj_gpio_num[gpio_cnt].gpio_ctrl = gpio_cnt;
|
---|
| 148 | + of_property_read_u32(child_np, "gpio_function", &(gpio_data->ndj_gpio_num[gpio_cnt].gpio_function));
|
---|
| 149 | +
|
---|
| 150 | +// printk("ndj_gpio request %s\n",gpio_data->ndj_gpio_num[gpio_cnt].gpio_name);
|
---|
| 151 | +
|
---|
| 152 | +
|
---|
| 153 | + switch(gpio_data->ndj_gpio_num[gpio_cnt].gpio_function) {
|
---|
| 154 | + case GPIO_FUNCTION_INPUT : /* init input gpio */
|
---|
| 155 | + ret = gpio_request(gpio_data->ndj_gpio_num[gpio_cnt].gpio_num, gpio_data->ndj_gpio_num[gpio_cnt].gpio_name);
|
---|
| 156 | + if (ret < 0)
|
---|
| 157 | + {
|
---|
| 158 | + printk("gpio%d request error\n",gpio_data->ndj_gpio_num[gpio_cnt].gpio_num);
|
---|
| 159 | + }else{
|
---|
| 160 | + // printk("success request gpio %d in\n",gpio_data->ndj_gpio_num[gpio_cnt].gpio_num);
|
---|
| 161 | +
|
---|
| 162 | + gpio_direction_input(gpio_data->ndj_gpio_num[gpio_cnt].gpio_num);
|
---|
| 163 | + //gpio_direction_output(gpio_data->ndj_gpio_num[gpio_cnt].gpio_num,!gpio_data->ndj_gpio_num[gpio_cnt].action);
|
---|
| 164 | + event_flag = gpio_flags;
|
---|
| 165 | + of_property_read_u32(child_np, "send_mode", &(gpio_data->ndj_gpio_num[gpio_cnt].send_mode));
|
---|
| 166 | + of_property_read_u32(child_np, "gpio_event", &(gpio_data->ndj_gpio_num[gpio_cnt].gpio_event));
|
---|
| 167 | + gpio_in_cnt++;
|
---|
| 168 | + }
|
---|
| 169 | + break;
|
---|
| 170 | +
|
---|
| 171 | + case GPIO_FUNCTION_OUTPUT : /* init output gpio */
|
---|
| 172 | + ret = gpio_request(gpio_data->ndj_gpio_num[gpio_cnt].gpio_num, gpio_data->ndj_gpio_num[gpio_cnt].gpio_name);
|
---|
| 173 | + if (ret < 0){
|
---|
| 174 | + printk("gpio%d request error\n",gpio_data->ndj_gpio_num[gpio_cnt].gpio_num);
|
---|
| 175 | + //return ret;
|
---|
| 176 | + }else{
|
---|
| 177 | + gpio_direction_output(gpio_data->ndj_gpio_num[gpio_cnt].gpio_num,!gpio_data->ndj_gpio_num[gpio_cnt].action);
|
---|
| 178 | + //printk("success request gpio%d out\n",gpio_data->ndj_gpio_num[gpio_cnt].gpio_num);
|
---|
| 179 | + }
|
---|
| 180 | + break;
|
---|
| 181 | +
|
---|
| 182 | + case GPIO_FUNCTION_RESET :
|
---|
| 183 | + ret = gpio_request(gpio_data->ndj_gpio_num[gpio_cnt].gpio_num, gpio_data->ndj_gpio_num[gpio_cnt].gpio_name);
|
---|
| 184 | + if (ret < 0){
|
---|
| 185 | + printk("gpio%d request error\n",gpio_data->ndj_gpio_num[gpio_cnt].gpio_num);
|
---|
| 186 | + //return ret;
|
---|
| 187 | + }else{
|
---|
| 188 | + gpio_direction_output(gpio_data->ndj_gpio_num[gpio_cnt].gpio_num,gpio_data->ndj_gpio_num[gpio_cnt].action);
|
---|
| 189 | + //printk("success request gpio%d reset\n",gpio_data->ndj_gpio_num[gpio_cnt].gpio_num);
|
---|
| 190 | + mdelay(200);
|
---|
| 191 | + gpio_direction_output(gpio_data->ndj_gpio_num[gpio_cnt].gpio_num,!gpio_data->ndj_gpio_num[gpio_cnt].action);
|
---|
| 192 | +
|
---|
| 193 | +// gpio_cnt++;
|
---|
| 194 | + }
|
---|
| 195 | + break;
|
---|
| 196 | + }
|
---|
| 197 | +
|
---|
| 198 | + sprintf(gpio_name_num,gpio_data->ndj_gpio_num[gpio_cnt].gpio_name,gpio_cnt);
|
---|
| 199 | + proc_create(gpio_name_num, 0666 , root_entry_gpio , &gpio_ops);
|
---|
| 200 | + gpio_cnt++;
|
---|
| 201 | + }
|
---|
| 202 | +
|
---|
| 203 | + platform_set_drvdata(pdev, gpio_data);
|
---|
| 204 | + return 0;
|
---|
| 205 | +}
|
---|
| 206 | +
|
---|
| 207 | +
|
---|
| 208 | +static int ndj_gpio_suspend(struct platform_device *pdev, pm_message_t state)
|
---|
| 209 | +{
|
---|
| 210 | + int ret;
|
---|
| 211 | + struct nk_io_pdata *pdata;
|
---|
| 212 | + printk("nk_suspend !!!!\n");
|
---|
| 213 | + return 0;
|
---|
| 214 | +}
|
---|
| 215 | +
|
---|
| 216 | +static int ndj_gpio_resume(struct platform_device *pdev)
|
---|
| 217 | +{
|
---|
| 218 | + int ret,reset_pin;
|
---|
| 219 | + printk("nk_io resume !!!!\n");
|
---|
| 220 | + return 0;
|
---|
| 221 | +}
|
---|
| 222 | +
|
---|
| 223 | +
|
---|
| 224 | +static int ndj_gpio_remove(struct platform_device *pdev)
|
---|
| 225 | +{
|
---|
| 226 | + return 0;
|
---|
| 227 | +}
|
---|
| 228 | +
|
---|
| 229 | +
|
---|
| 230 | +static const struct of_device_id ndj_gpio_of_match[] = {
|
---|
| 231 | + { .compatible = "nk_io_control" },
|
---|
| 232 | + { }
|
---|
| 233 | +};
|
---|
| 234 | +
|
---|
| 235 | +static struct platform_driver ndj_gpio_driver = {
|
---|
| 236 | + .probe = ndj_gpio_probe,
|
---|
| 237 | + .remove = ndj_gpio_remove,
|
---|
| 238 | + .resume = ndj_gpio_resume,
|
---|
| 239 | + .suspend = ndj_gpio_suspend,
|
---|
| 240 | + .driver = {
|
---|
| 241 | + .name = "nk_io_control",
|
---|
| 242 | + .of_match_table = of_match_ptr(ndj_gpio_of_match),
|
---|
| 243 | + },
|
---|
| 244 | +};
|
---|
| 245 | +
|
---|
| 246 | +module_platform_driver(ndj_gpio_driver);
|
---|
620 | 247 | MODULE_LICENSE("GPL");
|
---|
| 248 | +MODULE_LICENSE("GPL"); |
---|