|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. s: f5 I6 z! [8 c
#include <linux/init.h>. z$ K- x( g: H i5 Z7 V1 c. Q
#include <linux/module.h>
5 B- |1 m; h1 o' G; N#include <linux/kernel.h>8 B* [ S& N7 \/ m, ^; H' P* }
#include <linux/types.h>
! o0 v C _) r( W2 i6 D#include <linux/gpio.h>
* K9 z5 n3 n7 i6 K#include <linux/leds.h>
2 F- z% C- h7 i# \#include <linux/platform_device.h>" w v& D2 T8 ~
! z5 V0 |" n0 z
#include <asm/mach-types.h>
3 \% q* u, C- F2 h5 W#include <asm/mach/arch.h>
4 q5 {8 K, n' o/ Z" f/ a#include <mach/da8xx.h>
/ b7 r! {$ i7 C1 S" k& Q8 a#include <mach/mux.h>0 S. [; o7 {7 O0 y) x' s/ U) z0 y
% h8 r- Y5 K0 i9 J) ~; o* d* N
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 c5 u/ S% G6 w+ D. {! v" v7 X ~#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; ^7 i! B6 b* z( z( z" T7 [/ X#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 D$ h3 X! B- p7 x
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ a; D0 a# i( }/ P" i0 Q7 J ~8 v1 ]6 d6 I) ?3 C4 S) O
/* assign the tl som board LED-GPIOs*/$ g3 p3 P: M2 W/ a; O
static const short da850_evm_tl_user_led_pins[] = {
4 }9 h/ x0 e2 E" h+ x7 Z /* These pins are definition at <mach/mux.h> file */5 i3 } }- y, V/ g' X2 B
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 v% K. n# R1 i& {0 {% b% |8 @# b
-1. L- L5 R2 E' m' k! u; t
};- D; x8 q8 Q9 |
4 v _! n. Z! H1 J4 N% v9 d+ M. W
static struct gpio_led da850_evm_tl_leds[] = {* z/ g4 t$ V O6 q; \9 m1 k# Q' q
{/ |( H1 v. f0 d7 `& V
.active_low = 0,* N6 F4 }2 p1 [7 q+ B
.gpio = DA850_USER_LED0,
- G* \% F5 |4 G; s- e( R$ z .name = "user_led0"," F/ V" o2 U3 G( p7 `8 L: z
.default_trigger = "default-on",
9 C, ?" L9 W8 k: l9 E6 e" s+ N },
: V4 ?. Q& R0 t4 E4 Q7 P8 t {, T# ~( J K& U7 [3 a4 Y, U" S& ^
.active_low = 0,
3 j: z! D. X+ K9 x .gpio = DA850_USER_LED1,
# Q9 t7 w" ?! u; n4 N; x4 I .name = "user_led1",
" M, y$ c& t @9 O/ p1 h .default_trigger = "default-on",7 ~( w% o: k6 y) s2 [+ m7 f
},+ c; B7 c2 d, T% b4 S* ]
{+ z% t7 {6 [4 R4 P( U/ X% l
.active_low = 0, D% i! s& C& U+ j M6 i
.gpio = DA850_USER_LED2,
$ c$ L- l# L1 O; p! E' D .name = "user_led2",
6 z" b0 F9 v/ O ~* C" ?5 z1 f .default_trigger = "default-on"," t1 {; g. s3 ^# E9 j2 K( L: B
},1 E! l% h" T% f1 k5 x: P- i$ Q( D
{0 l2 r" F/ L6 w* D4 a4 M& s1 k+ g* g
.active_low = 0,
: W0 ^1 ^& t, ]) e- y' r' x .gpio = DA850_USER_LED3,5 m) [8 |. J% N" V2 N& Z
.name = "user_led3",
8 B0 j2 A, N/ G* h9 W! e .default_trigger = "default-on",- }4 R& Z& {2 g I( t y0 K
},9 s$ d! E2 t9 i
};3 `8 O7 h& [1 K& \ f- y) ~1 r
+ a& n6 G# F" q0 h# n! G. b1 V: dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) K0 m5 I& M* L7 O" Z/ {, T2 ]; q4 v. k .leds = da850_evm_tl_leds,; t0 n v4 h/ x1 z! f3 J( q, q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 [ z2 j7 ^+ S* T/ M3 T" a7 b7 [};
1 a% i, W1 i) @4 z5 b; e/ j2 Y" r Y" K
static void led_dev_release(struct device *dev)
$ r6 t. I! ~' X6 K3 B{
# l: ~* L/ ?$ a};3 ^* `/ l# P6 d' U
7 |$ v1 ], h. I* e1 Ustatic struct platform_device da850_evm_tl_leds_device = {7 h r& r4 p) ? d5 g$ H
.name = "leds-gpio",6 |4 s; a$ b9 h. k. M& p
.id = 1,
7 E7 I1 v( r1 e .dev = {' ]' `& {8 S- _6 T
.platform_data = &da850_evm_tl_leds_pdata,- U5 l0 R5 ]2 p$ t
.release = led_dev_release,
0 ?* O: W/ i6 `9 B }
( S `* l$ ]- S# s* x K0 l0 ]- U};
$ p; x `, L3 s4 _0 p' ?
4 r* q( @# c" q* K: X$ e. Hstatic int __init led_platform_init(void)
+ W: I* r; u4 Y3 X" u- U{* C& |6 J4 V3 ~: K- Y% P8 g
int ret;
' W0 k! g: Y7 x5 _" M1 |- ^#if 06 |3 t% i5 v* F$ x! ^' ? b
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, x% A! x+ a# j. {/ t: l8 C7 E$ K+ H
if (ret), ?% {4 p0 K3 `8 Q! ~& M# p
pr_warning("da850_evm_tl_leds_init : User LED mux failed :" {( q: e4 T" \/ u3 O2 F+ Y
"%d\n", ret);
5 H3 u) A9 g) m! t6 P3 b#endif- q9 j5 n j+ k6 V% S
ret = platform_device_register(&da850_evm_tl_leds_device);
5 |- h5 f2 s0 \. ]+ q. m if (ret)
0 R S' u5 F3 S$ a3 H pr_warning("Could not register som GPIO expander LEDS");
, B* J8 [8 e5 Y else: w W& e9 x1 B
printk(KERN_INFO "LED register sucessful!\n");+ }5 l1 g# A! F+ d3 N8 y/ }' r
+ F& M! o: Q: k, n2 P/ m return ret;
2 o6 s/ _8 E5 C}3 r, f! q0 L/ E9 ^# D# ~5 ]6 ~! v
K# B+ f! w2 T6 K$ T3 g- Fstatic void __exit led_platform_exit(void)
: H' H3 m# y( s% q: h( P+ w{
/ t/ K' N4 a/ C% T8 x# s platform_device_unregister(&da850_evm_tl_leds_device);
" R E2 G9 H8 _* {, A T; x$ Q% v8 O( Z' i- {
printk(KERN_INFO "LED unregister!\n");4 M9 ~9 f, a# K5 G0 A* b7 `
}
! Q6 E6 @) y' B9 p0 L8 g9 n- L
! Y# o/ Q4 `& Y5 Wmodule_init(led_platform_init);
$ H; E2 E7 ~5 H1 C) j6 O( E. P" A9 Lmodule_exit(led_platform_exit);/ |1 B5 h& P$ X b4 c& D! i
) U; P) Z7 q! D9 k6 h7 A4 RMODULE_DESCRIPTION("Led platform driver");1 Z& u/ {; a; \+ d! B1 j1 T/ K5 M
MODULE_AUTHOR("Tronlong");4 i7 U! S7 Z/ [4 {; ^) t/ p7 c
MODULE_LICENSE("GPL");( `9 b% Q" p2 O3 M" Q
- H6 R7 G% B4 l |
|