1 #include <linux/module.h>
2 #include <linux/kernel.h> /* printk() */
3 #include <linux/types.h> /* size_t */
5 #include <linux/spinlock.h>
6 #include <asm/rc32434/rb.h>
8 #define GPIO_BADDR 0xb8050000
11 static volatile unsigned char *devCtl3Base
= 0;
12 static unsigned char latchU5State
= 0;
13 static spinlock_t clu5Lock
= SPIN_LOCK_UNLOCKED
;
15 void set434Reg(unsigned regOffs
, unsigned bit
, unsigned len
, unsigned val
) {
18 spin_lock_irqsave(&clu5Lock
, flags
);
19 data
= *(volatile unsigned *) (IDT434_REG_BASE
+ regOffs
);
20 for (i
= 0; i
!= len
; ++i
) {
21 if (val
& (1 << i
)) data
|= (1 << (i
+ bit
));
22 else data
&= ~(1 << (i
+ bit
));
24 *(volatile unsigned *) (IDT434_REG_BASE
+ regOffs
) = data
;
25 spin_unlock_irqrestore(&clu5Lock
, flags
);
28 void changeLatchU5(unsigned char orMask
, unsigned char nandMask
) {
30 spin_lock_irqsave(&clu5Lock
, flags
);
31 latchU5State
= (latchU5State
| orMask
) & ~nandMask
;
32 if( !devCtl3Base
) devCtl3Base
= (volatile unsigned char *)
33 KSEG1ADDR(*(volatile unsigned *) KSEG1ADDR(0x18010030));
34 *devCtl3Base
= latchU5State
;
35 spin_unlock_irqrestore(&clu5Lock
, flags
);
38 u32
gpio_get(gpio_func func
)
40 return readl((void *) GPIO_BADDR
+ func
);
43 void gpio_set(gpio_func func
, u32 mask
, u32 value
)
45 u32 val
= readl((void *) GPIO_BADDR
+ func
);
50 writel(val
, (void *) GPIO_BADDR
+ func
);
53 EXPORT_SYMBOL(gpio_set
);
54 EXPORT_SYMBOL(gpio_get
);
55 EXPORT_SYMBOL(set434Reg
);
56 EXPORT_SYMBOL(changeLatchU5
);
This page took 0.063689 seconds and 5 git commands to generate.