diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2008-05-21 08:42:11 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2008-05-21 08:42:11 +0000 |
commit | a9c20f5789c13b486d217024a020f9d6163e2d51 (patch) | |
tree | 5da52ca9cc7a28ba21ced042cb739e6160d5f87b /firmware/target/arm/imx31/gigabeat-s/gpio-imx31.h | |
parent | 5f796087b009fee1ae60904b0355cc7febe3330f (diff) | |
download | rockbox-a9c20f5789c13b486d217024a020f9d6163e2d51.tar.gz rockbox-a9c20f5789c13b486d217024a020f9d6163e2d51.zip |
Gigabeat S:
1) Rework event handling and static registration mechanism. No target-
specific code in mc13783 driver. GPIO event driver interfaces more
cleanly.
2) Somewhat related - enable thread priority for bootloader which is
desireable here (ffs is used for GPIO event enabling anyway and that
goes along with priority).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17593 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/imx31/gigabeat-s/gpio-imx31.h')
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/gpio-imx31.h | 56 |
1 files changed, 40 insertions, 16 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/gpio-imx31.h b/firmware/target/arm/imx31/gigabeat-s/gpio-imx31.h index 34d3e72f8e..c3c3e1f63b 100644 --- a/firmware/target/arm/imx31/gigabeat-s/gpio-imx31.h +++ b/firmware/target/arm/imx31/gigabeat-s/gpio-imx31.h | |||
@@ -19,12 +19,12 @@ | |||
19 | #ifndef GPIO_IMX31_H | 19 | #ifndef GPIO_IMX31_H |
20 | #define GPIO_IMX31_H | 20 | #define GPIO_IMX31_H |
21 | 21 | ||
22 | #include "gpio-target.h" | 22 | /* Static registration mechanism for imx31 GPIO interrupts */ |
23 | |||
24 | #define USE_GPIO1_EVENTS (1 << 0) | 23 | #define USE_GPIO1_EVENTS (1 << 0) |
25 | #define USE_GPIO2_EVENTS (1 << 1) | 24 | #define USE_GPIO2_EVENTS (1 << 1) |
26 | #define USE_GPIO3_EVENTS (1 << 2) | 25 | #define USE_GPIO3_EVENTS (1 << 2) |
27 | 26 | ||
27 | /* Module indexes defined by which GPIO modules are used */ | ||
28 | enum gpio_module_number | 28 | enum gpio_module_number |
29 | { | 29 | { |
30 | __GPIO_NUM_START = -1, | 30 | __GPIO_NUM_START = -1, |
@@ -40,6 +40,22 @@ enum gpio_module_number | |||
40 | GPIO_NUM_GPIO, | 40 | GPIO_NUM_GPIO, |
41 | }; | 41 | }; |
42 | 42 | ||
43 | /* Module corresponding to the event ID is identified by range */ | ||
44 | enum gpio_event_bases | ||
45 | { | ||
46 | #if (GPIO_EVENT_MASK & USE_GPIO1_EVENTS) | ||
47 | GPIO1_EVENT_FIRST = 32*GPIO1_NUM, | ||
48 | #endif | ||
49 | #if (GPIO_EVENT_MASK & USE_GPIO2_EVENTS) | ||
50 | GPIO2_EVENT_FIRST = 32*GPIO2_NUM, | ||
51 | #endif | ||
52 | #if (GPIO_EVENT_MASK & USE_GPIO3_EVENTS) | ||
53 | GPIO3_EVENT_FIRST = 32*GPIO3_NUM, | ||
54 | #endif | ||
55 | }; | ||
56 | |||
57 | #include "gpio-target.h" | ||
58 | |||
43 | /* Possible values for gpio interrupt line config */ | 59 | /* Possible values for gpio interrupt line config */ |
44 | enum gpio_int_sense_enum | 60 | enum gpio_int_sense_enum |
45 | { | 61 | { |
@@ -54,35 +70,43 @@ enum gpio_int_sense_enum | |||
54 | /* Register map for each module */ | 70 | /* Register map for each module */ |
55 | struct gpio_map | 71 | struct gpio_map |
56 | { | 72 | { |
57 | volatile uint32_t dr; /* 00h */ | 73 | volatile uint32_t dr; /* 00h */ |
58 | volatile uint32_t gdir; /* 04h */ | 74 | volatile uint32_t gdir; /* 04h */ |
59 | volatile uint32_t psr; /* 08h */ | 75 | volatile uint32_t psr; /* 08h */ |
60 | volatile uint32_t icr[2]; /* 0Ch */ | 76 | union |
61 | volatile uint32_t imr; /* 14h */ | 77 | { |
62 | volatile uint32_t isr; /* 18h */ | 78 | struct |
79 | { | ||
80 | volatile uint32_t icr1; /* 0Ch */ | ||
81 | volatile uint32_t icr2; /* 10h */ | ||
82 | }; | ||
83 | volatile uint32_t icr[2]; /* 0Ch */ | ||
84 | }; | ||
85 | volatile uint32_t imr; /* 14h */ | ||
86 | volatile uint32_t isr; /* 18h */ | ||
63 | }; | 87 | }; |
64 | 88 | ||
65 | /* Pending events will be called in array order */ | 89 | /* Pending events will be called in array order which allows easy |
90 | * pioritization */ | ||
66 | 91 | ||
67 | /* Describes a single event for a pin */ | 92 | /* Describes a single event for a pin */ |
68 | struct gpio_event | 93 | struct gpio_event |
69 | { | 94 | { |
70 | int line; /* Line number (0-31) */ | 95 | uint32_t mask; /* mask: 1 << (0...31) */ |
71 | enum gpio_int_sense_enum sense; /* Type of sense */ | 96 | enum gpio_int_sense_enum sense; /* Type of sense */ |
72 | int (*callback)(void); /* Callback function (return nonzero | 97 | void (*callback)(void); /* Callback function */ |
73 | * to indicate this event was handled) */ | ||
74 | }; | 98 | }; |
75 | 99 | ||
76 | /* Describes the events attached to a port */ | 100 | /* Describes the events attached to a port */ |
77 | struct gpio_event_list | 101 | struct gpio_event_list |
78 | { | 102 | { |
79 | int priority; /* Interrupt priority for this GPIO */ | 103 | int ints_priority; /* Interrupt priority for this GPIO */ |
80 | unsigned count; /* Count of events */ | 104 | unsigned count; /* Count of events for the module */ |
81 | const struct gpio_event *events; /* List of events */ | 105 | const struct gpio_event *events; /* List of events */ |
82 | }; | 106 | }; |
83 | 107 | ||
84 | void gpio_init(void); | 108 | void gpio_init(void); |
85 | bool gpio_enable_event(enum gpio_module_number gpio, unsigned id); | 109 | bool gpio_enable_event(enum gpio_event_ids id); |
86 | void gpio_disable_event(enum gpio_module_number gpio, unsigned id); | 110 | void gpio_disable_event(enum gpio_event_ids id); |
87 | 111 | ||
88 | #endif /* GPIO_IMX31_H */ | 112 | #endif /* GPIO_IMX31_H */ |