|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 s# j# J) [+ G9 t; _6 V9 W" p
#include <linux/init.h>
7 c: `( {4 O& O5 E. @* ?#include <linux/module.h>
. V# |1 q0 B z" g- I7 M/ ~0 G) G6 k#include <linux/kernel.h>
( {4 z' ]8 Y, O9 h4 K#include <linux/types.h>
: V$ I+ J. W7 P9 }% u* h8 n0 O#include <linux/gpio.h>( o, b2 S( g* S
#include <linux/leds.h>$ Q1 _ |/ Z5 ?% W+ E: w% \' `! w
#include <linux/platform_device.h>) D/ m+ O; H0 @$ K) y4 y
/ D1 G( x$ m3 _- V9 U% w
#include <asm/mach-types.h>
; k: x! z% v( @! E( i( {#include <asm/mach/arch.h>9 ~) g* j& Z: Z0 \: e5 d5 t
#include <mach/da8xx.h>" v! E5 p$ i, O, Z. z9 c }1 o
#include <mach/mux.h>
. v( f6 z; y R
4 e ~+ N( f O7 E+ J) z4 M1 X#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) G% E7 s# h1 b3 ?#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* _9 W/ P' W: C2 n, c#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 s/ J' m# } y& v% R7 H' H2 ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 ?2 S* u# v. h4 q) U
6 A9 t- Z4 s" [' y0 H/* assign the tl som board LED-GPIOs*/
6 c. F& P& k o+ ] Zstatic const short da850_evm_tl_user_led_pins[] = {# |: T7 i& u$ a
/* These pins are definition at <mach/mux.h> file */
( p6 Z7 \& k1 n6 O& g2 | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. Y3 \; I: R& I: u2 T. N -1
4 o z2 a# j7 Q/ Z% U};) y, @" T$ i T$ S+ g$ d
@; r/ p1 T( u9 S. u( ostatic struct gpio_led da850_evm_tl_leds[] = {
* ~& y5 `5 d6 u0 X {: M8 ?0 ~# L( h1 I, r5 Q
.active_low = 0,8 {5 r$ @8 T( H6 @& m6 X5 t: n. |
.gpio = DA850_USER_LED0,0 `8 f x8 ?8 y; u$ h
.name = "user_led0",- _$ Y6 R7 {' n4 Z
.default_trigger = "default-on",$ M# t/ \& t" Q0 U% Z) Y |/ b
},: z d& l! x) z' _
{
2 z( C. u; y" u1 e8 @ .active_low = 0,# T7 a: n+ d' |7 W. R( I( A
.gpio = DA850_USER_LED1,
2 v7 T' h$ b, F& e .name = "user_led1",# G4 w3 _. B+ R" O. t) q+ @& t
.default_trigger = "default-on",. D R9 M7 }5 t
},
+ t* e: o0 L e6 c {. a6 y* u5 l$ |8 d5 }5 ^2 V1 L7 T5 a$ v
.active_low = 0,' p7 q8 ~8 Y0 A5 g; r
.gpio = DA850_USER_LED2," F6 [2 x+ J2 d$ n0 y
.name = "user_led2",: V( J+ E1 B, k0 R, e+ U7 m8 ]
.default_trigger = "default-on",
0 Z+ K" G+ \7 m: | M& ~4 Q8 q, X* \# M },
' _( t {$ u0 ]- ], {) ? {1 d+ n" J* m" T4 y
.active_low = 0,( l1 _6 R7 _: U4 G5 F1 p
.gpio = DA850_USER_LED3,
! l: I7 ^; C* q+ t% ]! P) x .name = "user_led3",
' P7 [- [& m0 K# I8 k& { .default_trigger = "default-on",6 q Q( `7 K$ P0 {# C' }
}, c+ _4 l# q" T* i0 n
};& n/ t, y5 ?0 F1 E$ J9 Y+ G
: a9 D3 l2 d2 B" b3 u1 H
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 {- }: H- ?/ i! ` .leds = da850_evm_tl_leds,
- A; Z" J3 `, ^$ K0 `$ W+ _ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, y2 v0 k6 |, q( s0 b
};! [ T* x' W4 @" h# O( C
' I' n4 p* K7 \static void led_dev_release(struct device *dev)1 b% q7 n9 y6 l' A* L8 ?
{
8 _) C+ m% m: o; } R/ h. B3 N+ y};
4 g2 s: O$ C) E: `7 N! D V) D3 ?- [/ L$ o
static struct platform_device da850_evm_tl_leds_device = {
- |! q0 y$ b" x0 o+ M .name = "leds-gpio",
~; I, t4 ]7 q# c- k; x/ p .id = 1,
7 t# F% o' _) N1 {( s* ~; w! x .dev = {
! w9 [( F `$ H* |/ u .platform_data = &da850_evm_tl_leds_pdata,8 B2 W# {5 J& V$ k+ t% p ]
.release = led_dev_release,
. v6 q4 V2 B! G2 A2 }/ r }& G/ z8 d1 [- T( C X$ m/ g; W; s
};
; e- P4 H3 U8 U, }% }( s1 a. T* [: I. _- p
static int __init led_platform_init(void): |$ V: ^- B) D2 f0 h. `
{
, j) }" t, c3 w int ret;
1 `& Y& E: l v/ ~% B* N2 F- x9 g2 U8 v4 A#if 05 M0 s5 v% `. B' g
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, o" g; Z5 L2 }. j if (ret)) G+ E6 i' o* w0 ^
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- f o* A0 ]' d! T$ s" B "%d\n", ret);$ l! ]4 S5 T9 Y
#endif
2 T; K4 C; E- S( V* [. ?% [6 s ret = platform_device_register(&da850_evm_tl_leds_device);
! W% ?1 d3 {* M% f if (ret). y, ?' f8 @! O8 V) A# S0 A: V6 y
pr_warning("Could not register som GPIO expander LEDS");
4 z; I: s1 I4 m else( r1 _$ z4 |1 x3 h- _" a7 ^
printk(KERN_INFO "LED register sucessful!\n");" u; n3 x% U; E% g
1 Q1 M: |# ^ A return ret;6 ]/ A, h, w- Q2 G4 O. R2 l# R; B' V
}; b0 w/ j, v: J8 s
& g# J- B0 I( |
static void __exit led_platform_exit(void)! k! [2 f/ }- t$ v7 o9 R
{
* F; J/ o3 W, ^. e3 H6 y platform_device_unregister(&da850_evm_tl_leds_device);
+ q; Y8 b7 l" j, N, c
# v, J% O# u k6 u) k printk(KERN_INFO "LED unregister!\n");- W5 |, V$ t* K6 y
}
9 E" B/ |- L4 T7 K
* {8 C* L0 I: Q* d- @; E5 E1 smodule_init(led_platform_init);& X# k9 o/ j+ D2 A4 S0 m
module_exit(led_platform_exit);2 M+ E1 s6 `0 R3 n, v$ H# B
; v( g2 `; ~5 R, R1 s
MODULE_DESCRIPTION("Led platform driver");
) d8 P3 h/ Q- _2 v% GMODULE_AUTHOR("Tronlong");
! _8 z3 T6 b O G+ I! A5 {; MMODULE_LICENSE("GPL");7 [4 M, c$ \! [# s7 i
. Q6 `+ l5 X2 L
|
|