|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, L* M X* x$ q1 C) Z* L
#include <linux/init.h>& C0 q, W/ R1 \+ M
#include <linux/module.h>. I) _/ @# \; C9 |* P+ r/ i
#include <linux/kernel.h>
; J; Y0 f& g: k# I. R#include <linux/types.h>% O" ?8 k# e1 @
#include <linux/gpio.h>3 H; n2 a1 k1 g! b2 `
#include <linux/leds.h>" L( j# p# N* }9 E- Z' S
#include <linux/platform_device.h>
. M/ h2 T9 K9 d& P4 c9 h+ y1 [1 E( ^
5 S9 a! X* l2 J( t5 d#include <asm/mach-types.h>
8 [) y5 d& D( @- a6 `#include <asm/mach/arch.h>% d0 u9 Z. d1 \1 G
#include <mach/da8xx.h>1 ^) ?. o" v# j9 ~+ Z: f* {
#include <mach/mux.h>
- O* q6 i# B8 S7 ?+ R6 o6 r4 V- x/ p* ~* }0 s
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 q, @; y& K8 z/ ]& m9 B3 C
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 \( _- |+ L8 Q7 T" n5 b" D0 W0 e#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 n) a: u4 X. r( x#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' p4 {* J0 I! y; m1 n/ R# R
4 c- S+ Z# q. m: h& q2 `, \
/* assign the tl som board LED-GPIOs*/5 } F9 k7 O+ M
static const short da850_evm_tl_user_led_pins[] = {# F+ }$ G _6 P8 {7 z% R! t
/* These pins are definition at <mach/mux.h> file */
( Z% y; @1 y- j9 O& P; p3 U4 z( Y DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# a: s5 z5 ?9 \# u8 ^ -1# B7 b& V, d; E; z9 T/ L. W
};5 Z J) C- L( ]1 C' g% E
( Y: J6 T* v) S* H. B# x$ I2 K: u
static struct gpio_led da850_evm_tl_leds[] = {6 Z# _! `& @/ L% E& u, L# `
{5 B+ o; h* W- q1 t9 e; }
.active_low = 0,
) {( j8 p+ |: n! z" X; n* ? .gpio = DA850_USER_LED0,- ?' m. [- a/ ]4 b
.name = "user_led0",! ^1 F4 `" b$ q/ w, P3 _
.default_trigger = "default-on",- N; o$ Z3 K5 | X
},0 [' f* _) s; v- H R
{) q0 K2 M7 ^4 f3 w
.active_low = 0,
( b- x' D$ o9 \) c. ?0 `& ? .gpio = DA850_USER_LED1," L$ B8 a, B. z; m: k( c# W# }; }
.name = "user_led1",
8 M# _, E1 J4 K9 Z0 O& o3 e .default_trigger = "default-on",
/ D5 C: ~$ [2 n( p- [. ?3 m },
: S3 \+ ~4 ~2 `% J {
- [. @" ~4 J$ h' d. P( I# c" t .active_low = 0,
; K5 X+ r- L( N& q, l& Z$ O5 b .gpio = DA850_USER_LED2,. c8 g r! Q4 u0 O! V0 |7 N5 m9 }* z
.name = "user_led2",4 _" ]7 e4 T1 }! \! m: ^
.default_trigger = "default-on",
4 X3 ?: ~& A# | },. O8 X) H% W* m' R
{% J- V: {3 R7 w/ c
.active_low = 0,) T, w& W& u0 J3 |% q
.gpio = DA850_USER_LED3,+ M7 U) l6 i, }! T* z
.name = "user_led3",
" I7 Q4 L( g P8 x3 { .default_trigger = "default-on",
8 S @8 H; l; D' s },2 |7 ~" Z; V& O: v( ?# K' X
};
" P% Z& g2 p9 X3 W7 Q9 O: x
1 [$ I0 k7 a. h2 @/ j' Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 E$ v/ r% G1 ?0 w .leds = da850_evm_tl_leds, B/ [$ y2 x. J
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ t, `: D- L! N' |$ e6 X
};# F6 c+ Y4 f- K7 N
9 u( U3 V$ T1 [; z, y: p
static void led_dev_release(struct device *dev)5 Q# t: U; r |) Z6 `8 t
{
: n- ?2 D. N& E3 R9 V};) E; B% c B5 _- t$ T5 R
' k5 v, D- W4 o- n* @static struct platform_device da850_evm_tl_leds_device = {
6 V: n1 b: @/ b3 W; c .name = "leds-gpio",
5 |6 F( O$ I* W) K% u/ F" a" v .id = 1,5 X* U* y0 `4 s+ z- |
.dev = {
% u. u, Z$ f1 F! I2 }( L' S7 o8 X2 k .platform_data = &da850_evm_tl_leds_pdata,
! A, k8 Y; J' N+ S1 o .release = led_dev_release,6 ^' o* ~# T3 K% q- _9 L
}" b; B1 t6 i" L: [ b' W' s: L0 q6 [
};
( @( U, d; k$ _7 L% _* t6 h: G/ Q; r+ Z" o4 D: m9 [+ Y$ v P4 ~" a
static int __init led_platform_init(void)
" j% G% ^# v3 I- _0 Z+ F9 Z{
$ X v. `, \/ a. ~4 B8 H+ R: I9 D int ret;# l8 Z# A! P0 ]. @
#if 09 O$ x3 K; t, k; f% M4 D
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' S7 K9 K, E3 ~3 j# N if (ret)
/ K1 o- J& [4 I pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 b* N# W% R9 P7 D "%d\n", ret);2 W0 M0 Z0 ~2 q, v: x, V% o
#endif: n6 P9 X5 i/ I1 @
ret = platform_device_register(&da850_evm_tl_leds_device);
* C8 [( Z3 {, B$ f9 \1 A if (ret)
4 z. l2 c& j5 j( Q' @! \ pr_warning("Could not register som GPIO expander LEDS");* c \. R5 W4 }5 a
else. g0 b8 j0 o; q4 `, s3 d
printk(KERN_INFO "LED register sucessful!\n");# Z/ q0 n: U( f6 e- x+ v
8 v2 s1 c5 X4 L; A7 G2 z) b return ret;
! F# s( x$ C* J' x0 w5 q0 G" q( }# u}
. P& V% N, P# L# @0 X# {/ @% i) v0 ~2 i% E2 D* i
static void __exit led_platform_exit(void)1 U5 z5 o8 H4 s, z* y3 Y
{
5 }2 k F% |3 v0 w0 Y6 l8 y1 |, S platform_device_unregister(&da850_evm_tl_leds_device);, d/ s8 ~ y; z5 Q0 y' ~) n3 j
: h: |% `' a+ w& E8 u0 v
printk(KERN_INFO "LED unregister!\n");
# m& y( y( M4 n% s4 d- t}0 k$ h& L- C! j' H( p O+ W
7 b% d: H2 T2 p, V/ Fmodule_init(led_platform_init);
' @0 a4 c; Q+ f$ w- ~6 Qmodule_exit(led_platform_exit);
/ ~1 p% I! M8 b! ?# B& n# c. H% ~/ G: b- N8 Y5 y6 }
MODULE_DESCRIPTION("Led platform driver");. Y' F Y$ U+ e
MODULE_AUTHOR("Tronlong");7 Y1 v& E3 D, B5 A* y( i/ Q
MODULE_LICENSE("GPL");
. |) a- E8 C( t$ W- n
% m, k7 X! q2 ]) O2 j0 \ V |
|