|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: M l& R' y: `5 M#include <linux/init.h># k4 R& {# \" a8 P3 M2 z! r) N
#include <linux/module.h>
2 M: v2 g1 p/ `, g; X#include <linux/kernel.h>
+ i( ]# i& ^7 V0 E6 ]#include <linux/types.h>8 g% X9 y( f, r" n) l
#include <linux/gpio.h>
; O. M2 f: [4 P#include <linux/leds.h>9 Z! T# A8 O4 j1 U
#include <linux/platform_device.h>
3 D1 _( A1 i1 \' o% {1 ]4 C0 M% T" o/ C9 n
#include <asm/mach-types.h>- c3 \& E4 v2 z6 r1 c; Q
#include <asm/mach/arch.h>7 ]) d( a; u1 r
#include <mach/da8xx.h>" T: }* C8 w+ |
#include <mach/mux.h>. C- v) D( y7 v+ n& G# X% i: h8 R
" {4 @% x8 B2 L3 c( m( U
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) c4 m' t) d0 v
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ \6 H5 j8 a7 H" d. y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 Q7 y/ s, M, J4 f- @4 j0 t3 y3 M#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* D* z# b# a$ a$ T" G2 j1 t1 Q7 _
) _9 j3 P8 V: j/ d
/* assign the tl som board LED-GPIOs*/2 h: s) v1 Q+ U8 B+ {! B2 z0 b
static const short da850_evm_tl_user_led_pins[] = {
2 z) ` C! a. N/ n k9 e6 G /* These pins are definition at <mach/mux.h> file */
" z+ i% W$ n% W, o& _" E; E9 C* b DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% {0 {7 N: u9 C, N7 R) c0 U( O -11 N9 p) X: P/ q* v6 d
};
% p& ~: T, X. { w; R" H
0 u6 |2 b& H% j0 {* m {: Dstatic struct gpio_led da850_evm_tl_leds[] = {/ O& i* H" B4 _2 A1 D9 f
{
Y' l5 \, x7 W: h4 C .active_low = 0,
3 a/ R" t8 E7 B .gpio = DA850_USER_LED0,
3 f* f: n5 A0 l$ O9 m0 K9 Y3 B .name = "user_led0",
, _/ _! }3 C' v9 Q; z# f .default_trigger = "default-on",% ]0 E d" l6 G1 B
},( m3 Y5 g' M5 \! y" _
{- {4 ?: E5 p4 J# E5 J
.active_low = 0,
( U- T! W$ H) k# Z- v) ?# } .gpio = DA850_USER_LED1,
( I2 j, D% I+ a$ u, ~7 J .name = "user_led1",
7 f, B, ], a3 c% y) _ .default_trigger = "default-on",
5 j4 e3 e* r# C+ @. q* b: n) x8 h },9 ?" a3 s$ g3 n. [# j% x
{
: H/ K- j( w' h- D' K! \1 ` .active_low = 0,: n o/ R2 k* l) u5 o
.gpio = DA850_USER_LED2,
+ P& g0 z2 H3 E3 \, w .name = "user_led2",
' w# h$ R1 c" l" z" R5 v! X .default_trigger = "default-on",+ P( `& j' `9 |& [7 {
},
9 }7 G7 A1 W& B& A" [5 s- ?' p: P {/ @: b [$ b( m. d6 X. M
.active_low = 0,
4 ~% g2 k$ s; q .gpio = DA850_USER_LED3,2 ]+ t/ q; Q/ @1 L5 [+ O* @. R" j
.name = "user_led3",8 f3 \9 J& @# G6 S$ ]0 S
.default_trigger = "default-on",
* ]+ o& J& [2 h },
7 l& O+ u5 R8 |; W};7 p1 N# ^) i* x6 ]% F$ a
3 L: E2 Q. t5 `- K. V- q* Estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- _/ B! [0 @& A6 T* ` .leds = da850_evm_tl_leds,
7 [/ l0 {: L4 ~' P7 n& ` .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) d2 x; x$ V9 `, H, d: G
};
0 U# B( r! c3 _! y
! R8 A( m0 ~0 a/ Wstatic void led_dev_release(struct device *dev)
( [0 L4 W2 T d8 ]( T- ~- g{
+ D# C( x) K! U' M: k6 B};, i* e W0 K7 w! p U4 q
% N# ~( q( a9 l! ?5 a( V- N
static struct platform_device da850_evm_tl_leds_device = {
; W+ Z0 B5 J: e& X% r7 k .name = "leds-gpio",: F5 O" O5 o, F; ]
.id = 1,: I: M" B) g9 W- P5 E' k9 g
.dev = {
7 e4 k8 M' v3 U4 v$ X .platform_data = &da850_evm_tl_leds_pdata,
( H! d& C$ Y- u+ { R- j+ l' n4 ` .release = led_dev_release,
0 X9 h/ R7 m$ N! ? }
6 R/ X: Z: N8 w4 {8 k u1 Z};
# Q" Z$ a m( c V) `; w5 ]5 d0 ]
/ C6 F$ y* X. u" k3 n- d" Ustatic int __init led_platform_init(void)/ T' y7 E& i1 p5 w m
{
$ F3 R U; x1 K6 j6 Q: Z4 z int ret;
1 V& r: I `" k- c, r) @#if 0
3 z1 H0 @) i3 _! f ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ B. G9 l8 y, z1 N if (ret)2 L& s, }3 r+ H' p
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 I8 k# D \* n: v& S6 Y: K "%d\n", ret);
( I! ^! g4 Q" |7 v. s#endif
$ s) T' R7 Y# k" `( Y ret = platform_device_register(&da850_evm_tl_leds_device);
! l6 r/ E; n: \! ^ if (ret)
A, w3 N+ s# f' \+ q pr_warning("Could not register som GPIO expander LEDS");
, V1 x$ z5 G( Y" a8 n; E else/ P* A7 d2 k& ]: V
printk(KERN_INFO "LED register sucessful!\n");1 Q9 A7 c* }: F3 V4 y
' a y$ g0 _0 P, V5 k, r# W
return ret;$ H. n5 ~. P8 L! m) B* @
}, R3 Q) a( [/ W' C+ L( H
7 F- q* J$ T& M, K6 a' Hstatic void __exit led_platform_exit(void)
: s7 b" Q1 \# E7 n" X{- z* Q Z/ N# r- C3 C) B
platform_device_unregister(&da850_evm_tl_leds_device);( A$ ?! w% H! W( Y
# U6 ?0 f: s0 F( M7 C9 m$ @
printk(KERN_INFO "LED unregister!\n");
+ S4 N. _9 n3 }}; j: s% c7 s; v' B: g3 |6 I
p: f5 G/ `2 N6 {
module_init(led_platform_init);3 l7 T e- x' B5 l7 q2 L& V
module_exit(led_platform_exit);( M5 K' U4 |4 R7 }/ C2 v7 I! l( r
: `" s/ n4 |. ZMODULE_DESCRIPTION("Led platform driver");. R4 X5 Y( C; k$ W9 m4 h z
MODULE_AUTHOR("Tronlong");
+ i5 W9 m, ] SMODULE_LICENSE("GPL");5 i2 P* X1 I" t( ~; T8 w0 A
, N y& r# m8 I' U& _) X
|
|