|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* j0 {6 h9 ^ e9 ]$ g#include <linux/init.h>
; u. U! o) V6 G5 i* \#include <linux/module.h>
3 l& W1 Y% G" n4 o9 O; t" L#include <linux/kernel.h>5 n, W* x, ~$ Z6 ~; x- _
#include <linux/types.h>( n4 J' P# A7 O1 k& o4 o
#include <linux/gpio.h>2 F U, h' L% z/ I; E7 A9 t
#include <linux/leds.h>
4 e1 B& v6 Q. f1 c" b0 F#include <linux/platform_device.h>
. {3 W" U8 b/ F+ T, k' C% ^: _& o4 Z& [: m/ `
#include <asm/mach-types.h>7 T$ s' b8 b5 ?8 T b
#include <asm/mach/arch.h>0 o. e3 N' ^7 W/ I& c% o. C5 L$ |) ?
#include <mach/da8xx.h>, h! i$ E7 \6 \) A o
#include <mach/mux.h>9 O0 h9 ?( E( v
; \4 z4 }6 u* W2 z' d4 D
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 T4 P3 m1 Q% [. r# _% G
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: u2 Y Y& X$ j" E/ k9 x- n( d#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 `" f! b8 W+ i; B6 |4 _$ q+ r' m
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 s7 Z1 W9 D; a& v( y- S
3 [# O2 v! `$ |9 i4 m. B6 h/* assign the tl som board LED-GPIOs*/
9 Z# } l& X' _, f9 W( J0 U( X# pstatic const short da850_evm_tl_user_led_pins[] = {
4 k6 P% d' N/ [! O /* These pins are definition at <mach/mux.h> file */7 O8 G* f3 h. D; q: D5 B& m
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) l6 n% w3 H) Z
-1* q! Q" Z/ l- Y; p4 Z
};4 b# n& H3 d8 _2 L
8 J9 \6 C) ]: g$ G: ~5 H7 bstatic struct gpio_led da850_evm_tl_leds[] = {
2 o% j+ K# l/ h9 q+ w {
/ h$ ^- ~( ~1 p .active_low = 0,
+ m* n3 \0 Y7 G .gpio = DA850_USER_LED0,
2 K: a2 `: ~- E3 |! G/ X/ O .name = "user_led0",
' H) d& o, S+ j( P4 W3 e .default_trigger = "default-on",+ ]- F1 G, ?9 c. Q# S( ^: _
},& |$ t/ q$ A, B
{/ b0 b9 F" N( T* D( {2 G$ u
.active_low = 0,
1 a7 r/ t5 P8 I; C+ ` y .gpio = DA850_USER_LED1,
5 J' V! c# M/ ]& V6 ]$ Z5 p& I0 h1 T .name = "user_led1",
3 i) D7 K, h. I% z& n G k; W" j .default_trigger = "default-on",
& @ ]3 y5 @* b& M* J0 N },
( T' o0 ^& G7 X' n {
- ^; o' v- q: v5 C) y+ C v8 m .active_low = 0,. B9 b: n7 G5 M; S H
.gpio = DA850_USER_LED2, u, j1 E" ^ g
.name = "user_led2",
y8 p9 l7 F l1 B4 v( h .default_trigger = "default-on",
1 ~) a& L8 v+ R1 Q- I },
0 K6 i4 b" T( _7 @- o9 z6 n- ? {9 q. K& ]# o! l2 W
.active_low = 0,
$ ~+ N% f) q( H .gpio = DA850_USER_LED3,) K4 _2 K2 j- ^/ A6 I
.name = "user_led3",
8 Z+ ] ^! j! H/ Z/ E$ i- V .default_trigger = "default-on",
) ?& H# A% o4 K& O" }6 S" o U! R }," ?& j3 o- ~- X4 ]5 r, }( V
};
5 H, V! f9 z3 t y: d1 H$ I( g3 h. i5 z4 w5 @3 u! Y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. s/ V% U7 T1 y- l( Q" l$ z
.leds = da850_evm_tl_leds,) W! D; q* j) n$ g, I5 Q& T
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 ], I1 P1 _) `};
, R+ g$ ^0 D: P8 n, C% g4 i/ p8 r) B7 x( M8 n& X6 _
static void led_dev_release(struct device *dev)- J& {& @+ C( r) P+ x
{% q# z; w5 I2 d9 M% z
};8 W |3 l: F _% k
- n7 d0 ?8 L$ M( t, I1 [9 B9 \static struct platform_device da850_evm_tl_leds_device = {
" G+ _) U+ O5 \- T( X+ H .name = "leds-gpio",
) ]+ L1 c; c9 L& A4 @. e* t$ K .id = 1,4 n6 S0 K( K" r" D) s9 `$ Z- ~
.dev = {* U% d0 `& f% \+ f* J6 S: T
.platform_data = &da850_evm_tl_leds_pdata,4 S$ f4 u2 i9 y, O
.release = led_dev_release,9 t; R+ Z3 L N0 d* z0 x
}$ _: l* n1 T: V- ]4 n
};5 m8 y4 ~- l) J
5 H; B5 a5 a2 I) bstatic int __init led_platform_init(void)
# I2 B: R! k! {) N{
8 F* q$ k. v o4 E1 ]! y int ret;
; Y# l. f' T2 p; A8 M2 [6 ^#if 0; N3 d! H1 T6 w: O
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 D+ A! c3 I2 N2 i if (ret)9 n3 k/ `3 `+ N3 e( N% M
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 ~7 L0 {( V! m' y0 T$ l "%d\n", ret);9 |/ y$ z( w- B" h4 g# M
#endif
# p: u- ?( Y5 O ] ret = platform_device_register(&da850_evm_tl_leds_device);
9 H' J: s5 D! \: A! T5 g if (ret)8 w( c$ h \' Y! v$ c) Q7 I- @
pr_warning("Could not register som GPIO expander LEDS");8 W1 b6 C6 L( l) ` o
else
2 M2 M# x2 D2 b5 a* G" e; S' S7 S0 n printk(KERN_INFO "LED register sucessful!\n"); F- k k6 L! D5 s5 ^4 f9 h% F$ k3 z
; o- J% q P# N i C$ Y4 h0 Y
return ret;
, z/ G3 B9 m3 A" I$ V}
0 X( S6 S( L9 T9 j
$ F/ K( s) v. K3 x4 e {static void __exit led_platform_exit(void)
, I. F% O- I+ Y. d3 Y{
7 u! }# u! t) M- F2 g platform_device_unregister(&da850_evm_tl_leds_device);* V; W% q( C0 l$ ]8 y
3 ]( G3 H5 k+ I# n9 g printk(KERN_INFO "LED unregister!\n");) o9 d5 B) |0 A8 m A0 @8 t8 ~$ `
}" R0 F# N; a! t* w7 d9 G# _! a
3 z1 v$ ~5 }( P$ Y. O. nmodule_init(led_platform_init);3 F( j' A! f. i4 `
module_exit(led_platform_exit);( f5 m9 r) G# v8 p( e, c k d
0 Y. v; r: M' ?) y6 e
MODULE_DESCRIPTION("Led platform driver");. \8 H4 h4 |( S' D& I4 B+ Z5 }+ A7 x( b
MODULE_AUTHOR("Tronlong");: v9 |) G% Z9 u0 X
MODULE_LICENSE("GPL");- ~6 v4 P) l* }9 D Y
+ h; g' \, g8 E& ~. ?
|
|