00001 #ifndef _ASM_ARCH_CRIS_IO_H
00002 #define _ASM_ARCH_CRIS_IO_H
00003
00004 #include <linux/spinlock.h>
00005 #include <asm/arch/hwregs/reg_map.h>
00006 #include <asm/arch/hwregs/reg_rdwr.h>
00007 #include <asm/arch/hwregs/gio_defs.h>
00008
00009 enum crisv32_io_dir
00010 {
00011 crisv32_io_dir_in = 0,
00012 crisv32_io_dir_out = 1
00013 };
00014
00015 struct crisv32_ioport
00016 {
00017 volatile unsigned long* oe;
00018 volatile unsigned long* data;
00019 volatile unsigned long* data_in;
00020 unsigned int pin_count;
00021 spinlock_t lock;
00022 };
00023
00024 struct crisv32_iopin
00025 {
00026 struct crisv32_ioport* port;
00027 int bit;
00028 };
00029
00030 extern struct crisv32_ioport crisv32_ioports[];
00031
00032 extern struct crisv32_iopin crisv32_led1_green;
00033 extern struct crisv32_iopin crisv32_led1_red;
00034 extern struct crisv32_iopin crisv32_led2_green;
00035 extern struct crisv32_iopin crisv32_led2_red;
00036 extern struct crisv32_iopin crisv32_led3_green;
00037 extern struct crisv32_iopin crisv32_led3_red;
00038
00039 extern struct crisv32_iopin crisv32_led_net0_green;
00040 extern struct crisv32_iopin crisv32_led_net0_red;
00041 extern struct crisv32_iopin crisv32_led_net1_green;
00042 extern struct crisv32_iopin crisv32_led_net1_red;
00043
00044 static inline void crisv32_io_set(struct crisv32_iopin* iopin,
00045 int val)
00046 {
00047 long flags;
00048 spin_lock_irqsave(&iopin->port->lock, flags);
00049
00050 if (val)
00051 *iopin->port->data |= iopin->bit;
00052 else
00053 *iopin->port->data &= ~iopin->bit;
00054
00055 spin_unlock_irqrestore(&iopin->port->lock, flags);
00056 }
00057
00058 static inline void crisv32_io_set_dir(struct crisv32_iopin* iopin,
00059 enum crisv32_io_dir dir)
00060 {
00061 long flags;
00062 spin_lock_irqsave(&iopin->port->lock, flags);
00063
00064 if (dir == crisv32_io_dir_in)
00065 *iopin->port->oe &= ~iopin->bit;
00066 else
00067 *iopin->port->oe |= iopin->bit;
00068
00069 spin_unlock_irqrestore(&iopin->port->lock, flags);
00070 }
00071
00072 static inline int crisv32_io_rd(struct crisv32_iopin* iopin)
00073 {
00074 return ((*iopin->port->data_in & iopin->bit) ? 1 : 0);
00075 }
00076
00077 int crisv32_io_get(struct crisv32_iopin* iopin,
00078 unsigned int port, unsigned int pin);
00079 int crisv32_io_get_name(struct crisv32_iopin* iopin,
00080 const char* name);
00081
00082 #define LED_OFF 0x00
00083 #define LED_GREEN 0x01
00084 #define LED_RED 0x02
00085 #define LED_ORANGE (LED_GREEN | LED_RED)
00086
00087 #define LED_NETWORK_GRP0_SET(x)
00088 #define LED_NETWORK_GRP0_SET_G(x)
00089 #define LED_NETWORK_GRP0_SET_R(x)
00090 #define LED_NETWORK_GRP0_SET(x)
00091 #define LED_NETWORK_GRP1_SET_G(x)
00092 #define LED_NETWORK_GRP1_SET_R(x)
00093 #define LED_ACTIVE_SET(x)
00094 #define LED_ACTIVE_SET_G(x)
00095 #define LED_ACTIVE_SET_R(x)
00096 #define LED_DISK_WRITE(x)
00097 #define LED_DISK_READ(x)
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 #endif