|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 o+ J- U c0 k- I( q$ J$ `3 O#include <linux/init.h>$ ^4 K Y; Z9 p+ p# i
#include <linux/module.h>
% j9 ?4 @6 k" |' S#include <linux/kernel.h>8 N0 H; ]4 o8 [# X) k& j
#include <linux/types.h>3 a& \, x6 b9 _: m( b
#include <linux/gpio.h>2 j3 [" a2 ~, W6 }& ~
#include <linux/leds.h>
k5 [+ m) e1 g% J1 y; T; ^#include <linux/platform_device.h>& E/ u: o& @ ^3 \2 w8 f: t A4 C# H
8 j) _& Z) g6 o' v7 T9 r/ v6 \4 H- J! u" P#include <asm/mach-types.h>
/ I- d) v! I1 x8 X#include <asm/mach/arch.h>0 W/ ]1 c- p6 G2 t$ ~0 w
#include <mach/da8xx.h>) M8 P. p% S5 X
#include <mach/mux.h>
0 a d" P+ B6 c
" j; p) e; Z$ `3 B#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 o/ J; K# ~5 ^
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( Q; s" m0 }/ i& Y: S' i, |#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 Q2 R0 \! v k4 o$ {! W
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) ~% p& D# i& A* h$ H4 J
1 i# `7 {! {& b- b; g/ s/* assign the tl som board LED-GPIOs*/. A) C- g: ^: k/ F* l/ d
static const short da850_evm_tl_user_led_pins[] = {
* u/ a% G, e: g. C' V) Q5 k0 G /* These pins are definition at <mach/mux.h> file */) P6 o' p8 p# x, F& y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 D8 N9 ?$ h2 n2 q! m -1
/ |6 q6 \3 r( r. K2 o};6 E* J5 W6 ~! M+ [4 ~2 B
m0 Q+ I7 ]9 G2 v, k9 k: N, Qstatic struct gpio_led da850_evm_tl_leds[] = {
5 g- j1 H/ n- N) \3 y {
$ A4 Y# i7 z: f .active_low = 0,
7 c8 c5 n: r" N0 n/ e5 u/ F5 I .gpio = DA850_USER_LED0,
1 F- H4 `5 ]. R% r# i' A5 E .name = "user_led0",
; {& T: q0 N0 B2 s ~( k .default_trigger = "default-on",
9 A @" q4 F! X0 K, R8 C, K; C },1 Y0 I3 e* G# ]* w( ?) ^
{! t" k, k" D1 b5 p: r( [& f6 B7 j
.active_low = 0,7 C) ?# Q, T6 b" a7 f
.gpio = DA850_USER_LED1,
; w9 S1 O* x) \! u1 e( V% [) V! R .name = "user_led1",, Q0 k- U' Y. a8 J
.default_trigger = "default-on",
/ W/ |* d! r2 C' E },
; Q3 L: I( k m+ k {
4 N# z. [- x. g( q0 m# a4 G .active_low = 0,
3 \$ i7 Y) z$ d0 @& I .gpio = DA850_USER_LED2,0 B$ |$ j- G2 Z4 Y! ~- |
.name = "user_led2",2 a T$ J. z1 [6 \; K7 ^* j) z
.default_trigger = "default-on",6 W: q+ ~, C* M4 D9 M
},% B6 g) c: U* ]0 p- H7 B
{5 T) u3 t* X2 @) D% Z- D
.active_low = 0,. H- J6 e" V+ U" ?2 N) w
.gpio = DA850_USER_LED3,1 ^* n; C9 ?/ [1 F& t* {5 E6 R1 Q
.name = "user_led3",( [' J' Z. n5 T$ l0 }1 C3 n, c6 Q
.default_trigger = "default-on",
$ Z' y, U8 l1 p* }9 C& a },( v0 V9 B5 V# c% u
};
% ]6 H ^) w# l0 }' O
9 C4 s" `- n1 z( {+ Ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& L! \: ]6 d2 v0 o' K _/ | .leds = da850_evm_tl_leds,
4 Z5 T/ G- |! {0 q* |) L .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 x1 }. n. P8 w0 _( }4 D};% ^# c, I d; U
* @; ` p0 P0 S- w9 _7 a, J- p0 rstatic void led_dev_release(struct device *dev)
4 e. n; n- f5 G" D# E6 V{
/ x7 @+ w; e* ^3 Z. q};9 g' {) M$ x/ b2 Y+ T
: Z- L n: ?+ `+ i0 S' g# X. t- f6 D# r5 vstatic struct platform_device da850_evm_tl_leds_device = {3 k4 q5 D- e: K4 v( f- U. l
.name = "leds-gpio",
( c& { d- g/ x' T .id = 1,, ^: ^ A) {8 f& g
.dev = {/ J$ l, w( n- }. D- Z
.platform_data = &da850_evm_tl_leds_pdata,+ X8 ^8 V4 f1 w: b# P
.release = led_dev_release,% M1 _4 P' _6 v6 e
}
6 U; q) D" ~% b};
B8 Y, ~1 ^1 G3 R8 K% h
% e% v# P% ]+ q- H) K+ A1 {# xstatic int __init led_platform_init(void)1 N: k0 M# _' i$ _# Q& X* Y5 J
{
* Y* b7 q$ U4 V: L0 c) e7 A int ret;8 D1 A; r, r% z) W6 y
#if 0
: h+ I1 A; B' d( f/ V, C' K/ [ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: U. J$ C+ A/ c6 N6 b
if (ret)
4 k' z$ u0 o- \# a; [6 \2 F pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 Y$ F+ @5 ~: ^3 O
"%d\n", ret);
# S7 ?' y. u/ z b' {% q#endif
, s) k0 Z2 P0 P! d ret = platform_device_register(&da850_evm_tl_leds_device); ]7 }0 m% k% S( _0 c
if (ret)
0 {% M K5 l3 o( n7 S% U pr_warning("Could not register som GPIO expander LEDS");
5 a% u; Y) [4 p" X. \/ i else
1 K# p9 D, }" g) F printk(KERN_INFO "LED register sucessful!\n");
- a) n& O) O2 V1 f
9 n. S1 [. R' h0 r& d2 S return ret;% E2 v* b( x" ~
}
) c" x) S5 `- Y8 J9 U/ c5 { N4 Y6 x" i
static void __exit led_platform_exit(void)
* p. d4 t( d0 I/ J{
9 A, Y$ ?, c) \; l2 \! M platform_device_unregister(&da850_evm_tl_leds_device);
3 l% E7 q% @) t& U) P: W4 N- S8 x( y, O
- ?- p8 b$ K/ [2 t! M |2 N printk(KERN_INFO "LED unregister!\n");5 ~$ F0 V6 p* N9 P; _* K
}
8 A$ Z9 b- P1 j: i
6 a# g/ s) J4 b: Q) b) R9 Zmodule_init(led_platform_init);0 X% M5 u9 [+ o# ~3 F; W0 C( g) C3 w
module_exit(led_platform_exit);
6 m" T2 Z6 X5 U# b* y1 P8 `7 @- u% ^2 d, n" w7 f+ }
MODULE_DESCRIPTION("Led platform driver");
$ R& o0 w7 r& Y3 U" U' W$ A0 G9 oMODULE_AUTHOR("Tronlong");$ a* m$ k6 B( R. f8 f
MODULE_LICENSE("GPL");1 _- @- e2 Q4 ~) G0 m, G9 @
* Y7 T0 ~( _7 }8 }, U |
|