|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 g. D2 }% d* u#include <linux/init.h># \* D4 W7 U# ^5 R3 I6 `
#include <linux/module.h>
" p' V, t, J9 c0 Y; `#include <linux/kernel.h>
" A1 y9 ?/ B7 p- n/ ]' N( r3 v6 X#include <linux/types.h>1 J# x, r' Q: C# p& t* j2 {$ H
#include <linux/gpio.h> N1 T! c8 S5 _: k" @
#include <linux/leds.h>
4 u/ Z( `$ q9 W#include <linux/platform_device.h>
& z. X# _8 p9 w0 p) B! A8 m- V M% U- e
#include <asm/mach-types.h>5 B* l* j. G' M) X$ e8 k3 {* n" |
#include <asm/mach/arch.h>
: b* _; _3 t4 y- W#include <mach/da8xx.h>
; Z- j# @/ I' t3 i% ?7 x. Z* o#include <mach/mux.h>& c( Q. t, O+ F* k9 A, b
k8 j q8 P, e" m" I4 {% ^#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ r% M" ~5 @9 x* n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ L5 ~, c; V s. ~% u
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 S7 R+ @$ w: o2 r& K( K#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 c7 k; R8 }( Z0 h; H
$ P* H( W7 i" ^; }) N/* assign the tl som board LED-GPIOs*/
. n7 t: C- @; |( Q% c4 E& p6 qstatic const short da850_evm_tl_user_led_pins[] = {
8 L4 H$ }0 J. v5 Q1 Q5 i /* These pins are definition at <mach/mux.h> file */9 F9 a X5 S; U! o' E1 g5 @
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 J: I5 [* X, d. m- ]8 Y$ D5 S
-1
5 x! |* K' b; z! H+ A8 I o5 O0 a i};' r5 e) h& s4 g' D4 D
- f$ b. c! [. h% u; dstatic struct gpio_led da850_evm_tl_leds[] = {
1 j# f0 B4 F" ^" f& Z1 H2 R { [5 t: l4 P% U/ z
.active_low = 0,( h# d1 U, U- l" U# j, V
.gpio = DA850_USER_LED0,+ W" U( r \1 S$ u- R
.name = "user_led0",
k! w, _ L8 {, {6 H& O .default_trigger = "default-on",$ K5 y8 j) u5 S' w, ^4 K
},7 o. w7 {$ {4 h: I0 D2 ^
{" R2 v' ]3 o# `# q
.active_low = 0,
- U- ]4 s5 S7 @# o2 ^7 U .gpio = DA850_USER_LED1,1 X- v) K/ w+ k) ]
.name = "user_led1",
& }, F2 h, j2 N% t E* t .default_trigger = "default-on",3 R- F- F ^8 N9 @4 N2 M7 K
},
) ^. P9 @/ Q; q" P; K, p' i3 ?/ r {; B; D# Q9 w. l' D; I
.active_low = 0,
0 ~! E+ [9 t. V! r- O .gpio = DA850_USER_LED2,0 X4 z8 w3 X$ }$ _' N; ]
.name = "user_led2",8 G h7 v9 N; S( V/ x5 q
.default_trigger = "default-on",- N6 u- u$ N4 L5 i
}, t1 ]$ l; O2 |8 d
{
5 E0 C. k3 m# X; E h7 U, D .active_low = 0,
# x" d7 Y7 P; S8 y( u7 B .gpio = DA850_USER_LED3,# m) T! W* l6 |* J$ A! N
.name = "user_led3",
8 W+ K/ H. f/ O9 v: e( }2 \: ?* O' V .default_trigger = "default-on",4 W! H3 `5 k4 ]! e! S- `) y3 F: L
},3 Z4 d) b* N7 o7 {+ E$ V- X
};0 T" T* N b* ]/ O8 k7 U6 ^( I
5 ]- j7 N: w9 i/ c$ v
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* {( \7 T4 l# [% r9 H& N- V
.leds = da850_evm_tl_leds,
& W9 {. p7 [# ]* D+ i .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, t& L A$ j+ u7 _9 {7 J};5 E% y% [; P: X5 t- A% X. j
4 u9 e& O' U( B0 V* [6 Astatic void led_dev_release(struct device *dev)
) D0 O9 v7 _) L- p{
9 ^ n/ U' c$ d U$ C- Y, [* L};" ]) w, T' [4 I' A; c7 |
3 X( L5 D2 B; Q( X4 Xstatic struct platform_device da850_evm_tl_leds_device = {
! e3 \' ~4 p' b .name = "leds-gpio",
/ G' ]% U( V* I, ]/ \# f& m .id = 1,2 l+ Y+ H* B: H& p) H n
.dev = {8 d) e/ I" v g8 c( z8 A- S
.platform_data = &da850_evm_tl_leds_pdata,1 i+ m5 z/ |& ]' b' e; |
.release = led_dev_release,8 R; J1 c6 ~% T; I
}
8 E+ Z4 D! f2 T, u5 W* E};- a ~) D" h% J# |5 M
! k1 q! j) a4 L3 U4 e" }static int __init led_platform_init(void)- a. H2 y, N; Q' J. T; `, V6 B
{$ U/ O# r1 E' X2 I4 m
int ret;
' Y% L2 m: n' g- p' G" L3 M#if 09 N* ^. M) `7 o9 T
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 D$ `: x7 o0 j% t7 T# V ] if (ret)
% |, E4 K8 `2 b! @, B) V- g9 X pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ n( Z' p; E( g: A$ e "%d\n", ret);
5 ~* u8 X) x. h: F#endif
5 B+ f0 g' e) v ret = platform_device_register(&da850_evm_tl_leds_device);1 }' }" X; ]5 P9 q" c! B
if (ret)8 }1 Z( t. M7 |, P! T) s
pr_warning("Could not register som GPIO expander LEDS");
8 q7 N4 k+ { b1 V' `0 n; X else
_8 c G$ t# T& _4 o( E printk(KERN_INFO "LED register sucessful!\n");
% f8 z8 U/ Q j- [" f
4 k2 ?2 |0 V: }- P: H( J return ret;
+ \2 v T5 \8 p# K8 L% s! a}
$ o: L: r5 l# X" V( J7 N: i/ \; y0 N4 M a
static void __exit led_platform_exit(void)
7 U9 z6 c. C0 }+ {8 J7 J{7 b/ k1 X: [* ~) K& N/ C! t
platform_device_unregister(&da850_evm_tl_leds_device); F$ [% q9 `* I4 [; A4 K. R7 y2 A
( ~* d2 u* w0 b5 Q1 | printk(KERN_INFO "LED unregister!\n");
8 P1 |& c3 I1 ?}* `4 {6 }9 ^5 G3 x
) P8 p% @, _+ \5 L* O! Y
module_init(led_platform_init);% W8 \; S1 V! _: l0 m
module_exit(led_platform_exit);
, Y% ~- a8 K- j, d% k. A+ N x4 s8 W4 }0 ]4 f
MODULE_DESCRIPTION("Led platform driver");
5 b, h3 @6 @) c: P6 `$ a( bMODULE_AUTHOR("Tronlong");- e& l( C" e* n( w- \
MODULE_LICENSE("GPL");. E W. C% V7 x6 E+ N
6 F8 s- a5 x" {4 a+ T! T |
|