|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 J0 U+ H1 j3 Y# {4 l
#include <linux/init.h>8 `! m( X& w% m
#include <linux/module.h>/ w2 w% z6 o% z; }$ _$ U
#include <linux/kernel.h>3 F+ |$ b' ~% [- u
#include <linux/types.h>
! h. K- N8 _3 e% e3 C. B0 z#include <linux/gpio.h>
- k; B. ?2 D* F#include <linux/leds.h>" o9 m3 P' Y/ ], w C- y
#include <linux/platform_device.h>- u. Z. w4 Z' p; s1 ?8 |4 e
w; d1 [1 ^) Z
#include <asm/mach-types.h>6 X( k7 b' S# s! i' D' B8 M
#include <asm/mach/arch.h>
8 ^( k# g! U5 Q( J9 Y8 h. _#include <mach/da8xx.h>
" M* t/ B. J2 g1 o! n#include <mach/mux.h>, ?) v/ w; z# T- X; I
2 W5 z! E' O- `$ g
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 _' [/ r& A8 y# C) Z* e. R9 j$ Y1 o6 n, U
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), M6 F( x0 g0 w9 p& L2 {9 J
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): w$ V* O1 B! k5 _
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& w9 R; ~9 p, U/ O
; `# G1 P# h. F$ l# a
/* assign the tl som board LED-GPIOs*/
( ]0 E5 m+ C, K- fstatic const short da850_evm_tl_user_led_pins[] = {
) W3 \& A. f9 l+ @ ] /* These pins are definition at <mach/mux.h> file */6 {) e; K. n# s* S4 v
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ U6 b7 M% f' f" V -1
' B9 M2 `6 `8 H};
/ _! K0 m& Y0 S' K+ \" z# v: V! W! I B, [
static struct gpio_led da850_evm_tl_leds[] = {; a& d3 y# E. u" t
{, l2 _/ c9 O- y
.active_low = 0,! c9 T6 _( f( a1 f5 C: [
.gpio = DA850_USER_LED0,
/ w9 ~' a5 @& D4 k; x+ y .name = "user_led0",6 G( h% z2 k6 w' S
.default_trigger = "default-on", ?4 P; Y" F6 z! w5 E5 b7 j
},
8 \2 o1 }- v( S9 x8 l- E) w, u {+ S! y8 U# F/ |" r6 M
.active_low = 0,* I, d/ O, K7 I4 N/ B5 l
.gpio = DA850_USER_LED1, Q4 E5 N% V- r
.name = "user_led1",
/ H' _: ~2 \& O% G3 L/ y; k( A .default_trigger = "default-on",% t3 q( |( X1 J- b4 s" _* f" i% P
},
; R# y6 ?! l! d+ e {0 R0 ~/ v- e! e/ G' S. q( T4 Y. _
.active_low = 0,( [ y. ^/ B% y7 q3 N- M* y
.gpio = DA850_USER_LED2,! C% X: [2 @8 e+ r+ l+ ~ n/ |3 a
.name = "user_led2",
( j: D; H6 }' j2 {: X .default_trigger = "default-on",% b( {% ]4 B P7 y
},
1 {; `! D4 l3 D+ T9 v4 W9 u- z$ m* p {
, T" p6 J( U" E. m3 G# k3 _ .active_low = 0, s' s& ~( S( J6 L7 u( E
.gpio = DA850_USER_LED3,. i9 c: F6 s1 A5 W' y* b
.name = "user_led3",
r [4 H9 R4 A2 Z .default_trigger = "default-on",
4 T7 ~& A2 c Y; a- r6 ?4 v! _ },8 b# Q0 B( T. v/ V7 b
};1 K# S3 i& x8 H8 h
: S; _7 p0 P( o9 Q4 w; C- Z4 ^' a
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 u+ n; c# m' x* c, h) C .leds = da850_evm_tl_leds,/ f: ~; x( V. w5 G5 c+ {$ L) h7 }
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% T$ `, ?$ P3 B! K( O9 C};
0 H6 N1 U* J7 i( X7 W2 P* t8 Q! o8 D/ Q5 W% Y% l4 H9 E- ?
static void led_dev_release(struct device *dev)
$ ]% w2 ]$ d! q9 U; a8 v. N{
K- u5 u" x4 x" G: @8 v};4 j! a9 Y, D2 r$ V6 ]. L- L
, `5 U$ F( U+ N; H! t5 M/ _! ~7 _
static struct platform_device da850_evm_tl_leds_device = {/ H. B3 Z; f% t. [! ~: Z
.name = "leds-gpio",$ z* @1 F% C. I( s5 ^
.id = 1,
9 I L, s3 b( i .dev = {$ ]# u) }" m$ t4 g$ {4 W6 C3 h: W, [
.platform_data = &da850_evm_tl_leds_pdata,, e" a% }" O( u5 Y
.release = led_dev_release,4 o) Q( x6 d$ g! J5 Z0 B
}
: K: D% Z2 v: W4 K+ }( D( {: |};0 x7 G- @7 r: @1 |( A( y( P& _
& q6 J2 R# }4 u h7 W& ^1 |
static int __init led_platform_init(void)$ K& N0 N5 K, X8 j
{
# d& }8 V0 }' b k int ret;
6 m# D: ?' a! A4 J$ L#if 06 _" |, i: J3 K8 w8 Y/ r
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' t5 y" @6 f# G1 X
if (ret)
3 P3 m5 G# C' D pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" | B; {& x W8 v( N% Z- T) S "%d\n", ret);
. a8 l* c0 g* V3 j- K! n, V$ z#endif' q5 E& k: E9 L* q0 [- Q
ret = platform_device_register(&da850_evm_tl_leds_device);" |% K4 p" K9 h' d1 J" m' H3 j0 z! I
if (ret)% j3 D* m4 Q' F) r: @# A
pr_warning("Could not register som GPIO expander LEDS");
1 y5 V8 A$ V# g5 F6 O else
7 a. d$ {+ i2 ~5 a5 n0 p printk(KERN_INFO "LED register sucessful!\n");4 ]5 g. ]( W5 Y* H0 p& G0 i
6 b7 I1 b: M ?' U3 z3 F6 B2 |
return ret;
P. V) h! l% N4 W+ N}
( E, }% u: C! ?; W0 T7 w8 Q, J1 V) D& I
static void __exit led_platform_exit(void)
/ D2 |0 ^: t# ~ ]6 H @4 m{
7 g: S% F Z6 S/ S/ T& d platform_device_unregister(&da850_evm_tl_leds_device);; }, o4 P! N! C2 F8 F" J* u4 h
0 k s% n$ I/ I% p printk(KERN_INFO "LED unregister!\n");
% f T. z+ |: R}
8 |; Z/ N% P: W" Q
" }* ^$ P- f' d! k+ A3 ]module_init(led_platform_init);! ~; Q4 |- ~: y. V- s
module_exit(led_platform_exit);
0 U; Q) f! Y$ W2 h& G; x- T7 r( ?) B6 f* f2 \' P5 t
MODULE_DESCRIPTION("Led platform driver"); q/ a. C$ }8 b/ \3 z
MODULE_AUTHOR("Tronlong");
! a$ H3 s7 M, m2 j4 h3 iMODULE_LICENSE("GPL");
/ q. K; @" O1 H, ?; [4 e; d
: f2 q& _9 J, B' u |
|