|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 U3 a: \; b: T) w4 N1 `# \; j#include <linux/init.h>
6 r0 G3 N, M+ b: s' F2 k#include <linux/module.h>
" J! d4 L0 Y0 n5 x% x8 x#include <linux/kernel.h>- h# f, O+ i9 U
#include <linux/types.h>
6 { b; i1 x% P3 n) S: I#include <linux/gpio.h>0 L' M4 V9 B/ S j4 x" z! V( @
#include <linux/leds.h>
6 O* v# g. p" J" g#include <linux/platform_device.h>
+ k" Z3 B( f& {5 b) E' c2 }
# T- Y. V" y# C2 K7 g' G2 u" j1 j#include <asm/mach-types.h>
( i% P0 |' J' @" C' e#include <asm/mach/arch.h>! m8 f6 ?# K# |
#include <mach/da8xx.h>7 A2 X. w6 x! u" ~$ c2 E
#include <mach/mux.h>! _$ X J7 f. V1 N1 [9 A; k! Z: `
; T3 d2 B" b; ?( X: b( K#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. b( V, |4 w% c0 j8 n- f: L( Z( P#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). @2 D; f: F4 b) J7 @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 h3 U' J4 }& D1 H& l$ W
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ U* p; d3 z v# L$ h6 T
: D6 k k2 c( G4 ^' z% I* m- w/* assign the tl som board LED-GPIOs*/
% Z( e2 x8 o0 `# Rstatic const short da850_evm_tl_user_led_pins[] = {, f! Y) f' z3 o" F
/* These pins are definition at <mach/mux.h> file */" @: T ?9 X4 p. A! v3 [
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 n) b) o8 d+ o- I9 h% { -1
' x9 S$ L% s3 p};3 s/ g/ v: ?7 g
9 K) E6 S' t$ @+ U/ ^static struct gpio_led da850_evm_tl_leds[] = {
. F8 C' S/ _) C2 E; Z {% Q( | J. M3 N* i) D
.active_low = 0,
1 {" n$ r3 g+ c6 _2 Z+ `; v .gpio = DA850_USER_LED0,
/ o: i& P. n ^0 l0 V7 E/ q5 { .name = "user_led0",
" ]. j8 L# `1 m$ |" w! e .default_trigger = "default-on",
5 N" Y$ o0 _" u: e8 o* u2 E) ] },
& n V. v9 [$ D- Q9 ?" \- x {. V& b$ j& O% M- P8 m; p4 [
.active_low = 0,6 Z$ }0 r3 @- D8 M* C3 q* P1 y
.gpio = DA850_USER_LED1,
2 \( \6 p# S8 b9 G .name = "user_led1",% P/ | C6 B# t% j% E x% @/ o
.default_trigger = "default-on",1 O, ^' U( X3 n- E% \
},
: n$ I. M9 Y0 K& j8 ~. N& c9 c {0 X0 t# ^/ _- s% X+ F
.active_low = 0,0 C3 Q. b- k: \. v- r
.gpio = DA850_USER_LED2,+ Z, ~; h. G' H J
.name = "user_led2",0 q1 ~+ r. Z8 U+ e, h6 w: J
.default_trigger = "default-on",
2 \. Q! c8 i5 O0 d },
) z" n+ K- ]& E# q" V. g! { {: _8 n, M; ~+ ]2 `7 P# r
.active_low = 0,
6 u; O& L0 A9 l4 `1 i .gpio = DA850_USER_LED3,
e8 E7 i+ q8 d8 k. w .name = "user_led3", W* Q: C3 [$ {) ?9 c2 g, I* p
.default_trigger = "default-on",
, {% [7 G. [. q$ N" j0 I0 I, G },
+ s9 A# ]* A+ z6 K$ [8 D% F L' C};% O% I1 q5 y+ Y" z8 E& ^, E
+ M5 P' r2 X# istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! O5 Q0 `! l* Q. r a
.leds = da850_evm_tl_leds,
% l# ~' Q, d( Z0 L2 ` .num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 Q5 ~8 R4 s& z# P% A8 ^
};
6 N# X" [, ~! z4 Q& C. S
" U+ f6 x. m: H7 r: H& `, kstatic void led_dev_release(struct device *dev)
, _" J+ {# u9 R. h1 Y, T{
9 @: `4 ^' J3 Q" M+ C) z! b$ q};
& T- E% O8 `/ ^2 O& A" }2 F4 _3 K: K. X3 k' e4 _8 a' ^
static struct platform_device da850_evm_tl_leds_device = {
! I. d: W5 S1 C* _. H h! l( _, c .name = "leds-gpio",5 z- H* A8 T+ v6 ^
.id = 1, n) a2 z9 `6 ^5 b0 q$ n2 R
.dev = {
0 `- m) H0 O5 G/ l* t .platform_data = &da850_evm_tl_leds_pdata,
& r' f/ k/ Q8 F( k6 f .release = led_dev_release,; |9 h; R4 O7 v: Z0 J, O8 _$ E
}6 D, F7 l1 L; ~! I
};
, F6 d0 _& x+ [: _, R' |. W, P8 @
5 d( a Y) T6 W$ z' Ustatic int __init led_platform_init(void)3 u1 Q; t* i" V7 A- R
{
6 b: a% K* c" K& W" ]9 B. y5 I5 N! E int ret;: t- l; D G4 o( o0 e+ \- H. n
#if 0: y' E1 L6 J( M1 N- A) N
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 U1 y" k( [4 q7 A u
if (ret)$ f: j" w n0 |0 R
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 W6 H4 D1 K; f' `, M "%d\n", ret);+ u" @0 G7 c4 p! I D+ m0 c
#endif
& B& R" B, I- N; V& ] ret = platform_device_register(&da850_evm_tl_leds_device);
; r: B( a, U' @* i3 n if (ret)
8 X9 @1 x& L7 c& ` pr_warning("Could not register som GPIO expander LEDS");6 Y/ m$ o0 x. a7 G
else
. z0 Z/ ]2 S' f1 x/ h printk(KERN_INFO "LED register sucessful!\n");
4 P: O/ X9 I* Y5 e& @9 V+ T$ N0 L9 j
return ret;
4 U4 y" C- e! {+ T}! N4 ~' m6 ^" s* J6 W
2 t7 F- H! C5 m; B; Wstatic void __exit led_platform_exit(void)' J( u9 m8 b0 F2 x
{: }/ z e# r6 L, J) e
platform_device_unregister(&da850_evm_tl_leds_device);
7 Z9 k! x0 w X- y, s
" Y0 j( P3 t" U: ` printk(KERN_INFO "LED unregister!\n");, c9 k$ U+ S3 H' s {. }; _
}% B4 k. {1 k5 N
. N1 N& J; S* T* O$ hmodule_init(led_platform_init);& e# Y# i% h/ z( D/ T" J0 Z7 Y+ u
module_exit(led_platform_exit);
5 Z" V" T: V% B* h, k7 O. r" S0 }
* k) ?4 _4 g) W* e: Q4 pMODULE_DESCRIPTION("Led platform driver");
; E3 q# @4 y }. uMODULE_AUTHOR("Tronlong");6 P! L' S' q2 P1 e1 h2 s! I
MODULE_LICENSE("GPL");! I+ }- `( G4 h2 n4 O" J, G
$ P. T' k* ]. f% [3 S- q- {
|
|