|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 A8 E, z8 m" ]
#include <linux/init.h>
# u& H7 `: a& g+ d8 C3 t* L3 m: \#include <linux/module.h>) u+ p) K. x6 }& f U
#include <linux/kernel.h>0 ]+ X$ M5 @8 |1 F
#include <linux/types.h>6 T( s6 }3 q3 ^ x2 ?
#include <linux/gpio.h>: a9 }4 N- m" @& r* U9 _9 R
#include <linux/leds.h>) i; t7 p+ w* Y) d
#include <linux/platform_device.h>: G! V' C5 w6 w, d7 y
9 f0 K7 d5 I/ I
#include <asm/mach-types.h>/ O7 z1 {: C( P/ E9 v! u3 b5 H
#include <asm/mach/arch.h>
) _ Y+ x5 J" Q* }5 b- f5 L) h#include <mach/da8xx.h>
7 e& D2 H' C8 I: ^5 i% O#include <mach/mux.h>
9 k6 F& `' [' Y/ g
6 D; m2 ]2 E" Z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 h' S2 w$ y u _9 t) [0 l" ^- L2 |" k#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): G+ C! U6 t1 \) Z4 m5 @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& P {0 T L8 `- d
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" L/ o/ a) H1 ^0 p0 Y, F
# L, T. v5 {6 {8 U" \
/* assign the tl som board LED-GPIOs*/
+ [; `7 y9 |" g0 Z0 S( Dstatic const short da850_evm_tl_user_led_pins[] = {
5 X, ^$ g* R# q- r) a /* These pins are definition at <mach/mux.h> file */( a- ~ H* z, k! T
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( l5 c1 I r& q& K -1
' M f1 r1 v$ C6 Z; ^3 U' n};5 t: F( C& M2 e2 u/ b/ P6 E
" J. q& a0 }% G9 k6 H& ]7 o
static struct gpio_led da850_evm_tl_leds[] = {1 e! }5 L3 l/ K! C
{
1 ]4 n5 i* H8 z/ R6 o* T .active_low = 0,
& D7 b2 _/ w6 W/ B) L6 | .gpio = DA850_USER_LED0,; a# b& v. T' H S7 ^3 Q
.name = "user_led0",2 W9 u$ ?2 z9 Y) R. C; V
.default_trigger = "default-on",& F+ v' V. m. E$ e
},
( T9 x& _4 w' Q {
3 o8 s9 `9 h6 {3 y7 X/ {: g .active_low = 0,# B ]/ R2 V: ]1 ?# x& C
.gpio = DA850_USER_LED1,, W4 n# ]) y) C+ X3 O9 N: B
.name = "user_led1",: C/ ~1 m5 u* ~ h V
.default_trigger = "default-on",
) N9 G% H1 b4 F# f% F( J: l# p },
: m4 c+ @; h& o* w& p {
2 |2 c- ~; F( S4 V/ I @7 a# Y .active_low = 0,
A/ V {& `- R: e- @. c- Z .gpio = DA850_USER_LED2,2 X$ `" F) U' z8 l9 L
.name = "user_led2",
8 z2 c1 q4 m$ L+ k+ } .default_trigger = "default-on",9 e9 S0 u) P" `( z% S
},
' e. \/ p4 b; y {( |: q! K2 b* x% O0 J
.active_low = 0,6 T% B- G7 O6 Y2 f( Y( N9 D
.gpio = DA850_USER_LED3,
1 ?9 }! q6 W) G9 R/ ] .name = "user_led3",7 K% x4 U& r& N8 u6 A3 c+ t
.default_trigger = "default-on",
) V5 @, v/ N, _# W7 Q2 ~$ R },! K- o) m/ D( Q4 ~& S* |5 ^
};( {6 z! l9 @: t5 V
1 m% {5 ]& \! T' C, cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( l6 `! h$ q) Y$ x( P4 C .leds = da850_evm_tl_leds,) ?3 j3 C- q+ F. Z2 U: D3 ?: E. `
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 z# Q& t, h& o9 F1 A7 a# ?};
8 G" x% a1 @8 B( S" N4 B, I% x& ` j+ B) t( A& A2 c9 X0 N R9 r/ s/ B! C
static void led_dev_release(struct device *dev)) g9 H6 v( K; C
{
5 x% e' N, ~0 `+ q& a0 K, | ~};
6 `3 i' {* ^5 Z+ A0 v8 _4 b/ D8 {: v
static struct platform_device da850_evm_tl_leds_device = {, m1 S% C$ e& \9 G
.name = "leds-gpio",
. C1 p7 o5 ~: w .id = 1,
& O! j$ l7 D R3 H% D+ S .dev = {) K+ a8 l N: B; M$ ^! L* h& S4 M
.platform_data = &da850_evm_tl_leds_pdata,$ y4 z" y# s+ a* p2 S, v
.release = led_dev_release,+ ^7 H9 }) j" D- z5 }* O; p" F6 K: o
}: P% s( \% t, s# U! R t
};
* i1 q+ Y' |: m" F7 [) w9 w' Y& U- A- X* k+ `
static int __init led_platform_init(void)4 |! I( b( Z/ B1 _5 j( ]4 ?
{/ |1 D# y2 {, X3 C( x, a @: G; J
int ret;0 h" Y' b. {2 K# d1 C" q- D
#if 0
2 t6 f% F7 T) f" Z6 s8 x ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 p0 N/ n4 u7 g3 g ? if (ret)
8 J4 r' W8 i7 Z7 _* c9 v+ t z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
o/ {9 ~# F/ T" q$ J- ^. y h4 E "%d\n", ret);
. \: E1 _4 U# B) e3 E; Z, J#endif5 j8 j C- X9 ]2 b
ret = platform_device_register(&da850_evm_tl_leds_device);# h) [* W$ @; r' R8 j$ ?" y+ q
if (ret)$ l Y% a( Y* I# f; l. S
pr_warning("Could not register som GPIO expander LEDS");/ s# e" f6 Z! h
else
8 Q( y L Z& B- F! H9 k printk(KERN_INFO "LED register sucessful!\n");4 a1 n+ m6 L* s$ [* T
5 O; [: _3 e% e! E! M4 K# m return ret;6 b" k0 O( T5 I- N
}/ ]9 U% B) B6 |" V. ^* k! T
0 k' c, l0 ]4 U" f ~static void __exit led_platform_exit(void)
, T( e# w* q! x9 ]0 e{
$ M+ l5 e+ _( g8 }, ~ P platform_device_unregister(&da850_evm_tl_leds_device);
( J- d1 k5 P$ D1 o) a5 Z; C; F/ ^: G
: ^8 M% ], P5 [9 x: i, k: ^ printk(KERN_INFO "LED unregister!\n");
3 J- ?! y' \) {$ S- i}% h! J/ }% M0 z1 _4 J" T
! u# v g5 C/ u9 v6 Z$ D: Umodule_init(led_platform_init);
) _/ N% j( V3 k( ~module_exit(led_platform_exit);) R1 E0 ?" B( C/ T5 _ {
6 ~ t' I" R! I, N
MODULE_DESCRIPTION("Led platform driver");% c5 ]/ s1 e, t4 [
MODULE_AUTHOR("Tronlong"); q5 P- C. R/ P) ^) ^1 c! N# w* h
MODULE_LICENSE("GPL");
1 i9 y2 M7 N3 a3 R+ J0 b
2 Q" w8 n% A& S v5 G |
|