|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. N, `" O: b, W& _
#include <linux/init.h>$ v# J5 e: T- u* m& l9 c9 K
#include <linux/module.h>
- X- B: W7 F" M6 l/ Q#include <linux/kernel.h>
1 U8 p/ P! b' a1 F9 T#include <linux/types.h>
+ {) f: s2 [* S$ }#include <linux/gpio.h>+ b, u5 ~ s; e$ _. I0 w9 L
#include <linux/leds.h>
, {6 T0 B" \* P l7 h#include <linux/platform_device.h>, l1 V0 [' |* I) Q, a" v6 U. B ^
6 g( k ~ S3 d/ C1 q
#include <asm/mach-types.h>
2 q9 o8 @. B! D2 n* {; c0 u, B0 e: l, P- x#include <asm/mach/arch.h>& c) e3 c: f4 s* ~2 h# [
#include <mach/da8xx.h>
/ j6 t9 R5 Y! p+ p" h. e5 E#include <mach/mux.h>. ?3 Q) f5 g& f' ^% g: L6 h
% y T. k1 w1 S
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): R. B8 z- T9 b p; h/ Y- k
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# k* m8 r8 F4 Y3 l; x" r#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, C4 z- a3 ]- p1 r y4 I0 E#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) L' _! [3 P2 o5 S) g! B- ]
5 n5 O& t9 F3 k5 j5 n/* assign the tl som board LED-GPIOs*/
) B5 e# W2 L# o) {& Hstatic const short da850_evm_tl_user_led_pins[] = {4 B. s, n; r/ e
/* These pins are definition at <mach/mux.h> file */
; P5 Y# D [" Y$ O; v DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 j9 l# U& o7 x, o -10 ^. p4 X" V/ f( `( y8 p# p* W
};3 H7 L; W0 S- N: R5 N6 b1 V
" F' P8 M8 _* ~0 t, vstatic struct gpio_led da850_evm_tl_leds[] = {
7 p A5 J$ V) L9 ^2 L( w% P {
! M: H1 W! d% ?; q: k5 s- l9 U .active_low = 0,
+ ^( ~. |$ U0 Q. |& { .gpio = DA850_USER_LED0,
' D$ h8 v4 i: Z4 C: S .name = "user_led0",+ a/ _0 c. x# u
.default_trigger = "default-on",. M D) c) E* e& x" O# f
},7 D% }* V8 g/ i. k, I2 l
{' n( f0 {* {* A
.active_low = 0,
' o7 d/ F a& V .gpio = DA850_USER_LED1,
0 K- ?: v* o" I% q6 {6 ` .name = "user_led1",
# t3 a3 T) p5 a, f0 w .default_trigger = "default-on",5 B9 |. n$ G- P; k T1 K
},
& q/ ~, E# T% w {2 T) r: F1 G4 A4 u' s+ ~0 d
.active_low = 0,' E1 ~" s1 j: J
.gpio = DA850_USER_LED2,
$ j0 c6 s! F/ k* T. X. W .name = "user_led2",/ n! Z( s6 n1 a( {, v" q
.default_trigger = "default-on",6 c& E+ C* J" P1 [
},2 m, M# q; q7 [# A
{
5 ~, `5 Z* n4 o0 K! r .active_low = 0,: w9 q% `3 G( \9 K9 b1 Q
.gpio = DA850_USER_LED3,
6 ]3 o6 ]6 w1 y3 p .name = "user_led3"," c3 n" B2 l' L5 @! _$ c
.default_trigger = "default-on",
# Z+ ]6 s5 G# f% G) q },
4 r1 A! g; i" h};
+ @9 v1 }% R, ^/ _# l, e' i/ Q5 Z) C9 B
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 q v5 h+ E8 C* ^$ I
.leds = da850_evm_tl_leds,
1 O5 m$ }/ A% X; x5 k: ]5 s .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 y( [9 _ b) l};
0 M3 {( o/ D$ `8 g) |6 H/ P7 c* p( U
static void led_dev_release(struct device *dev)) g8 y' w/ v% e- K
{- u7 I9 r% B7 z4 l k
};
" m" I6 X: z. `/ @6 F; B% z3 m0 [! N, I: f% j8 O# v# r
static struct platform_device da850_evm_tl_leds_device = {6 A; ~3 w* M4 \3 Z
.name = "leds-gpio",
' m! Z0 @% C/ j) F3 L: v' }5 t .id = 1,
2 f) J) Y; { _: x! K/ X .dev = {
- n f0 Q6 b4 `- }6 D! q6 c; Q .platform_data = &da850_evm_tl_leds_pdata,
8 `9 ?9 F, g2 @$ T$ _ .release = led_dev_release,2 m* }8 W& H% |0 _! f
}; Q; I& Q, h9 m/ E; g) m j9 ^
};( G$ c8 \: T# X% d
: T# n. T; m, I2 I9 g5 x1 |6 @
static int __init led_platform_init(void)
' H) y& c3 W; [' n9 y4 Z: L, z{! _6 `" U+ _3 Q4 J! p
int ret;
9 o3 g: M& k: o0 a- L#if 05 s& V6 v9 d0 O% z6 c% ~8 X$ |6 J0 h
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
M% y' D# }+ s Q+ h if (ret)
' l/ W, j* D% l/ _; B3 W- @( [8 p pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; M4 S3 N1 x6 I7 | "%d\n", ret);/ H$ w( d/ t% a2 R
#endif" U; u3 e+ |7 z2 m# G5 g9 H/ c" W
ret = platform_device_register(&da850_evm_tl_leds_device);
% f- @: c& n: r) j- ? if (ret); _7 p, w3 T5 S) n! [" J
pr_warning("Could not register som GPIO expander LEDS");( {. {( | K& b/ o. o% H6 E
else- ~, ?) N2 d# E# f
printk(KERN_INFO "LED register sucessful!\n");
- R- S, `. z0 W" l
' m3 G& `) S+ R) h, o7 R( y return ret;
& ^: A; h Z: V* S$ Q+ i}
' {$ K Z+ E6 ^- N' k- J
% k4 g8 t& A& d x' x. \( Xstatic void __exit led_platform_exit(void)
8 A; J% Q1 }, J$ V- r{- B; [' I$ F6 Q
platform_device_unregister(&da850_evm_tl_leds_device);* S8 O4 o- n( i+ k" G: W2 J
7 ]# |, }7 s( q% L
printk(KERN_INFO "LED unregister!\n");
# f9 c8 h# Y0 q( S* v}7 o6 [) F3 S5 J8 X
I: h( \' I- V: U, {module_init(led_platform_init);' o. \9 | ^- s" f/ u) n% _( C
module_exit(led_platform_exit);% Q1 [' o% s1 Z4 [9 `7 L8 Q$ Y# |
2 E& A8 O$ ]- r" U5 {5 M1 R' [
MODULE_DESCRIPTION("Led platform driver");2 c, ? F8 F2 b; J. S$ `
MODULE_AUTHOR("Tronlong");# Z* l$ t n! H6 Q( p
MODULE_LICENSE("GPL");" i' D! J0 s& l% t" x; w) H
. d5 a) P, S, v2 q o( [. `
|
|