|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: e2 b4 ?3 u. g _ z
#include <linux/init.h>
2 w, c" _1 Z* c2 }4 p* ~5 F! F, D#include <linux/module.h>
; D; J* R8 T ~- i# R& ]& D- h; O+ Q#include <linux/kernel.h>. c, I, }8 P7 }1 Q! V( a* }
#include <linux/types.h>
0 s7 z2 F0 E, [$ O, w3 D2 b#include <linux/gpio.h>) I1 v" c4 q3 g2 o' Z X
#include <linux/leds.h>
+ [0 S4 P. f: K2 p* {9 x1 l' v9 b#include <linux/platform_device.h>
6 e4 [; I0 c- Z7 U3 m. z( J: J8 z/ G' m$ G: F- E! ^% |8 A0 H
#include <asm/mach-types.h>+ E/ O* @, c, ?+ B/ K: |- J
#include <asm/mach/arch.h>
! e \) a$ H8 c/ r9 s: J) w/ @7 Y#include <mach/da8xx.h>
2 f0 Q. W S# u; R#include <mach/mux.h># k# x% ^8 `* b3 m1 l9 C; n6 y
0 I% n) Q1 U5 |1 h: R* s#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# w+ l% W: s" H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% _" v6 s' w: B7 |' |) X# k0 p) D
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& Q8 _3 N2 U6 Z% `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" n% z5 b9 B5 h7 J- m
" A( Z* ]6 A# e/* assign the tl som board LED-GPIOs*/
) N- P- ^- Y; h6 Lstatic const short da850_evm_tl_user_led_pins[] = {
/ C) O, c( A' ]! R( l7 d5 P: ?: m& e /* These pins are definition at <mach/mux.h> file */
: _6 N' H" ?; m- s. P4 C$ { DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 d. @ \+ [$ o% }% f7 \3 l -14 D. V& e; R1 y/ G, p( ]- k
};" m6 ^# y- u+ a6 Q
3 d Q- Y. l3 a5 K7 Lstatic struct gpio_led da850_evm_tl_leds[] = {
2 [2 n' g/ m( w8 w3 a+ U8 T; r2 l {
; P* l/ f, [% i- c( c% {$ O .active_low = 0,5 j. r; ]/ L3 O# @
.gpio = DA850_USER_LED0,
9 ?( g$ A. s0 e" T2 ]9 `+ u n .name = "user_led0",$ C2 z" d( i1 m) u: R/ G
.default_trigger = "default-on",
3 Z$ U$ b- _# \( D+ }. g },4 A9 N4 V/ N1 N0 {
{
; ], p5 ?3 A0 H) u2 _ .active_low = 0,. T; E7 f2 C) [4 k
.gpio = DA850_USER_LED1,
0 f# `0 q7 [* z, w1 ^ .name = "user_led1",6 g5 n# Y' v) V( P3 d. N
.default_trigger = "default-on",
: S: G! S. v ~9 m9 V },9 ^" D+ L. V. _+ u
{9 v. _# b+ y, @5 F" @1 U8 i( o) H
.active_low = 0,# V% G& L( [- Y
.gpio = DA850_USER_LED2,7 A' D0 _) Y+ t9 ]
.name = "user_led2",4 d, Q' P# i* C+ Q1 P9 O2 U) W
.default_trigger = "default-on",& ]' M. O' U+ S) G8 M
},
- v0 q/ Q, e# [6 Z9 B6 u" C {- \, ~$ W) t5 k% u2 e
.active_low = 0,( G5 }% U. W" z" n
.gpio = DA850_USER_LED3,1 H8 Z: f; w' E' `, P
.name = "user_led3",' U* c! w) ^) y
.default_trigger = "default-on",+ ~( b. [# ~, x9 M" ^2 B
},
0 s u$ c8 G! v) h};
- z/ C. |9 P2 f5 A* K: Z/ ~
" E ?& b( B9 n! g- ~( k2 fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: G% h' B6 T$ x
.leds = da850_evm_tl_leds,
* A7 q. z! K( k6 ~ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" C4 b B. N" q- v4 v5 C% A" o9 |};& e7 R3 z3 V0 N
3 {4 S6 {1 Q5 d+ Ostatic void led_dev_release(struct device *dev)2 `. s' |; T, X6 y. R: j
{1 j& N8 W Z1 o( M5 _
};8 z* n8 m, x8 o8 M) C" M
`, ?: ]6 p+ n0 C
static struct platform_device da850_evm_tl_leds_device = {
( j, t2 Y9 U% x) G: y .name = "leds-gpio",
4 J, T& r2 F) o1 K3 d/ a+ `' } .id = 1,
- q3 \0 X; s9 P9 W7 @, K .dev = {' {7 _/ t& o& T. j, e
.platform_data = &da850_evm_tl_leds_pdata,# P9 V, D1 }# z+ T/ ?' _/ b9 F
.release = led_dev_release,
8 t: [% V4 {, B1 l0 C& Y }$ }; ]' a6 z% X$ P9 w, y- \! n
};
q6 g- M, F6 n
+ ?, `, i* S+ dstatic int __init led_platform_init(void)! c4 @- D7 w3 M/ o @7 A; @; D4 P
{
2 |7 w. s+ K h4 P int ret;$ H: L6 O5 f4 D0 l' H5 Z; i5 L
#if 0
7 D3 E H' w2 s0 A* z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% O' b) M; a, w: W if (ret)
$ Y4 v# \2 ^2 _' I" s6 M8 L6 C pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 O5 T- v6 e# d+ l& w/ ^1 ~9 }' q+ P
"%d\n", ret);) e; y4 z7 ]' @* J B
#endif
, @3 a, u9 ^$ [4 T ret = platform_device_register(&da850_evm_tl_leds_device);& Q* {8 C; W/ M- @
if (ret)
( i6 ?. L' V1 B/ X- ^7 N pr_warning("Could not register som GPIO expander LEDS");
: @; W. U8 m/ q& H3 ^' b( V, L else% d' R b/ d% B4 D5 I
printk(KERN_INFO "LED register sucessful!\n");
+ G0 a) i6 W) P/ f" H
4 F( `9 E7 c7 Y9 L; m return ret;
+ S* N0 K$ G( I i b}
( x9 j4 p5 [/ q# O! w6 [9 T2 P" {- S1 m) w, @8 E3 ?* Q* k5 S, N* p
static void __exit led_platform_exit(void)/ g' k& L+ w- u8 ~: g
{. \5 B+ O$ G+ Y
platform_device_unregister(&da850_evm_tl_leds_device);
. L. H" K% n5 b+ c0 m7 i& e( n, Y3 @$ Y; l
printk(KERN_INFO "LED unregister!\n");' z& S2 a) N/ M! f2 ?: ^/ r8 j& r
}, z2 S; ]( S/ C
1 }( k: h4 s3 q' {
module_init(led_platform_init);7 f9 Q+ }7 m3 t* K
module_exit(led_platform_exit);+ L3 I3 `: v! ]+ t; N& B
6 R3 m) c, }; l! w
MODULE_DESCRIPTION("Led platform driver");
# U. o; f$ K6 o/ GMODULE_AUTHOR("Tronlong");
$ b$ Q& f/ ?* T( p9 z" r% X! JMODULE_LICENSE("GPL");: S) v5 V0 u5 D# ^8 i
( K8 ~8 y) Z! y; a) d |
|