|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ R& K; q/ f, B/ C; \' n. i9 }
#include <linux/init.h>
& H8 Q- K2 R1 ^" U#include <linux/module.h>
- ]3 Z! z \6 y" r( \( R% w#include <linux/kernel.h>5 r/ ~* C0 I! p, J+ M
#include <linux/types.h>
4 Z1 R' R/ s& q; q. V9 n#include <linux/gpio.h>7 A `1 _3 r& _9 t- O5 r5 m! h
#include <linux/leds.h>7 E) ], a- p4 v( R
#include <linux/platform_device.h>
g% M1 f1 P7 T9 e$ P
7 h9 w+ T V& d- T#include <asm/mach-types.h>
: G+ ]- ?' o+ g [$ h- h#include <asm/mach/arch.h>
! L# h4 D5 Q2 |4 x @! ]#include <mach/da8xx.h>
3 f' s% i7 s6 x# s3 q#include <mach/mux.h>3 A: r6 {$ G5 d* M7 _9 r
, M+ S. I5 s6 y& E, [#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 ]4 P1 E Y+ ~ [& _#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
C5 _& e3 S2 G% K#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) k$ @* k: m. D3 |. @* {, A/ r
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 ~2 y; ?+ f8 P* B- X' q5 M
. V: P2 G7 T! n) _! { `6 S
/* assign the tl som board LED-GPIOs*/
1 i% o' P# }: astatic const short da850_evm_tl_user_led_pins[] = {
( F* j7 T6 z0 f* {, y /* These pins are definition at <mach/mux.h> file */0 i9 W f+ g0 O. }) f+ k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; n" x$ g/ ~& t( I. M" j1 x# g
-1% L7 k6 [( ^% b& X X' O7 e9 ^/ B
};
: d: p4 j' w1 a3 w1 j0 A! z% @3 _, _
2 i( N3 @* A2 I2 `; Astatic struct gpio_led da850_evm_tl_leds[] = {
2 v: `* y; B$ j) U' d& r8 ^ {
/ ] B9 g D { .active_low = 0,
$ T& L5 g5 _# H. @0 r .gpio = DA850_USER_LED0,& s" G1 M2 Z3 [4 q7 v/ G
.name = "user_led0",. i6 W! Z( P3 l7 }2 J% S- U; M. N9 k
.default_trigger = "default-on",
0 ~5 ?1 P% r% |4 @3 ~1 s8 T },8 U `2 c9 `4 S0 M ]$ ]
{2 g* i8 z) v8 A& A
.active_low = 0,
: E5 ^7 q) c8 ~0 `; G .gpio = DA850_USER_LED1,; N* i- h h; U9 l
.name = "user_led1",* n: S; K/ Q T4 a
.default_trigger = "default-on",! H3 {9 K U/ i/ a% T7 z' V5 L
},
2 l B9 ?/ ?- L6 k {+ P- L3 o5 h* n
.active_low = 0,
2 [7 q9 F+ I: d4 I, K' R& k .gpio = DA850_USER_LED2,
- i' f- T0 y) S* e- K .name = "user_led2",* ^0 b1 m! Y. v) e9 H$ q
.default_trigger = "default-on",
/ m! L7 ]* C6 D7 \0 J. \4 l },
" p. s& \3 A' G; R4 u6 q Z {
* p' P9 p2 Z* \1 s: O% Q9 k .active_low = 0,8 R3 g# X" |1 \! q( _* h
.gpio = DA850_USER_LED3,2 c3 F1 c% ?) ^9 F. k# Y
.name = "user_led3",3 E; J- ^- I3 _3 p
.default_trigger = "default-on",
b" C0 W ~2 h% C' y }," V! c$ E$ W9 B% T% ]4 L2 ]
};- R. ]9 h/ O4 D) S5 F$ z% Z
$ X/ [& L y- s1 t( i* C3 ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" l" v* ]6 E% J
.leds = da850_evm_tl_leds,
' ?& T, I" h( `0 Z- { .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 u( Z7 r* ~: j
};/ O0 G$ r3 k3 B, c; Y
4 v( B6 g1 G* i, T: B% A
static void led_dev_release(struct device *dev)% N( A4 i0 e9 w U' B
{
& b" L8 l1 x. c* i, j};8 ?9 ^- B* J$ b: E* ?7 P
5 A* Z' H7 p% istatic struct platform_device da850_evm_tl_leds_device = {6 P! W% d# ~6 A% G
.name = "leds-gpio",
& l1 B( b C2 v2 B3 G/ | .id = 1," _: z; l* n- }* s* ]
.dev = {
4 h/ C! H, V8 X- @6 a .platform_data = &da850_evm_tl_leds_pdata,
# w% E6 W/ ~/ \2 F9 G# J .release = led_dev_release,
" k" x* `! w* j/ m7 Q" Q) { }- T z* `, Z2 k# ?% S
};6 J" Z/ f" E5 W R( S" q8 j) b
' ~! j" c/ z- O
static int __init led_platform_init(void)0 v2 \. u6 T0 F7 Z' i9 e2 |/ j
{
- j2 g* |) T! T9 P; ~9 Z+ R int ret;
3 |5 l7 u+ C8 W#if 0
( k) d, i ?+ x3 F E ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
f- n& W: L! e/ E) ]. J if (ret)
M9 ~% q0 M- ]8 X" B* ^6 r; R pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 T1 e, ?" V5 ?) T! [ "%d\n", ret);
9 N6 ?3 H) ^% `. [8 ?#endif4 H3 ?2 X' o4 Y
ret = platform_device_register(&da850_evm_tl_leds_device);
- k0 o$ A( n- r1 \) G' r9 ^ if (ret)8 \2 h, N9 \( I" E4 h4 K$ b$ i
pr_warning("Could not register som GPIO expander LEDS");
% a1 C" Y2 B" O+ F! Y else
7 Y7 `) i. d9 F printk(KERN_INFO "LED register sucessful!\n");% U0 L) p& x6 k6 W9 N6 w: D
* r( F* j. H2 s" S return ret;( t% }) }# J0 j8 d3 R9 W
}( m; s5 c* a) }8 g8 p; F
+ R! B- o8 d- v; R8 q4 O3 M' S, u
static void __exit led_platform_exit(void)
$ }1 V. I0 a/ {; Z7 V/ B{
; s( t( B3 ~# n' q4 ]* c: k. y" T platform_device_unregister(&da850_evm_tl_leds_device);
/ z7 E+ H% |$ T W
" V3 N* h+ D( v printk(KERN_INFO "LED unregister!\n");' U/ p+ e c4 c
}9 C6 {1 j2 M& L& H! C# D
! o- R% `6 l5 s. x. J3 s( i3 a& W+ m
module_init(led_platform_init);- T5 ~3 ]: W) P3 @
module_exit(led_platform_exit);2 ^1 Z* w, G- v5 U. \
( L4 [7 l8 v1 k$ W0 w# hMODULE_DESCRIPTION("Led platform driver");7 N+ z) {# b. h. U
MODULE_AUTHOR("Tronlong");
5 x0 i+ o! Q* q( H! v1 b7 y3 ]/ NMODULE_LICENSE("GPL");1 [" n2 w5 {# x# G1 [
. P. ]% T6 _6 O. E/ h% L; N# x. u |
|