|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 a0 b8 X* E+ a- l2 O4 z/ Z: Y
#include <linux/init.h>& K Q+ d# G6 K
#include <linux/module.h>3 P+ v6 T! R; f0 {+ E% E. @
#include <linux/kernel.h>+ T, t# b2 _2 k$ g
#include <linux/types.h>
+ w, N' l% Q4 r p9 O8 n1 T#include <linux/gpio.h>* n% i" i0 k1 }: S L
#include <linux/leds.h>
5 m8 H$ H6 K' m( F0 p0 C8 r; @#include <linux/platform_device.h>
8 |' F. L8 F# k; e. K& y
8 x# u2 Q9 Q+ U" z8 F5 v# P# ]3 i#include <asm/mach-types.h>
# {) n. H7 d: [#include <asm/mach/arch.h>$ D5 p% W% C( m5 R; q7 O
#include <mach/da8xx.h>
( T& @& B* m4 T#include <mach/mux.h>6 a& H5 p( A1 C( M+ B6 [4 x. ^
3 t, E, B+ R9 J
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ x/ \4 O$ v6 C% n+ D& {
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: t& T; w3 L8 h8 E#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); F, D7 o9 d% b' R4 u H {
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( e' Q5 u- N/ ?# x
3 @0 B1 D' {, m/* assign the tl som board LED-GPIOs*/2 S0 O4 U5 }% W6 F! u1 E; f# `/ m
static const short da850_evm_tl_user_led_pins[] = {
2 j9 A4 Y% R* Z4 B /* These pins are definition at <mach/mux.h> file */+ X8 b' G: i4 l, J
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 i; G, O7 u6 n% |8 t -1
- a( \. S: y( `* [};
9 A4 T! i y2 l6 W) S- }, o( B9 e5 j! [5 M4 ^
static struct gpio_led da850_evm_tl_leds[] = {- q% a# ^' V( S3 K3 L6 S
{
# j, K7 `! ] o, ? .active_low = 0,( |: z- d( r# M8 v" t/ t
.gpio = DA850_USER_LED0,9 E4 y2 \& l8 S
.name = "user_led0",
V4 \. J; R7 d# b3 d7 U2 F .default_trigger = "default-on",5 }( {$ N6 T$ i, ^2 Q4 j; m) N
},- H% p5 `6 M3 B& i! u/ C
{
+ H- C$ y/ U- N1 l8 s .active_low = 0,* u8 ]5 }. w$ N# f x
.gpio = DA850_USER_LED1,
: Y4 Y+ p n9 P3 m' E2 l .name = "user_led1",6 e) S6 n0 Y: M
.default_trigger = "default-on",$ B& ]+ {& ^6 o; c; n! I7 Z
},* |( Q0 D$ @4 A2 W
{
( I; ~. I$ B; t: B$ G5 H, U .active_low = 0,
u' k/ ~7 y& ^' H) K$ l$ A9 U# o .gpio = DA850_USER_LED2,$ D3 p& @ a4 ^6 I4 B+ {
.name = "user_led2",4 M4 F1 a* O' i0 \7 t
.default_trigger = "default-on",
1 J6 W+ @, e5 p+ ]1 o# o }, d+ @+ m# A. x% w
{: q$ O' E1 [/ Z1 V
.active_low = 0,( Q9 P+ Y Q) z n& S& u
.gpio = DA850_USER_LED3,
) ^2 u1 G: Y5 I7 { .name = "user_led3",. q$ f- y4 Y3 ^8 z9 _
.default_trigger = "default-on",
% w @* d! V/ ^3 | },
0 H7 F3 [) ?6 D$ B( T0 b* j};
( ^0 k" a9 y" L7 L r- e* m e& h& v0 w, j$ Z* m) A0 B9 v
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, r' J5 g& i6 t) |
.leds = da850_evm_tl_leds,0 x& h5 [9 Z( d) v
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; U4 Z' `, P" _5 G& L};/ s; P& j( N4 `+ B5 d8 C- `( X! O
& E" G/ }; U: {" D
static void led_dev_release(struct device *dev)6 @& {1 c" r. n" R
{! ^ d Z* \# R# r1 ~
};% W( E9 _: W _
/ ~, f8 O( m g; Y
static struct platform_device da850_evm_tl_leds_device = {
. Z5 e+ [- ~! M6 E$ i# H .name = "leds-gpio",; i3 u7 T0 U0 i/ C# b: ?. a% V
.id = 1,
0 C, E# K% O! k9 E$ i P6 ^ .dev = {
, u! @5 G/ _# D .platform_data = &da850_evm_tl_leds_pdata,
# ~) k" C$ g) ~ .release = led_dev_release,1 w( T2 N- T. y
}
( B2 H' G4 x$ G3 |3 H4 Z/ @. e};
. P& j: [, R- V2 a' H5 z! r& \9 n( X( f! ]! [0 T, Z0 [
static int __init led_platform_init(void)8 e8 @2 Z2 o2 a" X( }, K
{
) Q2 {: q: b. \. s int ret;$ ?* ^+ h5 z' k8 `3 V! ]
#if 0
; ?/ {- a5 q' j$ A ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) T' B) O5 R9 b5 `) M$ x! x; V/ i if (ret): i1 l+ m/ }# S
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( P5 r6 ~2 H2 P3 ?, a+ n0 i, D
"%d\n", ret);
* }! F5 X$ w! _, K4 M" O#endif
, ~4 ^" g6 L9 E {. R7 [ ret = platform_device_register(&da850_evm_tl_leds_device);
; w4 G V' _) _! s if (ret)& y& J5 y- @# x4 {# P l3 h8 [
pr_warning("Could not register som GPIO expander LEDS");
9 ~8 s6 y* ]* Z. Y7 f( F5 w else
- [3 D' X! y' ~8 Q- N3 v printk(KERN_INFO "LED register sucessful!\n");' k6 s* a1 O0 q, P1 n8 p+ g% |
9 h% ~5 \# v6 _$ V/ G
return ret;
& I' d' S$ F/ ^$ d6 U0 _}
/ x+ O7 O; A& v+ w* w4 P( c N. X" L5 T0 G8 A8 r: h$ i( r
static void __exit led_platform_exit(void)$ |, n$ Y# q. Q3 G5 \
{/ l$ p6 f: u( m
platform_device_unregister(&da850_evm_tl_leds_device);
8 `, h" J4 ]1 M. o
* P1 a( `6 ?4 l8 W printk(KERN_INFO "LED unregister!\n");
3 P/ W0 H: e4 ?" _}) c: u7 ^' v( l% p8 r1 d
; L. {; t2 o+ j' [/ [ S
module_init(led_platform_init);
! [* Y/ D7 c7 g, w4 X8 l7 Z7 smodule_exit(led_platform_exit);, w- D5 S; c. {& E
5 l w! f- e3 t% N/ Y4 i/ J6 yMODULE_DESCRIPTION("Led platform driver");
1 W& D, `: t+ x5 _" m! K- SMODULE_AUTHOR("Tronlong");
2 D4 L0 s7 d! s2 ^4 ]' w gMODULE_LICENSE("GPL");8 ?! N; f# y( @! K
, S/ o5 ?+ A# x2 @
|
|