|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 V: a; O% B' |+ w V: Z& P#include <linux/init.h>7 v# F7 O! e$ u6 ^8 h. V8 c
#include <linux/module.h>
+ Z7 `4 V7 V& e1 s#include <linux/kernel.h>
& I+ E. G* l- Y9 |+ A8 Y& `" W& t#include <linux/types.h>
" k+ p. V+ P+ E) ]: ~#include <linux/gpio.h>
0 m; i: e$ I8 O' A5 X8 Y. E#include <linux/leds.h>
$ w" E; r' [! Z. U/ O#include <linux/platform_device.h>
& |) F1 e5 Z0 `5 d9 Z
5 S; [& A$ p6 k#include <asm/mach-types.h>5 H6 c/ a- |: U
#include <asm/mach/arch.h>
# Z" Q5 O" l/ [8 `: @#include <mach/da8xx.h>/ P6 i( n4 \& g L0 {% z
#include <mach/mux.h>1 B c0 p# b: q! |$ J
# c' c3 G7 I- z/ J' l S p+ m#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* q! G: h' [" H v8 I( I#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) }, O# E/ `0 j( e b' T6 w' A4 t |#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); E5 ^% j7 k; ~4 [- Q' `
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), r" Y: n3 _5 {8 a- i
0 J5 C% E) P# L' W! N/ U- h/* assign the tl som board LED-GPIOs*/* F+ P' ?0 Y2 @
static const short da850_evm_tl_user_led_pins[] = {
0 v1 w9 ~& Z4 \+ e3 _: q0 @ /* These pins are definition at <mach/mux.h> file */
: v' I$ i6 N1 f0 Q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 c5 T( G& \% U7 C
-1( a6 v* }' }+ a2 p+ P5 K3 N
};+ v2 ~8 O0 w2 ]' q7 V* q1 k" a
a/ ~" c; e7 i4 U$ ~2 B9 r
static struct gpio_led da850_evm_tl_leds[] = {
" Q- }' A/ H$ E6 `' T d {
4 x$ f2 I* V2 S" r3 H* [& ~ .active_low = 0,9 ]! k) ?$ q: J* e% R G8 e
.gpio = DA850_USER_LED0,: B$ c& G- s$ P2 j. V7 L3 \4 o- V
.name = "user_led0",
8 G0 _; p" P' k4 ?) o+ G L .default_trigger = "default-on",
8 L& F7 s7 i2 ?6 x9 _2 s( _5 W },
1 J/ X$ }+ N% J% G& Q {* z' l1 L1 v5 y9 D: K2 R F, c
.active_low = 0,% V0 S3 `- ]. \
.gpio = DA850_USER_LED1,/ X. @# \$ l7 n ~' s0 f F6 {
.name = "user_led1",, I' `( _+ Y: G% b8 l
.default_trigger = "default-on",
3 u4 p3 [2 j* V* f e# J },
. b& j' U3 s. h7 V {
8 | i# k" i$ S3 P/ u/ g4 I. P .active_low = 0,2 j' x5 E& i! ]/ @
.gpio = DA850_USER_LED2,. ?- I0 C2 i8 @" Q( y
.name = "user_led2",
# A2 Q0 p9 o: h; `7 ~ .default_trigger = "default-on",
5 N, B6 l1 n- Q8 Z },, O: u! _3 e( E5 X9 D0 u# o4 w
{
$ `. T! Q/ Q: u1 ^' _6 P. \% @ .active_low = 0,
5 P; A9 e/ b# ^) {6 f% _ .gpio = DA850_USER_LED3,% o3 T0 {" W/ O6 O8 `$ d
.name = "user_led3",! E6 |- [+ @/ j- j, p/ K
.default_trigger = "default-on",
( h5 p( m8 d2 J, S1 H4 l: l& D },2 J0 m; W1 r7 W
};; t0 T3 {5 L& j7 s0 b% n! `' Z- j
6 [6 b1 d0 m2 `% T# D$ |5 k, Wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; O( S0 r2 Q h" O .leds = da850_evm_tl_leds,& R d# ?% d& V! H0 W
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- n! \6 p) n" e# h/ \$ B6 _};
! [. I# U9 ?9 ]. Z6 y; [/ `$ @. G6 N# J6 p: E+ v8 M% U( d4 x H) ?
static void led_dev_release(struct device *dev)
# N+ _2 o4 W, S9 y. Y9 h f6 U% M{1 _8 n' R: M0 u2 \1 z, i4 m
};* l8 ^% W' S* E6 o# s& d8 H
0 Q3 B" v! L2 Y. o/ U
static struct platform_device da850_evm_tl_leds_device = {
, Y4 b- n) |3 { .name = "leds-gpio",: M _1 k4 K! o% W8 f
.id = 1,
, Y! ]. r f, @7 c# k .dev = {; b G6 V W9 G* ]2 T* w* x0 f5 P4 G
.platform_data = &da850_evm_tl_leds_pdata,% r7 ]8 x) f" U/ K: v* V" n4 q
.release = led_dev_release,
% v0 ^2 q5 X4 {. G! p }
6 @7 k2 a$ L" ]) v};
( F! P! }4 v$ m2 v7 z6 M( L6 t, N2 w! `* a
static int __init led_platform_init(void)
& Y$ k! V7 _3 w( @# p( Y4 a{
; F3 r0 B# r" B0 ], r int ret;/ G" g: Q- D6 q- L
#if 0) H2 Y. i# y( d f
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 X. _: Y9 `6 B2 i/ j( Q if (ret)8 A* S" b3 q; Y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :": Q2 U* r- l4 d V$ J/ n/ E
"%d\n", ret);3 J! {. \$ G" N5 {
#endif
' S* S% s# e& M ret = platform_device_register(&da850_evm_tl_leds_device);" D* D) O! x0 @4 p+ a6 O) q
if (ret) u$ v. z3 H% a# P" ~
pr_warning("Could not register som GPIO expander LEDS");
* {4 W; D- ], h! K' z# f else/ i3 J* Q$ A0 x$ S& G
printk(KERN_INFO "LED register sucessful!\n");) Z8 ^ J" `+ c" h
! y+ c* V1 ~6 T* x2 S& a w return ret;
, B1 L$ d7 c' d1 a}) C# n8 r/ t9 E( m: Z H7 B
' {2 U5 A) K6 Z" R7 J. X
static void __exit led_platform_exit(void)
3 n/ K4 g( C1 s% A" I) J{
6 I0 |: |$ o7 f* S platform_device_unregister(&da850_evm_tl_leds_device);; ?6 G1 d" o, N+ ?9 _" `! d
2 |, T5 }5 a7 g/ s3 P$ W9 I printk(KERN_INFO "LED unregister!\n");; O+ W0 {6 q7 k6 o! r+ r
}4 ]6 A6 t) O! G$ \" ?+ R
- m. P% m$ S0 w, c, Dmodule_init(led_platform_init);
6 A* V. k0 |; A* q" B& cmodule_exit(led_platform_exit);7 }2 i: c% c' s; R0 t; u
8 H0 P9 R* T4 ~7 j1 s6 @MODULE_DESCRIPTION("Led platform driver");
4 l9 }5 g4 {3 e8 LMODULE_AUTHOR("Tronlong");, V" S: c6 {4 D5 E; S) _9 _: Y. O8 |
MODULE_LICENSE("GPL");
5 ?0 r4 H% ]% ~) B6 [; ~6 [! P* A6 _$ j$ {0 w
|
|