|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 b5 Q# X; O& D. g: N$ v#include <linux/init.h> B9 W3 O+ e. V5 F$ ?
#include <linux/module.h>
2 [3 z6 s$ ^, b1 P, ~#include <linux/kernel.h>4 X8 t* I) G/ W+ L
#include <linux/types.h>; Y0 B5 V6 _$ q! k Q
#include <linux/gpio.h>+ h, M: T [$ I, H% n9 m
#include <linux/leds.h>
3 V8 D; H' }2 L#include <linux/platform_device.h>
2 O, |% u1 G/ Z* X; o K
5 U6 N1 C+ H* m. k#include <asm/mach-types.h>
" r3 z- q9 s/ Q3 n2 c#include <asm/mach/arch.h>
( n. A0 v: [) U" f! k#include <mach/da8xx.h>
* T9 Y: K; j, k2 i2 Y( E6 G1 E# E#include <mach/mux.h>
& q" ?7 a; Z! ?0 b4 x* ]* a3 d6 w K! H4 Z& K
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& Q* D4 s/ L3 b. y- k. B; _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 `4 z% E- ]8 J$ |5 O& [! T1 }6 [
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, W3 G. F! P, [& R1 F$ k#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! i& Z# i$ Q) y: I- y
% x( l p }- H2 S0 _8 K5 P/* assign the tl som board LED-GPIOs*/ A# m, w) J2 g
static const short da850_evm_tl_user_led_pins[] = {/ ]% p3 O. G9 y
/* These pins are definition at <mach/mux.h> file */
/ a8 Q! }' n3 h% i& K DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# P3 q2 Z3 N2 w8 k& G
-15 E& _, q7 V; A; R* f- ?
};
9 ?5 E/ i4 D" O) t6 t7 s
: n; c2 W+ n: V& H0 Tstatic struct gpio_led da850_evm_tl_leds[] = {; x+ G7 G2 D( Y( \ p8 Q; P8 t
{5 r; \) B9 w) Z' w% v
.active_low = 0,
X- v% S5 e5 [) ^- E" }& ^6 I .gpio = DA850_USER_LED0,
) c! \: L4 g2 _+ S* B .name = "user_led0",1 o$ Y: U( U+ d$ l. k$ F# l
.default_trigger = "default-on",
4 P: h: S7 j! c) o },
( V$ ]& H9 Q0 m" f4 z {
u& W+ d6 D; R .active_low = 0,
% C( J! Y @; w7 T$ z0 I .gpio = DA850_USER_LED1,; ~3 Z# h( o' |4 ^0 j
.name = "user_led1",
5 P, d( y! s$ j' B3 C9 | .default_trigger = "default-on",6 u7 K2 ?$ c* g' E
},
9 @& w; _8 d9 R2 s! J9 x {
, g2 |# }! s- V .active_low = 0,+ k; E, g7 E# X
.gpio = DA850_USER_LED2,; q; _, I& ^$ p# A9 [! h
.name = "user_led2",
6 }5 A8 \% g: y; N% S( t3 {$ h .default_trigger = "default-on",2 O5 ^# x! y5 V6 h/ \3 [
},! K$ B+ b- o4 W1 s& n7 G3 o7 d/ O/ W
{, z& J# I) O! [' |! w
.active_low = 0,
" a/ t8 T% C0 k6 v" V" ?2 W .gpio = DA850_USER_LED3,% M0 B% j0 t* o
.name = "user_led3",
, c8 y, J) t" D/ M; [, R .default_trigger = "default-on",; S$ y e6 [1 E; E
},6 t" g2 n- c5 c; j) T5 F
};) f7 b# N4 u0 n9 p
; `4 p; ^* {2 X i5 J' astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = { j+ |, x5 w& V. {: U: [
.leds = da850_evm_tl_leds,: ?& O# s; Y+ Z# M
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 T6 Y) j: ~) C6 j8 V
};! T( M y6 a- ~ ]5 @
0 \6 Q/ ~! P# W: I
static void led_dev_release(struct device *dev)
4 t: x! Z' t, S* `{
( l4 W+ r- w0 m8 { n# R};
$ N5 X& S: F( E: p1 ]2 t0 m3 Z N3 b+ v$ M0 }
static struct platform_device da850_evm_tl_leds_device = {
. b0 e- p/ ]* M0 l .name = "leds-gpio",3 j. _) h6 q* \( U" x/ j
.id = 1," B# Z3 L8 _2 J9 R
.dev = {4 \3 ~) B* L0 o* V+ d; }' A' d7 _
.platform_data = &da850_evm_tl_leds_pdata,
5 P& s j, U: @ .release = led_dev_release,5 P" i2 O/ A( _3 F
}
3 F1 }5 _/ M4 v, T8 l};" i+ o) t( N1 b
6 k. @+ W$ \' A+ y
static int __init led_platform_init(void)2 T5 Z3 f' j, m7 w+ ~- C- o& }1 O
{8 Q8 B! c+ x, a, `& T7 O( U
int ret;, M( S8 J' i, q) c" i
#if 0* N2 D/ H7 ^8 p* v
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& ?' R H/ ^% `4 ^% V" R if (ret)3 |# D$ V* n5 l# t% [
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 |- m- B2 }9 b2 A
"%d\n", ret);! m* | A: t7 }# L$ W' X& e1 e
#endif& o$ l; p( p) O c
ret = platform_device_register(&da850_evm_tl_leds_device);
! {$ n# V/ s) `1 t9 {( S6 l if (ret)
1 e7 m1 S; H* P3 q+ s7 X pr_warning("Could not register som GPIO expander LEDS");0 Q2 r, r1 G8 |3 I$ V4 F% D) J8 u; J7 A
else1 K0 e# F' X' y* W5 Y
printk(KERN_INFO "LED register sucessful!\n");
. ^7 s/ H$ X Q J% e o( z5 K3 L
return ret;
+ b8 c; s7 i$ ~} L+ I2 L/ G0 N
+ U8 O0 w7 q" z
static void __exit led_platform_exit(void)
8 }6 d M2 N4 c+ y" w{9 N/ @# h) e: o+ l/ P
platform_device_unregister(&da850_evm_tl_leds_device);* K! y" C# h& a( k5 F0 K; s+ K
- x7 A% {4 w( b! z$ b printk(KERN_INFO "LED unregister!\n");
0 I3 u6 Y' c) X' u! B' e}
4 L8 z l" h+ {! a& b) M& p2 F2 h1 e/ p+ }2 q5 S* G8 e9 ?: Z" P0 _
module_init(led_platform_init); [( t4 ?3 O/ o' A8 L( X
module_exit(led_platform_exit);1 p5 x' b- M, E
9 I& b$ K2 {" l! e9 S4 F) ^" d
MODULE_DESCRIPTION("Led platform driver"); {/ R2 `5 H- x3 O! t
MODULE_AUTHOR("Tronlong");- |$ |( Y0 O% J& V
MODULE_LICENSE("GPL");
& y6 n4 l. o/ w) `/ Q/ M9 n k1 \/ n
|
|