|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. b* a& @, x5 x) D& ^9 A#include <linux/init.h>7 o' z: K4 v% h" R$ {# d5 x% D
#include <linux/module.h>
! ?9 Z6 U }3 @' H+ ]- {' r#include <linux/kernel.h>- }- a5 l8 i) V! i' ?
#include <linux/types.h>
8 Z4 O: y; r6 |! X3 ~( g" H* ]#include <linux/gpio.h>
9 E5 C( f! w6 Z6 f9 \! @- `7 ^3 k#include <linux/leds.h>
! a5 q& Z+ ~1 i, ~( `* S) n$ C, T#include <linux/platform_device.h>9 @# r0 d% @7 f) i% `: B2 p
& F2 a' b6 ?, _9 H. O2 _& s$ i& Z9 Z#include <asm/mach-types.h>4 B. `# h; E+ S
#include <asm/mach/arch.h>
$ g1 {' U: b7 k6 y8 p8 s#include <mach/da8xx.h>8 O0 v O6 U5 m
#include <mach/mux.h>; T7 o2 P6 I9 U3 z
9 a3 F) N) _/ L& p2 n; @#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). p4 R6 n1 ?. n6 c. b, w: Z9 E
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" G) i7 k7 M0 G* Z& }; }
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 s1 [# a, m$ L( j: i- _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
k* {: K* d5 _6 N/ a7 U, z9 G6 |
/* assign the tl som board LED-GPIOs*/8 u) O/ R8 x1 g: o" p3 V& z |! U
static const short da850_evm_tl_user_led_pins[] = {
0 G) i! ]4 `+ a9 ? /* These pins are definition at <mach/mux.h> file */
( H+ ]. _6 ]. F2 N" G( u1 e DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 n( ]3 P; O2 ~/ ]% S
-1
7 l) E/ H% R( i% h};3 x2 O+ W" H s! h
* d# d/ e4 K# ~: ?* astatic struct gpio_led da850_evm_tl_leds[] = {
6 T8 y, J8 m0 P' m" a6 ]5 e {
/ `4 y2 P# ]$ g .active_low = 0,
! ^# L/ S3 R8 x% ~- ]0 a5 x .gpio = DA850_USER_LED0,
, m/ d0 S, C, h- i .name = "user_led0",; ^$ @. k/ N# f
.default_trigger = "default-on",
3 L( o/ k( V, A6 y, ]# @ },
* a" v4 r9 \1 I' g. z( X {
3 }% a/ S W3 i3 B& C$ g .active_low = 0,
3 N: A) {! J# X7 O5 P) S* l( Q. x" t .gpio = DA850_USER_LED1,4 q7 j/ d/ T0 {! g1 j1 B2 `- j- m# Z( I
.name = "user_led1",
* j1 I& X' H0 ] E2 A! c) p .default_trigger = "default-on",- h1 y ?6 k* Q% \8 W! N
},! s) f5 f! {2 |- [7 x* N
{9 H6 ?7 h3 Q. }& B/ S) O
.active_low = 0,; z6 V1 K1 r7 F
.gpio = DA850_USER_LED2,9 e1 h3 q" d* U3 |
.name = "user_led2",
: t: [' v: E; F9 h& @5 r .default_trigger = "default-on",+ B ]! M* O f
},
1 t% H4 k8 r9 q3 M8 k- F) O+ L3 k! g {
# ]! F0 y& K$ M6 w7 R+ m) y% m2 x- p .active_low = 0,. b* @' p1 Y/ Q/ Y
.gpio = DA850_USER_LED3,- P! u8 |3 b: c
.name = "user_led3",
/ y; ~8 R8 P9 m0 x .default_trigger = "default-on",
2 i' b) h( ~4 r$ e$ b7 I) [* H },
7 X. V% C7 t0 n# Q};
5 e8 S/ m2 A0 J
9 c, Q. y2 V* J. |% ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 N/ v4 M5 x1 c Y
.leds = da850_evm_tl_leds,* p2 k5 O/ a% h, J$ }
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),! c% \( M- Q4 ^; H. H
};
2 m# F8 ]6 S" o' i7 F, E
% v: Z- X3 D, S/ d4 P+ U; ustatic void led_dev_release(struct device *dev), a z5 Z0 w4 D9 ]5 m! j' i
{
J( K! C$ @( r6 t! m};
. s- O3 X0 K! i% ^+ w
5 s" n; @+ j: h: |( {% l% Rstatic struct platform_device da850_evm_tl_leds_device = {$ b( o- V: Y( H2 N0 A: H z
.name = "leds-gpio",4 V9 n: b" h. p
.id = 1,
4 ], L6 g! F) A ?# ]+ P .dev = {
" g& ]9 y$ ~$ }. z# X5 V6 H .platform_data = &da850_evm_tl_leds_pdata,; S& ?+ e S. `$ M
.release = led_dev_release,
! O9 N+ G# A& `" S }; K0 Q( Y1 u( P3 t
};& g& Q0 u( }7 ?$ f+ k C5 X8 p
8 \: ~- _5 k5 [% o$ Ustatic int __init led_platform_init(void)
# W. F1 } `1 t% o' D. N{9 F+ O" ] @ u3 ^1 ^4 j# I
int ret;
* H% b/ F& Q" i7 j3 o+ L#if 0
4 V. D% l" d5 O ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) ^# e3 `& {4 G& b/ M
if (ret)
) N, K" Y* T+ x pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 m5 g5 ~- ~9 J2 m* @' D "%d\n", ret);
+ O# R1 H* {1 X" ~$ s( d' T#endif' {# U; ?1 m% h, W4 r+ j
ret = platform_device_register(&da850_evm_tl_leds_device);
4 F! ]3 _6 f- \ if (ret)8 |6 t6 Q* H' W) U
pr_warning("Could not register som GPIO expander LEDS");0 D7 c; T) E) S9 A
else
' ?9 C; s K- \ printk(KERN_INFO "LED register sucessful!\n");
1 i9 a, o9 l9 d+ k' Z" r+ c- {! n& H$ `6 ]/ S Y
return ret;$ k5 E6 o' I; N" L7 G
}& S: p- w) @4 F$ v
. [/ e2 j z/ V9 Vstatic void __exit led_platform_exit(void)
7 d9 y# v# D w ~# l{
3 X# M/ c. g6 _/ d$ W$ X, n y! {% U platform_device_unregister(&da850_evm_tl_leds_device);' L/ y9 m. h0 y4 `
" X8 S4 L! ~ Q9 w9 I1 J8 o& q
printk(KERN_INFO "LED unregister!\n");
' b1 I& [; u3 b( X i1 s}% a+ l m2 L2 t U5 z
+ [; z! [1 g( e4 K$ c# }. m
module_init(led_platform_init);
2 Z7 h8 z6 l1 W% p# @module_exit(led_platform_exit);) F: d( H1 _! o; f+ j; u2 ^# Z
# T0 s% u1 w' [8 WMODULE_DESCRIPTION("Led platform driver");
4 }' c. s% [: y f, y, KMODULE_AUTHOR("Tronlong");! U, |, u$ I& Y# Q: K! w" a
MODULE_LICENSE("GPL");9 I) O7 U- w$ v( ~- v Y
0 C7 Q! ]8 V+ N" v |
|