|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 @' [4 B3 A* B! m% E7 `: g#include <linux/init.h>( I" s" I) B% l; C" C, M+ w: x
#include <linux/module.h>1 J1 c& d, c5 X e! t6 Q; A1 F
#include <linux/kernel.h>' f' c$ U' S8 S. j2 c! V A
#include <linux/types.h>
' {, [" L+ g2 F3 V#include <linux/gpio.h>7 t) ^4 Q/ q% E1 X0 a- t
#include <linux/leds.h>
; p& v2 r( \) D. _' F r#include <linux/platform_device.h>( v& p( v3 K4 [( w
* r8 u3 O$ m, p
#include <asm/mach-types.h>
& A; ]. n( Y5 {' w! i#include <asm/mach/arch.h>/ g, ?- ?/ I9 f f8 g& I" C
#include <mach/da8xx.h>
: q! C4 X3 Y! V: A- z#include <mach/mux.h>) T' h: [, y! k, n' c+ |7 i# C0 w8 V
7 N4 I; G g/ ]- R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" n# [2 ~9 L* f, t% A
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 i, B: V- Y8 x5 ?# [; M% z/ Q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 j P5 I, N5 _0 m5 K; q2 S
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& o* U3 ~$ r3 Z% S( ?
6 L( E! Y8 @5 c! R/ [$ x: r4 D6 a7 ^/* assign the tl som board LED-GPIOs*/
, I I- ^: u: ~2 tstatic const short da850_evm_tl_user_led_pins[] = {- M* b% \' g' |5 [- v/ M
/* These pins are definition at <mach/mux.h> file */7 W" A& s! w) p; O3 C
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: F6 c/ R7 Y2 ~( j3 A6 ?1 D4 q- B -1
5 z2 c2 h2 ^) R6 a3 }- s3 i# a};4 z8 u7 Z x* F" O! f- ?
0 y) _7 U) ]9 @static struct gpio_led da850_evm_tl_leds[] = {5 t/ V4 _8 j/ H" Z) @4 d: }3 A
{4 t6 n% B) U- W, t6 `
.active_low = 0,$ K& h+ [2 D- S1 p+ D" J/ |
.gpio = DA850_USER_LED0,4 @+ {: f" N: |
.name = "user_led0",- M9 h5 |1 c7 X
.default_trigger = "default-on",
( `) h. }6 j$ |( f- t. c5 | },' P% R% ^* Q1 i; Q# F" I
{" P0 g: D4 p' |3 c: |
.active_low = 0,# X, }8 @2 F7 O% J1 z- B
.gpio = DA850_USER_LED1,( b" l; T8 X% m" e
.name = "user_led1",2 }: x9 R4 H" k" o$ ^7 f" z% x( U0 u
.default_trigger = "default-on",1 d( X2 F* H( }
},
; a6 w! i q/ ?" L( H/ h {
* T; `, b" x' L7 g .active_low = 0,5 l! Q+ _' _* o( u A7 @& k3 l& B4 R
.gpio = DA850_USER_LED2,
% [& N1 }" E/ j H$ p& j .name = "user_led2",
7 x- f0 `) {( t y1 l .default_trigger = "default-on",7 V: M1 Z$ {* c1 i: Z" g- p; m
},0 X |# t. B6 z; l9 N; N3 [
{
# _) ]: H5 t4 w7 m .active_low = 0,
* K: e+ V! p- X3 W8 n- t .gpio = DA850_USER_LED3,
1 C8 J/ h6 e3 `$ X9 n4 k .name = "user_led3",- V) ]8 s2 Z# ?7 D) p/ i
.default_trigger = "default-on",
2 Y! y/ Y* Q4 k3 E6 D },
4 M g- G0 M5 m3 v; J};" A: _0 D Z4 ~# a+ ]3 W7 m' z) ]
- Z( D4 z' L- F" k, vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ ?4 G0 V+ R0 V6 @0 I) r4 J1 m .leds = da850_evm_tl_leds,
* h/ E+ E0 S) C5 x! T% ~" q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( h& G$ N" Q( z/ G0 D5 O
};$ U5 Q H% H/ q7 E$ R( M
, T' D" M+ A: Q5 ]- Bstatic void led_dev_release(struct device *dev)
) h: t5 Q( [! _{) R+ o4 j+ M2 F$ `
};" S4 ~7 x! t6 f# L4 Z
; H/ \9 i6 }" Q$ Lstatic struct platform_device da850_evm_tl_leds_device = {
4 M2 _8 I" B6 J- A `, v3 x .name = "leds-gpio",9 P* [8 Q. y& H, `' z
.id = 1,
2 g A; \# p. v( Q9 q, F4 |) Z9 } .dev = {9 l2 w) [' D' j
.platform_data = &da850_evm_tl_leds_pdata,* y; c/ H, v. M6 t) g, g
.release = led_dev_release,
* Z3 J1 a" r2 h0 I/ K }/ a6 W; z8 H8 y" L6 `! Z6 H
};
% u6 t! R9 i$ Y, D* n; G2 r
8 l7 x8 j( |& W1 j, }' {3 R. Ustatic int __init led_platform_init(void)7 \' X! o& ^: p: l. ]3 x- D/ E- z! Q
{. F' z1 Z5 x) k
int ret;
- w, k( n" x1 e& F$ D! S* \#if 0$ l! Q) [1 f! |; E3 ~ @
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* c, S4 |6 N: g8 }# Z: h3 ]8 u
if (ret)
4 ^! @* ]* U8 z+ ^ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 T. \: N- I8 g& @1 }& f/ j
"%d\n", ret);2 h% |6 v! {$ b" a: N5 Z$ K
#endif
8 n% K/ l, ^# [- z0 C2 _1 C ret = platform_device_register(&da850_evm_tl_leds_device);! p7 Y+ T3 l/ ~/ e
if (ret)4 w; {9 P2 w. j% o" y' \$ l7 _
pr_warning("Could not register som GPIO expander LEDS");
( t' A; U5 t8 T* C, D else
) L; L, M2 G4 ~: z% A printk(KERN_INFO "LED register sucessful!\n");
, o/ m5 u2 m* K/ E0 H v9 t5 s% N r0 R* |0 W+ J
return ret;
5 f5 H( M3 A9 W# t}
' C$ O9 H) @# z p7 u
. ^) y4 n& O0 `0 K7 ?static void __exit led_platform_exit(void)
! }. y- g) I- e3 i* j; W, Z{% ^6 u2 q6 r0 l
platform_device_unregister(&da850_evm_tl_leds_device);, ]9 @' q) i6 {. n- d
8 n m4 m! c- D/ g1 o1 l
printk(KERN_INFO "LED unregister!\n");
0 G, `0 y: i: |) f8 _}5 D- j' b) N+ e8 Y# q
4 {! S: p* l8 G7 A. D, Fmodule_init(led_platform_init);
6 u! t8 X' D; h J& b9 Tmodule_exit(led_platform_exit);
* `' y! r/ z" B6 C" q/ g9 g+ c5 C! ^2 o, I- w" ^, a
MODULE_DESCRIPTION("Led platform driver");
9 [6 W4 u5 F1 s3 f. TMODULE_AUTHOR("Tronlong");
" u5 g6 }1 X$ P K" l7 ]. `$ XMODULE_LICENSE("GPL");. ]* a L& \. \, _* h+ o
6 d. l/ E: i# f* W8 D2 i7 R
|
|