|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* K( w. F7 U. Q# w) K3 h% B* L9 f#include <linux/init.h>
1 n0 J+ t, d, R* w#include <linux/module.h>
4 @" A0 j- @, T: b#include <linux/kernel.h>" @2 |1 U" m3 r+ h# c8 I* i
#include <linux/types.h>
. g; c9 t, i c# \' I, e8 u2 c3 h#include <linux/gpio.h>
, ~# @6 o3 ?. k% C#include <linux/leds.h>2 \9 |( Q/ Y+ E+ u
#include <linux/platform_device.h>6 f. t/ ~. }8 X: v! [" k. t, @, C
7 U n+ V* w2 U( p: y
#include <asm/mach-types.h>- K: A6 G2 b i+ e
#include <asm/mach/arch.h>0 I6 Z5 M7 i& L9 K
#include <mach/da8xx.h>0 l3 b# C. }6 B. P
#include <mach/mux.h>
5 ]# D7 }0 x8 T+ e& D2 I y }8 g6 G) z# A4 W
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 p% u. L& N' m" r* j
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 y4 T+ q) b% a9 _7 A5 z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), D" O2 m; v; M4 I- o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* e) P/ i" f4 N! t$ {- a' |) s: i6 K8 T; W1 t K
/* assign the tl som board LED-GPIOs*/: e5 g, |! x9 R
static const short da850_evm_tl_user_led_pins[] = {
8 i5 [- v; j% J4 s /* These pins are definition at <mach/mux.h> file */; f f) X2 ^- K5 r6 D2 W3 X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, Q; a* \( ?% J, Z
-1
% \7 h# c) B+ [) v1 w3 z};; `# T2 [& @( e# l9 q/ s
4 d I# ^0 l- X& Z$ ]static struct gpio_led da850_evm_tl_leds[] = {
' h4 u# s. o. n" \/ a9 j( K* X {
, P% a7 Y$ K. Q5 {& z9 Z! v. [ .active_low = 0,
9 N% o" c; t7 |! J$ q3 h6 L% I .gpio = DA850_USER_LED0,
4 l2 W$ y w {$ O .name = "user_led0",4 X X' O' a b
.default_trigger = "default-on",+ V. C7 H. p. u9 U1 c+ V1 X
},
+ y+ w: D2 Z8 g Y' e9 i {
% S% n- ^6 |, S .active_low = 0,4 W: K% x' x1 u0 a
.gpio = DA850_USER_LED1,
R) G: O G1 f8 ?" r. C7 R .name = "user_led1",: r7 M# N5 i, M- [
.default_trigger = "default-on",
# Z8 N; X0 d0 F, S& n; ~ },+ `2 S6 W' j( }& J: I
{' x- ?, {- `7 a/ A/ } H
.active_low = 0,) R- o: X" J+ `# ]0 w+ e/ j
.gpio = DA850_USER_LED2,
. e9 X6 m1 S6 J* \ .name = "user_led2",) Z; U3 v$ A9 X
.default_trigger = "default-on",8 r6 o0 A& j8 i: \5 ^9 h m
},
6 J+ a- \" G# l! _! G1 N {1 C/ d; }. P5 P5 \) @5 @3 u9 h
.active_low = 0," D4 C9 ~2 @6 I Y4 o
.gpio = DA850_USER_LED3,0 m& F. H% X& b- \, O' G
.name = "user_led3",
* c' w5 {# [+ Q5 z9 s .default_trigger = "default-on",
7 U6 ] x/ r; r/ n) j% H3 F },4 q$ L+ {: A. P1 F+ p' l
};6 G: w9 x- h: h5 ^8 J4 E
0 A/ Y6 \2 b5 p# V; p. {: ^: g1 Wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. k+ d j% R% }- e0 q4 H4 P6 A+ v
.leds = da850_evm_tl_leds,4 Y7 _4 ]9 ~ _+ f. b) R3 ^/ s
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ @5 R2 d3 Y1 @. J+ P
};: u: R* M( W2 }; D
" l" B2 U4 V% Q2 y8 Z# a6 Hstatic void led_dev_release(struct device *dev)% X# F! d& |. `7 f n
{
' x z: i) Q& |/ S. j};
+ J$ l4 c- I$ X5 F1 A* n6 G4 S) z9 } { w2 L5 H( k
static struct platform_device da850_evm_tl_leds_device = {
4 |% d. T* }' N" H) D .name = "leds-gpio",
- Q' g5 P" I n' O .id = 1,! ~0 A5 Q7 }) ^3 @+ u
.dev = {# `8 I {- A& q
.platform_data = &da850_evm_tl_leds_pdata,
, ~2 m- d, _; A3 f) z7 r .release = led_dev_release,
0 j7 ~0 o0 z9 _) ` }$ ^$ C$ i; ]+ m, m% ^" P
};6 Y* U2 `1 U# z0 N( |/ l
: G6 s+ R6 a: N$ v" ?% Estatic int __init led_platform_init(void)
& ~. |+ E( [7 J' r- U( M{! y; Z9 L8 d& H
int ret;
/ G* k& N: m& r#if 0
/ u/ E" c$ {: c ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ b6 Q) J- \2 T) h9 U! T$ w4 e
if (ret); p; o" z/ c. u3 R4 ^- n) {
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; ~# T6 f; Z: O* T- _7 Z" P0 |7 N "%d\n", ret);
3 x/ Q2 e, g! G; h#endif9 P* Q. r& m" \
ret = platform_device_register(&da850_evm_tl_leds_device);8 |+ y3 a& C6 s: p* v$ c/ O
if (ret)
( s2 A2 m9 o$ ~! J# K2 ~, P# B pr_warning("Could not register som GPIO expander LEDS");
/ U4 f) q6 S5 r% F else
* y& r3 V. A( t! ~, w1 g printk(KERN_INFO "LED register sucessful!\n");
p- u, s6 _" L* p: d) g0 k7 ]! b/ J5 ]1 _9 ?) ~6 }
return ret;
1 B, c2 E* C) W; J- O9 n& B}: H- `; j' s/ u6 y
8 m) U) K+ v3 mstatic void __exit led_platform_exit(void)* _3 e5 e4 D+ |; d) `
{
, @1 [( U7 x# K* K8 q' l platform_device_unregister(&da850_evm_tl_leds_device);
- _+ D! a7 y# L5 i- l7 m
# U# i: D* l+ c& | [( o2 L9 | printk(KERN_INFO "LED unregister!\n");6 f# Q, a( W, y: @- { u
}' j2 D) M% e8 s) G+ R$ f
: j8 t! Y. o; U
module_init(led_platform_init);( C2 u1 q- S" s8 r! H- m% B6 H5 p9 `
module_exit(led_platform_exit);/ [2 o0 O2 F; [9 W* a% c
+ F1 P4 f) m. W" R, o4 D6 e
MODULE_DESCRIPTION("Led platform driver");& B# Y; h# f8 v/ ?* `
MODULE_AUTHOR("Tronlong");
% q4 j4 \9 m2 l+ XMODULE_LICENSE("GPL");
8 x# I! X* ?/ V2 o* H
) M# u: S( P4 A& _5 P |
|