|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* ^) @- d& g: b1 O" Y/ s
#include <linux/init.h>6 A. i4 H' n+ P- N1 L5 t& X
#include <linux/module.h>& j- _- g, z$ Q( q% a! l8 t
#include <linux/kernel.h>$ M/ U A6 Y; C* b3 s6 x
#include <linux/types.h>
) h4 S7 G G$ |2 S' N# F+ q#include <linux/gpio.h>
) q5 a) s) T, a- L- u" M$ T/ k$ z#include <linux/leds.h>4 E3 m1 P, }# r: u- z
#include <linux/platform_device.h>
2 s; e$ @' @6 O1 t
" T( e% g9 O' B1 R- a" Z#include <asm/mach-types.h>7 d" M) U+ O3 _
#include <asm/mach/arch.h>
- E1 [: W4 @8 I# O& _! V) Z: `#include <mach/da8xx.h>7 ]( j" [5 C, f! `# h/ L/ N6 ]4 I$ s% Y
#include <mach/mux.h>
. [ ?* ]' p9 z+ B* ]" x, ^+ T4 o8 w6 W0 `: w" K4 w( e5 n1 P
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- \$ u# a- l. `( m% X2 g2 L, p#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). E2 o5 Y; v, O/ y- a9 _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ i8 Z! M# y4 m7 j- F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* ?' q/ u/ L! Z9 e
0 f) }1 c+ V1 W8 G/* assign the tl som board LED-GPIOs*/: V2 j5 P" `3 B6 P
static const short da850_evm_tl_user_led_pins[] = {" U0 A6 L+ `, _8 G
/* These pins are definition at <mach/mux.h> file */7 h4 z" W! h# u
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 p+ T1 e! y: A. {9 s9 Q
-1
. I* L8 U9 }& V8 E0 Y};
+ _; ~* t) K+ H% c" [6 Y
Y0 _6 d. }# istatic struct gpio_led da850_evm_tl_leds[] = {
. j( G$ v; J% ]# }. N& o1 n {/ m2 a5 w' [, W& \& G8 O
.active_low = 0,
5 [- Z; k2 y' X9 T1 V' ?# W* y .gpio = DA850_USER_LED0,
) t. S' x( S) m: R .name = "user_led0",, w0 O7 L0 B3 {( `7 B. C
.default_trigger = "default-on",
! v% x4 H& H2 g& B4 g& S, u },4 {, z; c5 {/ y( s4 {' J( @& c
{
0 P3 x3 w- ^2 U) o1 w8 c8 N2 M .active_low = 0,& w: h1 G2 L6 [ T
.gpio = DA850_USER_LED1,% M! Z& N' O1 j( E
.name = "user_led1",
6 X* i3 b' x! F .default_trigger = "default-on",4 K+ n* V- |/ f( N T% }3 t4 K& k
},
! Z" z/ g: C! a s3 c/ O5 _+ T {
, ]- X3 d6 E: z& [* t5 e: i. w; } .active_low = 0,
- }2 P. x0 _9 L .gpio = DA850_USER_LED2,: @9 j: }5 k( D) [2 H
.name = "user_led2",( _8 y' H# G. B& d
.default_trigger = "default-on",
" p' Q3 v2 A8 H. z },
! @0 G/ p6 X! S% z* b1 b' x" ` {
) i* w" @- k/ ^% { v .active_low = 0,7 i9 P/ F, P/ n+ L1 b( f& y* Z
.gpio = DA850_USER_LED3,
0 P2 f& J# B' ~4 o# K .name = "user_led3",
7 P% [6 f' {; F) k4 u. z& C .default_trigger = "default-on",# {( }2 Q9 ~; J/ L
},: w+ }/ `8 d% \, t
};
: j9 Y7 u+ p! N& ?6 ^3 F4 U2 k2 Z z( E6 o+ V9 g: g* }9 r: O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 j& v' ~; ~! j$ h0 k .leds = da850_evm_tl_leds,# @% A" V& u$ |$ V N* N
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. U# i* ]2 U0 ?% w# C+ N% O. n8 H};. a- D, X! Q/ [( j
% A0 I5 v) P7 J: kstatic void led_dev_release(struct device *dev)/ @- a/ G% Z" I. y5 f" w
{
9 a. c: r2 L- u$ D# v8 F};
$ q; m7 b4 h1 Y5 {; W/ h* d9 e) i2 a1 e3 G/ l h& h
static struct platform_device da850_evm_tl_leds_device = {( [/ e+ w6 l- u! p
.name = "leds-gpio",
; `+ o* Y2 x; v9 W .id = 1," O" ^0 @3 P% D0 ?* ~
.dev = {! `% ]3 v+ @ u* U6 e7 g6 x$ Q
.platform_data = &da850_evm_tl_leds_pdata,
! C, {" C. m9 w& G7 Q& L) n) n .release = led_dev_release,
2 P4 l. u" i! T$ g0 A }
' U3 e# W' J7 m2 o$ X! S. X3 w};$ W, S. \6 n4 C% P3 {
: q& J1 P- P1 r k/ o1 ?+ F
static int __init led_platform_init(void)
" R0 `, L7 i, ]" j, B5 U2 ^. E{
% f7 i0 u6 b. {& E4 F int ret;) k: K# P% [# D) i6 L
#if 0! v0 r. Q) L7 E
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ h3 b: I6 |4 g6 r! o
if (ret)
8 Q! \; f/ B0 {) J# ~ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# R( J7 J( ]/ q1 u1 V( ~; h& f "%d\n", ret);
" M3 P5 W2 S% m5 v! O# ]" v! w) t#endif
+ U, u( P3 ?% |/ C$ c ret = platform_device_register(&da850_evm_tl_leds_device);. Y+ `9 k+ x6 l
if (ret)
1 e% w8 e) D2 [. T# X G( g7 e pr_warning("Could not register som GPIO expander LEDS");" k! U) b, G$ ?. h' P+ D/ m
else
9 c( {5 |4 j8 `/ F printk(KERN_INFO "LED register sucessful!\n");
4 F5 z, \% W1 U) Y" Q2 _
! N! x9 T7 T6 d return ret;( f, S" ^* W+ ]1 v* f0 C3 K4 l
}
6 X) W- t- s! z0 V7 C
2 l3 [: F" _" x- U0 Sstatic void __exit led_platform_exit(void)8 \9 x$ U. c2 e9 n( H/ Z3 _
{! L* \ S4 m! O- ~8 {2 r
platform_device_unregister(&da850_evm_tl_leds_device);
# e3 K8 m# ~ p w/ Y8 Y' U( o3 ^" g+ B+ D0 I
printk(KERN_INFO "LED unregister!\n");2 {/ p) G- f3 e7 g: o' a
}5 _2 z! S( p% C9 y) |: |4 p9 d
T# @, J+ t" f9 y* jmodule_init(led_platform_init);+ \# s9 C5 e4 l, i9 F
module_exit(led_platform_exit);9 Z# g, o- F# P
8 p) l6 f. U }* }/ u! F' r7 P5 zMODULE_DESCRIPTION("Led platform driver");
2 u& j4 d; t* p4 ^3 HMODULE_AUTHOR("Tronlong");
. n2 S+ Z2 ?. D4 m8 AMODULE_LICENSE("GPL");9 h7 C$ \8 x1 Y: x5 e1 o$ }, q9 L
$ O) I, m# w& w8 D+ K! Z1 r% M
|
|