|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 @$ b) u W: [' _
#include <linux/init.h>
/ U- a$ \& {$ J4 e#include <linux/module.h>
/ K/ T, C2 x4 O# u' q- t/ b#include <linux/kernel.h>1 ~, ?7 `8 k+ u& y6 o# Z' v
#include <linux/types.h> g8 d; Y& G+ r+ N0 c! N7 H8 B
#include <linux/gpio.h>
) b9 {. r9 ^7 ?$ O X6 Q9 W#include <linux/leds.h>; w0 y; q4 p7 X9 R4 }0 M
#include <linux/platform_device.h>
/ j9 W4 ~+ ]: K X# w6 k
/ u" V; P. x- k/ E+ G0 |4 M4 R#include <asm/mach-types.h>9 H/ t% l2 Z, h+ e
#include <asm/mach/arch.h>
- P# L' g; S% f' ^$ [/ [#include <mach/da8xx.h>6 d {- B# D$ N B
#include <mach/mux.h>( M) ^, a# |, V6 P4 T) x1 r; [
7 _8 M# y3 g" F: ]+ t( q: B
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. |& S6 t2 g2 `0 o- q# T3 }2 u+ G2 y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ ^. q1 y" \) `* S X( _#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ M/ F8 G' L8 }+ e) c#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 T7 _! W+ ]/ i* P l' x/ n% c
0 \9 x. u) r; o. m3 C7 U/* assign the tl som board LED-GPIOs*/
; _5 _5 F3 I. Y1 p1 x* x1 Tstatic const short da850_evm_tl_user_led_pins[] = {
9 I* h7 _: k$ ]0 U* [ /* These pins are definition at <mach/mux.h> file */
$ c9 v5 B, J& [" q' y DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( j- U0 r6 y) Y/ P* K
-1$ q; _& g2 n$ t, q! _$ Q
};9 C0 E6 G0 |( N" d4 l0 V
1 r U1 I7 F1 m" b" n, h$ vstatic struct gpio_led da850_evm_tl_leds[] = {, ^! T" U) A$ m- z; G7 `- }
{
' e- H$ O% F1 Y .active_low = 0,
! m* V. p' p$ V) P0 m .gpio = DA850_USER_LED0,
) `5 o2 t6 d( A+ r* W .name = "user_led0",
$ W3 h1 v. N3 @! | .default_trigger = "default-on",
! n% Q" Y$ K5 W+ v4 T) G },
+ x$ h& E+ K: L# h! b% M1 {* ? {
* m0 [, D; k( b# `& d7 M8 F5 ?. S .active_low = 0,2 Z9 V( A* W4 n& i: n6 ? l
.gpio = DA850_USER_LED1,
; f/ ^( r q0 }! D0 r8 j4 q1 q/ v .name = "user_led1",9 y+ d: m" s! w- h0 I! M# d
.default_trigger = "default-on",
+ x: @' r; [8 C& I% N# b6 x) } },
) s& o# G: X7 I8 P {
; P1 B2 v! D3 T. A .active_low = 0,
% Y3 P9 V7 Z" j5 [+ y% E7 I/ R7 ^7 o .gpio = DA850_USER_LED2,$ g1 |5 B9 M4 C0 P- f1 c- |
.name = "user_led2",- g. U/ Z3 v: w* J
.default_trigger = "default-on",! f* R6 P# F. u
},
+ Z: C: @# s8 Y3 n {8 [, g1 g, ^, X4 c
.active_low = 0,: j& D0 u7 i R/ ~ j! N/ Q
.gpio = DA850_USER_LED3,0 ~3 u6 y) w) I3 W/ ^+ q
.name = "user_led3",
2 E: b! S. ^( R* x8 e" r& y .default_trigger = "default-on",
! e' ?0 f# l9 l) j* r* P },- ~4 \7 j3 i! {6 |" I: b n
};
2 Z: n8 A! j% O6 {7 ?4 y0 P% C8 e- Q2 p, o
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) Y* A4 T* [$ h0 Y9 _% ` .leds = da850_evm_tl_leds,& `# D% L, l: R- P2 U+ X% p
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; k+ |4 _( P+ h @- |( {0 ~- i};) D, ?5 V* `) u9 b9 k! F$ z
: h6 F8 W" O! P" L4 A* x- b7 p* Istatic void led_dev_release(struct device *dev)
7 p! I& h s, K% x1 ~% N{- ^; @2 r: H7 _ z2 `
};' p3 X5 \+ }/ Y' F1 n
& S' v) D5 `2 w. w8 g* m: e
static struct platform_device da850_evm_tl_leds_device = { l1 j& t# T9 C Q U4 @
.name = "leds-gpio",
5 R: T' r2 B$ F; U .id = 1,
4 o! @* A; ` S+ `- l9 Y .dev = {
. j3 g( n% K2 r$ ?+ f .platform_data = &da850_evm_tl_leds_pdata,$ l5 ]" c0 m2 ^& e1 I# n
.release = led_dev_release,: {3 r/ ?: \' h$ @3 @# l4 O
}
. h" p+ E! Y. G5 n2 z9 E};) W* U, a8 C& z
, R/ [8 S1 ?3 ?- \
static int __init led_platform_init(void)
3 p- ^9 z6 {8 W6 }- G0 U! j" G{' j! w6 X3 G* s5 K
int ret;* I& E' y0 ? J" k* c5 |3 R+ H
#if 0
! C+ v& q) f, Q) F; e7 y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 G/ p9 p7 w: E0 u. y
if (ret)0 m4 U7 ]3 L. k0 a ^; y, [0 k4 M4 D r
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- m/ q8 J4 ~( F5 b9 g "%d\n", ret);
/ S5 ?" }+ ]6 Q; c#endif
4 U4 j9 M3 N6 _4 Y ret = platform_device_register(&da850_evm_tl_leds_device);
$ R4 A1 ]; a5 f: F& n. A if (ret)
5 _& W9 O, h# b/ m* A2 m9 {( E" q pr_warning("Could not register som GPIO expander LEDS");
) q0 y6 d& }" {0 y+ i8 [ else8 V4 @3 ^% p _ L. z! K
printk(KERN_INFO "LED register sucessful!\n");
& I _; [9 T* b
4 i [, o+ U8 {& P return ret;
9 @( @+ r" _5 I$ q3 y}
( ]* z9 S$ t7 G% ]0 K0 P, `% ^# o9 ? c' H
static void __exit led_platform_exit(void)
3 y, x$ d: @9 ]{. K' M j3 u! ~$ O1 |$ F
platform_device_unregister(&da850_evm_tl_leds_device);
2 E+ d" E; U; N; b) `" v0 b; H6 J: R: X0 }# T. J% |6 A. I$ L
printk(KERN_INFO "LED unregister!\n");8 e. l3 q2 @9 d% M9 m
}1 @- I% |& \3 E. L2 L! `
6 \: W. g; s, n2 m b0 m9 N
module_init(led_platform_init);
/ i3 x! m8 M0 B5 q ]8 R, Ymodule_exit(led_platform_exit);
2 J* C0 ^* S+ c8 N8 E* I# j0 h" ~+ z4 u J$ Y
MODULE_DESCRIPTION("Led platform driver");# f! ]- q- m" K! o% O$ V/ S
MODULE_AUTHOR("Tronlong");
! w, ?; o% j2 }% f5 uMODULE_LICENSE("GPL");) q1 O# {6 g( K/ l$ n% Z: B8 c
h: G% h3 S& L( R
|
|