|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" K- q& Y5 z( h1 U t& M1 O
#include <linux/init.h>
3 a3 K) |# U* N#include <linux/module.h># A. K: b' i* N, p1 T( e( o# d" ]
#include <linux/kernel.h>3 O5 F( O$ _6 L3 Q/ d: c
#include <linux/types.h>
5 t% G* s+ h. n( a8 k" ` e6 h1 ]#include <linux/gpio.h>* S1 R% z2 j- d; x8 a
#include <linux/leds.h>8 [/ z W( Z0 h
#include <linux/platform_device.h>( ]+ y! X: i+ @' \
( i1 H* ?, j* Y$ e% m
#include <asm/mach-types.h>( Z+ m4 ]2 M' C
#include <asm/mach/arch.h>, C. {( \% ^ s- v& t
#include <mach/da8xx.h>
+ W1 b; E# h- d# i& b#include <mach/mux.h>
. D+ t- ~2 O% E# D7 o1 O- f/ K# F% e- V. `
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# v. y* Y! p/ Q$ @4 Z' [
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( g! m$ i! \( M
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 m1 K$ y/ U7 c) k#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* S- l$ Q; M k, J$ U- W$ w
$ [: b9 x2 A: j# e# I/* assign the tl som board LED-GPIOs*/
! c' t3 T0 H5 |* R% q3 Qstatic const short da850_evm_tl_user_led_pins[] = {
' r+ f8 q8 n2 p0 Y- a /* These pins are definition at <mach/mux.h> file */) j' X: q( ?' ~2 y# _, H
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( T! H) j; y1 [: |: i -1' l4 X' V! S, f5 \3 v1 S) i; [
};
4 ?* u$ @# I6 _) o4 Y0 Q3 B2 | I) y$ |9 m) I
static struct gpio_led da850_evm_tl_leds[] = {
* R5 T* o, ?4 V. t; V+ w/ u6 o {; g1 |; B- l; j" f
.active_low = 0,
! B3 }: _$ B; f .gpio = DA850_USER_LED0,
% _. b4 O! A! T' m .name = "user_led0",
; l6 x# o) T" Y/ |( p6 Z .default_trigger = "default-on",
+ F& a" Q$ b! z6 V2 X& } },
% f0 {* c* z: S6 u+ J$ H {
* t) g: I& I2 V+ {" F% e( N2 V .active_low = 0,- A5 f4 M7 v4 @3 Y" T. X
.gpio = DA850_USER_LED1,. }) r0 E5 D, L; Z( k6 A- v% c
.name = "user_led1",
) I6 _/ ?7 O3 K .default_trigger = "default-on",- R3 B8 h4 T4 I5 b
},
/ V2 t: G% I8 w {
/ `& ]" }; s# }& w3 U: C) n .active_low = 0,- l& \: Y8 K: f& G4 t
.gpio = DA850_USER_LED2,. ~% |; L' G$ J
.name = "user_led2",
0 s( D4 h1 S" ~& Q4 ?0 M6 |, g .default_trigger = "default-on",
$ X% L N& t5 ~5 J. O },
: ]# A; d) z1 i {
3 M3 g0 ~$ z, ?) D .active_low = 0,! A, H8 }9 t$ \4 ?% c
.gpio = DA850_USER_LED3,
$ H' A* k* ~7 [5 d b9 J5 ] .name = "user_led3",# c! J' r& m9 C! t2 M0 i) y
.default_trigger = "default-on",
& c+ l" w+ r2 a2 Y },% x- f: ?6 C/ X5 e- b
};
' z( W% M* G$ m1 }+ ^/ e
8 X6 `1 Z1 r6 R" N( Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% S( W7 C7 B0 F8 g
.leds = da850_evm_tl_leds,
1 ]5 ]5 z8 E, y) g' S+ I% H- l .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, w j+ o, h6 t. `0 e W! o
};
3 C( `8 B7 R" e+ x, J; W9 ]) ~ ~% k! D% l2 H8 g1 z: {" v1 Q
static void led_dev_release(struct device *dev)0 C. I, m6 Q% h2 x7 J
{9 l6 V2 t% n% b' X, s+ `
};( V! E3 c1 j# E- f# U" R# _
) _" F: T! B1 P4 v! N
static struct platform_device da850_evm_tl_leds_device = {
. z5 A2 M9 e' n) ]2 t1 Q6 H .name = "leds-gpio",$ M8 g- w0 d z/ c
.id = 1,
% `5 u3 [7 D: @5 `6 f+ ] .dev = {* [. {( _. Z3 h3 \, g
.platform_data = &da850_evm_tl_leds_pdata,; o; y' B2 g( z6 h$ t
.release = led_dev_release,
( Z/ t5 L3 L0 \: T5 z. A }
1 w2 \- H$ l8 g% j};, x) i8 C0 \7 a5 p- v
+ q: [) ~6 z$ s! y- _) D7 u
static int __init led_platform_init(void)
& x0 J/ \* \, v{
7 t, G; N/ Y) {6 y6 _$ s0 ~, L% } int ret;- F9 z; M$ a# H2 H5 w) i
#if 0
' Y$ Q- O3 h3 n ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ \( |' P5 p, H5 a
if (ret)5 ]5 ~5 t% ?+ q3 H
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# V" U; l! `5 b& o5 ~4 j9 V( T
"%d\n", ret);9 }+ K' W1 v' i8 X
#endif+ `* E" a( `, ]- i- J
ret = platform_device_register(&da850_evm_tl_leds_device);5 g4 |& L( }3 N9 t) P4 @1 d. u
if (ret)1 r# o- P! N1 M% s
pr_warning("Could not register som GPIO expander LEDS");7 F9 ?. t5 y+ x0 x3 Z
else: y& q; V/ ? Y$ Y' K6 a* @$ J0 z
printk(KERN_INFO "LED register sucessful!\n");
$ B1 f! S2 M3 w
% z+ J8 q- o7 W, [' z return ret; i, J" {4 l. X
}" o# j3 p( l W+ d) M; I
& K* G; E$ e9 ~7 E9 z+ }static void __exit led_platform_exit(void)) m4 Y8 B* k5 A6 F
{
# r( ?5 v. \8 V; `! R1 L/ `0 ` platform_device_unregister(&da850_evm_tl_leds_device);
" m' c9 p6 K2 ^. d/ i, S
2 y. c2 a5 R3 a8 \ printk(KERN_INFO "LED unregister!\n");
$ ]" _0 H6 F3 i( `% S0 M}
t9 ~' s r+ t& l9 [, w. k! V1 ?! m) T) C+ d: D/ j
module_init(led_platform_init);+ L- R/ K% s, j2 B8 v
module_exit(led_platform_exit);0 s" W2 L, V- c
+ O K0 l" N' V
MODULE_DESCRIPTION("Led platform driver");% Y* @- U" j; j+ I9 j
MODULE_AUTHOR("Tronlong");) C, L7 q- b/ r4 M3 Z& T; ]& M
MODULE_LICENSE("GPL");
, u4 b7 T/ u" k7 a" b) J
8 M( m; q, ^4 S- I& R( k) J- g( v Q |
|