|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 E* O; k; m+ U' s! `
#include <linux/init.h>
% F/ p) v& q& C5 z#include <linux/module.h>. @1 J `! _% ^5 w- L, ^
#include <linux/kernel.h>) B0 a7 }% ^3 R2 L c# `5 x0 N
#include <linux/types.h>
6 e1 v, I/ {* d; q3 q |0 |) m#include <linux/gpio.h>3 ?" g6 l$ }) G! q( _
#include <linux/leds.h>; p% M" U9 E- L n, K& s
#include <linux/platform_device.h>
& J" M( Y! v d$ M) t+ t+ t
& Y7 @* P- P6 ^#include <asm/mach-types.h>
) z# I3 A3 ?6 U( a/ R7 w' ]#include <asm/mach/arch.h>
; L; {% S. s1 P7 I. Q$ U#include <mach/da8xx.h>
9 Y& |% O C! ` e' p; M#include <mach/mux.h>
5 B6 {, H$ Q. ^2 j* m5 [$ a9 U! C& O4 j6 {8 g
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: U' ~+ }0 w8 L b: G2 h* k6 X1 j#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! ?( y" F8 g0 _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 a+ ^. |6 @. \+ P% N3 t! |" u" q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 C( u4 `* o' H
0 P- [2 b6 ]0 P9 N0 @! \' G/* assign the tl som board LED-GPIOs*/
Q$ ?3 r1 u6 D7 {, L5 y: fstatic const short da850_evm_tl_user_led_pins[] = {+ g5 R, m- b0 y; d0 d- v8 _' _
/* These pins are definition at <mach/mux.h> file */+ l, T% c9 A1 _) r1 T
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. y" V7 S+ b8 c3 J0 B- _ -1, w9 l5 a a: f- y$ ^ R3 C3 I6 z
};
3 B8 Z% i- d9 q- y7 M7 Q% p/ @3 H* ?
static struct gpio_led da850_evm_tl_leds[] = {8 I9 s, Y/ Z; [/ X* c
{
; @3 ` k3 ~9 C .active_low = 0,( V; W/ R' _0 H1 ?: o; l
.gpio = DA850_USER_LED0," c# }: ?! x/ r
.name = "user_led0",) H$ p8 c% k6 S
.default_trigger = "default-on",
! `/ H, c1 d X },, ^7 `* |* X+ ?- K1 f- _' |
{
" \: u: v, @( ^; U .active_low = 0,+ B1 o4 S( E% L$ `8 ?4 H. n/ z2 m1 i8 O
.gpio = DA850_USER_LED1,
1 K) C9 D8 v4 O0 D! d0 n .name = "user_led1",
8 m9 g S, P; N& J& r" d4 ~8 k .default_trigger = "default-on",0 ^0 X( d0 S2 O8 `
},
2 ?/ C* m) N" B6 J. O/ v {
I9 y/ N4 L& D: u5 f4 |+ ^* z .active_low = 0,
3 l' j- m' n D .gpio = DA850_USER_LED2,
A- E! z8 ^4 V* l; J/ P .name = "user_led2",
8 K1 B7 z, [' ]( D* [ .default_trigger = "default-on",: ]! G( z- Z& d6 O
},
# l# d8 f& g; a; |9 d" K& o {
( J4 l) O) Q# Z3 O6 z, ? .active_low = 0,; F+ y1 E! ?8 J, e5 ~/ T+ v
.gpio = DA850_USER_LED3,( A3 q1 K% r( `1 ?
.name = "user_led3",
% f9 J- Z/ Y7 ~7 S$ p .default_trigger = "default-on",0 u3 Y# a4 x9 V- ~
},
5 j0 U9 J3 m1 \};* z& \1 p( n e& Z
9 Q& \5 k! r. C5 ]
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 E6 _. q% r* \) F .leds = da850_evm_tl_leds,$ K1 d0 w, \. ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 N' K4 u& O1 U3 c};
: |7 m& A8 M+ j' z3 l& i2 ^: N; m% O5 C) H% O0 o$ j7 G
static void led_dev_release(struct device *dev)
$ `) l3 F8 x% U! m{
% e% O+ i) K6 I9 `. `/ W) h% f# a# B}; X, O+ f% t$ q0 V7 [' P) D& P8 l
+ k6 C, _. p% f: Astatic struct platform_device da850_evm_tl_leds_device = {* L4 O' t& `& a( h. Y$ h1 S8 O, H
.name = "leds-gpio",' D* s% }! H( F% Z9 D
.id = 1,, x+ I N( S% L
.dev = {) W2 }8 P- r4 `9 e% ~1 M: a
.platform_data = &da850_evm_tl_leds_pdata,
! _) |5 d1 D- S" Q4 S .release = led_dev_release,
" E) _/ O5 T" t) u3 G2 J/ z }
0 L: B6 v4 t) m4 M$ }/ f$ ~, x};
% A, C& m7 m2 c9 }+ `" @( L, w2 r6 ~4 o# v
static int __init led_platform_init(void)
$ a% v [1 A! a+ _' k/ K. o( W+ L{
0 U6 Z# E' B7 \) w int ret;
2 [3 X( j! |. T% r* n0 F#if 0
3 r3 A$ s8 n; i3 g& ? ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 n, y( ~7 _6 } if (ret)
) @' g% y$ H; v5 U. q/ ^+ ], K& t pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ L; u( ~, P6 \; [
"%d\n", ret);' t- q" m* I' E8 p
#endif$ Z/ q" D t! W, T" z6 P* K! p
ret = platform_device_register(&da850_evm_tl_leds_device);
! C* [9 K( F; W+ \+ p if (ret)
% k; w) {, k( y' m% b9 D% R" n pr_warning("Could not register som GPIO expander LEDS");& e+ |' a9 f8 G( ]- M7 ^5 w! U" o
else" L. P0 C/ l9 v4 ~, O [$ W
printk(KERN_INFO "LED register sucessful!\n");
# F3 y% f5 \. b( _' S; r I) n5 V) L8 u! e9 V& s: |( H
return ret;8 X A! E+ b* r0 P
}4 ~- y" {9 z3 A# r9 g0 n. v
: V% {0 K3 F0 X1 }9 K9 K
static void __exit led_platform_exit(void)
1 E' U" N L# n6 z{
+ }0 f8 C, O7 b# b, B# | platform_device_unregister(&da850_evm_tl_leds_device); Z% U1 d% F' x& t9 J
* Y% B& V7 S) O; @8 `' e! {
printk(KERN_INFO "LED unregister!\n");/ |3 ]* E4 n1 [7 L! w% m
}
/ d/ J5 U8 A+ y7 I, B2 z6 Q8 v+ n9 G0 E# J/ ?9 _9 n
module_init(led_platform_init);
0 t7 T" R" @7 ~0 J) T+ zmodule_exit(led_platform_exit);
& S5 p* Y0 c9 W! @% @7 q# r2 P
8 i* |! H. i) ?1 d. i& I! MMODULE_DESCRIPTION("Led platform driver");) W4 C, o: {4 w" a4 ^" w2 y! R
MODULE_AUTHOR("Tronlong");9 I# j- r* N/ F/ u- y4 H
MODULE_LICENSE("GPL");
4 e2 p& }# Y1 z4 M* b/ d. b) ^" I
9 D$ F# c" Z! y |
|