|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- I* n( @7 F6 ^" p
#include <linux/init.h>, m& W9 y$ D# z
#include <linux/module.h>$ ]' C$ T3 Q' b6 o. ~' q8 c
#include <linux/kernel.h>
0 {% A2 l# I& @: b#include <linux/types.h>
2 L$ ~6 X* J# E j* t#include <linux/gpio.h>2 q; m8 m" x7 E" C
#include <linux/leds.h>
; c: c& A0 I; u( p) Z: h1 d% N: B#include <linux/platform_device.h>9 ~% ?) [9 }$ G, |$ g. f! Q, N
$ l i4 f8 d! V* y2 U' j
#include <asm/mach-types.h>% p# E6 C, B; j2 {: a9 `' q5 e
#include <asm/mach/arch.h>
; I9 x/ h( w2 ^#include <mach/da8xx.h>9 a! U: U' H W' T
#include <mach/mux.h>
1 ?" g3 H- p) b' l8 S
8 J2 B- k* | J8 U( J#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 s! G+ U1 ?# T M/ c- F! s
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' [+ I& s v0 f' |#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: F' n6 Q6 h6 o/ E0 C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ L' p, N. ~. l* y; ^
6 M; R3 n$ `* b- E, [4 G7 Y8 u
/* assign the tl som board LED-GPIOs*/. U4 K' B3 l3 x
static const short da850_evm_tl_user_led_pins[] = {4 ~: l" L( J4 s% d9 k) j
/* These pins are definition at <mach/mux.h> file */
& V9 K9 D, J, }7 Q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ U6 d7 S/ a U. ]$ I3 z- G3 a
-1" d Z, @$ Q+ r! @ w u
};
# u! r8 I/ e+ k) }2 p1 {( w5 B+ y. f2 P% g
static struct gpio_led da850_evm_tl_leds[] = {
, Z/ s/ T+ e0 z( _ {) L6 b% u% d8 s0 @4 E- H. Q
.active_low = 0,
; d2 W# |$ a* t7 c+ Z" _4 @ .gpio = DA850_USER_LED0,
* H& u, F/ k3 J2 ] C( S: b. K+ t .name = "user_led0",1 w, h+ H2 O& q9 j+ j6 Y5 T' g. G
.default_trigger = "default-on",# B" M9 C7 r" p5 m! j
},+ X2 k# N7 M% B1 v
{7 p! v. z& u: {9 `: V, r
.active_low = 0,% K: K' s6 W$ a4 k! A. ^1 Z
.gpio = DA850_USER_LED1,1 [$ X9 U ?) D- J4 ~9 X3 D6 M" @# Q- x, e
.name = "user_led1",
5 L- c9 Z6 I, w( Y5 y {4 ^' g .default_trigger = "default-on",2 _/ a+ _# Q/ b
},# y7 D6 ]1 U. T# O$ P& W% `
{
+ v% G+ I6 b8 L$ F .active_low = 0,4 n4 o* R0 ]4 l
.gpio = DA850_USER_LED2,7 ] D3 y$ t4 {( `
.name = "user_led2",: G' ?$ \' Q9 x2 Y f. T
.default_trigger = "default-on",( w% t# Y* ^+ }% F4 |$ k
},2 ]" p5 e$ M5 ?7 T/ K6 L
{
( m1 I- ~: R" ^2 _- k .active_low = 0,* p; V J6 Y# d/ G
.gpio = DA850_USER_LED3,
; z$ y& q/ \+ Z .name = "user_led3",4 `# Q4 R) q1 @& H
.default_trigger = "default-on",
- a: Y7 o3 c$ {/ F' {+ I/ c2 b },
+ p8 y' f, J* U: |};% a+ U9 }$ {& e& }3 M) V# o3 o+ _$ r& ^: H
4 a* |8 ~7 ^; O1 H
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& W! R( r$ E" W; A+ a: l; ? .leds = da850_evm_tl_leds,6 g$ J9 P$ _3 p) F i; B
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 ?# D0 L" D; F};: @5 R2 o, F: E3 w# ^: w
8 c# d( g& ~) I3 v3 `
static void led_dev_release(struct device *dev)
3 k8 Y+ c {) C4 B0 `6 A{9 x$ ]) w# Y% i5 z0 `* { W
};
+ k# z' g" w6 H
3 |3 B' i5 m: R( G; dstatic struct platform_device da850_evm_tl_leds_device = {
5 G p) a. L& P' g% U5 ~ .name = "leds-gpio",: e" B+ }* O* @6 }
.id = 1,3 Z) _' ?0 g# ^/ R! v4 ^& n
.dev = {
" |9 s5 {# ^! D) ^/ P .platform_data = &da850_evm_tl_leds_pdata,
2 N: c6 y K! U+ G' ?4 y .release = led_dev_release,
/ R+ E. {0 U- o8 i8 |3 @* W }
, E$ u$ P0 D5 I0 X9 O};3 ]4 b: s6 ]2 e0 P o
Y' b+ r) ~( t+ `: @* C4 v8 ostatic int __init led_platform_init(void) b( ~( Q0 n4 n4 q0 I" H1 u& k, |1 o
{ i' t) |: T$ L6 h" q, f
int ret;1 f2 `3 H1 A+ f+ N5 P: ^" [# W) l
#if 0
' x/ {; [# e5 G* J: X, { ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' I8 v) v! E @2 h9 ^
if (ret) P# H4 n0 b2 c+ c. P
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 l# ~6 q3 c9 g; z5 K
"%d\n", ret);
* E1 h" M3 Y; ?2 k- Q" y#endif
8 y. W% T- t1 X C* x ret = platform_device_register(&da850_evm_tl_leds_device);3 J, i! z3 x0 |
if (ret)
5 Z$ y4 `( f" U: [( @! ^0 j pr_warning("Could not register som GPIO expander LEDS");
7 ]. y* o* _% | else0 q# e5 _& ~% V% V0 k) U- k. Y
printk(KERN_INFO "LED register sucessful!\n");7 Y$ h8 q7 E0 E s, d9 c$ y- p$ P
- {' ?* ^5 S. e/ \, I! c0 x+ }
return ret;, `3 O V& c u" _
}
% j) r# @0 d2 z2 y1 o: Q/ {2 R2 [; b. I* @, r9 ^+ g& r) f% Z
static void __exit led_platform_exit(void)
$ q/ w5 H1 D) a{9 |8 M0 \+ }. V! j4 t% ^9 `. k
platform_device_unregister(&da850_evm_tl_leds_device);9 q& b) m! u9 ~9 @! u- w
1 ^' ^! P2 u2 Q) Y printk(KERN_INFO "LED unregister!\n");
# H6 r {2 p. u3 C5 P8 }7 j( u}' t- z. G) `# H
- d$ ^ [4 h* T( q8 `8 f- j" X2 @6 n
module_init(led_platform_init);$ e, ^4 o% r( ^' `* Y9 ?
module_exit(led_platform_exit); Z7 j2 m$ G" u8 }. W+ e
% H$ M6 @6 E* e. [, o6 y) z
MODULE_DESCRIPTION("Led platform driver");# \% q4 X) x8 }; G0 X
MODULE_AUTHOR("Tronlong");# j# ~7 ^6 m0 R2 m; }/ c
MODULE_LICENSE("GPL");
, z) b q4 r6 w+ D) |5 Q4 K3 {! l/ \# Q# [
|
|