|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 y7 a( N: }2 M: U#include <linux/init.h>4 T& S4 l/ s: j6 f3 O
#include <linux/module.h>
4 Z* | [7 M% G8 @1 g. N#include <linux/kernel.h>& b5 ^8 h7 V4 \" ~2 U5 |: L
#include <linux/types.h>
/ A/ R' u6 T9 x& c#include <linux/gpio.h>
. t8 ~' b& U7 J% t+ D% n#include <linux/leds.h>' B8 W2 o" c* c/ t' k
#include <linux/platform_device.h>
4 L8 a- I) d: W/ [
# T" b/ l0 U3 V, s) _#include <asm/mach-types.h>
* s* H N$ T9 e0 h# r#include <asm/mach/arch.h>
6 L5 x* L8 p0 g% t#include <mach/da8xx.h>% M) M7 i( ~* q/ l2 F ?
#include <mach/mux.h>$ G3 B9 @$ Q: t1 y- z, y, g0 N
1 T% D/ N7 ?( r* j$ `! t" K8 G#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# @8 p0 N" x' y* z0 ]! _#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 L7 t2 q7 [7 M- `9 D
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* H3 T8 V" S2 B3 Y8 z0 g0 w
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ W- V6 ~' G O- }) a, m
! Y4 }' l2 N" {1 E4 D/* assign the tl som board LED-GPIOs*/
. M: v1 k* L) T, Ustatic const short da850_evm_tl_user_led_pins[] = {
" I$ r6 y% s; L6 K /* These pins are definition at <mach/mux.h> file */) @4 s& D( w+ C+ N* M9 r
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; A9 Z3 d9 i7 [+ p' _ -10 C1 |3 n( y* e R; d$ ]
};' i- c2 N( H' c& W# _6 q( N8 {5 G$ ^( j
& Q: E8 m, I! r4 e& ]4 P! v, x$ i
static struct gpio_led da850_evm_tl_leds[] = {
. S* R* T6 W7 d) h$ D3 T { M! R# R% G. e. r
.active_low = 0,6 ]2 H2 S$ B2 g+ V) u4 p* G; P
.gpio = DA850_USER_LED0,
* H7 o. k; W# P: w0 s4 a1 R( A .name = "user_led0",
( K, s+ u; |; D! X2 Y2 A: v .default_trigger = "default-on",
' f& k- @8 c1 w$ `. u3 g },% I; Y; v s2 z, ?7 f3 Z
{. F0 U- {$ |, e) T# i4 `; f4 P2 E
.active_low = 0,2 t8 Z4 w' C* ^ M0 U( `. r
.gpio = DA850_USER_LED1,* Q( S# d4 k9 O7 v
.name = "user_led1",
' F B j1 z; M4 J .default_trigger = "default-on",, K# S& x$ C1 e& Y
},
5 i; k9 m P* w' E+ n1 f- q {
& \8 z" Z1 t0 c8 I# d6 _; u .active_low = 0,
# w. V( p' B u7 p6 H .gpio = DA850_USER_LED2,
o7 |8 T3 {/ W- `; W, I9 ` .name = "user_led2",3 ?* H6 S, e# H) F3 c
.default_trigger = "default-on",7 p X* U( S5 L+ v4 K
},9 V: C; u' y0 [3 h; t. v3 m' K0 O
{9 r- @9 x0 c( {/ P2 F
.active_low = 0,
! d4 r/ \. H7 W) y: u' R$ \5 n/ [ .gpio = DA850_USER_LED3,
[7 L U! ?4 S0 R: W .name = "user_led3",9 i6 P1 \# ?. N% c- F1 ]
.default_trigger = "default-on",% U( j! a9 r ?$ r. W, q
},
; Z5 @' L% @; I! ]: S};
* V" T: Q M; u1 ~6 Q
: S' |6 O+ ^3 \, p( p, f4 t; B. `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" R3 g) ]: \. P8 d: b
.leds = da850_evm_tl_leds,5 e7 T5 }6 A$ H, i1 x
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. a8 j3 H# W$ |) P: ]( u; v};/ J1 T/ D \4 Q+ @$ N, Z5 T
/ c% I9 G7 Z# o. |" F" J) O, Fstatic void led_dev_release(struct device *dev)8 p. M# Y! c' e- w$ z! B" w
{9 q" W# U. p9 `& w8 U1 i
};
8 O0 F. u) |, o
; X) Y/ c+ O. l9 z; sstatic struct platform_device da850_evm_tl_leds_device = {* W) Z: {- k8 D1 A! n3 U
.name = "leds-gpio",+ P6 W7 j- _- R
.id = 1,% W8 r7 E- @# [# n/ U$ X
.dev = {, F: a6 v. Y I% F$ N0 b7 t0 G! N1 y
.platform_data = &da850_evm_tl_leds_pdata,
7 p5 b. o) g. `+ X( z .release = led_dev_release,
: c1 C0 r. P3 u4 J4 O: M }0 t3 ?) I' P8 k6 q% h' C8 N" c' g( L
};+ x: W( q2 l9 c ~: W4 g
' n* f+ {8 _! E5 `1 bstatic int __init led_platform_init(void)
1 r# J7 ^" ^9 E% a9 |( z1 B{. s" X/ A& z1 B( s4 L- ` Z/ m
int ret;
4 `+ {# O; D; N* N0 |- g#if 00 t9 |/ k% h) V9 t. e. S9 l. W
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( j) E' z, g8 Y/ S4 h) Z
if (ret)
4 X1 H2 Q. f4 o" Y- R& ?% X" e( R4 T pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# ^0 m/ X. }9 |6 A9 s2 I+ h$ a/ F
"%d\n", ret);
. D' u, r( r, `' I4 Q# I/ ], O#endif' V8 o' [: F7 M- }" e# V
ret = platform_device_register(&da850_evm_tl_leds_device);5 O5 l8 q3 r$ n! B% u# J! m
if (ret)0 h# ?$ u. C+ l0 o) K
pr_warning("Could not register som GPIO expander LEDS");
' D Y8 x4 L6 t: u else6 D( a, e( j) v0 q' W
printk(KERN_INFO "LED register sucessful!\n");
5 C1 v' h( h1 e$ ` K1 ?) f
+ T8 Y* t5 `! S7 ~! w! } return ret;
( I* d; M" ]/ T# q/ c6 N6 N7 J" I1 i4 d}
0 K# }. H+ _! r% f4 i( U K, }* P* ?5 h( M$ r" R
static void __exit led_platform_exit(void); F/ v( J- V+ A7 \3 |
{
; t& f. ], Y# k; T6 l platform_device_unregister(&da850_evm_tl_leds_device);
! `) L, L6 W: s7 g. b0 g4 p/ @6 u) i- T1 |5 G- e
printk(KERN_INFO "LED unregister!\n"); ]8 D8 S7 v" f) ]( v) s
}, y9 n7 _5 I' Y! \ h) L8 D) [
" `7 t" s, H: R1 v! X9 L; H$ }module_init(led_platform_init);2 [0 c( i: a. h: p. T4 s; H+ _
module_exit(led_platform_exit);
' A1 f$ c, h$ A) \: J" t; n% y; V! x, G
MODULE_DESCRIPTION("Led platform driver");2 D# W9 ~: a- A; J2 h! b
MODULE_AUTHOR("Tronlong");7 Y$ h7 c N! a- k: Y9 c0 @
MODULE_LICENSE("GPL");
/ P4 `! A9 u b$ A- r% U
/ R9 b/ S2 u" P2 Y+ v' v2 o- o/ L+ O; k* k |
|