|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! F) j+ _7 F' r) U# ~! B+ P& F
#include <linux/init.h>
/ l6 E' x( r; O' X* M7 |#include <linux/module.h>3 _# U/ E$ o& D
#include <linux/kernel.h>) ?" i" M6 F* d) }: g
#include <linux/types.h>
; d" q s, z0 M% `( p7 U#include <linux/gpio.h>
3 Y, w* ^9 L: r2 `" |#include <linux/leds.h>( ]4 j& g5 @1 {( d; \" m1 O4 ]
#include <linux/platform_device.h>$ t4 m$ m9 |: y
3 a9 W& u$ _6 w2 \2 ~) q#include <asm/mach-types.h>
, T8 S, Q, U$ s/ B0 ]#include <asm/mach/arch.h>
+ y* U" }" m0 i+ J8 X! x#include <mach/da8xx.h>
$ p: }& Q3 H& J. f#include <mach/mux.h>+ q8 t3 X$ ~- f b: ?* K" i6 d! B1 t
% K8 f& [% ~( d% |6 a
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 f2 m2 V7 N2 g0 Z! Y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 F5 M+ q. c9 [#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& J' j& s* J4 S) z+ j5 v
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 i$ g% P$ J' }/ C! c. ~7 p( J9 R6 f0 b8 N
/* assign the tl som board LED-GPIOs*/
I! _+ ^. }; r8 [static const short da850_evm_tl_user_led_pins[] = {& W' A& p2 R6 `9 T O
/* These pins are definition at <mach/mux.h> file */
7 g7 w. n3 W1 Q4 u: S+ y DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( x1 q9 Y9 B( A+ E2 E' I( m -12 n) Q, |7 O3 |5 `2 `
};8 N) e$ a8 Y! S$ {
6 G( s4 }4 N9 v0 c
static struct gpio_led da850_evm_tl_leds[] = {
~5 M5 d) q0 E* x5 x9 \( Q {
! d, ?* U5 a+ J: N5 B .active_low = 0,+ k: P; f& w4 X8 ^
.gpio = DA850_USER_LED0,
- {; ?4 \' |9 [ .name = "user_led0",
: F% H6 o: V: l- O7 a; R9 O$ Y, u. \) @ .default_trigger = "default-on",8 R" w, s6 n0 j
},
! T0 Z; {6 X0 L8 {/ m {
+ @$ \; d* [3 M& z( s) B/ v .active_low = 0,; E( s6 L' c+ Z
.gpio = DA850_USER_LED1,& d% @2 |0 ]8 O+ `
.name = "user_led1",
) K9 P4 `: g; i9 L' r# L1 ^7 Q .default_trigger = "default-on",. _7 _. c' b: \) S2 ]( g
},
" T5 r9 m7 B. m7 v6 Q1 O$ d) T {/ i) Z# E7 o7 S( U
.active_low = 0,
5 S; x" [% f! q1 ]: H .gpio = DA850_USER_LED2,
( T$ T3 _: P3 |2 [2 { .name = "user_led2",
* d7 ]; i; c$ W! ^1 E4 z; l .default_trigger = "default-on",
6 J: [2 b/ t0 ? },
% b! x6 Q9 `/ Y; o {
% t( m/ k( _" _; K) C .active_low = 0,
& F6 E( g- N" X .gpio = DA850_USER_LED3,4 H2 K3 Z) {' y' m' V6 J- x2 c
.name = "user_led3",! R0 H# t) S. ^9 `8 E( O
.default_trigger = "default-on",7 p# E2 G* `: c$ A
},8 I' U" v C' K; g' P
};
# b7 ~7 e9 {5 Q4 F* f ?' }3 u
) B7 G) Z* l4 n. Cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, n( V9 r6 Y3 y" [ .leds = da850_evm_tl_leds,
# y( p! t8 p7 ]6 b% Z& x! `7 u .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 V, `4 E8 f$ q( g7 V% `
};
$ T0 N+ B. O& n+ O4 F4 V$ q9 t
3 Q( h0 Z. {; [# @static void led_dev_release(struct device *dev): v8 e& Q! E& ^/ Q5 m, G
{! X- p, ^4 Y/ r7 U
};+ c$ v; ~: p7 B6 \0 z( S x
( E$ c3 y% a8 u: Y R1 {, M k) u
static struct platform_device da850_evm_tl_leds_device = {# C8 {6 U) D. {
.name = "leds-gpio",
: t+ D8 H0 f1 N5 O1 b0 i @* z .id = 1,, I U9 W; v( _5 ?. \
.dev = {
2 _3 g; s1 k( K) T- b .platform_data = &da850_evm_tl_leds_pdata,! Z: n# f% P8 s/ W. g/ ~" Y
.release = led_dev_release,& ~0 ~7 c5 Q2 c& @$ t% r
}
7 Z" \# Y% Q5 R};
: |- K+ O/ u3 S9 K' w
3 A! b8 h/ |( H" J* S# g- P0 e% ^* Xstatic int __init led_platform_init(void) _) E: Q% }' a K3 T, e
{
1 L/ W; b Y! ?/ B+ X( I int ret;
2 Q) C' b- ~% F/ I Q1 b/ c: k1 _#if 0( l% k3 z' ?: J
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- v: j A# I# R. Q7 x6 m if (ret)) ?4 l$ J% O* W
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* ]& p/ i( i4 u/ [
"%d\n", ret);5 x/ T* ~5 g0 Y5 i) t4 V( r
#endif
8 Z% b/ ]; Q7 A( M& V ret = platform_device_register(&da850_evm_tl_leds_device);! d8 k" G+ a! v$ @% t( T
if (ret)* Q n6 b4 f# x8 m! t/ g9 d# C
pr_warning("Could not register som GPIO expander LEDS");
6 `' Z8 ]/ v2 G+ [ else7 X s3 h( A* W9 Y' z
printk(KERN_INFO "LED register sucessful!\n");
" G* O4 C- u3 o" ?4 j! f
9 C8 I% a6 ]( c8 |& y4 |6 o$ M return ret;
$ h/ `4 ]# M3 D) U3 }1 q% H}
M" ~5 y& z1 q, u, V4 J+ b6 A/ K. b( o- s8 L$ v" O: p' h
static void __exit led_platform_exit(void)
& K# a( [, |, N{/ p$ m- M, ?2 z0 j) P/ ^- W
platform_device_unregister(&da850_evm_tl_leds_device);
6 R6 K f" |" T! o( e/ J4 l. \) J1 l) V
printk(KERN_INFO "LED unregister!\n");
5 F' ^4 L0 S7 d! n& a7 ~9 X}& b% O& C' ]+ M
; K8 P: \% i: D7 q% Kmodule_init(led_platform_init);" z% @" R7 G# K8 z
module_exit(led_platform_exit);3 R& }% `+ H+ ]8 {
3 c0 A4 S( b j0 P* J
MODULE_DESCRIPTION("Led platform driver");
" H. E& O9 r9 c1 w9 f& YMODULE_AUTHOR("Tronlong");
& d! J" T/ m' j& q! {& Z5 ^3 UMODULE_LICENSE("GPL");
6 c0 r( ]+ _% j) I/ ?4 q& f& U; O+ F( y$ W8 l8 h3 z
|
|