|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( N# b6 @2 b! E' ^- E" n
#include <linux/init.h>
- v; ]( H. N: |4 i/ g#include <linux/module.h>+ p6 F3 W$ E A ]6 ^5 z* r
#include <linux/kernel.h>* f: G N0 e* l; A1 ^- p# c
#include <linux/types.h>: u. Z% Z) j) Q! l7 e+ K
#include <linux/gpio.h>2 r& ? e, w% A. g+ C# s e' i
#include <linux/leds.h>
8 g# Y: u, a+ p$ S0 O) ~#include <linux/platform_device.h>
3 ]+ Z! B- i! o, |; {- L, Z
6 c4 z9 r m4 H! R% Q3 m#include <asm/mach-types.h>
1 a. W: U- }5 ?. a+ J5 Q#include <asm/mach/arch.h>: g) |3 P! L0 |- _/ n3 W" L
#include <mach/da8xx.h>6 _* _/ I& h/ u+ K
#include <mach/mux.h>! s6 J2 G: l2 K
; C: ~% u- c! A( z" K6 G
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 m7 k; G$ N: q+ y7 O
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- C) C+ ?, L( X2 z( P' v#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 z1 e6 j9 G* F/ d9 k, H) H#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( E9 \7 J: R2 H. ]" |/ Y$ W6 r# g
$ y* }$ V4 B, w$ b5 K6 W% `
/* assign the tl som board LED-GPIOs*/
1 E7 e3 v3 r8 W0 I$ V4 ostatic const short da850_evm_tl_user_led_pins[] = {
/ R) u( ~$ ~; P. J; v( x' r /* These pins are definition at <mach/mux.h> file */
0 [: ^& W2 v4 R5 W9 \ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- W1 Y% f+ D6 C1 l! N X5 I2 y
-1
! a/ D: a5 M+ u; H7 p};
6 B7 a$ c; C, E. k: \: v% P$ c- D9 ]& c" b0 E2 D
static struct gpio_led da850_evm_tl_leds[] = {
& V8 o J" n$ t; O: L- b5 ] {; Q: C- ]6 u3 _. O9 ^0 R6 ~
.active_low = 0,
4 y, n6 Y# x3 V. K! U G. T0 g# a7 I .gpio = DA850_USER_LED0,/ ~8 ]- E" {' U- G1 d5 M
.name = "user_led0",- T6 E7 `: J& e% X/ f4 z" t
.default_trigger = "default-on",. E8 _) M; v. b5 p
},/ O' w$ W( \0 [3 m# ?
{/ a6 k; N' e( }6 l: { V
.active_low = 0,
3 y" Y t( t% W* Z2 }+ M .gpio = DA850_USER_LED1,* P! z& q) x/ S V* z2 `; i
.name = "user_led1",
% _( F: Q& W' o4 B4 X5 @- e1 T& |. _ .default_trigger = "default-on",& C8 m# f$ ^4 w) E- ~& y3 U0 l! Z
},, z* O8 b3 P: V% f3 z' P! W4 @& |
{
$ l7 n7 p% Y/ C3 ?. l5 f) k( z" i .active_low = 0,- ?- }& _: G$ G* x: _* r
.gpio = DA850_USER_LED2,7 @6 ~& g: r8 l
.name = "user_led2",
$ B# Y% V: J8 e .default_trigger = "default-on",% P/ I0 c! K- i
},* u7 ]8 h; W/ j+ V
{
/ ]2 J) ? f& I* A& {9 J$ X+ @# y" X .active_low = 0,
7 m& [8 m& |! i- V9 G. G- @( d+ w .gpio = DA850_USER_LED3,1 @; C- e. N3 ?- G
.name = "user_led3",
& `- u; O$ c! y" ?7 e+ y .default_trigger = "default-on",! I/ t. `+ m1 @, e* r
},' S" L0 s' o9 `
};; @5 J: _6 K7 r% ~
/ l! D! s M# }5 Y2 {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% b8 k; }& @" \% U% q0 m .leds = da850_evm_tl_leds,
* w' `1 z, ^2 Y& h. ~8 d7 P .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 b5 Y* `5 t% }, m' {8 b};1 B3 A/ X7 e1 }9 d9 ]0 U- {
3 z9 |5 a3 Z5 c0 @3 Q. B% Q* V& \
static void led_dev_release(struct device *dev)
' _1 y9 e; i( m% T1 B& L, j{
9 b% x2 N6 a& M1 Q% M( U};; G, j/ ?* U' o# e6 A* i
1 h r: a9 p; b7 Q: _6 [static struct platform_device da850_evm_tl_leds_device = {5 ^# l) Q6 h/ i! |3 }0 _3 R2 g2 ]
.name = "leds-gpio",
6 I* O9 P) c# l% X4 } .id = 1,
7 y7 e/ S& T3 z/ ^% W6 C% `! R4 S .dev = {( O, ]8 R- r( B: p( \
.platform_data = &da850_evm_tl_leds_pdata,
# m% e( S7 Y* i2 V .release = led_dev_release,; J6 i/ `3 m6 @
}. ?' i2 ]& o" _& M0 t6 _# H6 @3 r
};
7 R0 r' ]0 U. ?$ G m
B7 l6 A" Q) Z6 U2 ~static int __init led_platform_init(void)
D" v0 S/ M: R. H. g+ D{
3 H: A: M+ f# f; o int ret;4 n6 D) {: P) ~# e+ h2 ]- F: D
#if 0
+ ^( N. h" p3 Y# H4 ^, b ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ e; o& Z2 x; Q$ E- c s
if (ret)4 o, O0 w4 h4 P
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 t0 S( c v& L "%d\n", ret);6 w5 r/ y1 a6 f- i! e4 d. O
#endif
6 R: F) o+ u$ U0 ^ ret = platform_device_register(&da850_evm_tl_leds_device);0 d7 g( E# |9 b* Y
if (ret)
6 ~7 g$ u; u; @ pr_warning("Could not register som GPIO expander LEDS");
+ {: r! v( j+ O& B else
2 u% w) w6 w* I' l$ H printk(KERN_INFO "LED register sucessful!\n");
' q L* W3 v/ [& J) I& l& |% h* Y5 \9 W+ U+ B- G6 _. o+ ~' Q
return ret;, A) S' H, w }6 X8 v0 S" f. ^
}
7 @" U3 u, R; P3 W1 c9 j5 d1 n1 r7 M x6 `
static void __exit led_platform_exit(void)
+ x6 v3 ^* u. y! o. G. E! A{
# B" w8 L: ?- h2 Q1 [* } platform_device_unregister(&da850_evm_tl_leds_device);( Y3 D: I" u: `' W) t: H9 m' Y7 u
* r' \7 b% ?7 |+ z: b! z" l
printk(KERN_INFO "LED unregister!\n");
5 c$ Z9 C: I9 Z}
$ K% W7 w% {6 S5 W1 Z
' o# ~1 y; w6 Z. N# J% l5 h1 Amodule_init(led_platform_init);
) J2 Z* ^6 @3 W ?$ h7 d2 j: j% Lmodule_exit(led_platform_exit);+ |$ ^. h8 b) s9 d3 G
/ Y6 |3 X( V7 B6 r& h$ vMODULE_DESCRIPTION("Led platform driver");. H0 r9 D: u6 \
MODULE_AUTHOR("Tronlong");5 @* M7 k& W! N8 w1 o: ~- i5 k% G
MODULE_LICENSE("GPL");3 m5 k5 H6 _8 c/ D) P- D
5 |% ~1 `- E2 o% L% ~$ R, |' A
|
|