|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( _9 c( t" n) J5 @3 Q#include <linux/init.h>
5 Q* K7 b0 J& A; \7 r2 \#include <linux/module.h>
- d2 f( ^# \ U/ ]* U#include <linux/kernel.h>- R v0 H: N& E/ K1 B1 E; @4 J3 A- x
#include <linux/types.h>
) {/ G6 g: }/ ~+ o& R" C: e' x#include <linux/gpio.h>6 y$ s& q3 Z6 x& g% D" [9 E' O# D
#include <linux/leds.h>
5 j; v; O, P. d; d8 L1 V5 ?#include <linux/platform_device.h>
2 ?0 [+ m6 d; T; Z/ |# }: Z
' K- h( H! C7 p, d4 P$ q+ w- H, c#include <asm/mach-types.h>/ F5 n( j' Q) U' E8 a u
#include <asm/mach/arch.h>
. Q1 t( K, j% {#include <mach/da8xx.h>5 D4 ?5 N; h: s ?9 i, C; ^
#include <mach/mux.h>
\$ v* m/ A3 x& ?3 i! l3 L$ _1 a8 o2 G2 z# T Z1 A$ P
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 O* v( U; ]& g$ r2 ~$ q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 B+ w8 P P; `/ ~
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 ]9 @# ~5 l# [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' g3 B) b0 e5 H1 c4 {0 b1 Y' K
8 A: r0 A; G' R- g/* assign the tl som board LED-GPIOs*/
" N$ Q( D' e# k9 H& wstatic const short da850_evm_tl_user_led_pins[] = {& g% r; z4 r8 n# ^) }
/* These pins are definition at <mach/mux.h> file */( K7 H+ E1 T+ I @$ |' `4 [
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 T$ Y" ?" r! T% S -1
' o- k, a0 f" v4 S1 u: k, m& `};
' P! H7 Q0 A1 }9 ]5 f4 y
0 p) ] Y, t7 ] |& ?" O0 x; b! |static struct gpio_led da850_evm_tl_leds[] = {1 i! l. {+ m9 w& K* V. K2 M
{
, ^: e2 G, ~5 M; Z! @* x, D7 r2 r; ` .active_low = 0,$ _3 U: J3 u& k/ `8 T' D
.gpio = DA850_USER_LED0,
- A, r+ k+ k2 }: M9 O3 u7 P& ~ .name = "user_led0", F6 n! l- q% |( e/ m
.default_trigger = "default-on",
$ }' [& y$ n% ~$ p& D: W% t, ~8 R },
& I. h. A( }- J4 g% z t! T7 ^5 h( A- c {
6 h% C8 Q% B! u$ e2 z' _5 ? P .active_low = 0,
+ f* }7 }" e+ a0 P+ f( _" D J$ v .gpio = DA850_USER_LED1,/ \1 {: S+ s0 K- R9 F- V- @
.name = "user_led1",* {, h3 [7 V/ d$ \0 m) n, F2 y5 [2 R) `
.default_trigger = "default-on",
$ {. V: m1 l; ` b },
" X3 l% P2 C, f {
) L, y) }( j+ P9 e& _) a .active_low = 0,) ]' G% u" d& t! [
.gpio = DA850_USER_LED2,
+ z$ l2 _' A! o: E( h( m .name = "user_led2",
, I6 \2 B: J5 `' Z7 I .default_trigger = "default-on",
# H$ d. N3 ^% ?8 {% Q; y+ _ },) y6 Q( J; Y# N, z# P
{
2 b- H2 l* Z/ o* [$ u .active_low = 0,1 `, f4 |9 ~* W4 H9 I: H
.gpio = DA850_USER_LED3," D# A# {! ]1 o& m
.name = "user_led3",
6 k; Y6 l/ U8 D- _& v .default_trigger = "default-on",$ h9 @3 X |$ \
},; o5 |5 F% c( ]/ c
};- p/ o) z, K0 ?
2 i. d8 y" q& }- O4 ]1 J' U( sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( T* ]" Y( B2 C; E, U3 o; |
.leds = da850_evm_tl_leds,
* d3 l( S2 n+ p" `& s* v0 i- b .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& f/ F! g, I4 i# \};7 ]- y( S" t+ j
$ F" `$ j, E- l( r7 F
static void led_dev_release(struct device *dev)
- `. O5 A+ l& u5 o$ n; v* M5 b& u- H{
1 R7 O6 M6 a! w* a; e};
/ B" E' F, s- _* g0 @' G* ^# O3 e4 J' j' H. i
static struct platform_device da850_evm_tl_leds_device = {/ r- w6 a$ T9 W3 D
.name = "leds-gpio",, n* S/ A: A. |9 U1 l
.id = 1,
5 F( g: U3 Y* M4 [ .dev = {- V& N. W3 P) @, e4 k: a& c
.platform_data = &da850_evm_tl_leds_pdata,
1 i/ ^3 c( h. s .release = led_dev_release,
0 s2 w2 i6 ~) _2 c3 a- I3 _ }8 k9 j0 ~% X- `7 y7 v: `
};
6 j+ n( ~, M" o& z4 j6 W; `7 U x4 y, R! D1 D
static int __init led_platform_init(void)
4 E6 v5 Z- G3 O{9 N: E$ f q: J3 @
int ret;6 X- {1 Z4 p2 \; M5 U
#if 0
8 M+ T6 k1 ~( B0 E ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) C7 I. u$ b( x9 ^4 t; e. [6 D4 |
if (ret)" u: r ]6 G* \) ^
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ b4 b2 [! d8 k2 G) D1 m
"%d\n", ret);
7 i, m' ~% C1 A9 ^#endif& R" {: k% D) b5 f5 F0 x) _, ~( B) S
ret = platform_device_register(&da850_evm_tl_leds_device);
6 i C) T) }7 e, [ if (ret)- v( J. X3 T9 m3 ?5 @: e
pr_warning("Could not register som GPIO expander LEDS");
9 x5 S- a8 ]* C( D1 e else3 T* P6 h2 u8 o3 `7 p. c% u ~5 A
printk(KERN_INFO "LED register sucessful!\n");
: ~# J/ u |) R7 {
2 P0 M, e; c" b3 l" I1 s8 ^ return ret;
2 x q9 x m: j}
4 i3 N) s( t/ h% }8 B E2 Q
9 e- P. Y0 v# l8 z3 Tstatic void __exit led_platform_exit(void)1 I5 i/ e% O" ?4 T# K2 ^
{
5 E! Y' h1 Y- f) i2 W platform_device_unregister(&da850_evm_tl_leds_device);5 c4 t7 d9 a o2 L- P
" L5 g. @7 Z; ^) i7 T
printk(KERN_INFO "LED unregister!\n");
) j5 z( M Z% h+ e% e}6 d# G5 g0 U$ ]& |1 t7 Z7 J
: _3 E* j/ J3 r: f
module_init(led_platform_init);; h. c0 _, N3 n3 ?5 ?
module_exit(led_platform_exit);
$ K# }2 y* g8 ]& H" p$ }% Y) w) H1 ~) @' t& W7 {8 |
MODULE_DESCRIPTION("Led platform driver");
G0 G$ x& h- C% S8 z1 b. PMODULE_AUTHOR("Tronlong");
8 b8 w2 j- |$ {MODULE_LICENSE("GPL");
+ p9 [2 }/ f+ ~
, A6 z7 ]- q+ U$ q- Q5 |* f |
|