|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 D8 j8 R+ A1 s6 g. c: o Y#include <linux/init.h>
: f% ?: O1 t0 \- [: R#include <linux/module.h>5 F$ t# ?( X* B. x, W
#include <linux/kernel.h>8 @- G$ Z1 }- [ P
#include <linux/types.h>
5 [/ J+ \2 K! x, n* @% c0 Q#include <linux/gpio.h>
9 W) t1 r ?, X8 E" E#include <linux/leds.h>: P' e h _6 ^. g
#include <linux/platform_device.h>6 ?6 E0 j( M6 k. k7 B# D
) k0 v: L R$ h. q) q
#include <asm/mach-types.h>
" j3 O* o+ o( T6 W- t#include <asm/mach/arch.h>5 I8 h% U7 F9 p' h! q4 a9 \
#include <mach/da8xx.h>/ R3 @, u) C% a" m4 Y6 `. A& l
#include <mach/mux.h>& y" \3 Y, |, I1 Q" Z
4 \$ o7 E1 F7 |( G. B: H3 R
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 W* J4 u: f3 K2 s# Y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- ?# Y, O. x1 X+ ^- @3 e
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 D) c7 p( q1 c- X
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 t0 y6 P, e, U' J/ p
5 c: `5 M6 o% C0 I6 m# x! G/* assign the tl som board LED-GPIOs*// W- ~$ q8 t3 g2 ^; v& L- o
static const short da850_evm_tl_user_led_pins[] = {
# U& |( P, Y/ E f" i$ T2 A2 J /* These pins are definition at <mach/mux.h> file */0 m/ G. N( @2 ~% T5 n
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 K- k) F3 C) M- I: @) K -1
7 x0 F8 D0 e2 M5 |& f3 o" t};* m: {+ [8 |+ l, l' l" m0 W
: m) j$ F7 D/ {3 w1 Qstatic struct gpio_led da850_evm_tl_leds[] = {% G: g* ]% _- _/ S) y) d. M& B
{
5 A- [) e2 R% |! r- T .active_low = 0,
7 n: S& \! z0 }/ H$ O! P7 P1 K+ T .gpio = DA850_USER_LED0,
" j( _- s% v% k2 s2 F, S$ R .name = "user_led0",3 P6 N; }0 B5 ~$ K
.default_trigger = "default-on",
& l. Y8 v% p. ?" V0 ~ },' B% B9 ~, i) V9 U" g7 f; w
{
7 h& M* b! Z' s- I9 w& E \9 X .active_low = 0,
! w1 z4 }( v' u( D, Y1 F .gpio = DA850_USER_LED1,& R9 M4 c: n, j, G3 V! p
.name = "user_led1",
/ c2 [, E4 R- A1 s! [, y .default_trigger = "default-on",3 d3 ?0 {' i- A
},
8 h2 s6 ?( @' D5 K: G9 L {
/ F/ {9 K. T0 g6 A$ H1 d .active_low = 0,8 E/ x' B4 `8 L; q$ u. o
.gpio = DA850_USER_LED2,
) X4 a2 | F& J- Z3 [4 H9 i .name = "user_led2",+ {( L% u0 s! Y% O R9 m
.default_trigger = "default-on",
2 X x' w6 H& {' g },
( r2 S+ |$ V5 J; D9 y4 C4 a, C {
. r( ~6 d9 z5 { .active_low = 0,
2 z. E5 X3 s8 ~! ^ .gpio = DA850_USER_LED3,0 h0 L/ N. R4 F$ d
.name = "user_led3",
& ^4 l& W7 f& [+ r9 j .default_trigger = "default-on",
& g$ U, S+ E( C; Y+ P },' ?: F; T) S0 I4 r
};: J' P9 K! Q/ N. P0 x
" ]) E S, D2 Nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 p% P, g* l7 Q) ~6 u% A
.leds = da850_evm_tl_leds,
+ r$ l1 K: B; {% E9 ? .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, m, K. r x3 Z1 I F8 _/ ?};
6 B+ `# g5 `; v6 F9 W% l1 D5 M* f" l5 n
4 q3 _/ U; V+ {7 k' s6 Ostatic void led_dev_release(struct device *dev)# }& K/ {9 \( Q" M/ } `, v
{6 V* r9 l) _8 l5 r- K, D
};( ~4 h2 f( R2 d( K: p% k% f
8 u+ {- \9 S% ]/ Astatic struct platform_device da850_evm_tl_leds_device = {
! j0 a* [- d! c8 v* o% _6 e3 N6 b& F .name = "leds-gpio",
' X8 p( E, L: a, e) e% w9 } .id = 1,. t o$ A( R0 _# v
.dev = {3 [7 }4 y: }: Y& a G# C
.platform_data = &da850_evm_tl_leds_pdata, ]& k& ~0 b0 F. c4 {% h3 d- q
.release = led_dev_release,
4 v: B4 m+ ]1 |+ |, X# O* d }! y3 L1 B' a6 C$ y% z- n
};
1 b& k0 C( m* o
( L. d) h0 |0 I8 F/ D Cstatic int __init led_platform_init(void)
2 ~8 R4 M5 F" P) L. ]{
0 Q. V" d7 V, { w0 N% N _ int ret;" k3 ^+ b( Q; L- L; l
#if 0& d+ s n: {- h
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( d4 W1 k( } `& ?. h
if (ret)( j2 R5 W4 k; v, q9 ?- k5 o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 P9 Y! j; @) W8 g# T
"%d\n", ret);
) b9 N' c9 ^5 a#endif
3 ]; X/ X7 f5 b( M/ ] ret = platform_device_register(&da850_evm_tl_leds_device);
9 ~: k( C o& b0 b7 @+ S if (ret)
# z; Z" t, u" L" o pr_warning("Could not register som GPIO expander LEDS"); d! { C+ f; e. j
else3 J4 o& B, J& B# I( ?+ \
printk(KERN_INFO "LED register sucessful!\n");
) \1 c8 C* V( J' B% _3 d$ y2 y2 N
6 M+ }& b. n3 c/ d2 F return ret;) ^7 d }( k. W5 S) x
}
# U% t7 s$ @& y2 V3 |
* p& L. y* p7 U' w, q; R/ jstatic void __exit led_platform_exit(void)6 u+ v5 l0 P; s; j% Q+ j
{) H: E/ ?) i. s
platform_device_unregister(&da850_evm_tl_leds_device);- t; h& _) n+ p. q+ E. @% ?' N
0 W* b; S2 @' h
printk(KERN_INFO "LED unregister!\n");4 `3 G+ l: H, E# S3 `& t" i
}- u2 j0 h6 Y x; @, A( l# f/ ]
& q+ G5 Y7 I' w( tmodule_init(led_platform_init);
8 H0 t8 q# e& c# p# Dmodule_exit(led_platform_exit);) V. V* e1 R/ k: o8 v$ w
$ @0 i Y# x5 KMODULE_DESCRIPTION("Led platform driver");
; r5 ^7 \* Z9 q) |, E; Y g+ ^8 aMODULE_AUTHOR("Tronlong");2 K+ X) k& E4 B( {* p
MODULE_LICENSE("GPL");: s$ G2 f* z& H' D- a7 n
6 ]8 y% x r4 ?% H" @4 N3 b: A$ ?
|
|