|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 f/ R' o7 P. s$ a% q5 t4 f. r* ]0 Y#include <linux/init.h>- r! \6 L8 V# z, t: }
#include <linux/module.h>
. T7 }1 Z" r$ m0 V. T2 u9 [! z#include <linux/kernel.h>( d" \4 N D. X+ `3 h$ S- [
#include <linux/types.h>
+ K7 G) @+ z; N3 V: O#include <linux/gpio.h> o7 }- `1 }/ k! I
#include <linux/leds.h>
. D! r- I6 ]2 t" R$ x#include <linux/platform_device.h>) [1 t Z/ _2 i" N8 l: f
7 l; ]! B; P/ J4 z! v# z4 M$ s#include <asm/mach-types.h>+ S- R) B% B# y9 P+ _
#include <asm/mach/arch.h>
$ Y% y( c+ y/ S, J/ e#include <mach/da8xx.h>" P/ h/ k: h4 Z4 ~
#include <mach/mux.h>
4 g+ o/ [8 A$ N' Y) b
8 N6 `2 g. A/ h0 Z8 Y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 b3 B8 H% N! q) |, _% ^1 y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 ?( n( Q8 Q* L) A2 {9 m" j#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* H2 W' N# N$ m. f ?
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); s4 G: t1 E' u# \: `
( [! X$ s! G; W) p: q
/* assign the tl som board LED-GPIOs*/
& R- X+ W, u9 ?# j( astatic const short da850_evm_tl_user_led_pins[] = {2 {6 T$ o9 F% X8 e% |/ v" d8 q
/* These pins are definition at <mach/mux.h> file */& c2 d3 E2 u |1 q* _7 P* l" ^- B
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 l) C8 e. |! m9 b
-1/ X( M6 F/ r* x
};
6 D- u: n @% u i9 d1 `" J
. G/ [/ }* k6 v" i! Q" C# n8 i+ e" T- rstatic struct gpio_led da850_evm_tl_leds[] = {5 l' a% b$ e1 _" {' w3 m& `
{& B' t7 |5 ] S5 V1 ^% S* N' ~
.active_low = 0," M6 x2 R+ [) i8 g
.gpio = DA850_USER_LED0,! ~5 s, Y' ]8 }( T2 t' Y
.name = "user_led0",6 l/ D8 U: T- @& z/ [+ a
.default_trigger = "default-on",
2 I* g( h4 m1 @. q' t },( m; u2 @ Q% q6 O' j9 F* f
{" d: G9 V! Q# I
.active_low = 0,0 X+ \4 f8 U& {5 q4 Q z
.gpio = DA850_USER_LED1,4 Y0 j) Q! f2 I# k/ h
.name = "user_led1",
i+ X: |" n. ?8 N& o& J .default_trigger = "default-on",
p- S: t; ~+ j2 a t& i- x% [ },& G; R* D5 N: e% \
{- `1 s" @( V& x) R$ a
.active_low = 0,
" z! _# s* u8 p2 Z% Y# s/ }$ s .gpio = DA850_USER_LED2,# }; ~/ b1 L! k% G7 n: g4 f3 |
.name = "user_led2",
% }/ y5 k7 o3 B/ ` x .default_trigger = "default-on",
G& X* ]7 S# g2 Y },
" u+ V7 ?, B8 D; M {1 j5 F& \% c# R9 \
.active_low = 0,
0 l: n1 [$ _, ]* `9 b8 F4 }+ o .gpio = DA850_USER_LED3,
; l, U8 A( `- T z) Q6 v .name = "user_led3",4 \7 z" h2 L; u! V) N" u
.default_trigger = "default-on", y6 T5 w$ C6 `4 q" b
},
. ^$ t! Z$ J1 Z" m' \/ V};3 u) a% t7 Y' Q$ w. ]
3 O' I# s8 R& N' _9 Y" ^+ c
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: F. K/ W5 Y" B* P: p5 R# c+ Y, {
.leds = da850_evm_tl_leds,) M- N' l$ N0 s a
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* F7 k/ P% |$ h6 \};
2 n# O0 Q7 U9 H7 p( x2 s8 q6 O. I0 g9 r$ N7 k
static void led_dev_release(struct device *dev)$ w& N0 s' J7 U
{' A0 E! H! `' r7 I. u$ x6 l% \
};
% r# W( U' d ~/ f, o
. ?3 s+ ^. _+ R; u6 U# sstatic struct platform_device da850_evm_tl_leds_device = {$ _- V4 T: R; V5 a/ U# U- E
.name = "leds-gpio",
; c2 a* b+ @4 ^( s, M .id = 1,
% o+ a$ f+ e* Q+ u6 M2 [6 t .dev = {
& F5 F5 j" { { .platform_data = &da850_evm_tl_leds_pdata,
1 S6 }/ Q: O# D: N. T/ \$ N, D .release = led_dev_release,
3 y2 c0 a, o% k$ C1 J9 ` }
! y4 y' _, Y8 w1 U+ T" c, T ]};- Q+ p. R, r8 f- {2 B. V% J% h
0 K$ m1 l7 D6 i+ J
static int __init led_platform_init(void)9 h2 _" Z3 B% r" L- B2 \# ]8 w
{) S+ f# y7 n: O
int ret;, o9 M# U, v" o
#if 06 S0 z$ o; F: v5 h* [# g- ?; I+ J
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 O$ }8 a8 W2 {1 c# l if (ret)* D3 \ e5 P1 e5 s0 K( F0 i/ l
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% A! a4 U& ~4 t+ c "%d\n", ret);
0 e q; L' L4 g#endif1 [* \$ w1 C$ S
ret = platform_device_register(&da850_evm_tl_leds_device);
# x: c* M( z* e: D if (ret)% w1 b7 S' W* |0 ]5 {, F
pr_warning("Could not register som GPIO expander LEDS");, L9 b- T" ?( `$ U% ?
else
' T0 j/ a) g9 T( d; D# F* E printk(KERN_INFO "LED register sucessful!\n");
( z I- m' }$ }7 {5 n/ R: R( [) r `6 \2 T( `1 q
return ret;
T) m) A$ E( @& K$ ~# O: l3 R* k( Z}
# ~; j( |, H3 W/ z; L; C$ w
- [8 a: @1 s4 }# ~. k- P% q7 ]- }static void __exit led_platform_exit(void)' V1 K8 K3 M# i/ O
{- I+ X, [ \4 z8 M( F$ d) W
platform_device_unregister(&da850_evm_tl_leds_device);& T2 Y/ J! A. L7 ]6 w! o9 V
/ ~9 Z5 O* ~& F7 h3 s
printk(KERN_INFO "LED unregister!\n");2 @& I. D" G4 ]9 H
}: K, N2 I) N; i7 M+ U. _7 X
& _; w( c: f: F2 g. t* F$ U
module_init(led_platform_init);
$ }, a1 d+ ^5 n8 |' Pmodule_exit(led_platform_exit);
' }6 F% N( n0 Z/ {8 ^
( P( C$ H9 C) ]' bMODULE_DESCRIPTION("Led platform driver");
3 b. j2 {& T$ b5 jMODULE_AUTHOR("Tronlong");& i1 {) O6 s5 L! }$ {$ }
MODULE_LICENSE("GPL");7 Z' l5 I2 {" x+ e- v$ I: U% V
# s4 q$ H8 a# R( ^ |
|