|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 o7 G y$ W2 Z) u4 C4 p
#include <linux/init.h>
( V3 _! [& e" F8 K6 N5 L* j% J0 b#include <linux/module.h> P& {6 y4 j+ T8 g
#include <linux/kernel.h>
; L6 }( { }" [4 V7 F#include <linux/types.h>2 j% A! @% r) ~( M' j
#include <linux/gpio.h>* y2 C+ H- T- z3 c1 K
#include <linux/leds.h>
8 B/ G9 j. w* T8 E#include <linux/platform_device.h>
7 H- @' I* n4 z2 r
/ b$ J5 h- _" }#include <asm/mach-types.h>0 D* x6 |9 k" j% _ ?
#include <asm/mach/arch.h>9 i- u% b4 B7 |' h8 c
#include <mach/da8xx.h>
; F9 I; V8 I- s#include <mach/mux.h>8 O% h: j/ f, R* {7 u d
; T; B& }4 ^8 P" f1 G6 }- z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* j( C+ _9 J3 O& p9 q' @* G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) }. l: p2 Y/ {6 o6 l
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
z1 k2 \# L/ S& Y+ x5 z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 J) @4 P- B4 c4 l. |4 U8 }5 m
; r* n2 R [0 ?: u8 @
/* assign the tl som board LED-GPIOs*/1 \+ Y' i0 T4 z" J( T3 _) s
static const short da850_evm_tl_user_led_pins[] = {
! A0 t; F& M) R8 C2 X /* These pins are definition at <mach/mux.h> file */3 E+ {. L( o# S3 O6 ~
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 M X8 k, V" G8 R0 v8 [ -1& P3 j# |1 r$ [( U* d" ?! F0 f# X
};
/ m/ Z+ h, v/ L# w l. V
( ^5 `& \5 }" _4 H* a$ m3 Mstatic struct gpio_led da850_evm_tl_leds[] = {7 O- Q s) m* i' z4 }
{6 L, I' O4 {8 T; G
.active_low = 0,
+ ?1 y5 V7 p: h6 `0 r2 h .gpio = DA850_USER_LED0,
/ w" v) ? }1 u$ }* m3 b M .name = "user_led0",
5 {) }# m1 a5 ?) \ .default_trigger = "default-on",& S; U7 y' N5 V- {9 R% o4 o1 V
},
" V% R2 @. ^: [# N5 h {
4 j$ {; Q3 m% a .active_low = 0,
/ r& X$ v7 H/ ^' ` .gpio = DA850_USER_LED1,
l; E, {* I! H# }* E& N2 m .name = "user_led1",
! @. M/ Q8 W& Z1 u* X .default_trigger = "default-on",
2 G5 `4 m2 f+ ^0 s# a& r },
3 E# T" v. O2 E6 q( D {! a$ \& J6 W3 T2 ]" m
.active_low = 0,
, Z7 K; ]' y, ~ ]; F! j- O .gpio = DA850_USER_LED2,
+ q% Z1 T, U! D6 Z4 A J .name = "user_led2",9 R" I0 U: N: W# A
.default_trigger = "default-on",
% o6 M6 D% w& x1 b. e2 ?- y3 F },
$ F* K: u8 w/ ^" \8 U* E {' E+ p. Y: K# f A9 ^) Y) {
.active_low = 0,
( t M! P% |5 C) A3 g8 I5 R# _ .gpio = DA850_USER_LED3,* B8 I9 a) B! @! O: b! K5 l
.name = "user_led3",' y7 ]- \- w7 b' ~
.default_trigger = "default-on",5 Q& b7 S+ t6 c S z" q1 ^8 `
},' y' e# P x5 N8 i
};
C' X, ~4 i9 Z, g/ p1 t
7 k; s p) x6 }! l& N3 hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: ~: Z8 O* ?( P: t4 w5 ]0 Z
.leds = da850_evm_tl_leds,6 Y# Z( E0 U2 j' e
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 s2 n; d! }. b) ~* W; [8 W1 T1 k1 R5 D
};; ~; N' `3 Y" n4 s
7 o9 [ {* |0 e7 _! ustatic void led_dev_release(struct device *dev)
( T+ X* y/ i3 I{) [/ ?/ l" X$ X7 m4 d
};4 Q4 W7 h) P7 l% B9 o3 G
5 y# C7 R+ Q$ v" s9 k B: j; m
static struct platform_device da850_evm_tl_leds_device = {
; G; v6 Z- I+ f# [ .name = "leds-gpio",
2 H/ |3 W+ A* ?1 O# |% E2 v .id = 1,0 _: T5 I. w9 e2 U1 s: N: Y' A
.dev = {( |2 g _7 B+ j7 K8 F
.platform_data = &da850_evm_tl_leds_pdata,
/ L: j2 Z" R" b; p# F3 t, C .release = led_dev_release,2 o# N m# \3 ?% C* u3 ?
}
. g0 y0 u5 R! s$ r, K};( f7 N. d3 j8 @# w' u
! v v, O$ u# N
static int __init led_platform_init(void)
: R1 `" g4 x8 j! {( p7 v8 |' u{
. S; E: E4 |& J! ?7 k int ret;, f$ B L; {2 e% x) D/ g6 r
#if 0
1 ~* A: L G# X' {# N0 b ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& Y; O: S2 D) F# b
if (ret)
U- u! J: E2 i m( ?6 f7 H pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# B7 g% g1 O5 l8 l1 p9 C9 H* d "%d\n", ret);
: {7 G2 c) a" B2 ^8 _" I& r6 X#endif3 u8 v& m; F$ w4 @7 K& i$ ^* g" S: Q5 Y
ret = platform_device_register(&da850_evm_tl_leds_device);/ p( K4 U/ k0 m0 j; [( m
if (ret)) S9 K6 {3 F( b! q4 G
pr_warning("Could not register som GPIO expander LEDS");, o1 w4 Z% p$ g4 l8 l1 o2 |
else
( u0 i; P5 |. {4 V& P3 f! e printk(KERN_INFO "LED register sucessful!\n"); k: l, r, v% y$ V3 Y! e
' P1 K' |3 g+ N
return ret;
& t0 z5 |/ M% q}
6 ?0 n4 f+ M+ c( e4 Y0 F
* }2 I: E( M% Hstatic void __exit led_platform_exit(void)7 B) B, d9 Q( u5 p
{
7 a% e( l+ W$ F. k) s) s. }0 ? platform_device_unregister(&da850_evm_tl_leds_device);
% J ^$ I' s, @" f
' @1 J5 Y) i! H2 J# U1 P m, } printk(KERN_INFO "LED unregister!\n");
. q0 t0 |2 e+ l" ~7 l+ g7 V& }}3 u! ?2 f' F" R6 o2 n
3 i* _* {4 Y% w( W4 |) f5 S6 \module_init(led_platform_init);; d- ]0 m2 E* d m7 S
module_exit(led_platform_exit);
9 N+ e/ U3 s0 M% v3 K
3 |9 R) `" V& `) lMODULE_DESCRIPTION("Led platform driver");9 I- t, o3 e8 c1 s4 ?% _6 }- `% j
MODULE_AUTHOR("Tronlong");: K3 N. T9 {5 l; M
MODULE_LICENSE("GPL");1 M0 J5 |) J, d, D* U
% K4 t. P) a# j8 p5 i |
|