|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: [; v9 \: h; s X( c7 C#include <linux/init.h>' k! v% M9 A$ y0 l8 g
#include <linux/module.h>
$ B R' c' j# y% k7 k#include <linux/kernel.h>4 p% Z$ \1 H- C; h
#include <linux/types.h>
: Z/ g+ S6 c& |4 W- [' I/ G% v/ \#include <linux/gpio.h>0 a! {% e d- p5 l5 B2 { }9 K
#include <linux/leds.h>& J0 {5 d5 s9 i
#include <linux/platform_device.h>
8 o- c7 C: R4 m- w$ |. ?+ n. b3 E; K, ~% j% `
#include <asm/mach-types.h>! t; Q' f9 e# B) s. X
#include <asm/mach/arch.h>: F6 o) ~5 c" }8 I, K* y
#include <mach/da8xx.h>
' g1 Y7 H: E% A3 Y#include <mach/mux.h>9 ^# t s: F/ m8 {
8 \* }# C$ e u0 M1 Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, n; K& N" i: \. P/ o4 ]# o# m#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" m1 S+ n! Y+ N; x
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 j: H0 ?1 Y v) P
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ t$ N& @& q( x$ ?! j- l- _
7 S( ?/ R; U" K! w- B s/ ?( B/* assign the tl som board LED-GPIOs*/
0 Y% W4 P% y. @7 d' s" L/ Pstatic const short da850_evm_tl_user_led_pins[] = {
& H# q9 B4 S6 M% ~: o8 U# a /* These pins are definition at <mach/mux.h> file */
% S6 ?& \5 G" |, q# Y3 T, y DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* |- a3 w+ `2 F/ ^
-1
2 G3 R. A3 d8 D. p8 W) t};+ Q) O. q4 \2 ~* U% g
) l1 Z1 K6 O4 X4 Z( \static struct gpio_led da850_evm_tl_leds[] = {
) A ?. o( A7 z7 b {
; a1 l% z* V' k .active_low = 0,5 `) B2 K Q2 }5 r
.gpio = DA850_USER_LED0,
3 F l r2 q' ? g! ]5 M: D .name = "user_led0",: l+ V6 V/ j0 b; f/ U
.default_trigger = "default-on",. g! b) c+ w$ s& T4 `! ~# t
},! Q' V* l1 z6 g; N' i
{
) p4 B# e E& t9 L% r# p$ Y .active_low = 0, Q. D8 C1 O( K# x: K4 [
.gpio = DA850_USER_LED1,
$ {" l- r- v9 E4 {/ p( p1 W! ^# h* } .name = "user_led1",6 B J% B5 {0 t5 s0 V& b% {
.default_trigger = "default-on",, K$ f g+ S! O; @' G$ k% ^
},
3 R. J$ S; @1 I {
6 `4 f+ m9 Q4 ~7 K# m7 ^* h; l .active_low = 0,
6 H+ L3 {, e p3 w; w .gpio = DA850_USER_LED2,
% G1 l6 i8 r7 q3 s0 i .name = "user_led2",7 r5 i/ Q) Q" |* a+ n) ^. A3 v4 Q; o
.default_trigger = "default-on",
8 A6 |* H! [! n1 J" @+ B9 e },
5 q7 _; w, J. l" ?- r, m' J# D2 n {" l* n+ ]# M1 E+ U* B+ ^! h
.active_low = 0,- ~) \! e9 M- b* A% x8 `
.gpio = DA850_USER_LED3,
& L2 n# n: }! J+ ~ .name = "user_led3",
6 k# M0 p) d) D, g0 t( b9 |" r .default_trigger = "default-on",/ j0 h$ ~3 X/ X" V% J" \+ Z
},
8 \- P" f* w1 O# T# _/ D* {};0 \4 y/ F9 f' [% n" N# z
$ f5 R( m4 W+ |static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 G, n3 B# w6 p" r3 v. I9 ? .leds = da850_evm_tl_leds,
+ [% J$ k$ n/ v7 d' ]# Z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# T9 {8 |+ M% x S4 F
};
8 F* \+ F D# \' t" _4 z3 X, K' K/ [: a
static void led_dev_release(struct device *dev)
, N( E) j' [; G8 r) ?! \; ~7 u{
- `, B. C! }. t1 F};+ x3 a, _( p+ f( _" l
+ u* M3 [* n4 ~- W2 a% Hstatic struct platform_device da850_evm_tl_leds_device = {
; }2 u2 n* C) r2 ? .name = "leds-gpio",
7 h& O( D% S5 Z9 @) X .id = 1,
4 U) J1 {) K8 O C% z .dev = {* V# _! v0 k; t9 @6 F
.platform_data = &da850_evm_tl_leds_pdata,
- I2 M6 ~* z9 e/ I! J .release = led_dev_release,7 m4 w6 ~" J* p$ _' N& e, U4 v
}& U4 _* s5 T& n$ T
};0 t( k9 v0 k3 { w/ |0 i
( _. X1 D2 r1 Istatic int __init led_platform_init(void)
1 P, v* `; ~" J1 k4 [; d{6 Z+ J& c; K) B* k
int ret;& o+ ]8 ^' }- v+ T( c, w/ r; G1 ^
#if 0
6 {: D* _+ ?8 o- g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 Z0 y! V8 L7 ~ U! ~2 N
if (ret)
; x N" F2 C; o; A' \ pr_warning("da850_evm_tl_leds_init : User LED mux failed :", `' ]4 d5 K" ?# H' h9 K* y8 Y. o
"%d\n", ret);
; H3 `" D; G1 t2 z' g& w: C0 q#endif
' k( {+ A+ r# v ret = platform_device_register(&da850_evm_tl_leds_device);9 }) U0 F2 [6 K9 a. F! G
if (ret)/ S1 t; n9 H$ Q- R) A
pr_warning("Could not register som GPIO expander LEDS");. L6 H L) p W' F4 w! `% U6 j& [
else
) _0 m u# h5 o7 } printk(KERN_INFO "LED register sucessful!\n");
2 u; s2 L, H: j" d) v5 K Y9 }+ c7 j
5 b S7 f! ?! f7 F" G! H# M return ret;
6 o3 g9 Z9 t: h- M}
9 E9 L) k9 d% e4 ^
* w5 X9 @+ x' p9 Ostatic void __exit led_platform_exit(void)
3 J5 S" x8 h- ?, R' R0 Q% L% Y{
# N- t7 H) q3 k; C7 v2 H platform_device_unregister(&da850_evm_tl_leds_device);. ~6 q- `. e& L: [3 V: K
2 O! s& h& i p! D3 N
printk(KERN_INFO "LED unregister!\n");
8 O7 Z; W& S# q: S0 x0 l; j2 _2 L. @}" R3 z" S; n, n
8 i# V+ t7 |- v6 _0 Cmodule_init(led_platform_init);
! j1 ^8 U# _) v Xmodule_exit(led_platform_exit);9 B+ J! q: _( M5 V
$ `4 Q/ s. C4 {$ OMODULE_DESCRIPTION("Led platform driver");' N5 V6 Z4 Z3 p- V' e! x
MODULE_AUTHOR("Tronlong");
( u2 N7 y% Q4 KMODULE_LICENSE("GPL");) Z2 ~; U3 t2 A7 B$ O; H& M
! `1 y! r& F1 Y6 U' Y0 {" g, P
|
|