|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 s0 j" v7 C3 M( \( i" [
#include <linux/init.h>; [& U9 q5 \3 B4 @0 I* D4 x
#include <linux/module.h>) d* J9 ~( f: m7 ]+ J+ D
#include <linux/kernel.h>
1 B! I; P. T4 E1 r#include <linux/types.h>: n; e! ]* |3 m& P6 d2 ~) t/ S
#include <linux/gpio.h>
, W, z( B. @$ Q9 L#include <linux/leds.h>6 ~+ @3 M. m9 z
#include <linux/platform_device.h>
" i ~+ h2 m0 i& x6 M& p- O
& T' u% m" w7 Z# b% v4 f#include <asm/mach-types.h>" `, w- N+ t* V# }5 f
#include <asm/mach/arch.h>" j2 }0 T, J4 f" L! t
#include <mach/da8xx.h>
2 ]( t2 [! C8 X' p& x. v#include <mach/mux.h>7 }& `; I6 k6 k. R: z
% B: |9 v; ?* @5 v3 B9 }0 K#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* M! P) m" Y! m. Z9 z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 Y) o0 Q m* I1 j! v2 |#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), k3 G9 S2 L! G# A0 V" B0 o4 Y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ d; ?! T$ O( L: ?
0 d1 q) ^# |9 y" G; \/* assign the tl som board LED-GPIOs*/4 g% j; [% H7 V6 y2 Y% w
static const short da850_evm_tl_user_led_pins[] = {
2 e: I$ z/ S n/ d: ^( @ /* These pins are definition at <mach/mux.h> file */
) w5 d6 H2 t% O9 e7 A DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; x; o! Z5 g2 X1 @& ]* l' K
-1
6 [4 ?/ S+ i7 B, D3 e};' G1 B. m6 Y3 n' L# n
5 p6 _# [+ H5 g+ ]# z& l7 t
static struct gpio_led da850_evm_tl_leds[] = {& L( U* c) U- u6 R! M
{
& Q# R$ ]! ^8 P- w .active_low = 0,! b; D D* i8 I. h: V o
.gpio = DA850_USER_LED0,' Q- Z+ ~+ Y0 x2 k) R; B
.name = "user_led0",
$ @4 p" u7 p3 s& ^- M- e1 O .default_trigger = "default-on",6 y: e: ]1 a2 I* A
},
& C U# ]' X# V K {" K# R( T( z3 M5 B' A
.active_low = 0,
7 a2 c! \ c8 _ T+ V .gpio = DA850_USER_LED1,. x# X* w- x5 U0 Q- N
.name = "user_led1",
. ~# a8 ^$ S9 Q( }% _+ ~ .default_trigger = "default-on",3 m0 u) i, h2 m$ ?% J- ]
},
6 V o0 j3 x9 N& n" X. A- R* \* i1 K {" t7 l; H2 a- Y& H5 f
.active_low = 0,5 G5 H$ M( m& K
.gpio = DA850_USER_LED2,
, M8 j3 s4 s# _' F% d9 P# T+ V .name = "user_led2",5 W" D, K$ M* y
.default_trigger = "default-on",
# `9 f+ M5 `/ i$ _4 C9 e. o },0 M2 W% m$ N8 r' W
{
1 U% U @8 P z5 D" s" @; y .active_low = 0,; ]: L, w. Y l+ l) N: ^
.gpio = DA850_USER_LED3,
5 R |5 H; n+ d3 W7 e1 ] .name = "user_led3",
1 ~+ x7 w4 P3 F ?2 O .default_trigger = "default-on",
4 t1 j$ K3 [5 N- a5 g% g9 w# _ },2 p3 m& X+ ~& E" |
};! o4 ]. H8 _- J3 [, G6 m
P$ _; B. E, W! [( H! A
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( |5 C8 E$ ] f: L1 q9 Z .leds = da850_evm_tl_leds,
6 @4 ~( j) y6 o$ z; v/ ` .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. Y0 k W0 W0 b# \; c9 e2 V. f4 s
};
8 S% V/ w- D. r( L) V3 ?( C# S y( V; R4 r J+ }5 ?* l! E
static void led_dev_release(struct device *dev)+ ?) r. q/ R% O
{
/ y+ r; Q- k7 X2 f3 y0 `};- c" d a! S _. T% X
, T7 Z9 E7 m# m% k3 a3 B
static struct platform_device da850_evm_tl_leds_device = {' X" n% r% p4 l: q
.name = "leds-gpio",! F( w- r, l2 K; O
.id = 1,
! M- [) R( }9 e% _* c# D4 ^+ }$ H, I .dev = {
+ w# k& }0 f5 l$ x! _$ J .platform_data = &da850_evm_tl_leds_pdata,7 A; u$ `" }+ k) e" q& \; F8 [, p, ^
.release = led_dev_release,
/ c, Y2 X6 a3 L' ~ }
2 ]) L+ L6 L! ~5 r. O};
( [1 M5 E }: B$ d% p
1 A! u8 O. E. V4 S1 I; gstatic int __init led_platform_init(void)
c. }- t% w. r3 V8 L, R{8 Y- o. F3 _4 `5 A- ?
int ret;9 q. c. |3 z* p/ ^
#if 0; L" u$ ~# M! ?5 {" ?+ G
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ ]9 l/ O. f! k# H) m1 |1 ~( J" d
if (ret)
- }$ B9 u2 n% i1 I3 i pr_warning("da850_evm_tl_leds_init : User LED mux failed :" p `, `$ F2 y" ^
"%d\n", ret);
$ D# h. g$ ~, I- z; F% L2 i#endif1 t+ h: u" A1 `
ret = platform_device_register(&da850_evm_tl_leds_device);
* A4 F. N3 g1 L4 C: h2 _( y& m6 s if (ret)* j: f; S6 q( w4 j' R) h! w
pr_warning("Could not register som GPIO expander LEDS");
9 O" e9 y- y- y7 q else
6 x; H) h; E p8 [3 g8 W( p printk(KERN_INFO "LED register sucessful!\n");
, t: r& D) g0 S+ `9 f% U$ h3 S8 W8 H1 A
return ret;3 n3 K2 `" @5 ?5 m2 a2 `' h' W
}4 ^7 a5 Q- T; `2 [) G
2 |4 Z* n5 ?3 P S( c
static void __exit led_platform_exit(void)
4 C0 B8 O3 v) @/ P4 y. g m) K{, }+ {2 m8 S% u" I
platform_device_unregister(&da850_evm_tl_leds_device);3 _: R% Q' D. B. x' V4 p: @
5 ? v( ~, V# u$ m0 ?' _$ r printk(KERN_INFO "LED unregister!\n");* W+ ~ w+ r. E
}
5 s n x% I& g% s! Z
. X7 w9 x) ^0 Vmodule_init(led_platform_init);( k+ V% v5 J7 |; h
module_exit(led_platform_exit);
; I* N' B0 f6 t( k# |5 D! a0 ~. {+ x3 P1 Z @7 ?! @) u- K' x0 s
MODULE_DESCRIPTION("Led platform driver");/ i8 B. S5 [ `' G; I$ _8 Q
MODULE_AUTHOR("Tronlong");
% }7 H4 A2 Z" B: k% P" R4 _MODULE_LICENSE("GPL");
+ y: I% q8 s8 P1 s, ]6 `0 i" l$ [
D8 j+ a) F, q6 g. Y |
|