Contiki 3.x
gpio.h
1 /*
2  * Copyright (C) 2015, Intel Corporation. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * 3. Neither the name of the copyright holder nor the names of its
14  * contributors may be used to endorse or promote products derived
15  * from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28  * OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef CPU_X86_DRIVERS_QUARKX1000_GPIO_H_
32 #define CPU_X86_DRIVERS_QUARKX1000_GPIO_H_
33 
34 #include <stdint.h>
35 
36 #include "pci.h"
37 
38 #define QUARKX1000_GPIO_IN (0 << 0)
39 #define QUARKX1000_GPIO_OUT (1 << 0)
40 #define QUARKX1000_GPIO_INT (1 << 1)
41 #define QUARKX1000_GPIO_ACTIVE_LOW (0 << 2)
42 #define QUARKX1000_GPIO_ACTIVE_HIGH (1 << 2)
43 #define QUARKX1000_GPIO_LEVEL (0 << 3)
44 #define QUARKX1000_GPIO_EDGE (1 << 3)
45 #define QUARKX1000_GPIO_DEBOUNCE (1 << 4)
46 #define QUARKX1000_GPIO_CLOCK_SYNC (1 << 5)
47 #define QUARKX1000_GPIO_POL_NORMAL (0 << 6)
48 #define QUARKX1000_GPIO_POL_INV (1 << 6)
49 #define QUARKX1000_GPIO_PUD_NORMAL (0 << 7)
50 #define QUARKX1000_GPIO_PUD_PULL_UP (1 << 7)
51 #define QUARKX1000_GPIO_PUD_PULL_DOWN (2 << 7)
52 
53 #define QUARKX1000_GPIO_DIR_MASK (1 << 0)
54 #define QUARKX1000_GPIO_POL_MASK (1 << 6)
55 #define QUARKX1000_GPIO_PUD_MASK (3 << 7)
56 
57 typedef void (*quarkX1000_gpio_callback)(uint32_t);
58 
59 int quarkX1000_gpio_init(void);
60 
61 int quarkX1000_gpio_config(uint8_t pin, int flags);
62 int quarkX1000_gpio_read(uint8_t pin, uint8_t *value);
63 int quarkX1000_gpio_write(uint8_t pin, uint8_t value);
64 
65 int quarkX1000_gpio_config_port(int flags);
66 int quarkX1000_gpio_read_port(uint8_t *value);
67 int quarkX1000_gpio_write_port(uint8_t value);
68 
69 int quarkX1000_gpio_set_callback(quarkX1000_gpio_callback callback);
70 
71 void quarkX1000_gpio_clock_enable(void);
72 void quarkX1000_gpio_clock_disable(void);
73 
74 #endif /* CPU_X86_DRIVERS_QUARKX1000_GPIO_H_ */