|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 e4 L2 ]+ v% z: _+ \# }* C
#include <linux/init.h>* D& r' _+ @5 j# V2 ^9 B8 ~: c- g) @
#include <linux/module.h>$ K" D; s. r6 [& @1 T
#include <linux/kernel.h>+ U; h1 V; e6 z) ?) f' |
#include <linux/types.h>$ H1 U T, {+ w) J5 j2 O& h
#include <linux/gpio.h>% c% {0 d6 W: I5 v: V" x; X- \
#include <linux/leds.h>* I7 ?7 B" l2 l/ J/ H
#include <linux/platform_device.h>! Y4 l& }) D% B- ^5 ]8 i4 d, e/ g
( Q( F" |0 s0 D) M1 Z#include <asm/mach-types.h>
7 ^* D! }2 I! N+ \2 B, ~9 q* ]#include <asm/mach/arch.h>
* c2 M( I) O+ x8 w1 R#include <mach/da8xx.h>! b* {9 l& J+ p2 ~: z, l
#include <mach/mux.h>7 n7 E2 e/ b2 y% G2 V, p
6 B- D1 N. }, ]0 O; A7 V#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& C$ W0 v# u- u" g" t* G; U' v
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 V$ X' I* L. w1 Q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 r8 ]" o3 N! E% ]: @9 @#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, R# O! w1 t: T6 t. s6 ~
5 k1 w3 p" {3 u- L8 ^/* assign the tl som board LED-GPIOs*/* a( x4 j- p; y
static const short da850_evm_tl_user_led_pins[] = {4 j9 r. r( _9 o* w. ]6 T6 g
/* These pins are definition at <mach/mux.h> file */7 r. K% Z" r0 v( i4 |: J a2 q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# ~; F8 Z& T6 G5 X, b2 Z# `5 C
-1
a: A0 n4 p7 ?. \% P6 n, l/ a};
+ f5 o2 j+ }9 q
* ~- {6 S% G+ Y, X, m( G. {3 V! x$ rstatic struct gpio_led da850_evm_tl_leds[] = {9 F' G. t9 Z3 T
{
. v9 C1 n( s1 X- [ .active_low = 0,
, ^5 D" u; }. d2 ]4 [7 R .gpio = DA850_USER_LED0,/ C0 `" B: |- e! B3 o
.name = "user_led0",
& h+ q ]( F w9 {. {" p- I .default_trigger = "default-on",
. _/ v8 O7 a+ V) Z },
" ^9 r( L5 g, S6 F% V# G {
) B) F8 j2 S. t3 a .active_low = 0,$ g. A& |/ Y2 J* D4 y
.gpio = DA850_USER_LED1,
J8 ]+ l0 B$ Z2 {* _ .name = "user_led1",5 }* Q8 T, h5 D/ }
.default_trigger = "default-on",
7 C2 s6 E8 }0 N( i9 v6 m, D },: K( f% E7 O' G& }$ l! w2 B3 S( B
{
4 F7 @% S0 E b$ y; j( U! j .active_low = 0,
4 q! _9 h: l" Y .gpio = DA850_USER_LED2,
) {' X% M8 ~: J, j, b .name = "user_led2",. R% p+ j M8 p7 F/ ?* z
.default_trigger = "default-on",
( i) V2 r$ \7 I, G, i }, I6 Y1 t8 w# a8 g' l
{
9 x* R, L/ r' a, e" B0 \& f .active_low = 0,
: k- e7 h7 i( h6 K6 x .gpio = DA850_USER_LED3, L4 S) R- k+ e. o: B3 L' S5 L, o
.name = "user_led3",
8 ]4 g4 x S& H! g- t .default_trigger = "default-on",' Z+ {6 Q% a5 q. x
},
% m, P: Z0 F/ \4 n};
( f" H% d, D; [$ D7 q* U" v6 t$ j: f4 ~' Y; S! `* {
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
E7 A: M1 D3 r6 t, B .leds = da850_evm_tl_leds,
9 i8 ]- r" \2 w& Q4 @ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: `3 ~$ D8 Y: t9 j$ }; r
};; |: }$ _' m! G8 H o7 X3 @( V
! Y9 O: v5 r( N% M/ t
static void led_dev_release(struct device *dev)
/ a ~' p8 T; q& E{
& v, c' d. e( G4 @- O};% M( s, J- ~. k6 o- y* d2 L
, z% }! I( r' j4 Ostatic struct platform_device da850_evm_tl_leds_device = {# W6 ?6 r( I8 {# q' X3 G U
.name = "leds-gpio",- Z2 g- s9 l. o! H
.id = 1,3 H5 a& x1 o4 N
.dev = {
& R. e& R9 d7 U# X0 i. [# J .platform_data = &da850_evm_tl_leds_pdata,- Z2 W$ G/ R; p2 P
.release = led_dev_release,- L6 c$ W/ x% u0 Y
}, K5 f( |9 P; _ `5 @! _5 j
};' p, d% M( V6 Z
" X* M4 p9 p0 S8 u$ q4 A! c
static int __init led_platform_init(void)1 \6 L! _6 f* X( ^5 ]7 {
{8 ^1 `7 v- M1 z: D6 M: o4 K
int ret;
: ~; k- X0 ?9 M#if 0
4 d: q2 G4 M! L% {& _ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 ]" x5 j2 z9 @, i6 ~' w if (ret)8 d' j6 h9 s+ _
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' j7 B# p9 O [2 u6 J) i
"%d\n", ret);! _$ p$ @$ u- ]: R) [
#endif S% y4 J; S0 G, ^. b- A5 ~
ret = platform_device_register(&da850_evm_tl_leds_device);
9 @; y( j) S$ U8 h: l/ s if (ret)
5 Z# f% \4 H8 y$ h g: D pr_warning("Could not register som GPIO expander LEDS");' I7 B2 b( @8 x! r% w
else
8 h) e/ {4 ^+ t, k- b9 p \ printk(KERN_INFO "LED register sucessful!\n");1 b* ?: k8 a) j0 E1 x* c7 e( o
5 h1 r- X& _5 L1 { return ret;
4 }4 H5 \* c6 ] U4 P/ z* R}
) X7 B" s7 Y5 \% t. _. [; D6 L3 q p
static void __exit led_platform_exit(void)% h/ q! \9 x5 r; _% Q
{) h, t7 a8 @1 \/ T9 E
platform_device_unregister(&da850_evm_tl_leds_device);
/ R+ \ W% z, ^
1 `' x7 x: \' a printk(KERN_INFO "LED unregister!\n");3 Q6 x& c( K+ r) e
}1 j% r4 i$ X" ^: D" N9 A* i, f4 z
+ [9 W6 R/ k% _( T! z' }( ? v
module_init(led_platform_init);
4 V7 \ \1 l7 e" \9 W1 cmodule_exit(led_platform_exit);/ n b! s2 D1 y5 z! I
& Z& c, V# P ^6 O# k+ n
MODULE_DESCRIPTION("Led platform driver");7 n9 U2 Q" u. {. H; u0 c6 S6 @; {
MODULE_AUTHOR("Tronlong");
7 h- F( m* T2 R& C- bMODULE_LICENSE("GPL");
' C5 Z h+ d$ b7 b& F& C; _7 H. i8 @
. M$ ], c) T( p& ^% ? |
|