|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! y- w2 Y- p8 k+ {) f% n1 {
#include <linux/init.h>4 A( \% ]5 v# Z
#include <linux/module.h>1 R/ Y/ X, L& Z9 O! J# I
#include <linux/kernel.h>0 W/ V$ L( Y8 }- x" C; T
#include <linux/types.h>" w; O9 Z K4 F; H; s$ e( g' k0 E0 p+ T
#include <linux/gpio.h>
* B6 m5 B! e! T#include <linux/leds.h>* |, ]- y0 B- X3 ?: O. h& K; W( C
#include <linux/platform_device.h>
4 d; a" t% d/ z; J6 K9 Q% z4 q# r. A; r$ o' K* ?
#include <asm/mach-types.h>
+ ~! c* u% s6 a2 G8 w) b0 H#include <asm/mach/arch.h>
' ~+ j+ D' b B+ C& g1 k# g#include <mach/da8xx.h>
/ }( u% a9 ~5 v2 ?6 h+ H#include <mach/mux.h>$ o1 a8 `. x5 j: r; s. H
. o7 \4 k# p1 Y4 H/ c# _6 q& A% F#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 b, c, n: i/ }: \- M
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 `) x( j J' I1 q8 H; q; i6 y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ b# `+ t& m# s9 `
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 ~; b8 D; W% u- ~ U
/ C, D3 `3 L9 Q
/* assign the tl som board LED-GPIOs*/0 N$ n5 H" Y, Y, S& e+ F( Z9 n3 J5 }
static const short da850_evm_tl_user_led_pins[] = {
' ]4 A; |/ {* y( w /* These pins are definition at <mach/mux.h> file */# [* |* U" {1 I: j8 x8 U
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 b1 V# T2 ?* C3 o- J -1
1 {: A& f1 f2 Z4 n) R4 ?; v2 m};- x9 ~# X% F8 {/ ~
0 v+ G3 s w& g9 C2 Rstatic struct gpio_led da850_evm_tl_leds[] = {& \; W' t0 D2 n3 P
{
; r5 e2 K3 S, a8 q. c .active_low = 0," U7 L0 l- G" Q F
.gpio = DA850_USER_LED0,. |* {1 }) C3 j* Q
.name = "user_led0",
7 s+ \5 I4 w2 [5 } .default_trigger = "default-on",# B* |2 S1 L+ x2 R
},: C+ z/ l7 Q( q& a0 P
{0 v+ c' v& K x' b0 @
.active_low = 0,
8 u0 l8 ?9 e( `$ S# ]" p, a( z .gpio = DA850_USER_LED1,
g! K# X3 U4 D- `5 J .name = "user_led1",
2 E, f& K9 F% h; F: Y5 Z M) L b .default_trigger = "default-on",
# M% Z: e. R5 Y2 [( r" d },, Q: Q1 a9 w' g3 F7 z
{
7 O0 m8 r S7 `6 G9 p; a .active_low = 0, m7 A( J0 X2 K; K8 B6 I
.gpio = DA850_USER_LED2,
. E) \* r* K7 j) ~ .name = "user_led2",
+ c7 Q" m% {! `) n% S5 U .default_trigger = "default-on",
1 t" ]% ~/ f$ c( @0 v7 P },
! }+ M0 R: k. f/ W {
- n, p0 T$ {" s% m B+ \ .active_low = 0,& ?4 D* T: p9 e0 C ?
.gpio = DA850_USER_LED3,
9 ?# W' k C1 _ .name = "user_led3",3 G" }4 |; R4 g( v+ k! Y. b. j
.default_trigger = "default-on",0 a1 U! _9 b5 E# r: J
}," i- G% G, d e+ Q' x
};! B) ]! k/ f4 S5 W. G# P& h+ A
$ h5 {7 P5 Y9 g: p3 {) B
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- h/ \ I$ U; }: Q" d9 V8 Y .leds = da850_evm_tl_leds,
4 q9 N' Z/ ~ L: {9 n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 u: p h2 l; W
};7 x4 c4 F9 g5 K0 S( s
- g* y9 q* v9 g; J1 ^9 @' tstatic void led_dev_release(struct device *dev)- F6 ?" E W5 z4 [5 |; d. \
{
7 [& N6 |7 O7 `* ~4 z};+ N" F/ x+ I3 `9 Y9 l; o
- f6 Y6 R/ O% A8 X F: z) b
static struct platform_device da850_evm_tl_leds_device = {" I4 z) v' K" D# a& W+ U
.name = "leds-gpio",7 \- J& \- {* ~* b4 D0 D! B/ L
.id = 1,
; R( n) c' \! a9 K# ? .dev = {
; d; i- `, b. n! a .platform_data = &da850_evm_tl_leds_pdata,
+ B% J! G) h2 E% W2 ~) E; P7 C .release = led_dev_release,
' a2 l% C0 I4 f, ^2 r }
& Y9 \6 f \( h0 |- w};
* q5 g" G5 c, E2 |7 }3 d9 B" o* H* s9 p
static int __init led_platform_init(void)
2 p8 {" U5 ~/ V4 H' t& m{
6 U: R+ S W. ~0 O int ret;
4 A( s& F$ V0 O5 V#if 0
# ?( G" C- W+ m5 i Q/ G% m* u/ l4 q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 ~& H7 F7 r! O+ d6 n/ k) B7 N if (ret)
9 S: [( \5 M# D/ F pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 P. [7 T! M+ ^9 W! {$ k; g
"%d\n", ret);
0 R% j. j' C. R#endif
+ U+ k; d% O' e3 w4 `9 ~ ret = platform_device_register(&da850_evm_tl_leds_device);
& F& A% A* g1 S" P. K if (ret) b) W. B" B- h! ]
pr_warning("Could not register som GPIO expander LEDS");- J- v7 @6 \: y- t* R* S
else
+ t& b) }0 x4 S' j. r8 | printk(KERN_INFO "LED register sucessful!\n");) G$ I$ L1 R1 m
4 S+ K$ J* m$ h, b1 Z& m- \ return ret;
! {$ j/ a0 d: ^) Q9 N$ r G}5 _* f' v, h& B3 |9 x* V. {0 f
6 S! J. z0 h. g' N3 ?3 n
static void __exit led_platform_exit(void)8 t" T4 k. H! ~
{
8 @6 h. U- T" p7 \4 i* X! Z platform_device_unregister(&da850_evm_tl_leds_device);
( g: T( ^; p. e6 c) X
0 H# q k- [, {3 N& ]/ e printk(KERN_INFO "LED unregister!\n");9 ]7 y; h( G" r: u
}
% Z- v$ G/ E& k$ s# l S, S5 |, Z
3 ]& h" c/ K: Z qmodule_init(led_platform_init);
* G( D8 V# C. {module_exit(led_platform_exit);
- e4 ]# Y) R+ k1 N$ b' K" Z" {
* v9 U# `: p0 J) vMODULE_DESCRIPTION("Led platform driver");# _3 J {1 t7 h4 N/ [
MODULE_AUTHOR("Tronlong");
: P/ M' y* B4 Y& a; w) dMODULE_LICENSE("GPL");
f0 t ~ i p+ s$ g: e9 e# [! L$ J5 l* r
|
|