|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* ^- j' e- v# L' [& S9 @" y- z
#include <linux/init.h>
9 i, j* b' s# T$ C/ \) {3 h$ t/ E#include <linux/module.h>
5 R+ R9 ?2 S- ~( \- T#include <linux/kernel.h>
! r$ c+ y7 j6 x* [1 Y#include <linux/types.h>
. G$ g- M2 u4 }#include <linux/gpio.h>
6 T% ?, e9 l$ g/ Q- z/ y6 I#include <linux/leds.h>' K0 p+ w$ p6 }. K. x% Y
#include <linux/platform_device.h>1 R$ L+ Z* s: W" X
9 w; h3 u/ S4 ]6 j1 f9 K) U# n
#include <asm/mach-types.h>
" h' V% p# h3 f4 j/ R9 w+ D) Y#include <asm/mach/arch.h>
1 x; ~9 a$ j) U" z- c#include <mach/da8xx.h>
7 ^( [# I+ V" |$ w' Q0 J#include <mach/mux.h>! R6 R5 D% k: X) D/ Y
1 r& L) v8 `! F6 Q0 N( v K#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: b# Z4 K! J: T. u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 [: b& Y- V2 ~$ o) S8 X#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 z* P! N7 ^* ^; r; R#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 p/ i" S0 s3 m8 ~
* u, {! F& K4 \7 _/* assign the tl som board LED-GPIOs*/
0 U# ~9 ~ k3 q" u3 x8 L! Astatic const short da850_evm_tl_user_led_pins[] = {, {' ~" w0 r4 i, W
/* These pins are definition at <mach/mux.h> file */
! m5 ?4 z$ |4 ]5 Y& n4 L2 S" S4 ] DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 ?! R a# A& V# s4 m1 K9 V -17 I! K# \. I- ?3 S( `
};* Q" D0 i) Q: f g# K$ f; \
+ \0 P! \- n3 \+ [+ K
static struct gpio_led da850_evm_tl_leds[] = {$ H2 O. G7 [1 ?. @5 W" Z; _2 N* B
{
+ g% i9 n; _: v. T# Z .active_low = 0,+ l- v$ ]2 ]8 O" h- R) D
.gpio = DA850_USER_LED0,
4 v* X4 ^9 k$ l; p .name = "user_led0",
1 }5 G2 u+ u7 n; `4 \0 _5 A" a .default_trigger = "default-on",
: f9 e4 A4 v3 g# ^ },
( q* w' I. U* p1 b) B {# n g& ^& a4 c7 Y
.active_low = 0,
- z( f4 [% I$ h1 u/ g+ q# i .gpio = DA850_USER_LED1,
) a4 ~' r6 N5 A3 D# f8 H .name = "user_led1",* \' _" L, j D: I& |
.default_trigger = "default-on",$ O' M. M/ N, P
},
6 k6 E: `+ g3 `4 B h+ k0 t {
4 {. r! h1 a1 Y+ C .active_low = 0,2 Z7 I: F: M9 B8 a$ |/ E
.gpio = DA850_USER_LED2,
6 {! e0 E7 e$ l: N .name = "user_led2", [5 r }) J; o: O
.default_trigger = "default-on",
3 ]# B8 h0 v8 I; S% O },
. p% x3 M; W8 m1 j6 Z6 n' { {, \6 }. i0 O+ q/ Z/ F
.active_low = 0,+ u3 O( a5 ~ X# N+ t% i& O
.gpio = DA850_USER_LED3,
) B) ?, F5 [- }6 U .name = "user_led3",
1 _& Z$ u% m w$ r& d: K5 d! L .default_trigger = "default-on",/ v8 c+ H- o! Q8 S* t% p6 h
},! [: o$ q+ H" b' z4 j# n
};
' E; I' X8 c# S# e
5 R/ I0 }8 x/ k- h2 Fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ o* D' c* F' ~" C7 [
.leds = da850_evm_tl_leds,% Q- ^% g, J" @; ~) v
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),% q3 b5 u+ h$ |# |' [# }
}; F+ n7 L8 U/ A; u: y
6 S0 f7 ^" G/ R' J( b9 ~static void led_dev_release(struct device *dev)
$ e, U; H" k$ [: O5 p, R! d, }{
" S! f# ]' |$ \1 f};
7 o: x+ |/ Q. D& r
* y, R( H, {; j1 w4 Hstatic struct platform_device da850_evm_tl_leds_device = {
5 ^7 M) A6 l% n' k3 B6 ? i# a .name = "leds-gpio",8 c) A, r; Y7 H8 k7 J' b7 c$ ?, O
.id = 1,
5 {# h9 j" E+ n6 J0 t3 x .dev = {& g! |7 n P) y& e
.platform_data = &da850_evm_tl_leds_pdata," f3 o. L% {: X. f4 P7 s( I
.release = led_dev_release, i4 f. q# M3 x+ g- n, y
}
1 a3 o$ {( k5 |4 w2 \};
. k. h( E, ^" s Q t. g2 H0 w9 Y
static int __init led_platform_init(void)
! k* `- l6 ~* a. ?: `7 _{6 C9 K+ F8 W' L0 z- I
int ret;: Q: e V! T, c! j
#if 0
: v% L* t4 e- c j6 d$ b8 a ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 m, b8 w! l5 p4 x* Y
if (ret)
& h0 h; O2 [) h$ @; ]$ j& n) E z) k pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 v( A0 t3 q5 @% J( `6 s
"%d\n", ret);
6 A) b2 B# ], ^$ c2 t#endif- a+ J+ c3 q2 M( ]# t9 H
ret = platform_device_register(&da850_evm_tl_leds_device);/ q* O- c! X y `
if (ret)% o/ B0 @. P" Z0 j- w; Z6 L
pr_warning("Could not register som GPIO expander LEDS");
" ?8 Q4 d: [+ O% ^" a; L else
, a) E& |0 t% c3 u printk(KERN_INFO "LED register sucessful!\n");
9 I- N, p, M$ V7 Q) A& {' X' _! @( C Z# d. P
return ret; l7 R& W% j( K/ i' r
}
6 b$ P. C5 P5 H$ j4 y. |$ {( g$ }: v9 ^ {1 H6 ~7 `. }
static void __exit led_platform_exit(void)4 h8 ?, H' R* T# n0 |' s" Y
{& D; k+ P. x: q s) M; [$ a
platform_device_unregister(&da850_evm_tl_leds_device);
6 K) }' Z9 l3 b; \9 V. a; O: s! H* i+ a8 n5 G# u9 s5 [
printk(KERN_INFO "LED unregister!\n");5 J$ R& a" N2 Z$ w4 e) r. s$ x
}
1 z- P* P/ N. A7 P, B3 Z! C! y% L: X7 D8 z
module_init(led_platform_init);; b0 L% r+ U- S* z
module_exit(led_platform_exit);
: j4 [2 m! Z9 M
( T& ~0 u1 D( T3 I+ BMODULE_DESCRIPTION("Led platform driver");0 x7 l e& w* a5 d. {8 E6 l
MODULE_AUTHOR("Tronlong");+ {) V" U: c+ }* D
MODULE_LICENSE("GPL");
e& n8 h' L) h7 l5 z# H1 z2 P h, ^) j% T) G
|
|