|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- d+ V: ?# X8 p/ ]5 r#include <linux/init.h>" o9 r5 ]& W8 i: G* F; e8 G
#include <linux/module.h>
: [/ \4 v( I% A) ` u" M) l& h9 b# K#include <linux/kernel.h>3 S$ ~( W1 Z/ T2 U4 t- c; O! J( H
#include <linux/types.h>* _% P# F2 i/ u$ C; Y
#include <linux/gpio.h>: D1 P* D7 E( Y2 a
#include <linux/leds.h>6 d. |- b$ l8 m* z! j
#include <linux/platform_device.h>- _+ `' r: |9 |9 N* l3 ~
, ]' F0 y) h r" v9 Z. U
#include <asm/mach-types.h>; ^0 A& t( Y7 k4 N8 B8 n0 o/ c
#include <asm/mach/arch.h>
" v5 y3 |1 _; z! k$ H# \: V2 J9 N#include <mach/da8xx.h>$ U! w$ x, G8 C/ L; d
#include <mach/mux.h>! c) X1 B/ e: y7 l. |& h2 W+ ?
# R" \% W9 U o! D
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ i# O& _$ R5 O9 \3 A6 n: Q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 y1 ^5 q7 x6 J, ]4 M/ K#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! c1 E) @ Z j% I& t+ H) g, I#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; Q6 b9 o9 A8 O, I! r
; J! z# G* y9 C4 n9 O/* assign the tl som board LED-GPIOs*/# T/ \$ z- t! K: k: W9 S
static const short da850_evm_tl_user_led_pins[] = {/ V. ?4 @9 H3 \2 } q8 L
/* These pins are definition at <mach/mux.h> file */! y5 o {( Y4 p3 c4 b& T: y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: {& A+ ?8 x( p2 z+ E
-1) ^4 a; G, D* @* g6 w p- N" b
};
+ E3 B5 G2 z/ c7 \+ R
8 H8 Y2 d5 L/ V: O1 ^9 ?* _$ F$ y' lstatic struct gpio_led da850_evm_tl_leds[] = {6 l x" B; Z8 H5 W7 o; j
{& I! C0 d9 N; X [
.active_low = 0,
3 x& S7 \% k2 `5 Z4 N* A% a& O6 { .gpio = DA850_USER_LED0,( P% b8 [5 h9 G, p6 f
.name = "user_led0",
9 @( W4 x, I9 x3 x! b7 M( L5 @ .default_trigger = "default-on", V6 ?- Y) b0 J& ]0 N- x
},
# P# D; g1 ~0 X ?+ }4 i {; P: E- P# B ~6 V+ U; z3 m
.active_low = 0,
" V- [7 X* y) M F- s' p; e .gpio = DA850_USER_LED1,5 i% M3 f8 ?# J' h
.name = "user_led1",
I) {3 C: F5 \ k* J* A6 D5 \' h .default_trigger = "default-on", V5 F& o' P5 R3 k# q; B; m
},! ~6 ^' X! j& E4 S5 i0 _0 |
{
+ O# l8 l8 q0 u. ]- w0 C3 o& } .active_low = 0,9 w, o! U1 _/ ^4 d) J! M9 p
.gpio = DA850_USER_LED2,
1 ^6 S3 | W. B( n+ D5 x .name = "user_led2", `( X( c3 \6 |' C" T
.default_trigger = "default-on",
: e n/ h, ?" f7 n0 b3 V+ y },6 F# B& v5 [4 K& m% E0 w
{0 v* I4 \4 A4 _( }8 D% e( N( ^
.active_low = 0,
/ U Q8 ]9 m" p3 B" c .gpio = DA850_USER_LED3,
1 [5 i# z2 T* x/ r; D& o" o7 E .name = "user_led3",
# q) u8 Z6 ]: M R: x .default_trigger = "default-on",9 [9 k9 m8 H' U, [9 O& S1 a
},) c/ o: E. T# C; a3 A
};- v& i r6 g1 S. f% D1 W
6 y' v7 |0 d0 A! wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& j/ u0 ]; @" H7 \+ Y1 P2 v4 |; b
.leds = da850_evm_tl_leds,3 i6 k# m$ \7 P# I( J
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 m8 X% w: j9 ` D* I
};& r8 g& m' H7 z0 y- o( u
. t; V% R N# _7 c5 x5 n c: ^
static void led_dev_release(struct device *dev)! Q: L; b4 X9 }- O$ N$ J
{
. S ]. N0 A, v; x& ?# t2 f' S};
, i% S0 F( B# S. H% n9 C D2 N. ^
static struct platform_device da850_evm_tl_leds_device = {+ Y. U, H0 q' C1 Q7 N
.name = "leds-gpio",
- e* j1 v( M# @, j- a# W0 ^ .id = 1,: [% M) b7 ]/ J' h' x1 A @: T
.dev = {. G* H! X+ x" ? {4 Y
.platform_data = &da850_evm_tl_leds_pdata,/ ^2 V/ ^: R6 M# i1 u
.release = led_dev_release,) t3 G; ?+ X! Y/ x* o3 @$ z
}: U( T' d! y& O, w# i0 D
};
( t) B& m$ s! }6 Q: @) q# U
. a# g4 I1 U4 c+ P5 V2 G, I0 tstatic int __init led_platform_init(void)
2 n% g% {. j9 a0 u{
' r+ E. I$ X/ R( d% [+ Q4 F7 L c int ret;
( K- r6 l) `& W, _#if 0
( i9 ^) i/ }; N- [4 r ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); x+ |6 h+ B7 U; z. j; q4 R b# K
if (ret)5 |! f2 J4 W9 R$ N! b
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 p- t# m; F$ U8 a ~ "%d\n", ret);4 J' t6 ]" V" F
#endif
( n9 F" k) c( ]* J' f/ P6 ^9 a0 ^2 G ret = platform_device_register(&da850_evm_tl_leds_device);" Q+ ^# f# G4 J' T: @
if (ret)
3 z- P6 l: W6 {$ S5 M2 H% V pr_warning("Could not register som GPIO expander LEDS");
1 l1 G1 {1 Z( c9 G* P' B& X else' c) U% ^) q7 ?! X6 w( M2 o; Y, l
printk(KERN_INFO "LED register sucessful!\n");7 ~5 f2 ~0 p7 ?/ q+ X
% Q* @$ ?0 E! E, s& A }3 I return ret;
& o" z+ d; [ L0 a5 g) R}$ T( W/ i0 [# `4 U% g0 Z* Y) f+ b
( z* V% Z9 {1 \9 B( L0 K( l
static void __exit led_platform_exit(void)
4 k7 f0 k( [0 w2 \# V{0 X* z8 Y5 r2 c' d9 p
platform_device_unregister(&da850_evm_tl_leds_device);$ o# w8 J$ b6 O) _; B2 s1 G( j
" K1 H. S/ D2 w) t# t printk(KERN_INFO "LED unregister!\n");
5 X3 h0 P+ t0 u, h}
% g0 G5 E( T$ G. ^# h" V% Q% v6 a/ M, i; ?" ~
module_init(led_platform_init);
6 I( ]6 Z7 h7 }% _6 qmodule_exit(led_platform_exit);" ?6 M! V6 |( h: w! ^/ d2 V
* t: h% A& F' N) VMODULE_DESCRIPTION("Led platform driver");
5 r0 D) d v$ [MODULE_AUTHOR("Tronlong");( Z( z/ w9 s5 ^+ X4 x
MODULE_LICENSE("GPL");
5 J8 {3 |. o% F2 H3 b& t# K7 b4 l+ t N3 w5 F! d
|
|