|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! M$ k) Y5 K# F( H+ T#include <linux/init.h>
( B; y2 |( T w$ u4 T#include <linux/module.h>
k! d) x& w* c4 @2 t% X#include <linux/kernel.h>8 C% z7 y4 o5 a; Z8 H
#include <linux/types.h>6 m$ z! ^4 w( h( C& t4 |' W* y
#include <linux/gpio.h>
& s+ z& \& u1 a) W0 {#include <linux/leds.h>
6 {8 o, x5 A0 d" n- Q2 I+ h( i9 v% I9 r#include <linux/platform_device.h>) |/ X; p$ s+ c# y6 ^& @8 D0 g
$ D* g3 V; X D. u2 ?
#include <asm/mach-types.h>
' |" N2 O: j1 B: y#include <asm/mach/arch.h>( H' U7 f3 a* J! K2 L
#include <mach/da8xx.h>
. b2 a" T1 V, |7 ?6 C0 Q#include <mach/mux.h>8 O) u3 Q. _' `% D# H
1 w( w' E* l2 [7 P/ s6 Q9 E
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ n/ O ~& C. K. V, n+ k$ n# p
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. `$ D" B8 K! v8 _) Z" F; d#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) F& H4 e" \6 P: e
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 f8 A- h( m' o
# s8 a! [7 P+ B4 x/* assign the tl som board LED-GPIOs*/
" [% Z" e/ n; @; ?. b5 estatic const short da850_evm_tl_user_led_pins[] = {
3 E! r. Q: Z. E0 Z7 E: K/ m /* These pins are definition at <mach/mux.h> file */+ \8 F7 H# [7 X+ @4 L8 X' S# s
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 y; i2 ?+ m; C3 ?9 w6 ^
-1
& D& y& T0 e7 S# d$ k};
9 I( b$ w. a" `
B ~, a1 p# r- k, Fstatic struct gpio_led da850_evm_tl_leds[] = {
4 v: p( L# D) N {- U4 b+ ~7 @" [
.active_low = 0,
8 E- r+ r( H- H; `9 s3 I .gpio = DA850_USER_LED0,; ?/ t; x) u. _7 t: T
.name = "user_led0",
4 F2 d U P4 d7 h% ?$ H+ ^9 I6 j! P .default_trigger = "default-on",5 [$ W6 P. v; n& a
},: f) i' p* I2 w: n( k* w0 K- q4 y
{4 L) D9 h( j9 i9 r; h$ H
.active_low = 0,
- D9 x0 K9 H, n. b7 D6 w6 c5 z) g' o .gpio = DA850_USER_LED1,9 ~8 s2 `/ v% B. G
.name = "user_led1",7 |8 K# w- n3 Z$ X
.default_trigger = "default-on",8 y. j$ S7 [- J) y
},+ U# i S' X9 B( ?+ n6 I/ t$ \% L& t
{. C4 D+ I) V! S6 g
.active_low = 0,
$ X' X- z; K1 M4 I .gpio = DA850_USER_LED2,
, E4 J# ^ y; ]8 \. [ .name = "user_led2",
9 _5 k0 _0 ^: x: p .default_trigger = "default-on",
) l8 E6 O; K, k2 r& p8 K9 v: W },% A; w5 P7 U" p
{( \* k: u; x0 y
.active_low = 0,
" X! F- p; @% h: k" ?* I .gpio = DA850_USER_LED3,
9 O) Q2 [ V/ v) w .name = "user_led3",
4 a4 m6 G1 P. R" W .default_trigger = "default-on",
' h5 D1 Y* h/ K) g4 y },' N8 ^ W1 k2 s9 c0 @) b. |. V F1 [
};/ ]6 ~, s' ^+ v9 h9 g
: G- ]5 j L1 ]" W: y8 i% L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 G4 l/ F s% ]( G" o
.leds = da850_evm_tl_leds,# u9 f, q' b6 n, b% j
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! A% z* v0 _& d};
! ^! N9 D5 w; R2 A% N/ T- _+ \% P+ x+ g" e7 y
static void led_dev_release(struct device *dev)
+ j8 u) k2 Y+ m D! X) k Q{& y6 ?) _1 V) P: H$ a. |$ u
};
. k$ r# n/ C3 J' K) r6 h/ l, C/ ~, j; u( H/ e9 y
static struct platform_device da850_evm_tl_leds_device = {
/ r" e _' g/ C& z: c .name = "leds-gpio",
0 e* q6 e# t8 w2 k6 R& i9 y .id = 1,% V# t `) d. t; b6 t
.dev = {3 J2 @/ g: D$ Y6 Z
.platform_data = &da850_evm_tl_leds_pdata,# z: [) h% V) E: i
.release = led_dev_release,0 \: E! o- m6 U6 F8 F
}: |6 M0 |0 u* |7 G3 m
};
! @( ]; W; d& H) X: _( l |
1 g* Z/ |. Z3 L6 g+ u7 s" h- A3 [6 ?9 Estatic int __init led_platform_init(void)
l F; M. \2 d' W. l& C" k{0 j( N) U; E8 [) Q7 |; w
int ret;
+ g. Y1 f1 A3 j#if 0" e u" g1 Q; v
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 z1 z& y/ @0 M* C8 w5 o# V$ Z# p
if (ret)
# Q+ t, E; S Z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' `+ H' S5 j+ d) O "%d\n", ret);
% v; B1 Q' V0 p% w. K% d$ _#endif, _. S% o% B6 d2 N x& o
ret = platform_device_register(&da850_evm_tl_leds_device);
1 z$ J- s& x' |& | if (ret)$ H7 T! T% }) k, b
pr_warning("Could not register som GPIO expander LEDS");
9 @8 j* {3 q& T9 m' h- ~- ] else
" |* B5 y0 k' s, u printk(KERN_INFO "LED register sucessful!\n");
' V5 u# c! q& B; k) t5 H) ?6 c5 G9 O1 {) L0 e5 S
return ret;) h4 J* H/ {2 \6 Q
}
# \+ {' T2 l$ w2 T8 z% x! }$ s6 m! q3 T
static void __exit led_platform_exit(void)( Z( h: L1 f# A/ @
{$ p& W) D1 B9 E
platform_device_unregister(&da850_evm_tl_leds_device);( V1 s: z2 ^- d4 I9 R
7 m. H2 {& ?5 g9 O( F printk(KERN_INFO "LED unregister!\n");
* A# D5 \& _% V2 ~( t Y# L) v}5 A- j2 v* D5 E( p
+ p, @8 B t# Umodule_init(led_platform_init);
6 C* B0 k1 q, \: smodule_exit(led_platform_exit);
+ T/ q+ A1 M% Z& J; W/ K* b( j3 P
( ~# Q" `" s+ AMODULE_DESCRIPTION("Led platform driver");6 x) r I& n; H; k. J: j
MODULE_AUTHOR("Tronlong");
( e: {/ x# @4 O6 KMODULE_LICENSE("GPL");& u. ~9 T* ]4 g8 u4 g/ q
! ?+ ]. c+ T8 s
|
|