|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- o a( r: y/ J! N
#include <linux/init.h>9 b. Z! G( ~( Y" i: w0 H2 P
#include <linux/module.h>" ?; q9 F9 Y0 i$ I1 s8 G, {
#include <linux/kernel.h>, p1 o- Q% X! j% }/ q
#include <linux/types.h>* D z- p; \9 M- P
#include <linux/gpio.h>
; @: R5 A+ T: s, D9 w#include <linux/leds.h>+ c1 I- n; a2 `& S( e
#include <linux/platform_device.h>
9 y. _8 ^9 A1 M3 f4 C
' ?# g5 n; q- S" e7 ]0 U! T) i#include <asm/mach-types.h>
! ~' C Q% {( D# b7 C$ H#include <asm/mach/arch.h>
3 [' N( c1 x- `4 k* j2 |#include <mach/da8xx.h>
8 f% S h: p3 W#include <mach/mux.h>4 {1 [6 ?0 {8 J) ~! z" Z& A! W1 M
0 j1 d) k/ J7 @, ^#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); }4 Z. ?* d% I' U' e1 y e3 ]
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( M0 Q' P+ x. d9 i
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- q. h) F4 X- O1 B! k8 ]( M0 o#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). z; H6 l' _+ o# h) l% ]
) Z8 p" t' ]: @+ R' t/* assign the tl som board LED-GPIOs*/3 L% j7 F: x+ p% D
static const short da850_evm_tl_user_led_pins[] = {! M# r6 [& @# @4 e; ^: r8 Y, I
/* These pins are definition at <mach/mux.h> file */
; q, M) c5 f( R& b# u$ D7 K DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. }, V6 w% R7 x; s: Z: K -13 C7 N' _' H! }5 \9 f7 `5 g; J6 ]
};/ x8 N4 H7 x6 j/ j9 n
0 b! _+ b1 p4 k8 |3 @4 G8 w
static struct gpio_led da850_evm_tl_leds[] = {
/ \# R* d# G: j3 n' O {' x) N3 X: i- P( x
.active_low = 0,
3 G; g ~8 [" b8 x2 k .gpio = DA850_USER_LED0,
( R5 Z5 m' v- G1 O( t& G .name = "user_led0",
- A F- K3 |4 |1 {5 \" u" I .default_trigger = "default-on",8 u8 k3 l7 L9 B4 x7 p+ V
},
$ |8 D$ a) b& F3 {/ @1 q0 ? {
m$ ? c5 h. o* g/ Z .active_low = 0,
' O# P4 z" D9 S, z) d! d0 g- \ .gpio = DA850_USER_LED1,
5 q4 a! ]3 x5 f0 X5 s. ~ .name = "user_led1",1 h5 U9 L% w# h* f
.default_trigger = "default-on",
' }7 i* ^3 h/ c' n8 [ r: g },
" I# |) t7 E8 v8 }2 _! J {
9 ]9 D6 y- X |. r, i8 \ .active_low = 0,, {6 g& O* ?4 ~/ H6 q$ ~, k
.gpio = DA850_USER_LED2,
4 ~6 b' f+ n5 P8 G .name = "user_led2",: C- O; e1 P1 g6 f# `' N# i
.default_trigger = "default-on",
b- j, t8 L# Q },
' x# F( y* p& _! T, @6 a {
: Y5 S3 F6 C+ Z. _ .active_low = 0,
9 i1 E0 T( c- j7 S$ ?4 \0 t+ I .gpio = DA850_USER_LED3,
) r7 b! d5 Z$ ]% V( F3 T. T9 u .name = "user_led3",5 K8 o* b/ U* F% [1 r1 _
.default_trigger = "default-on",3 E5 y# P: G3 S
},
! `) y7 Q% }* }+ I};# W7 Y6 _* x% @! r( B" D
4 l; ]! P& L, r) `' v: [; xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( W7 u, [9 I |- a% t2 K
.leds = da850_evm_tl_leds,
8 O4 t" x k+ u( Q) W .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 e/ d" _+ V4 j C! ]+ y; R};0 c z4 v) \/ ^) y9 m9 F& B
4 D5 c( y/ f7 r; F- d- `
static void led_dev_release(struct device *dev): f/ L# R/ s8 b# Z( S
{
: N- g* B' A# O* }& V6 ] k};1 N* Y4 ?, [. ^2 s
, {* K3 q* j. P9 S' Z; P; c
static struct platform_device da850_evm_tl_leds_device = {
6 s( X8 n3 n7 B8 }. [* i .name = "leds-gpio",
1 P- a, h3 L5 P R2 l .id = 1,$ q1 D1 E; a: p. Y; [
.dev = {+ _! J; C7 f; K$ l+ @& Q
.platform_data = &da850_evm_tl_leds_pdata,
4 R9 k+ H! n) G( K) y. V& b. p .release = led_dev_release,5 n1 s) }- P# o% t% X( r5 A6 t
}
* a) A4 M4 v+ _# j/ W};
9 g" Z. x! N I/ j- N+ ~: w/ {. q. Z1 e- Q3 q! \ E
static int __init led_platform_init(void)1 q* N8 `8 u0 a, t
{
9 Q& Z4 p* c; ^7 N$ Z9 w int ret;" i7 m( v' p5 X- r2 L0 j
#if 0- l. z& U& y# e- m% t |* w7 b
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 j1 N# ?5 O/ d5 n
if (ret)
, Z; i" E5 b, C! V2 k pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 Y" ~% ~7 w" F7 J+ P: ]8 l "%d\n", ret);( e' k( {' o" M
#endif# V5 H1 Z3 U$ Z; O b- d+ [0 f
ret = platform_device_register(&da850_evm_tl_leds_device);; O. z4 E- X' j. b" j5 F" H
if (ret)" }7 L1 W5 ?) }9 ]9 X
pr_warning("Could not register som GPIO expander LEDS");
( T9 x+ q6 E- X: M V else
2 V$ V" Z H; U9 g0 b printk(KERN_INFO "LED register sucessful!\n");
/ y$ v/ o5 K. X9 A5 P
7 H4 [/ L- V+ T5 c0 d) v return ret;
6 z' F6 o0 u N& J" l, L}; o: C! Z4 M; O! ?( l, G( U
9 s7 Z1 S9 Q: [- Y8 t9 X" V
static void __exit led_platform_exit(void)/ x5 y8 |" A1 C2 J2 a9 r* I1 u9 p2 x
{8 o. t4 B0 {4 b- F3 b. x+ x
platform_device_unregister(&da850_evm_tl_leds_device);- G& R7 {; j0 q2 g& i" V
' M& _1 L; u1 k6 z+ y* E- Y printk(KERN_INFO "LED unregister!\n");2 N3 [. h% O9 r7 B! t2 o6 H
}
2 ^7 \" D4 m9 w( v% p
2 K$ c! U. r3 e3 Dmodule_init(led_platform_init);
0 e, {) V0 M9 @0 V$ @module_exit(led_platform_exit);
, ] z, m7 l. r% [+ d% w7 T3 G" k b( w3 g' Z9 n% Q4 I
MODULE_DESCRIPTION("Led platform driver");
, u! d k( ~+ {1 c, _MODULE_AUTHOR("Tronlong");8 ]4 t# [$ d6 D: a' ~
MODULE_LICENSE("GPL");
& w! s+ \8 A6 R7 M, J8 w( z" w1 b/ n! n5 N: Q. z6 M; A) v" I
|
|