|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 c! A# K- \) g8 s" |
#include <linux/init.h>
! j8 `9 e& Y2 i7 J#include <linux/module.h> c( ^3 J6 O E7 V: Q3 k
#include <linux/kernel.h>
0 H0 C- g6 q+ L( u. s# q* F0 ?+ `#include <linux/types.h>; b# L8 n. O* d$ X7 r* M9 f/ x
#include <linux/gpio.h>
- O# A4 O) z) p$ B q/ X#include <linux/leds.h>4 ?8 @9 i0 t' c B
#include <linux/platform_device.h>
7 ^+ ?% N. @1 \# Z2 {0 \, O) n' @4 ~& _/ c L; ? S$ s; _
#include <asm/mach-types.h>, \( S/ p$ p1 i
#include <asm/mach/arch.h>
8 D6 C$ l3 L) E3 \#include <mach/da8xx.h>2 ^2 H7 r. Z8 D6 E4 X5 f# l% ^: E
#include <mach/mux.h>9 g- X3 ~ A) ?: a7 v; `1 \
' E- J6 k- n9 ^( Y- ?#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& ]' [9 O6 W$ Q6 c
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* V$ ^1 O ]" z$ v. e+ F#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 K. |2 k1 |6 _2 H8 t#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% U: F. W/ t' r: U% `# q
l: [4 ]& u3 D! |
/* assign the tl som board LED-GPIOs*/
2 o3 Z- h5 N9 Rstatic const short da850_evm_tl_user_led_pins[] = {
5 v( H, |: P4 ]+ t; d /* These pins are definition at <mach/mux.h> file */
! _9 {* j1 w# k; z m7 | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 A, C2 u3 U' h- q& {
-1% h: w2 X/ A' E' I# _7 U
};
. X0 N% y! k6 ?) T/ k0 F. ^/ X- t. r
static struct gpio_led da850_evm_tl_leds[] = {
. w/ P& ~; X5 p8 T {
. L4 V. i+ B) T! a T9 u .active_low = 0,
7 q1 H- S3 k+ H, i/ p! Y .gpio = DA850_USER_LED0,
/ D! S$ e7 G& W( J; a1 Y .name = "user_led0",
& R B, T: q( p6 D6 C9 K .default_trigger = "default-on",' f9 q2 Y/ s3 p: v& t) K
},
X8 B5 M, R& s" b3 ` {
' [& [! r) W F1 @) X' i% z( W .active_low = 0,
1 D' T: q6 a1 H, }0 {$ o .gpio = DA850_USER_LED1,
/ w/ O: g2 c) h: \( r: f .name = "user_led1",
' k( w+ Z- O) g9 }' ^3 A. k0 d .default_trigger = "default-on",
: u7 l8 q$ D1 r8 ~2 m T4 A3 t },
$ D$ ^2 S# _' F6 D* i {' U! I8 F1 s5 Z6 t' E
.active_low = 0,3 y }: F4 ]5 x% T5 J+ N7 D
.gpio = DA850_USER_LED2,3 S* v, o; @% H
.name = "user_led2",+ Z! c4 S6 N0 h1 S& X, A7 d% \
.default_trigger = "default-on",
0 u/ C# R8 M: { },- y* ?0 {& M# f7 Z! Z/ B9 H1 B, E# J
{
9 q9 `% w* w4 M1 T$ f .active_low = 0,
0 C5 g+ B4 u# A9 l; F .gpio = DA850_USER_LED3,/ n d' ~: U$ W2 H1 V
.name = "user_led3",0 @5 h5 r% K; D& p
.default_trigger = "default-on",' b9 H+ I( x: X/ g% e5 j! D+ n
},4 X* _3 W! J7 g: V# e( ?5 X- z
};
$ r8 g2 m2 g/ r+ M( Z4 g# B# h3 w+ B0 S. T
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) j8 I/ N7 Z9 W6 K6 n& y, | .leds = da850_evm_tl_leds,
0 l. E( M! g' i .num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 b i) R" p/ p: r# u" ~/ R
};
. C4 o3 K; D, R* d1 X [2 z- }* ^/ y- L& L) d7 p% |: ]. |. A
static void led_dev_release(struct device *dev)+ N% P: L: u3 k& P
{$ B! l, _* u+ Q" S
};
4 g0 u" d5 l# y7 b" M0 ]0 l4 o1 h; `7 v" j# _/ b/ \2 r
static struct platform_device da850_evm_tl_leds_device = {
9 B0 {* s+ w$ z .name = "leds-gpio",+ H. H$ u& \/ c2 c$ t
.id = 1,. b" {4 D/ R1 h) Q: P4 ~
.dev = {
* h& O2 l/ K: S9 A* F .platform_data = &da850_evm_tl_leds_pdata,
$ _8 d! m' U) L G7 q/ J .release = led_dev_release,
' ]' j# R+ J: c+ y }/ D6 }+ G6 y2 T6 U0 C1 T y
};
9 f4 b) V; _+ z% E/ u% R. n7 {& P7 ?. e: J4 x7 |
static int __init led_platform_init(void)
/ K6 Z8 B) ?) b3 e$ s! y{
0 ]: i9 x: \3 Q Y+ D% [ o& L4 K int ret;
+ r# X' A8 C6 m) p5 |0 k) _8 Z* ^0 L. f#if 0: o1 j. }3 t x" `/ `; i- U
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- {- I4 c2 L" r0 B, w# b) Z" j P
if (ret)
/ o. b. W1 F7 t8 N1 E pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& n1 k) t+ g8 f' Y) Y; h% i: y
"%d\n", ret);! B1 w; G- l& z# v/ `
#endif% x6 u1 v8 R0 B; S3 U
ret = platform_device_register(&da850_evm_tl_leds_device);
- e- K3 C1 B1 O! D8 M if (ret)
; {) J |! K3 G' @2 B6 H pr_warning("Could not register som GPIO expander LEDS");* W' Z2 D4 n7 y% F+ g5 Y, \% S
else
# ?0 {/ }- ^5 {4 Z/ K4 T1 W printk(KERN_INFO "LED register sucessful!\n");0 x) K% Q0 l$ G1 _3 ~% ` m
& U- \ `' l# _' z3 C7 k) j Q
return ret;
% e1 ]; A7 D2 `}
3 X* C4 p# Y* `# @3 X+ X) ~! ?6 [; x D7 L2 H- O
static void __exit led_platform_exit(void)* r1 t. d: C& e" |9 k% ]6 j
{
7 a9 D' b, P4 w8 I: f8 R platform_device_unregister(&da850_evm_tl_leds_device);# W; ~ Z! o4 ]/ k
) {) t; v3 `4 V7 h6 y" S
printk(KERN_INFO "LED unregister!\n");
# j$ h( E5 X- G' e}" w2 b7 @6 Y$ T7 F1 P
1 T" B" ^. c$ T1 U7 N ?module_init(led_platform_init);- T9 a: d' V2 v/ T
module_exit(led_platform_exit);3 I. O$ E8 C% f8 s' q9 a* c h; x. h
5 y4 ^* _1 ^7 X3 n) w
MODULE_DESCRIPTION("Led platform driver");1 I, _" J8 l9 [
MODULE_AUTHOR("Tronlong");
% Y( J' J9 W! i- [! iMODULE_LICENSE("GPL"); m% z9 ~+ ?: W+ q9 z9 D1 O
* u$ s! z; L, @+ \2 @- e
|
|