|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: Y0 G! @, F1 d! X ^
#include <linux/init.h>
2 p5 g& o5 X& }/ v' }3 `4 X#include <linux/module.h>( n5 N" Y. i% N
#include <linux/kernel.h>
$ w+ G4 v+ L8 C$ k+ }, R#include <linux/types.h>
# v- N5 [- \4 J& h& t#include <linux/gpio.h>" f$ ~! L1 M, i1 C* W
#include <linux/leds.h>1 o+ c2 c/ V( J* {" ^7 G
#include <linux/platform_device.h>
" q0 K$ P& J1 m0 {$ a: `" Q/ E8 U+ b/ L6 g3 D5 X2 k, a; \
#include <asm/mach-types.h>* d: S7 u1 ^ A, U, H
#include <asm/mach/arch.h>
) u+ n* A4 j8 h4 L2 }2 C#include <mach/da8xx.h>$ ?1 h& H& [( d4 r# z; z( e
#include <mach/mux.h>
/ Z5 J; k3 l7 T# t5 p4 y8 Q) s, L
% [9 w! `+ V3 {* }#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
J6 A6 t8 t3 P#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( Y t+ i1 B8 M- W5 b#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 \! B- `$ o- n! o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; I8 b6 Q) G. ?! p$ e3 m$ j; S$ { {: C+ K& ]
/* assign the tl som board LED-GPIOs*/
' G: ~- c6 X6 W8 O$ e. _5 ]1 Qstatic const short da850_evm_tl_user_led_pins[] = {, k1 o+ t( B; ?" P" P
/* These pins are definition at <mach/mux.h> file */
8 }( C4 a& {+ V& ~ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& C( s3 E0 j! T -1
) W1 W% R/ L" ]: _! p3 d8 r8 ^};' a$ @4 Z& d8 N: L0 V+ q- A' Q
2 L9 k5 r; _1 l' s/ x: C% |
static struct gpio_led da850_evm_tl_leds[] = {( _7 [! c+ f* F) W3 z: ?
{
. g5 s3 G+ q9 b4 ` .active_low = 0,& l3 X3 U& u2 m1 L1 \. B+ Z
.gpio = DA850_USER_LED0,: C7 J A) c) h4 t9 V* U) t' A6 t
.name = "user_led0",: J0 Z2 l* G" k, t' _
.default_trigger = "default-on",. v) D9 r8 @; ]% L% j- Z
},
& z, U5 k4 w6 u5 ?$ q {
a7 t! Y: E4 w .active_low = 0,6 D$ z1 g# J( B5 o* c
.gpio = DA850_USER_LED1,
; @. q: G Y. D: k0 R# J .name = "user_led1",
; ~2 Z8 `0 s1 \2 R7 S .default_trigger = "default-on",
9 E1 q6 [5 H! X9 a# r0 C },
1 ?& n' t1 U. p4 ]; n {
3 G) i: N6 V$ J O .active_low = 0,
' R3 m- P: t, c1 W* q, w$ Y: V .gpio = DA850_USER_LED2,
2 L8 [* H7 Z$ o+ F# C+ K( g .name = "user_led2",
2 F9 Q* C' G0 _- J/ J) t .default_trigger = "default-on",5 U n/ }; B# L& ?! A
},
2 n$ \9 e2 Z5 h# D {
9 Z2 n6 d' q0 ?3 U. W% @2 }* r$ c; J% H .active_low = 0,
8 d+ b, c7 q$ _3 W* U .gpio = DA850_USER_LED3,0 }$ P5 m, D! Q' H x( g/ R9 l q
.name = "user_led3",4 i1 ~7 @3 H; T6 }
.default_trigger = "default-on",
/ @9 ]! d- O2 I' s+ g1 ? }, O7 I% F) K4 n W0 U1 g) m* c! E
};; k8 I$ Z. r& ^+ w7 o3 d! I: x
9 Z- g% e6 G' g0 kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ S. B2 J. x* R V .leds = da850_evm_tl_leds,
! v# O$ c: m1 c E .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- k: K( q6 S4 `: c1 t6 { j
};
5 N( X& Y3 Z6 g" r9 H0 k
+ \% }) B( h) F, Y2 dstatic void led_dev_release(struct device *dev), Z, P2 U2 I& X2 ~$ s- z/ O- v
{
$ m7 {& J6 p# V+ K! [};4 V5 O* Z" b! t" m. D- M
- G7 u8 Z, H! U5 l: | o/ ?, Ostatic struct platform_device da850_evm_tl_leds_device = {5 w+ R: D- M* y+ D" J
.name = "leds-gpio",
; y9 R6 e: n2 ]; `( x .id = 1,- `! C$ z; T' M5 a9 B
.dev = {
- e9 F9 \- @1 C .platform_data = &da850_evm_tl_leds_pdata,
3 g: V) i \" e- r! X! r5 a1 A .release = led_dev_release,3 [3 B6 r* f, ?- ?* n
}2 J9 \+ U, v& P/ [* G. A# h
};
+ i6 D9 _+ ~# R$ P; x9 j
4 G8 l# t# c" v, _' zstatic int __init led_platform_init(void)
! e6 ?3 F+ G0 a$ I8 c, q{; q! Z8 m! u5 E }5 S, i8 B
int ret;
0 o# J2 L" O2 g7 ^) j% z& I#if 0
' x! B/ h$ {) }: O ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- C: \, r) c7 s6 n K: F
if (ret). T( D; w! D0 O3 o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; A! h, {9 W- |" U6 i
"%d\n", ret);0 _, ?9 v) J% U8 I6 e+ ^
#endif A3 t! U# S( ^ q+ `
ret = platform_device_register(&da850_evm_tl_leds_device);1 W4 ]$ `# t; D4 ~$ T2 O0 j
if (ret)# B5 f! u( e8 l0 W, s3 J/ J
pr_warning("Could not register som GPIO expander LEDS");6 I' @3 ]; K8 N! p& a s. U: ^
else( k( @0 q0 l# ]5 _4 B
printk(KERN_INFO "LED register sucessful!\n");
" C, \* D! f7 @! g% }& ~% p0 o7 o$ C& g/ m8 b2 n
return ret;- e" `$ E2 d2 H3 Y6 F& D. F
}' k2 D$ w: G5 J p6 M- a" j" N
6 F: t( `0 o8 p' ]: astatic void __exit led_platform_exit(void)+ @ Y; h# j0 v+ n' d; P
{/ O1 u, Q5 t" C) T; u
platform_device_unregister(&da850_evm_tl_leds_device);
9 ]8 W$ A) E8 _7 E. u/ g: z. K. K. c' W/ Q, C' S, b" z
printk(KERN_INFO "LED unregister!\n");
, I9 I. [: y5 N5 Y, Z: O}+ k+ h/ D: K, L& x4 L7 i( f7 `
- T/ M1 K- b5 _
module_init(led_platform_init);! x& ]: g( L& ]
module_exit(led_platform_exit);
y6 c+ Y' @: p' h4 h& W g j3 W+ v: [
MODULE_DESCRIPTION("Led platform driver");
: I$ j$ l, I/ G7 B+ M' a- _+ N& bMODULE_AUTHOR("Tronlong");- `2 D2 g0 ]1 G( z
MODULE_LICENSE("GPL");3 v+ y+ a w, M, u* N0 v
3 t) _6 Y# m/ _2 V" I- E ?) E |
|