2005-07-27 12:44:44 -06:00
|
|
|
#ifndef _ASM_ARCH_CRIS_IO_H
|
|
|
|
#define _ASM_ARCH_CRIS_IO_H
|
|
|
|
|
2007-12-03 03:16:25 -07:00
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <hwregs/reg_map.h>
|
|
|
|
#include <hwregs/reg_rdwr.h>
|
|
|
|
#include <hwregs/gio_defs.h>
|
2005-07-27 12:44:44 -06:00
|
|
|
|
|
|
|
enum crisv32_io_dir
|
|
|
|
{
|
|
|
|
crisv32_io_dir_in = 0,
|
|
|
|
crisv32_io_dir_out = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
struct crisv32_ioport
|
|
|
|
{
|
2007-12-03 03:16:25 -07:00
|
|
|
volatile unsigned long *oe;
|
|
|
|
volatile unsigned long *data;
|
|
|
|
volatile unsigned long *data_in;
|
2005-07-27 12:44:44 -06:00
|
|
|
unsigned int pin_count;
|
2007-12-03 03:16:25 -07:00
|
|
|
spinlock_t lock;
|
2005-07-27 12:44:44 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
struct crisv32_iopin
|
|
|
|
{
|
|
|
|
struct crisv32_ioport* port;
|
|
|
|
int bit;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct crisv32_ioport crisv32_ioports[];
|
|
|
|
|
|
|
|
extern struct crisv32_iopin crisv32_led1_green;
|
|
|
|
extern struct crisv32_iopin crisv32_led1_red;
|
|
|
|
extern struct crisv32_iopin crisv32_led2_green;
|
|
|
|
extern struct crisv32_iopin crisv32_led2_red;
|
|
|
|
extern struct crisv32_iopin crisv32_led3_green;
|
|
|
|
extern struct crisv32_iopin crisv32_led3_red;
|
|
|
|
|
2007-12-03 03:16:25 -07:00
|
|
|
extern struct crisv32_iopin crisv32_led_net0_green;
|
|
|
|
extern struct crisv32_iopin crisv32_led_net0_red;
|
|
|
|
extern struct crisv32_iopin crisv32_led_net1_green;
|
|
|
|
extern struct crisv32_iopin crisv32_led_net1_red;
|
|
|
|
|
2008-01-28 08:49:39 -07:00
|
|
|
static inline void crisv32_io_set(struct crisv32_iopin *iopin, int val)
|
2005-07-27 12:44:44 -06:00
|
|
|
{
|
2007-12-03 03:16:25 -07:00
|
|
|
long flags;
|
|
|
|
spin_lock_irqsave(&iopin->port->lock, flags);
|
|
|
|
|
2005-07-27 12:44:44 -06:00
|
|
|
if (val)
|
|
|
|
*iopin->port->data |= iopin->bit;
|
|
|
|
else
|
|
|
|
*iopin->port->data &= ~iopin->bit;
|
2007-12-03 03:16:25 -07:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&iopin->port->lock, flags);
|
2005-07-27 12:44:44 -06:00
|
|
|
}
|
|
|
|
|
2005-11-07 01:58:44 -07:00
|
|
|
static inline void crisv32_io_set_dir(struct crisv32_iopin* iopin,
|
2005-07-27 12:44:44 -06:00
|
|
|
enum crisv32_io_dir dir)
|
|
|
|
{
|
2007-12-03 03:16:25 -07:00
|
|
|
long flags;
|
|
|
|
spin_lock_irqsave(&iopin->port->lock, flags);
|
|
|
|
|
2005-07-27 12:44:44 -06:00
|
|
|
if (dir == crisv32_io_dir_in)
|
|
|
|
*iopin->port->oe &= ~iopin->bit;
|
|
|
|
else
|
|
|
|
*iopin->port->oe |= iopin->bit;
|
2007-12-03 03:16:25 -07:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&iopin->port->lock, flags);
|
2005-07-27 12:44:44 -06:00
|
|
|
}
|
|
|
|
|
2005-11-07 01:58:44 -07:00
|
|
|
static inline int crisv32_io_rd(struct crisv32_iopin* iopin)
|
2005-07-27 12:44:44 -06:00
|
|
|
{
|
|
|
|
return ((*iopin->port->data_in & iopin->bit) ? 1 : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int crisv32_io_get(struct crisv32_iopin* iopin,
|
|
|
|
unsigned int port, unsigned int pin);
|
|
|
|
int crisv32_io_get_name(struct crisv32_iopin* iopin,
|
2007-12-03 03:16:25 -07:00
|
|
|
const char *name);
|
2005-07-27 12:44:44 -06:00
|
|
|
|
2008-01-28 08:49:39 -07:00
|
|
|
#define CRIS_LED_OFF 0x00
|
|
|
|
#define CRIS_LED_GREEN 0x01
|
|
|
|
#define CRIS_LED_RED 0x02
|
|
|
|
#define CRIS_LED_ORANGE (CRIS_LED_GREEN | CRIS_LED_RED)
|
2005-07-27 12:44:44 -06:00
|
|
|
|
2007-12-03 03:16:25 -07:00
|
|
|
#if (defined(CONFIG_ETRAX_NBR_LED_GRP_ONE) || defined(CONFIG_ETRAX_NBR_LED_GRP_TWO))
|
2008-01-28 08:49:39 -07:00
|
|
|
#define CRIS_LED_NETWORK_GRP0_SET(x) \
|
2007-12-03 03:16:25 -07:00
|
|
|
do { \
|
2008-01-28 08:49:39 -07:00
|
|
|
CRIS_LED_NETWORK_GRP0_SET_G((x) & CRIS_LED_GREEN); \
|
|
|
|
CRIS_LED_NETWORK_GRP0_SET_R((x) & CRIS_LED_RED); \
|
2005-07-27 12:44:44 -06:00
|
|
|
} while (0)
|
2007-12-03 03:16:25 -07:00
|
|
|
#else
|
2008-01-28 08:49:39 -07:00
|
|
|
#define CRIS_LED_NETWORK_GRP0_SET(x) while (0) {}
|
2007-12-03 03:16:25 -07:00
|
|
|
#endif
|
|
|
|
|
2008-01-28 08:49:39 -07:00
|
|
|
#define CRIS_LED_NETWORK_GRP0_SET_G(x) \
|
2007-12-03 03:16:25 -07:00
|
|
|
crisv32_io_set(&crisv32_led_net0_green, !(x));
|
|
|
|
|
2008-01-28 08:49:39 -07:00
|
|
|
#define CRIS_LED_NETWORK_GRP0_SET_R(x) \
|
2007-12-03 03:16:25 -07:00
|
|
|
crisv32_io_set(&crisv32_led_net0_red, !(x));
|
|
|
|
|
|
|
|
#if defined(CONFIG_ETRAX_NBR_LED_GRP_TWO)
|
2008-01-28 08:49:39 -07:00
|
|
|
#define CRIS_LED_NETWORK_GRP1_SET(x) \
|
2007-12-03 03:16:25 -07:00
|
|
|
do { \
|
2008-01-28 08:49:39 -07:00
|
|
|
CRIS_LED_NETWORK_GRP1_SET_G((x) & CRIS_LED_GREEN); \
|
|
|
|
CRIS_LED_NETWORK_GRP1_SET_R((x) & CRIS_LED_RED); \
|
2007-12-03 03:16:25 -07:00
|
|
|
} while (0)
|
|
|
|
#else
|
2008-01-28 08:49:39 -07:00
|
|
|
#define CRIS_LED_NETWORK_GRP1_SET(x) while (0) {}
|
2007-12-03 03:16:25 -07:00
|
|
|
#endif
|
|
|
|
|
2008-01-28 08:49:39 -07:00
|
|
|
#define CRIS_LED_NETWORK_GRP1_SET_G(x) \
|
2007-12-03 03:16:25 -07:00
|
|
|
crisv32_io_set(&crisv32_led_net1_green, !(x));
|
|
|
|
|
2008-01-28 08:49:39 -07:00
|
|
|
#define CRIS_LED_NETWORK_GRP1_SET_R(x) \
|
2007-12-03 03:16:25 -07:00
|
|
|
crisv32_io_set(&crisv32_led_net1_red, !(x));
|
|
|
|
|
2008-01-28 08:49:39 -07:00
|
|
|
#define CRIS_LED_ACTIVE_SET(x) \
|
2005-07-27 12:44:44 -06:00
|
|
|
do { \
|
2008-01-28 08:49:39 -07:00
|
|
|
CRIS_LED_ACTIVE_SET_G((x) & CRIS_LED_GREEN); \
|
|
|
|
CRIS_LED_ACTIVE_SET_R((x) & CRIS_LED_RED); \
|
2005-07-27 12:44:44 -06:00
|
|
|
} while (0)
|
|
|
|
|
2008-01-28 08:49:39 -07:00
|
|
|
#define CRIS_LED_ACTIVE_SET_G(x) \
|
2005-07-27 12:44:44 -06:00
|
|
|
crisv32_io_set(&crisv32_led2_green, !(x));
|
2008-01-28 08:49:39 -07:00
|
|
|
#define CRIS_LED_ACTIVE_SET_R(x) \
|
2005-07-27 12:44:44 -06:00
|
|
|
crisv32_io_set(&crisv32_led2_red, !(x));
|
2008-01-28 08:49:39 -07:00
|
|
|
#define CRIS_LED_DISK_WRITE(x) \
|
2005-07-27 12:44:44 -06:00
|
|
|
do{\
|
|
|
|
crisv32_io_set(&crisv32_led3_green, !(x)); \
|
|
|
|
crisv32_io_set(&crisv32_led3_red, !(x)); \
|
|
|
|
}while(0)
|
2008-01-28 08:49:39 -07:00
|
|
|
#define CRIS_LED_DISK_READ(x) \
|
2005-07-27 12:44:44 -06:00
|
|
|
crisv32_io_set(&crisv32_led3_green, !(x));
|
|
|
|
|
|
|
|
#endif
|