|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ b* A5 n/ n1 b, f#include <linux/init.h>
9 S, F; s* E) B2 ~+ G/ \#include <linux/module.h># d2 f6 s4 v) Y! p/ o
#include <linux/kernel.h>
4 z2 o& [2 W: l& N9 O. N! }- J#include <linux/types.h>
1 \3 M; J, S) d0 M$ {#include <linux/gpio.h>; ~8 K# o' p9 j( g( Z9 u
#include <linux/leds.h>! s: `' a, z8 w4 u9 _* S
#include <linux/platform_device.h>& h4 X' a; b& l5 d
2 ?: ]) O3 c; b" I- X' ^1 T+ Q
#include <asm/mach-types.h> o) [0 q' S k
#include <asm/mach/arch.h>; J9 R- Z+ K8 Y; c5 N4 E8 p5 e+ z
#include <mach/da8xx.h>
& m6 } e9 Z5 r8 u. H#include <mach/mux.h>. p( z) i: Q9 X4 \3 u6 \
1 C% ]# r' O2 Y; g' L, g#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 ^1 d1 V' G. `& r7 L
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# U- S5 H3 I3 i#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) e, X1 Z- p9 n7 }# P& x3 b+ S. e#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- p9 @: B# Z, p) d, I7 u
0 }, C3 f3 X6 q0 y+ _( ~/* assign the tl som board LED-GPIOs*/
. C- W. e! l, k* V$ D6 y9 vstatic const short da850_evm_tl_user_led_pins[] = {
7 W1 p( @: W! B' H5 f, V /* These pins are definition at <mach/mux.h> file */8 x4 M q( a7 H
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 D' H0 L) e$ v" N# k0 _. u -1* h, f9 s9 _8 ^& b
};
. Y' m4 X9 J! J# w6 Y
/ b7 c8 b& n1 w0 f' ]' Pstatic struct gpio_led da850_evm_tl_leds[] = {
. o6 [* u# ]) C+ T7 o. J8 t {
8 [& k( G2 d% C3 z. u# z6 j$ L7 U .active_low = 0,
/ Z$ U6 I. p5 o( ?7 |1 f) q .gpio = DA850_USER_LED0,: G5 ~$ n. T- Q- a# E3 @
.name = "user_led0",; I9 c1 E" k& i2 W' i7 s
.default_trigger = "default-on",
$ C- v# E7 E5 [1 ^: a% i( t },
2 R2 |) B$ w& _3 r. s$ n {
J( w8 y8 |3 O2 ?- ]- X1 } .active_low = 0,1 ^+ N9 _3 M0 P- `# c
.gpio = DA850_USER_LED1,) T) {/ {1 \- f! {, T" X/ c5 Q
.name = "user_led1",
: Q( x# u; O m% }; Y% ] .default_trigger = "default-on",- o/ L% \# O+ @' O. z0 B
},
& n+ R6 `% A5 ], R. G& ] {6 f. j$ V2 Q0 X& |; H# ^
.active_low = 0,. i6 D5 a0 }$ O& j
.gpio = DA850_USER_LED2,
, s5 A+ l: P. i5 v5 o .name = "user_led2",. R+ x- L1 B: b
.default_trigger = "default-on",
' A: U5 [4 z% G: X8 |/ c- ~ },
1 W" O2 ?6 _" d& b2 r {" H {; I& s4 u6 G( K. U9 H$ M
.active_low = 0,& ?4 B' c/ H9 d* ]* m3 ^: ^
.gpio = DA850_USER_LED3, m2 ]2 M) \: f! }
.name = "user_led3",
: \- N( ]* [; `; B) W .default_trigger = "default-on",
! v6 H6 b2 Y5 Q+ e9 Z2 \ },+ n# p: N2 P Q. @7 g
};9 [. g: I0 U& |: [% x# `
, P- m+ A9 |5 N
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, H/ d/ S* U% t9 ^/ W .leds = da850_evm_tl_leds,7 v) ]' E8 i' [+ G& o8 n |, P/ r
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ L5 c0 o7 @. L! O# ~
};
, E& A/ e7 Y4 K3 i5 k' A) ?3 B; x1 o5 D3 U; ?) ~: T* y$ j
static void led_dev_release(struct device *dev)
4 I4 O* ]; h. T- R# [# x{: w) ?; E4 \: L$ u* T U1 Q
};' W( K5 b3 O2 }; J- P
, [# n8 N- W# U' k9 `8 A$ g
static struct platform_device da850_evm_tl_leds_device = {
0 ~8 o/ f5 D' _" n, v C0 z/ m .name = "leds-gpio",
! R n/ i. v( O7 Z. C; y* P .id = 1,: T8 T& A+ Y, _7 q8 I
.dev = {( |( ]3 [4 b( ?7 m$ y
.platform_data = &da850_evm_tl_leds_pdata,) E L0 i, V1 Y# ^. w) k
.release = led_dev_release,/ M8 h" v" K( T- |/ v
}! G! V, [& Y9 F0 Y! l! f: n
};5 S2 r7 R1 u0 E8 j m6 l* [
+ U( U5 F& n6 f8 ~
static int __init led_platform_init(void). T6 W; x- k F2 V) z; _
{
- G U5 w( m8 a) u' T1 f int ret;- ?! Q3 Y9 x, ]" H: i" g' U. i
#if 08 X1 ^: }/ i8 u' t, s1 [" u$ w$ j
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 Y8 y c0 c9 z if (ret)
* e, Y, }2 r* U, k! l, E pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 q: z; n! g' f3 W& f' T& e "%d\n", ret);' S: k" L% P C. R3 @
#endif0 |0 o! q4 Q6 L* u# h
ret = platform_device_register(&da850_evm_tl_leds_device);
' S3 k& W: U) p, @1 N7 [. H if (ret)$ d& j# l9 h! `+ B( Y
pr_warning("Could not register som GPIO expander LEDS");
; d3 f6 m' Q! a3 U. h5 @! W else* \, X3 ?9 y! V7 ~. ~% K' J' {# T. A
printk(KERN_INFO "LED register sucessful!\n");' `2 R& `: F+ c5 p0 s! v% ?
* u$ [0 d$ H9 G return ret;8 S: I4 N$ q2 u( n
}
) b4 E1 S7 }$ _: s. \
" S8 n* u+ P6 ^+ a! ^0 p) sstatic void __exit led_platform_exit(void)
1 u8 b4 |$ X2 i: W# o{/ J2 r1 W$ @- J" |0 [( G0 A3 Y
platform_device_unregister(&da850_evm_tl_leds_device);& u) L- @- j7 F
8 i) r6 Y1 k7 _5 f7 o1 H, Y# ` printk(KERN_INFO "LED unregister!\n");
0 E- j, u( A7 s9 M' W}7 C( A0 f' `& K; P
" N7 d$ i( n% b+ Smodule_init(led_platform_init);9 v/ ^7 i. Y$ U8 j" \
module_exit(led_platform_exit);
' W& y5 ^ C/ B' R" Z
9 y5 z6 `: q, v( {MODULE_DESCRIPTION("Led platform driver");
2 \4 ^: F6 D! d$ ^( w2 J5 tMODULE_AUTHOR("Tronlong");
% ~4 q* y6 V* S0 DMODULE_LICENSE("GPL");
# w- A d. I1 s9 v9 R F/ i* O# R1 ]2 K+ ^" t/ ~
|
|