|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 q- l+ F8 q+ f4 k$ }/ d" [
#include <linux/init.h>" K2 d7 m/ {( z8 F' V$ _
#include <linux/module.h>! T" Z% ]" D% K
#include <linux/kernel.h>
! l/ `8 u* q" z( ~4 d" f#include <linux/types.h>
, E# F2 {. B3 h& R9 j. J$ s- B& S: [#include <linux/gpio.h>
R* z. f, v& F% n1 z6 Q9 V# A. F#include <linux/leds.h>4 H* K+ K Z* W/ a6 M4 m- P
#include <linux/platform_device.h>% H* D% p ]- I, h$ G9 z
6 c! l3 X. {9 T5 J2 V9 N1 b
#include <asm/mach-types.h>
6 ^* A: ^3 \& @#include <asm/mach/arch.h>
, ? j1 q+ S& ^: f) e" }#include <mach/da8xx.h>
/ _* r# T- \' r; g; ]#include <mach/mux.h>, u* }# K. f+ v4 Q% ?3 r5 s
( h! Q6 V; u/ p* ?8 O#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 _* i" }. b1 j! c! @ E0 g0 l' z! d
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 Q+ r V! \2 c) r
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 D% f, ^- q, M8 e7 b) _6 o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 H5 C9 k9 Z) o. i* U r* ] y& S+ `- ^$ V/ P q
/* assign the tl som board LED-GPIOs*/ F" k, E/ e3 F% p+ `
static const short da850_evm_tl_user_led_pins[] = {: a7 Y' e- o1 Q$ d \8 x% K4 ^9 j
/* These pins are definition at <mach/mux.h> file */5 J: s: \% p( a( F) a
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" }( J! \! C3 X! K: r -1
9 n7 ^1 b! r1 T! P};" ], k8 x% E0 Q( @7 k; n Z; _
1 s2 z: A# M+ F- A
static struct gpio_led da850_evm_tl_leds[] = {' j3 |. a" E0 w5 k( ~! H" }
{
0 ]1 T$ n3 o2 P C6 M .active_low = 0,: u) b) @) R8 q& p2 G/ z4 G7 ?
.gpio = DA850_USER_LED0,
) L0 ]. h8 c% U! j$ H .name = "user_led0",6 C% Y. D; v- p5 o
.default_trigger = "default-on",
# c3 C6 N+ A* _) g: B! }- {5 } },& C7 ] f( V$ ]5 R0 o! F8 F$ S$ }2 z
{
, a; }! K# ?( F' _! B .active_low = 0,
8 C! V/ z: A; \( s0 G .gpio = DA850_USER_LED1,( ^) ~$ h2 V/ r X1 a7 b9 t$ ^ H- B
.name = "user_led1",
$ B' T8 u1 {# I/ l .default_trigger = "default-on",
M3 V: e* E& }/ ?* ?& v },7 H! ?$ f0 T. `, I0 O8 `0 v8 A
{
) I) F* D6 z" n( E2 y$ V" W .active_low = 0,
7 ^) [/ r6 Y" ~# W# N0 \9 P .gpio = DA850_USER_LED2,
3 p1 `2 j/ j3 w, w+ I) v .name = "user_led2",
' B% B1 U G. I+ i/ l! Z .default_trigger = "default-on",7 h+ M/ p Q) {# Y% l9 B1 B6 f9 i$ V
},% { C$ e: R+ o1 i, I
{1 a, _& N0 Y) j' L# s) h% L a# l
.active_low = 0,
! M5 E3 s# b# U, P% Z; M6 b .gpio = DA850_USER_LED3,
; b8 Y6 I' L: l1 \% k+ t( I- x .name = "user_led3",4 X+ o1 A6 d1 |' X# z- w- e
.default_trigger = "default-on",
3 X( q0 C/ Q0 M0 X; u7 B7 z/ A },9 _4 |: q) x) }! [( T8 y& N
};
9 O" i9 E' {; a, S: o* |+ H. u3 @' A# P3 C" v% | h j
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 d% w( n1 M& B( H( s4 {) `8 j
.leds = da850_evm_tl_leds,% p8 ?: u1 v v1 W! f$ s0 }0 k
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 g; F. }1 m$ ]) b5 J};' ^# K/ v N$ o8 m4 ?1 w
9 O* h! l& u+ Q6 pstatic void led_dev_release(struct device *dev)
0 w/ @+ o2 @$ r1 j$ x, W{
8 J; A9 ^; ]! T% E$ a" C1 V};
/ W5 i7 {" b1 e# [2 k f1 K0 @' B6 S ]4 {7 _7 s
static struct platform_device da850_evm_tl_leds_device = {2 l4 D k- j) D$ I' \ N. v
.name = "leds-gpio",3 j4 `2 ?: o+ r" s
.id = 1,/ n; A# J- Y! a Z% |' }2 U+ V, |
.dev = {
% L; W* t, I' T .platform_data = &da850_evm_tl_leds_pdata,
v1 x) O+ \/ X! q .release = led_dev_release,/ U d8 \! k, ?* L
}
9 E) A4 {3 [+ S! B: I};& g5 t0 j* [9 ^7 |
. T2 B7 q. I+ N& N
static int __init led_platform_init(void)2 G# r) W$ C- T$ N8 m
{8 V6 ^' i" f# @* r' B' i
int ret;
9 z& ? a& C& @: M& C1 n5 T+ X* f#if 0, C* q8 }; R' P+ O
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: a) u' z/ N a( @ if (ret)& F! |" ?/ F8 \2 J
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") I' H( Y( \, w( ]& X
"%d\n", ret);3 A, Q1 \0 d6 }) J4 }" T
#endif
% V1 p+ l8 f$ w( M ret = platform_device_register(&da850_evm_tl_leds_device);4 \( ~% A9 f! l" ^, V) k
if (ret)
4 w) Q0 d& h8 \0 `) I' ] pr_warning("Could not register som GPIO expander LEDS");
" T6 E" H" D% o! {4 _5 Z" Z9 w else
7 L: j! q, W" }; i; p1 ?, k printk(KERN_INFO "LED register sucessful!\n");
( ^" R9 s6 F, q5 N! h8 \* c0 C( T \5 [# c0 A
return ret;' Z7 S4 q7 x/ \" D& e
}' a0 s+ |5 b4 c1 \
) \& M7 R# W. K0 istatic void __exit led_platform_exit(void)( x" c* N' N. E8 ~9 ]2 M
{$ p* v. b; I( @7 T8 [( @( r2 l
platform_device_unregister(&da850_evm_tl_leds_device);4 N# Z) v3 R) l
N& o& s6 E2 a3 G; Z# u* O8 j* u: k
printk(KERN_INFO "LED unregister!\n");
" ~* O* w! b4 l/ [- y: L}
, y" {% i8 o$ _+ P
; k/ W @* ?9 T! T' Q9 J! Nmodule_init(led_platform_init);' D# H4 X' p8 H. ~/ g* H& e
module_exit(led_platform_exit);7 q$ Y# b0 r3 C4 z7 m$ l5 i
# d/ o/ Q) b F4 b5 \/ N: R yMODULE_DESCRIPTION("Led platform driver");
: |8 D4 K7 L1 a& y9 q( hMODULE_AUTHOR("Tronlong");
* r5 D1 I# x. c/ U3 A# @MODULE_LICENSE("GPL");- H8 `5 Q) c& q0 Q! y8 n1 V
. y& l$ ?- F/ g# g. n( z: C |
|