|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 d$ u. u2 b h, d% d#include <linux/init.h>2 q4 n1 ^% U! u
#include <linux/module.h>
' R: C" C3 S+ l. K/ H#include <linux/kernel.h>
! `, g$ S9 s" J" y; f#include <linux/types.h>) m. `8 a8 B9 C! H, Z" h
#include <linux/gpio.h>
7 j- h4 @2 i; I#include <linux/leds.h>) P* v* _$ \( B% [6 E- F0 y2 ~
#include <linux/platform_device.h>: l# C. g3 a. x0 ~8 L' _/ x- e
# \. g' `. T$ P1 b: c#include <asm/mach-types.h>
9 s$ r6 T' L2 m#include <asm/mach/arch.h>" D$ J( F. `" y" P9 v; f
#include <mach/da8xx.h>8 f% N, C+ O* b$ L c8 e8 |
#include <mach/mux.h>. J2 q. j+ r; n5 K# W
) d: u/ f7 D* x w, Z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 [6 ]. q8 l z8 f# O#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 [5 t* D |3 U0 C7 K3 h+ S& v#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): y, `" `( w; K7 B6 [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. n U1 v# u% o, n n( ^! p) i ?
" }$ X: r6 G- _3 }1 ^# l, H2 G/* assign the tl som board LED-GPIOs*/
, g' s, H" o! |static const short da850_evm_tl_user_led_pins[] = {
6 m/ H$ N: X6 } /* These pins are definition at <mach/mux.h> file */
5 u, V9 o) u: l& F% k, W" T DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, X% a& T# M. J0 d2 A5 b
-1$ k* k3 t7 \' j, _
};7 U6 W) A+ e& N' r
" N; y) n7 ` C3 r; K* ?
static struct gpio_led da850_evm_tl_leds[] = {
) w+ j- }# @/ O& X/ j- T {
{9 J! B* [0 e .active_low = 0,
- c2 d. ?# W F( j$ O .gpio = DA850_USER_LED0,! N- B" |1 b8 G
.name = "user_led0"," `- r U C9 T
.default_trigger = "default-on",6 o% h! q* G8 V9 G0 I* d+ L
},. P) p2 Q* X, ]: T$ z' t
{' f6 o+ h+ o0 c- P
.active_low = 0,- V4 Z' r3 @ n' G. n
.gpio = DA850_USER_LED1,
, y, P5 z; V1 l* w4 m .name = "user_led1",
x) }# \ H8 z& } .default_trigger = "default-on",
3 y9 U$ o8 Y$ Y% s" a( q& G },; p3 A8 P9 z2 Z! t$ Z. u2 y
{: G" P/ K( C5 V
.active_low = 0,' U& c3 `" f3 Q# G. S7 i+ A2 c2 z
.gpio = DA850_USER_LED2,, O' U: C' A- ]
.name = "user_led2",
+ `, t- P9 y- d8 z/ W .default_trigger = "default-on",/ I0 t# r; v) u0 P: G( G, b% }
},
9 u# v) \2 B5 v# G% | { G3 u; O8 X2 G; S- ?
.active_low = 0,
$ e% _! q% B5 r; J) a/ U, L' t .gpio = DA850_USER_LED3,& ^* W# {2 q$ m( X# h0 Y
.name = "user_led3",
) Y4 d: b4 I$ J: A: G9 ? .default_trigger = "default-on",
: M B$ M1 Z$ j9 {/ ]( r },2 y& Y5 | M5 Y
};
. B' F* k% o" w: H
, e1 @- U/ k- J. y% e# bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
{; s5 H2 y9 l- t .leds = da850_evm_tl_leds,* w8 a. K/ V7 k" U! m
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),, V; V$ T6 E) y8 @6 u( z; N/ c
};
2 G9 | [$ Y- s! ~6 c6 G( g
1 ?# M- I$ U: A$ z% Y' J5 @# Qstatic void led_dev_release(struct device *dev)
# t3 T/ q+ I- y4 h( j{5 A, x9 P5 h' b9 L
};, r# P- E- u, l, h7 k
8 N/ r1 Y) _! I/ t% f' R8 z
static struct platform_device da850_evm_tl_leds_device = {! }2 A2 J2 j0 D1 a: L! ^/ i
.name = "leds-gpio",
3 e2 }/ a! h9 c3 ] .id = 1,
, L: ~# Y* b8 R' P2 B4 c5 m0 c .dev = {- J6 {( }. G$ F3 b: s, R$ y- w
.platform_data = &da850_evm_tl_leds_pdata,
7 W7 d3 Q' m2 \3 o3 B .release = led_dev_release,
4 x& F" n" C7 H) T9 I }4 R0 h+ V6 k S5 T0 ]
};
) n; e) L9 m" T1 _* K9 B+ O, ^' ~; |6 I, r1 s) q1 s
static int __init led_platform_init(void)7 g2 h- [& u2 X# J" v3 A
{
( y5 V" N$ l9 x, c, [7 O, J int ret;- Z% m1 z5 M4 a7 b
#if 0; p/ e9 `+ {) g+ t8 V$ O( a3 V( [
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ F! a6 Z# S% k, ]' J
if (ret)$ v6 _- _7 z! S7 `2 t
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 w, p2 _- v! K, J! F "%d\n", ret);6 S3 S9 Q1 j+ a" b
#endif
& M; ?& |4 r' k& ~ ret = platform_device_register(&da850_evm_tl_leds_device);1 b& a- p! X) P
if (ret)4 ?3 k6 z8 I# i$ |0 C
pr_warning("Could not register som GPIO expander LEDS");7 L9 Q1 I# e- L8 W
else5 k9 I. H0 L6 \. s, t; K# V
printk(KERN_INFO "LED register sucessful!\n");+ [# A0 ?/ @: t0 a
" L. h& V$ P/ `3 g. H& H* F- j
return ret;: P, Z" S; L" H, [1 j) ^: N
}; a) V- L1 Z- ~6 {6 r* A& x
0 u8 r7 X5 l! R! Y6 Gstatic void __exit led_platform_exit(void)
: ]' Q+ O6 f* G( M1 b; i9 C# V% x{
3 D l, l) P; D8 t8 u platform_device_unregister(&da850_evm_tl_leds_device);
7 P2 {* V/ T& J7 @/ A3 y: R- u& d# c
printk(KERN_INFO "LED unregister!\n");. d) c0 E' q6 c" \) D. Q1 S8 m
}
( a# E% [0 \: K9 P+ L0 s# `) i1 b% ^: `9 J
module_init(led_platform_init);/ r- _6 a/ E% A% O8 `* ?" m! O1 U- ~
module_exit(led_platform_exit);: U9 y+ v+ J/ B8 T9 ~# j( v
6 h' O7 U. N7 W$ l. `3 Y
MODULE_DESCRIPTION("Led platform driver");2 [6 B- {* Q" D! }% k7 ?2 W
MODULE_AUTHOR("Tronlong");: F% r7 i9 @: j* w7 A1 B1 n* A1 Q- D
MODULE_LICENSE("GPL");
, q' s9 G2 ` H! t% K: d; Y* z8 c. n; E4 {- a& x
|
|