|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 N: Y9 h' {( ?/ l7 Z#include <linux/init.h>
& ?4 E* P7 M$ L#include <linux/module.h>
4 s0 f" `' C: s#include <linux/kernel.h>8 s' S& j0 }+ O
#include <linux/types.h>. K- a" k, w4 _5 V& ]* e" Y8 [$ M
#include <linux/gpio.h>
5 G7 a. {6 S8 ~# ^6 {" C0 F#include <linux/leds.h>9 D6 k1 _& X7 z6 D: L* Z
#include <linux/platform_device.h>( ]$ @8 l9 I2 v0 g2 A. J, k
( \$ e7 T2 g( |. ^/ y ~ _1 O#include <asm/mach-types.h>
/ `; Q0 {6 |8 Y6 _8 G$ F. B#include <asm/mach/arch.h># b2 i" ?- w' ~8 ^$ n% J& Y
#include <mach/da8xx.h>, Z- s \! s$ q# `+ ]: d. X# {
#include <mach/mux.h>
a. T0 q& j F# L4 z! F& O) \ F( u
! e+ ?* i W5 s5 b' }1 B7 p#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- r1 Q- M& c$ d9 O& A4 Q9 k" }
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 ~4 U' B, r) |7 l2 D) Q8 {#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- `5 D) }" k+ T" O( f. N
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 Q% n) G |" P% H6 N- d; j( [
! i6 Q Q2 j9 d+ J/ A' Q3 z" ~3 `/* assign the tl som board LED-GPIOs*/2 p8 \ Z1 A0 r- a B1 W
static const short da850_evm_tl_user_led_pins[] = {
3 P6 B) J, k2 g: o /* These pins are definition at <mach/mux.h> file */+ s4 S3 ]6 R1 u/ `+ K) F. t
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 F2 V1 I' X+ i( U5 y
-1; [/ J. J$ h# V5 D; x$ ?1 t2 V6 g; o
};5 y9 x. m$ J3 _ d
/ L! p5 r" [' \2 p& P( _static struct gpio_led da850_evm_tl_leds[] = {- Z' C) _7 M+ `/ V" N+ I
{% ~2 p3 q+ J8 ^& U! [* L
.active_low = 0,
3 t# [5 Z9 M3 S: d) z& V# V( q6 t .gpio = DA850_USER_LED0,
& f/ m, K) q: ]! B .name = "user_led0",$ h1 r9 A9 x8 L! d0 v' @8 ^7 i
.default_trigger = "default-on",# M0 _) U2 u3 J4 n4 V2 _
},/ [/ V# M7 Q Y3 g. j5 s# {. k0 z
{
2 y3 I: Y1 m( c, t, l( f1 R' w, U .active_low = 0,
( x* `3 @9 Q9 f& |6 k6 p; o3 a4 z; J9 @ .gpio = DA850_USER_LED1,1 X; N% ]+ S- G
.name = "user_led1",5 v) I& i" r8 f2 F) `8 E# H' k7 V
.default_trigger = "default-on",* x9 C0 w( T! }* ]
},1 K J) h8 x g' A
{2 O1 b" y1 U1 ? i
.active_low = 0,
- R0 ~& n) @6 O6 k4 B1 g' H6 | .gpio = DA850_USER_LED2, ]$ ]% w' F1 J, s% A; d0 J
.name = "user_led2",
" A* }" i1 c& ^/ G! \$ k2 T4 j .default_trigger = "default-on",
. V" }7 s3 J% w0 r6 Y },
% v L# Q# ]2 e1 L' }/ `4 I {
1 O! b5 L' l( F" W2 u+ } .active_low = 0,
$ L7 I9 X& Z1 A, ? .gpio = DA850_USER_LED3,
; t" k2 k; h6 x& J; y .name = "user_led3",
( d, w2 u7 S' a9 l( D .default_trigger = "default-on",
* x9 s$ S, x6 U) X },
0 h5 @; d( ?( _};! A( S7 N" K/ N/ l
. ^! C. I; |1 J* u4 e( e7 Q! w# w8 {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) |& `6 L' e c0 p% D4 g6 W .leds = da850_evm_tl_leds,
, h, U+ ~. ~0 h% T+ V; o: O .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 I8 x0 y6 Z {& |* l7 ?% j};
' r; t+ t4 Y" Y- C) E' O# y
3 y( z: G# y9 ]3 Vstatic void led_dev_release(struct device *dev)# E/ Y8 X* S* r! p0 e& P2 T1 m$ s: R2 |
{
' F' p R- ]# h, e# \};0 Z8 k9 Z3 b- Q; a' Z+ d" Z) h
+ t. N5 d' F$ f* W
static struct platform_device da850_evm_tl_leds_device = {
. g- Z. s( e# j, I- f+ q5 R .name = "leds-gpio",
% c0 h7 o% g$ g* I( K .id = 1,* L) E/ _. q) E! p; [" N. A
.dev = {
& E5 V" q5 ]+ q3 n. e# m9 g; ^ .platform_data = &da850_evm_tl_leds_pdata,
: E6 b/ o9 F% w' r1 F$ s8 D% ? .release = led_dev_release,
5 i* o, J8 o8 [' s3 o }
4 s+ Y' p4 p p7 K; T% L};
( |$ F3 H1 I9 s$ O/ o% Z( I7 o- J9 R0 @! `; q2 H
static int __init led_platform_init(void)+ B6 Q5 b6 E: w
{
# t( J+ l! p3 ?/ ?) ? int ret;
# P# N0 r, ^ k1 k S; d#if 0
' Y* }7 w; z: ?7 H0 H ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 U% R: b2 g6 d, r9 Q if (ret)6 {! F1 D$ o" y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 o! \+ B: V5 X3 n* z7 z3 A
"%d\n", ret);9 L; M8 J" y4 ^4 k9 U
#endif1 l, u3 d0 r d @! _9 |1 y
ret = platform_device_register(&da850_evm_tl_leds_device);- y/ J' a+ u( t, q; ?- a
if (ret)6 R: k) R/ `& F
pr_warning("Could not register som GPIO expander LEDS");
% G8 i( a) S* n9 E6 f else
7 E0 M+ K! x- O4 `# R printk(KERN_INFO "LED register sucessful!\n");- Q: x4 n+ m/ N$ ]: u
& H, n( S) F' Z. \0 U return ret;5 y2 r3 s6 N4 e" N; U
}! Q. G6 Z' W4 f( ]! D0 E+ k
0 E/ N, P: l; e+ _static void __exit led_platform_exit(void)/ w5 v" f! E# h5 h, ?$ a$ `
{1 C9 d o1 J8 ^' M5 m. J
platform_device_unregister(&da850_evm_tl_leds_device); h4 k, c: d2 |: Q( k
2 _9 J2 x/ B/ ~! I! g2 F
printk(KERN_INFO "LED unregister!\n");" n$ b7 h- w3 w/ Z/ J! i9 F
}; f! T4 w6 @) k3 z. c
. Q3 t$ s& v6 Y; I; @- m
module_init(led_platform_init);
& g% Z, L" B8 |2 D& Kmodule_exit(led_platform_exit);
- I8 v5 L. l. B% @, L1 O& V5 s* Z6 i0 j) d3 Y; Y
MODULE_DESCRIPTION("Led platform driver");
4 u, C1 _4 W; KMODULE_AUTHOR("Tronlong"); t0 q. i6 h& ~% k5 W0 p: B
MODULE_LICENSE("GPL");
& s' g* B: P4 e4 l; b2 c1 _
( [4 f8 Z3 R* r( P, Q( D3 p8 h3 S |
|