|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. R' @. N/ \+ C
#include <linux/init.h>
. H) v. I$ J K/ a. V4 M#include <linux/module.h>' Q; _4 p5 {* }
#include <linux/kernel.h>
9 }$ |- ?1 H8 Z( i9 z2 `& @" v, P#include <linux/types.h>, K& w& B B# F; o. s9 ~
#include <linux/gpio.h>
/ M T1 N2 S% h/ B8 G#include <linux/leds.h>
9 x5 j) z @- h! O#include <linux/platform_device.h>
& ^! a3 M E: K, W. R
; m! {/ ^* W! s4 |& F#include <asm/mach-types.h>7 J6 j. [) W6 ~3 b6 W8 h: V# o! p
#include <asm/mach/arch.h>8 E% S' b1 n. r! }7 \% q# b
#include <mach/da8xx.h>! E9 l/ {4 H% X5 A; }
#include <mach/mux.h>
2 G) x- x8 {: b z; t$ }# c
( `$ a4 D9 r+ K0 M3 V4 z& d#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# |* W; U; L( u* A
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' K' W, P' y1 X. \5 ^9 X Q/ ~#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* `+ i: U$ O$ O9 X- O0 n; a
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* B7 y8 Z+ p9 d
6 V* f! } r8 R( w* X0 S. b9 `/* assign the tl som board LED-GPIOs*/; Q; M4 k* O+ c* g) [: h
static const short da850_evm_tl_user_led_pins[] = {% P5 H( f8 [7 A% L: R- S
/* These pins are definition at <mach/mux.h> file */
, [2 D3 W8 X3 @0 d8 N+ I DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ k: W% p, `2 T+ Z$ n& L9 N3 V -1 [9 z( L6 j6 L
};
- G( O2 k/ c u/ o+ z/ x! @5 \% [* n) _2 v; [
static struct gpio_led da850_evm_tl_leds[] = {& Q) O0 P: e, ^' n2 h# T
{$ d6 d) }$ P @9 C" w
.active_low = 0,
; Z H0 a- E7 ]1 Y9 y .gpio = DA850_USER_LED0,
& S" ~$ n, y; } .name = "user_led0",/ v# |8 b" g1 }0 C' Z
.default_trigger = "default-on",
; Y0 j& o9 B$ W$ n; u },
5 }5 t4 g& G }" g9 ?! P {) b+ Z. o# A4 x6 e/ ? I; [ b2 H, t
.active_low = 0,0 j; t% \+ E! j5 a% S$ V: `- W3 ]* K
.gpio = DA850_USER_LED1,9 Z2 H7 s% l8 l/ k
.name = "user_led1",
1 G0 t4 J/ Z/ G6 W4 q .default_trigger = "default-on",3 V+ P/ z+ O6 j2 I5 i, {
},
5 u; k6 {# Z7 O {- R4 [' `' s; E* [
.active_low = 0,2 g) Q8 j0 t2 v) d
.gpio = DA850_USER_LED2,
5 K$ y$ E9 @: T: e .name = "user_led2",( T/ s! _" v+ H& b8 o( n |
.default_trigger = "default-on",/ S" b* D. M/ |' y' |' r' a, E
},
3 p- F( ~3 W' D6 Y6 j* H' H {1 @2 m, t% t/ F0 ?+ Y
.active_low = 0,
* h1 r# y J# j- v .gpio = DA850_USER_LED3,( V& e+ s! f: l4 f/ h1 h$ c3 o
.name = "user_led3",
2 ^, ]! K8 K6 s. p* ]$ R) Q; t .default_trigger = "default-on",: u. F0 A; ?. w( w
},( H+ `0 d/ [# g$ ~2 b
};; \$ f# H& @' Q4 L4 q Y" w
9 [! ], A5 V- x
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! L# W: x( x) O
.leds = da850_evm_tl_leds,
' T9 s% y; t' v: N+ |% v .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ A7 u# ?0 ~9 x% @8 O; K& e0 g};
. |& p3 B7 D; e3 }+ Q9 m5 \% Z" L& B1 x( o' M
static void led_dev_release(struct device *dev)
9 c0 O2 [5 b3 M# Q1 @- A5 T: [{
6 j; N& Q5 N: J8 j c7 O: ]};2 Q& ?* w9 F' P9 D; D
$ {" q1 Y% q- t" v4 L7 r# k
static struct platform_device da850_evm_tl_leds_device = {
# R% w" O% g) D( C2 P) i, x .name = "leds-gpio",
# e+ S q- W: `8 e3 X .id = 1,4 h! H( Z# X9 i* _/ G3 @
.dev = {* h# {/ c2 Y# u1 J
.platform_data = &da850_evm_tl_leds_pdata,( w+ f& }4 W' G, }# h
.release = led_dev_release,5 t; k5 s" O7 g, s; x/ t4 {
}
2 v& e' J# @' U4 c};1 Q+ V0 O2 d) L: @ b
4 N! p( H. F& v, ], i M: m' x
static int __init led_platform_init(void)) q, U" `2 H6 k
{
3 m" E$ m0 l5 ~# e1 i* U; W) C6 |! \: ` int ret;2 g% W' j' ?1 ~, J' s/ U
#if 0% g+ [" i& j% |- D4 B- c
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); ?: O3 R3 U2 g, n! w
if (ret)% ]' X7 A8 F& I5 Q9 w6 T! U
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 n# O$ ~* J) W9 Z8 G+ j3 @* ~$ P* n+ q
"%d\n", ret);
' k2 ^, t0 C5 V" T& N3 X#endif
' }( }7 K0 Q3 i ret = platform_device_register(&da850_evm_tl_leds_device);
# I6 _: A+ O+ d, ? if (ret), H4 `2 |0 i8 N) |
pr_warning("Could not register som GPIO expander LEDS");
/ O: q: c& m1 D* B, |2 w* i else: q* e) K4 ^* c. M$ D& ?/ D* U5 \
printk(KERN_INFO "LED register sucessful!\n"); i: Z+ l; F. V
& W8 c+ W: a, y( K$ L. Q return ret;
" V1 X$ J$ q! s1 T+ |}* H0 G) b: P/ o; A4 T! _$ c ^
1 P4 P9 a K8 Y+ X5 \; n9 V: w6 n! E/ Mstatic void __exit led_platform_exit(void)3 J; F( w! R5 k- ~8 g8 Q: x, C
{
. n* n5 f9 f: x/ B- f- x2 Z9 D* A. N+ i$ O- G platform_device_unregister(&da850_evm_tl_leds_device);
: Q- f0 K, O0 J# Y: V
) X2 ^' n. t5 w1 M- I( ~ printk(KERN_INFO "LED unregister!\n");
/ X3 I" ~+ M, p1 M1 A: q2 y}
4 d3 x5 b% K7 }1 j9 l( l8 R3 h3 W/ B7 F3 u9 y- l8 G' `
module_init(led_platform_init);# N: [6 y/ p3 {2 [0 y
module_exit(led_platform_exit);
( r. B3 k( G) s. E3 z/ `' C
% n2 Z) R- _% M7 a* HMODULE_DESCRIPTION("Led platform driver");/ g2 T) `2 p4 M$ r) K
MODULE_AUTHOR("Tronlong");. a, [, B% B2 H* r' v
MODULE_LICENSE("GPL");
& {* e% ]- {! ^" k) J h1 s0 M2 ~1 J+ Z. d) y* B# y! |1 c3 ?8 q
|
|