|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 u' a8 }0 u f$ k
#include <linux/init.h>/ r7 m3 f5 s; Q& B" c' g4 v
#include <linux/module.h>
3 g; b+ @' v5 h#include <linux/kernel.h>
, d9 w& V; I. H1 H#include <linux/types.h>& F: u; y3 J* b$ w. U. q8 }& Z$ d# H
#include <linux/gpio.h>
3 p V1 p; k8 }1 X O! j9 a* H |+ e4 r#include <linux/leds.h>
& ~% D0 B' L& a% L) j7 @#include <linux/platform_device.h>
. c2 I F8 X# u8 U
( G7 `$ ^( B( j#include <asm/mach-types.h>
( @2 R( ^, B! m+ k* F+ j1 v#include <asm/mach/arch.h>
; i) k! R3 B o: ]& q; |& R#include <mach/da8xx.h>* S1 |# ?. M4 v0 p7 e. P
#include <mach/mux.h>
4 f# S* s2 M) j ~, J8 [% _" w1 x1 g+ B& t# M2 v% u4 P5 l3 P
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ a: B; T% g, S' k7 M#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% u) E0 |( v3 _" v1 w#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- e" t4 K0 P: E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* z5 f# C# t, ]/ {0 R' r
! q B& B5 `3 [- n8 ?2 M) }/* assign the tl som board LED-GPIOs*/7 J6 x- o7 C! t2 |. N
static const short da850_evm_tl_user_led_pins[] = {
8 A ?3 k) v% E. h6 h: \ /* These pins are definition at <mach/mux.h> file */( A2 r6 F* n$ @* j
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
E- f" ^/ o$ ^' B: h) w -1
; q: X3 v" T0 I% t! V! M};
6 [9 d# E! r' a4 J! _! n
) ^* S B7 q, S/ [static struct gpio_led da850_evm_tl_leds[] = {
3 y, D6 j/ k2 m {
- `. V5 a# |/ M& a* | .active_low = 0,# Q& h1 U8 n5 S/ t! j
.gpio = DA850_USER_LED0,# N" }. X) a" R* y/ U/ M, D7 E
.name = "user_led0",6 I9 Q2 O( T/ C( _
.default_trigger = "default-on",# Y. X- F, I" j! _" f7 J
},
! T9 l3 U2 F4 [9 h8 ?1 G* p1 o: x {
/ A) i% d1 j- ]# e/ W .active_low = 0,- Z, c3 L: Q+ H6 {2 V" U
.gpio = DA850_USER_LED1,) l1 R( C) n2 o
.name = "user_led1",0 w5 L0 R$ G' I& b$ I* f
.default_trigger = "default-on",; A5 e6 S8 D% a0 A
},
# N- F$ R, L( q7 @( E+ {6 |$ O& \ {
& J3 ]4 x/ G) N .active_low = 0,
5 p& M+ B! r$ ^ Q. \8 [5 f1 y .gpio = DA850_USER_LED2,
2 S, U: k6 A7 \ .name = "user_led2",. J8 o8 b8 j" T n% e) ] G9 w
.default_trigger = "default-on",
1 R- v* s, N4 A9 J: b& d& a$ m- O },8 e, i2 ]+ q8 T; N( B
{
. f- ]8 V1 v" C5 u) b4 |( b .active_low = 0,
: v9 B/ c1 f& ^" Y. ~. F( O .gpio = DA850_USER_LED3,
0 w1 @( \! ]3 q m% l" N .name = "user_led3",
) O. ?. J% c, W5 T9 c4 m; I .default_trigger = "default-on",! m" f1 W# ^7 F2 k+ P. ]8 p
},& i q. x0 C8 b2 X6 X% _0 X$ f4 {
};; K" u+ B3 m8 P8 {* g2 U
2 `" w. l; J5 l5 o
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' U9 t( G" b. c, Y2 V& C& W. D
.leds = da850_evm_tl_leds,
& u2 E; z: P. B2 W% f! X .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 D0 p5 w! W; J+ O( m
};
: b" l! ]0 v: v! n* A6 k9 C5 @. K4 @9 q8 z7 ~7 \ k
static void led_dev_release(struct device *dev)
4 E, `4 ^ S! X% S{' f2 ~3 h, V. d: O4 j
};
* ~4 i* m- E2 A5 F! L# B- ^& l( L6 o0 C; R& x
static struct platform_device da850_evm_tl_leds_device = {
. x" Z2 M( q5 V: ~ .name = "leds-gpio",0 j/ ^8 K! ^0 o- w4 K" a% ~
.id = 1,
: e3 k( [6 z$ U4 x5 @; g& b8 @; ?. b .dev = {; K% ~/ L5 A( w6 e5 W* @; P7 c
.platform_data = &da850_evm_tl_leds_pdata,
, j3 m: [+ `9 u1 V0 V$ v .release = led_dev_release,2 l& W P. S3 x/ u* x
}. t6 B8 ~- i, R0 {6 l/ R- s
};
# ]7 O5 ]' t s" j
0 W+ r. a( J' U) C8 @static int __init led_platform_init(void)" m4 ~1 ~' S$ S. P. O
{
. \) |: ?2 a* E4 O7 }& e# } int ret;& _1 n+ c0 j* N; i+ L% B6 ~9 m
#if 0! a' L. p$ s( Y6 g6 ~
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: L+ @: I0 n) Z% m0 G; ~ if (ret)
4 \% z$ c' u0 Y; A: d- N( B/ t( C pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 W( P+ t9 [- o6 j C5 @) Z; i
"%d\n", ret);+ ], |: `' A$ _( k. _8 _
#endif7 @/ P6 e) ?4 i; j7 [8 x2 {
ret = platform_device_register(&da850_evm_tl_leds_device);! i( c; n2 c0 \! ?0 F8 @
if (ret)! a# ~+ }. y& R. V" \
pr_warning("Could not register som GPIO expander LEDS");8 i0 B+ e& O9 r7 S
else( k0 W; [- i7 W1 w) F' y% W. o
printk(KERN_INFO "LED register sucessful!\n");, ^9 m' {' [, k; d
1 h g1 Z I9 j. X; h o* d return ret;
/ e7 _0 `& S; W" q) R, ~! \}* I, J* I+ k5 \# F. n( I
9 m, w. s: ]. m0 ?! Ostatic void __exit led_platform_exit(void)
1 {2 n3 F: n$ d- H& V {4 c{: w0 ^5 ?( ]: {; _5 v" h# |3 }5 ~3 @
platform_device_unregister(&da850_evm_tl_leds_device); j2 x8 P& z, k `7 o5 T
7 r) ^0 M$ l( k% z5 Z printk(KERN_INFO "LED unregister!\n");
) e$ d ?, j9 @}4 w( F- H/ H* n5 r1 Z) X
9 Q7 H/ z+ N% I( l. R" _/ Q
module_init(led_platform_init);5 N4 D0 D3 Z' _ Y& x8 c3 U2 N
module_exit(led_platform_exit);( Z4 q' J8 Q# A7 ?, u
# H& B* g. a9 i8 q7 W5 kMODULE_DESCRIPTION("Led platform driver");0 J: J6 O- V! Z6 i! Z, V# _
MODULE_AUTHOR("Tronlong");
" }. [/ l" {; f& f. v; m1 v0 zMODULE_LICENSE("GPL");
# L6 U& O, K+ ?( e2 Z- E& d* i. h$ a+ h$ I" ?7 C7 x
|
|