|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) a! d! e. X8 L7 e#include <linux/init.h>& |2 X( H, g. ^
#include <linux/module.h>
! y7 G7 e# B, w2 R5 h; q#include <linux/kernel.h>4 ]1 q9 _* |) T2 C5 R6 _) u- c
#include <linux/types.h>& @+ T" h1 k. L; p: G
#include <linux/gpio.h>
# p) i* L; X3 i* ^4 I#include <linux/leds.h>
$ I4 i9 [' q# \+ Z0 u. `$ c+ q5 [#include <linux/platform_device.h>+ P! U$ ?& O; P' Z
8 s/ ~, Y0 l: m+ I' z3 a#include <asm/mach-types.h>
9 u+ m4 v& a1 {6 j* k, Z# c' k#include <asm/mach/arch.h>
, g( A; y9 m" L- }( E! T. n#include <mach/da8xx.h>
! y! O# n0 \& _5 z! _. c#include <mach/mux.h>
4 A+ r5 S2 a0 h; ]2 U5 p* d: l: F. d, d3 v7 K" U% A0 I% q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 y: g. P5 e h#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 ^- s {8 B1 X% `4 ~. d
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) l! i* c8 C5 x9 j8 E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 v5 \( Q( a2 z- A
7 L: T, o3 I ~5 ?* ^; Q8 y P
/* assign the tl som board LED-GPIOs*/
9 h- Z/ b# l5 l; m S0 W# istatic const short da850_evm_tl_user_led_pins[] = {
# e. t, ?7 l7 W9 v. n6 ` /* These pins are definition at <mach/mux.h> file */
8 Y. A0 a K# {6 W) c DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 {* z6 L. c1 Q0 |7 P5 a
-1
6 ]( T- j5 f, i/ Z3 E6 [0 \};& P% E4 I% c$ K7 q( o
3 `) l& _6 H9 {static struct gpio_led da850_evm_tl_leds[] = {, W/ o' H y3 `* l$ q
{* B# M& u K _2 L. P9 y' |
.active_low = 0,3 J' ^9 { D' ?/ }, Z
.gpio = DA850_USER_LED0,
0 Z! X; {! F/ M7 n4 ?! W4 N/ V( R' V .name = "user_led0",
1 Q8 V( X: p: D, T* O; ~2 t, q .default_trigger = "default-on",
4 `6 d4 H8 i% E7 h, L( Q: G& s( b },1 ~) |4 q7 @$ L6 R
{
7 P& [; N2 \/ Z9 U6 c! i+ V .active_low = 0,$ @/ S" H5 y' N/ w" ^- T" }
.gpio = DA850_USER_LED1,
1 z& d- G, G% |( g( k .name = "user_led1",
6 H5 r8 S+ I7 q* A0 m0 x .default_trigger = "default-on",
& y W2 r% O! J+ f% ~0 Z+ { },
9 z. w. i7 Q! d! a' r z+ p {
$ A5 t6 |9 A, Y$ n7 I! I: j( Z .active_low = 0,+ O" n1 b! k6 u/ C
.gpio = DA850_USER_LED2,9 K5 s2 c) i. A: S: o. W6 c
.name = "user_led2",& m) e' t5 g. g9 ]" U' `/ z
.default_trigger = "default-on",
' g$ \, i5 b/ ? },
+ l/ G s3 } p8 E2 e9 @3 X9 W {! e% r( d$ ]- A5 n2 X
.active_low = 0,2 x8 S; u# q3 u, K. y
.gpio = DA850_USER_LED3,+ C( K; b) s5 Y, o; {$ q
.name = "user_led3",( P0 j+ D/ x4 y
.default_trigger = "default-on",! c r* D; f0 V' h
},
8 G6 [& j+ f, `- p5 V% N q};# L3 g4 B$ t9 r1 V
! Q3 W) O) @: m; _2 P
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 p" F7 b* J$ ?
.leds = da850_evm_tl_leds,; E4 ? n1 U# Q) Y3 [" a* j
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' O, ]( ~ I7 Z};3 s" ]# }# g# N: T- D
$ X, r: y# h# N+ @* R6 mstatic void led_dev_release(struct device *dev)
- Q& l9 t g/ T{. `' G+ e4 o$ a
};3 f1 I% G) G3 d' T8 G
3 P3 H/ M# K) ?* C6 H/ }4 c7 I5 jstatic struct platform_device da850_evm_tl_leds_device = {
1 S4 N- G9 x) G+ R1 e: S .name = "leds-gpio",
, ~$ b7 u3 b4 G .id = 1,3 p3 W# I, W, k3 g& s
.dev = {1 Q- R) ?) |# q. [
.platform_data = &da850_evm_tl_leds_pdata,
5 e Q/ W8 S/ E, V" S .release = led_dev_release,) T: j/ X0 i; w2 `9 R% {9 a
}2 X7 g% O3 e$ V0 q) f" Y
};8 C8 u8 m% k# o4 B
% W- \7 |+ L9 `) L# w3 ~5 C6 ~
static int __init led_platform_init(void) B1 w# `/ U3 `$ }* w4 ^1 h e
{
9 g) n% k" I" D$ C$ [6 f1 d) p: A int ret;
3 A5 J" L4 |: y# N7 f) [#if 06 }( Z: u" U1 H/ r6 T# h+ N
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 }" ?! n8 j/ N' c" b8 F! H if (ret)
# n; o* {7 j) n' g: P$ V pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 v7 o% y' W9 W; \ "%d\n", ret);
! J/ u: G$ K( C#endif& i9 T9 Y. y! T- A7 o# `
ret = platform_device_register(&da850_evm_tl_leds_device);% i8 Z9 v% j, @! D2 U/ m1 g( `
if (ret)8 j3 Y% n8 [ ] M
pr_warning("Could not register som GPIO expander LEDS");. b) i; @# {- {( A) n" N+ I; c
else
6 B% V. P1 o* g- V printk(KERN_INFO "LED register sucessful!\n");9 g5 J. D0 a* Q* _0 I0 O
, S% H: I8 }4 N% B
return ret;
" e j; H, o6 Z1 v" S4 J" D5 E}+ x: D& ]4 s6 }4 ?; V) [9 }
9 e8 E, k* U5 w) [. X8 c9 y8 D
static void __exit led_platform_exit(void)4 o; r9 L( |8 z, K4 t/ t
{8 D; f& P4 s( z7 s" o! U# V3 E
platform_device_unregister(&da850_evm_tl_leds_device);; k. @4 N5 s0 c) U1 t& u8 J, A
+ f$ z1 S# k$ b
printk(KERN_INFO "LED unregister!\n");5 f" a) ^% g3 i E6 s" n. w
}
% a. Q7 c7 F D2 ^( _% \; C3 C4 @
module_init(led_platform_init);& `) N2 \: w9 l! y% X7 l+ I2 y
module_exit(led_platform_exit);' {8 g' Z& }1 J) U
7 s4 M/ Z4 _: T4 j" J7 FMODULE_DESCRIPTION("Led platform driver");0 T, @) z( a! y, g( |( M
MODULE_AUTHOR("Tronlong");
, P; J% X* g; S) E( Z, }MODULE_LICENSE("GPL");0 p1 l5 u) p0 L# u- [, p/ V
; @* U/ R5 e8 a/ a, c |
|