|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) T+ ^$ V( u; w#include <linux/init.h>
9 P& e" \+ t6 [% i#include <linux/module.h>9 i1 v9 F2 J# b
#include <linux/kernel.h>' n, I0 ?" n; r/ _6 ]; F" `8 j
#include <linux/types.h>. h, M% y. P8 S+ q
#include <linux/gpio.h>
3 C+ t2 y$ `/ f3 K. k#include <linux/leds.h>1 g2 V Z/ O( H4 F, N3 B. d- t
#include <linux/platform_device.h>' p& y( M4 i" K
4 J( `1 g0 k; R, W
#include <asm/mach-types.h>
. h# W" @! u: F3 p5 U6 X#include <asm/mach/arch.h>
. x% T0 t6 L- u7 o$ z+ a1 s#include <mach/da8xx.h>2 u: e" w8 X- [5 s
#include <mach/mux.h>
- m4 `% F% y0 G8 D2 ?- g& J! c% P+ I
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); V: K! J% q x. c( [. c( |
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' ?' C g- R5 \* _: `+ u2 M9 v; }" {#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, [: k$ E- y, ~4 f#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), z8 p2 |% T* v% E1 C
$ R9 x& {; m1 l. c/* assign the tl som board LED-GPIOs*/
5 q) Q" E4 m( V2 p+ B$ Dstatic const short da850_evm_tl_user_led_pins[] = {( f) t4 k: G% s# K4 [# S% W
/* These pins are definition at <mach/mux.h> file *// H f5 @7 a# }' f$ i6 d. V6 f
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. B/ ]2 [4 k( U$ R -1
3 R4 \3 N9 n" T};
q% I L4 c4 T* q1 B2 X6 Z
$ S# y2 I, E! |. s, V2 F+ `7 qstatic struct gpio_led da850_evm_tl_leds[] = {
$ J+ I) S* ]( Z$ `) E$ I4 U {
5 U# x* B% d U4 ?% A! Z .active_low = 0,
7 `( |8 a& \% J5 O .gpio = DA850_USER_LED0,, L. N: e3 L% \" s8 {2 B
.name = "user_led0",
* N# g2 H( _; C0 V( H .default_trigger = "default-on",
; X% [3 n. J' [6 ~ },
- z" J. J! f6 A. ?0 g6 D {
' m- }& C9 q$ U .active_low = 0,3 B! ~, v4 H6 r! |, ]1 G
.gpio = DA850_USER_LED1,
. y1 [' p: T/ F8 t- G6 r) ~ .name = "user_led1",
; q; U# k8 m5 X8 P. ?+ W .default_trigger = "default-on", T, |7 W3 @0 n3 P
},
& m$ P8 z; R7 K' | {2 K" f3 ~/ E; r% c8 M) G
.active_low = 0,
: s5 r( h: t' T9 P; g3 e* v% ~ .gpio = DA850_USER_LED2,$ ]) S0 ~1 k" w: A
.name = "user_led2",0 c/ k* b* h( o/ ] D/ W
.default_trigger = "default-on",
* j# X* }3 h2 s },; K" O& M1 h/ v
{ q, q. f. X6 D5 n: x9 g7 _9 |1 U" d0 ~
.active_low = 0,) e1 u/ V& u6 h4 N/ L! s
.gpio = DA850_USER_LED3,
b5 l7 t6 H- R V- H* k# ` .name = "user_led3",
; Y& u0 w2 G0 [ .default_trigger = "default-on",$ y' A2 E% b+ ~- M. ^
},' S/ q5 j! m. A, {
};
. H2 k0 r- l3 ?' z3 Y' r/ \, ^% P$ @* r
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ x7 K9 \6 k" x( _9 |5 q9 V .leds = da850_evm_tl_leds,& j1 P) X& [3 j8 B2 J( g& P0 K! ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 {! X4 Z S7 d" b# N};
+ |3 K) Q, D. r. K, f z5 U+ A3 M6 w4 j' O4 U. B
static void led_dev_release(struct device *dev)
- {- h* ]% V& v7 a{" Z& S0 w: o: Y, r: \
};
# B9 J" ~& G5 l# T, i& l$ {" \4 E' r9 K5 ^! d3 l9 q G9 X8 q
static struct platform_device da850_evm_tl_leds_device = {, v+ E- D3 `4 p
.name = "leds-gpio",6 v! G5 W ?/ H5 ?- X* ?6 M
.id = 1,' P1 X* J4 A" W
.dev = {
; q! x4 g6 l% Z .platform_data = &da850_evm_tl_leds_pdata,
9 T! e' Q7 r! e! d8 v .release = led_dev_release,. _' ^3 _% q( u
}
& `' w3 Y% z j, f/ t% }" O};
' H( {% t+ d3 v/ K( t, q4 {9 r+ t+ N
static int __init led_platform_init(void)
* a$ Q2 V) W$ o) l6 u{
$ C9 c7 M- u* C5 U9 b int ret; E/ G* v" s! D0 G8 O* {
#if 0- F, `* ~6 a9 W& }* w$ \1 s `
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: w1 h0 K( V; W3 A5 S5 T8 x: l/ d j if (ret)/ S% B. k1 z! S& M7 L/ i/ W0 s
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 j" @/ K/ g' n) A1 Y* V "%d\n", ret);
6 ~; Z+ e" z& U& J4 M#endif
* J5 r4 |# [0 E5 k ret = platform_device_register(&da850_evm_tl_leds_device);
# v1 N8 M5 {1 r if (ret)5 k2 r3 ?. K1 I, H( m
pr_warning("Could not register som GPIO expander LEDS");
" c, b, J$ X/ ?/ W# m else
- d, W& y. ~- {8 q- i printk(KERN_INFO "LED register sucessful!\n");
) N8 v3 |5 N* r4 M8 d1 S. s7 {7 T3 Y. w7 R( j7 }: R' O
return ret;
- B# y7 k1 Z* i}( S8 h+ s- a& v5 e: k, p
* y( f2 ?' ^6 K6 o# w; P% |! P
static void __exit led_platform_exit(void)
# v# A- t+ |/ c( h2 I+ U{; r" T: Q2 V% U: \! M
platform_device_unregister(&da850_evm_tl_leds_device);4 a7 F8 U; I4 K- y
: z0 w6 E+ O- {! v% j8 p* V6 J5 H
printk(KERN_INFO "LED unregister!\n");
7 B: |4 M5 ~; {9 U, a}- N/ Z ]1 v# I# e' k
$ n5 B1 U3 N l- N% t, Smodule_init(led_platform_init);
5 t9 Z- s2 ?" g4 lmodule_exit(led_platform_exit);' v: m9 G+ t2 C+ b. M
! U4 a$ d Y8 a3 V8 L |0 R" ?2 jMODULE_DESCRIPTION("Led platform driver");
" X: F* i9 |! G1 ]) dMODULE_AUTHOR("Tronlong");
% }' `& |' J+ a# @MODULE_LICENSE("GPL");# P0 v3 y5 g6 E5 l" l8 h
/ F3 R. H; Q. X5 Z! F z5 Z5 L
|
|