|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 c+ ^: q) h) D. z$ \#include <linux/init.h>
3 G0 z+ ]6 T* A/ p/ v" s3 x: m4 s#include <linux/module.h>( Q: C" K6 A7 i- x1 v- G& z: v. C
#include <linux/kernel.h>
+ R( w" z# y1 z5 M- g* D#include <linux/types.h>& D/ p- F" [& Q
#include <linux/gpio.h>; Z1 R' N; c7 H, J5 n
#include <linux/leds.h>4 {3 i7 L, b7 D& s# `8 h
#include <linux/platform_device.h>
2 @: q7 U+ u. D2 o8 L' P# z
# s7 f) l+ d0 p( T- `) B' }* Q#include <asm/mach-types.h>
+ i" N/ t0 a u# H#include <asm/mach/arch.h>. E5 V( d0 l* Z! T5 J0 U2 R' U2 I
#include <mach/da8xx.h>+ L4 D5 W. x- b' K
#include <mach/mux.h>' { X3 X( A( X7 T0 k) ?
" z3 h9 o: o2 t% f' E% A, x
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), B; N% `5 X; h s4 ~8 e
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 O; y! V6 E; t7 Z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) V& ~2 y0 p. O. a6 u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# c" d, b. h( Z0 f$ G' K& D- R6 c: T% f! G( ~" O: r Z
/* assign the tl som board LED-GPIOs*/
. }' Y* l' C, d( lstatic const short da850_evm_tl_user_led_pins[] = {* Y4 S5 V& M& I" Y- w- a# m1 {# O
/* These pins are definition at <mach/mux.h> file */
4 l+ N1 f3 |( S* _" U4 L DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' g6 G) z1 H6 A. B/ }6 f# [8 v" L
-1+ o, I; q8 l1 v( m/ J3 \
};+ V+ T8 y# B" R5 u) c m
; G9 k7 u8 C3 i! k5 ?, g, ~0 L; |static struct gpio_led da850_evm_tl_leds[] = {9 B" M8 a/ G5 l0 {& D; b
{
! S/ H( [4 @2 d1 `) y5 n [# h, I .active_low = 0,% u# ~- `% y6 A2 ^
.gpio = DA850_USER_LED0,
. \: H \# F5 \ .name = "user_led0",1 X% f+ n7 _3 `; T: [& v
.default_trigger = "default-on",
. f- W, a8 K B5 J },* [ c1 |4 X4 D( \) e% \
{" k- N# |! O$ e2 a
.active_low = 0,3 t: o" j' {! y5 m- w
.gpio = DA850_USER_LED1,
- t* C3 b' c( u6 ^: O .name = "user_led1",$ z3 I* i5 q$ O) b
.default_trigger = "default-on",& w1 ?; ^7 M7 m, L
},1 R7 M0 W# v* l
{
4 [. e& ^' a# P6 t .active_low = 0,- r8 Q& R* O6 r5 l' k' f" f
.gpio = DA850_USER_LED2,
; A$ w j, d3 A2 q1 F: P' E0 A .name = "user_led2",
A; ?" f l- C. k .default_trigger = "default-on",0 ~8 U( Y }) v/ J _* M! f1 \9 T
},
* E0 T3 M& R8 h0 s; o {- a1 e# \4 G r b& N) `* B; S
.active_low = 0,4 A" U& M8 E5 I4 Z
.gpio = DA850_USER_LED3,+ V, E( |# p& W" m! p& I
.name = "user_led3",+ i7 f: n; ?, X( \/ D
.default_trigger = "default-on",2 ?; ~3 e! o2 f7 x" }
},1 M7 Z# G# S' {, g9 W8 _ ?1 g( v
};
/ J, Q2 A. P; {, ~+ h0 k3 E$ a# x$ h: @9 X9 r: G2 T6 [7 y6 Q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ p) h' @8 }( e3 S& a a! v9 ^) D- V2 g: P .leds = da850_evm_tl_leds,
3 _6 D! |0 O( z$ r B$ t .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 B3 x- y2 B$ J' W9 T};2 \2 J1 \+ ~2 b* Z! k) o R
1 u- F( p3 N& a% v. [% [/ K
static void led_dev_release(struct device *dev)# a# z+ y5 q# U0 @ U& p0 O
{+ N# M% ^- }7 u* d- G5 m
};7 V$ _0 u& j. ?
5 _0 X) I; R7 c! p9 f: ?static struct platform_device da850_evm_tl_leds_device = {) x8 b, r5 `9 P6 `" w! j' q! B
.name = "leds-gpio",
; f3 X) Y# _ B! I4 @ .id = 1,
) G. _% e% v0 w+ I! Z n8 ^5 _' V .dev = {
( u+ z5 R x/ K2 l0 E% P .platform_data = &da850_evm_tl_leds_pdata,8 g% k3 w- v3 T; D+ F* L4 f
.release = led_dev_release,
# X. d7 [& m- M9 V- ]0 F }
R: j' T$ n. U1 w};# ]7 Z: m8 k8 e# n- R
& _7 O& I& s* k) [7 ustatic int __init led_platform_init(void): H- B$ M) }' g$ w+ K' \9 O4 T
{" m" A# M& Y5 O/ z
int ret;/ r+ z5 g3 b; o* ?
#if 0
7 L l* V) A2 X/ w/ Y# U ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); t# S' o; Y% o1 Q! Y: W$ A
if (ret)1 c& A- N" W% Y" S3 G) j3 F" n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 A( _: B; |8 s3 s' r "%d\n", ret);
1 @% S5 s- c; o5 ]$ d#endif
* v* y$ m, l8 Z( A ret = platform_device_register(&da850_evm_tl_leds_device);
4 w; o/ n( B* E" B& D if (ret)
& v9 S, Y, H. s- E, l& t2 y# R pr_warning("Could not register som GPIO expander LEDS");
) a* P4 ~' a( X7 Q3 Q else1 d" y# d, _" c0 Y+ y
printk(KERN_INFO "LED register sucessful!\n");; `7 W) }; ^2 L4 G/ f! y- V
3 v3 B; C$ j# E1 u return ret;
9 ~2 e2 D! O% N+ K t}
5 }" [' \* f# M( [
0 Y/ V7 d% Z2 J$ ustatic void __exit led_platform_exit(void)3 j0 D3 l" |+ F& x
{6 F, K+ V0 N2 U r2 Y R
platform_device_unregister(&da850_evm_tl_leds_device);. [, ~! O4 [8 @# F5 G4 k
* n+ P( ^8 {- i4 p& ]% E+ i
printk(KERN_INFO "LED unregister!\n");
9 s+ [# F% L* J9 v+ S) |; K}1 u4 o* l: W" g, k$ y
4 @. i1 z$ w" O6 u& f M5 x q
module_init(led_platform_init);! E2 _2 Y( a; s4 |) F
module_exit(led_platform_exit);3 i# U/ |" c$ V- y- p2 A8 U$ Q
6 l7 V$ {- h# O. o K) h0 KMODULE_DESCRIPTION("Led platform driver");9 u' g! G( I/ o
MODULE_AUTHOR("Tronlong");
6 Z2 m4 G$ a# fMODULE_LICENSE("GPL");% h+ O( B: ~7 L s; ?3 O
/ s5 ?! z' B9 l |
|