|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* P" M1 O4 w. H7 m0 b: L0 l
#include <linux/init.h>4 k. W9 q$ j& A
#include <linux/module.h>. b- q# O. w) v. p& x5 m
#include <linux/kernel.h>4 W' w# Y- ?; \8 \6 p( P
#include <linux/types.h># T: Z2 o1 ?5 O( |5 j5 S
#include <linux/gpio.h>: {- `0 W5 |3 B w
#include <linux/leds.h>1 {6 p! Z, {5 G) |
#include <linux/platform_device.h>9 t$ s9 K) h' s: a, v/ [ H$ ]& n
2 Z! A2 l0 A2 G3 `! }. p" Z#include <asm/mach-types.h>
" g- j7 X1 u4 r6 _#include <asm/mach/arch.h>" q" \. K2 T, I8 K( Q+ W
#include <mach/da8xx.h>2 B- z) W* x+ B/ Q9 T
#include <mach/mux.h>
# J6 u2 h& N% [. j6 J1 y1 b* R. W0 l4 h! d) K, Z% O( P
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 V* S" n! \7 G4 Y* j
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# t4 ~$ U, c, h d0 D3 g
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( x7 V: b) ~! F' t# k#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 Q1 |8 g0 t! k8 ^! s: s6 l
% h" a. W9 L% S* y
/* assign the tl som board LED-GPIOs*/
4 s' s$ a' J2 y1 D# ~static const short da850_evm_tl_user_led_pins[] = {+ g6 ]3 K. U3 @. k) l
/* These pins are definition at <mach/mux.h> file */' c1 F( Y; K( K/ o- b
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 f+ E9 x6 q# p7 }0 o9 a
-1& @; W* p+ y! I2 Z
};
0 U# d; Q! _ D% j' Y* I9 u$ k/ N7 \1 S
static struct gpio_led da850_evm_tl_leds[] = {
7 W" }+ |0 l7 g5 J( @4 ?2 ] {- {7 s4 W( F/ `# A |9 {
.active_low = 0,
K# s! F! M. u l' \* m6 T .gpio = DA850_USER_LED0,
+ z# g: g; n- D! N" f6 x3 J .name = "user_led0",/ j0 y$ r) _5 }& W
.default_trigger = "default-on",
7 g! ^! w, T% q( ?1 C0 b4 z" I },
6 b4 Q( M2 J+ ?/ a {$ X9 B; E' t" a4 O! Z
.active_low = 0,
; j! y7 K7 G2 _2 }8 f; F$ j1 n .gpio = DA850_USER_LED1,! d, g4 L+ T" H2 {
.name = "user_led1",9 V( g& M8 X+ d4 c$ @) {
.default_trigger = "default-on",
. K5 e5 b q# ]- |9 _: b },
# S' d- o- M' M( ~ { q- i: |' K; H/ w# a1 {
.active_low = 0,. U- g; g% q3 x4 p; j
.gpio = DA850_USER_LED2,8 _0 ]7 a2 X5 K7 Y {, N
.name = "user_led2",) A# c) M# K, f+ V; E2 a
.default_trigger = "default-on",5 P# b3 M5 B$ ?
},
6 p2 G+ o$ _, b$ b4 r/ }. L' Z" q$ B {$ Q. Y( e5 a5 U& `: j
.active_low = 0,
6 X4 H& o# r y, F7 [ .gpio = DA850_USER_LED3,' V; f$ @0 K: m Z2 H
.name = "user_led3",/ }8 m9 j7 v2 ^: Z S2 V
.default_trigger = "default-on"," f; M0 E! u, N7 U* }6 m* J
},
1 T: q% ]1 ^" w1 k. W ^};/ A' R4 z+ s6 r! H* n$ J
" `. ^7 c5 N# ]; wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. o* a& M$ b/ w- l7 q4 Z3 k { o .leds = da850_evm_tl_leds,+ y. ]" ?6 J% }- {) o# Q8 X% c
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 }0 G8 d7 S3 k: a: W+ F; }};! j1 {, }- Q3 m/ Q
4 u. E6 L. f7 Estatic void led_dev_release(struct device *dev)# y' A! [% o/ b) Y
{
. Q. x* N! v4 ~: i9 b};
, B1 ?) r) N( f2 K& M2 p- K
x/ g. j0 t" ~8 W2 Ostatic struct platform_device da850_evm_tl_leds_device = {- r% j8 Q1 L6 |3 H: w* a% p
.name = "leds-gpio",
- w# Y. d* z7 G/ F! a .id = 1,8 U5 v2 G8 Z: W, `: G# ^+ S
.dev = {) ?6 ~( g3 E. {5 Z
.platform_data = &da850_evm_tl_leds_pdata,# C. k' ]& L d
.release = led_dev_release,/ }) d% F/ c; u- R3 E
}
& j: Z B, v4 P. y7 g) b};
! ^% P* j# `' I7 q6 e/ ^& O1 D' ~% {, T! e# J
static int __init led_platform_init(void)4 r/ r9 o0 O0 t
{
8 l, z8 p8 T8 J) R4 D int ret;
1 l* s' D3 U- K( [' i2 f) Y7 C# j#if 0
* h6 q" l. p4 V+ U( k- T. Z( u8 F ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( @! I4 A8 @, k) J5 c/ ?, F8 H if (ret)/ T$ ?. V/ }. Q3 |( T. Z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* [' ^/ t0 I8 ^* K& b; r$ i
"%d\n", ret);
4 B E6 }# j) n#endif% e a( G! j1 _; D5 L( z
ret = platform_device_register(&da850_evm_tl_leds_device);8 K. G) i- |, A* [: H. j. R
if (ret)
/ |# ]( n2 j7 W2 v! M. k Z pr_warning("Could not register som GPIO expander LEDS");9 I; n# j6 |% c/ F) U
else. [! c, _) x: [* o: ~! `! }4 W6 f
printk(KERN_INFO "LED register sucessful!\n");
3 s7 k4 f }* {8 I( E9 D. a( o7 ]0 M! d! t* K* z# U+ K) x" r
return ret;( Q0 Y1 h! C+ S0 e
}
: w- \$ R5 S; c+ x) I- H6 E
% }# {$ X' l4 R" r' fstatic void __exit led_platform_exit(void)0 \1 G6 Q1 N! [0 Y
{( [# |6 C/ X9 u0 V- {
platform_device_unregister(&da850_evm_tl_leds_device);
, z7 t+ `, |- O0 q+ [$ t. v% ~
7 B ?' f* ~8 k* V, A, i printk(KERN_INFO "LED unregister!\n");( I# z: R+ o$ G: ^4 ]1 U
}, n8 G) C, ?" O& ^+ Y
* X5 w1 ], F6 e" s8 P' |! B$ `module_init(led_platform_init);" Z2 ~6 [% n$ W3 s! l% Y
module_exit(led_platform_exit);
& d) S" q+ E( e5 J& r4 f: t7 S
1 U9 `6 c) x* UMODULE_DESCRIPTION("Led platform driver");
' `) e' |, e8 d C0 W; ?MODULE_AUTHOR("Tronlong");
: q8 D |- N' \& ^ X% u9 \MODULE_LICENSE("GPL");5 G# Y/ B/ R A4 [
& _8 M- u# f9 _8 }8 e
|
|