|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
Q1 t2 o1 m" C( G& m: T2 D/ J#include <linux/init.h>" p- I1 s# a1 C$ ]2 f! c% J' I
#include <linux/module.h>& i: S+ D8 V2 U2 P, ~, x$ G
#include <linux/kernel.h>- z- x3 P5 r: R+ d, H
#include <linux/types.h>
& Y+ @% h+ F( \ p# R u3 P#include <linux/gpio.h>, d7 Z; }% {/ s
#include <linux/leds.h>
" j, o* M2 _& m' D% E# G2 j. R#include <linux/platform_device.h>/ a1 K8 W, X; J& l# s
- \) \! T! S2 q#include <asm/mach-types.h>8 H. D4 u' n7 T' }
#include <asm/mach/arch.h>
) K' g7 m1 P7 I/ x! C#include <mach/da8xx.h>: E/ G# @( {% p+ d9 Z# Z1 b) `
#include <mach/mux.h>
- Z6 ^" E& @( z7 n/ k# k; ], `' s( B
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) f& U; u2 Z, z# ^#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! Q1 {; V" i" q; f+ h! h
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ h8 F& _. f _- I7 R% V7 W
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! }3 i, q' e* S {8 V
( k9 d$ G5 T: A1 D. u/ @/* assign the tl som board LED-GPIOs*/
4 ~# t {) `8 p5 ]static const short da850_evm_tl_user_led_pins[] = {
6 \; M! i# L. y, [ /* These pins are definition at <mach/mux.h> file */
0 v$ i* C, s) T9 p$ {# \ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; G+ k7 P# Z# Q- w2 N -1
, F3 E1 x s; b- s};" Q6 w( s1 [+ C: P' p8 G
; j, a+ W9 V1 e4 q$ C, B
static struct gpio_led da850_evm_tl_leds[] = {
& s* y% U0 C4 h. g( M |* q {
* S0 K0 O+ q% g8 T .active_low = 0," h( p2 V" r; R2 O& y; ]/ b+ w. H6 G
.gpio = DA850_USER_LED0,
( V! U' J/ \0 p .name = "user_led0",1 g' |0 C% ?' @* Q" N
.default_trigger = "default-on",
% m( [" D/ e7 [* I* j },
) Y! d. B. L$ _$ u; t {
- ~0 c7 a% L$ C% B .active_low = 0,3 u3 ?' x: g7 e. i/ R) X- O6 W
.gpio = DA850_USER_LED1,
4 n1 W+ t1 O; d8 M- P" ?( s, F+ r .name = "user_led1",. f* D$ [+ t% s5 b" m; r
.default_trigger = "default-on",' K& Z& u; N" q$ ^( P
},# h$ B/ g* `; K5 D8 C" Y4 `2 r3 e
{; a- q/ u. D' j f6 {. l5 i
.active_low = 0,
! E; w. Z' L0 y" o. R9 `' Z .gpio = DA850_USER_LED2,/ `# h5 Y% Z4 Z% q1 h {/ C
.name = "user_led2",
: `5 N$ q' y) m. S2 ]! C5 O .default_trigger = "default-on",
) E9 P( G* n7 I2 w7 @) Z },
7 s* t0 {$ P0 h2 X1 t9 a6 _" | {) C; p% N r3 C& `4 |# ^0 X
.active_low = 0,! W$ x1 i, ?6 l+ e0 X$ C
.gpio = DA850_USER_LED3,
+ H. G. b8 q2 g7 c1 g .name = "user_led3",0 T4 S! b& g. z, Q6 a, V& l% t
.default_trigger = "default-on",
! l& ]4 \. Q% o8 N' `5 Q$ [" J },/ }; f; P m8 E# R# O
};; a- N( d, K- O
! |) D* M- w- \1 xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; j ~$ L/ P- Y% J; X1 b
.leds = da850_evm_tl_leds,
) ~. i1 m* z# {, {. r. X1 F .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 m, h9 d9 p: X1 T6 e};
2 k$ |5 {$ Y3 O6 z6 Y/ S% r4 u* h7 ~6 ]8 u2 d' D U
static void led_dev_release(struct device *dev)1 n. Y, m& L$ M/ J9 f0 ?8 t
{
" k: S4 [; J/ B0 A: Z6 p( b/ t1 G};' r- |! t* t1 g
' J% _/ u6 Y6 M, Fstatic struct platform_device da850_evm_tl_leds_device = {( S) g- Q" X* @5 C0 @; q
.name = "leds-gpio",7 Q5 q* ^- _) j5 h; S/ j
.id = 1,
2 R' p6 M5 P; O# W+ ^3 c .dev = {9 Z+ u* ]- r$ p: m& Y, q. z
.platform_data = &da850_evm_tl_leds_pdata,
' y1 X( K l7 p* R .release = led_dev_release,
; K; y1 |# [2 V% O1 e1 q" u- a! ] }
7 W0 U/ ?6 L- _" Z' [2 m& ~9 D n};- R% q$ Y( \% Z* f6 c' v
& k9 U5 ]$ l* ]4 Ystatic int __init led_platform_init(void)/ T; C( \, ?# m" o# E
{3 O/ z% N R' w
int ret;
. m0 ?- G/ q) I9 t6 w2 F( `#if 0
0 s- L, C- n* K @$ l/ [+ f5 K ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 d P" {: O& h% p2 F if (ret)
2 S1 @& a) m2 R- ` pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 w5 y! A9 t* |* J" U "%d\n", ret);" t5 j2 f2 \6 W: B. f
#endif
, P2 l9 W% }4 l- W ret = platform_device_register(&da850_evm_tl_leds_device);
# n2 ?$ A8 k6 r6 X2 ?% r- A$ J: L) s if (ret)
& ]1 n7 Y, c1 Q( W6 p& q pr_warning("Could not register som GPIO expander LEDS");
; [& C E) m6 ^ else
/ R3 ^* S- a0 t" x5 e4 @9 Y printk(KERN_INFO "LED register sucessful!\n");
8 N) K6 a% _- J% @* C
( q5 B1 _3 n, h. D' P return ret;% a% s: V: K: ]( {
}
8 p0 J1 x/ m; M! a" b
: V5 D8 t4 X& R1 z, Jstatic void __exit led_platform_exit(void) d n' \ ]1 O v w
{
/ k2 s: i3 f o7 P& A4 C+ s% R' R platform_device_unregister(&da850_evm_tl_leds_device);
% m: j) N# f, J* S; x
0 s4 e o( ]# x" D7 c4 Q printk(KERN_INFO "LED unregister!\n");
+ k& L d; e. H% V p6 r: {}- v( b X6 ?: h% Z6 i8 G
5 y2 ^( z# Y5 e3 Z2 E& R) B, Bmodule_init(led_platform_init);( Z+ r* ~+ s% I8 B4 y) v" @' K
module_exit(led_platform_exit);
- r1 l1 P$ r) I2 n+ K( S- ]1 f* L6 C5 r3 k/ U% s& x6 _. N0 V
MODULE_DESCRIPTION("Led platform driver");
2 s. `) w$ T$ A4 k" [( F5 jMODULE_AUTHOR("Tronlong");
) [: \) [" z. C" DMODULE_LICENSE("GPL");
+ z; R* b! [: L5 {8 t# s& D4 C7 h. j! {1 c) ~
|
|