|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. \ J0 y7 I' N6 R( I) A7 V#include <linux/init.h>; @ n: w3 a5 ~6 Z: {- R0 [ f
#include <linux/module.h>4 l& y1 M$ L0 K0 r
#include <linux/kernel.h>
* E* I. P+ }& v#include <linux/types.h>
- G+ f4 [8 y0 Y, @. s& n0 J$ N) G#include <linux/gpio.h>5 J4 j. f! Y# R9 C. D0 Z
#include <linux/leds.h>1 j6 \3 z: ^% }9 U; |) ?
#include <linux/platform_device.h>
$ t9 m, @0 M% ?. f9 z8 V2 C0 D" L3 [1 H
#include <asm/mach-types.h>
5 P, r% f2 s+ ~0 k' ^3 J$ g# H6 f#include <asm/mach/arch.h>
% {, s# _5 y) [* C4 I. o9 j! J#include <mach/da8xx.h>6 z* ]7 q9 k0 @' \# ]5 }- \
#include <mach/mux.h>5 j2 g" @% z, g" g: `, [8 M
8 Q8 h( U- j9 \ `4 \#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( i: z- I ^4 ?' ?- B2 i% b' Q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 J4 K' T/ s. x* Q4 r7 `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 o; W# p6 M* m0 [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ }4 r2 q1 x, M$ k: g
7 B2 k& t' z( I, |
/* assign the tl som board LED-GPIOs*/
: j; K. e; `) s n3 {static const short da850_evm_tl_user_led_pins[] = {
7 Z. Q, }- P9 d5 s /* These pins are definition at <mach/mux.h> file */
- Z! t; `. \; Q Q9 o6 D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' Z5 j1 _; s& g' G: ]
-1
/ t2 F) v, |% D& e ]7 y$ \, _};7 U# W% I! I2 \4 S) t" p7 x, B
0 H$ f$ d Y: J; }& {: K
static struct gpio_led da850_evm_tl_leds[] = {
! t9 @3 [! b$ w# ], m1 \ {
- U" M+ O7 ]; E! G( W .active_low = 0,
9 z' ~6 i) [/ R, _5 D .gpio = DA850_USER_LED0,# O" d$ q7 s! E* F; m
.name = "user_led0",
, A( |& V4 d! F5 b .default_trigger = "default-on",, |3 _6 }: v4 ^: H3 r+ ?- S; r
},
* ^' F& }0 p9 n2 J4 d) ` {* R/ n7 y: ^/ [( R' Z# l1 Y0 V
.active_low = 0,0 |, G8 Z% O$ c
.gpio = DA850_USER_LED1,
3 Y& Z/ t/ j/ J. K% @& j0 v8 [ .name = "user_led1",
0 K9 D6 x- f, O) K .default_trigger = "default-on",0 C+ U" q3 T9 a p8 _. H- y, r5 N% ]
},' P! `& H2 @- f! l# a
{
5 j8 \! O, z9 }0 V6 {+ T1 C .active_low = 0,
6 C% ]" W5 h1 y3 _ .gpio = DA850_USER_LED2,( u* L. ?" V/ E/ P7 g
.name = "user_led2",' G4 o5 n# a3 ]/ V4 k# @6 r
.default_trigger = "default-on",
7 t1 e1 `4 _" T& i },
8 E3 B$ K' q7 f! k {
* W4 ?, ^# p. V4 \0 S# `2 R .active_low = 0,) u. x3 p& y6 K" Y0 q& e$ K( P
.gpio = DA850_USER_LED3,% ?6 U* y3 m1 u
.name = "user_led3",( v( D1 T# D& T8 `1 r
.default_trigger = "default-on",, S" p4 ]; p0 X" q
},
# L+ l4 y2 c9 H9 y( ^" V6 \5 c};& O) f/ D% O+ n+ M3 [
) s7 a% z2 y0 V1 `/ U
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
q1 x( @' R B! N .leds = da850_evm_tl_leds,1 s2 f2 J# g( N0 q2 c" v
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! S+ @, U: e5 N1 l+ n};$ a% p. d0 l& x8 t, n4 @) ^# Z
* B6 o8 U/ ?) i& Cstatic void led_dev_release(struct device *dev)
. u3 A$ C8 V# E- M: m' Z{
3 l9 [! [, P' B" K8 F};
3 c F9 @$ Y5 R4 p5 g3 m: p3 Y, Q. n9 I2 l6 q& i( Q$ }
static struct platform_device da850_evm_tl_leds_device = {4 J2 t2 e, m& r! I
.name = "leds-gpio",2 [2 m* b( B2 }) x U
.id = 1,
/ u" h1 g% V2 z/ j# b) P) l .dev = {2 t4 o) R( R7 E1 u" e/ r* t
.platform_data = &da850_evm_tl_leds_pdata,0 g8 T4 T% Q8 G- I% f j3 b
.release = led_dev_release,( }* F5 c* b+ s6 L+ J x
}
2 \( E* c8 r1 q$ \};
$ v: v/ {6 I, i/ c
: E9 c; N0 l8 e4 zstatic int __init led_platform_init(void)0 E( U, l0 ]" T6 F8 [
{: C& v6 ^: q/ ?0 k9 X. B
int ret;0 d: ?& ^3 \) y5 \! ~' r+ M
#if 0
" T# r, w$ j$ `% R; P! N ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' Y% Z. E; H, r% C. j# [; l; g
if (ret)& `* ?: [: } y L8 t s( k" i& i
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ @& \' h# N6 \* x& e& W) }. w "%d\n", ret);
* k# T% |+ K' y& O- x% Y' E#endif- P8 k3 j( N7 i% A h6 b/ F
ret = platform_device_register(&da850_evm_tl_leds_device);7 a* k5 r- V, v8 P0 J
if (ret)
* H& D& P# j) o3 D, W9 x' H pr_warning("Could not register som GPIO expander LEDS");
4 M r6 B. \! _; D! B% z( o7 q& I; Q else" a0 ?+ v9 l* D$ Q
printk(KERN_INFO "LED register sucessful!\n");
& T; Q+ C0 t9 S0 G) }7 ^# Y R N9 M8 J: x9 g
return ret;
/ `$ x9 ?! J& l& Q( h0 f7 w4 P4 V}
. w- c" X9 x( B L2 M5 o/ d
* \: v: c4 ]$ M; k3 gstatic void __exit led_platform_exit(void)
, T. @# r Y% y4 S$ D# D ]* M% |{
: ^ c Z4 e7 R% Y+ P( m$ ? platform_device_unregister(&da850_evm_tl_leds_device);8 t* ` L1 h* f+ s) L
* i2 n, j1 w6 P( N
printk(KERN_INFO "LED unregister!\n");( L" h' R/ i* @
}
: s$ a1 @2 n2 W3 h
/ ~5 o b& r6 ^9 Wmodule_init(led_platform_init);9 T, M. {* w0 b0 E5 c7 f
module_exit(led_platform_exit);, { ]( C3 q, C1 |
/ F5 }. V- r2 h/ r- ?MODULE_DESCRIPTION("Led platform driver");
9 S9 D/ s5 F3 A3 L5 g( n! T: BMODULE_AUTHOR("Tronlong");/ K, Q9 z- O9 x( g7 Z
MODULE_LICENSE("GPL");+ E( k4 b; S7 D- J/ y" ~' \) E. s5 e
; P5 R& Y' O8 P+ q" a
|
|