|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' _1 \! k! x$ M, X/ Y# T, M% E#include <linux/init.h>4 w5 G2 {& l! B1 m' t4 }, x# @4 ]
#include <linux/module.h>
, B& @9 z" t f3 s#include <linux/kernel.h>- J5 C- T/ s$ B. ~: ]/ h7 D
#include <linux/types.h>/ a6 T5 [( `5 R
#include <linux/gpio.h>- l+ Y; c% I8 c% j7 l- o6 t
#include <linux/leds.h>% q6 A/ _+ m! H3 l+ H
#include <linux/platform_device.h>
0 \) ^2 f# u$ s
& u6 g- n! x$ I" j1 Q/ w6 F#include <asm/mach-types.h>
$ K& i( V# U' N0 K#include <asm/mach/arch.h>, T7 C5 x0 J! z; V8 a1 b0 K
#include <mach/da8xx.h>! J3 j* ^* G" m
#include <mach/mux.h>" ^3 F: r: P7 }
8 C1 @/ V/ G7 q! e5 l( d% l: P
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- ~- y& I$ q9 ~+ h& W0 J# r/ I
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) ]; b7 _6 j" Q, q# A2 W. x8 p
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" e1 d G; O" o! m
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 I0 |0 l# c9 `
& ]6 ^: T" S, a# S6 K/* assign the tl som board LED-GPIOs*/
- a) G5 o- D" H& k& P; P9 Gstatic const short da850_evm_tl_user_led_pins[] = {
. g9 P+ f0 h) ]. L# D /* These pins are definition at <mach/mux.h> file */6 \3 ^2 G4 c, @ C, Q) ?+ c- p) w: J
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% I9 Y" ?# k4 f' t1 N8 }7 h -1
+ G1 _- i Y$ A2 A+ u1 \$ `};
/ @. H) `3 q4 D( b, n1 q$ P R- X$ a# s$ L
static struct gpio_led da850_evm_tl_leds[] = {" Y' L% U( b: c
{
; H, Y" c6 c5 u$ H9 P' v# m .active_low = 0,
2 E/ c( c' X6 n o4 P+ \& K .gpio = DA850_USER_LED0,
3 W$ Q5 l7 N* A" D+ u .name = "user_led0",1 ?& V# I( m2 x: m
.default_trigger = "default-on",
4 g4 B4 K7 F& ^3 V4 S" J9 p g9 L },8 i3 b% N. r$ V5 c
{
v# `6 u5 e% P9 @5 ~* [ Z6 q .active_low = 0,/ R) l, ?9 b! R3 \( o
.gpio = DA850_USER_LED1,
4 g k% Q+ y3 ?, ?1 d! u .name = "user_led1",* Z/ h8 \1 b1 V. M* @: q4 y
.default_trigger = "default-on",3 V- F( `/ R. E- o! ?( a- N
}, {/ B7 X y; k: d
{
) T8 j- k$ g f! Z .active_low = 0,
* ?# L* N7 H8 j. @* B$ o .gpio = DA850_USER_LED2,
3 X& z3 M/ n; b7 j9 } .name = "user_led2",% D& c, w1 Y# |$ e6 B: E* R
.default_trigger = "default-on",( R0 z1 _) q/ x6 P& P( o
},
( u) q: u8 [2 D0 T) n {
9 T }& t8 v' x+ C8 l, R0 U' Q .active_low = 0,
P2 I2 k5 p5 [7 c$ l* s .gpio = DA850_USER_LED3,9 z4 y1 ]2 L k) p! l
.name = "user_led3",$ ?6 O6 T2 u6 I4 K0 b
.default_trigger = "default-on",
+ p7 w2 b% k5 N9 L* {7 a },
4 e$ e! O" l) }};* n; d1 _; B% `) \/ I% P
4 d: O/ R6 \; E2 u0 }, @+ c+ Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" g3 S* n' E, f1 A3 T& [/ r .leds = da850_evm_tl_leds, K1 T( r- U+ _1 \& m
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! g6 F/ c+ f0 ?4 `6 W+ |};
) M2 @2 _& H1 e0 r) u# C A/ b% [$ L. c5 ?: v. B8 }2 ^, ?
static void led_dev_release(struct device *dev)
, J/ V( X' Y0 t- a/ B{
9 U0 T/ \* _" o: s, y3 T% ~+ V};
2 A- x1 Z; x6 f0 _' R* [$ O6 `* L: n
static struct platform_device da850_evm_tl_leds_device = {9 ^7 i. H; ?+ ]% M0 j
.name = "leds-gpio",7 ^8 q1 o" C" p* \
.id = 1,
, `" T( R; I- U .dev = {
" @$ q+ @) n u8 Y .platform_data = &da850_evm_tl_leds_pdata,4 A$ I+ u$ h( F+ a9 ^
.release = led_dev_release,
8 H3 n) H# V6 I$ [. }" B Y }
3 ?& c. r# n; S& R4 ~};& N* e7 P% M: h6 T/ h- P! ?9 r
) x- N# I) p Mstatic int __init led_platform_init(void)7 l q8 S( R% O* `* E
{2 p3 w6 i8 a( @) M# v! _6 }
int ret;/ {0 {/ X3 Z9 a
#if 0
- v" W0 ~8 W+ k. G. y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
o) ]4 l8 i5 ~& b4 A. e- x if (ret)9 S: @# E2 y1 U& A$ a" g
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 q8 i2 \% A* A7 q! k% I0 H! {6 A& ] "%d\n", ret);
- k. d' M1 `$ H* }% {5 z F. D8 D#endif! L7 O" F/ X- A6 {" z9 M
ret = platform_device_register(&da850_evm_tl_leds_device);2 Z+ v6 ~' N. I- `
if (ret)0 `- q5 J; v* j. A4 ]) h2 r" U
pr_warning("Could not register som GPIO expander LEDS");
4 L* i( t; X$ @9 T" ?# ` else7 ]% T/ T3 |8 J# ~! I( R$ T7 O9 B( S
printk(KERN_INFO "LED register sucessful!\n");/ h2 T5 A( C7 L) D7 ^
! _; f+ Z9 r5 E, e7 C
return ret; U" L) H4 u: I! u8 k
}5 X5 U5 e; B9 h. H
/ x* ^4 R! c( H$ z; i7 f% d- tstatic void __exit led_platform_exit(void)+ y( B: z6 ?: \, e' L
{
3 T0 A: Y7 k4 M! }! |) e/ W1 s platform_device_unregister(&da850_evm_tl_leds_device);
7 p* j: G: z# [; U+ k! p7 l1 \! |, U! h' _. }: W
printk(KERN_INFO "LED unregister!\n");! w; W8 a1 t5 w* Y
}9 O5 W& P" |' k) U! ?7 p: z
( g3 k0 t. v; {( D- T
module_init(led_platform_init);7 F% D: ~, ` i/ W6 b/ G
module_exit(led_platform_exit);% s! M, q0 k d& a* o( W
9 o+ d6 f- N6 b: M0 K1 p& B gMODULE_DESCRIPTION("Led platform driver");
* U2 s6 J7 x( |) w* s2 eMODULE_AUTHOR("Tronlong");8 q# I; S# z0 p3 I: }
MODULE_LICENSE("GPL");
: s. y7 a" P5 V. w" m" u3 D, _5 z% d( V- K
|
|