|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ n0 y6 {; I$ y( L4 W1 @#include <linux/init.h>% h/ \+ ~& x* p6 J9 @. A6 M
#include <linux/module.h>2 e2 @* \8 l G. X1 p/ E
#include <linux/kernel.h>4 }3 W- }4 T0 o) \
#include <linux/types.h>
0 `& N( b. _* e#include <linux/gpio.h>
% z- c9 z# p9 O$ p. D#include <linux/leds.h>
7 u+ w( V8 q& T. ^$ m" D9 F#include <linux/platform_device.h>
# Q/ Y6 A; u6 m+ [! V
" s2 O( W3 P. f+ @/ F. J" |#include <asm/mach-types.h>
. _! F# h" R6 I! l' x5 i#include <asm/mach/arch.h>
0 }2 \1 O# W( O; U5 ~# [#include <mach/da8xx.h>
, E: u/ f9 |8 T8 g#include <mach/mux.h> t: _; @% o( Y) t! z& h: f
0 t0 e( I; T9 e* n, H! ]- H* r#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( P$ d/ R- g0 \
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 u2 a: J: ? J
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: S' [; S5 ^* h5 Y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 H* m9 I4 q1 z. r4 u3 |
- k* U) ~, Z% W# p/* assign the tl som board LED-GPIOs*/& x; `! g* {( p! a& d5 |
static const short da850_evm_tl_user_led_pins[] = {( K$ ]( }' z3 e# Z/ K
/* These pins are definition at <mach/mux.h> file */
* q& A% T8 X4 o4 ^. ~ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 B! y" V. n4 i( ~8 \. L5 ? -1
! a O9 ^( ?9 {; A/ a}; G9 t( E7 w' \# O8 ]
. f5 S* D. P9 ^) f3 e( l
static struct gpio_led da850_evm_tl_leds[] = {7 N6 U, r& W1 I% B- [* r: G
{
: Z1 @3 o0 }! T .active_low = 0,/ o4 O! | B- G- k* A
.gpio = DA850_USER_LED0,# b8 V. M" L! j6 Q
.name = "user_led0"," R7 s/ p0 M3 c7 L
.default_trigger = "default-on",0 `; f5 U( P& E% E
},
/ R8 C7 ^+ Z+ a* [! d0 M* i {
( [- m3 @( {2 H3 y4 G$ b; D .active_low = 0,
# e/ |3 m6 `5 c! `8 Y: c .gpio = DA850_USER_LED1,5 b8 v) T2 @- ]
.name = "user_led1", U' g, q" l" Z" {0 j& i. }' j
.default_trigger = "default-on",6 P8 a O& r$ A; j
},! u: `0 F. x/ h% y5 L/ G
{
+ [- a$ Q0 ~3 H: `. i5 f .active_low = 0,
' ~. [! y2 ~2 y) _/ v .gpio = DA850_USER_LED2,
' a: }: [% Z; m% \8 ? .name = "user_led2",
; ]+ ^7 [& U) z& p .default_trigger = "default-on",8 A3 T* s* G, j/ `4 H! U6 z
},
$ u: Z5 ]. F5 R) e; A {
" z6 o% l4 \0 @ .active_low = 0,7 K0 W; t0 s' h7 m' d$ O8 \
.gpio = DA850_USER_LED3,' A* Y+ X3 A- U
.name = "user_led3",
' n. o! k5 q9 X, ~6 U4 s) Y .default_trigger = "default-on",
" z/ M6 t) l/ D# Q2 h },/ T# X: y1 ~# J7 @' p: W# P
};+ v/ H* ^( v7 w9 S7 @
& c/ |9 K4 f6 Y. f* Q$ Tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* q8 O9 X" \ h .leds = da850_evm_tl_leds,
& @4 i3 M5 T1 I- ~" p .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 U: L! V* @8 V; t- D3 E
};& {! p7 }, C' X8 } c+ K
$ Z$ r/ Z# Q) m. P: Sstatic void led_dev_release(struct device *dev), K* G. t* v9 T# a. @
{, g1 D7 k$ C+ q2 d" K4 w& [
};: u* d4 f6 U5 k3 q
1 e6 F& E: L+ K& h' X F, f2 A
static struct platform_device da850_evm_tl_leds_device = {+ p0 Y+ d% P" {
.name = "leds-gpio",
6 F) `. }* l; f. P .id = 1,
/ E! j: r' P. |; u .dev = {/ O4 S( M3 M& d& Y3 \! F
.platform_data = &da850_evm_tl_leds_pdata,
( w# E I. D" `0 e- `! J* C( l .release = led_dev_release,
& G6 H4 Y3 f9 |9 H5 v3 r }" ?0 r# ^, \: k/ K: M9 ]
};
0 x" [3 R; W8 ~+ u2 [( u( ?" h, | R3 s/ d" i# X
static int __init led_platform_init(void)
, u3 } P9 ~# t2 c{! O$ y3 y1 Y5 m" S; c+ O
int ret;9 t" v( I1 U/ ?4 T8 o d5 X5 m
#if 0
$ B/ c) r0 |0 Z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 r! k7 {5 m' X0 l2 H0 `0 ~$ r
if (ret)
6 r' S4 |5 G: w2 x0 f R* g pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' W: K& ~( o# O "%d\n", ret);
, m) g6 O t/ V; m#endif
* S3 R. c, @6 f/ ], ^9 [ ret = platform_device_register(&da850_evm_tl_leds_device);
# U2 D: C2 i7 D if (ret)
+ w# E/ k' p& V pr_warning("Could not register som GPIO expander LEDS");
/ C- u# V: [5 i2 W: j0 {. m( ?/ q else
5 D& t; |( Y* U N! U" u printk(KERN_INFO "LED register sucessful!\n");
9 L) {5 o, u2 k6 `+ |. `8 [$ Q; z. ]% O& ^% i( P
return ret;# p& l. ^# D3 X, K! f
} C- n' v; }4 S1 t6 y
& L* u/ Q/ Z# u- }, i
static void __exit led_platform_exit(void)
% `( m: _6 ~+ S1 r1 C{
?6 Z* b' n# i+ C2 @' s platform_device_unregister(&da850_evm_tl_leds_device);" P7 e5 m e5 \9 @$ I
* E& w, ^; k1 A" { D: C% u2 G
printk(KERN_INFO "LED unregister!\n");
/ P! G: c+ H, Y" l# j}8 V; E* I" T# r% ~) N9 w( {
. {7 p: E ` Z% l3 _4 imodule_init(led_platform_init);/ o; ^! g/ {$ f5 D+ e
module_exit(led_platform_exit);
3 n1 P% i3 P7 F) a$ j6 Z* P q6 T U9 j% b2 r; q4 _! V2 R
MODULE_DESCRIPTION("Led platform driver");1 m: a/ X4 C+ \2 k9 o$ F) T. C
MODULE_AUTHOR("Tronlong");# Q3 V4 F* J- b W; f
MODULE_LICENSE("GPL");( O" O- w" v% X- ?
7 ?4 R5 e0 w h$ I* p
|
|