|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 C' H' P& H Q+ m9 I4 u8 j- r- R
#include <linux/init.h>
& G& K' j4 l' c) d+ p$ w# `( M#include <linux/module.h>9 Z; d! ? I3 Q- F$ {4 t: c, O
#include <linux/kernel.h>
3 X% Y( y$ w. _4 X* R& h" _4 H. S" g#include <linux/types.h>
# u E0 N# Q& f8 Z#include <linux/gpio.h>
K7 Q4 E, R8 H/ ] Q* Y# Y5 Q; a#include <linux/leds.h>
1 Z V( i' K) Q: f* q8 V8 [#include <linux/platform_device.h>2 j% l. Z0 O; ~4 U
& o( r2 a' f+ Y
#include <asm/mach-types.h>
% X+ g/ ?6 A w+ w#include <asm/mach/arch.h>% J/ M% U& Q! s! r5 J+ E, V
#include <mach/da8xx.h>
. `6 X. t' F) n* s7 w#include <mach/mux.h>
: r8 Y2 U4 }$ ~
' U' i5 z# P" V' z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 H9 z: V, u9 V' @5 V#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 {/ j5 m- B( ^# h
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% z* Q2 _( b7 z) g' P#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& P4 r, m2 }2 \$ n
) R1 ~- f) @& Y0 y8 n) V/ U' r7 M/* assign the tl som board LED-GPIOs*/7 b/ Z2 n T. t( D, [0 h5 C5 B
static const short da850_evm_tl_user_led_pins[] = {/ i7 w n: Y9 ]9 V
/* These pins are definition at <mach/mux.h> file */" m* |4 Y; H( t. ]
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& |# u" A, x" w/ h. a& k8 }$ I* u
-1
0 [ b9 k3 i& O8 v; i& ]: J( E};7 s% R1 n7 W: m0 [% `. K
5 v# g( b+ ]" t/ L! Lstatic struct gpio_led da850_evm_tl_leds[] = {6 J( \6 C9 M+ k% P5 i" M8 a
{
9 O& \, C \' A- \ .active_low = 0,' r1 C+ V: ?. o6 V* `& U6 H
.gpio = DA850_USER_LED0,/ D) E) [- Z/ i
.name = "user_led0",/ C1 x8 N8 o+ C, g& p
.default_trigger = "default-on",
( [- }' R i, w, m& T2 i: b* V3 R },2 }! q- n: h4 J. O
{' S5 s, f; _) b* w
.active_low = 0,; B3 O; z; R5 u/ F
.gpio = DA850_USER_LED1,
6 n; B- O1 {4 b. h: _ .name = "user_led1",
; y2 t, L/ d. d: d) x .default_trigger = "default-on",: _6 e9 S% U5 q
},( @+ s3 F/ v) n' R
{
0 K5 s. P8 Z+ @/ ]. ]+ F k0 s .active_low = 0,; T! O1 ~# i: j) x
.gpio = DA850_USER_LED2,* e/ S9 X7 h" K7 D4 {9 I! Z; K( W% d
.name = "user_led2",
* B+ x/ Z [( Z" R$ A .default_trigger = "default-on",
" F* w; N2 M) t$ f# d0 g7 @ },
1 u' b" W) q' x2 i {
: F/ n( |- d1 Q$ {8 b4 x$ A .active_low = 0,0 ?. i+ h8 T6 s/ v3 o
.gpio = DA850_USER_LED3,/ l- d7 K0 N# ]9 S8 }! N9 f5 X
.name = "user_led3",
3 B, x2 r& w, X1 f) G( r .default_trigger = "default-on",+ E, u2 c) L. B; P# b/ ^6 l8 k+ v: c
},
; n* \- D3 J7 K- v};2 o) r% S/ T8 Z$ h K5 @
5 U0 E V- g1 j: [/ l% w; Cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. a" h3 M: j T9 C6 U9 x: ]
.leds = da850_evm_tl_leds,7 k8 H5 T5 v( a9 \+ F; R( t; r
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),& q$ w3 u- K; a6 O, e* k
};
5 I5 S* \2 Y9 H7 T" t) w- d3 {+ K$ B0 i6 o
static void led_dev_release(struct device *dev)8 |% _. P& q# h$ |2 X' o* p
{ _$ v" d; c" C7 x5 q' e
};3 h: c* l5 g% G. J0 j; S# a' n
4 g" T5 o; Z9 ?0 ^" R& M
static struct platform_device da850_evm_tl_leds_device = {. d3 W5 d7 ^9 j$ T7 |
.name = "leds-gpio",
1 A1 }2 v$ ^. ?: d+ @ .id = 1,
( I) g. C& t9 e: H8 E3 I5 k3 D .dev = {
" M. P) X; u j5 M .platform_data = &da850_evm_tl_leds_pdata,
. t" w, R/ y# `* e% Q4 ]' E" ` .release = led_dev_release,0 |4 b% r; J7 J8 s# \7 K
}5 @* y+ T9 T1 }/ M7 p9 |- p
};6 l0 ]% v6 y* a' B# |" q& T" \
" R9 x3 R" o# B: `5 u7 ]& b# Tstatic int __init led_platform_init(void)
) N1 B4 [/ S W( F; A! n9 x) x{1 N l0 U* I+ @' c
int ret;
( R5 i$ k( i, N8 Y# X" D#if 0
$ t Q2 j- s# ?1 U+ L; z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- W" s2 c8 S! W; b { b3 L if (ret)- m# i% _# P- k( k
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ Y6 T& S0 \; t( L "%d\n", ret);
/ |: {4 W9 C4 E& {) h#endif
7 }7 H, j2 i2 {5 j/ [% @; \ ret = platform_device_register(&da850_evm_tl_leds_device);
4 F# k: k' h4 e8 p& m if (ret)
+ L5 A! P3 H$ k$ d# Y& T7 f, ^ pr_warning("Could not register som GPIO expander LEDS");! g) _( i$ I% Q) W; w- R* C
else b3 {- j2 u% w+ R
printk(KERN_INFO "LED register sucessful!\n");. p% ~# s3 M- u6 @" q8 X" d
y: y( R: @: F% I; F! w
return ret;: }4 P6 l+ C3 |2 Y) w3 H3 m
}
" ^/ @$ Q" c1 c# H8 r( i4 ?3 m& ~4 O7 R W1 j2 G, m
static void __exit led_platform_exit(void)1 j6 I% h- ^- x( O) }/ g
{
/ _! X( |5 Z/ h9 T% d( P platform_device_unregister(&da850_evm_tl_leds_device);
7 y1 u% _" j) u2 _1 b* y" L
" i4 Q. {; u4 Y' `9 k printk(KERN_INFO "LED unregister!\n");
/ N' T- b1 |) d8 t7 @/ X# C}' `6 C* @! ~9 \& x
# _8 Z {, @5 r+ Q; N5 f6 Amodule_init(led_platform_init);
3 C7 G7 |/ V8 |" Z" m$ u1 d) omodule_exit(led_platform_exit);
9 ]- R3 l5 f5 ] o2 \1 \( f
8 B/ a$ w/ ?1 m& l" bMODULE_DESCRIPTION("Led platform driver");: i! k& b7 P2 B/ a- r9 g9 @' r
MODULE_AUTHOR("Tronlong");8 F& i& B: u, Q0 t, h7 R
MODULE_LICENSE("GPL");
& K4 U: e2 k9 k& e2 [
% }% Z: n1 |& E4 w( z) s |
|