|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) q& s6 O" ]+ W3 f( R#include <linux/init.h>
* {9 r" l1 }8 e H6 h#include <linux/module.h>
) `, K7 c: }3 ]4 I3 M! k# `#include <linux/kernel.h>
, R$ f0 R$ Q. ?1 L) R#include <linux/types.h>3 D$ ~; b) U$ L7 L- `
#include <linux/gpio.h>
, E4 C3 @) ]3 W2 Y' {) B#include <linux/leds.h>7 J+ \ }$ U/ A
#include <linux/platform_device.h>
3 V- e. x* M% \
/ O" x! U* ?# ?" K* k( a#include <asm/mach-types.h>; c& Z( ]1 K) L" p- x2 V
#include <asm/mach/arch.h>
. L E e3 P7 f+ p! P* ^* G#include <mach/da8xx.h>
N# L7 z! b5 k1 @- }( K1 y2 \2 M#include <mach/mux.h>8 O+ k. B j" F+ ^$ k
7 k8 o3 o5 ~3 `, b3 K
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# p: h2 b% X4 A# K) `& Q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# B" C" x u# m" \. h: t#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). C: b+ l& H, r/ q! m- a& o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 y% j# m V, l4 g$ c, H8 K/ H
! p2 r0 L0 g2 E1 ~0 i
/* assign the tl som board LED-GPIOs*/
g% o6 t# m* {2 l( u2 rstatic const short da850_evm_tl_user_led_pins[] = { Y- f5 e9 Y: n* R2 B* ]
/* These pins are definition at <mach/mux.h> file */+ q* G) ]5 B& a$ _
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- {% s T% B5 B/ L. a
-1( H% L2 a3 z/ r
};+ f4 r% w3 e6 P7 |: M& u# J
! \& B6 s8 ^! l
static struct gpio_led da850_evm_tl_leds[] = {
7 w+ p, M: G0 e: _ H1 k {' l9 R P) k2 S: }6 F; b ?
.active_low = 0,
) |0 k% k$ p, i .gpio = DA850_USER_LED0,# C. @- |+ c9 F8 {2 r" G
.name = "user_led0",( m2 G* R( @) f
.default_trigger = "default-on",' e% v# Z, S5 @1 Z0 h" w& y
},' M1 ?: J9 J c3 J& c
{
% C U. q+ u9 b6 t- |0 |, T5 | .active_low = 0,
" j$ W0 h% r9 j* [ .gpio = DA850_USER_LED1,* V- n! j5 J6 E
.name = "user_led1",
4 G0 d- D- A0 } .default_trigger = "default-on",
$ y' D; d/ p; g: ~3 @; \# V- ` },
" | {! U1 }; T { [8 W2 ]% g V
.active_low = 0,
0 }& f0 s4 y$ e& `. D .gpio = DA850_USER_LED2,4 f& k# e! ]% z) _9 i
.name = "user_led2",- q9 ?+ C* {6 ], B5 y$ w$ c3 B
.default_trigger = "default-on",
g2 w4 d- G+ x8 f },
0 J. X" U% B w {
1 C1 {! X- L4 P' t( J4 V .active_low = 0,4 S O2 Q# `6 Y {
.gpio = DA850_USER_LED3,2 V ^2 A) i& y- ] A2 Z V
.name = "user_led3",
& R" s, G& Y* ~ .default_trigger = "default-on",) F$ f; T- I! h2 `% w) V( E
},
* T8 i9 v" j+ o9 ^};
3 B* r1 G1 M1 L( A1 }" L4 B- @9 K
# h0 d1 k; M! _static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, t3 i1 M4 i3 v2 q! l .leds = da850_evm_tl_leds,: w; v5 P( B' B" b
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),! I7 V) m) g4 n0 S. q6 X
};: z/ ?: T B3 h$ o1 w0 f2 w( \
( b: K1 W( t; W6 T. Z
static void led_dev_release(struct device *dev)
, g! d g, W. Z/ d" G! C$ ^{
# G2 n* {" M4 B7 j7 N};. {# o/ M; \! z7 h
" P% z5 U& F5 N7 G3 |static struct platform_device da850_evm_tl_leds_device = {: R6 O; X: p% ~/ L2 O0 |2 X; ~* S
.name = "leds-gpio",: j# l O% l# Q6 d- ?/ G
.id = 1,
: L, B& c" [8 n- _1 m9 G% w5 I8 ~ .dev = {$ C# b9 s: i# x
.platform_data = &da850_evm_tl_leds_pdata,2 B; s' N6 W2 w3 e
.release = led_dev_release,
! w) X) I) v# q; s% U0 S }
. H: V0 M0 ~* o# g$ \: }};* V+ E) F" E0 m q+ `- |6 V# N; o
& r: ^8 M* Y8 ?; C: f, B+ d! N
static int __init led_platform_init(void)4 R1 r1 Q" t0 {* y$ Y; a$ J5 m
{# x2 _4 W- e; i5 {( f0 Q* X- K
int ret;
/ `, F. Q% [) ^6 n. e5 d4 i#if 0
' ^8 C; H) P$ u2 g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ @! l- |7 B7 ?9 x
if (ret): r4 C: m1 }- h0 \7 J, J' w
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 M- r" z+ b2 e
"%d\n", ret);
0 B! h# ~! q' X8 t) }2 i S8 g#endif. m0 g2 Z: E" I( T
ret = platform_device_register(&da850_evm_tl_leds_device);" C& z* \0 S, D' l$ Z4 i1 s
if (ret)
2 \; r$ u$ m) N6 d, E( I3 T pr_warning("Could not register som GPIO expander LEDS");
; @0 i- d0 q( ^/ a4 N/ G% F else1 `/ K q9 u% b4 t) @+ b" A1 e
printk(KERN_INFO "LED register sucessful!\n");
: d# k9 i9 e6 D5 K' a' s) L
# U6 n6 K. B& Z( Q5 E1 _* H return ret;
0 C- B: S( R% i}3 M, L7 T3 Y& F* X m0 c E7 z2 m- q
- j' {& F, v' ^# [5 B
static void __exit led_platform_exit(void)0 T4 _+ B/ {3 a1 i# J8 l2 X
{+ ~0 l% E& d. C+ D
platform_device_unregister(&da850_evm_tl_leds_device);5 P, ~! ~3 R+ G" U
. i6 S5 r+ N. R
printk(KERN_INFO "LED unregister!\n");# W R# x7 B4 t2 W
} R3 S3 [3 s$ c% o1 R' k. i1 X& q! f6 s
' u* y- Y- K% v$ ~1 T# p
module_init(led_platform_init);4 |2 v" G( J- l! Q ?- W
module_exit(led_platform_exit);
; B% d, F w* ~2 o! n! j, d( U5 B/ Y" G# x& X2 H! i" m
MODULE_DESCRIPTION("Led platform driver");
6 m& v0 F& F5 e2 b6 kMODULE_AUTHOR("Tronlong");4 e9 N( @: f5 c D1 n, C
MODULE_LICENSE("GPL");. w% _& ^7 z# e2 B, M: Y/ ?9 y
0 Z0 L* U9 @( J/ P |
|