|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( z _, i5 p4 r* r& G#include <linux/init.h>
, x' q! f: m) S' o/ ^#include <linux/module.h>
3 P- n9 x- d" ^( b#include <linux/kernel.h> }$ a% h- M1 Q2 M
#include <linux/types.h>
! s1 j2 w. q5 K3 v$ ^% A* v#include <linux/gpio.h>
5 H4 @4 E. p4 U/ D#include <linux/leds.h>
* h2 L0 b, T1 u8 L+ h- @# A) t& G#include <linux/platform_device.h>
6 C, {$ d0 }; z. ]& Y; P' T- z$ k2 h* c/ h% I' A0 E7 z, `8 `4 y
#include <asm/mach-types.h>( w5 U9 D8 n9 B+ |6 h
#include <asm/mach/arch.h>+ K# A6 i& A8 {: d2 U9 R0 n
#include <mach/da8xx.h>
' L9 J8 X, S4 s( E! L#include <mach/mux.h>
' ]1 d7 _4 g: C, P9 M5 H) h' p/ n2 L8 I; C7 V. [7 `, s1 t8 g
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 m& [5 F; C1 S' O2 W1 r% }#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 `) T. v6 M+ Y& |3 z; K u
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 x& ]+ M& ?7 L#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). ~9 R& @# u0 g0 r3 h
6 p- I. h2 U4 R1 Y1 y9 e. G, Q4 T/* assign the tl som board LED-GPIOs*/
1 b5 S: {( u, b1 J; Tstatic const short da850_evm_tl_user_led_pins[] = {
7 @& W, N; i- x" N /* These pins are definition at <mach/mux.h> file */7 B8 I# k L6 A+ t* B, \
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& y3 l. S: d( O' F1 f+ G -10 h& T6 j& N0 u _; a/ t$ _3 h
}; v% [" Z4 C; \0 N
; k8 w0 x; r7 [" t/ V. |static struct gpio_led da850_evm_tl_leds[] = {
+ D8 a7 ?! C3 W& O: T {7 l) U8 j2 ^- o
.active_low = 0,
9 }' B8 [! f! N. |) Z+ }* j# U3 j .gpio = DA850_USER_LED0,
% y" _4 O9 W& Z .name = "user_led0",
) ~6 T9 z V+ L. Q* R' a, n9 C .default_trigger = "default-on", C" j1 J+ b! q7 z7 h# V3 Z
},- ^& Y [6 S' t) o+ h8 \
{
; T* i0 f: @1 |7 B' Q .active_low = 0,8 J. m: h+ Q {' V @
.gpio = DA850_USER_LED1,) }6 {. S9 Z; _
.name = "user_led1",+ I, w1 n, _2 [* d' C
.default_trigger = "default-on",
; b0 w3 {& p& Z0 R& i- } },
* S' }& R" v" b/ W: r {3 D: J* C4 P$ @) u/ N2 I
.active_low = 0,$ ]9 }9 B& }! m
.gpio = DA850_USER_LED2,, o% @& X4 J9 h, v* @8 o3 b" |
.name = "user_led2",* }+ ^0 o& t) B, n- p5 B, f
.default_trigger = "default-on",
2 Y: \/ u l l) l3 b },
$ y* v4 {/ J+ _& L' S4 \$ V {
! Z" _7 s: y* }5 ?5 I8 V% } .active_low = 0,
3 Y1 o! L. `9 h7 ^ .gpio = DA850_USER_LED3,4 `/ l4 W1 B9 A" `. p
.name = "user_led3",( D' p* ? l' @& @! v# p
.default_trigger = "default-on",2 L$ n: ?; D6 t v4 y1 ]
},1 e7 T4 T9 U- W, {
};
( r5 p/ ^/ z3 k$ T2 I6 B, L! G/ g7 Y d
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; J7 Q) p) p- T, ]/ r .leds = da850_evm_tl_leds,
$ D5 F/ T" A( `' ~ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* M" [- Z" d; A& ~# X};
& s8 f' B2 Z3 N% u$ B
8 _3 @2 x; n2 T( M O+ T% i$ Kstatic void led_dev_release(struct device *dev)
& r/ K' g! g5 z1 n+ j! \3 B{1 {! w6 E; \5 L1 k
};
) b! L3 G" `2 n9 {+ O# u& g
/ W& m+ Q+ [6 m. Y' ^static struct platform_device da850_evm_tl_leds_device = {/ ]) p0 d; N/ u& g8 U
.name = "leds-gpio",
/ D) L0 c8 {9 ~# k$ E .id = 1,
) G M8 t: I3 \8 l4 X1 m2 ? .dev = {, l0 }5 x" P* g) m
.platform_data = &da850_evm_tl_leds_pdata,) E o! e1 s2 Q$ r
.release = led_dev_release," M4 _: {, K8 e
}& `# t4 z& g, g! X2 O
};* @9 W# K& S- s! X0 u/ k: H+ t
2 k* A2 \- M* m8 H
static int __init led_platform_init(void)+ U% f) J: _# c6 A8 B+ Q
{
# l0 D) X9 x4 z2 P! o6 z. f int ret;
: ]" z) t- j3 c* u#if 0
" N+ X/ @9 l E6 p2 I ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ p* ], w0 c$ m7 a
if (ret)$ g$ s( X: ]3 y. q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 M9 ?( R4 \: ^: W4 F* ^) A5 g8 y
"%d\n", ret);
, W; w, h P% d: E% |% |#endif- o3 g' l/ }( z3 r
ret = platform_device_register(&da850_evm_tl_leds_device);
; p$ H- d9 @3 ~4 x, j+ V3 x$ \. V( E if (ret)) d/ w1 F* f+ H. [
pr_warning("Could not register som GPIO expander LEDS");
) }$ q; K! ]7 w else& }+ V4 S! B! [
printk(KERN_INFO "LED register sucessful!\n");( D" F, b9 e# Q
% n2 D& j& w3 O4 \. g) E' \/ s return ret;4 n3 m) l1 W& R$ [0 n) W0 U
}5 K% e& Y. q/ I$ @9 h
0 i, k2 W0 q* v2 r, gstatic void __exit led_platform_exit(void)
& Q) @: w( [% g4 S. s$ C1 m{
6 u# V5 a$ O+ W1 z$ C: ?3 |! B platform_device_unregister(&da850_evm_tl_leds_device);# b7 \+ Q8 S1 P, L
% k# q9 c: i5 f4 K5 E
printk(KERN_INFO "LED unregister!\n");
7 R( ?$ \. b3 Z1 e& s- j6 d7 i- a}0 X2 l ? Z1 S8 ~
& R4 J+ H: m* h8 u' L- d) emodule_init(led_platform_init);; A. g" b# E4 c9 o; Z
module_exit(led_platform_exit);
, [7 R' W9 w8 n7 \3 \. J* ]1 z& I# e; q$ ?8 p
MODULE_DESCRIPTION("Led platform driver");
$ Y/ d( ?/ i D( H' FMODULE_AUTHOR("Tronlong");
5 b$ _# r( S7 e8 v9 P' uMODULE_LICENSE("GPL");
; }1 u1 ^: C K0 f
* }( }: c/ b$ |/ w5 J& i4 V |
|