aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/brcm47xx-2.6/files/include/asm-mips/mach-bcm947xx/gpio.h
blob: 2999a255f01a50cb2c94b51a68e00d9391caf9ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef __BCM947XX_GPIO_H
#define __BCM947XX_GPIO_H

#include <linux/ssb/ssb.h>
#include <linux/ssb/ssb_driver_chipcommon.h>
#include <linux/ssb/ssb_driver_extif.h>

extern struct ssb_bus ssb;

static inline int gpio_request(unsigned gpio, const char *label)
{
	return 0;
}

static inline void gpio_free(unsigned gpio)
{
}

static inline int gpio_direction_input(unsigned gpio)
{
	if (ssb.chipco->dev)
		ssb_chipco_gpioouten(&ssb.chipco, 1 << gpio, 0);
	else if (ssb.extif->dev)
		ssb_extif_gpioouten(&ssb.extif, 1 << gpio, 0);
	else
		return -EINVAL;
	return 0;
}

static inline int gpio_direction_output(unsigned gpio)
{
	if (ssb.chipco->dev)
		ssb_chipco_gpioouten(&ssb.chipco, 1 << gpio, 1 << gpio);
	else if (ssb.extif->dev)
		ssb_extif_gpioouten(&ssb.extif, 1 << gpio, 1 << gpio);
	else
		return -EINVAL;

	return 0;
}


static inline int gpio_to_irq(unsigned gpio)
{
	struct ssb_device *dev;
	
	dev = ssb.chipco->dev;
	if (!dev)
		dev = ssb.extif->dev;
	if (!dev)
		return -EINVAL;

	return ssb_mips_irq(dev) + 2;
}

static inline int irq_to_gpio(unsigned gpio)
{
	return -EINVAL;
}


static inline int gpio_get_value(unsigned gpio)
{
	if (ssb.chipco->dev)
		return ssb_chipco_gpioin(&ssb.chipco, 1 << gpio) ? 1 : 0;
	else if (ssb.extif->dev)
		return ssb_extif_gpioin(&ssb.extif, 1 << gpio) ? 1 : 0;
	else
		return 0;
}

static inline int gpio_set_value(unsigned gpio, int value)
{
	if (ssb.chipco->dev)
		ssb_chipco_gpioout(&ssb.chipco, 1 << gpio, (value ? 1 << gpio : 0));
	else if (ssb.extif->dev)
		ssb_extif_gpioout(&ssb.extif, 1 << gpio, (value ? 1 << gpio : 0));
	
	return 0;
}


/* cansleep wrappers */
#include <asm-generic/gpio.h>


#endif /* __BCM947XX_GPIO_H */