factoryToolV4.0 support on rk3168,lcd,bL,codec,tp,usbwifi,battery control by parameter
[firefly-linux-kernel-4.4.55.git] / arch / arm / plat-rk / config.c
1 #include <mach/gpio.h>
2 #include <mach/board.h>
3
4 int port_output_init(unsigned int value, int on, char *name)
5 {
6         int ret = 0;
7         struct port_config port;
8
9         port = get_port_config(value);
10         ret = gpio_request(port.gpio, name);
11         if(ret < 0)
12                 return ret;
13         if(port.io.pull_mode == PULL_MODE_DISABLE)
14                 gpio_pull_updown(port.gpio, 0);
15         if(port.io.pull_mode == PULL_MODE_ENABLE)
16                 gpio_pull_updown(port.gpio, 1);
17                 #ifdef CONFIG_MACH_RK_FAC
18         //gpio_direction_output(port.gpio, (on)? !port.io.active_low: !!port.io.active_low);
19         #else
20                   gpio_direction_output(port.gpio, (on)? !port.io.active_low: !!port.io.active_low);
21                 #endif 
22
23         return 0;
24 }
25 EXPORT_SYMBOL(port_output_init);
26 void port_output_on(unsigned int value)
27 {
28         struct port_config port;
29
30         port = get_port_config(value);
31         gpio_set_value(port.gpio, !port.io.active_low);
32 }
33 EXPORT_SYMBOL(port_output_on);
34 void port_output_off(unsigned int value)
35 {
36         struct port_config port;
37
38         port = get_port_config(value);
39         gpio_set_value(port.gpio, !!port.io.active_low);
40 }
41 EXPORT_SYMBOL(port_output_off);
42 void port_deinit(unsigned int value)
43 {
44         struct port_config port;
45
46         port = get_port_config(value);
47         gpio_free(port.gpio);
48 }
49 EXPORT_SYMBOL(port_deinit);
50 int port_input_init(unsigned int value, char *name)
51 {
52         int ret = 0;
53         struct port_config port;
54
55         port = get_port_config(value);
56         ret = gpio_request(port.gpio, name);
57         if(ret < 0)
58                 return ret;
59         if(port.io.pull_mode == PULL_MODE_DISABLE)
60                 gpio_pull_updown(port.gpio, 0);
61         if(port.io.pull_mode == PULL_MODE_ENABLE)
62                 gpio_pull_updown(port.gpio, 1);
63         gpio_direction_input(port.gpio);
64
65         return 0;
66 }
67 EXPORT_SYMBOL(port_input_init);
68 int port_get_value(unsigned int value)
69 {
70         struct port_config port;
71
72         port = get_port_config(value);
73         return gpio_get_value(port.gpio);
74 }
75 EXPORT_SYMBOL(port_get_value);
76
77