|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 C% V! W: V( H$ q6 }. i#include <linux/init.h>
/ H% ^0 O; X6 Q* S#include <linux/module.h>
; t2 Z5 ~" W! I. X- H! b#include <linux/kernel.h># h4 U. j6 v. `# I4 J& T3 J- u
#include <linux/types.h>
2 _" L7 Y" y' }4 l: g#include <linux/gpio.h>* Z" C+ B/ `' ]0 u+ A* Z
#include <linux/leds.h>
" h) Y x0 y% b$ U+ O+ V* t! a9 r' P3 p#include <linux/platform_device.h>) y% t8 Q8 n0 ]6 r, B
% V' W8 ^% |. M#include <asm/mach-types.h>
0 H4 n9 |2 ]+ _#include <asm/mach/arch.h>- w* G4 c; D- z! @% u9 |2 _
#include <mach/da8xx.h>2 ^7 a$ H [7 j, z7 S
#include <mach/mux.h>
9 ?1 W5 O6 I" j5 W) M& `! c2 x2 l# J9 [7 E2 h
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 Z# k1 P$ C' j& |6 M* b
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% Q" F" K9 Y0 p( @; V
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 a& Y0 }) }* ?. ^' V; L#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ z) b/ H" J0 ~7 F G
+ F; p2 K) u" r7 F0 G/* assign the tl som board LED-GPIOs*/
1 W, x) u O/ _# P, p3 {static const short da850_evm_tl_user_led_pins[] = {
' y$ Y! H: e* Q /* These pins are definition at <mach/mux.h> file */9 N6 M% g | i
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* q9 T; p; W, ? -19 Y8 n" p- j' X1 U! \
};9 U9 m1 k0 |1 D' p
4 K* f- z9 N: \9 h. W1 g7 R, d9 t4 Ustatic struct gpio_led da850_evm_tl_leds[] = {
1 I3 J* d8 C7 w' {/ `/ v {
$ Q8 v$ n$ \/ S .active_low = 0,
! O n7 }3 h$ t/ Q/ M$ R .gpio = DA850_USER_LED0,
+ F& P! H& X7 e6 Y2 [ .name = "user_led0",
2 H; a5 {1 a/ p# R o .default_trigger = "default-on",
4 {1 ~7 \) h2 g6 U },: W; z5 }! O4 m- s1 j5 z5 b9 R! h
{: @! f* p/ b" C: P/ \
.active_low = 0,
( p0 h) L8 u' d .gpio = DA850_USER_LED1,8 T) G$ _1 w+ R" L: p
.name = "user_led1",
" g% g P# f& h& F' T1 g .default_trigger = "default-on",4 M G2 x+ `+ D. m* ?1 x% A6 D* @
},
+ ?2 |4 s, E1 W8 s' l {$ t9 P. X$ m" [/ l
.active_low = 0,# E7 t2 u7 T8 i' k3 f% l& o' u
.gpio = DA850_USER_LED2,4 S6 ~ c* m. I7 t: O4 q
.name = "user_led2",
- U2 v1 r. k) @( O, D# N .default_trigger = "default-on",& ~3 t3 U/ g8 t* x& z/ l% q( G
},
4 g/ z: _6 \0 l$ Y9 r" @" P7 D {
6 ^$ t; _( K: G" L# x. Z8 K4 V# ~ .active_low = 0,
* g7 { {, l1 g" C .gpio = DA850_USER_LED3,; z9 R, N2 j; F& {; x
.name = "user_led3",
* e. k, Z2 q$ g3 W7 S8 L$ r .default_trigger = "default-on",' y9 M9 a/ K9 h/ h
},5 y! u8 [. q. f0 ^
};9 T* T6 Z t- g6 M) ~" \* B E
: j! i) X+ ~6 `' y/ ^ ~0 I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ d% w5 W( D( s9 h+ D .leds = da850_evm_tl_leds,' ~& B0 S! F( y% ~/ D) \! \' T
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),: Z5 x% C, o5 l. i9 o
};
% X, \/ J3 n9 y6 L& M+ a' r
6 q v: U5 Q0 e( K+ Y8 g) ustatic void led_dev_release(struct device *dev)
2 n3 v- p! I5 v( K# Y0 E{1 a3 ?. B% q7 J: G u
};8 _/ l) ^; p3 _1 @. B, y
4 k7 s" @0 \0 y3 N! W w
static struct platform_device da850_evm_tl_leds_device = {4 Q9 Q( `7 k0 R9 S( P
.name = "leds-gpio",! W8 s. s' m# w8 b8 I
.id = 1,
$ Z/ o1 h% Z' G" E .dev = {
* S6 R5 |2 f" x6 a" u# T4 Z .platform_data = &da850_evm_tl_leds_pdata,& `8 s, U0 b- g# K% X8 G
.release = led_dev_release,& Y7 ~8 p# L0 U8 }$ g; @' X; l
}; h' i% K; N4 r1 A' f1 ?4 R. f s
};
* r7 U* z, @! g0 R- w, r# I4 j, L9 r. ]( R" `. |
static int __init led_platform_init(void)1 f- P# d- ^; [# {* T
{4 S3 |2 R2 K( U2 u2 C, t0 E
int ret;" R( U, m J) B5 x! `
#if 0 f/ ]' C' \, {7 T) W7 g
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# @6 X* E& D$ b5 T5 K: j) L
if (ret)
" @/ u. q1 d3 p. a( Z Z/ | pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 W L' [* C m' d1 } "%d\n", ret);
' z, {; [; k# |0 ?# e#endif
/ x$ o: j0 D6 }7 J2 s' f# D8 B ret = platform_device_register(&da850_evm_tl_leds_device);$ ^/ ^& s7 d7 y3 O5 y2 u
if (ret)
6 w9 G; |0 r2 r, T# R6 [ pr_warning("Could not register som GPIO expander LEDS");
' c2 I) z6 U1 f0 o4 W% s0 Z- ]! q else* A {+ R% F0 z# ]+ _. ~) ~2 ^
printk(KERN_INFO "LED register sucessful!\n");: ~/ x$ b4 z6 E# {5 {" m
# Q9 \' a+ K( B, G4 r/ U1 s return ret; e7 G7 b) |. k5 s# D$ X& ~9 S
}
" G' b% E# m6 w, G6 d/ [: w% ^- i. J, T p1 x* f2 x! n
static void __exit led_platform_exit(void)' V/ `" V# Q3 F% T$ N2 k
{6 T9 S, |1 \ @& U
platform_device_unregister(&da850_evm_tl_leds_device);
# r+ D8 e' a) E8 L$ P% o; p% ?% o% r- h+ D. g3 l
printk(KERN_INFO "LED unregister!\n");
5 E \; S# {3 [! f7 @}
( {$ g% b: u' U. y
1 e( \2 V" D" Smodule_init(led_platform_init);
; k- x- Z4 @' m8 K9 [6 e& _: Jmodule_exit(led_platform_exit);! ^9 S9 D( L0 A, x+ [3 [( I2 v: r
( m2 { P) Y/ T# wMODULE_DESCRIPTION("Led platform driver");
: }$ t/ y! c. @MODULE_AUTHOR("Tronlong");; @) J0 B! c3 L3 K6 h" w+ K8 V! ]( x) S
MODULE_LICENSE("GPL");
) j8 Z. ]4 f0 k4 L5 e4 W8 [1 J+ w8 O
& h+ D" `; Y P I3 [( S3 S9 |4 c% ?4 c" ~ |
|