|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 K: t" m6 P3 t9 U. p& }) H* H1 h9 h#include <linux/init.h>
+ L/ _1 L( n0 f: g#include <linux/module.h>
) r9 O% S V5 c$ b% F#include <linux/kernel.h>
- R' x5 O" e" e#include <linux/types.h>5 t' r- f$ P( ]" Y" H; P
#include <linux/gpio.h>
3 s. f. w# N& q* E h5 M5 J9 R#include <linux/leds.h>
$ x+ N* L' o& z' ?- C$ \#include <linux/platform_device.h>
% B; K) Y9 I }5 M
9 s& H5 f9 }+ U#include <asm/mach-types.h>0 z) `9 T, T# q+ U) x; E
#include <asm/mach/arch.h>
* z; ^8 n5 P( J9 U#include <mach/da8xx.h>8 ?6 ^5 `1 k6 z7 e6 n% R( c' A. g9 e
#include <mach/mux.h>- w, ~& ^; P9 m/ @- _) k) m" w$ n
% n) F/ s; d: z% E; Q! U
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% w$ [/ y6 V1 Y8 u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" j! X: [( d* S* r( T) f#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) E, Y9 M; E$ Q7 u2 J) E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 s$ j/ }; j4 \2 }2 t
1 O, G; o8 z# \/* assign the tl som board LED-GPIOs*/
& Z' F8 P6 y( r. o3 _- Sstatic const short da850_evm_tl_user_led_pins[] = {% b6 e9 p2 P+ {- r
/* These pins are definition at <mach/mux.h> file */
) Z3 F- w' d5 k, _& ~ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) f( N9 @4 S- x -1# B! |- j- {% Y' W2 d' Y
};! N' h, p$ w- y% d2 n
2 j6 Z! `. X1 a$ K0 W& c7 @ D" @
static struct gpio_led da850_evm_tl_leds[] = {* q9 B' g' L# F8 h
{8 h8 J7 ~$ `0 a4 q7 Q
.active_low = 0,6 ?0 r0 s+ b6 I; q6 n
.gpio = DA850_USER_LED0,) u- K0 q+ |7 M' A
.name = "user_led0",# c& f0 ]& j# K. L- A5 H# U) `
.default_trigger = "default-on",5 \ r# P; O8 x* ]; L
},' a( I+ m$ ]: V( Y1 _
{1 S: H. z$ g, o: n" M+ W, ^. f
.active_low = 0,& p; n- T" E/ A; U
.gpio = DA850_USER_LED1,
8 a* I# Z+ [' U. {( t0 J* S .name = "user_led1",
w, B& p2 o+ y" g$ X1 n% ? .default_trigger = "default-on",
3 a0 b7 T" ~' m9 }5 c6 ] }," [; a% X* u: |2 e/ Y( y1 }$ w5 t/ c
{' g4 P1 T o2 p
.active_low = 0,- c" p/ L- f" Y1 r( l# T
.gpio = DA850_USER_LED2,% E; x# E# c m9 c1 ?# V3 R
.name = "user_led2",4 I$ E: f* Y. Q0 ]; y# Z
.default_trigger = "default-on",3 ~/ |& \+ ?, f9 P, \8 r. c
},
" m4 P4 I: G) b" K0 r0 S {
: z% ^: p; }# z* M" W0 v" o .active_low = 0,
. A7 i, ]( _2 m# B d1 ~, l/ F \ .gpio = DA850_USER_LED3,
' Q0 _# f! |, ~/ k$ T; O .name = "user_led3",8 l7 f: ]' K6 ? m& C2 c
.default_trigger = "default-on",
3 K8 C1 I5 a- B },
5 e2 A& I0 v5 |+ d- A9 l};8 P2 U/ |6 ^$ h$ l
. T6 k$ y( |6 Z3 ?0 V
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( D9 C5 E- x1 w/ p
.leds = da850_evm_tl_leds,
9 e: k( @' e6 _) r6 T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- d* z3 ~. }8 }7 `. D- G& {6 J1 f};1 L! e1 L4 i8 }' K
+ H) }" j0 U& k* [static void led_dev_release(struct device *dev)- f5 y; ?& }# s o+ Q, |; L8 l
{- n0 k* g; u0 T! Z# ^- h
};( \# r) N9 }3 u
+ D3 Y" A1 G# `' Y
static struct platform_device da850_evm_tl_leds_device = {" \7 P- {- }) a& I& c% Z
.name = "leds-gpio",
: n( X( o5 ~" l' z5 F .id = 1,
+ c4 `9 d: g7 V; i* p .dev = {7 n) u& A( N4 V5 M& v( X
.platform_data = &da850_evm_tl_leds_pdata,
3 k' d# \* ~- S .release = led_dev_release,
8 s3 q: N- L- J6 R0 b& ~& ~6 d4 i }
) \: a3 k' m. b. t* ^& Z};
( q- y d+ Q L) w. B- M3 g' I
; U) @7 n m0 G9 J! D# P* Wstatic int __init led_platform_init(void)
0 S9 p' @% [1 S8 p{, m/ ^8 v" {/ L6 |
int ret;
" Y7 V4 U& d3 M: D0 i$ ^) ?/ W#if 0' J3 Y. G; D* W4 `
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ u# A: R% q% e, |/ w if (ret)
; g! u8 C5 a" D i/ e pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, r) Q) n4 k2 W "%d\n", ret);6 i6 h% w2 I! @& P9 |* ^. Z9 D: h
#endif
/ c: P. g) x( v7 w ret = platform_device_register(&da850_evm_tl_leds_device);
$ Y2 R" a# I% i( O if (ret)0 A1 @- M* h: R( g) O% {# `" H4 d
pr_warning("Could not register som GPIO expander LEDS");
' I* p( x: b7 \2 y% Y else
; I% e8 b% B2 @2 d/ X0 V) R printk(KERN_INFO "LED register sucessful!\n");
' i$ a( B y! t( j, X4 d" z' `( w" G2 Y' F V# {- V! V
return ret;7 E( o% T$ G9 P! y: M/ w- @
}
4 a2 t" H6 y* X1 b4 }% Q& j+ X5 ^; x3 S! { {( C
static void __exit led_platform_exit(void)
3 t; G: f- i' F% S( ?3 x8 {{
0 u' n1 d' R7 W platform_device_unregister(&da850_evm_tl_leds_device);
5 _" q8 P: K" p: E a0 w9 }( ~# M) U) w0 C, [
printk(KERN_INFO "LED unregister!\n");% e! q. y: S3 E
}, e% G/ e5 f$ n0 [+ J0 f$ l
9 z7 N3 H4 W! e2 R$ _* I& D2 `
module_init(led_platform_init);" Z4 ~" M K9 L _
module_exit(led_platform_exit);$ G( b! C2 I. I
% ~0 F& i5 A, H* ^1 Q; ^ ` Y3 cMODULE_DESCRIPTION("Led platform driver");/ r7 K r% C, i( w9 x0 n6 z
MODULE_AUTHOR("Tronlong");" ~' w( f( d8 l
MODULE_LICENSE("GPL");
' L1 ~, V% ]3 N$ s5 I$ t: {# s9 p
|
|