|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 |- f2 X: U. i5 |( o
#include <linux/init.h>3 d+ }& E/ {/ g/ ~5 v
#include <linux/module.h>* r0 M4 i; d4 ?# n' [) Z$ n2 Y
#include <linux/kernel.h>4 u9 q8 d& X" z% H. a
#include <linux/types.h>
u2 M% A5 n1 V2 \#include <linux/gpio.h>
7 N7 h* _( o% E3 [, m#include <linux/leds.h>
% E/ K3 O$ F W. G! l#include <linux/platform_device.h>
$ m4 m' D+ K) G* E* U8 G! S8 T; s& C. w
#include <asm/mach-types.h>
" q( P ^! L2 `9 h) M) z#include <asm/mach/arch.h>1 ]" R8 [$ U- W, `5 G$ r! v. [
#include <mach/da8xx.h>1 V1 K0 l2 P3 S
#include <mach/mux.h># {. X0 R" x( I7 V# v- W% q
9 J( D: H& A5 Z1 _. X1 h
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 q8 L! E/ |4 u" d: U( J#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 O5 r3 y9 N2 W#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
H2 K7 y+ J3 Y% ~8 P Q& i0 s#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 I) ?* D% C T, ^& F2 C
" K. O: m& J; T- G8 [* }! i9 W/* assign the tl som board LED-GPIOs*/7 s$ K: Q, U+ v+ d
static const short da850_evm_tl_user_led_pins[] = {7 ]' j# Y/ z; q# R( C
/* These pins are definition at <mach/mux.h> file */
2 b0 g7 T- E0 J, O7 V8 h+ _; m DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 g" X5 ^( z! ~9 {* X+ u7 T5 Y -1
+ d$ g! N- q$ v* R7 L5 R};8 U$ }- {9 D6 { O+ [
! t3 r' `% v d6 @% y9 b/ h) |3 hstatic struct gpio_led da850_evm_tl_leds[] = {6 T7 ]2 }9 u5 D( l) T+ q6 F
{. Y( N: z! v0 x" m
.active_low = 0,
% S1 h8 c7 o6 ]7 {8 w .gpio = DA850_USER_LED0,
$ T+ j) v ]1 x, }) y+ ^ .name = "user_led0",
9 G! z3 b0 n/ K4 M9 f9 r# O .default_trigger = "default-on",
+ S# c7 t8 j( b },
' n" H, P! ?2 C" {9 r7 Q" h {# K ]: D0 Y- n4 ]8 v" D. B L! }+ {
.active_low = 0,
( |6 A1 P' |# k .gpio = DA850_USER_LED1,' v+ y! V4 U. ~; A. S
.name = "user_led1",
4 X8 a6 j3 A4 o9 H6 I& N .default_trigger = "default-on",: u, F- l$ a% C+ \& E
},
2 {' }2 Y4 G" D3 f/ }6 t& J, ^ {
* P5 Q" p( c, `% g8 t .active_low = 0,
' |9 f4 {" P! t z' x4 @1 p- }5 \" X .gpio = DA850_USER_LED2,
( m: G5 Z0 _' J3 A5 P8 L% ` .name = "user_led2",4 b$ y$ t8 G# Q, J; {
.default_trigger = "default-on",7 D& |) ?4 J9 ], ^! a! }3 ]3 H
},
8 K( K; a/ z* v: N {
$ c# O/ R- {" k. W8 l .active_low = 0,/ _- p- J9 n6 M, O1 e
.gpio = DA850_USER_LED3," f- X& A- i! N, T, j! E/ e7 V4 I/ R4 o
.name = "user_led3",' K8 W' |4 |' u W, } C
.default_trigger = "default-on",1 P8 S5 ~: u! L( B3 G' q
},
0 Z2 F O: M- E( d};
( {9 ]' E" Z x8 p0 w& c, R! {; Z2 {* W3 d+ r0 l
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 D8 q# \ T; F; I
.leds = da850_evm_tl_leds,
% l m, }$ x" h .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 n+ k3 p. Y0 S$ h6 @, |! R};
) h Y6 }9 X4 k0 X. x( `& ^" Z4 s, S# y/ v) [6 `
static void led_dev_release(struct device *dev)9 A' f( ^0 ]4 l% |( ^
{
}& P, D7 i- q) p. J0 T};' Z& f8 U' R; R ~
f# K8 f& v) n. J* Vstatic struct platform_device da850_evm_tl_leds_device = {
5 v8 c# q/ n" z! v7 G9 ~ .name = "leds-gpio",
+ T$ Q% c/ g' \$ Z; f .id = 1,
7 X9 M# j, d7 l* r( l .dev = {% M, `; @. w$ q3 T0 U& e
.platform_data = &da850_evm_tl_leds_pdata,
4 J7 K; F: ? c5 m$ y3 b% t .release = led_dev_release,
. p7 @" K* x3 s& g }
, P1 r, A6 U" n; G3 _};, Q/ @9 ]0 k) U2 d
* x* S1 d8 y$ U7 H4 n0 G) H h+ r. pstatic int __init led_platform_init(void)
* E) N* B/ \& H{$ N9 _3 q' W l/ F* g9 `- q
int ret;+ P' p) m: X$ L
#if 0
* t. s7 c7 x( Q8 l$ b3 r ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! r5 ^5 R- l+ F- N! w3 u if (ret)
: {: P1 V$ Q8 I0 A' { ?& I7 _% z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 K2 Z5 \! h; I+ e1 w3 r
"%d\n", ret);
$ L$ K( R r0 X9 H#endif
@3 I! N) r, l ret = platform_device_register(&da850_evm_tl_leds_device);
3 E" N+ c `* M! E- Y) J& P! j if (ret)
i, K0 K+ q1 H' a- F pr_warning("Could not register som GPIO expander LEDS");
& N* @5 d" s7 \3 C else
5 |5 n0 Z" ]6 J: n; l1 p+ K printk(KERN_INFO "LED register sucessful!\n");( ]8 ^/ g( V0 W' l- l/ f4 E- ^
+ ^$ j) b% u2 m: p2 l return ret;5 j$ A5 L. s3 F; w7 @, c
}
5 d# L) u/ }7 J8 M6 O' r' Z$ m( o# G$ r L- \
static void __exit led_platform_exit(void)
% C* l- q6 K9 p' g1 M{
) ]5 ]2 o3 K) h0 U& @( n4 S platform_device_unregister(&da850_evm_tl_leds_device);
+ A9 l5 k& c- W9 |3 O( i5 j I! b7 m* e f+ B. A& B" ]. W; h( _. Y
printk(KERN_INFO "LED unregister!\n");
3 M% W2 i3 X' W/ \) o1 H}
8 e; f5 S# j& [& x- N) [. B+ r" a: Q \, y9 l
module_init(led_platform_init);! Y* N! b# g @. P% e# a
module_exit(led_platform_exit);. D) `2 G# G0 o& o! w
9 |; a! v3 Z* W7 z' h, x
MODULE_DESCRIPTION("Led platform driver");
" Z+ @/ o. z6 S5 _- P* i* X! ^MODULE_AUTHOR("Tronlong");
# ~- H# [, U! zMODULE_LICENSE("GPL");
0 i5 _7 u# r. C& C3 X+ s% N4 m3 m5 Z4 b# T
|
|