|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% g+ t* k5 T0 | ?+ m
#include <linux/init.h>' A# W, F( h# _$ f
#include <linux/module.h>
' O: q" |' A" s* [/ \# q) H( D- R#include <linux/kernel.h>( `) w# n3 y3 g6 m& e# m: }& C
#include <linux/types.h>+ H5 z" p+ g* x8 j8 y& Y; j" M* t
#include <linux/gpio.h>
9 a. x! B& k( G5 ?#include <linux/leds.h>
% I) U9 \. Y% R8 Y' L5 g#include <linux/platform_device.h>
5 f( h& ~$ @, p1 e) {
6 Y# I n' Z8 {+ p2 m* w#include <asm/mach-types.h>. C8 _5 s v6 o) b: ~7 y9 a
#include <asm/mach/arch.h>
4 C, q% {& y3 c* p( V#include <mach/da8xx.h>8 [+ G! F" y- L
#include <mach/mux.h>
9 m2 W( k+ O& v& o) G4 \1 o# L! ~& b: ~9 _! |. M4 H
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): H- p6 Y$ `, w* T% j, ~; h
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% [! \0 w: U. y5 P- {: u0 j
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 d* l- A3 ^( e& ~, y% K8 h
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 n1 u/ T. }0 b; v- u; v$ T! V7 h% ?% c
/* assign the tl som board LED-GPIOs*/) i# Q$ ]' e. K5 S) W
static const short da850_evm_tl_user_led_pins[] = {
% B3 @7 W' U9 L" n. S; B /* These pins are definition at <mach/mux.h> file */* |0 y6 s9 H) ]6 ^4 I) ?
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; \: b- |. k { -11 s' n; B: x# m- r1 j
};
/ a* [$ c B. s9 ?- x" G, p/ N' B' J: f" h) O
static struct gpio_led da850_evm_tl_leds[] = {3 Z- f2 q& |# G' o `
{
/ \" A2 X5 ~& T2 d! D, z, v .active_low = 0,
" T/ @% E+ Q7 W .gpio = DA850_USER_LED0,$ _( Y! R+ k$ v7 { k$ J
.name = "user_led0",
: }( G. T! v% X2 ^4 R2 q .default_trigger = "default-on",
+ h. w8 A0 h5 w$ b3 j# h; Y },
$ T8 [4 P8 \3 A {+ j' i$ R" w) V( H, n
.active_low = 0,
- N9 [$ a5 ]5 K+ N+ n .gpio = DA850_USER_LED1,6 @0 y- d7 [. w* B: ^/ ~) J
.name = "user_led1",8 `( L3 X0 l4 F$ M3 g& b) S, g; j
.default_trigger = "default-on",/ G8 E# Z' P% C8 R
},+ K, c% i ^5 I4 p4 f) h
{8 I6 R$ ~1 e! v7 y- L3 x
.active_low = 0,$ X; b% i ^& M! V3 x. O3 d' @( N% I+ j8 y
.gpio = DA850_USER_LED2,
9 Q! N( Z8 ^/ x% |2 e% J9 E$ B .name = "user_led2",9 i0 |. D) g# o3 e
.default_trigger = "default-on",
4 n4 I: F V7 ~8 x% W/ G: H },! T6 S/ X3 j' J3 a. F3 s
{4 }6 K$ c6 j/ N: |$ t
.active_low = 0,
R$ d' Z! f, I- C .gpio = DA850_USER_LED3,
, k9 _4 O" ^- O9 p) @ .name = "user_led3",
0 o, e7 r: U% |- T6 ? .default_trigger = "default-on",+ x5 Y( P6 v" K$ Z
}, L" a' _! O2 H- W* J; C1 x: W
};
! p' ^: M! O' H& L2 n3 A1 D# T7 n$ H3 S l2 V9 L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
[6 A/ w, k" b1 c8 }/ \ .leds = da850_evm_tl_leds,
4 b! ]; t1 E! J( {- H/ C .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 E: P5 p- L) M) v, O% @/ J1 D( t. S};6 n# a3 {2 w$ d4 ~
! s3 J: Y2 g; d* A1 f7 H, L# o. |
static void led_dev_release(struct device *dev)! E/ {. d* ~) [, D) A9 T+ I
{
s6 J) W8 C0 O6 z6 Z};9 B" y, z- _1 O0 i
D. ]5 ]( q# p1 o. }8 F5 Qstatic struct platform_device da850_evm_tl_leds_device = {6 u+ ?2 A" _2 a" ]" A# A# d* C
.name = "leds-gpio",
* @, U. K$ z) s9 }8 m .id = 1,+ ^+ m3 p) `# ?
.dev = {
9 h8 ^; X% }" m1 L' N8 j- v/ W6 I .platform_data = &da850_evm_tl_leds_pdata,0 k( ]! U/ K0 s! k. T6 H
.release = led_dev_release,( d$ u: t: Z" _2 X* H3 B( f
}
' J$ s% u1 F$ d* Q& x0 ^. t$ i};2 }, [. F5 N% U1 p/ P5 C) E
6 R' G7 J. f2 G4 _static int __init led_platform_init(void)7 O5 d8 |$ a4 o1 K# v
{, j# L( e' A. O3 t) c( d
int ret;' k7 o% U! r. A" N
#if 0
* p& C7 u( h; ~3 }/ `5 t ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; W, T; I1 J. j if (ret), T1 v. O, a# p1 }3 J) k m. \4 [7 H
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# E: ?4 |. I0 W4 [# R
"%d\n", ret);
0 r0 E: A( k. F3 t n#endif. W+ C' \# B: H. ?. P% d( R
ret = platform_device_register(&da850_evm_tl_leds_device);* e% B2 t7 j1 O* q
if (ret)
& L" f' |- Q) g! N2 C, S+ L& `5 c pr_warning("Could not register som GPIO expander LEDS");
+ U- h: ~7 `( Q! e else0 Z' I( Z7 A7 ^0 h: D" J
printk(KERN_INFO "LED register sucessful!\n");
# l: D5 g" d/ a3 f) F$ ~% g3 ^' E$ Y4 F
return ret;4 a& i3 i* c! a' t! U; o' e1 ^
}
# F) g" ]) _; Z- q5 y1 H* ]" \+ S; A% j; H5 B5 s
static void __exit led_platform_exit(void)
+ E* } r' Y% R) Y1 I; x- I{$ Z, c! U' S5 c1 Q: L2 A: l P
platform_device_unregister(&da850_evm_tl_leds_device);7 Y l5 B, D* V
$ `9 j1 E" F* S& Y* L
printk(KERN_INFO "LED unregister!\n");
2 [4 s/ m. {* d* r$ l+ u}
: o# z+ c+ |$ {$ _. Z9 @2 n
) p* p/ Z# p, m( K5 o5 Wmodule_init(led_platform_init);& n- U& ~. L' T9 J) _
module_exit(led_platform_exit);! _; [* S0 _ U9 b
2 X8 M" p+ X! z' H/ I |3 _" eMODULE_DESCRIPTION("Led platform driver");
1 Q9 M7 ~) n3 M, j l+ ]MODULE_AUTHOR("Tronlong");
* o C u7 v- i9 [6 f9 BMODULE_LICENSE("GPL");
* L8 f4 u1 U" q* f9 T- A+ f4 i2 D( B2 w7 b
|
|