|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: H6 X" h% E5 u5 c' {2 ?
#include <linux/init.h>
" y% J% b% ~( L# Y% a' E#include <linux/module.h>: V2 H) _* ]0 ^
#include <linux/kernel.h>
6 d3 g7 x$ N# h U) E2 g#include <linux/types.h>! ?8 t$ m8 b/ q# `
#include <linux/gpio.h>
3 J ]% `( \& H; I) G#include <linux/leds.h>
7 d! c3 F. `- E% H#include <linux/platform_device.h>
- i+ [) i2 _- n8 D0 e+ k% ?! |6 b% o0 a& B/ `
#include <asm/mach-types.h>
9 u2 k& h- _ V( s1 y& J* p( U#include <asm/mach/arch.h>
0 W& C: }. q2 b$ S. ~#include <mach/da8xx.h>
2 Q% I1 H8 I, g! `/ G1 l5 ?#include <mach/mux.h>
8 j. A% ^$ ?0 n2 O, q& k) F* j, x
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 y1 W, Q3 T) G8 J
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. l( b' h# V |#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# e( r% D3 s' S4 \2 X! r) j+ U+ T
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! D$ i, v# ]8 i7 Q; `: S+ o# h8 G0 {
6 u& B/ e- i- H% f+ ]
/* assign the tl som board LED-GPIOs*// W0 c' c3 u2 H! d" }+ Z* K& W1 t
static const short da850_evm_tl_user_led_pins[] = {
& e; k9 O% V! L, x. n1 @3 z3 O /* These pins are definition at <mach/mux.h> file */
) M* h# [) S8 H* s* u, @; Q1 B DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 R# L. N% X% v: d, l2 [
-1* k" r( _2 ?: q1 H
};
5 | z9 S, |6 }9 y- ^: c r- d+ Y$ {1 L1 I8 c* q. G; @) u4 \/ i- C
static struct gpio_led da850_evm_tl_leds[] = {; U8 G: \) U: z" k( _# I5 Q3 L, x
{
1 d$ ^' P* h1 H5 m$ @2 Q& | .active_low = 0,& O$ o6 W6 m4 E! v g
.gpio = DA850_USER_LED0,% q4 z: v0 X9 v2 s7 k+ s% l
.name = "user_led0",/ ]* j) t' F, m" ?
.default_trigger = "default-on",+ [3 x1 _9 L, s9 R4 Y
},
) [6 b8 H5 I* @3 S% f& Z6 i4 R9 i( V {
4 s* ]# M: {7 ~- W" J' { .active_low = 0,/ z$ _/ O: V+ @: g; q* Q5 i/ C. X
.gpio = DA850_USER_LED1,& w$ i3 {% G( T7 k
.name = "user_led1",6 _* q' D( P5 j4 p" c' H* D
.default_trigger = "default-on",
K6 Y j8 q% {. J2 n },
& I; x* j1 K! ^/ |) Z# j {
7 b1 ^3 o+ S9 |9 C) | .active_low = 0,
! f* ~% t5 `9 R8 H G+ ~ .gpio = DA850_USER_LED2,
& \9 a) R6 `' L) v' Q .name = "user_led2",: |- D' k4 J K1 G
.default_trigger = "default-on",
B$ ~8 C4 Q: c* k }, U5 l& X2 }% j
{: j6 k, M6 U/ E. f1 e; F
.active_low = 0,5 @! a" }. ~( R% P
.gpio = DA850_USER_LED3,
3 e) D# a S- q( C4 E6 ^6 W! w2 f .name = "user_led3",0 l O Q0 P3 q+ e, C" n
.default_trigger = "default-on",
5 y3 D* D+ S& o2 K7 S },
, u! H. P! J( [1 Q8 [/ p8 [};
8 l% s% ], ~ J v$ B# u4 f0 s% j$ h# ` z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& \) t% e& A5 J' w3 i .leds = da850_evm_tl_leds,
n& e9 H8 H8 T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: w6 h# m9 h1 U5 X: h% U1 k. a};
1 |* m6 @, F8 V. l* {( P( z# C
0 G# q- s& Q0 A+ vstatic void led_dev_release(struct device *dev)% x. F! `5 O0 E: t
{) L4 X0 T# P- q: g! B+ s
};
% t' y7 a- z* _( t; q: u
3 a4 ?! ^5 }% b2 hstatic struct platform_device da850_evm_tl_leds_device = {
9 E& B r; Y& | .name = "leds-gpio",
; l ~: R" w$ s/ B0 g# g .id = 1,: G* l+ @# U) W4 P5 S
.dev = {% U2 J; m4 j0 S( s
.platform_data = &da850_evm_tl_leds_pdata,
K9 x" N% X5 q8 S& k( V# n0 S6 f .release = led_dev_release,! z( }; M# z, D0 V- v( x& P
}
, k3 J$ \3 [. W) v( w};6 M9 u' }5 G8 Y$ d8 R
3 r: w$ ^ k B1 a. x" Xstatic int __init led_platform_init(void)" E0 y8 f' t1 x8 `4 X, T2 f$ {% v
{
% s" E& w" M. V int ret;- f% \2 R5 o5 e W% }! b
#if 0! v! O8 v8 R+ c9 [8 P8 z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); ~2 f0 O4 r0 W4 d' v
if (ret)7 l9 e+ z+ a7 i9 M) q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ W& z: R* F- o: e
"%d\n", ret);) @, j% s6 Q/ Z- C+ \
#endif6 l0 [- m! {& T7 I
ret = platform_device_register(&da850_evm_tl_leds_device);
5 u; @+ R3 p; J9 g; p4 z3 W4 | if (ret)
; M) h, B. T4 T3 ]/ M7 f- B- g pr_warning("Could not register som GPIO expander LEDS");2 [3 u* h; D$ Y; A: z$ p
else
. _/ T4 w9 x3 j& ]3 [3 t- k printk(KERN_INFO "LED register sucessful!\n");8 `6 Y. O: ~/ G- I; r2 i' t1 Q
) c9 ~ y, x' m# _; S1 S" H
return ret;
. r9 F2 g; Q2 h}
3 z- |' Q# D: }+ r9 N6 j) x* M( ~0 _6 J! {; E
static void __exit led_platform_exit(void)3 s+ @/ A- ~( l- U8 S2 L7 A
{, f+ n8 W7 W! B, W7 E+ L
platform_device_unregister(&da850_evm_tl_leds_device);
, z* w: j$ x& t9 r
0 n$ W1 c2 f" G/ K/ b7 m& u printk(KERN_INFO "LED unregister!\n");
9 V6 @; K$ G' G {! d5 m8 C}
" i! @4 X+ F& z4 B
; a: A1 h7 H' w6 T/ @1 d8 @module_init(led_platform_init);
6 c2 g8 b8 X, N6 Q. Tmodule_exit(led_platform_exit);9 C4 J' W# L; U) }6 Y
5 D( P. R) m' ]$ TMODULE_DESCRIPTION("Led platform driver");2 X* ]/ B. o) e1 V6 C
MODULE_AUTHOR("Tronlong");, p. p8 b+ X* l4 h( K' I& N
MODULE_LICENSE("GPL");/ A. g# |* o/ k* B
% o/ `4 r2 e1 B8 X
|
|