|
求大神给下面的程序做注解,请稍详细些,谢谢。
|! a f6 j; y" C#include <linux/init.h>
0 }' D2 n: \9 W% U% q$ n# K#include <linux/module.h>
5 y' `& Q! b7 `4 z" V0 Z: S* ]#include <linux/kernel.h>+ G \( q& V- u' O( m/ {. l9 v- G/ G4 o
#include <linux/types.h>5 b0 K1 J; [0 T
#include <linux/gpio.h>
- [; a0 m+ X. u& u& @, C) k#include <linux/leds.h>
/ z& F4 B6 K3 L3 F#include <linux/platform_device.h>
6 S7 A3 P! [- O( G4 A2 U1 h' H) J
C- |$ A8 V' ~! p9 d5 m#include <asm/mach-types.h>" X8 ^ K& N' f/ `: f
#include <asm/mach/arch.h>
# t( E7 }1 P0 w3 ] r& J ?#include <mach/da8xx.h>
5 s. }( z' \: Z5 \$ N#include <mach/mux.h>7 M" s! d# F% T; U" k
; Y3 l0 J2 `# _( L' {+ Y7 g( ], o
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" b: ?9 T3 F2 g9 U9 `4 q, l, {) K( o
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ d: v% F# @ U
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 Y6 D# f& f4 y. T
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 w+ j8 u2 I+ F( Y
! z& t) j' C5 f/ C/* assign the tl som board LED-GPIOs*/
# H4 L3 q( P- b% I1 zstatic const short da850_evm_tl_user_led_pins[] = {
" K: A' r7 q- K: y9 F /* These pins are definition at <mach/mux.h> file */3 w0 a, o. D- q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ }( ?. D1 G; T1 J( I4 |6 o2 [ -1* |& y9 C, D6 t( L- w
};
# t3 p1 O5 l, E- V, @* `) x9 i5 x/ w& _9 E1 f+ y: E: O9 F
static struct gpio_led da850_evm_tl_leds[] = {
& _1 b+ ]' i/ w! l- `: Y* S% j {, p% A( {, ]; E; S; r+ F- J
.active_low = 0,
+ \5 {. H3 R) e2 F+ ` ] E .gpio = DA850_USER_LED0,; |4 v1 F' {. D( [
.name = "user_led0",
1 x$ y: o/ T- m* A" h/ l- S .default_trigger = "default-on",
& m9 e, {' ]4 j8 T* d6 b1 j },
8 ]- ~6 E5 v; x! C0 [/ Y6 n( B {8 B* f: I# r% R( q
.active_low = 0,* ^% N6 c- j, G. ^
.gpio = DA850_USER_LED1,
6 {* Z. s* G( D. ^- R .name = "user_led1",$ ]1 s) y8 s6 x, H. O
.default_trigger = "default-on",+ B; D4 J" s8 k
},. u2 x" }: T+ T; B; x! m
{
8 {% {: U5 b. q .active_low = 0,
9 [3 K. f$ x" @# {+ [3 f .gpio = DA850_USER_LED2, e) `* G9 ]' p) r( V5 ?: P) x6 Z
.name = "user_led2",
0 r" a) H. S8 Z6 P( Y" _ .default_trigger = "default-on",
0 V% \+ y3 C/ }3 f },3 M% i! ?' ]% f% t/ b; [
{5 O5 b1 `+ O' ?7 y
.active_low = 0,0 _5 [, O- {* ]3 V7 ^. R& H
.gpio = DA850_USER_LED3,
& N7 y. j7 V7 t+ W3 N. E F .name = "user_led3",% f+ L7 s( L! B# I
.default_trigger = "default-on",
! D R) A' P4 N7 A },
1 r3 o$ N+ P: @7 Z& t};
% }! ^7 u+ o3 N+ {' X# p; v* ?- k3 g7 H" x, Q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 c8 x3 ^7 P; y
.leds = da850_evm_tl_leds,
9 S) z# Y/ O6 n, @: t: N .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& C: L: n4 H, ^. S" k7 w* V
};
5 @, v! n. d& s* g- a) }- R0 \- b! q7 }+ G8 f& w$ s4 Y: P! T
static void led_dev_release(struct device *dev)
5 {; b8 V8 w! N1 z! `! p9 d{
- P/ L: `) o9 T! E$ } K};4 [ w+ N. k1 {1 P( @0 ]$ h
; l7 A4 @( K, F7 ?! z+ u
static struct platform_device da850_evm_tl_leds_device = {
% F* y1 `* |/ ~0 D& ~. r .name = "leds-gpio",: @& f8 Z, x% h
.id = 1,
2 m1 C& P: n+ O" d% k .dev = {0 ]& G3 i4 i" T, v8 k5 A3 i
.platform_data = &da850_evm_tl_leds_pdata,
3 h! k w) D4 O' E) w" K .release = led_dev_release,
! g/ t, f z% x }
* g6 w9 q% r$ ]& s5 V' R};4 M% d J& H' y: z
* J, l( S `& h9 Qstatic int __init led_platform_init(void) X8 |& ~- y. s- d
{
" E# C/ M' J% d3 w: u. R int ret;4 L3 I$ ]* O+ r
#if 0
* W" u" ?% M5 F: X1 `) @$ b ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% `) Y5 X: _4 G+ h5 T& M i if (ret)! X! b& w$ Q2 b8 e% [ \ i: Q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" q3 N2 l6 S: f- I9 E4 A "%d\n", ret);: A# X( s2 q' d; ?' _2 m
#endif
0 w! Q' p2 Y, O8 o3 _7 ?% i ret = platform_device_register(&da850_evm_tl_leds_device);4 M1 t c- X* r" U* V
if (ret)- ^! B* E# Q6 X7 N% F
pr_warning("Could not register som GPIO expander LEDS");
2 p( R4 D) a# S9 L n" h- m0 a4 _ else
0 ]4 X7 K* i' M5 [ printk(KERN_INFO "LED register sucessful!\n");
7 Q' x, I" v9 e, @% P$ j% ~2 M c
5 J- V1 ]; n; c6 Z2 W0 ]6 P return ret;
+ w5 N5 L$ K* U( K: L" }& E}# c0 {0 Z1 \7 o* Q' b( K
- n* [) {# q( m( p( y; n' {2 j
static void __exit led_platform_exit(void)& Q! \6 V0 h. e" ?( r4 _
{, n. b7 {3 E& Q- j
platform_device_unregister(&da850_evm_tl_leds_device);
# l4 B; ^! j! A$ M+ E% }& J* }; Z' I
printk(KERN_INFO "LED unregister!\n");' B; H' i/ ?3 |7 a# L" w* Y5 _
}: w- L/ |7 }# ]3 d1 z
# r9 c+ K$ w! l* x" J
module_init(led_platform_init);
: k3 H0 i( z! g0 Q& nmodule_exit(led_platform_exit);
1 Q6 R' l9 |$ @$ q: P/ ]
8 p$ e) }8 N- x8 V ^MODULE_DESCRIPTION("Led platform driver");
8 _: u1 r# l& [% r( XMODULE_AUTHOR("Tronlong");* Z9 `" a" T: w
MODULE_LICENSE("GPL");
" X5 r7 g0 N- T2 ]9 C% K$ R6 S& F; B. s) j5 S m
|
|