|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 z& i* p1 x5 g4 ~3 V: A9 p+ C#include <linux/init.h> B- i! F6 k6 d: m
#include <linux/module.h>
( q, I! x8 l; m9 k) K#include <linux/kernel.h>
\7 [ x$ c( G: b+ U! o8 n#include <linux/types.h>! o% h. ?& p2 i
#include <linux/gpio.h>. L3 A1 Y8 f3 {
#include <linux/leds.h>
3 X5 l+ _% r+ K2 i#include <linux/platform_device.h>
# l9 |* d- U8 o0 F4 m4 ?' B7 d7 y7 G" q0 j
#include <asm/mach-types.h>
; Q4 H6 ^# \; s3 m. U#include <asm/mach/arch.h>
1 @+ `+ f6 t; J+ K( b, B1 n V" y#include <mach/da8xx.h>
" `' H. e, v- Z: {#include <mach/mux.h>
9 \; N) T/ C3 e; f' Y1 `: @, s$ G' D: s0 @0 C1 b
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 j: U3 o) P. k7 }3 v+ Z Z4 `* k9 p
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 U8 X2 ~( b. p: L9 A$ _/ R
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- a6 x9 A) t7 q7 t
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* }& p" [& U) n, ^5 j
! f1 O5 R" v' T& F" ~* \- ^
/* assign the tl som board LED-GPIOs*/) }$ s$ z' g+ l& a7 [5 k# i* N5 t
static const short da850_evm_tl_user_led_pins[] = {! D+ g# x9 K& j4 m# _
/* These pins are definition at <mach/mux.h> file */1 O8 O% |5 g, p+ E& v W
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ A% x# n* R+ [% S4 O' `3 z7 W -1
( U/ }( B8 }0 l5 g$ {$ K};
$ e+ ~( c8 _0 c7 Z+ J, g; _# F1 W! W9 q r4 m# ~$ U
static struct gpio_led da850_evm_tl_leds[] = {
3 v' O, `( [+ |! \ {
) _' }, n7 n# y" U B+ c7 R .active_low = 0,
8 ]( [& u# l3 s/ x6 i .gpio = DA850_USER_LED0,
; F U( F3 J1 v a- q2 w: }9 P .name = "user_led0",
$ f: _7 v/ Y9 W$ R. Z .default_trigger = "default-on",* F5 \" Y& ]7 L! q( k7 u
},
; p+ B6 y" V! ?; P {
0 d0 z6 Q. \& R .active_low = 0,2 B0 J4 B2 @* ~9 F; |; I$ p4 O
.gpio = DA850_USER_LED1,, W. _8 H& b: h9 ?4 o; I- ~) L# E
.name = "user_led1",# n& k9 X t: [
.default_trigger = "default-on",
* d) j I' v4 J0 G+ @2 b },
- H5 m" O! W. g; z- K {" d9 h9 @0 ~) K' e+ l
.active_low = 0,
0 e5 x( W W0 c- J8 v .gpio = DA850_USER_LED2,
5 o2 D$ F% g6 Q7 ?! g! _ .name = "user_led2",
# O1 N% ?3 x6 C; m, E .default_trigger = "default-on",- y: |8 f4 g7 s
},3 b2 V0 u% @, }7 D- W
{
; B& V1 m6 _8 F .active_low = 0,
! v- \' l% T; m V3 _ .gpio = DA850_USER_LED3,
* l7 v/ L9 Y7 V0 d .name = "user_led3",) l/ L2 J8 M: N+ i
.default_trigger = "default-on",: s0 ?7 Y7 ~/ s0 K d: G& B
},1 @2 W# u: s9 g! ^
};! c* h* b$ d( L
' P0 ~9 E' Q3 K! ]1 Lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 b D8 R* {* ]6 ~ .leds = da850_evm_tl_leds,
/ r7 r9 O0 P$ F2 F .num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 m+ g* N/ `+ J) a, h9 T8 F
};+ }$ a# a0 Q. _
+ F3 R/ E4 F- lstatic void led_dev_release(struct device *dev)" N/ W" t& t6 H0 m( @
{; a; w w1 T2 p6 b1 a
};
O! X9 i- l6 @. o. `9 m" q5 K' w V
static struct platform_device da850_evm_tl_leds_device = {
* R4 Q2 |$ Q0 d& s, E8 r .name = "leds-gpio",
" |2 [! Q& V1 t9 x .id = 1,
6 o+ \$ k: L9 P: D' N: @# o .dev = {
. L/ `- `& ? c) @ .platform_data = &da850_evm_tl_leds_pdata," l& r7 W, u' D$ B7 s- z
.release = led_dev_release,
9 [" v; x0 ~6 ^' k& U0 Y0 L }
3 A H2 G& g* C9 o6 J- L( L8 Y};
6 \/ V: h! v5 H$ g
! |, {6 g- B. g0 B3 N2 v9 K$ Tstatic int __init led_platform_init(void)' a8 a" i: C6 A- C- M* D
{
+ S! y3 h7 r, V int ret;
3 V0 R# G6 n2 d$ q0 ^( i#if 0
3 Y# j0 l) P! W2 u1 z7 T ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 b: w3 d9 ^% \0 {% W4 T2 x
if (ret)0 X1 K' b4 g. t4 W$ G8 p( S" p, ?
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. I' ?( `7 ~1 ]2 S( ~/ @2 _. \ "%d\n", ret);+ A& J# i9 Z/ q$ N
#endif6 n1 O, N0 Z2 H4 O8 \: g
ret = platform_device_register(&da850_evm_tl_leds_device);5 K( F" Q0 s+ z# T! |: G% L9 {
if (ret)
: n6 f4 _: Q" b$ \ pr_warning("Could not register som GPIO expander LEDS");
2 r/ m* F% s. {& {& }" |: K- a else
( K3 k) W7 ^3 Y* T X6 _ printk(KERN_INFO "LED register sucessful!\n");; s( ~1 z( h6 b# A" U2 ~, T/ {
" {/ L/ L7 D1 y) w+ ^8 s
return ret;
& u. \! `* ]; T4 r5 e1 F}
8 ^- N* Y1 f0 ] h& K; V' Y! i2 [5 a# g* J% B9 v; M3 z/ I
static void __exit led_platform_exit(void)( D1 n, i6 m* c6 T3 Y( {, `
{4 x$ [$ I4 J# b, T% l# ]
platform_device_unregister(&da850_evm_tl_leds_device);' p2 r9 s1 w, |0 C* x
7 Z$ |( d7 U: c. H# G& n: `! @ printk(KERN_INFO "LED unregister!\n");7 N% t. r3 F J
}
: U" C6 w% Z8 ^5 x+ \1 I1 B' ^" r1 {- \3 I$ m2 a2 O6 y8 ^/ F
module_init(led_platform_init);
( u' N5 s4 ~% |) G- C0 umodule_exit(led_platform_exit);
' Y" _; s+ @, f1 t4 |! ~2 [# x% G
MODULE_DESCRIPTION("Led platform driver");
6 { G9 D1 X/ w! v4 P aMODULE_AUTHOR("Tronlong");/ V, L, B' V' J
MODULE_LICENSE("GPL");7 |- F; S8 [0 u2 J6 ?! I3 M
6 V4 J" C( U3 [+ }
|
|