|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' O9 c' \1 ^" }#include <linux/init.h>
3 p6 a |- m- W% v, T L- P& t#include <linux/module.h>
# E& U' ~8 E! ]6 E: K- T#include <linux/kernel.h>6 R& T" }3 r$ R
#include <linux/types.h>) |0 r7 N2 g1 W& K0 C; V, d
#include <linux/gpio.h>
" M/ S; N& @ E- o& M; R& w' W#include <linux/leds.h>
# ^* J8 E$ W9 G#include <linux/platform_device.h>. `2 ]- t* p8 I: I! ]
# l! ~( l* N0 ~4 X9 l, ?5 m& R#include <asm/mach-types.h>8 C8 A; k9 k+ T+ A' T& n" ~+ T
#include <asm/mach/arch.h>
9 M3 C+ \" {! u6 e#include <mach/da8xx.h>4 B) M( q) x0 \3 u. w3 Y
#include <mach/mux.h>4 g: c$ O& y" }
' o b. h! u, j1 j% p$ D
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* s d, K9 l2 C
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): \# O3 u, X( \4 u$ L" d* _, p& r" x, ?
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- P, f+ o) [& d) g6 ?. Z- Z- C. \$ }#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% L1 L( w" y2 B. M; M. u
% `9 `8 o: e6 `- |) N7 d# k
/* assign the tl som board LED-GPIOs*/
# D4 F! q0 H+ E1 m% {: gstatic const short da850_evm_tl_user_led_pins[] = {
; @+ _* z3 w' `* P, f$ r /* These pins are definition at <mach/mux.h> file */
8 Y' ^% T9 \+ Q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 e* ?- A* l& F/ `; Y! t; j% {
-18 }, x* l; a! S+ \
};
: W2 ]$ ^+ w( E" o7 `- }1 D
( D) c: r4 l6 qstatic struct gpio_led da850_evm_tl_leds[] = {# {" q& N! c3 W% F6 W' M- h# W
{
, Z9 i" U; b( q! c .active_low = 0,
% e$ w1 ^6 F) I/ J9 U .gpio = DA850_USER_LED0,/ i. q) D. f8 N9 B: ~5 ~
.name = "user_led0",
) ]# z6 K& f0 }8 W) [; A$ A .default_trigger = "default-on",6 I& @+ o: d C* W, J
},
; Y7 d- c7 c2 z% Q {
0 R1 |& o1 R" M) c' b8 l .active_low = 0,
8 s6 B; G9 H7 y( R/ q0 ` .gpio = DA850_USER_LED1,' b( L* P3 ^5 H
.name = "user_led1",
" I( H1 j8 v% T$ Q" k! w/ v .default_trigger = "default-on",
N" X: O; B* t* n/ k- H: G },( O7 H" M1 f+ S! t) M8 ~
{
, Z) R! e( Q# x. Q; z- W! G .active_low = 0, x" q3 |- M2 E$ I
.gpio = DA850_USER_LED2,
- k1 @$ V. J% R w9 g$ ~ .name = "user_led2",
" v+ H, w8 t) |( d, |6 A7 f! D i" r3 o .default_trigger = "default-on",
. a2 V7 E& G* w/ ~) a" T E6 V },
( X4 l1 \8 N3 u4 p {9 w5 {5 a2 y* m! G8 p4 D
.active_low = 0,) c. v# i9 d! p) [) o( B
.gpio = DA850_USER_LED3,
3 z6 \( d( i5 g! o9 K% z .name = "user_led3",
) A! V9 A8 G# }! E .default_trigger = "default-on",
, k" R" t& `1 M4 o. C4 r. Z! V },! U& z* i% N# Z* C. k* t; r1 J- x
};
; w6 V& B( w7 ?' ^* ?- Q8 `" K7 {& B* e2 W& v$ t9 r# R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, J* G: @ f' S3 [' S6 i. C .leds = da850_evm_tl_leds,
1 I+ W. b0 @0 X. V+ E0 w0 _8 |7 o .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; U1 _0 M& K- H/ `4 a+ c! [};
6 |1 [/ ^1 D- q& W" B
: A3 Y- q! ~# P" c& [8 t* u: zstatic void led_dev_release(struct device *dev)% u3 V H' s! j$ Z8 t
{
" B; Z$ }, _# r; g};7 w. J6 l% A7 Y. ^" L2 [9 L$ n
1 h% G v/ r$ x. Qstatic struct platform_device da850_evm_tl_leds_device = {
1 ]/ C$ s Y: d .name = "leds-gpio",0 m1 O0 Y" r! @6 v; A" ]
.id = 1,* o' r4 ~7 ~) z( V, n' ]( { D. F
.dev = {
7 c+ s/ K1 S/ a9 `) x# X .platform_data = &da850_evm_tl_leds_pdata,' t# O/ A u' L& W) P. ~5 t
.release = led_dev_release,
* [) g# B1 F# K" \ }
4 K2 N+ A5 Z d4 r; V};9 [+ ^9 k8 T9 U; F. ?, T
; P7 t0 `; ]& B8 p$ O n% U; p% fstatic int __init led_platform_init(void)( C8 ] F$ v! y8 P6 [" z7 _
{- {5 {; Z3 V( B, m1 `! |
int ret;* B# W8 s& O O5 l8 d4 c
#if 0$ e z+ C* [, G q. q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 @1 C8 H' o& r- `5 r2 _
if (ret)
0 g' F+ y4 ^% H, { pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 `+ J/ Z, n: S "%d\n", ret);& D/ L/ D. i& y- ]
#endif
5 C j* t, H* d; B8 \& C- h ret = platform_device_register(&da850_evm_tl_leds_device);
) l" S4 }" B% t% X/ Y if (ret)% \$ \7 R7 n# i$ G& x7 F5 \/ r
pr_warning("Could not register som GPIO expander LEDS");, ~& a! K" W, K2 S' k# X5 ]2 |
else, }$ Y& d+ C3 [# m' S6 R1 [6 C3 q
printk(KERN_INFO "LED register sucessful!\n");! j$ Z* c; L& h+ N
6 o3 Q8 ?3 _: e& E- p return ret;/ C0 ^& p8 l1 S6 P* {$ i
}
7 {6 u- q2 o$ U5 E, M) [# Z' H( j0 c2 K
static void __exit led_platform_exit(void)2 G6 l: o u/ C( U$ I; N% @* T5 P1 ]. f
{, L- g1 y8 H* g( O4 |' S7 i4 k
platform_device_unregister(&da850_evm_tl_leds_device);
- `% W b9 z3 _9 M8 [0 U7 @) X+ K5 p. V z8 A# z* e3 _
printk(KERN_INFO "LED unregister!\n");
+ o; o2 ~& ?1 }9 |- b j}; [7 ?9 C# D4 H" a
$ g; I0 r8 f, _2 c" Y1 {2 Q
module_init(led_platform_init);
' W& I8 n$ E: O- O. E& tmodule_exit(led_platform_exit);" j7 b# {$ |( A5 A4 Z
9 p. C% l1 t5 P8 Q5 R
MODULE_DESCRIPTION("Led platform driver");
7 T9 ]0 N$ I0 M, F6 _' ZMODULE_AUTHOR("Tronlong");; {% R; Z/ l3 B9 O" }. _+ |+ M4 I8 n o
MODULE_LICENSE("GPL");
( F! r# }) i5 i3 B. L6 w4 E% `* w( l
|
|