|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( l& s6 ~7 H5 i( w2 H: y- E
#include <linux/init.h>
, j m, ?; d+ z. I#include <linux/module.h>9 m. Z. U$ B$ d3 p
#include <linux/kernel.h>+ Z/ {! h+ r# ?. T/ e- o& }/ z0 H
#include <linux/types.h>
2 ?9 _- E$ n6 r. N#include <linux/gpio.h>) S* a: R4 s0 C8 R/ \& X
#include <linux/leds.h>
* I3 W/ @, S+ B6 r6 e#include <linux/platform_device.h>
4 }8 F/ X$ E1 _* J: n: M0 U2 v
( Z) B; R+ @7 ~( @$ d' Z% _#include <asm/mach-types.h>/ l- b; m# ]- a/ y: p
#include <asm/mach/arch.h>2 P' q1 H6 T# n3 e
#include <mach/da8xx.h>2 T6 X9 B& L( j6 W4 J
#include <mach/mux.h>. |6 F9 `4 V7 ~6 |9 n- q
/ j) G( {9 ~$ ^! o8 H4 ~#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% N9 s7 ~: Z: t% y2 k#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 v! j! g$ d7 N' y6 ]: k: u
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 I' i! Y$ U) Y) ]3 s7 |! A5 B9 ~#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 w- E* ^, q% K0 g( M7 B) o. b
+ J+ E- K1 D8 L( X/* assign the tl som board LED-GPIOs*// N/ w t$ R, r( q2 u
static const short da850_evm_tl_user_led_pins[] = {) {( C* m0 p E# u; G" M% c
/* These pins are definition at <mach/mux.h> file */
. V2 T+ m# T, |+ a0 {5 L, b DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
E! N9 ~# F G0 I: U -1
% F2 a: y5 G: Q3 O+ {( B};
" K& C8 z2 q: b5 }) }% `
0 o; R( L* d7 R m" [3 Ystatic struct gpio_led da850_evm_tl_leds[] = {
# F/ ]" D* V2 X, P) v8 b2 T$ P {; p4 c$ |1 o" b1 o
.active_low = 0,2 c* F( ], v% t1 L% B% [
.gpio = DA850_USER_LED0,/ T0 u8 X+ p1 K
.name = "user_led0",
. t/ O' G2 l3 X: ^ .default_trigger = "default-on",
}$ g' Q( N; \. h },
/ _( B0 m; }2 D6 L1 o% p( ^( I {
5 S" C' L0 n' l2 \ .active_low = 0,
0 c9 n8 O# O6 S2 [( ]; u8 l .gpio = DA850_USER_LED1,/ \' A0 Z) |2 I8 W
.name = "user_led1",
) Q) l: _+ l9 x8 N% l \+ A .default_trigger = "default-on",: \& e5 V; w/ g5 ?
},6 z P1 r2 X; @3 v. S0 y
{
- }, }1 \* |& E$ U- f% {3 f( N5 Y .active_low = 0,- Q3 D& M. H* X1 d# U; @7 }
.gpio = DA850_USER_LED2,# @. ]6 M+ C0 a4 Y$ z
.name = "user_led2",5 U& [; g+ i. _: v3 b
.default_trigger = "default-on",% t- U7 Q1 D1 D7 E; M$ }3 z
},* @8 B( ^+ V3 ?
{9 _9 ?2 ~# d, W3 A, f ^& m4 |
.active_low = 0,
' m+ @- K2 I) E' P .gpio = DA850_USER_LED3,
7 y9 K& }( }- k3 T .name = "user_led3",
$ b3 r9 O( f% r* A3 `9 f2 q .default_trigger = "default-on",! ~9 C5 l: n% @ w1 d& G
},/ B" C m6 }* V& u
};! A! z. o. D6 X) N6 r
: H/ ?7 d6 t9 m5 S% n0 Nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: {. d5 [& O$ |, }; W* e2 \% {
.leds = da850_evm_tl_leds,
+ ^1 b: N0 G5 |4 _ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# Z& U/ F E2 W2 b
};
+ x L4 p: s4 x: R! o: I( w. @0 V6 J8 G, i x
static void led_dev_release(struct device *dev)
, C% R k: {$ y/ S{
, Y; Y. t$ h- b: k* f# C1 f, \" u};
`1 U; y8 r, u
9 K* \! O2 Q- M; i9 O5 Z6 bstatic struct platform_device da850_evm_tl_leds_device = {6 ~' u! |% y4 f& c! c
.name = "leds-gpio",
2 y& X2 S5 Q [ z, u .id = 1,% `. p5 Q7 t4 L2 ~) K
.dev = {
+ s/ A4 _. n" |1 g k7 H# [5 y( G .platform_data = &da850_evm_tl_leds_pdata,3 i9 {8 J# @& G
.release = led_dev_release,3 ^+ I K: x" H+ p8 x0 J
}
6 ]1 f! \( m! g" n$ C, @, e};
) O8 ]7 y% e' O3 ?( _2 K/ u5 k( s
static int __init led_platform_init(void)
1 p! Q4 `% c: ~{
# X# n4 b: z! k* D1 d4 | int ret;
) Z, [9 l2 s3 r8 }#if 0
% D: L% b% F c! n2 X0 | ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- j5 N2 C. o2 y0 S
if (ret); T& j) w" N# q0 H3 P# w* B, t- y& e% @
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' }5 t2 {9 ^2 B" _/ o
"%d\n", ret);
: l0 O% M6 I, V0 V#endif) H% T+ e1 R9 l0 b
ret = platform_device_register(&da850_evm_tl_leds_device);
- F( X* a# w% K; N; w1 c if (ret)0 H% w- j* P) U. s6 o
pr_warning("Could not register som GPIO expander LEDS");
8 ]$ C6 J1 F* {8 _* t, W- Y else/ v: A! ~, U' H1 W: s
printk(KERN_INFO "LED register sucessful!\n");' v+ C0 _& B+ y1 B R% E
1 n% j1 u' q( c6 A
return ret;
% |" B5 p' _) r6 w}
4 g0 e# |; H$ r$ B, B
) z7 @1 `4 b- {static void __exit led_platform_exit(void)- w6 j+ U6 h( i1 }
{
3 t" w7 N4 B* U7 m platform_device_unregister(&da850_evm_tl_leds_device);2 N. Q' j% x, _: m0 H' m: k* v
5 R/ X. g) `& m6 r3 _+ T printk(KERN_INFO "LED unregister!\n");: i# v4 z! [' Z8 o7 @
}
( Z" R1 s/ h m3 a0 |- {2 E: @2 [ p
module_init(led_platform_init);
7 J6 F) P: z0 }) P. b& Smodule_exit(led_platform_exit);' I7 B+ y7 w2 f5 x& F. C
$ I9 e8 i: u+ N" r. y
MODULE_DESCRIPTION("Led platform driver"); z% |' l8 |7 v: l0 ~8 V
MODULE_AUTHOR("Tronlong");
8 } X" S8 W# x' r' @) C# q. n3 C$ \( bMODULE_LICENSE("GPL");9 c) I3 P$ u, L/ n8 W5 Y- m
4 p- S6 L% d) W4 T& N7 Q% Q
|
|