|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 J+ \5 S0 r) l" Q" ?0 M
#include <linux/init.h>
: b$ b0 m% v. M e0 f0 r! U#include <linux/module.h>0 {. y# D/ ~3 n, e7 D" m
#include <linux/kernel.h>
7 {* s9 Z$ }$ D7 r6 D% p#include <linux/types.h>) u w, @* e0 s% Y6 ?
#include <linux/gpio.h>
" T# O1 V2 l6 \/ B. {#include <linux/leds.h>
& S/ C* Q, K& B#include <linux/platform_device.h>
( d7 B! o) ]% |& m. P4 C* v( u$ ~+ u7 t; |( j- y A8 G" q
#include <asm/mach-types.h>8 Y" }5 g; h* u- ]* g5 d+ |' j
#include <asm/mach/arch.h>8 _1 X0 e. W- N" n& f
#include <mach/da8xx.h>
" d( n/ {+ ]* j( ^8 }#include <mach/mux.h>
& T" [0 f9 U( n. H/ k$ P
2 I7 T/ j! n: W& ~#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) p; V+ U' B$ y v
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 _' t) e- n$ p H# B
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 |- N1 t. S* p$ a& j9 \+ {
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) J4 E6 M- c$ Z+ O! ]
& \ {# n9 P" _5 j/* assign the tl som board LED-GPIOs*/
8 \# A3 ^+ r5 S7 ]static const short da850_evm_tl_user_led_pins[] = {
, H- H' K8 s! Q# S$ A /* These pins are definition at <mach/mux.h> file */3 r& b& c2 t3 ]
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' k$ J/ C: e/ J
-1
$ ?* W( b5 V! G$ l: F1 E};
' @* u, ?+ B- \! \! l8 \# J6 X) D/ \% W1 J# y, l: J, D
static struct gpio_led da850_evm_tl_leds[] = {1 p5 z6 d) d" |( k' j
{+ H# k7 e% [, d2 `! J
.active_low = 0,
: r4 L' N9 D7 x! |' t .gpio = DA850_USER_LED0,
- G; r6 y) v* ]9 j6 x$ | .name = "user_led0",
( y( C- E+ `4 V! R .default_trigger = "default-on",5 { a8 \: J& r0 x- X
},* f% ^/ I+ o9 F( G( Y% T" s
{
; b1 Q# D) G7 N) }& W, X4 i .active_low = 0,
3 i4 }9 y" \" e# l- x .gpio = DA850_USER_LED1,# C& Q Y% H1 j/ c4 r/ a
.name = "user_led1",; L! F# g. R% X4 @
.default_trigger = "default-on",* z6 z1 G1 v) Z* M$ v
},- A3 ]% X4 _6 Y7 i8 z" U( D
{
+ ^0 B$ M( ^) z& I .active_low = 0,' `& Z' k' B- d
.gpio = DA850_USER_LED2,% ?2 q9 M% Q3 M$ Z
.name = "user_led2",
& [# V0 {" h* c4 _" g .default_trigger = "default-on",
( Y' p; e4 \* \& { },0 }' y( h/ J/ c. Z4 U
{ v! T1 M/ S5 s4 }1 [( ?5 K' ^
.active_low = 0,
6 {8 H9 l0 @" P6 t' i7 I .gpio = DA850_USER_LED3,5 k/ G1 p% }) I6 h4 ]0 h
.name = "user_led3",; P( h" W$ J; D4 P' c8 z
.default_trigger = "default-on",
1 J. L! U& o9 c },
' d7 v7 ^. ^! w/ b& s2 K9 ^, d( ]};: |7 \/ V8 r0 s+ l
7 c2 t3 \$ W0 G( Y# J7 [' y& Jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( Z2 I E; }0 E% x% `% M |0 ?
.leds = da850_evm_tl_leds,# b$ W( z/ z" f; F, f3 n' A
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),. E. a' w5 D* ?! f9 | j9 j
};% D& b# |9 l% B/ s2 p
4 |: D2 y9 t2 s( O' ]+ J, y
static void led_dev_release(struct device *dev)9 z( t, y+ h- Z6 ?8 G
{% e0 q1 ^" @0 j' x; {
};4 V! T4 r1 `. [8 `6 O7 q
' v& u- U) F( s" E
static struct platform_device da850_evm_tl_leds_device = {
$ ]4 d1 E4 j" G1 L* b .name = "leds-gpio",
9 V, a8 V/ W8 ~* O2 T8 X .id = 1,
X Z7 e- S% Q3 }/ e- Z .dev = {
2 L4 J. v# ^6 _# v( P, J# [; m .platform_data = &da850_evm_tl_leds_pdata,
; j, R( X; B; U0 m .release = led_dev_release,
0 K1 M* ^$ D" X$ W7 L }! i, j7 N3 K4 V) J
};
/ |* a# s" E. o! `% K
$ e+ |% _: t @1 K* C: Istatic int __init led_platform_init(void)0 t* c7 j/ q6 l, \! t
{
7 I+ {# z: P+ ` ~ int ret; M5 p6 k4 v- \& [
#if 0' t5 u. p7 X6 T9 D9 x$ V4 |
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ V, ?+ r) ?( U! f/ N if (ret)1 Y0 i$ f8 h- b$ T8 `. `
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 C% K1 r: X& J3 h3 c3 N
"%d\n", ret);9 T) J0 w& J9 `2 J: z* G1 r" f
#endif
- a% J# p" n: E" M ret = platform_device_register(&da850_evm_tl_leds_device);
! r+ T/ I6 d( [. a% ]" U2 T if (ret)3 ]; P( H' P4 ~( |$ T+ M
pr_warning("Could not register som GPIO expander LEDS");' s, C: b/ J! _
else
( b( t$ s% x/ E9 n' j# a printk(KERN_INFO "LED register sucessful!\n");5 J8 k$ f# R! l! v& n8 u. k
4 t o+ h; P; \6 _ return ret;
7 s2 g" p3 Y6 o5 o}
' k |1 g, e: I5 i+ e0 P6 k! f" {" v7 Q. L
static void __exit led_platform_exit(void)8 V4 ^9 R0 b8 o: }. L& w& }2 ^
{, ^( z1 S$ ~' m$ J( f2 b
platform_device_unregister(&da850_evm_tl_leds_device);
& M- Y2 X t8 \1 [/ }( ]8 ?( S" b" f- O) F" l) m9 G
printk(KERN_INFO "LED unregister!\n");
* l5 _) Q7 d, ]0 \ l5 x6 Y0 n2 e; x}
+ F! E4 O/ Y6 C) N( d
- M8 _' K2 r J7 gmodule_init(led_platform_init);
& q- N" Z0 ?( _1 t- ]. ` cmodule_exit(led_platform_exit);& G* }3 I7 ?) w8 _8 \
( V% l& I1 \7 v S
MODULE_DESCRIPTION("Led platform driver");
. \# X/ i3 q. R; b! I! H, `( PMODULE_AUTHOR("Tronlong");
0 C0 V* n% C# ^; M' GMODULE_LICENSE("GPL");( w. v9 P& X; D" v1 \
* I5 K& N i. K; s |
|