|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 m0 ]. }. ^ u* o1 _0 t
#include <linux/init.h>( n) ?/ Y& o( ^ p$ c: k0 |5 F4 d0 X
#include <linux/module.h>6 u& U$ \$ H& Y# X0 [
#include <linux/kernel.h>
- B5 x$ J8 ?1 R% W#include <linux/types.h>
- @+ [4 E4 d4 ?#include <linux/gpio.h>; W0 ?# I. t7 l( k
#include <linux/leds.h>
- }6 }) U. ?- G#include <linux/platform_device.h>
! x0 W, C. r# C6 ], v3 T
( q y* b% @8 U#include <asm/mach-types.h>7 W4 v& A+ L( L/ C; A4 K9 T) |
#include <asm/mach/arch.h>
9 Z1 }; D' v* h: q/ I2 X) D#include <mach/da8xx.h>
+ c6 _4 r6 x; L, |#include <mach/mux.h># c% T) I8 f! i. G
, T7 w% Z7 p- U: l. o2 I4 q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& N, v1 Z. @/ Z3 u" |#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' t: C5 H' Z, N- t5 P* Y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 r8 f; F4 M2 G$ U; R% ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- C2 P" [* ^- f
$ _5 L" i" J: |; S2 N/* assign the tl som board LED-GPIOs*/
* `6 b6 r$ r0 `static const short da850_evm_tl_user_led_pins[] = {
2 b' N" @7 @3 i# [ /* These pins are definition at <mach/mux.h> file */
& a R( |- } u# U; W" f8 s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, ?& G6 f$ C$ H8 {! u- _- C
-1; z; l* X2 P3 W m
};2 B# L" h) M& Q2 u4 ~2 }
- Y: ]" Y$ [6 {' y2 O7 S9 G
static struct gpio_led da850_evm_tl_leds[] = {$ p* P& t* Q g
{" G% i2 p! @0 ]) R$ y2 h/ v l
.active_low = 0,1 Z$ E/ c* ^6 ]/ g2 Q
.gpio = DA850_USER_LED0,
0 C C" z+ f M$ Z .name = "user_led0",! }1 ]; L# o3 g) z+ T# [6 m5 u$ _
.default_trigger = "default-on",
1 g2 { S4 a! t9 q2 k },
" @3 y+ `; p% z+ G d {& K2 B) t+ @) @2 v9 b
.active_low = 0,
& l4 P I' g4 ]* m .gpio = DA850_USER_LED1," L% l9 r) K! i
.name = "user_led1",
0 X9 f H1 e$ \) `+ M. O .default_trigger = "default-on",4 b9 p5 x- b0 y+ e) R: v, B
},: s0 s" f$ S7 F! _3 X
{
4 o/ Y# l s' {. W/ d2 U" I9 j .active_low = 0,& k" P$ t7 _7 I# W8 T2 |
.gpio = DA850_USER_LED2,
/ ]" U4 Y9 w: X* j! k8 L) h8 ?3 t .name = "user_led2",
: a+ u1 \5 j* I- v$ u4 z .default_trigger = "default-on",
d5 |+ t1 |; [# m# @; \8 L% g },
! \9 \, A6 V3 h {
" r3 x! b! J2 J& l .active_low = 0,
+ n- D- ^( c) G. k .gpio = DA850_USER_LED3,: `- i3 C1 c1 O) }- o" ]: r& b
.name = "user_led3",
$ [) ^; W4 g/ P1 N .default_trigger = "default-on",6 d4 \6 b( {$ F
},7 _' ?7 v! x. Z! Y3 ^) p' s- O7 z+ c3 ~
};
$ T+ |; D8 R" {: N$ w/ q% B& ^; d
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* d+ d" A ~1 G" h+ c
.leds = da850_evm_tl_leds,
" c1 }. c' f4 w .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 M$ L, m* Q1 C0 q ?% b};: _$ ~8 E3 n$ n7 f% a/ M. `/ ?
- ~) }# x- ~6 x2 E( Gstatic void led_dev_release(struct device *dev)
% ~3 V3 g* {9 q{2 }' t( H% Q4 O8 S
};
/ B% S. y+ d' y- _ S$ h+ J; T. S( n
static struct platform_device da850_evm_tl_leds_device = {
' Q- Y9 F/ ]7 C: }! }) E1 _ .name = "leds-gpio",# u3 b; M, ^1 E6 |
.id = 1,% ~8 i7 d. O" w" i. m
.dev = {
7 \/ r- m. T) i" v! _, c1 V& {+ D v. p .platform_data = &da850_evm_tl_leds_pdata,' k: q3 V0 r4 X4 w. k- S* ?
.release = led_dev_release,
% H7 ]6 {& B* e" O6 a& h }% i) s6 W2 W2 c$ \/ B
};: W) Y% @5 y- g7 R& t
$ W3 q+ n4 Z( c4 z6 G; e9 y
static int __init led_platform_init(void)9 K0 M1 ^4 T5 ^0 ~5 T, {: h/ D
{
1 |3 E4 z1 j. u int ret;- w1 o) O7 Z) t
#if 0
" \2 c3 F' `- e" |' s1 v: t7 ]3 r7 B8 l ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' P% F/ i, g" n4 h, J
if (ret)% X% A- K- U3 r1 B' X
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 M. e( V& h( a! h
"%d\n", ret);
: ^( G/ S% e* {4 ~4 g) p#endif
$ {9 X! }% k9 B9 t+ U L ret = platform_device_register(&da850_evm_tl_leds_device);9 m* L6 S4 @* S3 F( m
if (ret)
V/ y. D- `! N pr_warning("Could not register som GPIO expander LEDS");2 j8 J) N7 M6 h8 [! @
else8 q* p1 R4 ?- I5 K
printk(KERN_INFO "LED register sucessful!\n");9 \6 q6 _3 Z8 X8 u* [
1 b0 b; O! Y) S return ret;7 n# @; m, U7 d# `8 m6 v0 t
}& t3 L: c/ n+ d0 j" j |
- w/ t3 o. \& c" w- ]( Hstatic void __exit led_platform_exit(void)' G# a( W8 L6 q0 n6 W/ |9 f' m" N
{
& W- q# R- ~* L5 h) k. N @% w platform_device_unregister(&da850_evm_tl_leds_device);
+ K( Q& h- T: j4 b+ E
" g' X% ` K3 K! H" E* C printk(KERN_INFO "LED unregister!\n");
- P% x& R# b! t; f* }! \8 N}( C7 a+ J/ r7 ?
4 f# m2 H# b6 umodule_init(led_platform_init);: h7 ?* ~0 O+ c3 B. @ s' t1 g. h
module_exit(led_platform_exit);" D& \+ }3 f! D4 t ?, n0 e2 A
- ?' M/ v; M/ V( _; N6 |MODULE_DESCRIPTION("Led platform driver");5 A5 Z# J3 Z9 Q3 y- k$ w
MODULE_AUTHOR("Tronlong");
( }! j7 [' V' k1 ~# }2 D7 P$ uMODULE_LICENSE("GPL");
8 z* e+ q: h- K4 P5 S# l2 H' K) v; n. s' Z& N8 U
|
|