|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 n0 v0 J$ G4 x; v#include <linux/init.h>
+ l8 _7 G* Z' W; p0 |1 r/ T#include <linux/module.h>
7 a+ K9 _% y \" G#include <linux/kernel.h>
: h( t$ {# V& \ C/ g#include <linux/types.h>" X) J: P, A- t/ s+ _8 d+ r$ E! S p: T
#include <linux/gpio.h>. k9 W2 C; @( T* F
#include <linux/leds.h>& x! V' F& }7 }8 p0 @* `1 o7 v- H
#include <linux/platform_device.h>
2 ~& ^5 J+ u' h$ J& x, G& V' z) g/ h/ I) |% B/ `$ I
#include <asm/mach-types.h>
, Z E. J, ?3 Z$ D#include <asm/mach/arch.h>
0 M. ] K+ Q+ q: d# l0 u#include <mach/da8xx.h>
" [9 ~7 T2 Y, {( M#include <mach/mux.h>9 \9 h) E& K# v+ G A$ X
( j: ^ S+ D5 s/ w" X8 m# g: l
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' B! u# g p# v+ B7 r$ [ h. _#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' }; F8 C4 ^% v' L2 h9 c#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 A$ ~7 [' j( K+ z& ?6 M+ `
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ W/ D# J$ L) x
) i) Z R+ \9 k- T7 r5 f# s, k/* assign the tl som board LED-GPIOs*/4 c, y9 ]! \# I' s6 x- a
static const short da850_evm_tl_user_led_pins[] = {/ l" M% i( p5 {! O! b7 ?( O% k( F
/* These pins are definition at <mach/mux.h> file */& |' e1 H6 p/ l3 B1 D0 \8 M' i
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 n% K- S6 Q1 F4 q; M- C7 D. i
-1+ e7 h% t+ E1 V+ {
};
9 X8 b* I; ]) S' ~4 f/ [/ [6 P- ^- `- `3 k: ^1 p
static struct gpio_led da850_evm_tl_leds[] = { q9 E& K0 \+ G: t
{& Y& |/ I3 P) ^
.active_low = 0,
5 E( O/ f4 ~( s3 [" E" [/ g .gpio = DA850_USER_LED0,
$ E' {& z# |: \% C8 c .name = "user_led0",9 F4 n0 y2 L8 T) D& M* ~! x2 C
.default_trigger = "default-on",) e1 d( g4 n" a' u; ?6 ?) ^
},5 Q. O# H2 v' k# ~4 F/ w
{
- K. \; \5 K! e* c+ \8 E) { .active_low = 0,
8 e* F) a2 _1 _! b- ~( ^8 b, A .gpio = DA850_USER_LED1,
8 `* R: ^$ _$ y; f .name = "user_led1",1 U% c! X/ v& V" ]. P7 a' _4 O
.default_trigger = "default-on",+ ]+ U) s9 a, W6 g
},# h/ n. i) [& K- P
{- j- W$ ~; l4 i# e" h5 ~: v _8 i
.active_low = 0,
& C( Y$ G z4 Y! e# W& O .gpio = DA850_USER_LED2,
; Q8 d6 |* e3 ^ X .name = "user_led2",
: t5 `( C) l# S+ | .default_trigger = "default-on",7 i9 d6 T/ n8 P1 H+ u: ?
},! P- D! L. A" y: q# `/ t
{
/ O" {; ], z6 n4 W. `7 x/ L .active_low = 0,7 w9 r h/ Q9 F
.gpio = DA850_USER_LED3,
+ p) P- P( M( }% ] .name = "user_led3",4 L" C4 C2 ?, u2 y z v
.default_trigger = "default-on",1 e& b. b5 U& { R
},
1 z' [: e; y' P: c};
/ M0 F& q6 p3 l3 I# w. y2 t- O# ]" @ ~2 w. X
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
w' ]; ^3 y6 q) d .leds = da850_evm_tl_leds,6 o! z% M* G0 \
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* o2 y' m) K6 r$ u9 Q" a; r};: I1 F$ I8 M( w( }9 b4 O, M
/ W% |1 C% }4 b- `( l
static void led_dev_release(struct device *dev)- D3 L. N; l7 n; J! R9 w1 |
{
8 k& g6 r: S6 s};' T; V& I' m. w& p$ y/ n
! [4 ]& P$ \3 ~static struct platform_device da850_evm_tl_leds_device = {9 \# f& A/ O$ x% y
.name = "leds-gpio",8 E/ K% k D, m! q# r
.id = 1,6 q6 N8 R! R' G' R* D- h1 S
.dev = {1 u% C! U1 ]- ]9 g$ M8 S% u* T% _
.platform_data = &da850_evm_tl_leds_pdata,. k$ Q, ~+ }1 g2 X* M, d
.release = led_dev_release,
4 X+ @1 |6 S3 A+ N6 Z% j }3 ~4 M6 K/ m ?$ ~
};
% o; s0 s' z) ?7 j [7 `) |# N9 o/ j7 ?6 S# ~
static int __init led_platform_init(void)) d9 p6 ]9 ~ L3 N" g- V1 H
{
7 X: l/ }: u) F# Q: b$ w5 p3 [ int ret;( V0 o8 l2 {6 m: S' C
#if 03 J2 \4 N1 E+ i( v& g% q6 g, r
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; C% \2 ~% j/ \' {3 [9 @# q if (ret)( W) C2 W: C" r3 [1 X# F. K' ^
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 a" B$ a0 P3 R6 a4 O0 x G
"%d\n", ret);
. q2 ?: b# p% d4 ?3 S Y#endif5 i$ k5 |6 B" q; l
ret = platform_device_register(&da850_evm_tl_leds_device);
9 p `8 _2 y* b: A5 N5 P y if (ret)
X3 `3 Z+ T R1 q pr_warning("Could not register som GPIO expander LEDS");
+ A, u7 y, C% o' E* X' ` else" A$ l) B7 Q+ t/ S; _( U. @
printk(KERN_INFO "LED register sucessful!\n");
$ @3 k: ~- d4 N3 N( D/ r& E4 p& t
return ret;" O* u/ `2 K/ w0 _
}- [' c7 }; ~' Y2 m: Y; F: ~
0 M. t) H, g, C1 L) I5 l
static void __exit led_platform_exit(void)# n' H: @$ q& b" Y$ d, ]2 l
{
) f& f8 Q2 b- Q platform_device_unregister(&da850_evm_tl_leds_device);
3 X/ l' E6 V1 k6 C. K+ y3 o7 g8 t/ N, W6 h5 \2 _: U( l+ |
printk(KERN_INFO "LED unregister!\n");( r/ e7 X1 ?% q; V% F% p
}
& r4 Q/ v+ L1 S/ y$ ]
: l2 ?. @( }) _$ R, p$ Kmodule_init(led_platform_init);9 J2 {7 Z& O% l( c. J
module_exit(led_platform_exit);$ X- p; S* z* y2 A* |
& y& o6 }1 `( X- h
MODULE_DESCRIPTION("Led platform driver");
# U5 x/ q$ Q8 ^. `- o" tMODULE_AUTHOR("Tronlong");
( I5 e! z2 [% I1 m# h5 q. vMODULE_LICENSE("GPL");
9 b3 M: W% t# |; Y% m/ y" \7 n9 _0 r& J8 A. C4 E; G6 R |
|
|