|
求大神给下面的程序做注解,请稍详细些,谢谢。3 j. Z9 |: o+ s7 t& H' _$ I; n
#include <linux/init.h>
( B* f. r4 N0 K4 H+ ~& f, O2 m+ R/ b#include <linux/module.h>3 y- f8 V( X& M* ^ P
#include <linux/kernel.h> J6 n6 c# O( ^
#include <linux/types.h>
) e2 D+ C% T) z4 ` N#include <linux/gpio.h>$ q* y8 D: f& W+ I
#include <linux/leds.h>+ S. v. J# L" T+ R, q( v! Q' w
#include <linux/platform_device.h>- }6 J0 |! s0 p- _. n; S
- i' _2 w3 S% B4 ?. o# P2 K) V! d
#include <asm/mach-types.h>
9 z2 k" r' x4 i' z& O9 r* T' t#include <asm/mach/arch.h> w1 x3 W- g3 Q4 C' q* `3 C2 q
#include <mach/da8xx.h>
% E; q: B9 ~+ q$ D. j#include <mach/mux.h>% N; u: I/ f2 R; Z; L
% @9 D6 H* Z5 _: D( P
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 R9 `+ {3 L. X. r* B#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* }" t( ~) R- S# N! w
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! v3 |# W7 H" @6 `
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). E- O4 x1 g! r( Y; N+ ~
, p5 y% k X+ c, Y; ?
/* assign the tl som board LED-GPIOs*/
" T0 J- @% p/ @static const short da850_evm_tl_user_led_pins[] = {
+ o* O/ a) G* q$ A /* These pins are definition at <mach/mux.h> file */
4 J% m* Y$ h; b- w; N& d DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! U' f3 q. |( ? o% O1 a -1
% N$ g6 `' r/ G% s6 m. B% t};
5 V& Q4 ?+ Y( x) F5 K
3 \3 d! O; K; Z5 n% D! ~5 c; Istatic struct gpio_led da850_evm_tl_leds[] = {
) i% u( N. v% J3 @1 r: h) J {* Z: {; z. [% X4 {; p/ h
.active_low = 0,7 k- B' u2 h; p; Y
.gpio = DA850_USER_LED0,
' |0 ~$ P; c2 u. I .name = "user_led0",
$ g7 `, l# z# V .default_trigger = "default-on",
5 L, F" V. k$ X. e* p$ p },
5 [4 k/ X9 A1 \- n {1 s+ A& O; L9 s, r. j8 I4 L
.active_low = 0,1 T, j& b; u0 a6 j" ]
.gpio = DA850_USER_LED1,
& y) C4 n. m# Q. ] .name = "user_led1",; N% \8 c% ~! A9 n3 _1 z
.default_trigger = "default-on",6 P% F0 L/ j3 N" K1 ~8 o& k
},. d& j! i3 e5 d1 W+ k1 k
{; t' G. G/ H% V6 I$ I4 }8 |
.active_low = 0,8 w _- u m* X9 F+ X
.gpio = DA850_USER_LED2,- a8 O U0 h! |" w7 y9 a
.name = "user_led2",
" x- n, Z- `9 ^1 P+ @3 ^1 ~ .default_trigger = "default-on",
- {$ j8 @( b0 Y },2 M$ F f1 [+ Z1 o
{: j0 v1 Z8 ^+ d- g& d
.active_low = 0,
( |! O9 X5 k! } .gpio = DA850_USER_LED3,/ W& W: r x/ L7 y& ^+ D8 g
.name = "user_led3",9 I! Z. @( B% n+ J! O
.default_trigger = "default-on",, W- H, D9 @0 L
},
0 K$ V0 u2 m; c- S- l4 d9 e};
/ |) C3 D7 e2 K, x0 {
2 N( j- D1 o3 R0 T0 J' ]! Lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 l$ Q& x: J- c .leds = da850_evm_tl_leds,
0 P5 q: M( [6 R6 n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 h1 r# N1 h: n+ D4 b) a! Z
};
5 a9 ], K D! V
0 k t9 d$ X/ Nstatic void led_dev_release(struct device *dev)$ P& w- [6 ^9 L, r( X6 C
{
2 l1 `) v* T; }* N};9 {3 L) V M* M5 k6 u+ r
" n! y: q/ y. u" N$ o, ]
static struct platform_device da850_evm_tl_leds_device = {
: D# n) m# Q3 E9 k .name = "leds-gpio",
* y) T# A4 Z) w+ w) }% p& a6 s0 z .id = 1,, |. R( H6 I5 u7 D
.dev = {+ M( i$ y+ n# Q8 p0 ]0 k" j
.platform_data = &da850_evm_tl_leds_pdata,# T; w2 H) Y4 @: o8 S; g
.release = led_dev_release,
; I/ ]4 h8 S3 P4 a4 `! o% G }; b) F& l- v# i; D& S# w
};+ d) ?2 M- S( `1 n" w
+ Y# R0 p) b& f- l2 w( bstatic int __init led_platform_init(void)- F; a3 s% {* V/ l- M& o
{- k- }2 E7 x M$ c9 U. a3 |
int ret;
) [+ H2 c. t, l3 W( X6 V' }, R#if 0
5 g9 r D: R% Q$ a, j% W7 F ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* p* I% C( W: `6 j& {3 C- i
if (ret)
* H* U% Q7 F* d" U- ]( d% X5 u pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
b+ r1 T' q: j! N "%d\n", ret);
! _9 k" b8 T2 U% d6 V#endif- p1 h. F& i; p* e6 A
ret = platform_device_register(&da850_evm_tl_leds_device);
! V }& O% x) T if (ret)
, t, x1 l% Z) Z) W' z" d9 T4 @ pr_warning("Could not register som GPIO expander LEDS");
* z, ^* A9 Z- p2 Z. D else% A' q2 F* v, J0 ~2 @7 Q
printk(KERN_INFO "LED register sucessful!\n");, f& U- C; W; m4 f
) m3 M. L* }2 E' E8 N5 R' S3 Z# g return ret;
& t6 K8 S$ q! b5 h; g7 b8 b}
3 F' k& z/ D" F3 ?
, c3 c5 H/ @* ^9 B9 `6 estatic void __exit led_platform_exit(void) x( ]; p( |7 f$ o4 }1 _" C
{
( G4 F6 J- ]/ H3 E platform_device_unregister(&da850_evm_tl_leds_device);/ x% ~) f6 l* {- U5 w
]- t, f$ S# N) Y' G
printk(KERN_INFO "LED unregister!\n");
1 g* z: q g: I' ^& `% R/ {}
' \+ M% S( W7 y2 a
f0 t4 n& b5 p, V5 e) J0 f) Umodule_init(led_platform_init);
) U8 d' b0 f+ w/ b3 p/ U- w/ T9 Amodule_exit(led_platform_exit);2 n) }3 T0 i" t5 G( h
% A4 b; M4 v' U% P) [
MODULE_DESCRIPTION("Led platform driver");
: j* L" j* k) @" Q3 `% N+ Z/ n$ wMODULE_AUTHOR("Tronlong");
5 H- S0 O9 M9 ^& b% FMODULE_LICENSE("GPL");9 J( V$ }, B: e
( D4 X" ?) j4 ?( B |
|