|
求大神给下面的程序做注解,请稍详细些,谢谢。0 A/ c( A# e! D
#include <linux/init.h>! k* K+ a& j* i
#include <linux/module.h>
& d: B4 Y: h" z" T5 L; }#include <linux/kernel.h>
7 m, i3 I9 U3 x#include <linux/types.h>
2 f8 e& `: Y% _% A3 [5 n' t+ U' a Z#include <linux/gpio.h>
( }' ]$ G8 o. c' ~#include <linux/leds.h>& ?4 @" W" ^! y% t- K: X
#include <linux/platform_device.h>( D( N. q8 w0 E& t6 H
- C4 @! P0 h+ \8 `( Z+ ?6 @
#include <asm/mach-types.h>* [# c' u: {2 B2 W K: P* a B
#include <asm/mach/arch.h>9 u2 A5 v, t9 u; r6 w0 N
#include <mach/da8xx.h>: l9 S: Z5 A( {7 R$ @# N
#include <mach/mux.h>4 R- C' ^) \/ v2 g$ \' e
+ d0 }6 G Z3 K, e#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 }+ \7 b4 C& q6 z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# E- _# j- K' e( e0 R- e- w#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). k$ f. R& a3 k0 U! m& _
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ o* V e, O9 E, [. D' _, S
* D3 F0 ~: i3 }' e2 q* @/* assign the tl som board LED-GPIOs*/+ p6 t" U/ `+ L7 K
static const short da850_evm_tl_user_led_pins[] = {
7 f3 s& V& F# ?1 K3 G: D /* These pins are definition at <mach/mux.h> file */* z6 Q3 s: m8 `/ X7 s
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ Z8 d/ x1 D. K -14 R9 I1 |, u9 ?2 H K0 L4 W
};( Q* S/ ?) N# k7 Q U2 x* k! x
$ W7 x3 a/ }( I4 Y# v, k/ `4 m! _static struct gpio_led da850_evm_tl_leds[] = {
; v b! m, [' R6 `5 @ {, Q5 J* P l' e( v3 l9 o
.active_low = 0,
% [* R8 ^8 }, e. X .gpio = DA850_USER_LED0,' j- Z2 F; r9 S, Y* @3 N
.name = "user_led0",. e& L) J& W; ~. f
.default_trigger = "default-on",
8 [4 ~) b7 L# t( J },9 X# W% i0 W1 `3 U
{$ B: [$ m. c$ Y; `" I
.active_low = 0,
( ^: Q+ Q' G1 @( | G. w& [4 } .gpio = DA850_USER_LED1,6 p N. @! w8 F! V7 ~7 i: q1 V1 J) h
.name = "user_led1",; t3 p/ o3 i3 h; o
.default_trigger = "default-on",8 M( `, c9 \1 f& X1 x
},
, C% \ ~; P7 z {
" k4 [5 X W1 R# D/ M .active_low = 0,( Z& f) M- t) T+ S, c$ d. q
.gpio = DA850_USER_LED2,
' ~" M w) U& P# C3 ^9 a .name = "user_led2",$ I: e* }' I% I1 X, d' g
.default_trigger = "default-on",$ C; M5 X; N* N' h
},
! |/ q- B1 C8 Q" L7 g6 k% l {
, u: H3 F0 y h1 m4 |$ O .active_low = 0,8 c8 z" `+ L1 q" Z( `! [4 ~
.gpio = DA850_USER_LED3,
/ r9 \5 f8 o2 S0 g) o% s/ c .name = "user_led3",/ S5 r& g6 u6 H- z
.default_trigger = "default-on",
: T" r) i9 m4 L7 t2 H0 ] },: M) v$ v& V& I5 f1 W; n8 A$ ]1 q
};
& t2 y2 o; ^1 p7 J; O8 ^/ y9 \# [6 w* \7 ] Z6 Q; u
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* {3 {, t- u* f9 }7 S .leds = da850_evm_tl_leds,( i; p" o+ |& M9 Q! c% D1 t2 X
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
o& ]* X- t& X};; a3 N! m' r1 n: {$ s& }6 d
$ g; \4 Y% V7 r
static void led_dev_release(struct device *dev)% g, m2 i7 _ _4 v1 k5 z: u
{" L- q2 @" ]- S: S$ b& y9 \0 g% @
};
% V. g5 X) y9 e; q. T% \& ]2 L! }* m
static struct platform_device da850_evm_tl_leds_device = {; _, z0 I: n' G* k2 @* w
.name = "leds-gpio",
( w1 q! G- ^2 O& B b0 f+ G .id = 1,
( n& T0 ~0 u* Q% { .dev = { M( w) k: T0 z, I6 B/ h
.platform_data = &da850_evm_tl_leds_pdata,
! g) `$ F# i5 s+ t) n .release = led_dev_release,
4 d& k/ g# D8 b7 V/ I+ C/ B }& C% |$ i4 g$ w' D- e: I' k
};. r9 Y5 f( O7 S; X& n, f$ J
* _; t0 H: |( {static int __init led_platform_init(void)
P3 L9 s" ?* e1 i) l{
S5 Y( k4 \! Z4 F4 I) q# L int ret;) s. Q# y- o9 l* y' L
#if 0' W3 |, \4 l4 k; c+ e9 A% ?$ ?
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 X1 S% T/ y) N" X; A3 K' h if (ret)
9 r P* H$ A( W) H# U- |; P pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. t9 B9 k% a% |& z "%d\n", ret);
/ ?! ^9 q" o" z#endif
) c6 f' F* t$ R ret = platform_device_register(&da850_evm_tl_leds_device);
$ U! g1 x% A! x$ N* v- V+ I if (ret); k. \% ?; P8 }" p0 m8 u% A
pr_warning("Could not register som GPIO expander LEDS");
( G# X8 J' a( l( t else
3 J: d7 X$ c: ?% T$ f printk(KERN_INFO "LED register sucessful!\n");; M }; }: {) Y ^! A4 z0 a
8 G" w F9 N8 q/ A- }; l# a) x; z$ M return ret;
, h8 L1 P" B8 R' k. t- k$ G/ s0 @}
0 x3 A; Z# `: |, I
* Y; W2 [1 d# K# L' c/ Vstatic void __exit led_platform_exit(void)
# Q& b8 h$ ?/ Q( t4 c{$ f% E W6 {+ {# y1 f
platform_device_unregister(&da850_evm_tl_leds_device);$ h$ U( H# a# l9 `
! u; d" R5 ^0 P$ a7 q
printk(KERN_INFO "LED unregister!\n");6 D) r8 Q* \0 \7 a+ `# [1 A, J- {$ D
}( d% b8 U' p5 B* s, S+ }
) |0 l; H, R4 m
module_init(led_platform_init);" v' z, \! {+ h+ W" {! g
module_exit(led_platform_exit);9 X1 W+ d% G8 n0 s4 B, C4 v9 y' U# y
M; a* j( J% h/ A7 q: S/ q" t- ~! Y1 }
MODULE_DESCRIPTION("Led platform driver");
! H# w% E% ]3 Y6 U& v! L, b0 j( ZMODULE_AUTHOR("Tronlong");
- Y8 Y, V4 C$ G9 U* ]- `. KMODULE_LICENSE("GPL");- Q1 g4 O8 S' w' [' R$ c; c
/ U' E9 d6 @- L" P2 P- p, E+ @$ I
|
|