|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ e, K* M# I; N6 S- @4 s* j% P6 ~- X
#include <linux/init.h>4 E+ {4 ?: Q( j& _* f
#include <linux/module.h>
) M$ z) K) h5 A#include <linux/kernel.h>
2 S4 M U1 a& C/ E#include <linux/types.h>
3 j5 h; ^/ R0 n, {5 J% [: L#include <linux/gpio.h>
" l$ o1 F- m ]#include <linux/leds.h>
( x0 n! P, W+ v: d7 h#include <linux/platform_device.h># { V; ~7 E) f4 | @) R+ w
( T8 @. W- w' O0 j( Y. U" f, A! |#include <asm/mach-types.h>
7 ?/ C4 l; f7 {#include <asm/mach/arch.h>6 U i, j- V ^; r1 N- b7 ^, X: |
#include <mach/da8xx.h>6 e, Z* f; V/ W8 G8 R+ I
#include <mach/mux.h>- U- F6 |1 L! q2 |/ i' D
1 J' j% b: q+ A
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; c* h* `7 C4 P) Z, W. t#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), _% B1 U/ X" F9 T6 n1 [
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
O" q8 L7 M0 \/ [4 O) i, y" r5 e$ y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 r0 E' [- b2 c% Q7 U7 c/ B- \4 {
8 Q/ p O2 V. e- w2 g8 d: u( d/* assign the tl som board LED-GPIOs*/! D3 r$ x8 P8 }! A
static const short da850_evm_tl_user_led_pins[] = {2 m( \, p6 V* e3 N- H. G. R5 W2 W
/* These pins are definition at <mach/mux.h> file */
' ~5 i9 D6 ?4 O1 |7 W3 y4 T8 G DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ c# L! l1 ?# N3 i) u5 [5 o -1% s# t5 T0 J, p/ S! ^: q6 ~
};* k% Q- T: f* M" V9 o( x
/ ^- |% C1 x2 y ~: z* v. B
static struct gpio_led da850_evm_tl_leds[] = {
9 ^. c7 ]" P6 q {
2 v4 v7 U: O" Z. D .active_low = 0,
( ` V4 Y5 |3 V& P& W! z' b .gpio = DA850_USER_LED0,$ T# n% b: w6 Z0 \- h
.name = "user_led0",9 g, P- t$ n, M8 I
.default_trigger = "default-on",
/ |) g( E y- E1 ^ },+ h* }! T. i' m" q% {8 R% m |
{9 r% Y7 Y% o: C4 t
.active_low = 0,; a" r! R' a, V; v
.gpio = DA850_USER_LED1,0 Q! _) G( Q! A, K0 R& p' n! X
.name = "user_led1",/ {" n# ]. i5 }! P* |/ n u
.default_trigger = "default-on",* e. |$ k- u& U' {
},
" }3 s' Z, N( Y8 D3 i {
& c4 h% e3 ^# s2 G& D r$ _* C .active_low = 0,/ s0 O0 M4 ?- C$ G e' c
.gpio = DA850_USER_LED2,/ W. ?) N, @1 K M' J
.name = "user_led2",- | U8 E: n" P; ~8 G# F3 o1 f
.default_trigger = "default-on",3 Q" _& t, G6 P2 H, ]( P5 ^7 O& B+ w
},
n/ E/ F# ] r- u* t% r: G" e/ V/ ? {4 p* [# X% R. m: _6 X
.active_low = 0,8 q$ y$ ]$ {( d6 j
.gpio = DA850_USER_LED3,. X1 F u, d0 f* a' X7 }& X
.name = "user_led3",$ P! H# \1 e4 Y, H+ ?! A' d; G
.default_trigger = "default-on",5 v, N# M# c! @) W! M; {$ D
},( D' w8 `* x0 d$ `' h F2 {
};
8 F+ M8 ^ [9 Z8 G* I
) f) W" D9 E/ D9 Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. ~; s& E* o4 Y0 ^ .leds = da850_evm_tl_leds,
% d. V5 z G7 [+ ~" J" J .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: Q+ R, k0 x& Q/ ?" e( q4 C
};5 F, V; Z; a6 {' \ }; r
\0 ?0 r' s' a7 @, m, c* Fstatic void led_dev_release(struct device *dev)$ J$ c5 I! R* I# X
{# v/ c4 @+ E, U
};! I5 O( q; z& ?" U8 Z4 \
& y$ }3 \+ T3 zstatic struct platform_device da850_evm_tl_leds_device = {% X" B& l% j: I
.name = "leds-gpio",6 F( a5 P' ?1 D& Y- p$ b
.id = 1,- Q9 z2 B2 R k B
.dev = {6 \2 X9 ?# _/ X2 _9 F% Y5 s
.platform_data = &da850_evm_tl_leds_pdata,
4 m' Q( S0 E% l .release = led_dev_release,
6 t4 q0 o2 W2 n }. K" \: S, ^+ g. x, |* o& M
};2 R1 T. m2 M* M. s- u
7 b/ r8 C+ k( h% p- S1 Q
static int __init led_platform_init(void)" q* X, A* u* e# `6 P5 Z
{
9 x, ~; u5 u9 [# m+ x8 I int ret;0 B3 j* S3 b5 j: W q( } o
#if 0
0 U$ w1 C+ t; ]7 |* w ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! q% Y/ L+ T3 z2 f3 ]: c
if (ret)% q" Z: U/ B. A( k; d& n1 Y+ Q! x
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ B% |: R% e% E! v1 J0 X. e( w "%d\n", ret);! A; T# ] M) e. c# f
#endif
% s( n( ]0 s- v# l- R, I ret = platform_device_register(&da850_evm_tl_leds_device); W( K) b' S8 {7 m0 b5 ~
if (ret)
& r5 s. |3 }, V9 F) ^ pr_warning("Could not register som GPIO expander LEDS");
i- C& b5 Y$ }2 } else, ^( P. X; q& y. K& |# I0 S `0 f0 Q
printk(KERN_INFO "LED register sucessful!\n");
/ x0 }# ?6 N4 x: B- q
2 R+ A" ?4 ~* |" Y return ret;
: T! i$ t9 @9 G0 Z$ @. r}
) e4 v& H( x( c
. i/ s6 V+ q# I$ Sstatic void __exit led_platform_exit(void)
8 D7 \- V6 p- K2 k$ Z O4 e{
6 [7 }( x! g2 x! ]: w platform_device_unregister(&da850_evm_tl_leds_device);
x6 W) U; p8 A# p( O. a0 f( z' e' S! [- |" `
printk(KERN_INFO "LED unregister!\n");# I, e9 q2 X: U7 x l; p# L+ x. w) \, K
}( g1 @( K# K C
# \' `6 S( ]* n0 g: l4 N
module_init(led_platform_init);3 D+ E3 ~7 I1 @
module_exit(led_platform_exit);- U( L. Y; S7 k, r6 M0 n0 v# G0 ]
6 g% ? \ M5 ?1 H# l
MODULE_DESCRIPTION("Led platform driver");
$ U+ f8 y: o( cMODULE_AUTHOR("Tronlong");
, U6 b# \6 ~0 zMODULE_LICENSE("GPL");
: n+ E7 }. s! i0 G5 w
@1 u8 b! G# H* M$ g; ~ |
|