|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 k z% c: x+ t9 }5 k! ~8 j& l
#include <linux/init.h>
( w9 ]. s' D \: m4 E% A5 x( V#include <linux/module.h>
; U* x+ h; d$ V2 G0 J9 B, M#include <linux/kernel.h>
: X* h* B" i5 p* \0 B, O2 T#include <linux/types.h>, N6 W) n2 D; E7 d% E7 M
#include <linux/gpio.h>4 j' m! k$ [8 q9 `9 @
#include <linux/leds.h>
9 X# T4 ?6 r; g& o: k V' A& U#include <linux/platform_device.h>
) R( j5 F" O4 O9 M m$ a+ u
8 M" [( @8 E, b$ C) @; ]: t9 f7 D' _#include <asm/mach-types.h>
P. Q6 E$ Q$ `#include <asm/mach/arch.h>0 R+ G1 e3 K' X8 E$ c9 Q+ m2 _
#include <mach/da8xx.h> F5 U: D4 U5 [
#include <mach/mux.h>2 ^+ _ E" ~& t3 L
Z3 g$ Z/ B' W1 J( l6 m) R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! s2 ?8 u/ T1 P8 F$ n' J. u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 W4 W) y) ]! V' q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% v9 r2 Y% `: r/ a- N#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ Z4 X( g! R# u# l* v& r
I% {: j( d& a8 C
/* assign the tl som board LED-GPIOs*/4 L" M1 n' ^5 `- j
static const short da850_evm_tl_user_led_pins[] = {* h, u: f" P. D, k+ Z& [ d
/* These pins are definition at <mach/mux.h> file */2 c2 h( x/ |& `, s* C
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ |4 _1 c9 |( {$ N -1
+ x' _* Y9 w q' m! c};$ k! S9 T) X# q1 `9 g
' C5 N* a! ~' N* ~8 F) m( h7 Estatic struct gpio_led da850_evm_tl_leds[] = {
4 e1 `9 w5 S+ \% c: `* V6 a! m {) T% G* J$ J, i+ N
.active_low = 0,
2 h! s# v+ Z' { .gpio = DA850_USER_LED0,
; \5 B l6 J3 P; B, w .name = "user_led0",, l7 A) G* A& Q H4 s
.default_trigger = "default-on",
# e) B2 a7 @* n6 q" |+ W },
5 |& ^2 c# m" s {
- ~ N# ] v S% o .active_low = 0,
" E* j* w o! N) S2 Z1 u: w .gpio = DA850_USER_LED1,- T+ D3 p2 s* h( c
.name = "user_led1",
" s4 j) ] P+ _ .default_trigger = "default-on",# l0 V. M- \* C* f
},& G9 k* n+ @; t: [$ H* t9 |# b
{2 S3 ^; L, V& O) a2 v
.active_low = 0,, F3 F6 x7 h8 t$ y# H6 F
.gpio = DA850_USER_LED2,, x9 n* \0 d2 U
.name = "user_led2",
2 n( ?0 o4 l# ?( B' i5 Z1 ` .default_trigger = "default-on", Z/ H" \# f* W8 [- R) N
},+ G* `/ _- u' d' R$ J9 G
{; a% t7 u; S* f. L T
.active_low = 0,
5 n9 s5 W# ^) B, g1 o .gpio = DA850_USER_LED3,
/ x* r* ?& h4 E& } .name = "user_led3", f1 Z# j8 Y+ W/ v
.default_trigger = "default-on",
" U5 m& z5 ^( D* R- [0 y },
6 T2 K: A9 m% l8 B};
! q7 v4 k& i3 L5 B( L2 i0 n: O0 Q& b% \; V0 m
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: K: \& F/ y h8 F" D- M
.leds = da850_evm_tl_leds,
$ O" m7 C1 P9 {- k .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 o. R! L- D6 |; A, h4 q! q( e};
! s0 n% c7 f) U) l- I
0 Q, E0 o" N$ vstatic void led_dev_release(struct device *dev)
# k# x; N0 U- Y" T# v( {{) O' w$ C; s- {6 A
};
3 a. |. Q# }' B* Z3 s" o I$ G5 S% Z( {+ P5 f6 C6 ?2 ^( t
static struct platform_device da850_evm_tl_leds_device = {
; s+ ~ o/ P; \8 ?: l" S& e& k .name = "leds-gpio",. \0 s' a. T; V& b
.id = 1,# }% t/ K4 A# u2 @) R
.dev = {9 Q) H6 X4 z- G3 `, ^
.platform_data = &da850_evm_tl_leds_pdata,- q/ e4 |: v, P; A
.release = led_dev_release,& J- p2 b2 f' r! H1 ]
}" a* {4 S) Z6 R* k8 F
}; X" B1 L/ Q) N: s6 S
1 U+ b$ T7 n( R
static int __init led_platform_init(void)3 m# M+ I. p/ E! ^
{% c3 R- P! W( a: [* T# Y( S
int ret;
$ J/ J7 N: U! N! ?8 u#if 0
5 o% N O3 a, ~$ g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, S6 |6 a# I. y" G4 Q& y if (ret)
5 E% O! e( r/ l; W* v pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 m' Y/ C- b' o/ d2 T9 Z9 w7 _ "%d\n", ret);
$ p; C, t2 e9 x4 E. D#endif% ^. r! v3 U9 x, O. s I' s7 q
ret = platform_device_register(&da850_evm_tl_leds_device);3 L. y! R a& m% q3 K5 W a
if (ret)
* ~' n; h f$ [3 ~5 H$ e( b# ? pr_warning("Could not register som GPIO expander LEDS");
. x& n1 b. ]7 p/ J else
; }# Z9 I, R* O- w) M printk(KERN_INFO "LED register sucessful!\n");
; t; ~: X, z7 Z; C7 W( z
0 G: F9 k: D1 v/ [# W# ~ return ret;
4 X3 y4 y) _1 @6 }5 }}
1 |0 L! _" F! A# D C3 m# g7 S/ ~' P1 F2 ^
static void __exit led_platform_exit(void)$ Z1 k: j; |6 j; b( _. v
{0 e& |! P5 V5 _
platform_device_unregister(&da850_evm_tl_leds_device);
2 T5 Z0 I ~8 g# s+ V
% [# w2 s; ?$ F( t printk(KERN_INFO "LED unregister!\n");2 f* M. z7 T+ g$ }
}+ C1 @$ p& Q: F) m! e
5 s) i( O! \ s% [% o2 R
module_init(led_platform_init);- z7 t+ z( z$ c* ~& `7 E0 G; x3 \
module_exit(led_platform_exit);
! O* q, \; V. ^. O3 D2 n/ _# r% O1 O; \* C7 T9 ~& Q1 B! w
MODULE_DESCRIPTION("Led platform driver");
0 ?) Z5 b4 }9 J+ e& @MODULE_AUTHOR("Tronlong");
- ~0 W' |( V% {- @; `2 B9 G; T# S! fMODULE_LICENSE("GPL");
* E/ r2 F3 C, X8 n7 _. W; G: L, s; Q7 k/ B- P3 c
|
|