|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" }# o' |+ V+ o9 q4 ?* l" t' D) _
#include <linux/init.h>$ g D8 t H; ~, W
#include <linux/module.h>
3 ] c3 L% N- M0 N#include <linux/kernel.h>" m. X$ V5 t+ B1 [& s; G
#include <linux/types.h>
- ^: B( c7 v' }! L# B) t#include <linux/gpio.h>
, o/ A2 w; s- i" n* V$ N#include <linux/leds.h>
6 ]) K4 y8 q- ~& a#include <linux/platform_device.h>% r* L" m- B; ^" q' E
' ]( \0 U5 w+ a7 C: D- z
#include <asm/mach-types.h>( Z9 {; C; `; c s) @' L2 [# u
#include <asm/mach/arch.h>
5 P4 s4 A# F+ U. n#include <mach/da8xx.h>
1 |4 g5 b; A5 T# ^#include <mach/mux.h>
0 S4 r" i1 `; Q
$ j' ^, B5 K k" F#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- x2 O4 L) H# p7 Q0 a. u. d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' R; s1 N5 M. n- O7 W( V# J#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ [5 y8 q' Q0 ~0 f2 ~0 R. O
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ e3 [: \; {0 f$ W; @" D# I) v; f' q7 d5 y" r
/* assign the tl som board LED-GPIOs*/
0 V" A7 {6 n' F' {+ rstatic const short da850_evm_tl_user_led_pins[] = {8 H! H, b4 Y* T5 I) y
/* These pins are definition at <mach/mux.h> file */
1 q Z( x# \! Y: s7 J8 _( E/ O% H, [ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, {0 t, k9 ^9 J; s1 c/ E" T
-19 o* T6 }; `# {% }: k5 w0 c
};3 T( v; Z2 M: t5 m) S6 B
$ ^8 O. D f2 s. y# _
static struct gpio_led da850_evm_tl_leds[] = {0 ~ }' D/ C% H& ~
{6 M O# o6 z, d' L7 K
.active_low = 0,, c, @: D3 t6 r. _3 ~- i
.gpio = DA850_USER_LED0,
/ }: N h' h0 S- N8 w/ E" \ .name = "user_led0",
4 ?! a; L% ~9 G7 l- H .default_trigger = "default-on",9 Z/ ~ Q s1 a2 u
},8 J9 ]3 N4 I, q# o& B0 Q/ R. ]
{" T) h6 q: a" |
.active_low = 0,
7 ?+ n% r4 a! z* e: h4 o .gpio = DA850_USER_LED1,
9 W8 M( i( B" H1 f- \0 h& F .name = "user_led1",6 x/ e- b+ G* ?. l5 A
.default_trigger = "default-on",) ]. Q9 R c- @4 S9 }* c
},
1 Z# Z' S: Z0 c _( J& ?1 y8 f {
2 b$ ]. U2 V2 E- R6 T V4 K .active_low = 0,
4 x) |# [% s" a' t, {- `( I .gpio = DA850_USER_LED2,
' [8 D) C- _2 W .name = "user_led2",8 A- h5 q' P+ D! ]
.default_trigger = "default-on",
' q- m. F& ]- R; }; r },% }2 D- j+ s' r! T* I5 X/ E! i ^
{
& s2 l% B1 z6 U- q. Z( j .active_low = 0,: l/ X7 A5 f8 N7 ]
.gpio = DA850_USER_LED3,
4 w+ x( N; d% R! F2 a0 z* l: k5 g0 e .name = "user_led3",
, v% i0 m* E' | .default_trigger = "default-on",0 m8 _. r& L8 E2 a
},4 d' a) v1 r$ t
};, f% T+ T: r+ l7 A% ]
0 ?% I$ `7 `4 ~5 s9 n
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* W* p7 G* O+ S+ \- [6 z7 { .leds = da850_evm_tl_leds,
% q6 J8 s6 E( A4 |8 N+ R$ t .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 z( @ k/ M* z/ d
};
7 H* ]0 f9 O! S: ~
; {1 u+ f) I3 Nstatic void led_dev_release(struct device *dev)
, E& d2 z* [+ a{% L3 J4 E/ S/ u6 n: X
};) ?/ K8 }. S: S( i* u/ h8 U# M
& k: f5 p- R3 q' {* ^/ B: _. istatic struct platform_device da850_evm_tl_leds_device = { e3 `- H% O5 K5 D
.name = "leds-gpio",
. T( l& J& O3 o$ p( l: u .id = 1,* m' _, {. d$ J% W) n
.dev = {
. O- |$ {& E y2 ~7 R .platform_data = &da850_evm_tl_leds_pdata, F, l4 {# N7 i8 J
.release = led_dev_release,# y8 `* A; p# M/ w7 L1 V
}
: t' ]6 T4 ^0 {, _};9 f' _' f9 Z- H: f
' w: O- V/ o( s# {static int __init led_platform_init(void)
* ~4 S) Y |( p{! y2 X& w: ~ L: y8 Q
int ret;
# U7 a D6 @4 C; y#if 0
/ G! z$ [, r5 i1 s ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- ?. h) Q' G6 ]; p: k if (ret)
/ e5 s1 @# |0 u' p pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& ~6 i- |) [" j9 V "%d\n", ret);) v7 }( T3 N; u+ q) W4 X& n
#endif" l' H6 b* F1 i9 Y* M9 I% K7 {
ret = platform_device_register(&da850_evm_tl_leds_device);8 v7 O. |5 y5 a1 U' ^3 ]9 [; m2 k9 ]9 \
if (ret)2 X3 ?; X; s, a; v' r
pr_warning("Could not register som GPIO expander LEDS");
% ~* ^4 d" o" k" Y ]& z else- W6 k4 n2 A$ A" v% x- y0 _, c
printk(KERN_INFO "LED register sucessful!\n");1 E8 W# Q, j, e: @& j! T [
9 h0 H2 X% r( Z: g1 f7 J7 m+ Q0 Z
return ret;
& Y' Y( k7 ~$ x( P4 H1 y$ |}
8 p6 d2 R1 T! s S: c4 V) J5 |. H
7 `0 \' i4 Z1 [# d* kstatic void __exit led_platform_exit(void)- C1 A/ Z) Z# b: c
{: k8 q$ G& G7 [9 ?! A
platform_device_unregister(&da850_evm_tl_leds_device);9 p. m' A( d; O- k9 ]5 u8 Z
/ g4 ~9 x M( B1 j- \; q
printk(KERN_INFO "LED unregister!\n");+ S! w g3 l' C& J7 E
}( G4 d+ l) b7 ~, b0 F" `- T
: a- l( l9 s2 B) h( {4 ]1 ~module_init(led_platform_init);
3 C; M/ Z& z p" N; n: i& emodule_exit(led_platform_exit);
$ B: `% Y! A! F4 H/ d+ Z$ C" q% B1 _& g
MODULE_DESCRIPTION("Led platform driver");3 c) Q- j$ N3 v# V- ?, i
MODULE_AUTHOR("Tronlong");. M3 J: S& S# z# C
MODULE_LICENSE("GPL");
* M4 m3 x: c& D* K) j5 v9 K
* n: Z/ _, G: _( i8 G* j5 z |
|