|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 K3 R! P1 T6 E5 l. `#include <linux/init.h>
: n5 p+ _" e3 a) B. t- [7 y#include <linux/module.h>/ \9 h) j3 C1 V: T( B# X
#include <linux/kernel.h>
( J4 ]. O' b D+ M- V" l" x#include <linux/types.h>
( k( w2 G, t& H#include <linux/gpio.h>- W n5 `! }; S( I: r) {; B
#include <linux/leds.h>; o! k; `3 Z: Z. Z1 h8 l
#include <linux/platform_device.h>
9 T r7 ~, K, ~) n' K4 k! I
; p" v P( I! v#include <asm/mach-types.h>" O' v+ q6 x G/ U" L3 y ]$ O% k
#include <asm/mach/arch.h>
( w! m3 ?- b# G1 z, ]#include <mach/da8xx.h>0 `8 w4 P/ ? t+ P
#include <mach/mux.h>
* y& C' _% [5 Q! u
1 P' V- h; T( Z3 ^#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 Z B i0 `. ?* S#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 g. @! O% g) k/ B9 N#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 P* T S. c! M4 w
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 g( j, Z& O W% l+ u
: ?% v- B7 Z7 A5 ~# F/ A/* assign the tl som board LED-GPIOs*/9 z2 F; i: v, f
static const short da850_evm_tl_user_led_pins[] = {# ?# Z! w8 i* b( R
/* These pins are definition at <mach/mux.h> file */# `+ l" u: z# y1 ]4 W6 m
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ o3 }/ w+ d( [0 r0 ~; H( \9 r -1
* ~. F6 Y& {3 G: g8 t};3 T8 Z9 ^$ f9 d J: \" L0 q6 J
% i1 V) O5 q; a+ ^$ e
static struct gpio_led da850_evm_tl_leds[] = {
( E; L4 }9 Y" z8 {! P, y) r/ ~, I {6 e: O. I3 `- L' ?
.active_low = 0,3 C" w' G7 S: Z/ P+ v) q
.gpio = DA850_USER_LED0,# j5 V8 b( [: a% b; ?' m$ E6 Q& e
.name = "user_led0",
+ f U1 e. a' n) o .default_trigger = "default-on",' J5 U* z; U l( P2 c
},' M7 X3 R# Q+ E) U+ K# W1 b
{
_ r- R5 ]7 [: G- W' | .active_low = 0,
L. g" u7 J2 H& R+ x, K .gpio = DA850_USER_LED1,
1 w' Y5 C6 k! g' i# f7 h- G .name = "user_led1",
$ X& k8 N) q; i .default_trigger = "default-on",
: f( r- r) w: Z1 y& I" _4 W( S },! H/ ~% u6 Z" ^' A k6 v
{
% q) G6 z k: H6 b .active_low = 0,
! z# z @: Y' o- ^; j .gpio = DA850_USER_LED2,
& N: i4 c8 F5 v .name = "user_led2",
0 c/ s$ r9 l' b1 h .default_trigger = "default-on",
* r+ l5 B! N6 |* c9 Z: J* } },
' ]+ L' Y+ l- I! X' L- E* B {
) r& J! X' h/ _; x. J .active_low = 0,
6 J s% q! m- d4 V! e .gpio = DA850_USER_LED3,1 a- |7 Q) _. s) b
.name = "user_led3",
& `, z2 x h1 n9 f0 V, n* o .default_trigger = "default-on",
+ g2 a; p4 d) g+ H },
2 e- X3 ^2 B- y ~};' _; C u2 T4 L- g Z! c
4 j) R3 z) J& }* I% |( c' V2 f" j
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; Z. c2 b5 A/ E9 Y! f. S v- E, @
.leds = da850_evm_tl_leds,1 m: t) A p0 g% l
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; m& s5 C! v+ ]7 I8 ?$ q
};3 Y3 n3 k; f3 A( i4 ^
# X7 q" r' x! p9 ]. R$ {2 x
static void led_dev_release(struct device *dev)3 f+ H' T7 x1 Y7 p5 d
{; @: X5 Z0 m; I$ i5 v4 L
};
+ K k5 Y5 J7 O; R
4 d+ C7 z/ D; I1 H8 ]9 _static struct platform_device da850_evm_tl_leds_device = {' Q+ R2 r6 P; ]/ q8 W, K4 b( R3 N
.name = "leds-gpio",, `# R0 V" \1 ?) o" t
.id = 1,- P/ I0 I( L; w' r. Z
.dev = {. E, Z }; P1 C+ `
.platform_data = &da850_evm_tl_leds_pdata,, C; D, z, d$ B% `
.release = led_dev_release,# u, q" q0 A, w
}
4 L5 w1 t5 e+ Y6 X9 x6 Z8 ?2 m+ `};! H0 b# O4 o1 O b0 B0 k
, W1 Q& X! ?/ D) t9 T4 s" wstatic int __init led_platform_init(void)
& |& R* _5 [" q! _: H( Z- ]7 }0 M{
8 d$ X* f6 r ?- t: Z' q' K0 v int ret;' T5 r5 j8 a3 d+ W" [" I1 S0 K
#if 0; T- j" k" `3 `4 f+ Q" d, q6 U# G# E
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ Z/ H5 ]5 w3 Z
if (ret)1 g4 D S8 P7 I, b I5 x
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# p2 X3 [- n7 n4 o$ }2 X1 e "%d\n", ret);
2 I* G7 z( ?2 j& j9 C& B#endif
- }/ G! E3 e# b6 ]+ T. {- V ret = platform_device_register(&da850_evm_tl_leds_device);6 k+ c- y( i% [$ L6 j
if (ret)
& v( h$ Z7 c8 L0 ? pr_warning("Could not register som GPIO expander LEDS");
$ v7 f# e' H+ W4 G4 V* D2 q: Y else2 h+ \% T# A6 f& @2 F
printk(KERN_INFO "LED register sucessful!\n");
- q$ C) o! {' m. C( Y$ ]/ t( _2 w3 v7 U- Y+ s( E9 J2 F ? s
return ret;
4 T7 h- C3 X1 T}
% ]9 a- @ o0 W9 Z: O6 W. L0 t' f* O9 a
static void __exit led_platform_exit(void), f. t* y9 [1 w' H/ w; o4 W
{
1 c1 g$ \0 p Y5 B3 F$ t platform_device_unregister(&da850_evm_tl_leds_device);
' Z& {5 g1 p* @, ~! ]) I% e3 z* [$ x8 O3 w4 r
printk(KERN_INFO "LED unregister!\n");: w7 B; i- q% O
}% H7 C) l) u4 k+ v3 C: E
1 B5 o3 } @! R8 ~' `module_init(led_platform_init);
% b& e) r3 @' x5 ~: Omodule_exit(led_platform_exit);+ a7 s1 O F6 V- s: A
! x" k# i, Q, F \* v0 F
MODULE_DESCRIPTION("Led platform driver");( x7 |) r$ X2 H) `
MODULE_AUTHOR("Tronlong");
; O6 P- @# M4 x9 w. RMODULE_LICENSE("GPL");3 ?( s$ b, O& T: O' U6 E
; y2 J' @7 A5 Q; i
|
|