|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% @' R2 G9 ^3 d#include <linux/init.h>
3 D1 I5 o' v/ K3 g: M3 v& ^" [1 n#include <linux/module.h>0 J; t! Y8 V& @
#include <linux/kernel.h>, [ K% L9 f3 j0 z2 M0 f- D! `- P" ^
#include <linux/types.h>
" ~; Y& V* q7 v" G. a9 J# M& I#include <linux/gpio.h>* ]" r& P8 {/ ^; V& H( I n
#include <linux/leds.h>
2 x3 Q" {9 A1 Y/ T- D#include <linux/platform_device.h>
, x; L" D- [% a8 z2 o
1 o E+ b X' ]#include <asm/mach-types.h>
! r5 s* b# n* ]" b. S# \#include <asm/mach/arch.h>
3 w2 P7 A/ G/ J" V1 G9 u# Q' o#include <mach/da8xx.h>$ w4 w! M& y# C; R& p7 u9 d9 M
#include <mach/mux.h>
$ @$ o! Z( a- m# V% y1 ^" k. [% R! V" }. V" K6 |0 o' P% O
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 a* M1 ^' }4 x2 f#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# P, F6 w4 l* F8 Q6 y. t
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ v+ ~: J: I% G/ e6 H; H#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 O7 ?% v& K/ I- v" V8 L* l, V: e5 H* G' H: J9 {6 W$ H
/* assign the tl som board LED-GPIOs*/& d7 y' J6 e# H( j6 c- M8 {) P
static const short da850_evm_tl_user_led_pins[] = {
1 d9 q& r$ m/ \, }; C) w3 L: X /* These pins are definition at <mach/mux.h> file */, {& W6 _( @( s: l2 n. @+ x8 e
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% J5 y' |" w a; D3 Y9 t( w& { -18 [5 b" G; m1 U4 K% v
}; \3 s: L, p. t" ~. q! m. |
( ^- {7 M, @% Y* U, V0 Tstatic struct gpio_led da850_evm_tl_leds[] = {- m5 ^! N5 j/ v: K6 w5 M% l
{, s# s0 J, h* T) I% M2 W
.active_low = 0,( X; ~& G7 g5 X0 o. |0 l
.gpio = DA850_USER_LED0,
+ v+ P0 E0 j8 B2 |5 W6 Z .name = "user_led0",6 k' k! D# _$ m% ~) y I
.default_trigger = "default-on",: \% q7 v4 C0 i- G
},1 s; I. J+ y3 {% B7 |$ s
{
; {4 x( m! R/ j/ t/ U% s) ?) m! d1 r .active_low = 0,0 I5 \9 _+ C* L
.gpio = DA850_USER_LED1,
4 N) A( \4 N6 \- R0 i- [2 {3 u! } .name = "user_led1",
9 p g+ i0 r9 Y! L4 f .default_trigger = "default-on",
, p8 k: o6 D; t" D) ^# ^ },1 O2 ~1 {- \7 y( S) G
{
. U% V8 Z/ D8 p .active_low = 0,' `0 V' |4 z& R5 ~& u0 [' N% P
.gpio = DA850_USER_LED2,
5 w5 p$ S+ g- v$ x2 ~/ @& `5 s' K$ l .name = "user_led2",
D+ d# F. e" J1 a+ h .default_trigger = "default-on",
1 |) t' k/ N5 ?) P },
/ e! I2 c8 p8 c) f {' N; _1 S1 Q9 p' O' {* |: q2 W
.active_low = 0,6 C9 U+ O' N; {+ k& G# H
.gpio = DA850_USER_LED3,
+ ~: M0 `2 B, V0 H7 ^5 y .name = "user_led3"," q/ ~' S$ _& d* `
.default_trigger = "default-on",# }; D/ T1 h G% G" _0 V2 Y
},
% D0 B! H1 v) d2 ~6 {8 ~. P};8 M3 y! A3 L7 J- m8 D/ ~
& i) s$ Y% s& G6 F. p
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 k$ Z7 F5 m! e4 ]2 V' w9 n2 k .leds = da850_evm_tl_leds,
3 J) q+ Y6 G& S, E7 J .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 F2 e% S# r" [! S};
$ L4 K. I1 G* T
. ?2 }0 P+ t, v6 D0 ostatic void led_dev_release(struct device *dev)
0 t( J' }& }$ M- u/ q{" n( g Y- K; q+ t c/ a
};
7 Z' O7 e+ Z3 }/ J {% F- I
- W, ^$ S: l, r3 n7 Jstatic struct platform_device da850_evm_tl_leds_device = {
& L. d6 t/ k' l8 R .name = "leds-gpio",; G& B0 l2 k. k5 P" h# a1 N. @4 I
.id = 1,
3 ?% {1 b: s8 Q0 ` .dev = {
4 U! m+ ?# s" ^7 D' z5 E- O .platform_data = &da850_evm_tl_leds_pdata,
6 p# C8 I' b5 ~* r, h$ X' J" v& \ .release = led_dev_release,
& G; h& m2 _" G. F }8 [7 ?3 L$ B# Q. M
};
( U. Y2 x1 S" ?! ?4 b5 O! H9 J+ p/ L c9 Z) y
static int __init led_platform_init(void)( N7 y* H( D7 C( ?7 W
{9 P7 }: H( Y8 O/ N7 z. P2 H _
int ret;
# I* F2 w' \5 P, L( D& y+ T! @#if 03 W. U9 b% @7 h" h/ R: |. ^
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, F/ B+ l/ W. K& h0 W; E4 b: S# f
if (ret)
8 U( @: L, f% y6 S6 _ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; G7 H9 z) O% o5 A5 u "%d\n", ret);
; B. O% k4 U# r5 |. t# j#endif$ e7 O& k! _& V
ret = platform_device_register(&da850_evm_tl_leds_device);9 @2 P/ J2 b3 |, }' B
if (ret)2 b8 w. \( U( b
pr_warning("Could not register som GPIO expander LEDS");) N9 V0 e K1 v' R
else( i; b+ ?! _% F% |& W
printk(KERN_INFO "LED register sucessful!\n");! [3 }3 O6 w! {6 l5 H4 F
6 F2 @6 j! N+ _( A4 ] return ret;
+ m& I5 M8 W! v: \}1 ?" l$ _& g3 Z! Q! O$ M6 A
9 P: X" x* n. w% n+ x* `& I K/ Lstatic void __exit led_platform_exit(void)
. z" E$ M: M0 K% {{, `2 ^# k/ p! x U6 I
platform_device_unregister(&da850_evm_tl_leds_device);
4 ]& C0 ^; `* l6 A( A1 a2 [4 @8 w6 k, q% M$ x0 W
printk(KERN_INFO "LED unregister!\n");
, [2 o( c8 P+ [' i5 ~}
& h$ J, K" U4 b3 D a% C& X- d1 V
module_init(led_platform_init);
* v& t2 O$ Q" Y5 H/ dmodule_exit(led_platform_exit);$ i4 L7 d# S$ I: H m
4 h8 y7 ~5 q% q. \3 ~MODULE_DESCRIPTION("Led platform driver");
, u: Q. `, X9 c/ V! cMODULE_AUTHOR("Tronlong");2 h' y2 S% l; u. n4 W
MODULE_LICENSE("GPL");
0 X5 q6 a" g& h4 s O& ~) {( X2 j5 O# K4 U$ Q
|
|