|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 ?: U( Z) M! G! Q# ]9 J#include <linux/init.h>+ I7 \; s* A/ _1 C: u+ S2 ~
#include <linux/module.h>
) p: @! X) E$ @0 P. p#include <linux/kernel.h>8 s) _% D8 d# a. K
#include <linux/types.h>! k1 R0 S/ i! g/ d0 {( M
#include <linux/gpio.h>
" _0 R8 [1 q; u Q ]/ R" f#include <linux/leds.h>
" h) f6 O$ x" ~! U6 K3 a#include <linux/platform_device.h>
6 j' m+ \7 r- @+ N& c8 t. \
/ z( i$ J6 z7 @* M/ _#include <asm/mach-types.h>
" ^, L* m8 q6 B' Z#include <asm/mach/arch.h>
8 X/ R/ v2 b( | p! c) b* {#include <mach/da8xx.h>6 _- k$ u* o2 C, E
#include <mach/mux.h>
" P% T8 w/ k% Y/ M# B- \1 a5 ]. P- Y# N/ G8 ~+ M X' Y" ]! b3 \& H( \
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ J" T8 j* z. d6 g* u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: J ?0 N+ Q+ J9 P#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 B5 f% P/ n* q* r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 b6 }8 _# k' R1 R* D. y6 h
" [& _# n2 a" p* I/* assign the tl som board LED-GPIOs*/
/ ^/ h8 S" h: f& G+ v& xstatic const short da850_evm_tl_user_led_pins[] = {% A8 F6 y# T6 F, p( ?$ e; P
/* These pins are definition at <mach/mux.h> file */
; u$ q6 ^2 j( n. L& }5 w DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) ^( T" I; r2 W$ _
-1
5 \$ O5 f; V5 l: j3 R0 D9 F3 v};6 }/ A2 J( G* K. `# E9 ^+ W
# w+ x) J" A6 t; {1 Lstatic struct gpio_led da850_evm_tl_leds[] = {
2 `; l6 P- \+ n) E {. f% ?) E& Z4 P2 i9 o0 ~
.active_low = 0,
1 Y, O& l$ W: f4 @% S/ X .gpio = DA850_USER_LED0,2 S0 x* Y( @+ h6 o3 I7 O, x. P" N4 Y
.name = "user_led0",
% K) n, H; z+ \ N% J3 J( | .default_trigger = "default-on"," N) v/ ]4 G, E3 b
},
# J0 ^7 l$ h( s( {5 _- p {
# y8 e* i2 z$ V1 X. s ^ .active_low = 0,
+ _7 V$ e% a# G9 o6 } .gpio = DA850_USER_LED1,
( s# W' W4 z, Z .name = "user_led1",
& e* P# f0 n* A, F, s .default_trigger = "default-on",5 R5 d. d( _$ ?0 u
},: a0 _# C D% _5 V7 I
{
) }. W1 C" f4 t% t3 p. Y .active_low = 0,
x% Z6 D1 x0 R8 { .gpio = DA850_USER_LED2,
1 s, `* D, z3 ? .name = "user_led2",/ q! h/ l1 u1 L1 j( w# p0 H
.default_trigger = "default-on",) a, j$ F# r [, S3 Q# q8 b% V
},( E% G9 y9 @* N; U- B, i
{2 m( Q, V4 o) `' Q6 L
.active_low = 0,% U+ U+ x6 N4 s+ O r
.gpio = DA850_USER_LED3,
4 T2 f) J r: }+ m .name = "user_led3",9 x D b# U( k. X6 g2 {6 a
.default_trigger = "default-on", H9 c$ F0 ?- a
},) V5 Q2 }6 P+ h6 X, Y, s0 X
};
0 D, p+ j/ P# X g, a# u! Q. s' E( P' \$ @9 U! J* Q: v; f9 [$ H* A
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 @2 S) ?9 X) [/ T .leds = da850_evm_tl_leds,
" [- q4 @. |) x# s, q: s .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 {) j7 l7 p: e8 t1 K4 L};9 Z3 d4 c+ o3 @3 X4 R) c
q$ p1 q. _9 x0 P* u# g
static void led_dev_release(struct device *dev)" {* M) r( F/ c
{
l' Q; T# ~$ d' \" f};1 k9 b2 |* k: M% g
& |7 F, ^2 M8 v4 W( J7 V, _static struct platform_device da850_evm_tl_leds_device = {$ {5 k0 [& ~8 l
.name = "leds-gpio",- r" j3 v: L- H$ c$ R3 \
.id = 1,
+ }; o2 F" t0 m9 _( U% A9 p .dev = {
0 X/ f" P0 J2 h* ~% F3 ^ E7 F .platform_data = &da850_evm_tl_leds_pdata,. W/ W7 G, ~# y
.release = led_dev_release,: S' i4 A/ Y1 W$ K; M8 L
}
% F6 p! J2 X2 i};
5 i& n: } c. V7 m3 x* m+ I6 h0 K- {3 V; m5 c8 G: ?
static int __init led_platform_init(void)- Y: I( b4 ~8 ]/ k6 p
{
0 w3 V% _! k, a6 p$ E5 \& { int ret;
8 K e- T( t& s( C! p#if 0" Y% N7 m& j8 R, v
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ P+ b+ C8 Y5 L9 q4 V3 x if (ret)
2 w0 R& b; L: G5 ~4 E+ {" n pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 H& e7 N6 `8 l8 } "%d\n", ret);
! ]- P. }5 A+ ?. ]& o; Z#endif
4 P) X A! w/ u) ~( Q ret = platform_device_register(&da850_evm_tl_leds_device);
$ Z2 I: U4 d# R if (ret)
, P- d1 {$ s) ?* D; C) T2 I' v pr_warning("Could not register som GPIO expander LEDS");
% C+ L$ n8 B& y7 }) k" S/ O else
- L J+ V; z5 s printk(KERN_INFO "LED register sucessful!\n");
* }! ~* s+ b5 u5 G# d
! Y) S. b4 u9 K/ ^, s return ret;
* d0 e; o; W/ l2 g+ f}) u2 X# r6 J- g" Z9 W
% W2 ]) F4 e. ~' W* Hstatic void __exit led_platform_exit(void)5 V/ e I- A' G
{( D- A) D' q- z, i& j2 D
platform_device_unregister(&da850_evm_tl_leds_device);( l: Y; f, Y$ X. G7 C/ ^. {- a
8 N, S3 F1 l2 r) ^2 p
printk(KERN_INFO "LED unregister!\n");6 n3 w2 [& O0 N0 K5 Y3 }7 ~- @
}
+ @! U( x! q# m# f$ ^4 R; x' W9 G. Y! ~
module_init(led_platform_init);
, d7 U& w$ \% {: z0 t2 V1 Imodule_exit(led_platform_exit);7 K) Y' w6 S$ e$ s* T
, F3 V4 B- _* L1 H5 [& W; i
MODULE_DESCRIPTION("Led platform driver");
+ W% z; r& D6 K) U N" T0 aMODULE_AUTHOR("Tronlong");
. N' j- a5 z) J% M; oMODULE_LICENSE("GPL");9 F2 \2 d$ R* \- m% q. R o* R
1 m t& x$ s" R
|
|