|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ H& Q9 |; E# b5 G3 { @+ q1 m#include <linux/init.h>
& B" x, v2 I+ |: J& Q9 T% L#include <linux/module.h>% h9 c6 v! ~ \' N1 ~9 C
#include <linux/kernel.h>
! G3 R8 `6 @- _#include <linux/types.h>; S% v8 c: W9 y: G3 f6 T
#include <linux/gpio.h>
8 T; E& A3 _; e/ u3 M# @8 n/ K#include <linux/leds.h>0 s0 ^$ g$ D- {5 F$ p0 h6 j
#include <linux/platform_device.h>) u2 p6 f6 e1 E2 o
8 o3 b& H& S w( J
#include <asm/mach-types.h>
6 P$ q, ~: ?) V0 z2 |3 W#include <asm/mach/arch.h>* B+ c# p4 m5 r3 b/ ^
#include <mach/da8xx.h>& T! p6 k/ ~) L2 y
#include <mach/mux.h>3 F" a0 L/ [) |" q) |! C0 C: I- J. \
/ `" C+ v ^2 J" @#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ I( t: D Y$ {" w
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& J; `* ?0 E1 N#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( {1 t) G" Y% p#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ f0 C- z F( y2 v6 N
. M, ~2 T8 e; p! g- x) b* E3 o/* assign the tl som board LED-GPIOs*/7 Y4 K* p9 \ ]2 M) E$ Y0 g( B
static const short da850_evm_tl_user_led_pins[] = {& I# ]. m2 D% ~0 k# N
/* These pins are definition at <mach/mux.h> file */
: F4 z! A w0 G: s& j DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 X2 q7 O9 i2 l3 |( V# o9 ?" ^* L -1
( i7 n$ C4 j& X6 I1 A& m& ^};# N" P2 B, m; } G* l7 Q
+ n, l$ C5 n7 A- p7 B4 W# Z
static struct gpio_led da850_evm_tl_leds[] = {* y0 q9 q( w* ^) v: I
{) d4 ]1 ]2 l" `- R7 M% d
.active_low = 0,
1 Q7 @# y9 ]; I+ g/ O t .gpio = DA850_USER_LED0,* R( b$ s# h* Z" ~6 ~8 V1 ~! i
.name = "user_led0",
; c- P; u1 h, L3 w# ~& b5 J. i# \ .default_trigger = "default-on",' n5 S% @9 T: O9 Y# i8 B. a
},! P) |) ^' ?) W& {5 x" J) h& N, _
{
3 x/ h2 V# n. N; r .active_low = 0,7 d( }, |" k8 A# |, @( A7 {; Q
.gpio = DA850_USER_LED1,& a8 U$ }. O4 E9 C1 f0 H2 V- x
.name = "user_led1",
" Q' ^1 @* S+ _+ J! D8 j% M1 h .default_trigger = "default-on",
- i- B# k+ `' Q. E },
8 a4 b; f, q. o) U {3 t" a3 I2 H/ O! B/ Z# I
.active_low = 0,
/ l; M/ M) n$ _& S9 ~ .gpio = DA850_USER_LED2,
. M+ E' K) B" a .name = "user_led2",' V( E) @5 c4 k f7 R% m
.default_trigger = "default-on",6 G1 T- Z9 c, g" i% g2 c
},
8 s# S+ N8 f1 w" B% c1 o& R( n {
- ^0 Q1 u7 w& s3 L6 N+ ~9 X( t .active_low = 0,) R/ b, `; }; p/ C4 Q k& K
.gpio = DA850_USER_LED3,
3 L9 r- k0 t/ z) ?$ v2 s .name = "user_led3",
. q: }, D, H4 _3 L2 a7 D0 j. j .default_trigger = "default-on",7 b O! F" M. T1 s. o+ _3 i
},. j# P1 m( s4 ^4 _
};
9 w8 j q1 y% X- O/ R% Z) |. O L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 v: s! X# M) |7 s+ Y .leds = da850_evm_tl_leds,
" r4 w. c* T, a! i/ K1 C; \/ Q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% ~1 F* V. o/ H' T- `6 y0 r" d
};
3 k$ p1 v! c9 b3 _7 D* @3 \2 N* A8 i; C5 x
static void led_dev_release(struct device *dev)' Q% r% |. R8 B
{0 V1 b) |* e( j$ g
};4 v4 M# |6 D4 f/ I( k; x
: Q3 ^) c+ m. ystatic struct platform_device da850_evm_tl_leds_device = {
$ b& w3 i% k. f( m* M .name = "leds-gpio",
6 H4 s0 \9 p- ?0 d! o .id = 1,
6 V4 ?2 O2 F" Z+ ` .dev = {
7 T2 W! K3 ]5 d7 @* Y' S3 ~ .platform_data = &da850_evm_tl_leds_pdata,. g) W# J4 k9 v2 g( ?
.release = led_dev_release,& J9 J1 o* ~2 }, @# Z+ m" Z% B
}9 G3 z1 h: C' {- T2 z
};
, a0 f/ y# q1 i( ]6 |& x: l, t+ X3 q0 }/ r2 K+ M @
static int __init led_platform_init(void)2 B6 o* l6 ~; j8 q
{
+ ]) P, N! e! _; J4 k int ret;
) e) o' d5 ^+ Z2 d0 a- f* J7 X1 a#if 0" _" V: ]( s; v5 Y0 D/ r- `6 k
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& I5 c- i# _. `$ C8 W5 S! m
if (ret)
( j; l8 G2 J& m6 f9 F% G7 J pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 ^. w! ^ C( \# e, {
"%d\n", ret);
! A% R& {& w, t1 n v#endif
+ a% y$ M" A( q. A8 _5 Z9 H ret = platform_device_register(&da850_evm_tl_leds_device);
- f7 Y0 B5 r0 z6 c- o0 h if (ret)% a {& Y& x5 K* x4 a- w7 `, M
pr_warning("Could not register som GPIO expander LEDS");( s6 l }9 E* x/ W8 V4 K3 T5 o% O4 \
else& N- _1 I8 D: D7 U5 z1 I |7 Z
printk(KERN_INFO "LED register sucessful!\n");# o& p, r+ W ?5 I
; K2 R5 ]& F" H1 g return ret;
" V! L, J. t( n9 u}
0 x# ?5 J! }1 I8 b
& J& s5 e6 p8 s& Q: D2 J. \static void __exit led_platform_exit(void)
. m0 G/ G, h$ O8 g{0 R/ J, q z( e2 @: s5 K! }
platform_device_unregister(&da850_evm_tl_leds_device);3 B. s+ Z- S5 L5 ^/ p
3 W7 S* }$ Z8 x! i, s# ~ printk(KERN_INFO "LED unregister!\n");. c0 c3 c! T6 ]1 K) _ c& S
}
9 L1 F. Q9 S! o' S% z
; q8 E5 Q" S; c9 umodule_init(led_platform_init);# j. Y7 O4 D$ }& G3 T
module_exit(led_platform_exit);+ y; `/ [8 y4 Y4 P% |( v
) {) [1 l0 C3 N3 u- S8 E5 V/ DMODULE_DESCRIPTION("Led platform driver");' Q5 Z- s& F% ^ `5 E* t
MODULE_AUTHOR("Tronlong");
" b M' ^+ c$ ?$ D8 Y/ \ tMODULE_LICENSE("GPL");
' i6 |$ p$ z( n2 e' M1 N+ B( t# y; i3 P m$ k% v; T
|
|