|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' D3 q# ?3 h$ ~ H, o, @, e8 o
#include <linux/init.h># [# D# c2 r( V/ ], a
#include <linux/module.h>. L. k) V$ U2 p9 s/ r
#include <linux/kernel.h>
0 L9 Z: c6 M, V G8 V5 j#include <linux/types.h>
H% u4 t3 w3 ~7 t- ]#include <linux/gpio.h>& H! R- p% X: W# m
#include <linux/leds.h>
2 x% g- g$ L% L, R0 c#include <linux/platform_device.h># _9 |) V+ f6 T, H: u
$ P' M5 b% n1 N3 [ Y) Q# ^; I
#include <asm/mach-types.h>* l2 @7 ^, u! W
#include <asm/mach/arch.h>- n' R7 q2 ?& [3 N9 x5 c
#include <mach/da8xx.h>
' R, k! V; Z9 S% a#include <mach/mux.h>
3 Y" O4 e- ]- t/ o" T# U0 w+ K- {, n5 F/ \- |5 N: X+ C" K2 k
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# ~" X1 J& m/ u. K: \#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 L9 w( U5 B6 _) x#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 n2 ^# ^. \ P" U! a5 i#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) z: E- N7 A3 D/ d) ~
) e$ \1 R5 v& @( N h$ R/* assign the tl som board LED-GPIOs*/0 ^! P0 m! n. _
static const short da850_evm_tl_user_led_pins[] = {
4 P" m. p5 O' b /* These pins are definition at <mach/mux.h> file */
3 T2 M K( g/ n" \2 M DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. i! Z* \5 L. A3 F( d% J. R -1% j/ S3 h# K3 P5 H
};. N4 ?7 z' w3 f9 U) t: D
+ m6 Z* Z& J) M5 @7 mstatic struct gpio_led da850_evm_tl_leds[] = {
3 x( d) g5 V4 A3 b3 W {
& n4 J! g) s# a! v6 z .active_low = 0,
2 }7 t! o% d8 B' E .gpio = DA850_USER_LED0,
) I7 c+ G$ w8 X6 N- ]/ A .name = "user_led0",' _- n4 N3 j0 n0 ^
.default_trigger = "default-on",
, _9 b& ~$ i* @2 K( l9 b },# [2 V& k% [+ A6 {+ k9 f' V
{
+ d# l' k$ G% {! e; a2 [ .active_low = 0,
. l2 Z% Z- c$ O8 Z .gpio = DA850_USER_LED1,
2 [2 s" G4 \/ n .name = "user_led1",
& C$ H' O( A- C' c' A .default_trigger = "default-on",. k8 }; r& k$ M# k
},
! k ~+ @4 o2 ?' L3 P2 N* N% i {
* s) _. O! }: x8 f, Z& [ .active_low = 0,
* K8 F$ [1 k; `+ v; _/ j" w% e- Q- W .gpio = DA850_USER_LED2,) C7 u( m* E1 i0 |4 C! B0 X
.name = "user_led2",3 y" t+ K" K; l5 X$ p
.default_trigger = "default-on",
# b, _- k; i# j$ x& _% k },, f7 A4 i2 s% |
{
p4 z5 K$ R$ E4 ?- `( P5 z3 T) L* q .active_low = 0,$ I) A3 J& O' o% H# D4 X; f) s& O
.gpio = DA850_USER_LED3,/ O+ }7 m8 d3 E& _
.name = "user_led3",
% n5 R- {1 v1 I" H5 ~! v .default_trigger = "default-on",
# X- D3 H7 J# { }1 K) d- h& z },
! b/ D- q _7 B/ @8 i};& R6 ]# n; u7 U5 H, P
! X6 B6 }. G, W4 Hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 r! I. P! l' Z3 V5 X; o7 E .leds = da850_evm_tl_leds,# U6 k! b' y% q/ s% n
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. _/ H( E* c) r+ d& _6 R* s4 `$ D};5 x" K7 A1 u, W* T( Z3 t7 [
& |, \' g+ _) t6 wstatic void led_dev_release(struct device *dev)
; |& d$ q0 D9 ?/ s4 M; c{! a" R& U! N c" b. b
};1 `+ \, p; @* W+ ^9 P2 }
! S! X- U1 y8 M: y- f4 H2 Hstatic struct platform_device da850_evm_tl_leds_device = {
! N$ {* _6 B3 @5 p" R: E .name = "leds-gpio",$ N/ V* `/ q+ d7 s0 X% w
.id = 1,# A2 n! x( M; P) B C2 J
.dev = {
! B4 j8 y: Z& o# J) a/ q! k2 H .platform_data = &da850_evm_tl_leds_pdata,
0 N- Y: H6 {7 U* E! a$ _* v .release = led_dev_release,+ Y4 \# ~, A- C% d" K
}
9 M1 j0 l+ L0 h) b. N};
+ t/ G3 ]6 J% k* n, y/ h" R. x& G! e1 Z8 Y( r* _4 @
static int __init led_platform_init(void)) G/ h+ }, f8 g/ V
{3 G' V" D7 V0 @8 M
int ret;- L7 J0 c9 g1 ], Z O
#if 0
# b7 o& [- l8 h ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 S9 e* I+ l- P. v: a0 N! f
if (ret)
' @5 x! L* v: Y3 V pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( p# w9 a# j: b* i) ? "%d\n", ret);: `1 T$ J) S ~
#endif/ z# ~# z9 s; \7 x0 |! Z7 H' c: j M
ret = platform_device_register(&da850_evm_tl_leds_device);8 f8 v9 D* ]( v$ ^3 A. a* ^1 e
if (ret)) f" ~; a. a; ?% w4 N; W0 S
pr_warning("Could not register som GPIO expander LEDS");
$ E. W7 F# K" P1 G+ h else
, g, y3 }; O; ^8 ^) p9 d- ^ printk(KERN_INFO "LED register sucessful!\n");
$ `" R$ c1 g# X
* t1 |2 P W: F$ ]; X4 a5 p6 a return ret;
) L8 Q5 b: m! H! B5 j& F1 W- Q}' [" Y4 i. i" i9 c, x. m3 C' P0 F
0 ~: }$ R2 q: C0 |
static void __exit led_platform_exit(void)6 v' I$ E- _% D0 R; x6 p7 ~ ^
{
* t) p; v5 F+ v0 K5 T$ c# ^ platform_device_unregister(&da850_evm_tl_leds_device);) H7 {+ ]' W& o j- k2 F5 v: C- ~
' z4 o( m' b, _( N2 @3 Q6 c% O
printk(KERN_INFO "LED unregister!\n"); m3 ~! q* k! L% f5 L
}
; \% A$ j" v) o7 S! D
) R8 Y- \, J" u9 p1 _; ]module_init(led_platform_init);
6 ~- e0 }$ o- M. C. Tmodule_exit(led_platform_exit);
+ e4 y3 n1 j) P' h* ^( {, A+ ~9 I* u
MODULE_DESCRIPTION("Led platform driver");/ b$ X3 S7 y5 _* D4 u
MODULE_AUTHOR("Tronlong");9 e, Y. S1 u& T9 j! \3 W+ o0 N5 y
MODULE_LICENSE("GPL");
3 g( |+ {3 U& D/ D3 W) S) w- L/ V C j, z! f: D$ w! C
|
|