os/linux-2.6-tag--devboard-R2_10-4/include/asm-cris/arch-v32/io.h

Go to the documentation of this file.
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 #if (defined(CONFIG_ETRAX_NBR_LED_GRP_ONE) || defined(CONFIG_ETRAX_NBR_LED_GRP_TWO))
00101 #define LED_NETWORK_GRP0_SET(x)                          \
00102         do {                                             \
00103                 LED_NETWORK_GRP0_SET_G((x) & LED_GREEN); \
00104                 LED_NETWORK_GRP0_SET_R((x) & LED_RED);   \
00105         } while (0)
00106 #else
00107 #define LED_NETWORK_GRP0_SET(x) while (0) {}
00108 #endif
00109 
00110 #define LED_NETWORK_GRP0_SET_G(x) \
00111         crisv32_io_set(&crisv32_led_net0_green, !(x));
00112 
00113 #define LED_NETWORK_GRP0_SET_R(x) \
00114         crisv32_io_set(&crisv32_led_net0_red, !(x));
00115 
00116 #if defined(CONFIG_ETRAX_NBR_LED_GRP_TWO)
00117 #define LED_NETWORK_GRP1_SET(x)                          \
00118         do {                                             \
00119                 LED_NETWORK_GRP1_SET_G((x) & LED_GREEN); \
00120                 LED_NETWORK_GRP1_SET_R((x) & LED_RED);   \
00121         } while (0)
00122 #else
00123 #define LED_NETWORK_GRP1_SET(x) while (0) {}
00124 #endif
00125 
00126 #define LED_NETWORK_GRP1_SET_G(x) \
00127         crisv32_io_set(&crisv32_led_net1_green, !(x));
00128 
00129 #define LED_NETWORK_GRP1_SET_R(x) \
00130         crisv32_io_set(&crisv32_led_net1_red, !(x));
00131 
00132 #define LED_ACTIVE_SET(x)                           \
00133         do {                                        \
00134                 LED_ACTIVE_SET_G((x) & LED_GREEN);  \
00135                 LED_ACTIVE_SET_R((x) & LED_RED);    \
00136         } while (0)
00137 
00138 #define LED_ACTIVE_SET_G(x) \
00139         crisv32_io_set(&crisv32_led2_green, !(x));
00140 #define LED_ACTIVE_SET_R(x) \
00141         crisv32_io_set(&crisv32_led2_red, !(x));
00142 #define LED_DISK_WRITE(x) \
00143          do{\
00144                 crisv32_io_set(&crisv32_led3_green, !(x)); \
00145                 crisv32_io_set(&crisv32_led3_red, !(x));   \
00146         }while(0)
00147 #define LED_DISK_READ(x) \
00148         crisv32_io_set(&crisv32_led3_green, !(x));
00149 */
00150 #endif

Generated on Fri Nov 28 00:06:24 2008 for elphel by  doxygen 1.5.1