|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" ]; B" ~4 Y) G X, j
#include <linux/init.h>! Q/ z- K7 M8 [6 L
#include <linux/module.h>
' X& _8 B* P1 l$ u+ [' ^#include <linux/kernel.h>
% P& r- n# s3 X5 ?7 i#include <linux/types.h>
6 k, I1 j4 x K: x' [* }#include <linux/gpio.h>
3 h4 D7 _) I1 e* U#include <linux/leds.h>5 i# r' h/ G/ i& s/ ^ o
#include <linux/platform_device.h>
4 n- b# G. A/ E! {8 b
: ^% `. D. y5 L1 Q+ F# D1 @$ ?#include <asm/mach-types.h>( t9 ?3 r8 j/ a$ T' |
#include <asm/mach/arch.h> O) g2 Z; D& d1 W$ ], Y5 N
#include <mach/da8xx.h>
& z: n1 {8 J" j; U5 ^2 V#include <mach/mux.h>
# B* R! _8 f( N& Q: s, q2 W" @7 k- c- Y9 k% C' v' U
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 u, d6 b4 E6 g$ V5 O) y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 Q' Q" I* z5 R
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- Z" u& p0 L7 r( k# o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 r$ h* O! O# [, \* U R
0 O6 q4 E# @; J! O
/* assign the tl som board LED-GPIOs*/
8 \7 r! K: E1 mstatic const short da850_evm_tl_user_led_pins[] = {1 M5 ~, ?+ h E. H
/* These pins are definition at <mach/mux.h> file */; c% [' J* ?6 L7 W
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( F7 ~% Z3 o; _3 H) e -12 O* g( T9 ?2 Y: F) P% u2 b1 O
};
. ]$ Y/ x: K7 q. }$ A( M5 Y1 Y: _% Q7 ~; e9 ]' Y
static struct gpio_led da850_evm_tl_leds[] = {
7 R/ J1 @2 k# q- ? {1 u8 f i' u$ F) ~) j% [5 n
.active_low = 0,
! L* U9 m; u J; I+ r .gpio = DA850_USER_LED0,
9 P2 I) \- w% E' d .name = "user_led0",
$ z$ j, U% x! ?2 e/ y .default_trigger = "default-on",
4 C8 _9 Y4 \ v },
: T/ d- t# ?4 V) R& ~: c' b {
: O5 }% t. X: \# f& ~ .active_low = 0,
8 ~8 z* N; A9 i4 o, {5 H .gpio = DA850_USER_LED1,1 M; e2 B) W! ^7 t, ^4 g
.name = "user_led1",
5 m* v+ q: c/ B4 ?* [! ?4 V .default_trigger = "default-on",- ]& @. M2 H3 f8 h e$ g7 z
},
# ?: Z2 q/ J8 F {1 Z$ N1 M. c" z" A% c0 U
.active_low = 0,' d# |( Z; r! E( @! t9 Y" U
.gpio = DA850_USER_LED2,
. a) p1 V6 {. g) V$ I- _1 g, D# R: Q .name = "user_led2",
/ r9 _9 U/ d% J8 W+ {+ F) k; m .default_trigger = "default-on",
$ K9 s6 @. w' _" o$ E },
, r y, K, h+ u7 i& {+ ~( g& W {
/ v( Y4 e7 ?: F0 D$ n0 t .active_low = 0,
1 C( a0 @7 f6 f2 ?6 T$ X9 Z .gpio = DA850_USER_LED3,, L1 I. y' k' |. V+ H% v% U
.name = "user_led3",& e) C8 E% _2 E W
.default_trigger = "default-on",
$ |/ H3 i6 ]: f },
$ M2 [; G6 r3 C6 [1 I" t};
0 ], c+ g2 z0 [& U: o
4 q; F$ r/ G+ B9 [0 Cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* C5 }# P! H2 |0 c .leds = da850_evm_tl_leds,
, U M1 }( R: K* V+ \ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( P: Z% g, w9 X5 ^
};* j+ ?: v' G, y! ?/ M" L) ]
1 ^! T( W* T9 H$ D9 H* Q% sstatic void led_dev_release(struct device *dev)
8 f3 v) y; B5 R H" c{
' `" D" }5 j- s};7 S5 C8 B% Y( @ ]9 {$ N
: y& G5 W7 A2 q& S2 v
static struct platform_device da850_evm_tl_leds_device = { H$ ~- C' C9 h! n3 x
.name = "leds-gpio",
" n1 S0 H Q! l4 Q7 N& d7 A .id = 1,9 s9 c: i1 S6 h, x# L% z7 _" p
.dev = {
6 q' {) v* L) O/ ? .platform_data = &da850_evm_tl_leds_pdata,
3 E' u4 K& W7 `! l .release = led_dev_release,
& q7 v' W; ^3 y& k! D" [ }' I8 c2 | I9 a- A9 x$ |
};
/ a3 o9 `. L! c. g
9 _& G: [- d9 `( {, L% qstatic int __init led_platform_init(void)
$ p# H+ e6 @7 m( I% H{6 r0 H$ v. E. V. f; ~6 {
int ret;
* @3 o. b# F( B) A$ v- l. \6 ~) b( g#if 0) j' z+ q- S: N: R8 ?
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: C8 _4 o8 f$ D1 e# M
if (ret)
% W& u$ j" N+ J pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( g) l$ l% A% B6 u6 H "%d\n", ret);& I( A. s- E# U1 O
#endif
$ Y) n5 h& z- c }4 p b ret = platform_device_register(&da850_evm_tl_leds_device);
/ H$ ?2 A" X1 R- ]- B& [0 E8 C if (ret)2 P+ k9 `6 @1 p. }* K l
pr_warning("Could not register som GPIO expander LEDS");8 @7 f: T/ H7 U9 n2 R
else# O$ w6 L; `* d1 J) Y
printk(KERN_INFO "LED register sucessful!\n");
9 n5 ] [. w, {7 o9 z: R6 J) u0 | G: Y
return ret;
+ ]) V* W9 T% U$ H4 M9 G& X}
2 n6 Z4 {5 [& [ R& r* [
4 S& E; v! Z" z O+ l$ dstatic void __exit led_platform_exit(void)
! j- T+ z; E; v0 c0 l2 ]* D{
0 X( T1 S! s* x2 r0 M platform_device_unregister(&da850_evm_tl_leds_device);
* X% T3 i- O% ] Z- l6 V$ J3 c) v4 K/ l$ y2 ]9 T" ?
printk(KERN_INFO "LED unregister!\n");; O7 Z7 D6 u, X! o2 T
}2 E$ c, f v v+ G* ^
3 z0 l* Z1 n: e( |1 s1 k
module_init(led_platform_init);
8 Q* Y C7 I. h8 l: X2 P3 @) emodule_exit(led_platform_exit);( Z l/ D8 n2 D$ [. y0 d. I
% f& R' G! n5 v
MODULE_DESCRIPTION("Led platform driver");
7 a9 F1 [) ?5 KMODULE_AUTHOR("Tronlong");& Z- R! ]2 d& K' Z
MODULE_LICENSE("GPL");: u7 C) O; u! x9 `
; p/ r2 Q3 k* z7 c# \ T |
|