|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' d4 ?8 A; P' n8 {6 d
#include <linux/init.h>4 V9 v7 J% `$ Q Y
#include <linux/module.h>) w1 p& R8 P Y5 \5 L
#include <linux/kernel.h>
2 x" K" ^0 q# L% v- {4 {#include <linux/types.h>
" M! J5 R. a. g5 e) q#include <linux/gpio.h>
. O( B7 N0 o1 v3 q, y#include <linux/leds.h>
; b/ G# F. v" z' o& F; X, N5 s#include <linux/platform_device.h>
7 k8 M- E* t( D; L4 ~/ F/ g) q7 D, L" s5 x+ O
#include <asm/mach-types.h>/ h& B) \9 }$ |; i7 C* n
#include <asm/mach/arch.h>) W8 P! d3 ?9 h: |( W
#include <mach/da8xx.h>) G- |1 k2 N/ B+ G& Y7 L
#include <mach/mux.h>7 Y# \3 w, E0 K% z0 J! L
; O9 I; j" @7 x S) Z$ Y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). D, t9 B9 v8 x" ` N% F$ t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( j. A, k9 A" y5 q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# e% \, {: k0 C" K#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& M2 ~( d' W* e5 K$ J: |9 W
8 F' u, p t9 a
/* assign the tl som board LED-GPIOs*/6 [0 L& f% X* x8 A$ y
static const short da850_evm_tl_user_led_pins[] = {, e/ B6 q" _* \* c V8 q* [+ Q) C
/* These pins are definition at <mach/mux.h> file */
}7 _# r) o! q+ a DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& r0 x+ l0 D3 [ -1
' \1 Y7 J. c0 M" d8 m5 n};
8 z' o" s3 v, ^ r t! k' P1 ^8 m% Z! v4 _6 |- Q
static struct gpio_led da850_evm_tl_leds[] = {# J3 u: `; A& X; A, M
{. J: r' O6 d, v k
.active_low = 0,' C3 r2 J; b0 J; z7 X
.gpio = DA850_USER_LED0,
$ I+ F: ~5 p( b6 D: R$ U .name = "user_led0",
# g2 x3 D, f2 y9 X .default_trigger = "default-on",) h2 l0 Z- F7 g; s8 j7 B8 B: T
},
6 o$ [+ k r. y3 d {
3 x- X K: q. B: u }; w .active_low = 0,
2 j( E4 o! c7 f6 _6 k' ^1 g# o% Z7 } .gpio = DA850_USER_LED1,3 `# L+ e1 D# t# d. X6 L' \
.name = "user_led1",
/ a, S U. A. X3 g: j .default_trigger = "default-on",8 y2 ^6 S2 h+ r% f
},
8 |, ^& }+ G1 b$ [$ M, U7 H) |3 N {. G8 a6 K) P/ c2 t K8 v
.active_low = 0, Z+ F. v& k: X
.gpio = DA850_USER_LED2,- a, V( R, p/ A6 Q
.name = "user_led2",; b1 x* K& a' |2 |) Q% e( q
.default_trigger = "default-on",
1 K7 }% S( t5 B0 M( @2 R },5 Y3 B3 V {2 x$ }. g. g
{
; l6 U- f; l1 c; |7 ~9 q( X0 J .active_low = 0,
* G) _% Z0 r$ j* V- P2 N) e, _2 x .gpio = DA850_USER_LED3,# j8 ]2 |7 Q) i; T& [0 q5 `2 y$ h( D- J
.name = "user_led3",
! v4 Q3 w) {/ j .default_trigger = "default-on",
% i9 ~1 e" R/ U2 T( _ },+ f/ I9 a2 ~. o+ k
};8 k0 H* g, b. T5 |6 B
$ O4 Z8 I, @0 `8 l
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ H+ a: J1 S5 s- }) D
.leds = da850_evm_tl_leds,
0 j" D) @' D# p" q& c/ A .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 O: n6 k6 k$ l. Q};
$ C g1 \" {% l+ q8 ^- A" X& A/ `# \- o1 s) j4 w; L
static void led_dev_release(struct device *dev). T' o; ~# ~5 v8 s
{ S& f- K7 \2 T' f3 M; o& E
};. g* L; g; k! C9 j" X
' i2 U7 H& H' q( i- `static struct platform_device da850_evm_tl_leds_device = {8 N s1 L% o( @/ x2 X
.name = "leds-gpio",
* E. s8 N. ?/ v" s$ D .id = 1,
0 n! M& C j! f$ g. ?4 c .dev = {
( y. j6 q7 v% W0 }: M .platform_data = &da850_evm_tl_leds_pdata,
% B4 A0 j0 e: ^1 |! ?3 V5 g6 x% _ .release = led_dev_release,4 D' d$ }; ?9 E1 x
}
* v. f9 J' L4 R5 O* j: p3 M2 @2 X};
( j' w4 f- Q0 V/ }- [
# J: e9 a7 K7 h) k, Lstatic int __init led_platform_init(void)
# d6 x* `5 [7 e/ p6 @' s ]{$ L! q& O) T- W" H0 W' ~5 ^
int ret;
( X$ o8 B6 o; h& U) m7 K6 {6 H#if 0# o* B; d' L# w8 P! S! O* r
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* x! w w u: w4 y5 C' Y if (ret)
% u, F( N& {7 `+ M9 m+ _ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
l# T$ @/ W- L& S "%d\n", ret);
- N1 t, \5 G+ E#endif; c+ Y; J! q2 N1 H8 a4 R! s' Z5 @2 X
ret = platform_device_register(&da850_evm_tl_leds_device);
* @) t0 z t% ` if (ret)
3 q4 c( \/ E7 b1 s pr_warning("Could not register som GPIO expander LEDS");1 Y# w2 Y J& A
else, e4 @) G* E8 \% k
printk(KERN_INFO "LED register sucessful!\n");3 g4 Q. R6 A* \& r! X0 m
& `, k: }' N- U; Z return ret;9 c$ O" Z2 h- {9 s
}2 U( v) {2 U( p& y
1 s% D6 S, ?4 h" D1 ~7 O
static void __exit led_platform_exit(void)0 Y2 d2 m7 E3 Q, `1 v! l
{. p- o6 O D+ l) L4 a. G
platform_device_unregister(&da850_evm_tl_leds_device);
5 ?7 d' T# V, z& z) S+ u& M8 S& [
printk(KERN_INFO "LED unregister!\n");
3 F6 v: Y/ Q+ M% H. \, S. Z! J F}* f5 P# {6 X$ b' A \7 m- U- B
- r( K+ v! Z( }0 l/ F0 S; g
module_init(led_platform_init);
1 O! ^2 j' i# l W! n; r! Gmodule_exit(led_platform_exit);5 Q& O6 ^& X+ x) x1 o* g& W
" E8 E) p- r4 Q* k1 s& J
MODULE_DESCRIPTION("Led platform driver");3 O" q9 t1 N, p5 b2 G
MODULE_AUTHOR("Tronlong");
. s/ N( \; v& S _( x& @; ^MODULE_LICENSE("GPL");
/ m- S, }" ]; I+ L/ f- {3 a. l/ y' o* B2 P& L
|
|