|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 i2 Q2 ~ A: r% D#include <linux/init.h>
" N) H8 ?' V7 V$ [" P! a W0 T#include <linux/module.h>
( h5 |, C3 ^+ g2 \: E$ Z#include <linux/kernel.h>
7 L. W* J) @5 ]0 o3 s- X#include <linux/types.h>
3 u; Z2 D6 |+ ^( b4 F" I#include <linux/gpio.h>, @8 h2 i( P* C3 O
#include <linux/leds.h>
* {: n" {& V; |9 h7 `#include <linux/platform_device.h>
+ y' p6 v( H) C. g8 B+ [+ W, B# H9 H. O q: ?4 a
#include <asm/mach-types.h>3 t0 J4 a8 Q3 ]5 a2 F% l' A
#include <asm/mach/arch.h>
: F8 d, K( w* w( b8 O4 ~#include <mach/da8xx.h>* n3 r8 L7 C- }' j( `) e
#include <mach/mux.h>$ N" @" { t1 e
0 ]; D( N) h1 @, z. b/ S" ]6 t! h
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 O; r% p$ S9 w) d0 N7 F* @6 K. |
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 F: N7 x7 N$ z- g/ U; b: i#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ R( r5 g+ b5 ]9 ]7 \$ a. {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) S8 d7 I3 ]% [3 x4 i+ R6 Q" g3 A+ q3 o
+ e7 k: S& o r$ ?2 d L$ i; U/* assign the tl som board LED-GPIOs*/! Z. R3 R" E6 @1 v- _
static const short da850_evm_tl_user_led_pins[] = {5 G; I- K; Y& W" n9 @6 W
/* These pins are definition at <mach/mux.h> file */# K& f/ W1 q) y3 E
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ c# C. F4 {+ U
-1
! e5 j( L- X; o# Q1 ]3 Y+ _, Z};$ j! J% p; w# ?
% j* R" i8 `/ A1 b4 w# ystatic struct gpio_led da850_evm_tl_leds[] = {
- q- v( p! E, q1 K8 P) i- C {1 ?. d6 Q: g$ O+ O# T. |
.active_low = 0,
0 d7 S }- e& l3 ^/ z .gpio = DA850_USER_LED0,
, X4 P8 |5 F/ ]1 I .name = "user_led0",; j0 A$ g* i" V: _) ]2 X$ ~
.default_trigger = "default-on",
) \( G p( h& `! u, f( X L3 i },6 s( c: i- V5 Z/ f# ]6 p
{
! X+ d0 @5 ~* t3 W0 P .active_low = 0,6 H/ s3 C! L5 ~7 Q) _. s
.gpio = DA850_USER_LED1,% l8 ~* ^) d ^/ n6 \
.name = "user_led1",5 ~6 F% m7 [* U+ y) Q
.default_trigger = "default-on",
6 N, Y5 g; a/ P ]2 ]) m" e },1 N4 d3 w$ i: C# M! ~/ x( `
{: L- T) C4 a/ Y+ p; @0 v+ t) T
.active_low = 0,4 q& d# v7 Y) Q4 M2 B- n5 |5 f- z& Q
.gpio = DA850_USER_LED2,4 a3 p& s2 j! q, {# ?* \: A) S+ ^
.name = "user_led2",
3 V$ |% c) ?- V( V .default_trigger = "default-on",, b( d8 W; |+ P
},3 d1 Y$ V! F$ {$ ~4 L
{
. _5 }8 T4 D% p .active_low = 0,
4 {! P1 \ d6 R9 X ] .gpio = DA850_USER_LED3,3 ]! R( i9 _) {- k. S' Y( z" e5 Q
.name = "user_led3",
6 }8 F8 ~- D9 d4 h ^8 n! s .default_trigger = "default-on",
1 j( Q; F% S. I },
1 G n' N$ c: Y! b) W};+ c5 E1 t0 |" J9 e
4 J Q" |" G& ~" A( l8 w2 h
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# X0 n; e [ N) B \, q .leds = da850_evm_tl_leds," v8 ?) Z5 l5 u" e$ W; c" J9 e
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),, Z) z: ?6 S3 J I& G- v5 k
};& R6 T# p1 f% o8 V4 H5 N$ Q
' \% n( N+ B7 W8 f: v$ t+ `6 vstatic void led_dev_release(struct device *dev)+ H+ W+ ~ \: p
{
" V6 l" w1 E: e8 r5 P};
, p) m! ]- n$ f& Q; H+ \ Z( @0 @5 u. B' Y6 j/ {8 t
static struct platform_device da850_evm_tl_leds_device = {
6 S. Y3 P( c! c) Y .name = "leds-gpio",' k e% l7 w) m2 u' ?- F0 r1 {4 n
.id = 1,: Z, l- W. [6 \( _5 G! k0 H( D2 P
.dev = {
" e% x& f* T$ l$ v* _# L% X- ]: x .platform_data = &da850_evm_tl_leds_pdata,
$ Q. Q, w1 c8 v9 ~ .release = led_dev_release,3 H. L8 L. e6 V
}* ]8 ?; U9 O! b/ l) J
};
9 U, G! y n3 r" C$ |: e: M0 E8 ?8 M* }, D) Z7 `' P4 j
static int __init led_platform_init(void). L& B: i& F. }3 ~
{
1 L7 c. Z2 i3 h$ Q9 H int ret;
6 l- F! z6 |" u+ g9 K- C" N#if 08 x" Q# [7 a7 R+ M( P
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; o6 I) C: f: W& y0 A if (ret)+ w0 b1 Y: \; @# J+ Q# w
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; W R2 e- s/ G "%d\n", ret);
. R6 M8 ~/ d% L, h#endif6 K) h& j4 q& B* j4 q% g
ret = platform_device_register(&da850_evm_tl_leds_device);% H; H4 u. J1 ~7 l( E! o" e
if (ret)
9 {8 x2 m5 u( z/ C$ B pr_warning("Could not register som GPIO expander LEDS");
$ G& m- s$ U* F F else
0 |5 J( g# x1 H- v printk(KERN_INFO "LED register sucessful!\n");: Z# Y6 D! ^/ Z. ~- w. ~% A
0 C2 u, i3 ^+ T6 ^7 T7 w# y1 ?+ s9 O
return ret;$ R7 `& c7 j1 `! v# q$ ?/ [
}* F/ n8 X& o- y% l5 K3 X! [
- A5 Q0 m6 t' v, Q5 P X1 W/ k" ?static void __exit led_platform_exit(void)' b+ k& T4 m# A2 w
{$ }6 {! J/ a$ q" Q
platform_device_unregister(&da850_evm_tl_leds_device);
. q* E0 }% R4 y/ [+ c3 b0 ]
$ i) @9 V3 }7 j* r: U+ e printk(KERN_INFO "LED unregister!\n"); a2 {- Y; |7 C! J U/ H) F) \+ ?
}; E" n: W& a; ~8 N0 x
4 [7 m7 y/ l0 K; w
module_init(led_platform_init);) e/ |! t: z# B: e- v
module_exit(led_platform_exit);
3 h/ ]! Q/ p" M3 F/ m9 m' G! i' Q! U; u) t% p! q
MODULE_DESCRIPTION("Led platform driver");: l& X5 U% o8 z! e* ~: U. X. h
MODULE_AUTHOR("Tronlong");/ ]1 M+ V4 T% Z/ R
MODULE_LICENSE("GPL");5 B1 \0 Z7 E) Q6 S5 f
5 }; g* U: }+ `) q* D3 x |
|