|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) c1 x6 x# z9 O+ x! x#include <linux/init.h>
# [' m/ A8 W/ W% l& I) U$ v$ a#include <linux/module.h>! u) }& F, d/ \# z& F1 d6 \
#include <linux/kernel.h>- x/ e9 f5 f- s$ A: i, J1 t
#include <linux/types.h>6 X0 J/ C3 J& c
#include <linux/gpio.h>
3 ^4 ~9 F1 A0 j: p) b8 H#include <linux/leds.h>$ L# R/ k. J1 l4 l( |6 V4 Z. x
#include <linux/platform_device.h>
! M; c. ]9 z4 k7 Z Y
% C4 C: `; l8 O8 X8 \#include <asm/mach-types.h>
6 V1 S( l8 q+ P#include <asm/mach/arch.h>
, G9 Q: V) N ]4 ~8 k) {. ?6 v#include <mach/da8xx.h>
0 B7 s* h6 u8 q+ H, u. e#include <mach/mux.h>
# O: U. C$ \, E8 L, g6 _7 m* P
6 C3 v5 H/ ~$ {6 K/ k) Y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( T, ~# ?* w) Z" ?#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" `1 Q( _7 `& Z- z6 r) J#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ T8 p) K6 t" c$ r/ o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) Y( G2 _4 O' K$ F- p1 u+ ?! W
, ^9 z" h) G, s$ K/* assign the tl som board LED-GPIOs*/0 @ v B2 L! F/ K- [" ]9 I8 |
static const short da850_evm_tl_user_led_pins[] = {
/ _6 M* U2 e6 b! G /* These pins are definition at <mach/mux.h> file */
; M1 ]& J4 g) D; P DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 k0 ]) K9 X7 P" e4 R* _( \ -1! b, P" P; e+ [: l& C$ m3 R! ]! B
};% L& \# P! S% ?( d6 S* n8 e# _8 W! u( ]
% i$ Z( `/ [3 O# V4 l% c- Istatic struct gpio_led da850_evm_tl_leds[] = {8 d1 c L- W4 Y4 |7 U5 c
{7 M1 C7 F: y( F( o5 S
.active_low = 0,+ d' I. H8 q+ C) G
.gpio = DA850_USER_LED0,1 |" {" |" G# n
.name = "user_led0", N$ D/ ?: Y% F: v
.default_trigger = "default-on",
" ~: ~- [. W7 ?4 d$ \ },- c5 }" Y- [, s
{
1 c5 w6 e; ?; ^- R6 e .active_low = 0,
% d) u* z3 W; c7 t U .gpio = DA850_USER_LED1,8 A: \2 s7 s0 Q; l
.name = "user_led1",5 f+ l, M' C) f1 P% s' u
.default_trigger = "default-on",( B; l/ K+ O# B! e# p) y# P
},% v* T8 m. ]5 h
{1 m: ~; H7 c- u! s
.active_low = 0,, z- ? Q- d- {8 Z8 P T# Q
.gpio = DA850_USER_LED2,! q s- e& G, O" E
.name = "user_led2",9 S6 f2 E. Q; o# [' C1 ^
.default_trigger = "default-on",
& H6 f; L# U9 J },
- U/ Q$ N' W( l! Y5 J {
! H; s) G3 V1 J. R5 r; @ .active_low = 0,
! R! J( w q7 F& F) u .gpio = DA850_USER_LED3,& \1 T9 D# o K
.name = "user_led3",
# T" A7 u# V; C& w .default_trigger = "default-on",
$ ?0 @8 h) Z) D( X },
$ q0 J8 P' u5 W2 O( F- J6 v) p$ I" r};
, C. h4 V/ k1 x/ A# o& @; P* l- y6 x4 h- ~2 |* j" Z6 E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 F6 |. t ^* ?! [9 r2 ?# V& S
.leds = da850_evm_tl_leds,. ]3 ~' Q4 l: e ^! F( D N3 w4 T1 m
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; j% _2 x& B" }; C0 R3 \9 m
};* m) w) @+ b* [: Y) T/ b8 `; g
) p# W; d, J- X; E% U, a9 ]
static void led_dev_release(struct device *dev)
+ q) t/ L3 S7 F$ I1 \, a0 p{
/ B7 a0 c) H( i+ `' k& F1 p};+ j; l$ r" X$ q
1 s* p' F* t% wstatic struct platform_device da850_evm_tl_leds_device = {6 W6 ~6 _( t( ^5 P2 b7 S5 h/ \
.name = "leds-gpio",
; t9 M g( X5 Z9 }6 e, U3 y: T .id = 1,+ D* b* R! q$ P+ d. K( p
.dev = {
/ e0 A: M2 [3 X .platform_data = &da850_evm_tl_leds_pdata,
& h5 S$ X9 [* L# o. e* V0 V$ _ .release = led_dev_release,; P# d5 `/ z |/ i
} R4 I9 E* @) V5 I# m
};
: S( X# m$ D* [5 O+ n
0 S5 ?3 K. l+ n4 \% L9 Kstatic int __init led_platform_init(void)
. a0 b" {3 W+ ]. }/ o! c, H, }{
5 u" y M2 y* [6 c9 b int ret;
/ a$ x3 G' y4 d: [% T#if 0
( j9 r& s$ e4 c! I7 D; D ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 @2 g' n B Q# g- V
if (ret)
' t/ j! E' L+ a pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" J' B3 q% t! E. k! G+ V" { "%d\n", ret);5 @! U/ X4 x& {- |5 N
#endif! E& D* D* A u% p2 n
ret = platform_device_register(&da850_evm_tl_leds_device);- x; {5 B5 c9 } F
if (ret)
" Y% v8 M% x9 P" m# w$ L pr_warning("Could not register som GPIO expander LEDS");! b( x" [$ @- B* r! W2 O
else
0 N5 \$ M1 K# I7 t# f3 G) _ printk(KERN_INFO "LED register sucessful!\n");" |" ~ y6 i; J8 g! n. D
+ o2 @/ ?0 V. ? return ret;0 q0 Y6 \ z$ W" R) z; ?
}( {5 l; @+ t' }0 `
' ]/ s; E: [0 _6 c0 Ystatic void __exit led_platform_exit(void)+ W/ J: J, Y* T' ?
{/ F4 I) V- I# \, W! R- V
platform_device_unregister(&da850_evm_tl_leds_device);$ t2 A; C7 A$ B# r% ]
8 ~: u. Q: ]) Z% t" J printk(KERN_INFO "LED unregister!\n");
4 V2 P9 z5 O' n% b$ z+ [}
) N9 N& y- w: d
) E5 [3 B1 ?( G9 E9 q5 `module_init(led_platform_init);
' Q6 {( e5 y# p$ D, _; Qmodule_exit(led_platform_exit);
. v) [' b1 Y9 R+ f4 w4 C* b& }% S5 A/ p! Q, ?7 f
MODULE_DESCRIPTION("Led platform driver");- F9 c/ W5 c+ a& n
MODULE_AUTHOR("Tronlong");/ f( N0 T- C5 H: N5 C; ?0 H- P2 f$ k
MODULE_LICENSE("GPL");
5 a. |* U- D4 Q+ _, k
7 b6 m$ T. S7 _( g3 t; ` |
|