|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 b8 K9 u; w+ Z2 Q7 |6 w# f/ J; [#include <linux/init.h>* N( m% @! n8 l" n4 X f& H
#include <linux/module.h>6 a0 D2 J h4 m, I3 F$ E
#include <linux/kernel.h>; A7 s3 O' U+ D4 }% ^/ m8 y
#include <linux/types.h>
/ \) N0 w' ^9 z- _#include <linux/gpio.h>9 U. y7 j3 X+ `# o/ O
#include <linux/leds.h>6 Q! \ Q* r# x: r- v; @
#include <linux/platform_device.h>
3 @# \/ `6 T, ` v# ^
K5 F* O+ w9 u#include <asm/mach-types.h>( B4 Z0 M* O8 m, @$ \
#include <asm/mach/arch.h># B5 V9 X) o6 V& d
#include <mach/da8xx.h>
# Q6 a, }0 T3 W3 s! ~#include <mach/mux.h>
3 i. C, X. d7 `0 D1 \+ `$ f, W2 X$ {0 X0 z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 [8 p _, a; Z$ d. _& n& D
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 c1 u0 ~% q7 T6 S( G4 a' p
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- s3 s+ l6 t) n
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& u/ t, K- v/ ?
2 A' o+ C" m- k/ j/* assign the tl som board LED-GPIOs*/: H# G9 V) x! W; Y
static const short da850_evm_tl_user_led_pins[] = {
. }. z- i. o3 U /* These pins are definition at <mach/mux.h> file */
2 D. [) ?/ D5 _ ^# K2 a: l) m DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ }* F- u0 {5 r* x, _
-1, ~& y* q) D* n5 d9 Y! I; t9 j
};
- @& x) ?6 X2 D" r9 U0 O2 D
! \- h5 _- ^) h/ Istatic struct gpio_led da850_evm_tl_leds[] = {
U; V; M( b' J. r9 r8 J {
7 o2 j; P1 f+ ^/ B( V) @ .active_low = 0,. Y) G4 d7 j2 g/ L8 p' G
.gpio = DA850_USER_LED0,
0 V0 T7 A; e% J& D2 Z& g .name = "user_led0",
- l' i/ p8 C2 o6 Y .default_trigger = "default-on",& m' ? p; N9 }
},
0 k8 c; J" T3 c7 e# F# S% Y$ H* ~ {
0 x! |6 {9 K9 Z4 R( O- t .active_low = 0,
/ L6 H& N% @6 I8 m9 t .gpio = DA850_USER_LED1,8 _8 A( ^3 T% ~& A. ?( E9 {- {
.name = "user_led1",& y, h! C. z5 v. U. S1 a1 }& V6 `
.default_trigger = "default-on",
+ u2 p2 b7 [' v/ L },
: V5 h4 n9 c- A, x {7 S6 J2 v4 j( Y A1 T
.active_low = 0,
3 f) k7 k1 h: M. f$ | .gpio = DA850_USER_LED2,
( S) L. t7 c0 ?* X .name = "user_led2",
8 ]+ o# z* E0 e9 h6 N& }% q .default_trigger = "default-on",6 n- Z& g7 T- `3 Y& E& D+ X$ r
},& q* d% i) g3 s$ @: r( v
{
7 @$ Q: \# _5 K, V2 } .active_low = 0,; \0 c. j. \1 @' E6 X
.gpio = DA850_USER_LED3,# y/ f" A, W$ C4 _
.name = "user_led3",* E9 `0 t; ^9 Z% x, x
.default_trigger = "default-on",% ]+ R4 p: W X# P) ~
},
6 j9 J1 i2 V9 E8 U2 A};
: d( M2 \% z/ M3 ]% L' L- _' e8 N9 n+ y& f# g5 s5 M
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 v) E1 `4 S9 z. V8 d. B
.leds = da850_evm_tl_leds,2 ~: t; \9 h9 c3 s2 Y( R
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 G7 a2 N' v9 j) L, r' H3 P};
. w0 v" n% l) C( f q" i P8 x0 D9 ^
static void led_dev_release(struct device *dev)
, s: ~; e* G0 P, d{
5 C: O& N# H+ J! E G: d7 M& |$ l' M, X};# w0 j1 J% I! L/ E
3 j1 ]% Y7 a- S' G
static struct platform_device da850_evm_tl_leds_device = {+ D+ T, M7 I: A; O1 U" Q1 u
.name = "leds-gpio",! P6 s) q- M+ Y+ [! v. T m
.id = 1,1 Y' Y' G" p6 I R; p
.dev = {
3 W& _' ?* N& v6 x# ?. }, O/ a" T- V .platform_data = &da850_evm_tl_leds_pdata,
$ B6 Q, Z7 M6 P3 \' T9 r' k" y% \( L" O .release = led_dev_release,
! v9 B1 J) A! m7 V9 i. _2 a6 U }
/ I. g) y0 |( O+ ^" N% f7 m};8 u; t Z: J5 E
5 C! j6 Q' L9 Q* C
static int __init led_platform_init(void)
# [5 \, q* z T2 \, U- d9 W{& I. y' {- g+ S3 _3 u2 R; g
int ret;* F9 X3 [5 u9 {( r" @2 E% D7 V
#if 0
9 y+ u3 V9 ]3 v ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& ^6 p7 q0 V4 n7 p
if (ret) z; A8 L9 f" V+ z( [- u# @ K! R& n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- Q8 g0 W# c ] [5 z% P
"%d\n", ret);$ H0 R8 E! L& w, G/ ?
#endif
- Q* L1 B( L4 ^( ?4 q ret = platform_device_register(&da850_evm_tl_leds_device);; l; P% r6 \. s b; s
if (ret)
N: W2 ^! E8 R6 p& M0 `+ z pr_warning("Could not register som GPIO expander LEDS");# w/ z: v; T& b8 q
else
, n( Y3 K5 j$ Y1 W+ ^$ l2 g- F printk(KERN_INFO "LED register sucessful!\n");; y: H x- M& Z0 h
; O a# f3 z0 f9 N4 E, @ return ret;9 `. T# }9 c# N3 _
}
9 A/ l# j5 [: a3 v5 x G8 Q a* `7 K$ N
" y! Y& h5 o5 N. cstatic void __exit led_platform_exit(void)
# t# U0 z# y- C: j0 t' @2 D4 p$ [{
! K$ l" }7 Q- A7 l: z$ |6 @ platform_device_unregister(&da850_evm_tl_leds_device);( T( B1 t+ `% c
8 i' ^, ^# \/ P1 Y printk(KERN_INFO "LED unregister!\n");
: C+ p' A4 P6 H' |; t8 Y}# D U' ^8 }8 d+ \7 e3 ?
& x, \) Q; _: f1 tmodule_init(led_platform_init);
p1 `6 L3 e: ^# p1 bmodule_exit(led_platform_exit);
9 P3 \8 R5 \+ Z- ]4 r& j' A- i5 M' Q q1 l4 y
MODULE_DESCRIPTION("Led platform driver");
% C% j; O' M$ Y3 CMODULE_AUTHOR("Tronlong");
3 n2 Q! a! E* |& H4 }' ~9 Z9 X2 @MODULE_LICENSE("GPL");' T% k1 b/ p4 d! s0 s
! c+ x4 \" ^) @& C8 B n2 J |
|