|
求大神给下面的程序做注解,请稍详细些,谢谢。
& K, S& v" S' m3 r#include <linux/init.h>
! V: z2 B Q7 }+ \# F. ^#include <linux/module.h>6 z2 r" o$ I2 {' F" I9 S/ f
#include <linux/kernel.h>& e1 i8 R3 J/ ~: H4 M
#include <linux/types.h>+ B5 i# p, S6 A& B, e
#include <linux/gpio.h>
' O8 h" D. _' x1 ]% J& j#include <linux/leds.h>; S8 S( }+ Y: x8 X5 j' W
#include <linux/platform_device.h>
2 `2 s# `6 \2 p( \. }, `1 C& t0 U6 n' n: ]: ]
#include <asm/mach-types.h>. ]: ^5 K" `6 y
#include <asm/mach/arch.h>
# O# _/ m5 b6 V+ d; N#include <mach/da8xx.h>5 O5 S% u7 D7 Z/ T9 j( P" T
#include <mach/mux.h>9 G B \! p) c R$ D
+ ]/ w# A! w0 E" F1 \
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* ?3 Z! B2 w# Q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ v( Y3 [0 a9 k/ ^' }* |" L#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# q+ d$ b2 j" x# L#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 \, _* C. Y2 p! ^: m! ? Y0 q) ^/ ^3 y. z1 E: c3 t X9 G
/* assign the tl som board LED-GPIOs*/. `- Y6 D; t3 Y2 i1 a& {
static const short da850_evm_tl_user_led_pins[] = {
8 L! p7 _6 o$ m: u- ^ /* These pins are definition at <mach/mux.h> file */
' I" s) B( z( Z ]* Q, _. F) e DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; n4 W& I1 N6 s% h
-1
" E4 M! ]5 D# K/ y: X2 d, @) M};
c- z' Z2 ]) ^0 M- N/ A
N( P* }; ?! V4 j3 v# u1 O# Q2 ystatic struct gpio_led da850_evm_tl_leds[] = {' \0 a' ]% V3 F3 ~: G
{
) g$ C* f ~! _# z* M .active_low = 0,
+ ?( d$ l: H4 D5 a0 Z .gpio = DA850_USER_LED0,! d! S1 O2 d& E
.name = "user_led0",
1 W$ A6 A, @ }- v E .default_trigger = "default-on",2 L& s3 @' A$ d) [% n* I' N
}, J1 b6 O5 q! {4 I" Q7 I
{, X' N7 s0 M+ N3 L: K
.active_low = 0,
4 _3 v# X ~' }' |4 \/ e; d% ] .gpio = DA850_USER_LED1,1 }, }# R9 M/ F+ \. T c+ M
.name = "user_led1",% i8 c7 f+ m4 j* h
.default_trigger = "default-on",
# w, \/ n" p6 ~* l/ g4 T },
% z, b+ z& x" R& j {/ s4 A# e6 f* A7 ~
.active_low = 0,
6 W8 A6 k- G, y/ a5 F+ R3 L& e6 @1 q6 A .gpio = DA850_USER_LED2,* Q( U6 J. P: L6 ~' s0 u
.name = "user_led2",
2 ]6 \5 U+ r! q7 c .default_trigger = "default-on",
' ?- H4 q, J2 l& f },5 O' U: L u2 q) x( O
{
( N0 b& q6 L& E .active_low = 0,2 [& z2 s4 g: B) `, q6 C
.gpio = DA850_USER_LED3,! v7 P* A% q7 |5 R; I, @6 z+ `* j$ l
.name = "user_led3",
& c2 E P! p) o* [1 K .default_trigger = "default-on",# `% r- _2 | {# B9 `& i' X4 p: _
},
1 y! v: x$ b4 I4 @};% N! y+ z* u3 k5 f3 h7 x
$ L8 N, ?! j/ ?" L& M3 j2 y' k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- e2 X" {- c: c) X4 D' t. ?
.leds = da850_evm_tl_leds,
! N3 H- Q& r) f6 g% t3 h3 }: l .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! Z' ~9 x2 P! p) O};
5 D; P# r# \0 {) V5 R- u
: y9 `5 W5 j' i& wstatic void led_dev_release(struct device *dev)1 M) z! m0 H9 m7 h# B p
{
) U' t4 x5 g7 L7 e# c/ j& k};+ `8 f7 T0 _ ^. d+ Z
. r3 \9 F1 S3 w9 c
static struct platform_device da850_evm_tl_leds_device = {
" m1 L1 j) T8 \ .name = "leds-gpio",
" Q: L. z( W$ n$ |8 t8 _& s .id = 1,4 F+ u7 S, a: @0 s+ N) i. b
.dev = {$ z$ N* Z0 p' n! C1 U) W2 @
.platform_data = &da850_evm_tl_leds_pdata,3 R3 e7 _# c) W4 ^
.release = led_dev_release,
. y! |+ x2 d% o6 r } _ W/ _# h' d
};" F- W( W1 J& Z9 w1 k
6 n: q% z, g2 Q) S7 D0 f+ {% J6 Lstatic int __init led_platform_init(void)
& K2 J3 x" u [3 m/ l( q0 {{
1 e: k) `7 b/ ^ int ret;" i# \8 N4 \2 Z# q w8 m; }! m
#if 0
5 b5 s2 H$ o. Y) E& _ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ x5 }4 m5 E& o }
if (ret)
E* U. |0 e U pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 [: q% `6 O# Q3 g5 N8 u d "%d\n", ret);# I& g \% l3 o4 _6 j4 j
#endif5 Y" @* j4 d: @
ret = platform_device_register(&da850_evm_tl_leds_device);
1 ^0 X; P0 |8 J0 E! m2 a if (ret)9 f4 Q& g7 _) c# K
pr_warning("Could not register som GPIO expander LEDS"); m* A, e f' n' [. E
else) y/ B. f! U7 O- ^' b! K
printk(KERN_INFO "LED register sucessful!\n");& v0 S& o8 i$ h: p
+ |9 N3 T; o v8 T2 V$ d# L" {+ P* V return ret;
! q8 n9 D# R+ X5 s3 ^+ }1 F2 P}- u; f5 x0 f, f; b* g9 n$ x
1 f1 }) x, {, d& }$ z
static void __exit led_platform_exit(void). J1 N2 E4 W' l( N7 r# ^
{
! T3 S5 ^# |8 c9 O8 Q2 S platform_device_unregister(&da850_evm_tl_leds_device);, c$ h# R) ]8 A" c* o7 K' e
6 o. R2 h7 N5 ^0 y% U2 ?
printk(KERN_INFO "LED unregister!\n");5 I# |! W0 x$ a% g ]: S, E! c9 _
}1 K) D. v+ K4 X3 w# \2 J7 O
; ~! n/ I2 X1 _0 O3 ?8 s/ l1 Dmodule_init(led_platform_init);$ n' J; i) L6 C; M# v+ M
module_exit(led_platform_exit);
: L4 ]9 d1 K! _/ u9 f' d' V7 ~
7 C4 h7 h5 z8 v5 ]MODULE_DESCRIPTION("Led platform driver");
7 \3 @* s' L; A9 O$ b- o w4 L; \MODULE_AUTHOR("Tronlong");
& M! W5 N* }: m4 y5 O5 h* i* I! fMODULE_LICENSE("GPL");* G" K$ d4 |7 Z0 d& l
+ Z; L) O7 d: B; e6 I |
|