|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
E! z1 ^# g' L. P& x( V#include <linux/init.h>4 {: {; t3 R3 `
#include <linux/module.h>
4 |0 k e* O% o/ x: G#include <linux/kernel.h>
: `' o" n7 |" ^6 d$ H- x+ }#include <linux/types.h>
9 S- Y c7 m3 d) T#include <linux/gpio.h>
) S/ T- S0 _) s3 U7 N#include <linux/leds.h> A; H6 p: Z2 h' c$ n- x
#include <linux/platform_device.h>0 W# h( h/ z: U% J s
" G1 O: k- g+ w! K#include <asm/mach-types.h>
! i0 e" G S: L#include <asm/mach/arch.h>
+ S7 Z. m1 y n+ v( y#include <mach/da8xx.h>
: I8 P& r) S3 c% P/ m" ?#include <mach/mux.h>
* F+ T+ l6 c) b+ P8 H4 t' z$ C$ j1 K" ~5 F6 e$ [3 s4 n* C
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): Z4 b* ?" m/ C5 X7 I9 c! |
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 ^3 C# J' n+ [; Z' F! L
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 J) H2 M' U& c. p
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: j( c3 s7 }0 b0 E' s, |
9 o. z0 n2 n3 k; l% b$ f# D/ F4 a/* assign the tl som board LED-GPIOs*/
$ ?& a3 y- h8 o9 K2 e2 dstatic const short da850_evm_tl_user_led_pins[] = {5 b! k3 g; l5 j$ v4 q$ s! i+ p0 ]% S
/* These pins are definition at <mach/mux.h> file */
, f$ o% f2 x/ O0 z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 S' M0 `) y, X( ?0 _6 ` T6 j
-15 c4 E8 W- E, j; ^& Y+ y
};/ i( A, b4 |7 {$ o
% |; E9 Z; e( }static struct gpio_led da850_evm_tl_leds[] = {
* l9 g, T6 K) V+ a {
0 c0 x( O1 [/ i: K( {" t* S .active_low = 0,
2 W. F- A' e9 E7 l2 t .gpio = DA850_USER_LED0,
1 S1 B8 i; _- F) c .name = "user_led0",
! c! m6 j8 n' p, {2 U% p .default_trigger = "default-on",1 n$ u5 _9 B Q$ k3 c# {
},$ ~! K( P( p" O6 }, Q% ]: l: H
{
4 w+ ^* \+ E/ h .active_low = 0,+ g1 F$ r* k5 E6 m b. @$ ^0 E
.gpio = DA850_USER_LED1,: c, e+ f: \2 |) f: b8 M
.name = "user_led1",
! N. G, e% t$ ~. Q2 f .default_trigger = "default-on",2 m* i$ }6 T5 q- s m9 K; l
},
F# R! _3 h) g0 `, k( Q6 l {
- ], w& b3 n" |$ X .active_low = 0,
; L: u# A. `9 @% V4 m+ E4 a Y9 u .gpio = DA850_USER_LED2,
3 f2 [9 g% E* p% Y; L! m$ K# A .name = "user_led2",3 g4 a b$ N) b8 c4 a/ ?
.default_trigger = "default-on",3 `' \0 j: _1 [
},
8 Q8 l+ B: U1 k! t9 f3 m6 i1 X {
% ~% h5 K1 T' {& T" O2 { f5 ? .active_low = 0,
9 ~- y4 `4 ]: E .gpio = DA850_USER_LED3,( _: q" P8 n" |5 E! ~
.name = "user_led3",
9 f* W, E: x7 r; g; E( e( z0 e .default_trigger = "default-on",
2 e' y! x) y3 W$ y, o8 r },
1 h" J ? c( X1 ~: Z};
9 D4 h8 f1 x: `$ t% E/ I
5 l: w. F9 H2 l8 [. x" Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 S+ t8 _* H- y( T+ g3 K .leds = da850_evm_tl_leds,
8 E! n" L8 i8 J( k3 S0 W" Q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- {0 U# j3 e# G
};
' h" `. B# u3 j) E% e# L- z9 f* z6 V' R# I
static void led_dev_release(struct device *dev)3 \9 ]; O4 H: m. w X
{5 ~4 ~: m( I; d% ]
};
r. @& i1 i5 L C/ h
$ e! b) c% _5 ?; @" Estatic struct platform_device da850_evm_tl_leds_device = {- x6 Z3 Q# L5 O% M
.name = "leds-gpio",
# V6 l' y' ]/ W .id = 1,
, L( n1 ~# d9 H% V; A4 P) m .dev = {4 ~4 Z0 C2 x, d- T# Y+ h7 N- x4 y
.platform_data = &da850_evm_tl_leds_pdata,' ^6 r+ i' d; f- @4 r
.release = led_dev_release,) k6 S( G9 w" j0 }" g q8 y" w
}
$ i$ ^. D( o/ f( m7 v};
% V5 I M0 |, H7 ]% `
. _5 l* B/ k" k- h" Nstatic int __init led_platform_init(void)
- f4 L! l' g$ Y7 A{, j. y; z+ ~: D
int ret;
- [6 n# w+ X! o: X' [$ i1 V#if 0& T [, P& Q9 E$ M, {2 P+ Z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ N6 E4 Y& T2 ` if (ret)
! D, V, c- H7 q5 |; K pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% j' L+ \) `- M "%d\n", ret);
: P" k2 X0 `. x4 I7 V! _#endif
) j* j. v+ r7 D) E ret = platform_device_register(&da850_evm_tl_leds_device);
I; \2 u/ K7 @- b- K4 i( D if (ret)
) w* c! h- ^* V7 y/ i8 S pr_warning("Could not register som GPIO expander LEDS");
* X; F6 O' Q# b, ?" I2 d2 t4 ` else
8 c, t9 w" N1 O* r! I9 q( h printk(KERN_INFO "LED register sucessful!\n");
+ p1 M3 z# T( R, V( x( \) O' {4 ?! q& U: l
return ret;6 J( m0 @3 x2 G3 `" `* H/ ~* O
}0 }' F, ^- r5 g, o' v$ x1 J
' d3 k1 @" I7 ~3 k7 `7 _' j
static void __exit led_platform_exit(void)) L; O. T: N6 q V$ O
{
# t$ Y* _5 o ` platform_device_unregister(&da850_evm_tl_leds_device);$ Q, x4 y( T4 b5 l
. t: g2 G, j$ {7 B, l7 q" r3 ]4 X- i# M4 T printk(KERN_INFO "LED unregister!\n");! t" S2 l" j9 `$ y& l
}# }/ W9 P5 s5 b' A4 [
$ W$ J! B+ t5 S$ I" R% _module_init(led_platform_init);' k3 S0 c! r) F" V
module_exit(led_platform_exit);
& j% `6 F5 D( F; |9 P: [; |2 A7 J* x& ?* l. H
MODULE_DESCRIPTION("Led platform driver");7 W- Z/ b: u+ `0 z
MODULE_AUTHOR("Tronlong");& m. c8 \7 a( L4 \
MODULE_LICENSE("GPL");
! ~4 v, w% Y3 I/ X" g8 U8 u4 N8 U! j+ \) W
|
|