|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& j& H& Z1 [ S+ F4 e8 e9 Y3 L
#include <linux/init.h>
. a5 b$ q' \' Z$ O$ |5 w/ G#include <linux/module.h>
; ^0 X! \% `$ W6 R1 P#include <linux/kernel.h>
8 ]: C, v6 b6 e3 `) y0 n$ C#include <linux/types.h>
/ d; K# v' z( R1 |7 @#include <linux/gpio.h>
8 P9 I0 c6 {1 p" B" ^#include <linux/leds.h>
$ E& U$ d7 ?! l+ l2 u6 C) Q6 c#include <linux/platform_device.h>
% n4 s: @! i7 R" V. ~" r( V5 w. _/ E& Z( j; y
#include <asm/mach-types.h>0 {' ?7 X% J. M5 [% V8 F
#include <asm/mach/arch.h>
$ a/ J B: T4 Z#include <mach/da8xx.h>, C5 F, u9 ^ A5 A
#include <mach/mux.h> T; b9 d ?" K' I( z& _+ f
. }2 W/ I% j; Y: t* C
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# T9 X" ?5 ?/ K) C1 ~
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- k0 | M% Z! K& p! r#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) f" U2 i; }- E1 ~- h4 M
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 i) k! E0 d; K8 u$ X& P- L
! ~7 I1 u) m- |: K+ v1 Y) M/* assign the tl som board LED-GPIOs*/
+ t+ _" O. ?0 L1 R! {3 Istatic const short da850_evm_tl_user_led_pins[] = {
% L6 V6 [7 z: x: k /* These pins are definition at <mach/mux.h> file */
7 F1 X1 y" P; ` DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 M" s/ x$ M( l) C, @0 ^
-12 K1 z/ Z- L3 X; d6 F" T6 E, M
};$ u3 `9 b, `: H, b2 E& E1 G
" ~1 \2 b! Q+ s2 u2 n& ?
static struct gpio_led da850_evm_tl_leds[] = {. r/ t: t. b$ r
{9 U' k. k6 x5 P3 S# [3 n
.active_low = 0," s- i6 ?' D6 j: b7 I) c
.gpio = DA850_USER_LED0,
5 }7 `" f, J" V# r .name = "user_led0",
6 A( Z% P. j8 D# Y( o0 }: A& n .default_trigger = "default-on",6 ^; j" Z5 v/ y
},
& F; B" G9 `" z- f {* m h3 Z d; e) Q
.active_low = 0,
5 g, J& c) t1 j+ e .gpio = DA850_USER_LED1,
( r) T/ i# q( e* G, c3 h u .name = "user_led1",
5 } \7 k' s+ ^( ?4 _7 y8 B .default_trigger = "default-on",
4 R: v9 H b2 a' v. S; E( j3 |# n },
* g \) N( j9 D9 a& l, l4 \( O {4 B9 b! F0 ~3 l/ X* J3 A+ j
.active_low = 0,
0 q+ s& N O6 D4 E .gpio = DA850_USER_LED2,
( y2 `) a/ N% c, u( G$ F .name = "user_led2",
: t: A% i. \0 }9 r( a# O$ C* I .default_trigger = "default-on",
/ H( r* o& n( H$ Y0 ^! j/ r },1 Z; Z+ b: E- s3 I9 g3 l
{+ @- H: o( X3 W |1 {, \! ]
.active_low = 0,. @* X$ H! I* } j) y7 p. n' w
.gpio = DA850_USER_LED3,8 o% e5 Q/ S0 t) H6 s" i' _
.name = "user_led3",+ W' C. x6 v; v- Q# c
.default_trigger = "default-on",& d& D% q9 q2 D0 s, h5 W
},: L+ G% H: y8 I" R# u8 i- l& j2 W3 h9 a
};4 M' b" S1 P3 L6 c
1 k$ W$ l( W sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 ~/ M- d& n& o8 v0 m9 g6 _7 W .leds = da850_evm_tl_leds,
& q. f* s9 [7 d0 z2 Q6 q( c .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 R" V# H0 R ^9 W
};
$ ?; {9 s, X, U1 m x) f5 c! }- z; [- T6 ~1 R( _
static void led_dev_release(struct device *dev): q& Z) \0 e6 }" D- c: R
{
3 M' ]) A0 z: _6 i3 |; C3 u};; g1 o" ~) {' Q& G4 d
, H) Z6 @4 C @; {4 i# x
static struct platform_device da850_evm_tl_leds_device = {) U# _) X# q7 C
.name = "leds-gpio"," _$ Z+ q: ?& Y3 S0 Z
.id = 1,
1 a/ c+ L( A$ w; o( t8 \" ~' C5 \ .dev = {
, [! {+ W: B9 n D8 |) @ .platform_data = &da850_evm_tl_leds_pdata,
( ?- `% X- K) R0 o* k; @3 D; x .release = led_dev_release,
$ W$ R9 I) Y- { }% H! E& M+ W1 [: W
};
8 ?8 I: @" o' `
; W9 \5 c2 N7 j1 Ustatic int __init led_platform_init(void)
1 s( {- \1 T4 V0 q4 g* W{9 L& L+ m, L0 l( ^4 L2 [
int ret;
$ l8 N+ x& @4 C8 p* f2 [. f#if 0
# w, M. G! e! l4 E- Y2 [ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: z# K3 s- L1 s* s( e if (ret)% {0 b. G' n4 T) d e! \
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 j3 n4 o) T Z# N
"%d\n", ret);9 m7 r. ?/ |* o1 {" z- B/ v7 l6 M
#endif
* o' K# C9 l: m& E ret = platform_device_register(&da850_evm_tl_leds_device);# G0 E7 W w! @0 o ~0 \8 S
if (ret)# e' `3 I. M- f5 O; V
pr_warning("Could not register som GPIO expander LEDS");4 P1 c/ n( W T1 s6 }# S* |
else$ n* [1 n! ~: u% I1 C _
printk(KERN_INFO "LED register sucessful!\n");
* s k! {6 C+ U, N) k# v! x
" ], b) _( ]" E9 A return ret;
, _0 s0 c) o; c1 G0 j}* u! T! i6 B& O; f
" {* U) X; Y5 o7 H2 y; ystatic void __exit led_platform_exit(void)
6 w; j! ?# P: z. O{& O+ R; L5 Z% U3 ~
platform_device_unregister(&da850_evm_tl_leds_device);, v/ l5 C6 ^2 P
7 ^) l" r/ A) p H% `1 a printk(KERN_INFO "LED unregister!\n");
% z4 R2 Y1 k2 J' {}
( s/ `. V- z2 g# P, u
" r1 t# S, |; e: J( Gmodule_init(led_platform_init);3 W, r8 K' g5 C) d
module_exit(led_platform_exit);
1 y0 G1 r- ?2 c+ l- `9 {
/ s8 {; G) f$ a2 ]3 `MODULE_DESCRIPTION("Led platform driver");
6 y% V$ c8 W! E) @' _MODULE_AUTHOR("Tronlong");
/ t7 G; B8 s' S, S y% w% L# f' _MODULE_LICENSE("GPL");0 C) Y- V+ h5 F+ |. h6 w
$ F+ m, I# a( H5 L7 ^4 D: z0 f
|
|