|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 q& q {0 l: i2 }- J- c& t
#include <linux/init.h>& h! R9 b6 n' _4 Q3 V3 E1 y5 z/ _
#include <linux/module.h>3 @* G) w' x1 l
#include <linux/kernel.h>- w. u' F: \. ?
#include <linux/types.h>
5 J3 s, h# f/ V) [/ w#include <linux/gpio.h>( s* d' i. h9 |5 z3 h/ g. r
#include <linux/leds.h>* m# p& _8 H9 i( D
#include <linux/platform_device.h>
5 p$ Z2 L/ l: o) h; g# |: x. p; U! y5 I% e, U0 p7 r+ E7 u
#include <asm/mach-types.h>
' N0 {# \/ t3 F( A' _4 B#include <asm/mach/arch.h>
. q2 K3 \5 n. R/ k#include <mach/da8xx.h>( u# h! E7 `& `( w$ R2 v
#include <mach/mux.h>
, i. T! ]- Y: a- `! p' U
* `# l) s' O- V: b#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# Z& I: c1 G6 \9 M6 v) e
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 e+ F' F5 u& Z. K* {# L# `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 z+ K* J+ J. m0 g0 [5 v/ c#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" E% ]: o1 y6 g0 v9 B
7 O$ U K: K+ m2 {
/* assign the tl som board LED-GPIOs*/
+ ` Q% i$ {3 u: T I& h8 d4 ystatic const short da850_evm_tl_user_led_pins[] = {
' e m5 C; H3 c/ L' w /* These pins are definition at <mach/mux.h> file */
" j- c( e: J+ H8 I7 F: q8 \ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 {: f1 y4 R, k9 ~3 V4 @
-1! l2 h; V' U$ e. E( {1 f
};4 }' f9 Q' o+ ~4 k3 a
, M1 z* f* Y7 x' Dstatic struct gpio_led da850_evm_tl_leds[] = {
- ^0 f% R- w0 y0 k% N {0 a! h9 \) H8 `2 S, A
.active_low = 0,: C4 h1 i g; q9 B
.gpio = DA850_USER_LED0,
$ c }! D; d1 T4 \7 u, u .name = "user_led0",* e+ y9 t7 Q% |4 T; o: W
.default_trigger = "default-on",
$ ^! T) q9 {" L# M# Q" ]; f },; C: z$ t) K" i; k) `
{
% A0 Y4 E. L: ?- s( u1 ` .active_low = 0,
7 F) q; e2 D2 E .gpio = DA850_USER_LED1,
; b& d; z' }9 n5 L .name = "user_led1",
& z# y# A* |- t9 o .default_trigger = "default-on",; T O# D' X0 z8 P: r; h
},
% ]5 `* o) E1 r {& H. K2 M9 ] C! R' L9 ?! k* t
.active_low = 0,1 U1 Z% N' N* C' m6 ^1 @* P2 @+ t
.gpio = DA850_USER_LED2,
/ l1 T% Y2 x4 S2 G( y8 r$ w .name = "user_led2",3 M6 W8 h0 w( v9 O: v
.default_trigger = "default-on"," h/ B4 I) p7 n1 t* {5 o
},1 Y' {3 C. ?& u
{
; M6 }' I: B- z1 ]9 X5 J .active_low = 0,
. F T1 G$ m o .gpio = DA850_USER_LED3,* }; }3 j \ S# d p, w1 @/ w
.name = "user_led3",
) B/ o, n% y2 ?: c; C .default_trigger = "default-on",( a1 d4 g4 \2 h/ s$ w
},
3 ]8 h; {/ v# x$ h$ r) \};/ c2 E6 ^( [- |" V- M0 n; \
2 m# Q! K2 p" Y7 b2 A2 Z' s/ v2 Xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 ]0 ]6 d [$ F3 O7 U! a .leds = da850_evm_tl_leds,
: |) }; u& ]& _* t5 { .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 H6 w! b3 t9 ?& |3 O};) a$ c% G$ Y+ l4 G
) R( c# n$ G4 w
static void led_dev_release(struct device *dev)
/ d2 P9 C) z: I5 y{. v& Z3 [, ~: z+ ]8 L- Y
};5 q$ z$ f1 U$ B, `; T" t8 p6 B( G* a
& d1 C4 D/ n. F& M2 b* H
static struct platform_device da850_evm_tl_leds_device = {# c! ^9 f% D7 a6 X# ?/ H, X
.name = "leds-gpio",4 o/ X4 Y# ~3 t; P! @/ S5 z+ _5 ~
.id = 1,' m0 q0 k+ }. d$ c u
.dev = {
! ^# {* x) W0 h0 a& G7 I; A .platform_data = &da850_evm_tl_leds_pdata,- \' U- Z3 ~! I% ^0 V! p
.release = led_dev_release,) m; p* T2 z* I) J. i% d% M3 P
}
% h) I2 Y- S% j3 y/ { g};
( z5 m3 J9 _3 G9 E% @. {+ ~
/ w+ ]; j: B+ R* U( X' g' Qstatic int __init led_platform_init(void)
o8 k. V e3 s9 E; Q{) ~0 S! ]& n {: s% c) N
int ret;
R9 n0 P) m4 ~+ y1 A! F9 a#if 0
# L* s6 I% v( ^% s1 A ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& S% E# T4 i5 Z$ k4 T( a( \; E
if (ret), j5 X" D1 J0 ]
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( ]6 b* l& c5 \ "%d\n", ret);
8 { S& F6 V; y3 e; P. I. w#endif+ T+ ~ k4 ], f
ret = platform_device_register(&da850_evm_tl_leds_device);
, T: R! I: O8 W+ Q# V if (ret) `& _5 T3 M a. z7 b, {: j% X
pr_warning("Could not register som GPIO expander LEDS");! I5 Q/ I2 O& |8 x4 V' [5 A
else
- m; l% v& c7 r$ }' z6 V printk(KERN_INFO "LED register sucessful!\n");. Z7 Y- x" D) E" W
$ X% W p% Z [ return ret;; H3 r2 m6 X+ P) z5 Q
}( E* ]* g# o9 w z; v4 w1 S. N% l
1 g V# ]. n& K; y! B e- w
static void __exit led_platform_exit(void)+ L/ T2 T8 _3 K+ m8 P( A4 V- q
{6 M: H3 p5 k# x) T3 D
platform_device_unregister(&da850_evm_tl_leds_device);0 e+ s. C. h ]9 q) H- T9 a
+ |0 s1 |% l0 M2 z printk(KERN_INFO "LED unregister!\n");5 P: [$ @- \, l D; T
}# |4 s# l2 f$ G% W
: _% K6 O- U% A1 m5 Ymodule_init(led_platform_init);7 L$ @7 e+ w% X* P5 c( P) p
module_exit(led_platform_exit);: v' L# f- e5 Q5 p# W ?
3 t5 \- B3 s3 ?. `' L6 _& k5 zMODULE_DESCRIPTION("Led platform driver");
5 ]8 ~6 j) w ~MODULE_AUTHOR("Tronlong");
2 Q& _2 h. K9 `+ i$ nMODULE_LICENSE("GPL");6 I' L$ C- j. ]8 Z+ ?3 T# b
8 `7 _$ k- q7 ^. s
|
|