Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 84949
b: refs/heads/master
c: d8ca6b1
h: refs/heads/master
i:
  84947: c63205f
v: v3
  • Loading branch information
Jesper Nilsson committed Feb 8, 2008
1 parent 1cbbba1 commit 20bc2fd
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9ce1ea751f7256b2248321c2427612a295f15137
refs/heads/master: d8ca6b1593382e51f4c245de9040c795be3a0281
70 changes: 55 additions & 15 deletions trunk/include/asm-cris/arch-v32/io.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#ifndef _ASM_ARCH_CRIS_IO_H
#define _ASM_ARCH_CRIS_IO_H

#include <asm/arch/hwregs/reg_map.h>
#include <asm/arch/hwregs/reg_rdwr.h>
#include <asm/arch/hwregs/gio_defs.h>
#include <linux/spinlock.h>
#include <hwregs/reg_map.h>
#include <hwregs/reg_rdwr.h>
#include <hwregs/gio_defs.h>

enum crisv32_io_dir
{
Expand All @@ -13,10 +14,11 @@ enum crisv32_io_dir

struct crisv32_ioport
{
unsigned long* oe;
unsigned long* data;
unsigned long* data_in;
volatile unsigned long *oe;
volatile unsigned long *data;
volatile unsigned long *data_in;
unsigned int pin_count;
spinlock_t lock;
};

struct crisv32_iopin
Expand All @@ -34,22 +36,37 @@ extern struct crisv32_iopin crisv32_led2_red;
extern struct crisv32_iopin crisv32_led3_green;
extern struct crisv32_iopin crisv32_led3_red;

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;

static inline void crisv32_io_set(struct crisv32_iopin* iopin,
int val)
{
long flags;
spin_lock_irqsave(&iopin->port->lock, flags);

if (val)
*iopin->port->data |= iopin->bit;
else
*iopin->port->data &= ~iopin->bit;

spin_unlock_irqrestore(&iopin->port->lock, flags);
}

static inline void crisv32_io_set_dir(struct crisv32_iopin* iopin,
enum crisv32_io_dir dir)
{
long flags;
spin_lock_irqsave(&iopin->port->lock, flags);

if (dir == crisv32_io_dir_in)
*iopin->port->oe &= ~iopin->bit;
else
*iopin->port->oe |= iopin->bit;

spin_unlock_irqrestore(&iopin->port->lock, flags);
}

static inline int crisv32_io_rd(struct crisv32_iopin* iopin)
Expand All @@ -60,28 +77,51 @@ static inline int crisv32_io_rd(struct crisv32_iopin* iopin)
int crisv32_io_get(struct crisv32_iopin* iopin,
unsigned int port, unsigned int pin);
int crisv32_io_get_name(struct crisv32_iopin* iopin,
char* name);
const char *name);

#define LED_OFF 0x00
#define LED_GREEN 0x01
#define LED_RED 0x02
#define LED_ORANGE (LED_GREEN | LED_RED)

#define LED_NETWORK_SET(x) \
do { \
LED_NETWORK_SET_G((x) & LED_GREEN); \
LED_NETWORK_SET_R((x) & LED_RED); \
#if (defined(CONFIG_ETRAX_NBR_LED_GRP_ONE) || defined(CONFIG_ETRAX_NBR_LED_GRP_TWO))
#define LED_NETWORK_GRP0_SET(x) \
do { \
LED_NETWORK_GRP0_SET_G((x) & LED_GREEN); \
LED_NETWORK_GRP0_SET_R((x) & LED_RED); \
} while (0)
#else
#define LED_NETWORK_GRP0_SET(x) while (0) {}
#endif

#define LED_NETWORK_GRP0_SET_G(x) \
crisv32_io_set(&crisv32_led_net0_green, !(x));

#define LED_NETWORK_GRP0_SET_R(x) \
crisv32_io_set(&crisv32_led_net0_red, !(x));

#if defined(CONFIG_ETRAX_NBR_LED_GRP_TWO)
#define LED_NETWORK_GRP1_SET(x) \
do { \
LED_NETWORK_GRP1_SET_G((x) & LED_GREEN); \
LED_NETWORK_GRP1_SET_R((x) & LED_RED); \
} while (0)
#else
#define LED_NETWORK_GRP1_SET(x) while (0) {}
#endif

#define LED_NETWORK_GRP1_SET_G(x) \
crisv32_io_set(&crisv32_led_net1_green, !(x));

#define LED_NETWORK_GRP1_SET_R(x) \
crisv32_io_set(&crisv32_led_net1_red, !(x));

#define LED_ACTIVE_SET(x) \
do { \
LED_ACTIVE_SET_G((x) & LED_GREEN); \
LED_ACTIVE_SET_R((x) & LED_RED); \
} while (0)

#define LED_NETWORK_SET_G(x) \
crisv32_io_set(&crisv32_led1_green, !(x));
#define LED_NETWORK_SET_R(x) \
crisv32_io_set(&crisv32_led1_red, !(x));
#define LED_ACTIVE_SET_G(x) \
crisv32_io_set(&crisv32_led2_green, !(x));
#define LED_ACTIVE_SET_R(x) \
Expand Down

0 comments on commit 20bc2fd

Please sign in to comment.