|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- L0 b) B. n7 I& \3 n& e#include <linux/init.h>
! L% Q7 D) K+ v Q#include <linux/module.h>
2 X2 W& H2 g5 l- ~. |0 A/ |#include <linux/kernel.h>3 J, ^! T+ _& w6 A X- _; Y
#include <linux/types.h>
, A) ]" v; r: O. i! F#include <linux/gpio.h>
l. ~( q9 {4 @0 v6 E; a/ Y#include <linux/leds.h>* Z$ o3 I& g% V8 g
#include <linux/platform_device.h>
0 W* w) F% w5 `# _ B% F6 |$ l2 K
' Y* G4 ~5 S9 l4 I7 z8 b#include <asm/mach-types.h>* ~% f* k* u, _- p
#include <asm/mach/arch.h>
' m; b# h& W& n6 }$ r3 ^#include <mach/da8xx.h>6 @. ]: c" H/ _8 n+ y4 L. r
#include <mach/mux.h>
. Z# R6 w1 i2 e; q2 Z* a/ h! _: K4 S% C- r
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 J# H$ G# O ^. ]% `
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 j9 i8 L6 T& }' A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* ^* C2 k: G- m#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- L+ S$ l1 f1 X
' o& P3 O& s: F2 V. \8 f+ c/* assign the tl som board LED-GPIOs*/! b N5 l. | w1 B) Y; }4 q
static const short da850_evm_tl_user_led_pins[] = {% K8 V, ~) Z% h! X0 e4 O
/* These pins are definition at <mach/mux.h> file */
' d# k4 E5 ?% z/ [: Z$ b3 @ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, R4 d1 x8 C! ~7 j( l -11 V# ` Y9 }5 o! x1 P
};
$ q! G/ s2 A* l% `3 A
, j+ N$ @& J6 a8 Q( ystatic struct gpio_led da850_evm_tl_leds[] = {
4 p( g4 v h4 x }, k {
2 O. D+ O9 E, v6 ?) q1 \4 N .active_low = 0,: X4 y. t0 ?4 y4 d" }7 K/ S$ A9 c
.gpio = DA850_USER_LED0,
6 v N, V* [, o9 ?5 U/ U/ m0 \ .name = "user_led0",
" g" S; h9 L5 q+ U& T& i t$ z .default_trigger = "default-on",5 l# e5 j2 }: p. l3 |$ L3 R
},
* p9 J+ s5 K& m% \0 x {
& U8 ?+ y$ b; w3 J/ _ .active_low = 0,4 S: ~* W1 S7 S2 X
.gpio = DA850_USER_LED1,
5 Y, m/ a* _/ z% i: |% E# _' ^6 } .name = "user_led1",$ e) v3 p H A K5 q* d
.default_trigger = "default-on"," I# q' u5 ]: v8 G5 M8 }- |& U) a$ [
},
( E9 R% s( `& F {: s1 p7 t3 [! s! j/ [
.active_low = 0,+ h( A4 @( P0 Z% V; s: X% U
.gpio = DA850_USER_LED2,
( s" U" k* A& Z9 _5 I( `+ ^ .name = "user_led2",9 J' I0 m+ q! D
.default_trigger = "default-on",
0 M5 L$ i2 p3 s/ `; T& Y1 Y; g },2 T3 w, Q) j3 f. h4 z) ]. m
{7 s. b: x' _ C8 b8 T6 T$ j, P' G( [
.active_low = 0,
/ H8 k- r( f r3 J5 ^ .gpio = DA850_USER_LED3,# t, J; D# ^( X' r
.name = "user_led3",( Z5 Q# k8 N, n2 R
.default_trigger = "default-on",
, A; _4 [$ R' I# s5 r },' O8 e0 ~( N: G) i1 c- c- Q& E2 Z7 g7 z
};* t+ @6 U5 A: a. h. T
7 W( }7 x4 q9 z7 @static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; P) Z7 D9 l' N/ N( O3 `
.leds = da850_evm_tl_leds,
! I, \3 M' C; J; r1 X' _ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, }) ?! C; S! r* B" u& }
};4 o5 g0 o/ o3 d
7 c1 g# D% s1 a, ^. V4 i6 ~static void led_dev_release(struct device *dev)
1 N2 M! V! d9 a4 o+ c{1 ^* B0 V9 s# ~2 ^
};8 L6 v9 q; O0 B# E+ m" S. i* R3 I
6 ]7 m B5 z. f! `4 n& V [static struct platform_device da850_evm_tl_leds_device = {1 i( f1 ]( [9 d J
.name = "leds-gpio",
! C/ ^ W4 k# h$ i- F9 _1 @ .id = 1,0 A" C2 m$ T% \0 i
.dev = {/ G* } a1 `3 `
.platform_data = &da850_evm_tl_leds_pdata,
7 M! |- @1 j6 o/ J3 R q .release = led_dev_release,6 {) g/ e$ a) g4 ~7 {( [# `
}
* b/ k9 y" b+ C$ a};" y) F- u2 k$ F8 }% {. A9 Q" l; w
9 O, T3 ~( x5 R" k7 `% @) G! Istatic int __init led_platform_init(void)
0 o, @* f9 O1 x: j{% h- f7 k4 g" Y0 ~
int ret;
- I6 P" |) W X* p#if 0
z- C$ Z5 K' Z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 I* R$ v$ s1 ] ]8 h; s/ p. }
if (ret)
9 Y5 e1 [# u/ {$ f pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& L6 |, R) F1 m- ~+ h6 \ "%d\n", ret);
* H0 ^, @ [! C7 C. @#endif
- v: u& W* ?5 @& d0 R6 F ret = platform_device_register(&da850_evm_tl_leds_device);
# ?: d" E& K3 q. _* \ if (ret)4 h6 A" L& a: P; L; F# U
pr_warning("Could not register som GPIO expander LEDS");5 R& q- m3 T. f1 u. ]$ b
else. l0 V ~5 p9 U- T% W
printk(KERN_INFO "LED register sucessful!\n");! |: |: W3 i1 V8 i* _4 L/ o
5 a8 l& X0 o- q* } w return ret;7 z& S8 X+ m) G. o; q j
}
9 D( x7 l% t' Z3 H7 U
# A/ k; A' `" O# b+ e0 {6 t: C# tstatic void __exit led_platform_exit(void)
; n' ~8 N- V& A* A{( {- }& U; Q! y: H
platform_device_unregister(&da850_evm_tl_leds_device);
N7 b7 k* S$ \ C, N
' G+ \+ J% O: P printk(KERN_INFO "LED unregister!\n");
& S* p: u9 G6 e9 R}( Y* X* ]; Y a% P2 i
! \% e0 _* G' z- I
module_init(led_platform_init);3 S# D# I/ ]5 C8 C
module_exit(led_platform_exit);" i7 S9 W: |0 S# Q. d6 _- x: }, l" ]
9 w* p0 P( K2 v- J: \; WMODULE_DESCRIPTION("Led platform driver");
! m9 |8 }$ D7 j( Y, m2 s# DMODULE_AUTHOR("Tronlong");7 V) i" p/ y- B& }1 Y
MODULE_LICENSE("GPL");
! K' {1 [- A8 o, t: F) e, k: Q3 e# l
|
|