|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( b% w+ @' G Y" e' m( ]" s#include <linux/init.h>
+ E& m; v6 y V3 q0 A: p1 `#include <linux/module.h>: ]& e2 w8 T9 R
#include <linux/kernel.h>
3 s+ K5 w q- C0 h4 Z; V+ s' }#include <linux/types.h>! Z& r. [0 z# y+ d: V
#include <linux/gpio.h>
$ x* L u" D6 |9 i3 q4 Q#include <linux/leds.h>
0 j. m g( D% p#include <linux/platform_device.h>: J+ U. S* ^; w
: K! m6 b! u: T$ m
#include <asm/mach-types.h>
7 }! _4 G g7 K3 r1 H: `0 _#include <asm/mach/arch.h>
" M5 U% M" i2 F#include <mach/da8xx.h>, T6 v& | T: e4 f# l n7 S
#include <mach/mux.h>. D+ } K' L; ^* B! m/ W" D" ~
0 j9 y2 b' _' b4 b3 O# ~0 Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& u! [5 e7 i5 m! b6 l+ [2 Y" @#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. e5 r' Y6 @. I1 ]( |/ f; f0 i# i6 ]#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 k3 k( X6 o5 M" p! q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 v2 P% ~9 R# K% [5 N: j" m) b z7 Z! T1 P9 ]
/* assign the tl som board LED-GPIOs*/. u; G A7 x$ Z" t/ s
static const short da850_evm_tl_user_led_pins[] = {; w/ F7 I( @( D3 z% r! G: c' n
/* These pins are definition at <mach/mux.h> file */
$ K* q+ n# k' H7 f DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" y7 E' [9 \- [( q, }* s! S4 u2 s -1
7 U. @8 q. {1 O" J7 `" z8 u; H};
0 g s9 v2 H6 O6 [" |2 i& {' N2 b8 G+ @6 S- W7 @
static struct gpio_led da850_evm_tl_leds[] = {! n" i) w& s6 ?, p( N
{
* ?8 {6 i6 b# s2 Z+ b) S1 g( {5 g .active_low = 0,. ^' s; v4 s2 n; q9 f
.gpio = DA850_USER_LED0,5 ^( a/ L( R* S& T
.name = "user_led0",
q: a; s3 k; B0 ? b- M" R .default_trigger = "default-on",+ B z) y: Q3 p- d, X% @$ O6 s
},) K3 b r' V9 m- a' T7 R" T
{
7 q# ?0 | J) v$ L .active_low = 0,
" s: O. i" c; N \( T; { .gpio = DA850_USER_LED1,( Y0 g; k; n$ }( l& z9 H( F) x
.name = "user_led1",
% N2 d: b: [9 q) G7 O( B4 Z3 B .default_trigger = "default-on",8 Q. r) M4 ~, y5 n9 M
},
6 ~3 F. O1 O/ c/ |6 R {
) }( r/ A9 z ]9 n2 v3 S .active_low = 0,6 M5 T- @- @6 h) O2 Y
.gpio = DA850_USER_LED2,' p3 t# t$ _9 X, o
.name = "user_led2",$ I2 Z4 |1 i5 u7 Z% ~( L
.default_trigger = "default-on",
; m2 M" v: o: y8 s },) _8 p6 g' _ [3 M$ A$ a6 D
{( v* I1 ]: R0 {! v- r) s* _$ Y
.active_low = 0,
/ ~$ ` u/ x8 H) C' L6 _& F ^ .gpio = DA850_USER_LED3,
2 Z$ s4 V# U3 l' W& G: E .name = "user_led3",. ~1 W% U2 t$ c
.default_trigger = "default-on",
4 R5 |0 s# z$ L, |8 D9 s" m& Q: }! t },
6 P* h$ _ W. s1 I9 h};! o" f. N% x3 s
n3 Z5 r4 h- B( j$ s7 H Fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
f Z v* v' X- U .leds = da850_evm_tl_leds,
0 L! C5 Z& V7 Z0 F6 w# K# y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 q2 H2 Z0 x+ A6 n7 t e( k
};
, `' s& f; o0 {* [# H2 E$ Z/ [- }# {- v Q* Q/ B
static void led_dev_release(struct device *dev)
" {" D$ L$ @* I{
+ t. y$ @2 _' N4 ?};
4 }" R7 k+ ?: m
" e; `. m/ M/ M `8 U5 Ostatic struct platform_device da850_evm_tl_leds_device = { v. {+ ?5 l& E; f, C1 m
.name = "leds-gpio",
0 ]% h' L, f6 g: g .id = 1," G( T+ A+ j: M: g2 ?( |
.dev = {
7 a3 Z; v8 z% h3 A& [/ k: u: U .platform_data = &da850_evm_tl_leds_pdata,+ v1 z7 o- N# Q8 `2 R) \
.release = led_dev_release,$ k+ D) A) Q! W0 j. l2 U3 l! ]
} R$ D N5 b# v0 W% s; V4 l
}; E+ Y5 V, N( U3 l" C5 `
( k, j8 U, Q5 D/ b6 f
static int __init led_platform_init(void)
' z( V$ S* _" u5 X0 A{
8 u/ C. A1 N/ x6 f( ?+ d int ret;, U+ W( T6 N- ~: o/ q
#if 0
9 [0 S( b/ E8 y0 f) I3 J' w' O5 |! x ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 a# p) ~0 S7 D if (ret)
4 v# @$ Y' G6 X7 y9 ? pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* i V$ J. u3 N+ n { "%d\n", ret);/ k! k% A$ C' s3 s+ k9 [5 r
#endif
: ~6 l# }6 q7 x. ^5 a3 E1 j ret = platform_device_register(&da850_evm_tl_leds_device);
* |4 j# R* W& ` if (ret)
6 |( m8 k O8 V( h* T pr_warning("Could not register som GPIO expander LEDS");
* F0 h0 @! O, C9 q1 l6 y else9 X* I7 x: I$ \. f& h% N, u
printk(KERN_INFO "LED register sucessful!\n");
+ A; b+ {; ]& w) }
/ z! f0 L& h) A# m return ret;% W u; r9 E. G2 p! x c
}. ` M% [. Z" T
0 U0 z* z4 J R U) `static void __exit led_platform_exit(void)- ]# L+ w# U$ A3 U; }: P# j2 x
{
( {$ h/ [8 q+ _! l7 I# O platform_device_unregister(&da850_evm_tl_leds_device);8 ]3 R1 K- b) @2 l E S- {& ]4 G
/ b8 v6 u' q+ j# c+ w7 e# m N printk(KERN_INFO "LED unregister!\n");
- s# J. Y+ R) G3 I J}
f, f6 B, s6 P3 N6 w. c* ^( h. v5 x) D" H. M1 {& L+ U
module_init(led_platform_init);
! O) K" H- \& p" L; Lmodule_exit(led_platform_exit);* b' {0 J, e& P) _3 H6 `. l5 c
/ p6 i3 K; m" o6 m2 NMODULE_DESCRIPTION("Led platform driver");* X- s C6 E- M U* {2 Q O1 m
MODULE_AUTHOR("Tronlong");, T/ {3 b3 t5 T( p! H7 H- R
MODULE_LICENSE("GPL");
6 S6 j( y' |/ `8 E w
% W# T( t, ^% _7 M% K% R [/ j! I |
|