|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# N- ?! c! r6 V% k! r#include <linux/init.h>( m; {- o9 d ?7 W' U
#include <linux/module.h>6 {( V6 D+ I) d4 p
#include <linux/kernel.h>
' G* u3 ~3 I0 V#include <linux/types.h>
# E3 o* G; n: o! ?#include <linux/gpio.h>
) _& C* Y0 K. n4 j6 G#include <linux/leds.h>
2 U! M' G8 S( G$ p0 J#include <linux/platform_device.h>5 T% S. z: n5 `( p3 t! T% W, w
8 |8 l. r6 W) {) ]$ ~8 o5 C
#include <asm/mach-types.h>
3 |% C" T9 C' U3 |. e6 q#include <asm/mach/arch.h>
. C0 u* y/ B8 {" L- g$ f& ?#include <mach/da8xx.h>, [8 W: d/ a; b1 s( C9 \
#include <mach/mux.h>
: I t7 k' u- W+ N7 v( l: I, y& U6 C8 X6 @- C6 x8 q+ d& J. g
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 C- |0 B- g G! y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; S t$ z8 e( n$ L/ `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); m) t8 ^" b. @1 x/ Q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): W5 w+ }- ^) F D
8 b/ k+ d6 b+ Q: h/ B) p
/* assign the tl som board LED-GPIOs*/
* c8 T. V* P+ X- hstatic const short da850_evm_tl_user_led_pins[] = {: y& s# P( S) u& v& Z! y
/* These pins are definition at <mach/mux.h> file */9 C/ ]' \3 A# H' Q4 o% b
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 M; D ~6 r' t" C" o3 Z; O4 L/ a -1
h: n8 [; O3 J- @. B f};
3 p, M8 S! w$ |& G- s2 k' ~' u: ]4 P) T6 {4 A9 _, X- k5 c
static struct gpio_led da850_evm_tl_leds[] = {$ V$ X8 f9 _5 ]7 c2 E" N2 a
{
2 a' v& y- `" A- c: p .active_low = 0,2 N7 \% e& {" a& E" c V
.gpio = DA850_USER_LED0,
, K' m6 ]+ u( U: Z3 h9 g .name = "user_led0",1 h" C9 L1 `% F8 A' a7 x7 R) ^+ y" w
.default_trigger = "default-on",
! D9 v3 s0 R+ j, {6 f },
, ]. G5 Z, f( K* v9 x2 \4 V7 ^2 H {1 P4 k6 e7 I* m4 n
.active_low = 0,! \3 x9 z7 Q: E! }
.gpio = DA850_USER_LED1,
+ Z0 G* g3 ~7 p; M9 Y. q; w .name = "user_led1",0 J8 r; }# ~2 ^0 ]
.default_trigger = "default-on", R0 a; v( ^$ N' g- ]$ s
},
/ A1 `' G l8 ?7 I! m4 j$ }% {0 E" Z {
" C9 t* J' O; Q" r0 |2 i .active_low = 0,
) D- F. d* d$ A, A7 w+ I' t .gpio = DA850_USER_LED2,& p% M" n( G; o; k/ h4 T
.name = "user_led2",
* J! J9 ]$ R3 p( E% H$ m2 U7 e .default_trigger = "default-on",: Z- G/ {5 `: ~+ ~/ k9 {/ O% D( K
},
. i; ^0 Y, Z1 x {
9 ~' m! `" N4 t .active_low = 0,7 p; d6 {# r4 h$ G" J; `
.gpio = DA850_USER_LED3,' q1 B/ [) A2 ?/ h
.name = "user_led3",1 h9 l0 E, U6 z( _2 C
.default_trigger = "default-on",
6 [) C& ?, ]/ S+ { },
2 e( m4 f$ y; w0 J5 @" ?) k};# `# j0 c+ P% X8 C
3 R( u4 }1 l9 L% a# J: Jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = { \6 M* m% J4 ~ O" M
.leds = da850_evm_tl_leds,
; O9 D6 P9 n- T4 E .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, `4 G$ Q9 }2 E7 e& K* ~};
2 e8 p, `2 j9 M; h% n' b* z7 c5 }" _$ _. m9 ^
static void led_dev_release(struct device *dev)8 w9 R3 s& A% |' Q% C
{
/ k ` M ?' U. f5 T* z9 w0 k! m' c};" ~: {, ~6 O/ U
$ R3 Z' M8 O8 K( Kstatic struct platform_device da850_evm_tl_leds_device = {, r& q( m3 {2 m t$ U
.name = "leds-gpio",3 J! I9 i( Z! F/ i5 b, E0 K
.id = 1,
) |/ J) c$ k7 v! E# e# Y .dev = {2 z% x, @! W4 T' ~ L9 O7 i6 n
.platform_data = &da850_evm_tl_leds_pdata,
0 j3 c4 |9 M: {; V .release = led_dev_release,! b# O X4 }: T5 r, F
}4 x: Z8 ~+ P- p3 n
};
* Q/ J- j" L0 \2 U+ P- H6 f2 r2 I1 U/ Z& @ J3 A
static int __init led_platform_init(void)
3 ?$ D( ~ J8 L/ u( ~1 l8 H8 j{9 X3 S, V4 h2 C
int ret;* H/ S4 S I' B$ D8 d, q3 E
#if 0
% O" d1 R0 v) `3 D" f A2 I ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% i3 |: D# B( U" X" a- O! F if (ret), v9 z5 @8 c& c# W% P! ~% ?1 O, U
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 Z3 G- M' U1 P2 W/ Y! x! {
"%d\n", ret);
9 @0 k6 b& n7 M; Q# y" C2 c#endif
# g9 k: t1 a6 V. n. `" L' M( R$ u/ m ret = platform_device_register(&da850_evm_tl_leds_device);* J- m. _( H5 d& `
if (ret)
8 ]/ h+ ?" V/ a2 [) u) x+ ]. s pr_warning("Could not register som GPIO expander LEDS");
+ D9 E; I9 P* s else
1 W" {4 X! ]8 H7 Z( w5 M. E printk(KERN_INFO "LED register sucessful!\n");2 z. S$ M W) G4 a$ g7 v
$ h8 t+ i! l1 { return ret;
+ X1 U A; `% w3 N}0 \3 q% Y6 H e7 ]6 Y
- q: F+ c. ]+ Z5 xstatic void __exit led_platform_exit(void) m+ g# a$ o6 Z
{3 m. i0 p! i. f
platform_device_unregister(&da850_evm_tl_leds_device);
5 i. S$ Y) P" G' W- Y! V1 i" _: K
}) W) R" |, F% F printk(KERN_INFO "LED unregister!\n");! |% Z3 a0 q2 ~) V3 U' F1 n' G
}8 W/ v) w8 C) M, e8 _
6 d- _' @8 k( lmodule_init(led_platform_init);& q( L8 C7 H4 A9 K4 A a+ R3 V# e
module_exit(led_platform_exit);
D% r3 a0 P- v7 S r& m9 K2 s9 x1 H* c5 q
MODULE_DESCRIPTION("Led platform driver");
# p; c5 c6 C9 e* j" @% G4 h2 N5 rMODULE_AUTHOR("Tronlong");$ L: F* P! x5 Y+ _
MODULE_LICENSE("GPL");+ P" N' b1 y4 M- F3 S$ g N
$ l) x- w: D6 N* l) S6 b |
|