|
求大神给下面的程序做注解,请稍详细些,谢谢。) g# g0 Y& Q0 a, O7 |5 z
#include <linux/init.h>$ m4 T# _7 j+ ^# c
#include <linux/module.h>/ M+ W) T" E. F, }4 ]9 D. C
#include <linux/kernel.h>, G" e; v$ G/ L' q
#include <linux/types.h># r# G- N; E/ t
#include <linux/gpio.h>
! V9 ~: ~5 I8 c#include <linux/leds.h>" v5 h( ]* I" H
#include <linux/platform_device.h>
- Z: \( T6 ?1 t# M, |) [# m$ Y, a6 O& z5 d/ y4 R' c5 t( Z
#include <asm/mach-types.h>
! g D3 P* Q9 w6 ~$ d3 L' \+ n+ k; c#include <asm/mach/arch.h>* A& O3 W# a* {8 J
#include <mach/da8xx.h>
7 J7 E2 k! q5 Y; { M8 V#include <mach/mux.h>1 |" Q4 M8 T, @5 d# {
, m" T0 _* ]" g
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' B+ E6 q/ F' I) `; _( D2 e/ {#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% O2 {" B a) b# N8 \' b6 ^/ {* t4 G#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 Y" N# T- U+ J8 ?: i' V1 P. [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 ?( G* m% N, a1 R
+ x" n- t# H2 G; ?
/* assign the tl som board LED-GPIOs*/7 I X8 `! r# W
static const short da850_evm_tl_user_led_pins[] = {" |$ [8 |/ e) Z2 b
/* These pins are definition at <mach/mux.h> file */
8 _. e9 S, I" v DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 _+ R& R( {" z' t6 G: _ -11 f5 L) E1 h/ e; @! d; S
};$ }3 W8 j+ m7 v5 x9 ^+ g
C, _, q8 c" D; k; ?static struct gpio_led da850_evm_tl_leds[] = {
5 n; A- @& h- Q/ F0 ~ g {
; |+ v3 F/ w- b! [, Y( w .active_low = 0,; y5 s \% y2 h
.gpio = DA850_USER_LED0,+ i# v5 u2 |$ o* p% K b; {9 D/ _ s- m
.name = "user_led0",9 s: D# |9 R2 e9 y5 s; Y
.default_trigger = "default-on",
# {9 Q4 H! |7 B! q) m4 i6 O2 } },1 E+ o: t5 l- y" Q3 M3 x' J2 r
{
# f- u. G) P- T( o( e .active_low = 0,) ^/ @7 k1 D) t- B1 V& m
.gpio = DA850_USER_LED1,
' l, f! [" x, b# N. B$ ]; c. S' \ .name = "user_led1",
, R( J0 `2 T" S .default_trigger = "default-on",3 ~) y/ u5 E( S& R# E& A
},
}1 [( l) H) M( Y1 I% t {) z: S: }1 S' G2 A' u8 T
.active_low = 0,; i* D5 t2 J- _, Q+ _: ]4 Y
.gpio = DA850_USER_LED2,
0 H0 i" \$ V" X' K/ a* {6 i .name = "user_led2",
& R' {: E- S4 @8 G9 J3 x: G .default_trigger = "default-on",3 P8 ^' s& @0 C# G
},
2 G8 v9 L2 Q8 h4 p% ]3 P {
1 s' F2 [9 n) G! s2 d6 r: F .active_low = 0,% X. W* r4 h5 k9 {! z7 w. R
.gpio = DA850_USER_LED3,3 w1 j9 a: z# Y8 r8 h% L
.name = "user_led3",
* u7 I! s: h: Z$ c: w5 W .default_trigger = "default-on",
. `9 b* \& r8 I5 l }," l9 J# N( F2 R# ~( r* P4 {
};
4 }5 @ @4 W" R1 s8 U1 k) ^8 b; I$ f$ O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
`! K% x7 q, Q" y+ Q3 C .leds = da850_evm_tl_leds,
* o7 D$ O+ Z8 m' F .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ e. S1 f/ k; c* b};
5 Y# U# q8 [. f7 Y; E" S4 J y9 x& }) k) K7 b3 O9 ?4 ?1 R% M: [# p% S
static void led_dev_release(struct device *dev)% S# x% F0 K+ ^ Z( S ^8 E* w
{
) Q9 }) d4 }2 ~8 l5 N8 G$ F2 t};" ~- s" o# Q* d. l* d8 i
1 j, X" g. A1 F& ]$ R# Ostatic struct platform_device da850_evm_tl_leds_device = {4 \+ n, I- N, ?0 X& b* O
.name = "leds-gpio",
+ x; K' M: h" |7 n9 r .id = 1,
# |- I7 F( `5 `" n% E6 w .dev = {3 @7 X' H7 X5 J* j& S
.platform_data = &da850_evm_tl_leds_pdata,. m5 _- O; F$ K
.release = led_dev_release,
0 ~ N8 F1 s) l$ I }
0 @ A4 n& o; A( ?/ j! S* k};) I, R) O. I2 X! G3 Y: u
- l: Y. W6 Q1 e4 w- J: Gstatic int __init led_platform_init(void)& F1 D- Q8 S3 E$ k" {# Q% i. g8 `
{, {7 x+ |. U6 `
int ret;- K/ ~5 i! m4 G! |, x) M
#if 0+ T5 S- q% P* W7 J) T. T$ D
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 X8 a$ G/ q" Z7 k( {* ?
if (ret)
R! R: Z; I3 o' q2 M6 d) @ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" E: _" o% `2 k; d# L3 P; \
"%d\n", ret);
4 ~2 Y/ j6 T4 A, t) ?: v#endif
6 J* r" [6 j( |! Q6 M ret = platform_device_register(&da850_evm_tl_leds_device);2 ~" a% h9 s3 f. m/ {# U: Y
if (ret)
2 z; s' Z. i% W9 L# j pr_warning("Could not register som GPIO expander LEDS");
4 n4 F p- u8 V else
& d0 Y4 f. U% d printk(KERN_INFO "LED register sucessful!\n");
8 E6 U9 F; [" f6 p+ o4 X4 u0 Z. Z! z2 |" O6 Q3 A/ r$ g
return ret;
4 q( O1 t; ^5 K$ H) i# M}
' r) [* Q1 {; A0 u6 T8 x
+ K) C' w" P0 M( ?) Y( Pstatic void __exit led_platform_exit(void)0 p6 o* q# J4 P0 L/ ^& n u
{( @' @. `9 Y1 _
platform_device_unregister(&da850_evm_tl_leds_device);3 W$ ^+ N8 Q% ~# u
, X2 n |' F8 f printk(KERN_INFO "LED unregister!\n");! k. v% |+ [& ~( E. H, Q
}, Z0 h6 N8 W# h' _* _2 l
" }, Y8 ?/ s0 N, [) Cmodule_init(led_platform_init);
( K2 n4 Q, Z! ?module_exit(led_platform_exit);
6 t; e7 ` |* ?9 I6 X* O! ~ l6 h6 ^
! d7 F% G: g7 u" p( U" CMODULE_DESCRIPTION("Led platform driver");
2 |, o. k: E& h3 S- A9 P( bMODULE_AUTHOR("Tronlong");
+ p- C, @9 Y) h- ^. t9 C8 e, ~MODULE_LICENSE("GPL");
1 t$ s, q% w5 K Q. B( U) P
0 x) {: E1 i. {5 [. \/ C& z |
|