|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ A/ r+ C; u9 D& B8 q) d/ v#include <linux/init.h>
* ?# |. _7 P& T$ W/ [" o#include <linux/module.h>
2 L) [$ n+ f" t+ Z% f. F#include <linux/kernel.h>, `; m4 F2 ]# K' @& L. d1 S
#include <linux/types.h>( p$ m! m: S' e( _
#include <linux/gpio.h>
e% q$ V K) v/ e. M2 `5 K#include <linux/leds.h>
' f4 a2 N$ v6 _4 o. I! ^#include <linux/platform_device.h>
1 P/ _& q. S X5 |
3 _8 Y3 U6 {; D' A4 D; z#include <asm/mach-types.h>
) h% w. @( i1 I& i- D#include <asm/mach/arch.h>
/ a7 f2 C2 X4 p8 ~ D( }8 g#include <mach/da8xx.h>
{- n6 Y0 {$ z! Y2 |/ ^) K" B* O#include <mach/mux.h>4 \3 P6 U) J( @' u% _
" T" \; S( U+ |! _( Y8 t#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) s/ W6 W6 r1 W' `; C
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) ^) v! ^- b2 z3 ?#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! A( W* [/ d: v& r1 r
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. l8 w8 O6 ^# K+ X# \% i' p% C" v5 F! ~
/* assign the tl som board LED-GPIOs*/7 @) c' }# V4 w" a
static const short da850_evm_tl_user_led_pins[] = {
1 s; u& N. ]! B: H1 {7 [( F /* These pins are definition at <mach/mux.h> file */
2 k/ [; ]3 h1 A* s' i" B DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) A+ s* v* K* P7 G7 N* t; n3 x
-1
" _0 q- @' x4 e' x+ `, W};
) ]& H C4 z# G+ B, {
! A8 b4 d, D3 Y9 s+ Kstatic struct gpio_led da850_evm_tl_leds[] = {
8 ?% f0 C9 o6 [% Z. \- g {
+ D, R$ ~; E1 V% s3 E .active_low = 0,
) V% L9 B G) J% k .gpio = DA850_USER_LED0,
" M/ X2 ?" S" \+ H3 H$ y! ? .name = "user_led0",
C8 E! c, [/ F; d; d .default_trigger = "default-on",
! ?- Q( {1 _. z+ S) M4 f },; U; d$ a1 H: ~6 b
{
; V: n z2 q/ n .active_low = 0,
: p. U6 S/ q* X* { .gpio = DA850_USER_LED1,7 U1 H1 P! A* o6 @
.name = "user_led1",4 b& Y. W2 `$ q' n5 P1 z, J9 g( P
.default_trigger = "default-on",
: ^0 c N& N* j% K }," P. F r) u" e1 D8 y [: ]. S, T0 b" J
{: v. O1 g' R7 h
.active_low = 0,
" M8 X. X6 p$ ^9 x9 d Z* b$ u .gpio = DA850_USER_LED2,& L3 N+ L/ k% G! y0 N: U2 d
.name = "user_led2",
, ?0 x* G" U3 R5 X* V' J .default_trigger = "default-on",% |6 y; K- P) Y7 x9 E
},
4 Q" o* D2 G" g& [) c) l) e1 {. C { D& j5 H" ] k
.active_low = 0,
4 ^# b$ Q0 `' m5 P6 M .gpio = DA850_USER_LED3,) u+ F7 s& F2 `4 e G
.name = "user_led3",+ ]7 M$ _( k2 ?/ z
.default_trigger = "default-on",
: I6 q. X% H& Z. a },) H9 l1 I, @5 q3 `: u9 P
};2 j1 E# r: \% x4 n. E9 b
; i8 c' E: [* n
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( a1 G: k6 ~7 p( \1 o' C .leds = da850_evm_tl_leds,9 \7 v G. \# ], I6 y {. t ^
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),% u/ x: q4 @ o! t) {
};
$ l% u9 F, T# ?; i
+ X7 [& q" @' {) e& D* ]static void led_dev_release(struct device *dev)8 ?; S2 x; W5 A% o3 U( k' s' @
{. i* g# ~2 d# ~
};
, ~) w, I* F4 U' S# l3 {
8 v$ o8 B) v( k+ x1 Bstatic struct platform_device da850_evm_tl_leds_device = {
( {5 }! x- w+ w' z2 ^: A: p1 t; _ .name = "leds-gpio",
9 J R8 w/ s' z .id = 1,
9 ?% o- b8 _5 b0 O) b .dev = { x- K8 D8 p) o9 U9 l3 ^) j4 Y; z
.platform_data = &da850_evm_tl_leds_pdata,
% ^9 j, r* w ]% o5 c& W3 S5 K .release = led_dev_release,
5 F6 C$ p3 w) K* z* E }; x7 V7 c+ ?3 U2 ^. w
};
7 w, Z" a" N" `0 z o2 j6 u
; r- A: O# ~; i/ t& P( estatic int __init led_platform_init(void)& ^; a5 _; x* W& E
{
, x! I$ K5 I2 K int ret;
! Z; P9 _) v& K" X#if 0
7 d; }" q8 s8 D- c4 d9 S2 v ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 X( M6 g7 o1 W3 G if (ret)
5 n; Z, f2 d9 D2 T" p pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% I& b7 P7 S, d5 q, W# ]5 g, t( `, N "%d\n", ret);
/ K# U, g1 F7 T) {& S; g' c#endif4 Y' ?5 j" G4 A$ A8 `% b
ret = platform_device_register(&da850_evm_tl_leds_device);
8 H* Q8 o0 ]0 |$ L- T2 ^" w# r if (ret)1 I9 ~$ A/ c3 p
pr_warning("Could not register som GPIO expander LEDS");
* ]# @, b q' V- l: x" m else8 r i8 w3 }' W, {9 Q
printk(KERN_INFO "LED register sucessful!\n");
" M( A; W- ]& F' g9 B: c" i* x5 y* U% c3 a B' N6 E
return ret;. h" ^4 f/ X2 w1 b" N5 }7 }
}) ]" A$ W. }3 s7 O6 v; `
. l. E% I# i# j$ bstatic void __exit led_platform_exit(void)
3 U- }9 d" M- p, M{
4 i2 \/ [2 F. ~* l3 l% v2 j platform_device_unregister(&da850_evm_tl_leds_device); J1 Z$ i y9 @, n/ z0 q1 r9 N
& ^( ]' ^" z4 X/ P
printk(KERN_INFO "LED unregister!\n");
# T7 a" t9 ` L3 h# I& ]( q+ |}5 n0 T b; W7 v/ B& ~, n) g, h
1 F8 q& L' e5 @% V5 zmodule_init(led_platform_init);
( X" c( L) }7 C2 Q) _module_exit(led_platform_exit);* I$ z! p2 p- g9 Z
" T: X8 h! W6 \- R2 ~" P- {MODULE_DESCRIPTION("Led platform driver");
! j1 {) C* Y2 y& w4 b- v1 ~MODULE_AUTHOR("Tronlong");
0 @* }. f$ x' B& [MODULE_LICENSE("GPL");
) ]6 j( p9 d) P% b& V4 m% ?' B6 l% d( M/ a: m! I5 Q( W
|
|