|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 }& e+ V! n) ?6 e7 v: e* U' j+ f0 r
#include <linux/init.h>
2 [% m7 [- l" Y, K0 [# t#include <linux/module.h>
1 T! Z/ B4 H7 z, o" R1 b#include <linux/kernel.h>' o: R8 L, L4 Z% M- q% U
#include <linux/types.h>. y# k& [/ z9 x, a
#include <linux/gpio.h>
3 U2 M7 I# `# U5 l6 O, t2 D4 y9 B5 l#include <linux/leds.h>$ U2 r' m8 O! a" Z
#include <linux/platform_device.h>+ G: S+ h, {9 x8 N' i- r( `
7 L7 d, [ ~; A) `% u
#include <asm/mach-types.h>
: c% T2 \6 {( o2 }2 s( [! F#include <asm/mach/arch.h>. Y J, A" }1 g9 V. f( P
#include <mach/da8xx.h>
1 T. l$ |( J% k, Y; l#include <mach/mux.h>
$ O0 K" i* Y: h) p/ X3 H% ]1 L& ~2 Q' `! G1 k1 N- e7 Q' |2 o ]
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 v! X" q! X% B# I. J8 X2 b {
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% k! W! h7 F7 L" d/ h6 H/ k8 P+ U5 F
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: \8 U) {2 K( @- u* j#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% P' o% g9 P( C/ }
7 e8 R, Y) L' Q) D- h/* assign the tl som board LED-GPIOs*/
% R" W2 b' u& u, \- a8 j1 R- xstatic const short da850_evm_tl_user_led_pins[] = {
- K9 y$ I& p( ?5 S0 n/ C X" o, ^- j /* These pins are definition at <mach/mux.h> file */! H7 P: K* d; d* G( g; {
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 T6 \$ q g- M -11 I! ]$ J8 G; H3 F5 Y
};
- R- Q5 t* ~/ b$ ^
( k$ A' H8 K! }; Tstatic struct gpio_led da850_evm_tl_leds[] = {2 {9 E- ?* H& T) S. ]
{: z, F O& W, F+ W% I
.active_low = 0,/ U5 Z I- L! O' J) z, B4 ^
.gpio = DA850_USER_LED0,. r: `2 _* }- M& Z ]( E
.name = "user_led0",
! N8 {6 U5 t6 A .default_trigger = "default-on",- [- p0 ?% R8 H' E# c+ j! D8 y! j8 b! @
}, c" P; S$ r! g- x
{
+ Y+ O7 j: P0 ~: H' q+ V* W .active_low = 0,
1 K9 w) T$ |# Z& {. I .gpio = DA850_USER_LED1,- j0 v; D2 A V1 O5 \) j1 H$ l
.name = "user_led1",
: d/ V5 k5 h2 n. T( Q' P! g# Y .default_trigger = "default-on",6 c4 G+ x" R3 U7 i) J( C, a. }
},
- B0 J7 V4 C" i0 { {2 \: E- i# A; L* d! k4 T4 n
.active_low = 0," a% e: d* t: \+ c- |
.gpio = DA850_USER_LED2,
& U' l8 _& ?' f' ~6 o .name = "user_led2",
" \$ G L' x$ A9 S x; Q; z& m .default_trigger = "default-on",
) O# ?& L0 F3 ?5 k8 ] },) }6 I7 U) R) T
{
" ~5 M% F: o' C7 j .active_low = 0,
( `8 A: A/ M' y .gpio = DA850_USER_LED3," K4 d1 ?: V8 S# ~' q
.name = "user_led3",1 l5 G4 Z5 I& g3 B
.default_trigger = "default-on",: c) v2 l) j* j+ H& Y s
},9 k) |8 y& U$ [
};
' g/ J$ Z, S( w9 p3 M
Q( v% ^7 y. w( Nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' B: a* T& E. V
.leds = da850_evm_tl_leds,6 h) \1 G9 T; i! q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% R1 w# x& n, M3 n4 k! @' G; s};+ n( g/ d, E8 S6 V/ T( |
) }/ s" }) t) B8 V/ w) I) s
static void led_dev_release(struct device *dev)
2 n4 O7 h5 ~+ E b& e: E U- ]) L L{ j- K. \+ X* [- s
};
; b) M$ ?% m, w/ ~
: J4 M& T# i( ?. n, n2 G8 `) [/ lstatic struct platform_device da850_evm_tl_leds_device = {: M$ c2 S7 R3 C: {: C
.name = "leds-gpio",+ J- _+ h. B N
.id = 1,% g4 @: S! ]$ W/ P) x
.dev = {
# Q7 g6 ~( o# ]/ [. @ .platform_data = &da850_evm_tl_leds_pdata,
. l+ g! ?" h4 o& \1 A .release = led_dev_release,
# q& x! Y# C5 w2 \5 v }
$ |" ]; ~3 Y# o% Z};& x9 J5 p8 o& w* N, i
( |+ L9 |) F: f. M/ f& Wstatic int __init led_platform_init(void)
& X$ r$ ]" G2 `{) D( C* V9 B: L
int ret;
Y! A, h; d2 p' Z1 k#if 0
5 X5 F9 S8 ?1 H$ h- d f9 V ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 {! G; h9 E) s! U' {+ ]/ a if (ret)
: m- \! ]2 ^( @) m" l$ t5 `6 i pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, R& B! u6 V) t( W; E "%d\n", ret);
9 j, |) w2 Q' q/ }#endif; m- ^3 b O) x& ~- r" D0 v
ret = platform_device_register(&da850_evm_tl_leds_device);
. u) R* e6 u6 F. J if (ret)
: Z7 B$ W- Z* v pr_warning("Could not register som GPIO expander LEDS");1 M C' {7 N; g3 F% \. U4 I
else
2 o$ a8 I' K$ \* X0 @* y1 e, O printk(KERN_INFO "LED register sucessful!\n");
# m* ~% G0 [7 `# M4 ^2 Y) |& ` M5 c1 z9 [3 W" u0 S' x: H9 p! w
return ret;
. b5 p7 ]1 K1 K Q% f0 `+ a, r0 c, ]}
2 v8 c% @- ?! n2 }/ D
& Y8 T- V+ s* \static void __exit led_platform_exit(void)7 ?+ } c9 {" w
{& i) K- A" ~, u
platform_device_unregister(&da850_evm_tl_leds_device);7 M6 ~9 I8 K0 x- N2 |, Y. p! M( J8 r# A
1 o a5 z+ h1 I5 @; K h$ a
printk(KERN_INFO "LED unregister!\n");5 T0 q+ ]$ c0 Y& F
}. p2 v ]6 G c$ L" [
8 |* }% I+ I/ b( T0 r# Bmodule_init(led_platform_init);2 Q8 a8 ?! Y. d
module_exit(led_platform_exit);' ~& Y8 m3 s: v# ~0 Q$ G" l6 v" O" U3 }
6 A9 Q2 N5 W% a0 k. I: vMODULE_DESCRIPTION("Led platform driver");
. ~. v! {7 V( FMODULE_AUTHOR("Tronlong");" Q$ f7 Z; d" ? f# t
MODULE_LICENSE("GPL");: d6 }2 X+ o+ ^' j/ I9 h9 l
) v8 I' c. Y+ N4 m9 `- H+ L/ ~ L |
|