|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 I+ i. D/ Y6 q* H! h; b#include <linux/init.h>
* {* X4 X/ V$ D" j7 u#include <linux/module.h>+ { h s8 b5 B$ D3 E# X+ h# o1 K
#include <linux/kernel.h>
+ \7 h/ u1 u* G( L! k# Z& V9 U! p j#include <linux/types.h>$ d1 W- I+ }+ x- E( c: T
#include <linux/gpio.h>
9 \& c1 v9 D, U2 T1 S#include <linux/leds.h>
# I' v" F" n( O# b#include <linux/platform_device.h>% k3 G& y& c, v: H0 W
/ T+ @' {) t; r4 I6 Q# W#include <asm/mach-types.h># a; U& Q5 J* D8 |; z) @- ~
#include <asm/mach/arch.h>
/ C" T2 {! F N: y& m+ M. u7 f#include <mach/da8xx.h>7 | |* R% C, t# N- r u7 {
#include <mach/mux.h>
& y# `* Y6 f7 y: {
4 u2 C0 k% A: P" R h#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% W/ |: g9 ]- B+ K: L
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 p5 r+ a3 G; A9 ^$ f#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; J9 m! J# j3 C; S. B8 L* B#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 G- U% l L% a B7 H: D
4 ?; X- P$ ]5 {( k1 F, |; l1 m! {8 o% h
/* assign the tl som board LED-GPIOs*/- Y, `6 l0 ~, j; U: t* b$ D+ w
static const short da850_evm_tl_user_led_pins[] = {9 O- I3 q2 o4 H9 y) a4 J
/* These pins are definition at <mach/mux.h> file */
( G, A% Z, T+ m |' J' H DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# E6 j* R2 V6 A% k4 ~/ z7 L9 ~4 g
-1
. ]* \, k$ o8 R};
& J" p; p7 U1 Z7 Q! d+ U4 z4 a: \5 e2 K1 Y/ t4 L
static struct gpio_led da850_evm_tl_leds[] = {/ S5 S: }! \8 N3 A: h, {
{
, n/ ?4 n) Q; {9 S8 o8 {4 T5 ] .active_low = 0,5 |* [ ^" s( ]; Y% f9 O0 Q& T
.gpio = DA850_USER_LED0,) H8 k9 S9 `1 G
.name = "user_led0",0 j, P; N+ q; M
.default_trigger = "default-on",& \) e% k) _" e9 B# o5 \2 }
},9 F& _" m/ [9 m2 l3 Y, o ]
{; v: l2 p1 b! w* m
.active_low = 0,
: w. W; G# z4 E, I( H2 u .gpio = DA850_USER_LED1,
5 g3 x3 @0 _( q3 I1 q1 _ .name = "user_led1",
" k; g- D( p* ^& F! n .default_trigger = "default-on",2 C. @6 H8 \- v# t) A; P
}, {" P- X9 Y s4 r
{* I8 Q0 g- W. `- E5 \2 p9 S6 _0 ]
.active_low = 0,1 x& K7 R' W4 N8 c; u
.gpio = DA850_USER_LED2,7 X* s* x* i* e$ L& W% t2 P
.name = "user_led2",
l* j$ z( z( t1 A6 d .default_trigger = "default-on",; E/ m- I' i0 i9 p- L1 ]
}," ?+ u& }, m+ |" `
{
& O0 P) t5 U: Q5 q" X7 H4 m .active_low = 0,. I0 T* a) k9 b8 \+ D) L+ P
.gpio = DA850_USER_LED3,; {$ D3 B9 F1 W4 u
.name = "user_led3",
& g0 m# R0 h6 N7 c* u W0 v9 `) ? .default_trigger = "default-on",
5 f Q( D7 y. O* B2 m, b },; \1 p8 f4 i9 k( d# Y" V6 g9 ~2 P
};
2 ^8 W3 M1 c+ ~% A& i6 _, @/ _3 h5 z1 q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 p1 e& |& D$ A .leds = da850_evm_tl_leds,' F. L7 |9 F2 u- @% `
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) ]! p" {! f# z- V};
4 E8 h. C+ m6 G6 |
* r$ Z h9 W) _static void led_dev_release(struct device *dev)# f$ N6 P* n S: l8 ^6 G# Q. S
{9 T; A" |0 a) ^
};5 R _/ C: c! K4 D
1 @1 D7 g0 q/ E/ W p! ^7 W2 U2 |$ `static struct platform_device da850_evm_tl_leds_device = {
5 o2 V* s2 I( d, v .name = "leds-gpio",
, f/ Q8 l8 b" J! O$ m+ Y .id = 1,6 W, G, {& X3 G8 u# N( T. U
.dev = {5 O& B: s' R' v7 d* q
.platform_data = &da850_evm_tl_leds_pdata,/ o$ o* J# D+ e5 A
.release = led_dev_release,
\& [) X& a3 n& x$ E }
/ T, A6 @& | S& C/ e3 A}; k" B; k# K! K8 z) x
# \: j) Q N. P2 {/ [6 O8 Ostatic int __init led_platform_init(void), O! ~6 O- K: b" Y
{. \% l/ N; i9 B; d* t
int ret;
7 W, T9 `1 z. Q% L#if 0: r) A; ~: r H9 y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 M9 ?8 k9 m& J3 D- T! M. [' o# e: v! j o
if (ret); ^! E- X" E" |$ L7 u
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") B8 g4 ^2 f1 X# i$ e X! m V
"%d\n", ret);
' q7 r9 {: U: X. q, P#endif
, o" ]. S0 r5 P o8 z$ C; j ret = platform_device_register(&da850_evm_tl_leds_device);
! q" Q- ~0 P3 ~ if (ret)
P2 B" H4 p2 c6 m pr_warning("Could not register som GPIO expander LEDS");
# y5 o0 `( L3 ^ F else N$ [5 ~& V- G( x: m. E) a
printk(KERN_INFO "LED register sucessful!\n");+ t% a) a$ V4 ~% p6 j8 c
! h$ A& e9 R6 x' f" \
return ret;
1 ~9 P! X) ]4 C, m2 W}8 D' E/ l% d2 L2 T
7 V# O8 l- i" \ T1 I& L6 i' Nstatic void __exit led_platform_exit(void)' Y5 A1 t/ r/ E" \& g- q
{- T* _0 w6 a2 \) h. X" B, ~
platform_device_unregister(&da850_evm_tl_leds_device);
1 L& E8 x2 C0 I$ r: R, w! F( D# b+ p$ R# A" R
printk(KERN_INFO "LED unregister!\n");
/ }% ?! \6 b m' S+ ~- c! r}/ U, B) h1 b- G- @
1 `: p2 ]3 _0 v6 v8 e+ K2 Umodule_init(led_platform_init);; C0 j5 A& ~5 [2 t! Z! t% ]4 K& e
module_exit(led_platform_exit); w6 Z; g- e* n3 ^9 a
, G& |4 Y2 G8 k/ ?+ n8 `0 g4 kMODULE_DESCRIPTION("Led platform driver");+ [8 S* E" s3 l5 H$ K
MODULE_AUTHOR("Tronlong");
' O0 s @) g, k+ o& eMODULE_LICENSE("GPL");0 j6 N# y' F& N9 V/ t: V4 {
8 F3 H# r# s6 P8 Z2 w [% l: r- { N# M
|
|