|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 f1 H& G$ L6 {* Y6 k; A% n) c& B
#include <linux/init.h>* P, R8 m% J( [( y) g l
#include <linux/module.h>
( a( m* u; C3 m6 H" k#include <linux/kernel.h>6 A: s7 O2 t! ]0 y
#include <linux/types.h>
# o& {, K; M- f, _( p#include <linux/gpio.h>8 d+ w( |6 v0 t% ^5 J
#include <linux/leds.h>
# A0 t4 U4 X, o" _#include <linux/platform_device.h>/ T! h$ r8 ?6 N) T/ @
8 R4 l" g9 E2 c; @
#include <asm/mach-types.h>- t3 y8 \1 Z+ u6 o8 E h ]
#include <asm/mach/arch.h>- S2 v/ X `' S* P1 f
#include <mach/da8xx.h> r+ `+ g9 |: ?+ x+ W {
#include <mach/mux.h>
- l& G, F$ b# r6 b5 R- P# m1 O1 n& @' }" K: E+ `) Q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# Y5 j* Z2 _6 I! e# l#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( W* `+ V/ Q1 _: U9 H1 m#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! g+ G$ ~6 [2 D# z3 k" N G#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): n7 ^$ L$ m2 ?- \( Z
" T+ J) |9 D- N! X; M( b( P5 D h$ e
/* assign the tl som board LED-GPIOs*/
1 | \7 k+ y1 Rstatic const short da850_evm_tl_user_led_pins[] = {
4 S5 [, H" m$ ?( t /* These pins are definition at <mach/mux.h> file */: k( J: n3 v( O" a9 t
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% o+ P! ^! ^* G1 c9 D' H0 z -1- |. Z' `& {' P% Z0 s& u0 c
};
5 k! P/ z2 l4 A* r
) @* h8 H3 O6 u+ J( D, r" v2 Vstatic struct gpio_led da850_evm_tl_leds[] = {
! h ^1 {/ p; [; c( P9 a6 s {
# W* i, X4 |7 n6 a3 | o; u .active_low = 0,! C5 x6 F% ^2 r( H
.gpio = DA850_USER_LED0,
6 C. B/ H1 T# f) h# q$ f .name = "user_led0",
$ Z$ \* [, |& m% J0 R .default_trigger = "default-on",7 h9 [9 p) L# @
},
4 j" U# f* t+ t' A {
" {! K8 X3 a: h7 d. n8 n* J .active_low = 0," S- r' x5 d; {0 u4 c4 E' X( [) t
.gpio = DA850_USER_LED1,
" h& D& j. Q1 g4 u$ G3 f1 P5 J .name = "user_led1",& [. i# F' f5 M+ V3 U8 y
.default_trigger = "default-on",
2 B' Z. i* G. A3 R. x },6 E( g& y+ v9 O) ]4 z, R
{
v9 p2 K8 }# c: ?. V .active_low = 0,
" J9 W8 H x' R' k! l( `: m .gpio = DA850_USER_LED2,7 D$ P: U$ Q7 a" H. [
.name = "user_led2",
! Y) J$ b* y/ d8 x7 W6 M .default_trigger = "default-on",
1 ]9 W8 k0 W4 A0 n" B },1 c$ q% M, Z* f% L* |! n; u7 p, F
{
) p' J; v6 L% G1 o' g% F* C .active_low = 0,
& u' s$ s$ U4 ? .gpio = DA850_USER_LED3,
3 |+ P% L" W0 g9 `: v4 f& ~ .name = "user_led3",+ |/ \6 p9 u* S1 B
.default_trigger = "default-on",* K3 y2 h* ^+ M8 l. `3 ~! u. z
},' t9 g, d6 j6 I5 E( a/ O( ?* q
};
1 \: H2 L) ^4 k" \3 p- t, P
, X, v% H l2 ~3 m$ {4 tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, U7 L: E% T1 S) G
.leds = da850_evm_tl_leds,3 p5 G, f- S. Y) T" y7 q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),& r- o! c. W' O: j% O% i+ R8 x" U& ~% a
};
# [. t1 U! K/ D$ h0 B7 \2 W( R: Z! r+ g& N& {, B+ S. j
static void led_dev_release(struct device *dev)
9 e) X: I, @8 K: y7 }{6 P4 N+ K- E% S. [6 _ P! R
};
9 X7 H5 H! S0 F0 j9 e1 Y
' M. a( Y b ]' v3 N4 d- D$ h# x/ Xstatic struct platform_device da850_evm_tl_leds_device = {' y7 h k5 a. G9 ]2 m
.name = "leds-gpio"," V7 p: Y* R$ k# R* ?
.id = 1,
) M. i+ g- n% P .dev = {% h- _$ C6 W& W/ q. H, ^5 ?2 j
.platform_data = &da850_evm_tl_leds_pdata,
6 R# E* w: F9 o* v) \ .release = led_dev_release,7 R2 Y) @3 o7 M H
}. ] L" f0 t" {# l
};* I u- K0 ?0 w5 ]5 H7 X; F
. _! {- p# C! x2 }static int __init led_platform_init(void)" I1 N# z0 N3 v
{) d4 `1 g4 @ x
int ret;
* [6 T; T& D9 A6 @, f1 V#if 0
: t3 e- a) K5 W9 C1 h( G' n ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 j5 e9 J; M: a4 h4 M# J if (ret)
7 f: U+ I4 i( L" N4 ` pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ C6 v4 s) s- V1 z
"%d\n", ret);
) a# d( _$ P, g#endif
1 ]5 Z1 U2 v; [ F7 w' Q4 @ ret = platform_device_register(&da850_evm_tl_leds_device);
/ P# d6 }& @9 v- W/ f3 i if (ret)
4 ^( _, j/ v+ u+ V pr_warning("Could not register som GPIO expander LEDS");& ^$ \0 z' s: _. w) P0 g
else
$ V. c* K& R& Y3 y e! c* r printk(KERN_INFO "LED register sucessful!\n");8 C$ n& _1 d$ E$ j. ]
7 H1 I# K. Z2 g0 k f! C2 ~* b8 b- R0 | return ret;
+ S8 B" |- H4 E; F0 H' k2 I4 X}
0 W% w* d6 @3 y- a* a
: s1 I- L3 n, Nstatic void __exit led_platform_exit(void)
0 q4 k5 X$ M3 m# P{5 R: Z7 C4 I$ q9 }+ x$ E
platform_device_unregister(&da850_evm_tl_leds_device);
' |; ?- n+ Z& a- S% w, o- s
# ~* Q. z: r" J- z printk(KERN_INFO "LED unregister!\n");
9 n& D* H0 W t7 Y}
$ P% g3 w# y+ E8 _' F' `9 T
5 E: B5 n: B' C1 {& ~: Zmodule_init(led_platform_init);2 d V# `% _5 P/ d w! P
module_exit(led_platform_exit); J/ G; l7 B2 G+ {" ~, {! l
2 f$ Q3 M$ d7 _8 Z7 z9 a; j
MODULE_DESCRIPTION("Led platform driver");
7 l8 C8 h3 q# p2 O0 W6 w9 B$ v SMODULE_AUTHOR("Tronlong");
9 p' R7 @7 j7 m) B3 GMODULE_LICENSE("GPL");
6 J- S& k) h2 N; y! |3 r$ e
% T- a9 w( s, W0 R) M4 x. J1 T |
|