|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 t. K0 H0 P: a6 {2 N# w$ `
#include <linux/init.h>
- w! H& z0 |) k8 Q% y5 Q#include <linux/module.h>
( [) E! k' d, Q( w#include <linux/kernel.h>
+ p9 d6 X5 a9 i% ?% m( X( ?, y' I8 c#include <linux/types.h>
- f6 F- }4 T/ ^' p7 ?( _#include <linux/gpio.h>, j; `$ I7 G9 u. J
#include <linux/leds.h>
' _* w' u0 ]+ i! G+ c#include <linux/platform_device.h>
& r/ ^: u/ u4 P4 D" _0 }& ?2 h x$ |2 ]
#include <asm/mach-types.h>9 v: }! W4 l, |7 _
#include <asm/mach/arch.h>0 r& w% [2 Q" @- }3 ]
#include <mach/da8xx.h>2 `$ P8 c0 k; f" ?/ P' e
#include <mach/mux.h>
. ^* A4 R& j4 f& L: W, ?
7 B% Q. w) }4 n, D0 F% j#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 N# [' M3 C6 m
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( u" t+ ?' e6 p
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). P- F& L/ O) P- N% [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# k: d( H6 P* D6 p: ^2 o
! z% |: e. ]* s9 i+ W/* assign the tl som board LED-GPIOs*/
4 L, }) J h. L: [- Lstatic const short da850_evm_tl_user_led_pins[] = {! a4 d+ j% f' ?" Q
/* These pins are definition at <mach/mux.h> file */* Z: ?2 d4 Z9 I* Q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 _5 v, F8 o5 B -17 T0 Q6 M7 g, A5 h! g
};
+ v7 r/ K' J5 y8 k1 o5 ]
( x9 n9 M1 [) ?2 h3 T! t1 A0 b Nstatic struct gpio_led da850_evm_tl_leds[] = { W u2 L% s' \* Z. b3 T% ~2 U, F
{
1 C( W1 k5 s# Q; J .active_low = 0,
$ P3 y, {' G8 U. @: G .gpio = DA850_USER_LED0,
( r# Z/ H$ `4 q; Z6 [1 x, N .name = "user_led0",
) x% W" ^6 S/ M- p' D .default_trigger = "default-on",
7 g! j" `7 _; T$ `# i& B },
# ~; O2 ]3 V1 d" U {
7 r% G. [2 m) Q, u* \* J* d .active_low = 0,
# y, e' r% ^' c3 S3 e7 | .gpio = DA850_USER_LED1,
. r' A% `4 R' O3 o* n .name = "user_led1",
* Z' C. t5 [. @5 u .default_trigger = "default-on",0 c2 i8 N/ Q$ T+ G. U
},# t( \5 A8 j$ R( A3 e2 }
{
& t7 q+ C, n' }7 r( \ .active_low = 0,+ Z; A. u! Y/ P7 x" v$ O& D
.gpio = DA850_USER_LED2,
) g7 o% x- p/ H1 i .name = "user_led2",0 H# o* @! ^% Q; ^5 B4 n7 d# u' I
.default_trigger = "default-on",
' J/ [3 Q$ p% a6 v& h },
) L2 r) G7 q+ Y1 z6 R% X+ ~" h* g {
9 t6 v2 Q v8 \' U4 \' U .active_low = 0,
& {* d# Q% ?0 I: @" [* v, e; P .gpio = DA850_USER_LED3,# @' I5 E; N$ V, t D4 z
.name = "user_led3",+ V! ]) f2 ]2 ~$ u. u5 {0 \. A0 D
.default_trigger = "default-on",( j7 }" _8 F# \" A7 }
},
* ]7 d1 q% b( Y& t1 {6 w* N4 g};2 y; \, V) Z- Z+ m4 f8 C7 k
4 n0 ? o/ n j3 G1 f% Q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 y4 h: | ^; g0 J. k' L
.leds = da850_evm_tl_leds,
! U# c, B% F# _- U$ ~ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) r4 _, D) ?( L9 u- n
};
% m( r1 ^1 e% T$ ]$ a+ ^% l2 S8 `* U
static void led_dev_release(struct device *dev)
# X2 m: }) } V/ g# N{
# q1 L* |4 }% l. V. E# ~};
0 }* v, ]' d( s7 M# Z6 a0 F- u9 V4 V
static struct platform_device da850_evm_tl_leds_device = {. B3 ?6 U: t9 b0 G7 q, Y+ r; u
.name = "leds-gpio",
3 t! |; _2 Z$ \. E7 s% ]* z .id = 1,
" T" s! b, C9 k6 w .dev = {2 d- P3 u6 A2 C1 N! e9 J
.platform_data = &da850_evm_tl_leds_pdata,
$ A- q- ^$ }7 B$ _; } P: \. H .release = led_dev_release,3 Q1 I# F4 p- @# S+ @
}
( g F" @0 |0 M6 j7 I _};
% o& _0 Y6 C ^7 O& I) L l3 T9 q6 Y. A' Z( d) B/ X* t
static int __init led_platform_init(void). L4 g9 N% W1 L2 d
{
0 B6 ?# H1 d* E; X w, d int ret;6 Q7 ~, C( x! n# C) l0 ?& ]
#if 0+ t# f) N8 I6 m* e2 ^( G9 t5 ?
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! R) g H( V s if (ret)
" r/ O" j! X; G) U+ r1 S7 l pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 B1 ]$ Y" \1 x
"%d\n", ret);
i: a+ R, Q4 E; g#endif
) _* I2 @. Q: Z" {* \0 |& C) o% J ret = platform_device_register(&da850_evm_tl_leds_device);: P( m) k: V3 W; r B9 E
if (ret)$ b% a# N+ T& L. u7 V$ V
pr_warning("Could not register som GPIO expander LEDS");, N" h2 h) [% w% ?
else
. L; Y2 d4 e% x( Z5 L printk(KERN_INFO "LED register sucessful!\n");! E9 m! Z: n( b/ q: T& Q+ N
( N- x- I0 @: w: V$ S return ret;
, w7 D N' [' Q! C! F! O9 O: |} B0 d2 a( U* O- C" D
( {5 L- x z g! I3 Ostatic void __exit led_platform_exit(void). x& Q3 r! v. b, e
{; @7 W- l8 }: x" o, I% ]4 D
platform_device_unregister(&da850_evm_tl_leds_device);% S! V3 _& x# q6 a5 w* ?: h
9 b& I4 d: M: J2 [ printk(KERN_INFO "LED unregister!\n");
9 ]5 h: t% s9 G- U# P! D}2 n5 J% I; @0 d" c! p
! q' t0 d" A! t, pmodule_init(led_platform_init);
$ Z# L. E( p7 J9 w* @module_exit(led_platform_exit);' q) z( D. B2 d4 b9 F2 \
9 B+ m+ t; f/ aMODULE_DESCRIPTION("Led platform driver");
0 J; ]/ B$ t/ m9 }MODULE_AUTHOR("Tronlong");
& A0 a& {! K# F! _7 S4 q4 |+ KMODULE_LICENSE("GPL");& |2 r( K& B0 A
6 y) f. i4 U, m5 e Y5 x |
|