|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ S `! r9 m0 k0 I, X
#include <linux/init.h> y' _& l2 {! }- \8 x) O
#include <linux/module.h>
2 d6 ?* G2 t3 x$ i; u#include <linux/kernel.h>. \0 }5 K1 `- e2 O) c0 u9 H
#include <linux/types.h>
) c0 Y( A3 }) B$ m! x) Z9 N#include <linux/gpio.h>
8 s% H. H( _ Z4 n9 A9 r#include <linux/leds.h> V2 {& @- U. p# X
#include <linux/platform_device.h>
9 K. T T @7 O1 W* U6 z6 f% i9 r, i8 z" K2 S6 f/ K
#include <asm/mach-types.h>2 }# x' X) T$ v* r4 W
#include <asm/mach/arch.h>
0 P9 v2 [. w1 b) w4 L2 s/ R#include <mach/da8xx.h> W. X, V8 R. L1 d
#include <mach/mux.h>7 [6 I7 v) o; K& w; Z4 Z3 g
7 m8 x+ U: ^. q7 a- M+ ?#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 O, N9 F0 b0 Y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 k% Z3 y, E( A+ P: d V2 D$ H#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 H# l* c8 X z/ z& p& F' O
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 | W6 B% |1 v( t5 p9 o
( \3 q% @+ j% B' P( F/* assign the tl som board LED-GPIOs*/
; t/ O p1 ` g; istatic const short da850_evm_tl_user_led_pins[] = {
3 V1 S3 e/ C: F, X, z /* These pins are definition at <mach/mux.h> file */5 C; V' M, C( j) B7 |! e
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 V0 N6 [; i7 B
-1
& ]2 F. M: i7 F. Z e7 _};; z% S p7 e/ }: F2 b$ U
5 s b L. {, q& H
static struct gpio_led da850_evm_tl_leds[] = {
: C7 Z' p! j$ E7 B+ G4 ? {( o* z3 d0 s" T& | q# Z* |
.active_low = 0,
) c! p0 e/ X6 U .gpio = DA850_USER_LED0,
6 q* `$ c0 Z. `7 }5 X, i9 b .name = "user_led0",
( R' K9 D6 q3 x; |7 c7 U9 e. `2 L) [ .default_trigger = "default-on",! X8 {& y' F1 y, b; ]8 C
},% O v% q9 ]6 k4 ^% Y$ O( _/ T8 o
{
+ D9 q! w9 O, S2 ^# ~" f .active_low = 0,- Q' H, [& Z- t8 f4 S
.gpio = DA850_USER_LED1,
; h) d8 X: J5 G .name = "user_led1", ]* X) o$ v% w- A& U1 e
.default_trigger = "default-on",# V Y" x- @3 F0 J7 E
},
; t/ h" @* s4 h9 F {9 t( b3 j' |! J5 {& P
.active_low = 0,( ^ R: A& I! x. C g1 ]. c9 _
.gpio = DA850_USER_LED2,
% w1 `( T0 i) i1 N .name = "user_led2",
) }3 T1 x. [& C8 w/ P$ Y& ^ .default_trigger = "default-on",
/ R! }! u9 J T/ C2 N },- i" ~# t. J' r7 u6 v8 ?
{
. _2 l* G* X) W+ }+ m. n .active_low = 0,* t! H( V) V4 M5 ]% Z1 B- D# J- l
.gpio = DA850_USER_LED3,2 ^5 r& W$ C, E
.name = "user_led3",; I9 J, J4 Y6 a
.default_trigger = "default-on",
! D9 Z4 j" w; R9 W- Y* p1 Y },* W7 \, U4 S& D: A# b. O
};
% w. o$ _" @9 [' r/ k8 v5 p6 L/ _" w
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 H7 {+ C2 B- h/ U n. f8 ~* X .leds = da850_evm_tl_leds,- N/ t3 a# x$ q! v- d) s" T
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 j/ c. @9 z" M# c+ W};! o& X. x! \' R# y" N' ~
( {" g9 v0 u( M4 @" ostatic void led_dev_release(struct device *dev)
4 q* v) U1 o( |. E0 V{7 F- o- I3 v) m
};9 `! z/ Q( r( ?3 B: J9 `9 v# z
* H8 U0 W7 ^9 ~
static struct platform_device da850_evm_tl_leds_device = {' `" x, ~, i- o
.name = "leds-gpio",; e' I5 I' l. G1 {; _' t4 D
.id = 1,1 h I' T/ j/ d' y( ^
.dev = {
; U! o1 q5 W6 J7 ? .platform_data = &da850_evm_tl_leds_pdata,
! c' d: C( `/ { .release = led_dev_release,
& P0 |3 q) `0 M/ l }: ~! J2 j4 s: q; i
};
0 C. M: {: l2 N1 t$ d% P3 s* C1 V. V9 W2 Z) X; H
static int __init led_platform_init(void)
9 X) N8 B# @$ \3 U+ y, L5 H1 \+ d{
6 T2 {/ u4 ~8 N5 i5 q- u int ret;
/ }- t, x5 f- W7 r# u( E7 q#if 0" \& i" Q. K) {8 Q6 W2 q- \
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); ^+ ], O) e5 \) m
if (ret)) T2 A @) M# z+ A! b
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 ~ d+ m( z- g. X: k "%d\n", ret);
2 y7 k8 Z3 n: O: x* e4 t5 {#endif N8 O ]# s8 x5 b k5 L/ ]) A
ret = platform_device_register(&da850_evm_tl_leds_device);4 s+ X0 @) ^& z1 Y
if (ret): x% v% [- G/ H, j) ^9 A. I
pr_warning("Could not register som GPIO expander LEDS");
( ^8 V2 ]0 ~8 z0 l: i else
8 t( f) q! M* l: t4 a% V3 T/ j printk(KERN_INFO "LED register sucessful!\n");
K; [2 k3 l/ H" u$ `; [
$ z! c# h) Z4 T return ret;
F8 G% i r$ P% Y7 j8 g2 V! r$ u}0 s- f" ~0 |! o% q( f2 P
7 w5 e& z: o" i7 R3 Z' Nstatic void __exit led_platform_exit(void)
7 X6 p4 h' t3 W# j, D3 |{
9 L" E4 J4 f8 e, p H& G% p# y platform_device_unregister(&da850_evm_tl_leds_device);- V3 x3 b; E2 X I; Q
1 ~9 z) d% L7 Z3 v printk(KERN_INFO "LED unregister!\n");6 |6 Z( U H P' y2 j2 \# j7 G
}
2 h. K) B8 @ @+ B& i9 v9 V G* K
( g4 t7 K4 U; {- rmodule_init(led_platform_init);
% h$ R) h1 r+ |* Pmodule_exit(led_platform_exit);
, |/ W. l) Q. g4 m# j5 z* P( ~' f) _# ~) j0 c' Z* k
MODULE_DESCRIPTION("Led platform driver");) H/ S' H. F4 D' y1 y
MODULE_AUTHOR("Tronlong");& L4 u5 v; f- c2 [
MODULE_LICENSE("GPL");3 T' ]( T2 Y! u, k2 `
8 A* s' n+ ]8 j1 I! C
|
|