|
求大神给下面的程序做注解,请稍详细些,谢谢。9 m- n/ |: C: s! ?. }% p( o6 ]
#include <linux/init.h># Q/ K3 y" w% J, D
#include <linux/module.h>3 ]' D2 X( A; S4 }4 ]+ t0 S- D
#include <linux/kernel.h>
% {0 F' R7 L9 I0 `7 ~' f/ u#include <linux/types.h>
] C* i: G( q: q7 I#include <linux/gpio.h>
! T4 M5 @! k+ ~2 v#include <linux/leds.h>
7 n. y2 J1 }$ h% q#include <linux/platform_device.h>+ c0 l8 }3 H3 g- s2 E
' f0 X: ]' S$ u4 k8 e/ L% f, C#include <asm/mach-types.h>. ~* _* K) A6 l
#include <asm/mach/arch.h>
4 T- Y+ ?+ f: C) i#include <mach/da8xx.h>% v* B2 `6 H3 @0 S
#include <mach/mux.h>, B% r8 e) n5 t# b; a) G+ D
& s. ? M0 r3 O. W! F+ q3 k5 r#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ D4 }' c6 h% e5 o. D* Y9 J#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 y! i3 G3 q* ?1 f% q' o#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# r" x8 y% j9 o4 L" w! u. w3 P, d
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% V0 Z6 Y' L$ W6 x9 P7 K9 _
8 o0 Q. `# X- Q5 I1 ^5 S7 w, R6 z3 v, M
/* assign the tl som board LED-GPIOs*/
- G+ R/ B2 z; z. z) k5 Xstatic const short da850_evm_tl_user_led_pins[] = {
' V# \4 m3 d' e! V: ?: S+ l /* These pins are definition at <mach/mux.h> file */4 y. n# {5 `4 w8 X9 _2 e
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ U& T5 e* w- g T
-1) g, P% l% M- \8 w! h3 J
};
2 y" H; A0 R1 K9 ?1 @, X
) E" \- c% m+ w+ s4 C9 U; Kstatic struct gpio_led da850_evm_tl_leds[] = {
4 a \* U3 Z/ @7 c0 l" A! E {
8 Q: S8 z8 q/ _) r7 i9 u .active_low = 0,4 f d5 \; p" @# p
.gpio = DA850_USER_LED0,/ o/ n6 l+ F2 A3 I1 O2 N& j
.name = "user_led0",
& \. O! k, i( s. m% \& N$ | .default_trigger = "default-on",6 A2 g, u, [# ^' o% X+ p
},. f' Z+ W" d2 r, ~) a
{- k1 X/ I+ l4 l' l( R' n! Z. C
.active_low = 0,
; [- i/ g: V. s2 L ^ .gpio = DA850_USER_LED1,
+ v; S9 x& j: f3 H/ q) Q7 l .name = "user_led1",
: m" F) j9 g; X+ ^+ \9 A% q .default_trigger = "default-on",
( v+ F z" P, \ },. Q8 C# o2 ?4 s2 }2 y
{
( w' I) q1 ]8 r% n .active_low = 0,- ~: G; @0 b& _9 q2 r+ o6 {
.gpio = DA850_USER_LED2,& |- @7 E' W8 M6 {3 s8 `
.name = "user_led2",0 M7 s. z4 l7 ?
.default_trigger = "default-on",
) x8 l2 Y' Z4 D },
' {. h F; [8 v7 D/ G0 ] {
1 h7 \' H' S' X" z, u% y' N1 ~ .active_low = 0,
$ ^, W4 g6 R! }! b( r- h9 ] .gpio = DA850_USER_LED3,+ @( r0 d' ?* l
.name = "user_led3",
2 }7 x- l$ k* B% G% |" _ .default_trigger = "default-on",
7 b n) I5 j3 G9 W/ `! C/ ~7 Z* w },
1 N4 p. k6 e- f0 n6 _) O# z5 V+ W};
7 F' P- h+ L) n4 k: y& Z4 z$ T: `3 _! \; ~# C) V7 z4 a
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" W" ?0 H% a$ z% K; u2 n .leds = da850_evm_tl_leds,0 B5 s8 u2 E: |4 b' R% Z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ A8 K; N1 }, z, ~% ]( N, e: ~};
( e& {2 p2 E( b9 Q& K1 H4 M' O. p( s" E7 V
static void led_dev_release(struct device *dev)
! z: ^* m/ u2 j f0 r! j{
/ ]$ o6 U! y2 }1 l5 s$ d$ O0 R};3 {6 c- @) R' z% ^2 }' w
' |( ?. }; M/ W
static struct platform_device da850_evm_tl_leds_device = {
. S+ y) M" o3 w, x5 |2 L* F) G e* c0 T( ` .name = "leds-gpio",
- d/ }( O+ M( J1 O8 z% l- W$ R .id = 1,) u% t! r# w4 k* Q$ u
.dev = {
/ [0 d0 F4 k4 L2 L; B! d .platform_data = &da850_evm_tl_leds_pdata,
, n) L8 j5 q# h- t* V# @7 |$ g .release = led_dev_release,
4 M+ y5 S, @4 B6 O9 V }2 J' I5 v7 f# d/ w1 H& Q7 F# v
};: X% \ f- f6 p" t) ]% n: k7 a
+ {# [" A- J% O5 u" {0 r) O
static int __init led_platform_init(void)* e# D" ]. D) i3 i$ P- K0 [
{
" _1 s0 n* ^7 a; G, X% X int ret;
: [8 ^! Y: Z* G( P#if 0
g1 ^( p$ h; C9 ?- I7 z, V6 P3 @2 \ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) P, J1 z: c" x0 y; b if (ret)
+ h3 g3 t; Y0 ~ k3 S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 x+ Z- P/ K4 O "%d\n", ret);1 w" _0 T9 I7 }! |( p
#endif. }9 |0 F+ ]" J* N5 t
ret = platform_device_register(&da850_evm_tl_leds_device);. q* O }$ P) Y! v$ D$ m
if (ret)
7 y+ M( c$ h# z6 [! w0 | pr_warning("Could not register som GPIO expander LEDS");5 G- s! A0 J w0 I9 a# ~
else
3 c( p' [! V4 P& m printk(KERN_INFO "LED register sucessful!\n");
' h. n& k' K2 k( O# ?% ~# ?4 Q4 @/ J- E0 D
return ret;+ H6 N! D* V& X6 y
}
& a& \3 F- N X7 c, y O/ Q% Y
+ T8 X& K# m9 z! f, e+ ystatic void __exit led_platform_exit(void). I4 F6 ^$ F+ K+ R# n; q4 P
{
& d: D2 i) G1 c: K2 ~* n& O. ` platform_device_unregister(&da850_evm_tl_leds_device);% [4 v1 f/ i' u0 B& Z
4 Q" q# `3 M" g; k) n
printk(KERN_INFO "LED unregister!\n");
- }# f" t1 X6 z0 s}' e3 ]5 T3 q( ]' N5 l( Y) P+ W
9 e1 d/ a) i; V; h
module_init(led_platform_init);( |; e6 p3 }& \ K0 G8 N; C
module_exit(led_platform_exit);
& |, f Q2 @+ n3 s8 c5 w7 n V) S4 |1 j' h9 T
MODULE_DESCRIPTION("Led platform driver");/ @& O) ` i+ i* [. s* ?0 l$ }
MODULE_AUTHOR("Tronlong");5 {5 O7 D: r# |' ` I
MODULE_LICENSE("GPL");* N% ?1 g, H) v
A0 U5 \8 ^1 W |
|