|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: e( C$ \5 H( e0 D4 M1 D. X+ U#include <linux/init.h>
5 V6 u% Q4 Z2 q) x1 C8 I! Q#include <linux/module.h>
; P/ @% h! [7 n8 Y, e. c+ J6 I5 Z#include <linux/kernel.h>; F) e' `$ W! G& }
#include <linux/types.h> {% f7 b5 ?2 [3 F, j) a
#include <linux/gpio.h>7 R9 ^, B; I8 e/ \! c7 z
#include <linux/leds.h>
7 T2 ]9 H' z* J6 O# }#include <linux/platform_device.h>
o$ \+ P3 ?5 L5 V" ?1 t
' H$ {3 K8 d0 l+ r( W#include <asm/mach-types.h>, V: A8 W7 z& L. d) W. E- R. o; [
#include <asm/mach/arch.h>
: K& p( _6 E& D#include <mach/da8xx.h>
+ @) Q4 v8 I/ B2 K#include <mach/mux.h>; c, G: A4 [- h# \5 A8 e" W0 m+ B
% e0 O' q3 p7 {! \4 x#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ X" P' f) Z6 I
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% z' C+ W0 V0 e4 X8 m
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# p; Z3 `0 o* G
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! J6 e. j& ^" l4 W
4 b) e8 t" B6 |8 R; L
/* assign the tl som board LED-GPIOs*/& f& L; U& B' q# ^" E
static const short da850_evm_tl_user_led_pins[] = {$ D1 D% d. y/ g( g) x+ g# Y4 b
/* These pins are definition at <mach/mux.h> file */
9 y) k5 M/ e6 |9 V+ J# S DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 _+ I+ p% Q r2 M2 c -1
: K3 K* ^& h8 K};6 g) ]1 N$ K d$ G7 i
. F, k2 f1 {) w% w2 [
static struct gpio_led da850_evm_tl_leds[] = {
9 E. ~' e& L5 u) m* V* p. ]3 @( v {
8 J' T0 j, P$ D4 Z ^8 E% w$ x .active_low = 0,
$ L1 K1 v; m6 ]5 ] .gpio = DA850_USER_LED0,
) `5 F" D- E$ E" q .name = "user_led0",
& |9 B/ W9 f! P .default_trigger = "default-on",
7 t/ o! Z0 t$ ] k },
2 p! b9 f9 B( M/ ?2 v8 s: n i {; q' A# ?& a4 X9 p4 Z0 o' q- p* E
.active_low = 0,
3 m B4 \9 r( d6 L .gpio = DA850_USER_LED1,/ R! {+ `& a0 k; y6 h3 t
.name = "user_led1",9 }6 U1 n9 I* @! d$ P. a
.default_trigger = "default-on",
8 y# {( u% z1 ~! O },6 b& D2 u Y# Q( u' {$ G# i
{0 t2 \% L+ b( W
.active_low = 0,
! ~" q; k: k* P3 m0 F) O .gpio = DA850_USER_LED2,
( Y8 a( ^4 Q+ p .name = "user_led2",! m- L( B! C# ]" k7 W
.default_trigger = "default-on",
) r! b, W' x5 a8 w( i# `* } },
2 c+ c. i7 V" V; @$ U( o {* K @! U( h% }. V9 b; C' S
.active_low = 0,
! s' b3 k$ |" S5 e N .gpio = DA850_USER_LED3,
; R( |) f" p4 k5 C4 s .name = "user_led3",
: U) b* t @; n .default_trigger = "default-on",
) o* X& e' ?( D },# J( F9 Y& T$ @4 I- k8 B
};
8 s' n9 F. b3 D) Z; p. W
5 s1 G2 P4 J/ Nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# B' Y N a2 P
.leds = da850_evm_tl_leds,
$ o _% a) N9 Y4 ^ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 a+ Y* u3 V) s* F};
$ }5 P+ q/ ]$ w% n! X I
* u7 @5 L/ F" O9 y# R4 R! ostatic void led_dev_release(struct device *dev)
3 V8 m- E, b) t{% P1 z( K8 H) l
};
: k6 W9 x; M5 I
, f: p3 Q) l) z% `) astatic struct platform_device da850_evm_tl_leds_device = {
/ T" f( Y/ d1 O# P* j+ u- E .name = "leds-gpio",8 ^& }' x9 L/ [) v0 e) `* }
.id = 1,( H3 N' H+ ]$ Z4 v6 l' Y
.dev = {( f9 A/ K) a" _, |
.platform_data = &da850_evm_tl_leds_pdata,
: h1 ] O; Y' D8 H$ n .release = led_dev_release,7 j( \' K0 @# {( h( n
}$ T1 E' E$ F. u. A) U }
};5 ]' X" j$ \9 ]
1 ?1 |1 Y, h0 x8 i9 d2 }static int __init led_platform_init(void)
; ^4 @# N% J( O" r{# L# c& W. ?( k* O1 y, _! j
int ret;
5 v d2 o% X4 l. [ ]1 K9 y% [#if 0
' y* v$ M) a/ l5 W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 K, J) o1 c7 Q1 D+ r8 v7 |4 n
if (ret)# t4 ]& p- p; o# G( b
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 I2 r+ d- }- V0 j8 T& S1 F
"%d\n", ret);
2 r+ L, t* R/ L#endif
. {' Y6 g: a! ?! l ret = platform_device_register(&da850_evm_tl_leds_device);3 ]% d: D# f. {: L& G
if (ret)
6 M5 Y6 f2 Z% J' o* q- }+ |; N pr_warning("Could not register som GPIO expander LEDS");2 m0 b2 E! A% @- v+ d4 p
else
; R, }; Q/ k" `2 a8 V0 S: O printk(KERN_INFO "LED register sucessful!\n");# [- y* `7 N3 {7 }) V) l0 {4 h
! Y6 h- o! _9 b9 }
return ret;) F- N5 S) y5 S
}8 h2 l- v: V- b0 P k' a3 V
+ j+ U* b* P0 ]$ ~* Z3 ~
static void __exit led_platform_exit(void)& u- \! k0 }# r7 ?3 U, B
{: T3 V1 V- f* G+ }
platform_device_unregister(&da850_evm_tl_leds_device);
" S- L2 Z& c% L0 s, g& _6 d+ `; G3 ^3 t( `
printk(KERN_INFO "LED unregister!\n");
6 l# G# Q# P% U$ K) W, K}
8 |7 l# Z* H( |6 s2 i+ Y0 s
3 g |7 h+ a% i# I0 pmodule_init(led_platform_init);
; y1 ` J, j% U. [+ S* X8 x, |1 qmodule_exit(led_platform_exit);, t c. h3 `, _" x+ V; G& \) q
3 _4 n$ q- P1 g5 x6 ?; W+ u
MODULE_DESCRIPTION("Led platform driver");
" F/ X0 _( Y, R4 B1 h7 A" c- P) HMODULE_AUTHOR("Tronlong");
2 L# v8 }( J j, p) E6 E sMODULE_LICENSE("GPL");
F9 ?4 F6 z9 O1 _6 K7 S
& u6 C$ s3 g& g |
|