|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) D' s$ e7 t, q* \+ L
#include <linux/init.h>
0 X( F5 t9 d s7 q8 P, S#include <linux/module.h>- K# {9 G, e. b6 `2 J3 q
#include <linux/kernel.h>
2 D0 |. u# c7 U& L, q- ?2 p* b) ]: k#include <linux/types.h>/ G- A! P W# \7 Y6 f( m+ y; x
#include <linux/gpio.h>- j- i. F2 v3 _$ M! A
#include <linux/leds.h># ]$ F$ k# g* V" e2 n1 `( T
#include <linux/platform_device.h>0 o) t5 L$ T' d+ h$ n
! z/ u3 k# b$ b* N6 r#include <asm/mach-types.h>
7 M( K! L; m. v8 f#include <asm/mach/arch.h>
0 N1 {1 @ ]" l* R, N4 l6 c+ }#include <mach/da8xx.h>, n9 y. V6 b: P! X7 u* n; O
#include <mach/mux.h>
9 N; @" z& V8 @% {' l8 p
- \; z1 O7 `+ x( \+ v5 S#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( F$ X q7 `1 B4 u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 l1 x6 T( x w1 L5 `& m1 x
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% C: k: n6 ?, l& S#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! ^% m3 g3 b+ V) K- T
- p- a; F. M2 t2 |/ u! p
/* assign the tl som board LED-GPIOs*/8 n5 @. g( J* b$ j" w
static const short da850_evm_tl_user_led_pins[] = {+ z. U; @" j" ~8 H1 Z
/* These pins are definition at <mach/mux.h> file */
* M" _3 C, Y; F: j) J) B DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 c; \# s" N6 c! k9 ?. D$ W
-1
( E, c, V( ~ X$ c, m};
- {' |: x) f& c( s$ g2 H
8 s& e6 V9 e; `: X) a7 ostatic struct gpio_led da850_evm_tl_leds[] = {
5 K. J+ V* e, k3 I* B# ^8 ^ {
, G2 V7 \; g$ O. E .active_low = 0,- Z `* W( V# K! e
.gpio = DA850_USER_LED0,. P3 I9 m, N; u+ ~/ ]7 L* E) R3 E
.name = "user_led0",+ C+ k' r0 b0 r4 `' U" \
.default_trigger = "default-on",: ?4 S9 }) C9 ^
},( S' ?8 b% y0 K0 W
{: g5 j: f* b$ N6 Z' @- j3 v
.active_low = 0,3 F$ \6 Z2 u- Q; y
.gpio = DA850_USER_LED1,
' ] A7 ~- w5 \2 z' K .name = "user_led1",9 u$ H3 s6 E. m5 t+ a
.default_trigger = "default-on",. B, N2 S- ]( G( T
}," s; Z: [- j4 @& q; k R
{
2 n. U9 A. c3 E3 P- z9 ]4 D .active_low = 0,
9 \" I5 Z" o! K4 y. N2 | .gpio = DA850_USER_LED2,
. M* ]" x5 w0 _' k4 [; c .name = "user_led2",
: d: v, u5 `- u2 j) h2 I .default_trigger = "default-on",
) r/ M" {& V0 h% r* G6 o9 r4 O# i },
9 u4 ?1 ?+ J8 }, G8 u( N2 J {/ X' K; B+ f2 ^: ?% I0 Y* c4 w" x
.active_low = 0,
# ]& L7 ], x2 h7 b .gpio = DA850_USER_LED3,) _' M y- n) D8 o7 `
.name = "user_led3",
7 @: W! ?; f: p .default_trigger = "default-on",
/ J7 \, w+ s% k1 o },7 K" h8 e- J# n% T# E
};
1 ]7 w: T% g- m& M1 _/ o. i
0 Y9 w: g3 N* k5 R$ |: O9 Z+ ?static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* p* X6 u* Q- q+ r( s w. j% y# m* C .leds = da850_evm_tl_leds,
2 Z, E, T" I; o2 i9 T- x5 a# T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 o; E; Z' A) B2 n
};
0 v+ k2 Y' `+ G+ u9 S- t( f
2 U# e( P$ B/ l- I) t/ s+ v& Istatic void led_dev_release(struct device *dev)( {4 N) E; D8 i5 \+ q- P: u |
{
" h; u! \) z+ W7 b};" x+ F A/ O& E! y R0 q' z% Q
8 k4 {* k% ?$ Sstatic struct platform_device da850_evm_tl_leds_device = {
* p1 w2 T {( y# E* \ .name = "leds-gpio",, H- k/ ?8 g; R% @7 x
.id = 1,1 \6 x. y# b, J: \ y: |( Z1 N6 \
.dev = {
# G" o( t( _- [' X9 P( k9 Z$ N. } .platform_data = &da850_evm_tl_leds_pdata,
4 [6 `# e; J" J" h* R N .release = led_dev_release,
2 N! f n8 _, K1 L5 E+ c }
; p; l/ }" h: ^8 `! H}; t ?; `, x9 U" F( w# ]
2 Y0 ^* E3 Q. q5 z; _0 L9 c/ w: pstatic int __init led_platform_init(void)7 q) Q$ }: u4 k. Q9 a0 Q: L
{
1 { g) r) d9 _2 \1 q- Q: [ int ret;0 i% E5 b& _1 H a
#if 0
1 F& ?6 P1 f' ~( z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, q7 v3 N' T6 M( T6 Y) L if (ret)9 C& s0 U+ w5 k/ i- m7 j2 @! L
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 B0 \0 l# g) g0 Q
"%d\n", ret);( k. ?+ w1 E1 Y1 u- s# p; `
#endif9 H' @! v! M1 N
ret = platform_device_register(&da850_evm_tl_leds_device);$ o8 V/ G3 H3 U$ }
if (ret)
1 c8 W( G! @' u; O* G& m pr_warning("Could not register som GPIO expander LEDS");" S0 q- S! T1 A" Z# O
else. p8 R4 ^' Y J2 c' U$ d/ J. N0 h
printk(KERN_INFO "LED register sucessful!\n");
6 r1 O7 N$ x0 \6 b# k! R% n9 e! j1 f I5 Z2 i7 f l# G9 q0 X& h
return ret;2 i# b1 T# Y7 m
}; G' C! `3 d3 X( |* Q( B$ r
% u- D: J8 B3 b4 P1 A6 ^- \" J
static void __exit led_platform_exit(void)
$ U9 a8 p4 L/ Z) q! y- K" Q{6 B9 Q6 T, U. Q1 [+ ]) F
platform_device_unregister(&da850_evm_tl_leds_device);# q3 I1 q( y3 N5 o
; K; L0 O$ H% w$ e o' m. K" I( o printk(KERN_INFO "LED unregister!\n");
[3 Y4 i w* q+ p}) V# ^* P: U/ w
1 @# v7 K& N# t: h8 b, L1 bmodule_init(led_platform_init);
# m* X5 n9 p+ g, d+ Kmodule_exit(led_platform_exit);
7 E/ T9 f" y, V! r! p z
* J7 r2 Z; D) Q+ i7 nMODULE_DESCRIPTION("Led platform driver");) R( y$ W/ H [
MODULE_AUTHOR("Tronlong");" ~$ |3 V+ n0 j" W1 {7 r
MODULE_LICENSE("GPL");
1 {; Q. t$ r2 W3 A, z7 \
' x- O9 W6 e7 d9 s |
|