|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 z2 i& N% @6 u: M
#include <linux/init.h>
& m- w9 U Q0 h1 O! D$ X' a#include <linux/module.h>, O Y! u1 n2 r/ i4 s. v/ {$ d" {1 f
#include <linux/kernel.h>3 X, n5 u' U! S$ s, B3 [
#include <linux/types.h>
" ~, `7 n, H! a) |#include <linux/gpio.h>
5 i0 e: @& z) M& D" h4 e#include <linux/leds.h>0 g0 t, v. w! Y3 d2 s( A
#include <linux/platform_device.h>
$ r) w9 E# t. S% Z/ ~; g0 Y; \( y z6 K1 t& V
#include <asm/mach-types.h>, i3 v3 e f) \% _ Z
#include <asm/mach/arch.h>
8 b0 F/ S- W; T* O1 b" z+ _( R#include <mach/da8xx.h>5 x2 v C+ g2 d/ v
#include <mach/mux.h>
$ i8 }5 q( p$ a- }: c5 P, D5 u" W4 R' L, R" P: W5 D
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 |7 e, o2 Z& x1 V% Q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 P- @" R3 k( @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 T' v6 I$ s) e#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), q* _0 q" ~" t
) X! Z& G: O6 F: h
/* assign the tl som board LED-GPIOs*/
6 C, D! `' c; d3 K6 x1 gstatic const short da850_evm_tl_user_led_pins[] = {; V1 o: w0 J' R- m. j: f
/* These pins are definition at <mach/mux.h> file */
# {# e* U9 N9 Y5 v' I DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 \% `5 W+ R1 {4 x( S) A9 J -1; N, V' r0 Z* [( `. P+ f
};
8 F' W( U5 g( K+ z
" L( P1 j0 j& Q% W3 i5 Wstatic struct gpio_led da850_evm_tl_leds[] = {4 `1 {3 F* x8 _) ~) l
{
/ M; K$ P; a3 w) P) C .active_low = 0,* l" A7 ]7 U) a$ `
.gpio = DA850_USER_LED0,
s7 ~6 I9 T8 [' t1 G5 O .name = "user_led0"," @( x! S! m! j7 I
.default_trigger = "default-on",! N' D$ w$ _/ P2 f! Q% v# v% R
},$ j3 @& Y1 x& l: J! w
{
; D4 ^: V% r( E! K2 ? .active_low = 0,8 y! a4 C5 l$ Y3 ^/ I/ b- D
.gpio = DA850_USER_LED1,9 _, u. l7 q- z
.name = "user_led1",
" G* @3 k/ _+ }% U4 Q5 O .default_trigger = "default-on",
* J8 g m0 k; H2 F, H3 q },4 z) J. m9 y% U
{
* P) W0 b: h/ \% u; i% s0 a8 I8 J .active_low = 0,
a* W4 Q1 K8 A, U .gpio = DA850_USER_LED2,5 P D' r# i5 I' l
.name = "user_led2",
h! ]- r$ [2 J6 D- k- P% @. U R .default_trigger = "default-on",3 l4 H, |3 |( p: k6 M
},
$ v& a; _; ?# p+ h {7 R' i1 m [1 D2 {8 X; k E
.active_low = 0,* ~# s2 Z/ V0 L! c2 m1 W6 E
.gpio = DA850_USER_LED3,
% S! ]0 P6 A; X6 w. ~6 { .name = "user_led3",
( ^+ k, f* F. |0 b0 |$ B5 ] .default_trigger = "default-on",; X4 R2 [# p! W
},
! V/ @ z: V3 |: t9 H. ~};5 L O6 f# T6 A; t
@- D; n# ^- P' M' h$ ~" Fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 k) z4 u' D. ^4 }- X
.leds = da850_evm_tl_leds,
7 x! ~4 T% m0 c5 i: S. M- w .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 F. V2 f9 G# r' n8 e1 [};; s) O) j" j4 U# v1 i/ u7 {: x
# C/ d9 p9 g' r7 d' ]. Z& }& J" M
static void led_dev_release(struct device *dev)
$ u# L* \; G# p# w{
3 `* `2 ~! v1 l; Q2 S1 ^9 b/ W* c};
- l( w4 G6 ~/ n4 F1 [
X( ^7 p+ G+ M, Y4 `static struct platform_device da850_evm_tl_leds_device = {4 }7 Y$ F; K+ @$ N& ^" V
.name = "leds-gpio",5 O7 E6 G8 Z$ `3 z; I6 u2 w6 }2 h7 H
.id = 1,
) h- e6 r6 h' U! S .dev = {
|$ d# P& o8 `% h# u# k) U$ D l .platform_data = &da850_evm_tl_leds_pdata,
4 |: f9 E& k4 A- b .release = led_dev_release,
/ A" r, w. L9 z: F' ] }
& @/ X4 J! n+ S" m9 S( C, t};
8 Y' O) l3 w8 o' u" e- Y
% _! l9 t% V! [* l% \/ T5 \$ ?static int __init led_platform_init(void)4 j9 r- g, e+ d4 p2 n' Q" v7 f
{( { q5 o" N% {- y" A/ e
int ret;- q$ `8 i7 @# b2 i7 c
#if 05 y* O/ [! k9 q2 X; W
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 e& I$ J' G7 ?1 [! Y1 T
if (ret)6 C2 M: M/ f m
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 }/ V3 i7 x F "%d\n", ret);
/ J: y$ q0 F6 C7 |; Y#endif
2 s) P0 [9 D7 i, u! @ ret = platform_device_register(&da850_evm_tl_leds_device);$ n' Q5 s5 ~ p8 u8 Q0 I
if (ret)9 r& n. Q4 S( f, P1 z
pr_warning("Could not register som GPIO expander LEDS");
! L) {+ `3 U1 M+ H9 _( j7 S* Q else
2 f+ E y/ p2 Q! h+ T printk(KERN_INFO "LED register sucessful!\n");
; y9 R6 y0 d R/ n7 c2 h8 g2 B* o+ \9 l& y! C
return ret;
/ p$ c- C- h& S( k+ i7 Q}4 X$ l( m8 G7 y$ W3 A* C8 n
C2 \4 j/ Y% tstatic void __exit led_platform_exit(void)6 s. K# P$ I/ Z: {
{
6 e8 [ A7 Y7 k platform_device_unregister(&da850_evm_tl_leds_device);
+ u( [5 ?; Q7 n( l# g0 Z
% P" _5 E' _2 i4 D, m8 L' _8 y printk(KERN_INFO "LED unregister!\n");
" ~# @4 T. o, H6 N}6 f5 L7 B2 @6 H( z* @
7 f1 Z3 L6 W/ u) D
module_init(led_platform_init);
" P2 O4 U) B; K" Q% Omodule_exit(led_platform_exit);# B& @' [2 d' E( I6 q5 K( O9 t
9 n1 a. T% `% ^9 O& H; _% ^
MODULE_DESCRIPTION("Led platform driver");
1 L1 x W3 a# {MODULE_AUTHOR("Tronlong");( i3 S4 K- Q2 @& A A
MODULE_LICENSE("GPL");/ i9 ?# W+ @/ b1 k8 p5 O$ T
- b/ m4 s& p" m$ T- n% T; f
|
|