|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- F4 f2 J Y: w4 {# v' O# x! U& {0 `
#include <linux/init.h> E& {, K8 b# |# @
#include <linux/module.h>
8 a* X- W' L* u! |. M: P#include <linux/kernel.h>
) C! M w1 _6 @3 @2 ^#include <linux/types.h>8 o+ z! Y5 r' u
#include <linux/gpio.h>
. D5 H+ a0 J; @. o6 b5 b#include <linux/leds.h>
( S# J7 ~8 ~8 \! M# h#include <linux/platform_device.h>
$ L9 M1 [" U B! \, {( |7 E
0 n8 D6 b6 G9 p" p( {" j# W8 O8 I#include <asm/mach-types.h>$ f& ^1 J) _, V6 C$ b, t5 p' C
#include <asm/mach/arch.h>
& ^8 z3 q; M3 I' c#include <mach/da8xx.h>6 C, s$ T" `$ ]
#include <mach/mux.h>
1 z. z8 [$ V( V5 ~" n
" ~1 e% [* H( E$ G#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* N M7 Y% [" ^$ ~; B& b#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 T" f# p0 w4 [/ g( L. O- w5 s8 J
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 k d7 f. P( [& T
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( r# n. M- ^2 H; k
4 d, a8 `6 l7 c& c- q+ ]3 G l/* assign the tl som board LED-GPIOs*/, v' R8 y' E* V
static const short da850_evm_tl_user_led_pins[] = {
( V6 w! b: g( Q( r /* These pins are definition at <mach/mux.h> file */& K3 I% _3 x0 v! I7 b
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 g+ x& P: J2 ? }" x9 G -1
0 [' a7 R! e4 c% h; Y7 c) A0 S7 l2 O};
# c0 F4 m! L- r$ l: L
5 b6 b- [+ V; I7 e( ustatic struct gpio_led da850_evm_tl_leds[] = {$ z, q4 `% R# j3 y
{* H, k2 F+ B0 M% _5 x
.active_low = 0,
: w J' r$ L, [" u+ R5 r .gpio = DA850_USER_LED0,9 z% ~6 \+ x7 j6 v. u- V
.name = "user_led0",
, T3 B) r! [3 `" t .default_trigger = "default-on",4 c9 S- c! H& I
},6 ~/ M# u# f& ]. l
{9 z* I5 x1 U7 G' T* v1 h$ i
.active_low = 0,) w+ I, t& f6 O) Q
.gpio = DA850_USER_LED1,
3 }8 M9 U; O% k; G8 _& t# o .name = "user_led1",% e. k! G6 A$ d3 E, {
.default_trigger = "default-on",
# }, |* u5 _/ U4 z2 R% O' m3 y( f },
3 M2 b0 o2 g6 i2 D" a {
( _ i+ b/ N, {+ X* ^ .active_low = 0,
8 w. ~" n2 d0 H% F- l" Y .gpio = DA850_USER_LED2,: F. m: R) d; W0 V# j0 y
.name = "user_led2"," l2 V5 }, d" h* R8 p- c
.default_trigger = "default-on",
7 x1 O* Q+ @, P+ b# ~ },. ], D/ I- p( T$ X1 ]: y
{
; j. w( {/ z' Z3 o, F5 P- C5 B .active_low = 0,
* H& Z; E# ?$ F: `! y1 t0 G .gpio = DA850_USER_LED3,! N% X) n8 l! z
.name = "user_led3",
8 h+ Y# o1 q! D' m+ V- W# d .default_trigger = "default-on",7 h- v1 f) p0 n& c9 r6 \: T
},' w2 `; Q/ u2 U' e
};
/ {- x* c# s8 _( q5 P3 f$ g
% h! y8 h/ W: v$ o" Cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' K: i* h2 T7 v0 n .leds = da850_evm_tl_leds,2 A. Z, T& q1 d2 {1 o
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ }- O" `, s- n# C& r: s8 \};
# ]4 i. r7 c5 F! L$ v% `* P
& S+ ` p# Z( lstatic void led_dev_release(struct device *dev)
% W1 p& \% _& k/ m8 ]2 I{
5 Q! \' }: b; `6 d; o- q};) q! W4 q, z" E* j: F: k6 e
4 k7 D0 H- u$ s$ U. [* G2 Wstatic struct platform_device da850_evm_tl_leds_device = {
3 b* z$ R' d" O2 N2 Z. ]. W0 ~- _ .name = "leds-gpio",
: J1 b! E2 l8 E# l0 A' {( u .id = 1,, w, v5 B/ y" y" S1 P& E5 i
.dev = {
+ G% n/ Y/ i0 t" W .platform_data = &da850_evm_tl_leds_pdata,/ R0 V" a2 H* i1 }
.release = led_dev_release,
, G% b' b( U7 S) W0 `$ |& Z; M }4 g* ?0 z4 y4 t
};
4 q# G! M2 k8 l$ W+ ?3 ?, q/ e; P5 I4 V j! ?2 J; s
static int __init led_platform_init(void)8 C, [- L) X, W4 i3 }; ^
{9 G9 f4 ^! i! q% [
int ret;
, r0 l* h3 F1 G% U! ^( S/ x$ O; y% i! X#if 08 E A n; h4 V* Q' [( u0 L
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 u5 ~. Z" H/ }4 x: I
if (ret)
) T2 E6 i2 @- Q9 {: h+ R7 I; u" n pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 b& I. z; Y1 H; {$ n
"%d\n", ret);7 Z( X6 l! t4 j8 n
#endif
( y* P+ e: w* ?) y' M( @! F ret = platform_device_register(&da850_evm_tl_leds_device);% F# V3 \( ?. l; | c" F! A
if (ret)
7 N0 n* }, v4 S4 o9 w# o7 u pr_warning("Could not register som GPIO expander LEDS");
& x3 z* W, \) h: \% v else
3 `& W: P* J* o) [- U: R printk(KERN_INFO "LED register sucessful!\n");8 | L7 G$ p+ u y
. k: \! C' i: J+ d' o" J return ret;3 `* |( }; E8 I) q5 h2 @
}
$ A* j8 [- W, w
; ]8 b3 i0 A) Xstatic void __exit led_platform_exit(void)6 H. G, J' a! y- ]* Q9 h+ |0 T
{
$ X0 J2 |; ]6 k" @: _ platform_device_unregister(&da850_evm_tl_leds_device);/ ~; K8 B9 w6 R. V' k0 G- G
5 H1 j* h( c* \8 q# }* @8 t) [ printk(KERN_INFO "LED unregister!\n");
6 q' o# Q5 ?2 U* a' b8 g}
8 `6 @$ Y4 `' d
( J* b% }6 h# f) e1 gmodule_init(led_platform_init);$ U3 q, {* w& M: @! W% w1 C1 f
module_exit(led_platform_exit);) v S) b- H5 s9 N
0 N. |* G+ z) i3 K& b" GMODULE_DESCRIPTION("Led platform driver");. s. B5 G; z% o0 R3 C
MODULE_AUTHOR("Tronlong"); x; f5 M% I( S8 Z" q
MODULE_LICENSE("GPL");. a8 W) `4 D8 Z' f. y5 `
; n% }! `' M5 v4 O) L# c) A* d
|
|