|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( g, G( A% _4 s/ P9 w! ]7 r* D& V
#include <linux/init.h>
$ F8 M( s+ ~$ C4 o! J#include <linux/module.h>
2 Q( P$ G* ^0 ?7 j& C2 y#include <linux/kernel.h>5 x# d2 K& \! z. L# N
#include <linux/types.h>
9 n4 f0 [7 E+ n6 ^& l* x. G#include <linux/gpio.h>
6 c% G3 F) I, }9 c2 p4 E#include <linux/leds.h>5 p/ \2 V" U3 K* ]* W4 H7 @
#include <linux/platform_device.h>8 K8 v2 B) s1 {( @5 b; V) o3 E$ s3 ~
: k4 M2 T( }( g0 r#include <asm/mach-types.h>
3 E- p! r2 \, N; A1 t" C0 K#include <asm/mach/arch.h>% w+ `1 ^8 c, `# `
#include <mach/da8xx.h>3 y; H: @: _" |2 M
#include <mach/mux.h>
% m% x/ w e4 f& M6 r b2 e5 ]
7 H# e" K5 j |! i#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& i( u! S6 {( q! g( I& U0 }
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# I1 M# c. D& j% U/ A# b$ t) I#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 D: Z: V" u9 ]; D- H
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! U/ g" b8 Z) y3 }. q, C
$ V$ H5 M5 `3 @- a6 |/* assign the tl som board LED-GPIOs*/
# v7 {" H; _& _' o4 T' P) sstatic const short da850_evm_tl_user_led_pins[] = {
1 _* o* J9 w- F- W /* These pins are definition at <mach/mux.h> file */
: o& e) B2 d! @- F; D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 M' W; |: a( E w -16 A" k, X. q! n0 i7 h
};
# g, }2 ]: D5 y% @4 c
' R( E' U' |0 y4 d3 C+ }6 estatic struct gpio_led da850_evm_tl_leds[] = {/ A- t& i; ~& A# J' s) K$ ]
{+ ? g6 y4 W3 ~& J: k9 V8 A/ l
.active_low = 0, _( A+ o1 j& N& |9 f% J6 `7 c
.gpio = DA850_USER_LED0,+ E( z {5 X( Q/ q9 l' N+ z
.name = "user_led0",6 k8 E7 F4 h; M! o
.default_trigger = "default-on",! w; S! ~) n* ^' a: a* C4 o" U
},
, K& p/ z/ M# U; v3 T. g8 v {
& e. A+ V5 \' ?6 p4 u V .active_low = 0,& P0 c1 D5 Z: F9 y7 S: k( ]' h
.gpio = DA850_USER_LED1,
& F. K# I( t4 e% B: \9 R, h2 [0 t8 k .name = "user_led1",4 h7 Z& z/ j1 g( l9 A! @$ D
.default_trigger = "default-on",* m4 X1 b: [; X4 v% y) o' D* D
},
, m* ~0 `) J5 N% b: L' n+ Q {- v* n& L0 q4 T
.active_low = 0,1 d) V i1 o: S' x
.gpio = DA850_USER_LED2,
0 A: L6 t6 }; q# J8 b .name = "user_led2", L1 [4 D$ R) p
.default_trigger = "default-on",5 M- c. r4 I9 {4 o/ a3 v5 w4 L: |
},
" _, Q; x3 B6 R. Q2 _! _0 a {. m$ \! h' K0 a* P) U3 d4 {0 s
.active_low = 0,' \9 a4 s5 A+ h5 R9 o+ V+ G
.gpio = DA850_USER_LED3,
* y c( Q0 P, c) B+ T .name = "user_led3",% e" ]6 v E/ C& I1 \
.default_trigger = "default-on",
- A! r/ Y. _& H# u1 D },' i7 L) N1 Y; H: S& F0 L
};
% _' B* V) C0 I" p Z3 u
4 m: S6 V8 v& kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
b: D4 n" \. m" o. E .leds = da850_evm_tl_leds,# ~: S4 v; C |0 Z0 W
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 o, V7 ?. ?6 S
};% k% w5 r' n8 x! N
% Q. c! B- C7 ~; u
static void led_dev_release(struct device *dev)6 ?3 e& L5 g2 O9 H5 u) }; d
{2 M" f: E; v) q. X. x4 ]
};$ u m# l2 z, v. q( [- o4 m! d& e
" G, K" U- g: a1 @% t- D
static struct platform_device da850_evm_tl_leds_device = {, m9 E1 }/ r" B- v# r
.name = "leds-gpio",
) L* A; o& |' _; _( \ .id = 1,
* k# p# ?/ r+ j0 p5 t7 B' w& L, D .dev = {
5 ~& `/ J( Y! K .platform_data = &da850_evm_tl_leds_pdata,
; o0 v; a. W3 m- O- n, n .release = led_dev_release,. P6 E, \6 @# Q
}% x% G a" h3 y ~8 L1 E& R8 S
};
' s. Y% [* Y% T' V; Z$ p
3 Y* ]) B5 \: F! J0 S* jstatic int __init led_platform_init(void)
" S! G3 O) ]! R' b2 s{9 E; H! t- y5 B! Z
int ret;5 I; C* f* Q5 X, a- _* j% k
#if 0) h/ n) ~% h1 G6 F. r; t# O- R2 m
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) b; d- M) x! f7 o+ E8 [
if (ret)
5 ]6 X) z4 u5 ~7 m }3 k* V8 N2 e pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- ]; D- t% q! W# C, k
"%d\n", ret);
7 q0 X' }0 _0 s* Q$ D, Z#endif
: B* O2 \: G0 j$ f ret = platform_device_register(&da850_evm_tl_leds_device);) p: ~+ W8 b. e9 h% Q
if (ret)
$ O/ v1 n7 i; n2 } pr_warning("Could not register som GPIO expander LEDS");
1 m8 m' X1 e( d' E: y" G& T else. \, |. M7 X9 w& j+ B
printk(KERN_INFO "LED register sucessful!\n");+ h& z: e- h3 r5 }
9 W" ~9 g2 Y2 h; ~; n. {
return ret;6 T6 g( o; V( j
}
, \( A9 \: }/ @2 e3 S) L. Q" Q
! n4 ~) o- r" S( ` wstatic void __exit led_platform_exit(void)1 d; H& i* }0 k6 W* Z
{
8 I$ \5 c A! v, Q! Y platform_device_unregister(&da850_evm_tl_leds_device);; v: l% n% T c$ p0 K- Q
, ^. l' b6 l0 G$ H ^% b% } printk(KERN_INFO "LED unregister!\n");
2 Q2 l1 t3 k: w, }* E}
$ q. D% w9 J: G, N2 `0 Z9 O5 M. l& P* _ D, X2 M; W( D
module_init(led_platform_init);7 |$ j. v, E& _# [- C3 c4 L! [
module_exit(led_platform_exit);# A" S. N( T9 Q7 c$ s
1 c( H5 k" J; _7 D1 s
MODULE_DESCRIPTION("Led platform driver");/ e8 A" N ]" K% I- i3 z
MODULE_AUTHOR("Tronlong");
; ~# Z; f' A# ]2 L. u1 QMODULE_LICENSE("GPL");
9 V4 e2 l0 U* N: u2 f% z! y
$ D9 {5 B) w# i$ Q' ?2 `* M |
|