|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% }; M+ d# j0 V- @
#include <linux/init.h>5 P: t' b5 E' p5 W0 h& P
#include <linux/module.h>
& Z- U6 E) S" P# ]#include <linux/kernel.h>, [6 G% h+ m) S9 ~7 L" m5 z
#include <linux/types.h>6 |3 [4 P% m( Z2 P/ ?
#include <linux/gpio.h>
/ c5 _. Z/ H9 h/ h) ]#include <linux/leds.h>
: c; g# b' p( X% w8 P#include <linux/platform_device.h>, t( @; A0 G/ ?- Z
5 y* {# ^4 \2 k+ S! L* x$ M+ X
#include <asm/mach-types.h>
# `) Y. i. z' m" ?, L6 u#include <asm/mach/arch.h>
9 D4 z' `: }" k2 `$ u#include <mach/da8xx.h>( J8 m) H8 P I
#include <mach/mux.h>
' v6 H0 G8 J9 F/ f! `; y6 g( n
* _4 @* b w K* }5 ^ c- Q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* W6 W' R) Y' H
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
b. K2 D* r5 ?" d* p. v7 Q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 ?1 ?% [7 \3 c% C; p. X#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, B ~1 l" a* k# r4 d" f! h; p6 s
- ] |) n% h. _4 x9 s/* assign the tl som board LED-GPIOs*/
! D" C1 z' [* B9 M) j" Ystatic const short da850_evm_tl_user_led_pins[] = {
a* `. C+ a+ ?" z( D4 g /* These pins are definition at <mach/mux.h> file */
5 H4 p) ?5 b! Y DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 q( J' A0 w! j0 F, d7 k -1
D7 G& L; L$ ~ o};
3 l1 h2 V* [8 Q& T0 Y' `- O# b+ P, l7 Y, I6 Q6 T
static struct gpio_led da850_evm_tl_leds[] = {' w1 j1 l) u6 w; s& ^
{& O5 u; s; g9 N+ K. p
.active_low = 0,7 v" E* b2 a9 E; T1 E
.gpio = DA850_USER_LED0,
/ Q" s' h8 n0 @/ G .name = "user_led0",
8 A; A$ e* t) \, S; C5 o .default_trigger = "default-on",
) J- L5 w! t9 m; ~ },
4 b! W4 e% ?' W) ^. V {0 ?) H3 {) D* n" j$ g
.active_low = 0,
' y N5 j% W" w/ N .gpio = DA850_USER_LED1,; ^+ i4 }, Z4 Z/ s+ u
.name = "user_led1", V* f# ^! h$ ^ w0 O" ^, a
.default_trigger = "default-on",# v8 X8 n d/ m) u0 P; i; `
},
. B6 z4 x! q; `) ?( j( A {
, W. {4 h% c3 g2 b% x. ? .active_low = 0,
- e0 {# x" @9 H0 s* }8 P .gpio = DA850_USER_LED2,
, P# f: e# |9 H$ |$ ?! r2 i+ O" e .name = "user_led2",9 X6 ]$ W; ^$ R( ]9 B2 g- b
.default_trigger = "default-on",
+ [, r S i3 h },: j( k# C- D; R Q
{
3 h- e* o9 T" |5 q4 ^ .active_low = 0,5 r1 F Z* O& j E
.gpio = DA850_USER_LED3,
2 Z. x2 l0 K0 ] .name = "user_led3",
& W" w5 S' G0 X# i, Z- q' p! I .default_trigger = "default-on",
7 ^$ m# ?5 S/ V( c0 Q( J },
% P$ _4 K% H" E: R};4 G+ M7 i& S3 p
. G @ y. O$ r' J: H
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! X" c* |: f. \/ i4 N" T6 v5 V .leds = da850_evm_tl_leds,
3 A* x! Z! F' I+ q$ E5 h' s .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, _5 w7 c' I8 _};
' S9 |$ H9 I0 {7 q, `
3 z, H" `- M, Z9 p8 Rstatic void led_dev_release(struct device *dev)0 y: H( _) f& @; R' E4 @
{" {1 _+ [. |* b+ S) b
};0 D' J! y1 ]9 m$ F4 w8 I1 p
3 _, G+ `! R9 S9 wstatic struct platform_device da850_evm_tl_leds_device = {3 z4 U* k w- w6 U& j
.name = "leds-gpio",- Z# }1 X$ o/ j
.id = 1,3 m" R9 S: I* T9 Y% P
.dev = {. C; Z7 N' y, t0 J' D8 c; L1 N* L
.platform_data = &da850_evm_tl_leds_pdata,, ]2 O! X+ c' B: f8 _( ~0 v3 H4 Y
.release = led_dev_release,$ @ f: Y- a) L) ]! j
}+ j3 F. R8 Q& F" R8 G
};9 @1 Q0 A/ W$ ^8 W* s @
8 V+ N4 \/ F* X+ }' H
static int __init led_platform_init(void)
4 n) `2 R: {. Z{7 }7 ^; s! `- X
int ret;7 m1 T3 W7 V1 E7 k! S- ]
#if 01 r2 F' F3 w% Q, p) A; r/ \1 ~
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& y9 N$ z& g% D( P+ M/ Y
if (ret)* }- z8 ^# y$ D, b( [
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 P) o$ ]! J8 D* U- N* ?/ x5 z2 v
"%d\n", ret); s9 j0 r; a( N8 i. T) H: K
#endif2 u' f/ ^# b7 E
ret = platform_device_register(&da850_evm_tl_leds_device);0 b" y5 V3 y) Z2 R- m
if (ret)
, M* @# m& y' h: _; n6 J pr_warning("Could not register som GPIO expander LEDS");) Y9 G) h3 M1 O" r0 H1 |
else5 q, d1 @4 ~1 }4 m) Y
printk(KERN_INFO "LED register sucessful!\n");2 M: R# i& N$ d/ _+ c. K) P' E
# Q$ O& V4 l# d+ ~8 \3 F return ret;
# ]2 w+ C: q/ N2 K}3 ^9 G! \1 Q/ h$ I, s, y9 o4 V
; Q/ u' I; K$ B" m
static void __exit led_platform_exit(void)
0 o% L8 l p( u9 E8 j- v/ v{6 b/ G# t1 \+ V
platform_device_unregister(&da850_evm_tl_leds_device);
- l# m, e* E+ p: J r* [
8 [; V+ B& e1 m# H3 @% t& I2 v printk(KERN_INFO "LED unregister!\n");
" b& i% v! e6 E}
+ ]$ G# k# r5 X- D/ P3 e; `8 j; u9 D
module_init(led_platform_init);
2 ~1 D, \" {1 Rmodule_exit(led_platform_exit);% v* M" h9 V+ o. u& o# u4 _9 W
$ H+ N' q/ L2 s- ?
MODULE_DESCRIPTION("Led platform driver");0 F8 J" r9 l+ U
MODULE_AUTHOR("Tronlong");# F+ C, H5 {. K* q) ^( S
MODULE_LICENSE("GPL");
l" B3 u1 H# C" R# j* O7 s$ v5 z& L6 g5 E1 W! p H5 _/ x- L2 {
|
|