|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. x( J" L+ v+ Q% ?5 |4 b0 l
#include <linux/init.h>
4 ^. G4 U. r+ o! Z" n#include <linux/module.h>
' h3 C% v3 I/ y/ b- q; _#include <linux/kernel.h>8 e/ e. P- N+ q8 m0 |, Y
#include <linux/types.h>% k0 Q( X5 X4 A' \! Q# f
#include <linux/gpio.h>
3 d# O8 E, d5 W# C3 N& p#include <linux/leds.h>
+ y5 x9 }* o( J- r9 f" X#include <linux/platform_device.h>
9 Q; Q0 |+ Z' j+ T% ~) T( e
8 a/ M5 k9 ?& w+ H; O/ e' L% f#include <asm/mach-types.h>
* j3 u$ o9 E- m! I#include <asm/mach/arch.h>! n9 J- D7 ~) m+ [; ^
#include <mach/da8xx.h>! M% U4 n4 w) P* k; W& S* O# f
#include <mach/mux.h>
- @! u# Z% n" d. w$ q$ t" s7 N: {0 L- r% a
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
t# n: E5 t; J3 I8 J# W#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% m4 M2 i8 K" b: U1 U3 ^#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ s; C# p, K* F& x2 `' v
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ `2 r0 g, ~- V: r; I
+ y7 C' F- a) q/ s& v' N: k6 d. x/* assign the tl som board LED-GPIOs*/
6 A/ k$ S+ D3 x5 X( |static const short da850_evm_tl_user_led_pins[] = {
/ j6 P5 F7 ^) Y% ~1 s- ^5 ~ /* These pins are definition at <mach/mux.h> file */* e" f) x$ B5 I; m5 \% M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) r; u5 y/ s8 x; I2 A C2 F) ^! L -1
( P. w# H5 [6 x1 Y2 s};+ o+ ^/ f8 |: i& V/ @
3 p9 ~' z6 K3 p8 ^9 ?3 j% Q% c; }static struct gpio_led da850_evm_tl_leds[] = {
5 _! D: v9 y/ c* k+ l; ~" u {
. f2 H' G3 Y0 U- s8 ] .active_low = 0,4 P8 f9 @0 e7 g6 q3 [/ _
.gpio = DA850_USER_LED0,
$ r M/ h# ?7 }. U$ Y .name = "user_led0",5 i/ L: d1 d F, }
.default_trigger = "default-on",; R# b4 ~7 |& I4 t2 |
},/ H0 [1 E1 X1 `5 Q% q, d
{4 S2 \- k4 W$ Z) \' d: T. W
.active_low = 0,2 p% ?8 C5 }- W* j
.gpio = DA850_USER_LED1,
4 C: w, P7 ^$ v# k U. y- X1 v% X2 d .name = "user_led1",
0 t5 P! Z5 x$ H7 ^. x; y& ` t6 t .default_trigger = "default-on",
1 f+ M, h j* V+ n* D: i },4 {8 S/ S. E0 a9 }3 @8 d
{7 I3 d N6 j2 f5 t' N
.active_low = 0,& E6 b, E- w# U5 s+ b0 O
.gpio = DA850_USER_LED2,: L0 d+ {% [/ D! G2 g) q
.name = "user_led2",9 Y+ B- Q1 e& [, q6 c
.default_trigger = "default-on"," e% { s4 X9 x' D; K& l
},5 S6 O" A) Z7 n. Q
{5 p" f% f& c5 W. U$ C7 v
.active_low = 0,
1 x& i6 }% }# F+ h1 H; y .gpio = DA850_USER_LED3,- W; e! m& S) w. k8 [
.name = "user_led3",) ]& k& M" J$ u' j6 a
.default_trigger = "default-on",3 J" Z' g; D; M6 [% s1 S \
},
1 T* k U d2 s" }% F4 C};4 w4 ~# M) W7 Z2 v7 Q% i
w3 R+ B/ m7 M- i7 U! b$ B* Y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ X$ i$ j1 _$ [ .leds = da850_evm_tl_leds,
1 l" Q( @* X1 {$ \/ I .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 S" e+ G, u) I+ Q5 q7 G; [
};6 k; I+ J; f% n" H
# h4 D% N0 H2 jstatic void led_dev_release(struct device *dev)
- `5 x) \7 |; C4 b: S6 H{: L- |" n/ @6 Q5 D1 f9 {, h
};
$ P( B7 ]3 s; ]9 A5 [0 `& T+ [8 |# K7 m- `7 Y. f: X
static struct platform_device da850_evm_tl_leds_device = {
( o. w( w" {* }; P! k0 P7 P& b .name = "leds-gpio",
( {5 |( J3 E/ ~ G6 c .id = 1,
' A/ K2 r8 T8 z .dev = {
" g' U5 p) g0 P' J .platform_data = &da850_evm_tl_leds_pdata,; Y- K1 p U n! M! @; X
.release = led_dev_release,
6 M2 W# [" c% |/ G- m8 z }% E# e1 M7 h8 `6 p! B5 [% D
};" r& J1 l0 i: V! H3 J6 X& T
- u+ J1 o7 x) x& H1 Lstatic int __init led_platform_init(void)
5 G3 [- p6 M) M/ ]/ a{
3 M) W% z+ \* l( c+ E int ret;
$ P4 d8 C- c/ h' m. u! w#if 03 }$ c: Q* y. n g5 ^3 M o
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; ^4 u* z7 p/ u3 y
if (ret)+ T: c6 Y8 e0 P
pr_warning("da850_evm_tl_leds_init : User LED mux failed :". R' I! i4 ]! y7 W
"%d\n", ret);. h+ L1 f) V3 W5 ~' S( P
#endif
7 A# x# p/ @, l. Z$ I& Y ret = platform_device_register(&da850_evm_tl_leds_device);/ U; L3 r5 h, g
if (ret)/ L# `3 H7 m- K. {
pr_warning("Could not register som GPIO expander LEDS");
8 | J: j6 k4 L6 K. { else, w$ h: l* r! z/ V: p, t
printk(KERN_INFO "LED register sucessful!\n");
4 X5 A, E9 l3 l) K- |
0 [# o0 [& e: O return ret;8 z7 K3 K! v7 k
}
- t' Z" g* i: f( \
* ^! ^% m* |8 J: \/ p# n& Lstatic void __exit led_platform_exit(void)
5 k& F: Q) {) R1 ]) C' @{; c5 L% z0 D( u, Y* N
platform_device_unregister(&da850_evm_tl_leds_device);
! D% Y- B5 l$ Q1 U
6 t$ i) ]$ d/ z) l6 a. \ printk(KERN_INFO "LED unregister!\n");$ I5 q; y1 f: S+ ~" a
} A; k. I3 L/ I. [7 D) A
( U/ Q$ b; \$ f- J
module_init(led_platform_init);) l6 ?# h2 W( R5 k" l4 V9 r* W) c, J( Y
module_exit(led_platform_exit);% l t" n# m& w+ X. r; C% v
% @0 D6 L0 t" ~% H
MODULE_DESCRIPTION("Led platform driver");
1 o2 n: O5 w3 { L: e% JMODULE_AUTHOR("Tronlong");# b" M2 D7 q9 ~$ J! j/ J
MODULE_LICENSE("GPL");0 [6 q/ p1 J) T3 C* e# N
3 E8 Q4 f( d+ Z8 I |
|