|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ z$ `. L8 ]$ E! a# _#include <linux/init.h>, q. j7 H* Q1 o: C9 O0 w6 _; s
#include <linux/module.h>! a' ?* `, `0 c( @" _9 ~
#include <linux/kernel.h>
/ O6 m# M- w P8 J#include <linux/types.h>/ D3 f: a2 H, w+ n" g' v* b6 w
#include <linux/gpio.h>' W6 J N1 S( \# }
#include <linux/leds.h>
g, ~+ G! t. d* C% C E# n2 u4 S#include <linux/platform_device.h>
/ H: C* w+ {3 P, @1 ?% k! o
n1 ^* J5 D$ R) ~8 ]* R3 N6 c#include <asm/mach-types.h>
& T3 w4 V3 p5 z#include <asm/mach/arch.h>; y P8 F @! y' u
#include <mach/da8xx.h>
; I& L7 E( L2 m: D#include <mach/mux.h>
2 u" ]. j8 P& M, _4 ^" P. h% V! g' Y F
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% P( q4 o! \$ v7 \ n4 V7 [
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ m6 G3 S+ Q1 m( q+ [/ \#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); c: o6 U8 e" M* N& O
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: z9 T2 f& s% e( q, K& N" E3 v# v& P
/* assign the tl som board LED-GPIOs*/
' K- l0 p0 A! b5 Xstatic const short da850_evm_tl_user_led_pins[] = {* C8 a# P8 B8 G% U6 @
/* These pins are definition at <mach/mux.h> file */ ?' J# H# B$ r! m' z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ |6 ? d8 W. H# F+ c& R5 z+ Q( b3 d
-1
% M, }" U$ {0 V3 s. w% ~};8 d6 G1 j# b2 h/ Q7 U
7 n0 d) A) L/ N" e
static struct gpio_led da850_evm_tl_leds[] = {
& ?* A$ V7 n! {: ?+ }5 w' v {6 l z6 X, }8 @0 K/ G$ F
.active_low = 0,
6 ?$ B; z# R3 b& r- L: |! x .gpio = DA850_USER_LED0,
4 ?4 P( g9 v W- y6 b0 ]: B .name = "user_led0",
) G; g! w5 n' ?8 [* \5 ^ .default_trigger = "default-on"," u/ G9 \2 o% o; q6 g8 ^$ b1 m
}, T: G+ S) M4 ^: Y
{+ C7 Q/ x5 O' ]- o
.active_low = 0,
% Z5 A2 f, B! r6 P .gpio = DA850_USER_LED1,( I$ G& ^- o8 y3 A
.name = "user_led1",/ s, y4 _# O8 a. o
.default_trigger = "default-on",* @4 t8 e1 P/ a( D4 y+ j
},
; @: B; o) D. c {* z# p9 V% ]0 i1 p/ n+ k0 W6 s
.active_low = 0,
6 ~5 {; W' j6 w8 @7 b .gpio = DA850_USER_LED2,
1 ~7 `/ A) [+ b0 [2 K8 U H7 ]3 k9 R .name = "user_led2",
# _1 _; m" ~0 ^5 ?2 F$ K9 e* z .default_trigger = "default-on",
7 C+ j( } T- |+ D! _ },
3 _( D2 G. z: t3 Z p# Z {
2 `! G1 p7 e7 I7 x$ Y, q' W- y .active_low = 0,
0 K# P3 q3 K( Z- D- w' F .gpio = DA850_USER_LED3,
1 W9 N) m/ \" M .name = "user_led3",% e0 ]1 o6 ^: n3 r
.default_trigger = "default-on",- a6 ^' [# q4 c
},
1 s: O) ?# Y) z( r4 g' n5 o5 j};( b" K' a; L `% j
8 v- o8 N& Y. ]) }7 P0 F6 j& @static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 I- J0 r9 x* `* p% Y( I .leds = da850_evm_tl_leds,. F3 f9 y) A! V1 r! Y0 t" m* g7 F8 `
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 i3 Y4 o# T/ X2 [$ u# E( {% t
};
, F3 |7 O5 G8 o- l9 o9 L! S2 G V! F' L) o. I$ `" N; \( t
static void led_dev_release(struct device *dev)+ T; g6 j" H& _% R; e2 a5 B/ P" f1 a# O+ U
{( o% h5 o$ j% A
};& y' _: `7 \" c @5 [2 J+ D' K
( A$ B. {2 M. {/ B: H0 G; zstatic struct platform_device da850_evm_tl_leds_device = {
, j- F+ [+ m: j: O3 D9 p7 }& a .name = "leds-gpio",
* h x8 V2 w8 ?* o' A2 t2 _3 E .id = 1,
7 ^% k9 v3 Z9 z8 C0 m" p' _- j .dev = {
5 j# P V2 ]. ]. H! d4 ~ .platform_data = &da850_evm_tl_leds_pdata,1 j& @( X1 M* n
.release = led_dev_release,7 O/ _5 O1 e# \5 X3 L r" B8 z5 w9 z
}+ i4 G& r3 C: A. Y8 B( z9 q3 _
};/ n4 g. K: l: ?$ E/ g. Y
' q$ ?1 ]) ]5 @1 i. `2 d& astatic int __init led_platform_init(void)
2 Y& W& X% o5 B% N/ ~7 J8 f{
- B7 d, B/ x# P- V8 J1 ?3 Q, p int ret;) D3 d g- p4 i% P) r" D8 {& _
#if 0
# n# Q1 l; A; g# l* C# t1 E ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ t- L, d& N6 k: \: z$ p1 L
if (ret)* w0 U- V. u% F! M8 ?
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- T* ^! g7 [0 _" K "%d\n", ret);! K4 V: ?0 J) ?' A; K
#endif
% Q# R4 }6 B9 \1 ~ Y2 r$ c2 }! X ret = platform_device_register(&da850_evm_tl_leds_device);
2 J3 x9 s; ?, S. }# t if (ret)
# S% @7 {0 z" i& v& ?- p pr_warning("Could not register som GPIO expander LEDS");
- c+ j7 j$ f9 L' M; h+ l* W1 k else: { | i- K% U+ m
printk(KERN_INFO "LED register sucessful!\n");- h" o" q" K4 o$ s5 K: ]5 G% a
1 X# z7 `5 z. T. h: i
return ret;
0 A0 B, m( U" c. M! D9 c' J: d}. D/ u9 n- b3 N! g0 o/ ?2 ]7 h0 P
/ e/ E& f+ N; y4 T6 e# q# I0 Gstatic void __exit led_platform_exit(void)0 x6 f% n' v+ O. ]3 t
{) g# S4 i) H1 u- f# g
platform_device_unregister(&da850_evm_tl_leds_device);
4 @, R1 q# [1 p+ A' w: x6 B6 O4 C) O7 C% \6 a" X- E
printk(KERN_INFO "LED unregister!\n");( a U+ c' M1 k! g3 W, B
}
& @, U1 V1 r5 m8 P% J5 I9 n! d
+ D' t0 k8 \, d4 S& Hmodule_init(led_platform_init);- L3 D& w, x& P, |
module_exit(led_platform_exit);
" M2 j& W# @% Y7 G: x
/ I; L# T/ M9 y( y1 a. R! {MODULE_DESCRIPTION("Led platform driver");
6 X2 _ W3 h, G% p+ F" fMODULE_AUTHOR("Tronlong");$ _+ C# f' b+ n; a
MODULE_LICENSE("GPL");
8 ` H$ ?* @$ ]! D) [; I, `; t( \) \( A6 U0 g* m
|
|