|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 R) q u$ r: u. z0 \#include <linux/init.h>! m: a8 _0 b$ @
#include <linux/module.h>& y7 r+ b0 L) Z" \7 x6 x
#include <linux/kernel.h>6 P3 s+ {- _& Q
#include <linux/types.h>
2 s* y3 y7 u. x; Q, n( z6 Y#include <linux/gpio.h>3 a( E6 Q; c K U! D! r
#include <linux/leds.h>2 d$ [" s- ^8 R) O% V j
#include <linux/platform_device.h>
x0 U& t L: K; u" m& e
! v5 Z$ K2 K0 u#include <asm/mach-types.h>, s. r, D+ O o* I
#include <asm/mach/arch.h>- U" r* w7 S9 Z4 v; q
#include <mach/da8xx.h>
0 f& `8 r. l1 P% K#include <mach/mux.h>" x3 F: K. Y! C; `2 ^9 W3 b
4 p1 e# x$ S6 Y S2 T; {9 m* l0 g& \
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 l: q; W/ o* ^+ m# {& _) h; Q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" g0 H$ P) g( l9 f& v5 Q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 Q; f; ?6 k: K e6 A( S
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' j; q; b3 F4 W* t3 O) ~( N0 |6 T- w: ?
/* assign the tl som board LED-GPIOs*/$ _3 F' E0 @: y
static const short da850_evm_tl_user_led_pins[] = {# N8 ?- D' b8 `
/* These pins are definition at <mach/mux.h> file */# b A9 W; b# t8 N
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& R% _4 L" L0 U$ [+ A -1; J+ N0 C7 _2 x
};3 D3 N$ Y% g z/ Y9 ?' h
! E6 t* _9 j" u( z7 Mstatic struct gpio_led da850_evm_tl_leds[] = {8 l0 w0 z# l2 L8 Y: s" m
{
9 r V& b" v- T2 G0 I .active_low = 0,
+ d3 X) y. K8 H/ n% e" g .gpio = DA850_USER_LED0,+ b7 x2 n! D$ m4 Z' k" r) R: N
.name = "user_led0",
: e' t( z" C; T, m$ x* H .default_trigger = "default-on",& f# ~2 I0 ^$ G9 V
},
, [( A4 F- j8 z/ l9 a. P {* s+ r& I7 [/ p- X
.active_low = 0, Q8 a; ~$ I2 I/ y" t
.gpio = DA850_USER_LED1,
$ P' t/ w3 }& j" J. _) p+ x .name = "user_led1",
* I# u! E& L% [% E9 a5 T .default_trigger = "default-on",0 q& m0 v) r/ a& u# v, k
},( ^7 M- N% U8 h& O: g
{
% \; T: G/ E' B! |2 z .active_low = 0,
( x) Z; H3 `5 k$ q7 x( R) p .gpio = DA850_USER_LED2,
5 k1 i: O3 v4 C* L .name = "user_led2",+ b/ a0 L# O; S
.default_trigger = "default-on",/ i* y: G7 A. G6 `$ J0 h
},, c; I \4 t- i5 g
{
8 s, j& z- S' y& r .active_low = 0,3 K* g' [2 A+ \. l M) |7 K# D$ O& S
.gpio = DA850_USER_LED3,
- R' F2 d' s) _. ?' U .name = "user_led3"," f+ `$ s3 X: v( p4 ]+ ^
.default_trigger = "default-on",2 H" |7 p; y( S- `* f, d
},3 y7 U8 Q$ X# B1 W! c; h; I- ~
};
M. E8 Y! ?" P& _7 r
( _, V& P& X" H/ j2 `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' s1 J! x- C! z/ D8 T O- J .leds = da850_evm_tl_leds,2 Q! F4 E2 X5 B! G+ ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ a, D6 B! j/ I/ z7 M5 W2 m+ M};
# Z! c! C9 p/ |7 C3 k+ y, }& V0 C- @! W# {3 x$ }( @. E
static void led_dev_release(struct device *dev)
, y. K6 T$ b$ _! o{( g" J' U, o5 e1 N* g1 Z! b% G
};8 h e& A+ I9 F$ R0 R' W
, f/ H, [" h# u9 H+ c# ystatic struct platform_device da850_evm_tl_leds_device = {
0 O) b+ J3 O& E, l .name = "leds-gpio",
; M7 E8 C: v* E7 f" y- X; I t5 X* k .id = 1,
7 E4 [, E: k! f; B2 J( I .dev = {, j4 j2 I4 B) Z# l
.platform_data = &da850_evm_tl_leds_pdata,
; c1 ?$ \0 E: `. K- m# p& q .release = led_dev_release," z3 A" z8 _' `0 W: k" a
}
& ?: ^, q* t* _' N5 Y6 f};
2 e# w: z0 o4 I' z, Z* G
) m1 }( H( _: h, cstatic int __init led_platform_init(void); B1 N$ a- ^# h* V( M$ a. L
{$ t' ~6 \0 g/ t# W. f% O( c+ z
int ret;- S( K( U' w! [; ~9 G+ v
#if 0
: j ?6 a+ p8 }: F5 } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ d! l, a. k/ ?$ W1 O
if (ret)
' O8 Y/ A S2 t9 r/ T pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ \0 Y1 l6 K* s0 h6 l
"%d\n", ret);3 R; R- d6 G, `% O) \6 P( e
#endif( E1 j9 o. t4 w
ret = platform_device_register(&da850_evm_tl_leds_device);
; m' A8 W* a) `7 j if (ret)% N* E, P' `/ c: \& d
pr_warning("Could not register som GPIO expander LEDS");( f2 E: h! W* f4 [
else
( D, e1 f5 _( m; k* @7 A% U printk(KERN_INFO "LED register sucessful!\n");( x# c( \! F. K: p
8 a* ?( V4 Q9 o$ ~( P- I; ]' @ return ret;
6 X" o$ m1 \9 m0 F% n}
; S4 P! |- z" Y
! b0 e) c. O% {% d! Ystatic void __exit led_platform_exit(void)
0 d; v S( x6 _4 T2 H{& X2 ~6 m0 R- W3 f
platform_device_unregister(&da850_evm_tl_leds_device);
; D2 T) S& b1 t8 b4 t8 Y$ c. O
0 ?% C8 U' c; E printk(KERN_INFO "LED unregister!\n");" K9 \! `4 |, o, p3 T! d! h) v3 `
}
1 s, Z! g/ w% t5 w6 u' s4 N! a
$ [* q5 T! X d& t. O# n- A* Smodule_init(led_platform_init);
, r9 M; n# P% k4 ^3 _" a9 Omodule_exit(led_platform_exit);
% E( K+ `2 ^. w: v$ A! a- X7 D3 T7 G& L" J" o6 @9 I% [; |- g
MODULE_DESCRIPTION("Led platform driver");6 |4 X8 h- {, j1 m* C$ M
MODULE_AUTHOR("Tronlong");* E% U' {- |2 X
MODULE_LICENSE("GPL");6 H6 \3 e1 g3 s; Z
* b; G2 p+ u1 A1 m F0 W |
|