aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-cris/arch-v32/io.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-cris/arch-v32/io.h')
-rw-r--r--include/asm-cris/arch-v32/io.h95
1 files changed, 67 insertions, 28 deletions
diff --git a/include/asm-cris/arch-v32/io.h b/include/asm-cris/arch-v32/io.h
index 5efe4d949001..6b38912f29ba 100644
--- a/include/asm-cris/arch-v32/io.h
+++ b/include/asm-cris/arch-v32/io.h
@@ -1,9 +1,10 @@
1#ifndef _ASM_ARCH_CRIS_IO_H 1#ifndef _ASM_ARCH_CRIS_IO_H
2#define _ASM_ARCH_CRIS_IO_H 2#define _ASM_ARCH_CRIS_IO_H
3 3
4#include <asm/arch/hwregs/reg_map.h> 4#include <linux/spinlock.h>
5#include <asm/arch/hwregs/reg_rdwr.h> 5#include <hwregs/reg_map.h>
6#include <asm/arch/hwregs/gio_defs.h> 6#include <hwregs/reg_rdwr.h>
7#include <hwregs/gio_defs.h>
7 8
8enum crisv32_io_dir 9enum crisv32_io_dir
9{ 10{
@@ -13,10 +14,11 @@ enum crisv32_io_dir
13 14
14struct crisv32_ioport 15struct crisv32_ioport
15{ 16{
16 unsigned long* oe; 17 volatile unsigned long *oe;
17 unsigned long* data; 18 volatile unsigned long *data;
18 unsigned long* data_in; 19 volatile unsigned long *data_in;
19 unsigned int pin_count; 20 unsigned int pin_count;
21 spinlock_t lock;
20}; 22};
21 23
22struct crisv32_iopin 24struct crisv32_iopin
@@ -34,22 +36,36 @@ extern struct crisv32_iopin crisv32_led2_red;
34extern struct crisv32_iopin crisv32_led3_green; 36extern struct crisv32_iopin crisv32_led3_green;
35extern struct crisv32_iopin crisv32_led3_red; 37extern struct crisv32_iopin crisv32_led3_red;
36 38
37static inline void crisv32_io_set(struct crisv32_iopin* iopin, 39extern struct crisv32_iopin crisv32_led_net0_green;
38 int val) 40extern struct crisv32_iopin crisv32_led_net0_red;
41extern struct crisv32_iopin crisv32_led_net1_green;
42extern struct crisv32_iopin crisv32_led_net1_red;
43
44static inline void crisv32_io_set(struct crisv32_iopin *iopin, int val)
39{ 45{
46 long flags;
47 spin_lock_irqsave(&iopin->port->lock, flags);
48
40 if (val) 49 if (val)
41 *iopin->port->data |= iopin->bit; 50 *iopin->port->data |= iopin->bit;
42 else 51 else
43 *iopin->port->data &= ~iopin->bit; 52 *iopin->port->data &= ~iopin->bit;
53
54 spin_unlock_irqrestore(&iopin->port->lock, flags);
44} 55}
45 56
46static inline void crisv32_io_set_dir(struct crisv32_iopin* iopin, 57static inline void crisv32_io_set_dir(struct crisv32_iopin* iopin,
47 enum crisv32_io_dir dir) 58 enum crisv32_io_dir dir)
48{ 59{
60 long flags;
61 spin_lock_irqsave(&iopin->port->lock, flags);
62
49 if (dir == crisv32_io_dir_in) 63 if (dir == crisv32_io_dir_in)
50 *iopin->port->oe &= ~iopin->bit; 64 *iopin->port->oe &= ~iopin->bit;
51 else 65 else
52 *iopin->port->oe |= iopin->bit; 66 *iopin->port->oe |= iopin->bit;
67
68 spin_unlock_irqrestore(&iopin->port->lock, flags);
53} 69}
54 70
55static inline int crisv32_io_rd(struct crisv32_iopin* iopin) 71static inline int crisv32_io_rd(struct crisv32_iopin* iopin)
@@ -60,38 +76,61 @@ static inline int crisv32_io_rd(struct crisv32_iopin* iopin)
60int crisv32_io_get(struct crisv32_iopin* iopin, 76int crisv32_io_get(struct crisv32_iopin* iopin,
61 unsigned int port, unsigned int pin); 77 unsigned int port, unsigned int pin);
62int crisv32_io_get_name(struct crisv32_iopin* iopin, 78int crisv32_io_get_name(struct crisv32_iopin* iopin,
63 char* name); 79 const char *name);
64 80
65#define LED_OFF 0x00 81#define CRIS_LED_OFF 0x00
66#define LED_GREEN 0x01 82#define CRIS_LED_GREEN 0x01
67#define LED_RED 0x02 83#define CRIS_LED_RED 0x02
68#define LED_ORANGE (LED_GREEN | LED_RED) 84#define CRIS_LED_ORANGE (CRIS_LED_GREEN | CRIS_LED_RED)
69 85
70#define LED_NETWORK_SET(x) \ 86#if (defined(CONFIG_ETRAX_NBR_LED_GRP_ONE) || defined(CONFIG_ETRAX_NBR_LED_GRP_TWO))
71 do { \ 87#define CRIS_LED_NETWORK_GRP0_SET(x) \
72 LED_NETWORK_SET_G((x) & LED_GREEN); \ 88 do { \
73 LED_NETWORK_SET_R((x) & LED_RED); \ 89 CRIS_LED_NETWORK_GRP0_SET_G((x) & CRIS_LED_GREEN); \
90 CRIS_LED_NETWORK_GRP0_SET_R((x) & CRIS_LED_RED); \
74 } while (0) 91 } while (0)
75#define LED_ACTIVE_SET(x) \ 92#else
93#define CRIS_LED_NETWORK_GRP0_SET(x) while (0) {}
94#endif
95
96#define CRIS_LED_NETWORK_GRP0_SET_G(x) \
97 crisv32_io_set(&crisv32_led_net0_green, !(x));
98
99#define CRIS_LED_NETWORK_GRP0_SET_R(x) \
100 crisv32_io_set(&crisv32_led_net0_red, !(x));
101
102#if defined(CONFIG_ETRAX_NBR_LED_GRP_TWO)
103#define CRIS_LED_NETWORK_GRP1_SET(x) \
104 do { \
105 CRIS_LED_NETWORK_GRP1_SET_G((x) & CRIS_LED_GREEN); \
106 CRIS_LED_NETWORK_GRP1_SET_R((x) & CRIS_LED_RED); \
107 } while (0)
108#else
109#define CRIS_LED_NETWORK_GRP1_SET(x) while (0) {}
110#endif
111
112#define CRIS_LED_NETWORK_GRP1_SET_G(x) \
113 crisv32_io_set(&crisv32_led_net1_green, !(x));
114
115#define CRIS_LED_NETWORK_GRP1_SET_R(x) \
116 crisv32_io_set(&crisv32_led_net1_red, !(x));
117
118#define CRIS_LED_ACTIVE_SET(x) \
76 do { \ 119 do { \
77 LED_ACTIVE_SET_G((x) & LED_GREEN); \ 120 CRIS_LED_ACTIVE_SET_G((x) & CRIS_LED_GREEN); \
78 LED_ACTIVE_SET_R((x) & LED_RED); \ 121 CRIS_LED_ACTIVE_SET_R((x) & CRIS_LED_RED); \
79 } while (0) 122 } while (0)
80 123
81#define LED_NETWORK_SET_G(x) \ 124#define CRIS_LED_ACTIVE_SET_G(x) \
82 crisv32_io_set(&crisv32_led1_green, !(x));
83#define LED_NETWORK_SET_R(x) \
84 crisv32_io_set(&crisv32_led1_red, !(x));
85#define LED_ACTIVE_SET_G(x) \
86 crisv32_io_set(&crisv32_led2_green, !(x)); 125 crisv32_io_set(&crisv32_led2_green, !(x));
87#define LED_ACTIVE_SET_R(x) \ 126#define CRIS_LED_ACTIVE_SET_R(x) \
88 crisv32_io_set(&crisv32_led2_red, !(x)); 127 crisv32_io_set(&crisv32_led2_red, !(x));
89#define LED_DISK_WRITE(x) \ 128#define CRIS_LED_DISK_WRITE(x) \
90 do{\ 129 do{\
91 crisv32_io_set(&crisv32_led3_green, !(x)); \ 130 crisv32_io_set(&crisv32_led3_green, !(x)); \
92 crisv32_io_set(&crisv32_led3_red, !(x)); \ 131 crisv32_io_set(&crisv32_led3_red, !(x)); \
93 }while(0) 132 }while(0)
94#define LED_DISK_READ(x) \ 133#define CRIS_LED_DISK_READ(x) \
95 crisv32_io_set(&crisv32_led3_green, !(x)); 134 crisv32_io_set(&crisv32_led3_green, !(x));
96 135
97#endif 136#endif