|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 u! }" y3 J5 r! C0 b9 c% C
#include <linux/init.h>
4 x8 l1 I" k) J' ?! [ r' K! z, o#include <linux/module.h>
& E: w6 |+ _0 f2 ^6 h- ^#include <linux/kernel.h>8 X4 i5 k! v, E+ S
#include <linux/types.h>! r4 J6 V2 [3 O4 ~& v, A+ M
#include <linux/gpio.h>
e; X4 k0 c- J& L# |3 V#include <linux/leds.h>
' N6 }5 ?. u9 f( q#include <linux/platform_device.h>2 T/ }0 a/ N- I/ F# j
8 j3 }4 X3 I3 y6 S#include <asm/mach-types.h>
9 |9 \- y3 c0 X( o6 z2 E' _#include <asm/mach/arch.h>* ^& P+ {" g0 W( P6 K s
#include <mach/da8xx.h>
8 Y0 x; {7 n; W Y+ U$ @#include <mach/mux.h>
! q4 _' V: N7 z' n0 n$ y3 W
+ v, l7 r% [$ A; B' e#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 p( @! D2 K% q) L0 t#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% V; b3 l4 c/ s+ d* Q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 C v1 E: d& U9 C, j#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ V6 ?- o1 _3 {/ @) o( E& ^
5 p! c. R; q5 P2 x1 Z
/* assign the tl som board LED-GPIOs*/
! Z2 l( v- @7 E7 Kstatic const short da850_evm_tl_user_led_pins[] = {( B- K: `$ w. u5 N, r) J9 h
/* These pins are definition at <mach/mux.h> file */
, ~) n5 z4 ?* y$ {8 l DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 V% q% Y! i5 D/ J: P2 D
-18 [: z1 ]# o( M+ z4 W# w! g
};3 p0 }# ~8 w# ^/ K8 m4 \
9 Q, b4 } _# r& ^ @' f
static struct gpio_led da850_evm_tl_leds[] = {5 {7 V% B; I2 }1 P
{3 q9 ], s7 i T# s6 O
.active_low = 0,
2 `& U4 E. e k1 w# ?7 [/ B .gpio = DA850_USER_LED0,2 j3 ~9 d7 ~8 ^/ ]( w+ A
.name = "user_led0", }. ~' w" j( a
.default_trigger = "default-on",
3 h2 r; ?# j) N% b0 Y },
, z, Y1 R; C+ f" I, K, Y4 l {, g' U# p Q# ?9 N+ e9 Y4 N1 J
.active_low = 0,6 H* ~4 _' h, Y4 I7 U( [0 V
.gpio = DA850_USER_LED1,
9 Z7 @5 }8 t0 \) B/ \ .name = "user_led1",# o$ _/ M p; I' k- l
.default_trigger = "default-on",
; n& ^2 ?! v: n- m/ M! A& m8 a },
+ U. u3 X, E7 ?% a, G' T {- d$ Z3 `" b4 Q. C
.active_low = 0,
& {8 V, X! j" c6 p. N2 ], u' @ .gpio = DA850_USER_LED2,
6 y: c6 g" H- p1 G2 X7 [% H% e& p, v .name = "user_led2",
+ D! \: K# U+ m- q0 t* V .default_trigger = "default-on",
$ W) L @2 B% D# Y7 ~ },
+ ]/ v* W0 v( W. x. O1 t# a {
( {/ C! v7 | q) x# C .active_low = 0,% O8 N* H8 G( V2 j8 O
.gpio = DA850_USER_LED3,. g. ?- ~9 A3 b- t0 s* ]3 c0 M
.name = "user_led3",
% ` r& M! m9 D' f% q" {5 _ .default_trigger = "default-on",
: J9 x/ @3 R* p. a- V( Z( U },- Y- j7 y& A" M% E5 [9 C7 H+ W
};8 Y$ l+ `% t% r
' g E- K" X' s: Q& H! u9 }) j3 M8 Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 t& z2 I- Z0 I% d .leds = da850_evm_tl_leds,
3 O: K$ o! A O7 ~$ a .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 P/ h: ^5 P; g9 Z/ x# G};
) b1 F9 H6 \4 P
. U O- M/ w! Sstatic void led_dev_release(struct device *dev)
" C' @% t, }# ^' W- R+ s{
}% e: D' c- R7 V' [};1 r5 Z( {8 i" x" {. B* X; z E
- p, b: c5 H4 o# s* kstatic struct platform_device da850_evm_tl_leds_device = {
, R- a; B3 V+ l9 ] .name = "leds-gpio",& {0 m% ^- o- d/ \7 s5 o6 P
.id = 1,
5 m7 e9 F3 p- b .dev = {) B, h* c M/ [3 F8 A
.platform_data = &da850_evm_tl_leds_pdata, |# ` M3 O6 k3 ^% c& x
.release = led_dev_release,8 z/ K' n4 u- ^9 O* G# E7 C
}# }/ B$ S+ T8 Q
};
" S% v8 g) q! M8 A1 L4 M' v
; [1 c/ K6 {' a/ P" m- qstatic int __init led_platform_init(void)* e9 b* a( s4 N% E0 q" w
{1 I% ?% f) _/ N7 l0 p3 V
int ret;9 Y" N t2 w* Z, g' J: c
#if 0" I e: j$ t+ `# e
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ N' P2 q& u+ P; C+ r) y if (ret). I# V2 e' w2 Q) b) L9 y& y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) n! B/ e) R: f% s& S* Q "%d\n", ret);7 f4 I& c" y. b$ G" l3 s
#endif5 d& f5 ?7 o" _
ret = platform_device_register(&da850_evm_tl_leds_device);* j1 O8 E' r- [9 N
if (ret). C7 g" T$ R9 r6 {4 i6 d! s( ]
pr_warning("Could not register som GPIO expander LEDS");# J' Z; I/ f$ Q T$ k) U4 O. |- O9 V! q
else% n& ] n4 u6 L5 {$ G% U
printk(KERN_INFO "LED register sucessful!\n");
* ` @2 }3 o" o) h7 x) ~& {: f) ?; ]: P
% n& P, }- l. r8 T8 c& A return ret;+ r! d! G$ J7 C9 e- ~) b
}. D% E. V4 F, j4 s
; l9 \3 z% Z2 w: Ostatic void __exit led_platform_exit(void)2 l$ f( ?8 h, H2 y3 `1 q
{
. v- P1 f$ N* @2 Z2 ?; q/ X6 p6 p3 Q platform_device_unregister(&da850_evm_tl_leds_device);6 o$ r: \9 T4 X' \
( w8 x) J1 a( \5 U" { } printk(KERN_INFO "LED unregister!\n");
! V% p3 l. M( e# N! o; e}
! F7 y3 I: u( f/ S H
( Z- [: N2 U8 s5 Mmodule_init(led_platform_init);0 Z( |0 \ [* o5 L' \; M- E
module_exit(led_platform_exit);
# H% j' J. J7 T1 t7 K3 E
1 h0 |2 N5 Y3 z; ~MODULE_DESCRIPTION("Led platform driver");
- j7 t3 }$ t4 qMODULE_AUTHOR("Tronlong");2 s3 Q- [* S1 [2 \) q' I
MODULE_LICENSE("GPL");' V) d' O2 @ R* j% n6 T) B% _
- [. b+ V* r& P" V: _2 {6 w
|
|