|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 A7 k- h/ v, ~& q) r
#include <linux/init.h>: ^6 I, w, M/ B; {4 Y+ F: \' M
#include <linux/module.h>
3 M+ J b/ w8 e( i$ }1 L#include <linux/kernel.h>; R* d. x4 h4 t3 n5 m5 |1 u2 G) {
#include <linux/types.h>
. ]: h$ B: i* Y#include <linux/gpio.h>! T' J6 v* X* _' T
#include <linux/leds.h>
" r* l$ z! a d/ A& O& W#include <linux/platform_device.h>
c: H) o, G5 t' Z3 l" u) o. @
9 U. Q' s( |7 Y5 o, O* ?: G- N#include <asm/mach-types.h>
$ s7 h- I Y0 E% n#include <asm/mach/arch.h>5 V- {6 n3 M {- r2 o" T# K6 t
#include <mach/da8xx.h>" E- Z# H- \- X/ {1 S$ l3 ^
#include <mach/mux.h>( \; O+ N7 A- d$ c- Q' a
( x+ X* P6 a% t6 T8 E* B' j% @#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% q0 i6 q$ g' `5 \
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 e% H. w- y, r) z6 T. }#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). e3 A4 {- U9 d$ M
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- O6 ?5 k( |/ u1 s! \5 j* V4 z. f, }; k5 W
/* assign the tl som board LED-GPIOs*/$ X% ?9 b/ f U3 B+ X ]- f8 f% A! }
static const short da850_evm_tl_user_led_pins[] = {
1 \. E; [. _. s' N /* These pins are definition at <mach/mux.h> file */9 L; O/ c9 l/ N- d( O) w8 z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 `9 X; b8 v* X9 P- P
-12 F, z6 ?/ g% J$ B3 l) D
};+ U1 f0 ~2 J' u5 P3 @1 d- R. O
% b( y$ d2 y$ G! i: _
static struct gpio_led da850_evm_tl_leds[] = {% @6 i8 _8 b7 Z# g8 x; `
{
: ]5 O. i# a( w& N% n .active_low = 0,, z" X$ i6 l0 h+ T, R6 R$ `
.gpio = DA850_USER_LED0,
/ h8 A" d( {3 x* s# [# S .name = "user_led0",7 v& x$ w- A4 e# O- Q) k
.default_trigger = "default-on",
, E7 t9 s" L: ]' d! x },
* ]8 a$ R) v8 r {/ D, g& z; M7 H# w
.active_low = 0,4 G3 a" z, K' \8 }; a& c
.gpio = DA850_USER_LED1,
# k% ~7 c3 U: C- u: S3 b% H .name = "user_led1",
) K' T2 F8 i0 L: }& | .default_trigger = "default-on",% S. N4 G4 B& R% k( g
},# O5 f, m; t4 C6 D/ T4 I/ M
{
. Z% H3 Q& ~2 w; Y# u+ g- m .active_low = 0,( l. r7 f' I7 d! f; ]
.gpio = DA850_USER_LED2,: H+ ~7 z# l* R( \0 U
.name = "user_led2",
5 B! L+ J. l% y! \7 P+ i9 i .default_trigger = "default-on",; _$ t O: m* E
},
7 e) k i7 h) O# a! h {* x/ M! h1 c3 q; i' K
.active_low = 0,2 d9 Q4 B. u4 [ S
.gpio = DA850_USER_LED3,
& W4 E* d" C6 [# m8 g6 j .name = "user_led3",4 q, A* m1 ^, i# ]; W
.default_trigger = "default-on",8 C. j# a$ ` }$ E
},0 a/ D9 T4 U6 r( O
};/ Z* T9 B" K- U k4 M* {
! _& k7 K" {8 {/ P$ u
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 A( \% |. j5 B* a' s( Z/ ~* M9 P .leds = da850_evm_tl_leds,5 ^, b/ P% _- v' Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 }/ o9 N a& v: A};( C) k1 S5 v' C& k
' R( Q0 |3 N) A# y; n5 Cstatic void led_dev_release(struct device *dev)5 j7 o! c0 c% B6 W- J
{
3 I0 e9 D* X l};/ f! w* E7 L1 G
. D. K8 \1 o& U9 z+ E: L; L$ \. Ostatic struct platform_device da850_evm_tl_leds_device = {, D5 d, U8 Y4 V* H
.name = "leds-gpio",
1 w6 \% b7 M$ S7 K7 L( q" i& |0 K .id = 1,% }- s3 K; X% v7 K9 P5 g
.dev = {
9 k5 C/ S$ O( S* J+ c# Q2 k# K .platform_data = &da850_evm_tl_leds_pdata,
; W' U8 C$ G) P7 G4 r& W4 p .release = led_dev_release,
& }( ]& b! s8 y1 i8 Y; r" \ }
# F: @- n. B9 ~; ?9 w7 H2 e};( a" h, P' } H+ I7 D) ^1 ]5 z
% A9 A$ u. V8 X$ p0 S1 ^
static int __init led_platform_init(void)
7 U( K& c# p$ W8 j3 `9 Y7 v: ~, G{% M* Z. z) X) ]0 \. I2 D6 F9 W
int ret;
2 @4 T7 d; [* K/ {#if 0 q; J" J9 { ?9 ~2 t6 f0 s
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 ^1 D! f) V+ M if (ret)
7 m! j0 ?! N p; k) Y" e9 s9 p pr_warning("da850_evm_tl_leds_init : User LED mux failed :", ?! M* Q2 F. f. s! U/ @1 W2 ]5 c
"%d\n", ret);
% x% k7 w3 ?6 p; A% m& c$ W#endif: ~. j2 o- _# t/ P9 H: T
ret = platform_device_register(&da850_evm_tl_leds_device);
) [4 R1 X4 h1 ^& ^. D2 m3 [ if (ret)& z- B8 `8 s& _! R+ W! W
pr_warning("Could not register som GPIO expander LEDS");; z7 k4 ^% [% ?8 w- w5 _5 F
else
, K9 b7 x9 _/ i. @ printk(KERN_INFO "LED register sucessful!\n");
7 h' {; n- b+ c3 [% N
- K& K( N; `0 a, t( q4 p return ret;6 G: r8 y" i6 @. q; w- X! g
}* R' N5 ]% T+ I8 I% P* W* }. _9 B
9 u9 e! u2 _* X
static void __exit led_platform_exit(void)1 k n& U1 V& L# s" D% t2 C( J
{
6 p2 s% t* e0 G platform_device_unregister(&da850_evm_tl_leds_device);
' T9 @; s4 d Q! U0 I! S0 L C; c6 b, [
printk(KERN_INFO "LED unregister!\n");
. S! j, E$ f4 ?. U9 C; q}
4 e9 R6 {. u1 c9 }3 l2 [# w- O5 O; V7 \
module_init(led_platform_init);
/ e6 Q: K& o& c bmodule_exit(led_platform_exit);. l# h+ k! M( P( }6 h3 z, S
6 ]/ t+ M: [7 H6 X+ RMODULE_DESCRIPTION("Led platform driver");
9 f: h9 j1 z1 q1 h. w5 oMODULE_AUTHOR("Tronlong");9 N) O( y- h6 m9 o& g8 z `
MODULE_LICENSE("GPL");
7 r" e& F; y& L7 F: g O. a
/ P$ ]7 q2 E6 [4 Q5 z |
|