|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 Z; A$ T J5 D, k+ `* v#include <linux/init.h>7 C- l* a, G% G; x. f8 _# V
#include <linux/module.h>" _+ E1 }& b5 g: j7 I. W
#include <linux/kernel.h>
3 N9 ?* d( a9 y ]#include <linux/types.h>6 c" z O+ s) H4 \ c- I
#include <linux/gpio.h>
8 ^( |: d& l9 z( \" t#include <linux/leds.h>* R% ^. v; g4 b7 b6 C
#include <linux/platform_device.h>
4 ]: E& u( v6 ~
9 B2 o8 P r0 ~5 @ L; Y( t#include <asm/mach-types.h>; y# S4 z. V# R7 r( Y
#include <asm/mach/arch.h>
4 V S- g$ Z0 b7 }; g5 b#include <mach/da8xx.h># d' T T$ w. Z5 @, I& h) Q
#include <mach/mux.h>
; b, |' b2 T" ]1 q+ c! Y# O
. ]9 r" Z) t; }! i) R/ x& Y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 y q0 }7 f, \: {* v
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 y+ s `5 g# g# I8 W9 J#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) a9 ?3 Z$ n- ?
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), O$ P6 Q U; r0 @
1 X! n1 F/ F5 q
/* assign the tl som board LED-GPIOs*/
5 d& M. D. L) @, M( j$ k2 u7 _static const short da850_evm_tl_user_led_pins[] = {
& l( p5 l# b+ R9 K c% D3 ^ /* These pins are definition at <mach/mux.h> file */
8 V1 d' a1 P. ^/ K- C/ L5 k DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, x' G- ^; O8 f
-1, P2 {& d a9 Y% ?+ N* g! u
};! |. l. Y6 o5 d* N s
; t7 |$ u* v7 n4 S8 d) {% K' t& O
static struct gpio_led da850_evm_tl_leds[] = {
8 w3 @6 b9 N/ T+ u3 y2 G6 C3 @ {4 s7 a' b! H& m5 T9 K" [7 c4 W" J
.active_low = 0,; B- N6 P- f: }2 l
.gpio = DA850_USER_LED0,) ^8 h* F; Y1 ? ]- f+ ]
.name = "user_led0",' X6 ]2 L. Y1 r4 A5 |. A. {
.default_trigger = "default-on",
7 |7 m0 ?: ?: c- l& _- P& h },2 M7 F ?; F. m0 [
{
2 e) g" U6 c6 g+ D8 X! j: a .active_low = 0,
) _4 R: f- j2 s2 i .gpio = DA850_USER_LED1,6 ~* p6 o& }) z$ f3 J% k
.name = "user_led1",
' o' a8 { v% L .default_trigger = "default-on",. @$ p1 p: x2 D
},
% f, M4 q. F% L% q( ]9 [& W7 V: { {
# |9 R0 v' |% D. r( Y/ ^ .active_low = 0,
& K3 P' g9 q# y$ `( f; C .gpio = DA850_USER_LED2,
8 w) h. [. _' o% Q .name = "user_led2",2 B- I; n2 [' ]( f
.default_trigger = "default-on",
- Y) n2 M, e9 J. n, J- i },
+ J$ Y( b {) ]; B3 l; i9 y2 N) j {
( ?# ]4 `% h6 W( @ .active_low = 0,
& S/ H4 t [" E* r% ?/ \% p .gpio = DA850_USER_LED3,8 o' W2 X A( z. t7 Z. e0 c
.name = "user_led3",
2 ?& W2 W4 b! S6 E .default_trigger = "default-on",( N$ E0 n! g4 {
},
3 V( o' s d3 t" P8 d};. @! P5 V" k% _5 K( R
; p0 j3 [% U1 Q, U2 }. @
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 b. k$ D/ f. d) H .leds = da850_evm_tl_leds,: o6 Y) W+ ]' g9 A
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% e t9 [$ k3 k* `. }/ T1 b; w};
; K t% N9 r" r! y9 Q; Q+ Q: ^/ p' r. K* F0 V6 e
static void led_dev_release(struct device *dev)
3 V* d# |- ~$ [{2 M; E& w( m2 ^+ A) q" L/ g" v' V
};
5 q2 Q( p3 t9 o, [; o' r
) P5 ]2 G2 E9 \' d& |6 C0 _static struct platform_device da850_evm_tl_leds_device = {
7 J0 H, I/ U, @$ T' N, ^ .name = "leds-gpio",
" K, u! ?: O# p# H .id = 1,
; ^" v2 {0 h3 a9 @8 U .dev = {
" ]/ k7 @6 V1 C" i8 z4 M! d .platform_data = &da850_evm_tl_leds_pdata,
) v7 e4 w9 x0 @( ^) S( N- M8 L .release = led_dev_release,4 q/ Y1 m# f* k' p; e/ S5 g1 {, m
}, ?( W/ j% G5 G: M/ \1 E; T
};% g* L* Y# f' f% o
& k, D. D' w1 C# S/ Vstatic int __init led_platform_init(void)
7 R/ N2 x5 {4 b4 U* o{# |$ B9 o) i, |5 Z' w1 B# d
int ret;6 S T9 ^$ c8 L9 M6 a
#if 0
# r+ H6 K7 l8 P; { ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 F. f; b/ D' @
if (ret)" N y- B0 k2 m3 w7 L
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& w4 t( U+ G& `0 r+ | "%d\n", ret);' {0 H2 U% {8 d
#endif
8 A8 p' W3 X! U% c) [1 I; | ret = platform_device_register(&da850_evm_tl_leds_device); x. F/ {4 `1 [! a
if (ret). Q1 ]# `6 R* c3 T) e: t6 Q
pr_warning("Could not register som GPIO expander LEDS");( Z7 g( ?4 w0 a- i, g/ J5 u# q" M9 O
else
2 G; o0 I7 K5 H9 O$ E printk(KERN_INFO "LED register sucessful!\n");, ~# z. u2 ^. \3 v
2 @7 O# k: @+ S- h& K return ret;
. T, T2 V, p0 G8 {}
( D C; e: {* P3 ~! o ]
# `6 I3 y- n9 \7 f9 Estatic void __exit led_platform_exit(void)
5 m6 r% R* M' t! S- p{
% ]: {' N. o: J6 ~1 }- V platform_device_unregister(&da850_evm_tl_leds_device);
; i& Z( j+ L4 A, ~# w$ q2 Y2 Z. `+ i4 ] S1 I i$ U
printk(KERN_INFO "LED unregister!\n");
: G" O n8 S0 ?5 H# d}
# [, p ~: K# g' l9 m. ?" A' {
$ S j4 L( d5 R/ _module_init(led_platform_init);; y$ r5 I( q( v5 Y" T
module_exit(led_platform_exit);
7 {6 [5 i! h8 |4 T' Y
: [$ [9 q. l. w0 I a8 y) o LMODULE_DESCRIPTION("Led platform driver");. p* [/ P6 N3 a
MODULE_AUTHOR("Tronlong");4 K; f. g3 l0 w' |
MODULE_LICENSE("GPL");0 i/ ^4 P& |% ?" ]+ B/ c
6 B) Z# r' `+ r8 o( m4 o
|
|