|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ U" g; j' i- I" n) c4 N% ~1 H+ s0 `5 J
#include <linux/init.h>
0 y) a9 @8 {/ U* d#include <linux/module.h>
, Q' B# ~/ z) u! [, l; a: m( U! {' D#include <linux/kernel.h>5 H, q0 @! W6 _; }* A
#include <linux/types.h>
( a/ m# o2 F+ X6 ?: U" c7 ^1 `#include <linux/gpio.h>' b+ q! S5 n; p. k5 B
#include <linux/leds.h>. k0 Q [+ o: v O6 i" T
#include <linux/platform_device.h> `7 y0 m0 y9 ~7 d- S1 `
; M7 `4 `' S: k% n' c+ e" l% v* s( x#include <asm/mach-types.h>
8 L1 D/ W6 Y/ x+ D) Z( ]#include <asm/mach/arch.h>
/ T% F* m6 a0 J#include <mach/da8xx.h>
+ n. O# d4 @2 S9 Q- ~) g#include <mach/mux.h>
+ S1 b, a% y0 J# d
% k4 z0 W! I/ d& r9 f0 \7 [! N- K0 f#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 n0 a7 g6 m( K9 p#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% Q) s1 g( V9 C! Z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 h4 N7 D% i( ^8 e1 k
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 U! z8 W0 u7 D' o$ z" \
7 a. V7 r1 a/ n" L* z5 J( G/* assign the tl som board LED-GPIOs*/' T3 W( v. ^$ r) |$ ?! _+ [
static const short da850_evm_tl_user_led_pins[] = {
! E; Y6 h9 d1 u$ }- X$ O /* These pins are definition at <mach/mux.h> file */
5 c1 s C/ T! o \% E L DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ E8 }' a3 X: I+ {. u! I
-1
) _8 j# e# t' _};$ C& G }/ Y8 l& G
8 C7 ^) r7 V7 i9 H7 _static struct gpio_led da850_evm_tl_leds[] = {2 E% J+ [7 W) I3 Z4 k l
{
& Q3 B; Z5 `$ @& ~; m5 ? .active_low = 0,3 I$ Q- f; V# M* F+ E+ F! C3 P0 V
.gpio = DA850_USER_LED0,
+ \, B% I0 K/ k9 A j .name = "user_led0",$ E& b% C0 N$ @. M& w
.default_trigger = "default-on",* b; y/ j- q2 A# Y& D, X( d7 y
},# E* L% K/ F& c: ]: h% K: j# c5 p
{
, `+ o G/ v% Z6 y& ^ .active_low = 0," a$ _! @/ H$ c5 Y. I
.gpio = DA850_USER_LED1,3 ]" h2 M& L E- ?2 O0 |" u
.name = "user_led1",2 x# O! G7 E' @
.default_trigger = "default-on",
& `( ]; g1 l/ r, \% u2 ]: C },
" q. w) i' M9 b {
- ~7 w0 G ]7 b8 I7 m; M1 \, a .active_low = 0,
! k1 c+ U2 G, m) ^4 P) U .gpio = DA850_USER_LED2,
2 X& j G$ v8 R( k7 u4 ?% B9 Y0 u9 l .name = "user_led2",2 G$ N% ?. @( ~! a1 ?$ c
.default_trigger = "default-on",
9 m W* |7 r1 a( K* h/ t },
9 l* i* x9 b; T; a' n {
- M3 D' b% i9 k1 T+ U% B .active_low = 0,
3 y1 \ f- q4 u) } .gpio = DA850_USER_LED3,
* P6 ?0 @! @% s9 T0 e .name = "user_led3",) E% y# o5 M Z) @ z2 @
.default_trigger = "default-on",
2 ~- ]8 P; m4 F1 b) S },9 f1 ]5 f7 k- A: _( L; M% |
};. m9 m( x# d1 h' t. U G; p& C7 N
! S \$ N& ~# V% O, c3 h& Y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! V9 M* T9 }. {4 h1 L F .leds = da850_evm_tl_leds,5 p2 t* K* u$ D& E& m/ J0 H: v; O
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) c- K) E C" s- ^2 q};0 ^5 h7 \" W! N# P
5 m7 K: \7 Y% w
static void led_dev_release(struct device *dev)
+ h8 F! T0 N8 k+ m# {{
" a% S, n9 Q" i& k};% X6 z7 P4 S- a5 m
' {8 H. k6 F" ?
static struct platform_device da850_evm_tl_leds_device = {6 H$ i @4 A: k; \5 O1 {% Q- C
.name = "leds-gpio",/ X) G }7 D5 k8 [! @; Y" {
.id = 1,
7 A7 b- h! I! G+ C" P5 v5 F5 L .dev = {( Y- D" l) e, C
.platform_data = &da850_evm_tl_leds_pdata,
- d/ Y R+ g4 U% f; }5 `1 U1 U1 A4 a1 S6 n .release = led_dev_release,
# l$ ~5 r; ?& r$ W }
, ]% [9 b, [7 j& `5 _/ z};
4 p: n% p0 x/ K2 P* |5 O$ T: O% e' A& d+ n
static int __init led_platform_init(void)9 v% l$ K( U8 c! e' K
{
6 {1 o/ l4 R. J) d" x int ret;( A. X2 A' R6 E2 f6 D: \
#if 0 a* q3 C2 a& l) ~- _; Z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ _2 u+ G7 } U: l
if (ret)9 E' i6 t! E5 o3 _+ e$ m6 g& f, O
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& {# o- ^9 G5 g2 _; Q) w# J "%d\n", ret);; E9 b2 S; b- F* p6 J% C4 n* P
#endif
: W4 [5 d. K P. z# x/ R; N ret = platform_device_register(&da850_evm_tl_leds_device);5 A' f; W" X% U5 O
if (ret)
, v* r$ [4 @% J pr_warning("Could not register som GPIO expander LEDS");1 R' t0 o1 Y! E
else
( Z* U& w& u+ _8 f! d printk(KERN_INFO "LED register sucessful!\n");0 T: j8 b/ } `, ?- t1 J2 B# c
) [( K X+ T3 ~% N. b* o
return ret;# V+ l& T" q, U& V
} E( x( r# X4 n8 u }" @& g6 B5 F
, A4 B0 R- B8 ^ o; |
static void __exit led_platform_exit(void), m/ {6 i* Z: c4 O1 O
{
0 W; y+ P t6 o& D' l+ X platform_device_unregister(&da850_evm_tl_leds_device);( H, a* C- s9 C: x' w
! @7 u4 T& ~1 Q8 E, n2 H" D
printk(KERN_INFO "LED unregister!\n");
) C: B" V+ a4 }$ v+ m% _: F}0 y/ h3 A0 O6 f: t7 S! ~0 e0 O
( [1 {" V3 {. t) q; Z
module_init(led_platform_init);
: i9 t! P0 `" f& m$ Pmodule_exit(led_platform_exit); q, Z9 m: a- ^( R. H$ `
2 y3 f; x1 ~& hMODULE_DESCRIPTION("Led platform driver");
/ x1 o, z7 i4 ?. d* o+ }# uMODULE_AUTHOR("Tronlong");
S/ I: D) N4 e, I6 iMODULE_LICENSE("GPL");
/ q4 c' m2 {8 F) o
2 R/ G% P B+ _/ m) w |
|