|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- I8 q: g. e& x! [
#include <linux/init.h>+ m3 n) ^2 k- j+ m0 X% f6 X K
#include <linux/module.h>5 E( s$ s1 `, t6 M! P
#include <linux/kernel.h>
) K9 r! J2 g o5 U8 f& c#include <linux/types.h>
5 R: R9 M- @/ w7 P, Z0 d9 w2 p#include <linux/gpio.h>9 G2 g7 Z: n! f2 z
#include <linux/leds.h>
, m- ~7 b3 I+ A& i3 n#include <linux/platform_device.h>+ M1 e5 ]4 I7 H
3 Z6 p# j7 @/ _; J2 \, @
#include <asm/mach-types.h>9 s8 S1 U2 o: ?, f0 }
#include <asm/mach/arch.h>
1 Y" f V' s" c# d; ]#include <mach/da8xx.h>- }. I+ |% }/ W3 {/ _1 \
#include <mach/mux.h>$ a6 `0 B0 K( H' A: k. G
4 b( _/ @0 q' d+ D. _#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! _4 m; p) W8 J& @& f8 i
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 M3 N9 y& J1 W" `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 T) ?4 I2 C* {; p( h0 \/ r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# `: B7 Q, s/ ?5 x' }
+ c- e1 _8 g8 _1 P; g$ g7 t/ }/* assign the tl som board LED-GPIOs*/
! o$ m/ D: G" h) a, estatic const short da850_evm_tl_user_led_pins[] = {
" \6 [4 G/ U$ W. ]! \ /* These pins are definition at <mach/mux.h> file */; D2 y! O" I- s K) i2 H
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 |# G5 B% Y% B' _' G: _
-1
+ N0 ?& J/ j/ S( k: x};
1 I* {3 W( ]) s* [3 h) _/ c0 \- n4 Y- d( @9 U
static struct gpio_led da850_evm_tl_leds[] = {
; r& }! w8 H/ O( E& {+ d {
* _( j, e) V% Z1 D$ Y .active_low = 0,! C; T! ]; H. u
.gpio = DA850_USER_LED0,
) y7 F1 E' |. u& p/ a6 w! l .name = "user_led0",
8 q: p1 s/ |, k .default_trigger = "default-on",! V F& G! v% `6 e8 t- [
},+ d) r+ A8 l G z2 r% Z+ `
{8 ^5 Y: B" l4 ?- k& j
.active_low = 0,$ A1 f; T# n$ U# j) p
.gpio = DA850_USER_LED1,: p0 [4 o% z# I/ O1 }1 r9 H4 Y
.name = "user_led1",
[ E% y; G/ V& Q- Z4 h8 n .default_trigger = "default-on",
" U Z6 ?5 _' o },
$ }7 \2 E! j6 Q/ C! D {
8 s9 k; H+ k. m# ~ .active_low = 0,* Z N0 o0 q7 r
.gpio = DA850_USER_LED2, h9 @1 R% l' g
.name = "user_led2",
8 e z9 ?: k3 H7 k .default_trigger = "default-on",
. r- S* N) ?" j) k" x- t, g6 t },, o* w2 v/ V8 E/ k7 ~9 I7 u
{
* m# Y+ ?& F1 |/ e+ q* \ .active_low = 0,
* n. ~* q* d( ~& I% }" W .gpio = DA850_USER_LED3,
" h7 l( }3 }4 K: Z* G6 b* C .name = "user_led3",: `9 z) a5 y4 K0 ]' M
.default_trigger = "default-on",
- O$ L# W' ? e9 y. f1 { },
. p# _, S7 b8 F& q};
. R F" J$ B- _5 H' S! F, F: G) O7 ~, I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 G9 f9 L% w+ n; q% C .leds = da850_evm_tl_leds,
1 R% m: |5 e/ `+ R .num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 _ G6 o2 t: V# b2 p# P# \
};7 q! k( _, u2 N/ A% u
& Y5 m( Y0 u" Z2 ~6 c
static void led_dev_release(struct device *dev)
7 r, W- j7 K# c& C: u{9 I% p, ~6 I! A0 l
};+ e8 J1 l$ `. |( T, Q' S) c9 J
, U6 a& N; M6 | T. P& Y
static struct platform_device da850_evm_tl_leds_device = {
+ d$ b0 T/ f' q3 h& s# t5 P .name = "leds-gpio",
5 B* ?6 u# Q) I' ]9 J# w Q, M+ E .id = 1,
; y( `4 X' l, J2 r" e& k .dev = {" M, h$ Z9 K9 g% C
.platform_data = &da850_evm_tl_leds_pdata,8 \6 P. Z. a' f8 ?
.release = led_dev_release,
# t; x0 y0 Q0 @3 x; x* L) p$ {" R# L3 V }
& G) K: v- ^, J7 |& J/ h$ l% j# g};% q r$ Q) H7 h
+ g4 X$ D# q. D, ]8 }& ostatic int __init led_platform_init(void)
! v7 C, S; ?; s- C& j3 H{
! h. J6 w, ~3 I9 U& |. a! R @5 @ int ret;
' u; U. x e0 @#if 0; G2 ]/ G6 U6 G% {
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% Z2 f6 P% _4 H' x5 Z$ v if (ret)
3 s% X7 J3 X9 p9 l$ J- C- \ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* D* G+ l+ Y. S3 W7 V# Y! i2 X" O S "%d\n", ret);. U8 `$ p; u' E( ^
#endif' Z+ f3 G U5 \4 z6 a
ret = platform_device_register(&da850_evm_tl_leds_device);
. b- B6 G# T1 i0 n) f if (ret)6 E; R# |0 c8 f
pr_warning("Could not register som GPIO expander LEDS");
/ \# u' X0 H$ {9 ^, t) C9 b( g else- |/ r J$ V) c1 [2 U, \
printk(KERN_INFO "LED register sucessful!\n");
* r4 `2 L. X" n; V' H# Q
+ W4 h+ [8 O, T/ T return ret;
# i8 l, J) D' V, [}& d7 A) {4 H! M1 z" j( s, [
) @" ?1 y/ M4 A5 s5 ?6 n0 n) \6 wstatic void __exit led_platform_exit(void), k) q! A* K& S" \
{
" h% l3 M+ K) O3 K T4 j% E platform_device_unregister(&da850_evm_tl_leds_device);
+ P1 u. Y: g, p, F# {* H3 p! |2 l+ L% |9 F. @
printk(KERN_INFO "LED unregister!\n");
8 c1 b- N+ Q2 h; y* ?! |}
; M9 U) d0 ?8 I9 G2 c' ^1 `0 f$ s. ~6 I8 u; M
module_init(led_platform_init);( S# E- [- {+ g; ]+ j, g
module_exit(led_platform_exit);# m; v( \# w7 a. s t; G5 {9 v
0 N% W: \0 e$ ~8 C5 U$ O6 L0 u5 z) A
MODULE_DESCRIPTION("Led platform driver");
7 u& }7 c* |8 [4 BMODULE_AUTHOR("Tronlong");( C$ a% n( M* G2 x: W2 | h0 m
MODULE_LICENSE("GPL"); @" c; F' B' l
: Z, T- N& T$ W: m8 x* Z) Z! L6 O! w |
|