|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 D7 I2 f' d! g7 ^/ D _- X! R/ e#include <linux/init.h>
, B" R( G" R* d( O) B& S#include <linux/module.h>1 q' i8 C' o+ m5 D% a4 Q
#include <linux/kernel.h>
7 f6 K X+ e4 U#include <linux/types.h>
/ b$ A1 N2 j; J$ _. I/ T0 N9 |9 |#include <linux/gpio.h>
' P$ o$ `5 s" w {8 `9 X#include <linux/leds.h>
5 E" O- S( m8 J" u% O8 q#include <linux/platform_device.h>% Y u' t3 b8 B/ v
, S. @1 r; p5 d
#include <asm/mach-types.h>8 b, f4 R4 o" D
#include <asm/mach/arch.h>( @3 y5 x4 T( Q( f: s5 D
#include <mach/da8xx.h>* a1 v# |, I( ]1 Y# t# y- Z$ L
#include <mach/mux.h>
1 D; V Q, D% J' v& v* d5 w, E2 V$ o$ u
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) M( E( K$ C2 x; Q0 E& n$ _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- J( h) z1 D7 s) `( v2 N#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 ~) y) e3 U! W+ Y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) ^2 L, t7 O1 }1 I2 w* ]% [, j* f
' ?* k$ f. n7 P; U# M- ] }/* assign the tl som board LED-GPIOs*/
0 j) B# _* c) ]( w; `- Q( [0 S. b0 J8 Sstatic const short da850_evm_tl_user_led_pins[] = {
+ U* o& a, ?/ s) b+ x3 w" u /* These pins are definition at <mach/mux.h> file */# H) |' F2 o5 g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: H" [/ C, [7 d4 j$ t -1) Y9 C9 O, V% u5 M1 B
};, E5 }- u/ g/ [% _$ j7 t
# q# c3 E2 p& i" s, q, Y1 X& {static struct gpio_led da850_evm_tl_leds[] = {" z6 F8 Y5 [* V6 ?
{
: G3 @+ N' ?8 a .active_low = 0,
* z, a! ~4 i4 i. R3 Q k( d h" f .gpio = DA850_USER_LED0,
2 R5 g' c# X% G/ | .name = "user_led0",$ g) P) k |" l6 u
.default_trigger = "default-on",
1 t: h2 I& G/ o0 c1 I" b },- A& Y Z" T) |* ~
{8 { P/ T, B; d7 T
.active_low = 0,# k" Y. d( g+ P
.gpio = DA850_USER_LED1,* }5 p3 U. V: H; n% e0 r# S/ ^3 N- k
.name = "user_led1",
( z! f* n6 O+ V- c( g9 ` .default_trigger = "default-on",
. x" J C) L7 Y3 j V },
* H/ [2 D) e; G3 m1 d, n' i {8 N' b6 y: K6 ^: b' Y& b
.active_low = 0,
& |) r3 _7 Z* W3 Z+ C) w .gpio = DA850_USER_LED2,
0 v7 s$ n$ c& S8 b- M .name = "user_led2",5 Z; E$ C- L c! E6 C1 d8 K
.default_trigger = "default-on",$ l( P; m. |. Y- l: g, v
},
% C) C1 Z) s0 h6 @- w9 A% _ {' s' ]7 J; `/ H7 H
.active_low = 0,
r7 b% S8 b3 N4 a5 h .gpio = DA850_USER_LED3,' {1 ?& _( P+ j- @, n
.name = "user_led3",7 u! k" O/ p' ~0 _3 c3 w; G
.default_trigger = "default-on",7 C! I% Y" R! ]' g; y
},
% p$ B- z( ]4 H8 n* E8 E% Q};+ a6 J( ~9 c; w( h4 R3 R/ Z) Z
3 i8 o. t. m* i9 X3 @/ g6 u! ?
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 C6 I0 T6 b. x
.leds = da850_evm_tl_leds,
) e4 S0 W- o1 N" o6 u! B& ~' K- o .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' b; _# O# i4 u8 f3 d};/ a. U" Q& T1 w6 v( l+ v7 c
: p" S! L5 C+ b
static void led_dev_release(struct device *dev)
5 M0 }3 a" @8 I& B{" F5 d, f' Q/ F f; h; g9 r5 ^
};3 }' O7 \2 n1 O& a) G
5 G/ R8 X- A# F1 s( t4 G, cstatic struct platform_device da850_evm_tl_leds_device = {
U5 [+ I" k3 |6 ? .name = "leds-gpio",
# A) {( d; h1 K4 x) j .id = 1,4 Z% |3 F" `3 `/ {/ b; w& k
.dev = {
! a7 L0 i: F+ H+ @ X .platform_data = &da850_evm_tl_leds_pdata,
6 U4 O1 V/ I3 g! P; ^ .release = led_dev_release,9 }# h* s, x8 V; e: h& J
}0 ^; L" P- w0 }* Y
};0 O& ?8 r9 ?8 U8 F
) C' b1 d ^ Y0 F: N1 e2 X
static int __init led_platform_init(void)
# Q( c; r$ i, _) w{
' J- v& j5 b/ q! M( i4 ~. V int ret;
I7 B, J# D! U; ]4 E#if 0
! G0 ~; v1 _/ x7 m ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* S: R0 d4 L5 j) a
if (ret): x5 U# Z: s+ t, O" ^% Y+ Q/ b
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 S9 y0 _+ Z* Z) R: p2 M0 U; {3 h
"%d\n", ret);1 i& j) c; c! {3 V' k' ?1 S
#endif" X( \, V' b2 O2 ~' D3 F9 B$ O
ret = platform_device_register(&da850_evm_tl_leds_device);
1 S2 P- a5 P9 A, i- J+ [4 l# @ if (ret)9 z8 I& A1 Y) S7 C& h
pr_warning("Could not register som GPIO expander LEDS");" v. F# O, o* c- ?% u- z3 a! h3 S
else
$ `7 G, a/ v2 S printk(KERN_INFO "LED register sucessful!\n");
4 r" ]& B3 Q4 N+ \9 r" C0 V+ z3 K9 p) K/ `4 [
return ret;
& M4 q# j# e' V}% x" } K$ ~' b- |* k) g
0 X7 g8 [2 I- n J: [static void __exit led_platform_exit(void)9 e+ b6 ^! o+ `4 N3 c- F5 x% ?
{' w Q% s! l9 H( a
platform_device_unregister(&da850_evm_tl_leds_device);
" K, ?9 { l8 w' t" p
1 F* r0 }$ p, v: y* z printk(KERN_INFO "LED unregister!\n");
- o; R. J5 M7 o+ a}3 y/ p7 U8 _& B( L7 a
$ h$ N3 f, n7 v
module_init(led_platform_init);1 p% E5 O1 j7 D* `% e7 Y- Q6 ~2 ~/ ?
module_exit(led_platform_exit);
$ F% z: S6 T( v1 Z
0 y: d" y. v- `/ ?0 T9 ?' ^MODULE_DESCRIPTION("Led platform driver");* P+ c- e, D6 c4 I) r9 `5 W# z
MODULE_AUTHOR("Tronlong");: O9 h7 k* W+ k5 q. c# W
MODULE_LICENSE("GPL");( g" Y: {# |) K) L$ R$ F
! ?7 r' x4 C( Y- T6 {
|
|