|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 G8 k7 H5 ~; M, }8 B- l#include <linux/init.h>0 E! S1 i% ?8 z0 {% y8 S, H; _
#include <linux/module.h>3 Q2 |7 p& { e
#include <linux/kernel.h>
* N$ E1 M7 A3 P#include <linux/types.h>- W9 k5 n) J9 p
#include <linux/gpio.h>+ a! Z! Y* s9 o/ \% e! e+ N2 @
#include <linux/leds.h>6 A/ Z( S/ {" d
#include <linux/platform_device.h>
. g% B# S Z/ N5 {* r8 i6 i# A: { X+ I
#include <asm/mach-types.h>
9 R$ s6 l# ]: D( h m5 y#include <asm/mach/arch.h>
5 B6 }6 Q. r! V#include <mach/da8xx.h>
" M6 }! s4 j7 m9 L#include <mach/mux.h>
8 [4 J( E3 F* K0 A
0 Y6 a9 o4 {4 |& s( G' r#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 G: |: |+ x4 d7 W9 q& J& e#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 O) |$ `9 p' ]+ L: {) Z6 j8 N* L#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) t9 W3 |5 W$ x& r7 g
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 F% _! ^4 X! v0 |: q o9 D2 x# x" n/ ~. o! m% \% q
/* assign the tl som board LED-GPIOs*/
3 N- ^0 y9 k. Lstatic const short da850_evm_tl_user_led_pins[] = {
+ J( O" s! S2 P+ m' P4 F /* These pins are definition at <mach/mux.h> file */, A. o R/ U4 O& h. D0 X+ T# H
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' o) D; u1 L; a4 Q -1
$ c: g) c) _$ t$ j};
" i8 p ?2 H6 s+ M; f$ t3 i6 a$ T' Y8 ?% v# S# Z* G+ T0 b( Q
static struct gpio_led da850_evm_tl_leds[] = {8 E1 r- |4 Q4 `0 Y9 L
{6 T8 J+ {4 f$ Q5 \4 W X; {
.active_low = 0,
& _0 p7 `0 D; H8 [! ] .gpio = DA850_USER_LED0,
# g1 c: o+ e# G0 @ .name = "user_led0",
9 l" ?; G) h* q% ]$ V .default_trigger = "default-on",- k: r4 `, }! h" ?: }' a
},) R5 _" i- H1 ~$ W1 f8 d
{
0 n% z* q3 `8 M; _6 T+ L& g# E+ O .active_low = 0,$ v( F; W* z0 y1 f4 ?2 {
.gpio = DA850_USER_LED1,
% s9 H0 X8 i0 [: e" J" I, v, S% q .name = "user_led1",
1 C/ v# ~# \& j$ U; Q* H! `( U( a .default_trigger = "default-on",
3 v: Z; U ^% w x! y8 a+ j8 |% W },
6 s' s. q* a$ }6 R, }) A1 ~ {
4 L6 K( S2 j% H" W+ I6 b0 ]; ^# _ .active_low = 0,% M) y# R/ ]# |
.gpio = DA850_USER_LED2,
2 ~, C- I2 G, t6 X. `0 p" O c .name = "user_led2",7 P6 I8 B# X6 e; H6 I+ O0 F
.default_trigger = "default-on",: _+ d: \, H, w# V! j
},
: Z+ V( ?# {/ E3 \ {7 K- y% v, [1 \0 I, s; `3 j# x ]
.active_low = 0,
$ ~2 Q/ L, O6 p8 T1 p7 d .gpio = DA850_USER_LED3,
2 Z& B+ ]0 _5 ~2 n0 ]4 P$ M .name = "user_led3",; R% _/ L' r2 x2 D6 ]: t
.default_trigger = "default-on",( X# [4 K) C/ b# _/ a1 I4 u0 @
},$ ~9 f& g! |* D- D" V/ k
};
0 l" {( X; |7 w# |' H$ F9 C6 L4 \1 w, i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ Y2 }- |# \- ^ .leds = da850_evm_tl_leds,6 q+ d2 z, }, \- \
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 N$ l: |: n0 f' Z7 z+ s k2 v};
J) J2 \1 W& O4 y U' x/ k7 b6 E+ g/ g- L
static void led_dev_release(struct device *dev)7 Y0 y+ ]% @3 y: k- X
{
/ S- W9 a' b4 V' X# s+ t+ i& R};
) D$ u+ P# E7 e% J# m! e3 Y9 O3 {+ j. ~* s' t
static struct platform_device da850_evm_tl_leds_device = {7 \' n0 W7 w$ l" ?* \( {+ J
.name = "leds-gpio",
2 K6 G1 k" x/ {! Z( z4 c .id = 1,
! q) Q% ~: S) Z+ G; _) W w" ] .dev = {0 @! f& ]7 m; W$ w" t& V
.platform_data = &da850_evm_tl_leds_pdata,3 `. L9 l4 E! k& y U" P+ \
.release = led_dev_release,) W1 |: ]* h% P& ^ ~4 i
}
% A2 n3 _! G. E' T. k& n' D};1 G. v% C1 m# d0 Y( b+ }& I5 k
: \! U8 e$ A9 E9 c2 dstatic int __init led_platform_init(void)0 R7 G9 N# l4 Q+ N2 G
{9 n/ C1 ]: N j; P+ U2 P
int ret;8 M& Y7 ?, N' p- ^1 U
#if 0, X y- I+ @) A+ }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, J# V4 _( `7 x' j' I. S+ | if (ret)7 N9 c2 L1 Y& q7 e+ O3 {( W
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 w) d* b' B% Y, ~ "%d\n", ret);1 @, i+ p Q. @" X/ [ s
#endif
]/ ~. z( p6 R6 a! N6 h, w! |) I ret = platform_device_register(&da850_evm_tl_leds_device);
! O) I# t! P) C' v: k if (ret)
- |4 O9 N& [( z# p) F9 G' @ pr_warning("Could not register som GPIO expander LEDS");" |+ ]. \3 S3 W" ]) s/ {* D
else
7 K5 ?6 X, X# o5 v+ z5 `+ l& k2 \ printk(KERN_INFO "LED register sucessful!\n");, n/ d. e! K" K+ F+ b" Q
& g1 J" \& L' ^: }6 w5 o return ret;% u. O: S6 F+ N" w2 f3 Z9 `
} X( {1 {2 ?" j2 q
- `& ]' |( l& W1 y* h3 d |6 c# x
static void __exit led_platform_exit(void)
4 M W3 z: x8 G# r2 ^6 ^0 \{
( M- L w$ Y1 D" | platform_device_unregister(&da850_evm_tl_leds_device);4 b/ |5 ^" B: O2 n: E' C
; W- t% x, e5 [- J3 l
printk(KERN_INFO "LED unregister!\n");& x5 v+ X0 d* W2 d
}
3 ?- B2 z. w; b. \# `8 I; S8 ?
' I: n5 F" V' Q! u8 Fmodule_init(led_platform_init);; J" E8 q& f$ k. B
module_exit(led_platform_exit);% a2 X, \8 o2 s# Q4 Q
3 A, f H6 c+ F2 C
MODULE_DESCRIPTION("Led platform driver");6 R4 n( `9 s6 [7 U! X
MODULE_AUTHOR("Tronlong");5 k: Y4 z& C. `( z% b
MODULE_LICENSE("GPL");0 x9 _+ m s5 b- ~* R+ ]
) K' W% H: g; n
|
|