|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! Q4 M. w5 S1 `2 \* j/ \3 P
#include <linux/init.h>
0 |- u, l' [' U2 t5 }' V8 [. c#include <linux/module.h>
0 K8 n& Q4 l% }" Z1 c1 s. f0 L#include <linux/kernel.h>
" m9 U' m" o% n9 V- a7 T#include <linux/types.h>
6 S8 x' m5 k6 f* g6 F#include <linux/gpio.h>
U. H- |1 {# u* x) J: M# |6 D; t#include <linux/leds.h>" k) u# ?' N# f' }0 z
#include <linux/platform_device.h>
/ z, O% d, ^2 } i3 M9 B
8 c0 x. C1 l: r, i4 N! F- ]#include <asm/mach-types.h>- Z" I9 d5 B9 f" b8 O
#include <asm/mach/arch.h>
4 y4 G9 q8 u0 g2 d#include <mach/da8xx.h>7 h. @6 R' q) ]# C
#include <mach/mux.h>
. d' E$ w- B$ p# j& E+ f# m0 p0 B3 B8 r. o, z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' f& x6 j. u' t$ _0 K) ~; u% F/ N
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* Z n- r4 R$ ]: \8 {* [1 Q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 ^: J" [5 y- z$ ` F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& ^3 N! d1 x* L7 ?3 M/ u7 x2 q# ?, |6 Y% h
/* assign the tl som board LED-GPIOs*/9 a4 C2 w+ w7 {% G* Q6 D
static const short da850_evm_tl_user_led_pins[] = {2 t" m0 K" V2 h
/* These pins are definition at <mach/mux.h> file */ f# ]0 F+ u% A' `
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# a3 f: y; F& {& g# v7 }
-1
+ `% x J" k o, V; z y7 H$ p};
$ O% n/ R/ ?! r2 r/ a
/ a9 r/ I# B6 ?' R9 rstatic struct gpio_led da850_evm_tl_leds[] = {
`( v( _& v: U4 O( g; D" I( M {# J2 m8 n; c+ q; L% K: s0 C
.active_low = 0,
$ K+ c: O" a& d& n5 ~/ A! K .gpio = DA850_USER_LED0,
' d- u; J- |& R) b .name = "user_led0",
/ i2 a; @' C1 Y0 a/ T .default_trigger = "default-on",% y: S' u2 C! F4 H7 }7 i+ z
},
2 }: K1 D" H- n" k {
o5 P- `( K' e6 r, B: ~' i$ V .active_low = 0,7 S+ {. L+ n. d5 p
.gpio = DA850_USER_LED1,
# h# O6 |# i( G4 S+ f- m- y .name = "user_led1",
- X2 y0 ^* |6 L- J, C% @: ? .default_trigger = "default-on",
& A, P* Q: a3 d; H2 w1 ~4 f0 X },
2 [+ h0 u' _" w {! w$ m8 T% T. D' P/ d! s
.active_low = 0,
) N& |0 r. ?% M, d, r. q$ p .gpio = DA850_USER_LED2,
; K% d5 j# q1 B7 h! k .name = "user_led2",
( U+ `7 J A* E# B, k1 v7 ^6 c) ] .default_trigger = "default-on",. [* Q; p) J# W7 Q; y# [+ M
},
1 o5 b% B, ^4 W* t/ I8 j {. o' ~% J. a1 B( C6 k/ X& \& j
.active_low = 0,
4 `5 ?) V) } n$ U6 M .gpio = DA850_USER_LED3,3 t" u: U4 x1 |' f2 |7 R
.name = "user_led3",& ^+ Z" I: W( @; o
.default_trigger = "default-on",
' x1 i# A+ _/ g! i) [" [$ ]$ |0 ?; F },
& J3 {4 ?) @8 s" p, @4 f: f};
. l s6 L& V0 f- e% G; C
1 ]1 V3 z6 r; m* ]+ y4 vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 [* O! g1 S7 P' _ w0 B' W* @$ `
.leds = da850_evm_tl_leds,1 ]& ~. Y( B' E- r1 ?: J
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; C6 c" U7 S( r* ]8 F$ V9 ]
};
: O% D3 \ R8 m0 m
( Z ]9 U! S( D! M: R$ C+ ostatic void led_dev_release(struct device *dev)$ a- l' [1 E, N; s' N
{
" c7 W2 D7 x# M( u' f7 Y};
( F r8 A6 c) v+ `) ^5 h
2 m7 q! y3 e5 F+ C! m+ Ustatic struct platform_device da850_evm_tl_leds_device = {
z. |3 d! B" g0 z7 V6 h6 m2 ~ .name = "leds-gpio",
. V% A9 j! u6 K .id = 1,7 P' U4 Y+ [) Y+ Y. x* j# p z
.dev = {0 u. `7 U- z" `3 I- v N
.platform_data = &da850_evm_tl_leds_pdata,; u, m6 U) z7 h# V
.release = led_dev_release,+ w; C p" t7 Q. @# L' y
}- a' L) }( K ~9 t( [ ~! c
};0 y/ `& e+ N- r
( j9 ^1 H* C6 ]6 {
static int __init led_platform_init(void)
! J6 k/ a$ v+ k1 _7 Q& W{
' a4 _! h6 o0 W( M( O X. ^ int ret;
5 q5 E' \! e: s0 d#if 0
8 Q) \* I- |; Z: f- b3 Y, w ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# _( B5 x2 R9 ?& M4 Y if (ret)" \5 |5 x7 n+ I: x3 {( `! `
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( }5 O' ^0 Q3 B S4 T "%d\n", ret);: r0 ?5 D$ }6 V. X
#endif
V" d) a% r) B0 J3 g/ y8 [6 k ret = platform_device_register(&da850_evm_tl_leds_device);, y M5 d* l: K& N- A1 e
if (ret)
* W; a. u' v8 I9 X9 C7 g pr_warning("Could not register som GPIO expander LEDS");1 G- a) s! e, |& Y' Y& x) }6 o
else, w7 U5 V4 w1 {. F$ b, x) G
printk(KERN_INFO "LED register sucessful!\n"); @" K) @! Y* k1 B' Z0 B. x7 \
* u# u& ~0 Z3 ?5 a
return ret;5 ~3 R: L! M. _6 Q' [8 A
}
" A i7 W4 w# W2 A- B1 k' v
C( k/ d' G4 y, X: f8 F( C- j6 a' Mstatic void __exit led_platform_exit(void)
& s" ~2 L! Z+ {! h{0 v, S' }* a; B2 S. O/ o; i
platform_device_unregister(&da850_evm_tl_leds_device);" h# I+ Y4 X# `0 \
/ G' |6 N+ ]( @! o& G. ^. u
printk(KERN_INFO "LED unregister!\n");9 B; F$ U) X0 T: h: T! T. A
}
! b: Y5 p4 ^1 \0 h- ]* V
/ _; T R: M7 cmodule_init(led_platform_init);
8 z4 v, W$ T4 m& O4 Emodule_exit(led_platform_exit);. X+ x8 a; X# X; o
' q" }3 s& D! |* {1 d: {/ T, Q9 NMODULE_DESCRIPTION("Led platform driver");
+ q% u5 S! U+ ]) ]2 L* u3 @MODULE_AUTHOR("Tronlong");- Q0 \' i9 k$ h- l! v
MODULE_LICENSE("GPL");
0 {5 O9 z6 |. F3 E4 J2 C
' z0 s p; F: M& z |
|